X

NV5 Geospatial Blog

Each month, NV5 Geospatial posts new blog content across a variety of categories. Browse our latest posts below to learn about important geospatial information or use the search bar to find a specific topic or author. Stay informed of the latest blog posts, events, and technologies by joining our email list!



Geo Sessions 2025: Geospatial Vision Beyond the Map

Geo Sessions 2025: Geospatial Vision Beyond the Map

8/5/2025

Lidar, SAR, and Spectral: Geospatial Innovation on the Horizon Last year, Geo Sessions brought together over 5,300 registrants from 159 countries, with attendees representing education, government agencies, consulting, and top geospatial companies like Esri, NOAA, Airbus, Planet, and USGS. At this year's Geo Sessions, NV5 is... Read More >

Not All Supernovae Are Created Equal: Rethinking the Universe’s Measuring Tools

Not All Supernovae Are Created Equal: Rethinking the Universe’s Measuring Tools

6/3/2025

Rethinking the Reliability of Type 1a Supernovae   How do astronomers measure the universe? It all starts with distance. From gauging the size of a galaxy to calculating how fast the universe is expanding, measuring cosmic distances is essential to understanding everything in the sky. For nearby stars, astronomers use... Read More >

Using LLMs To Research Remote Sensing Software: Helpful, but Incomplete

Using LLMs To Research Remote Sensing Software: Helpful, but Incomplete

5/26/2025

Whether you’re new to remote sensing or a seasoned expert, there is no doubt that large language models (LLMs) like OpenAI’s ChatGPT or Google’s Gemini can be incredibly useful in many aspects of research. From exploring the electromagnetic spectrum to creating object detection models using the latest deep learning... Read More >

From Image to Insight: How GEOINT Automation Is Changing the Speed of Decision-Making

From Image to Insight: How GEOINT Automation Is Changing the Speed of Decision-Making

4/28/2025

When every second counts, the ability to process geospatial data rapidly and accurately isn’t just helpful, it’s critical. Geospatial Intelligence (GEOINT) has always played a pivotal role in defense, security, and disaster response. But in high-tempo operations, traditional workflows are no longer fast enough. Analysts are... Read More >

Thermal Infrared Echoes: Illuminating the Last Gasp of a Dying Star

Thermal Infrared Echoes: Illuminating the Last Gasp of a Dying Star

4/24/2025

This blog was written by Eli Dwek, Emeritus, NASA Goddard Space Flight Center, Greenbelt, MD and Research Fellow, Center for Astrophysics, Harvard & Smithsonian, Cambridge, MA. It is the fifth blog in a series showcasing our IDL® Fellows program which supports passionate retired IDL users who may need support to continue their work... Read More >

1345678910Last
«August 2025»
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
10700 Rate this article:
No rating

The Case For Static Methods

Anonym

A new feature introduced in IDL 8.3 is the ability to create static methods on IDL objects. For those new to the world of Object Orientated programming, static methods are essentially a normal IDL function, except the function is attached to an object.  Let's take a look at a simple object definition:

function STATICEXAMPLE::doit, x

  compile_opt idl2

 

  return, x/2

end

 

pro STATICEXAMPLE__define

  compile_opt idl2

 

  self = { staticexample, $

           inherits IDL_OBJECT, $

           _count: 0b $  ; "unused" member variable

         }

end

In this example, our object has a function DOIT which doesn't actually depend on any member variables or other functions defined by our object. Traditionally, to call this method you would have to do the following:

obj = StaticExample()

obj.doit(2)

However, since DOIT doesn't actually depend on the state of the object or use methods defined on the object, it makes sense to mark DOIT as a static function to give it greater usability. We can do this by adding the static flag to the DOIT compile_opt:

function STATICEXAMPLE::doit, x

  compile_opt idl2, static

By marking the method as static, I can now reference the method in a single call:

StaticExample.doit(2)

Or if you have a STATICEXAMPLE object already:

obj.doit(2)

Note: It is best to avoid calling static methods this way.  It is a lot easier to read your code if you don't have to double check every method to see if it is static or not.

" OK, but what benefit does marking a function as static give me?"

1.       The ability to group functionality into a single object. 

For example, say you have two sets of function to read and process different file formats: ff1_Read(), ff1_Process(), ff2_Read(), ff2_Process(). I can use static methods to group functionality into meaningful objects. In this case, I would choose to group my methods by functionality to create READ and PROCESS objects. So my calls would now be: Read.ff1(), Read.ff2(), Process.ff1(), Process.ff2().  This, in turn, leads to...

2.       Content assist! 

By converting your functions into static methods you can use content assist to help find that function call. Now, when working in the workbench, I can press CTRL+Space on my Read or Process objects and find all the file formats which I can open or process. 

3.       Avoid naming conflicts. 

When IDL compiles a function, it uses the code of the first function which matches the name of the compiled function. As such, if you have a function called Colortable and IDL releases a new function called Colortable, one set of functionality will be unaccessable depending on the ordering of your PATH (this has probably happened to you, and we are sorry for the confusion it causes). However, by wrapping your functionality under a static method, the chance of a namespace collision greatly reduces and leads us to...

4.       Libraries!

If you have a library (or even a bunch of useful functions) and you want to give to your coworker, with static methods you now have a dedicated object to contain all of your functions. So, instead of having an ugly tag hanging off the front of your functions (i.e. MyAwesomeCode_MyAwesomeFunction()) you can have a pretty object (i.e. MyAwesomeCode.MyAwesomeFunction()). Plus, it means your objects benefit from content assist, not having to worry about naming conflicts, pretty method names, and overall making your code more readable.

 

Pitfalls:

When using static methods there are a couple of things to be aware of. Static methods are not normal methods on objects.  They are not aware of any other methods or member variables.

 

Cheers!

Please login or register to post comments.