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!



Mapping Earthquake Deformation in Taiwan With ENVI

Mapping Earthquake Deformation in Taiwan With ENVI

12/15/2025

Unlocking Critical Insights With ENVI® Tools Taiwan sits at the junction of major tectonic plates and regularly experiences powerful earthquakes. Understanding how the ground moves during these events is essential for disaster preparedness, public safety, and building community resilience. But traditional approaches like field... Read More >

Comparing Amplitude and Coherence Time Series With ICEYE US GTR Data and ENVI SARscape

Comparing Amplitude and Coherence Time Series With ICEYE US GTR Data and ENVI SARscape

12/3/2025

Large commercial SAR satellite constellations have opened a new era for persistent Earth monitoring, giving analysts the ability to move beyond simple two-image comparisons into robust time series analysis. By acquiring SAR data with near-identical geometry every 24 hours, Ground Track Repeat (GTR) missions minimize geometric decorrelation,... Read More >

Empowering D&I Analysts to Maximize the Value of SAR

Empowering D&I Analysts to Maximize the Value of SAR

12/1/2025

Defense and intelligence (D&I) analysts rely on high-resolution imagery with frequent revisit times to effectively monitor operational areas. While optical imagery is valuable, it faces limitations from cloud cover, smoke, and in some cases, infrequent revisit times. These challenges can hinder timely and accurate data collection and... Read More >

Easily Share Workflows With the Analytics Repository

Easily Share Workflows With the Analytics Repository

10/27/2025

With the recent release of ENVI® 6.2 and the Analytics Repository, it’s now easier than ever to create and share image processing workflows across your organization. With that in mind, we wrote this blog to: Introduce the Analytics Repository Describe how you can use ENVI’s interactive workflows to... Read More >

Deploy, Share, Repeat: AI Meets the Analytics Repository

Deploy, Share, Repeat: AI Meets the Analytics Repository

10/13/2025

The upcoming release of ENVI® Deep Learning 4.0 makes it easier than ever to import, deploy, and share AI models, including industry-standard ONNX models, using the integrated Analytics Repository. Whether you're building deep learning models in PyTorch, TensorFlow, or using ENVI’s native model creation tools, ENVI... Read More >

1345678910Last
9997 Rate this article:
No rating

Implicit Get/SetProperty calls in user-defined classes, part II

Anonym

In this post, I showed a demonstration of how to use the implicit Get/SetProperty call allowed by subclasses of IDL_Object, using existing Object Graphics classes as the basis. Here, I’d like to go a little further: I’ll write a class that inherits from IDL_Object and implements its own Get/SetProperty methods, then show how the implicit call works with them. The class Integer represents a single long integer value. Start with the class data definition, nothing that we inherit from IDL_Object:

pro integer__define
   compile_opt idl2

   !null = {integer, inherits idl_object, value:0L}
end

Recall that to work seamlessly with IDL’s calling mechanism, this routine should be the last in the file and its methods should be listed before/above it in the file. Next, the Init method, where the user can initialize an Integer to a value (otherwise, the default value of 42 is used):

function integer::init, value=v
   compile_opt idl2

   self.value = ~isa(v, /number) || ~isa(v, /scalar) ? 42L : v
   return, 1
end

Note that, counter to standard technique, it’s not necessary to call IDL_Object::Init from here. For simplicity (and because there’s nothing to clean up), I’ll not write a Cleanup method for this class. Next, the GetProperty and SetProperty methods, which are straightforward:

pro integer::getproperty, value=v
   compile_opt idl2

   if arg_present(v) then v = self.value
end 

pro integer::setproperty, value=v
   compile_opt idl2

   if v ne !null then self.value = v
end

At this point, let’s stop and create an instance of Integer, int1:

IDL> int1 = integer(value=5)

and then perform a few simple diagnostics on it to check that everything is working correctly:

IDL> help, int1
INT1            OBJREF    = 
IDL> print, int1

IDL> print, isa(int1, 'Integer')
    1

Now, get the value of the Integer int1. Prior to IDL 8, this required an explicit call to Integer::GetProperty, like this:

IDL> int1->getproperty, value=v1
IDL> print, v1
       5

whereas IDL 8 allows an implicit call to GetProperty when using the dot “.” operator:

IDL> print, int1.value
       5

Note that the keyword name in the GetProperty formal parameter list is what is used in the implicit call. Had, for example, the keyword instead been named TH3_$VALUE, the implicit call to GetProperty would be int1.th3_$value. Analogous syntax holds for the Integer::SetProperty method. For example, use the IDL 8 syntax to change the value of int1 to 7:

IDL> int1.value = 7
IDL> print, int1.value
       7

The implicit calls to Get/SetProperty only work for subclasses of IDL_Object. Also, this does not change the fact that instance variables in IDL are protected. In my opinion, this syntax is more elegant and easier to use than an explicit call to a Get- or SetProperty method. But we can go further! What I’ll do next overlaps with the description and example of operator overloading that Mike Galloy gave some time ago, but it feels natural to extend the present example a bit further. Here, we’ll overload the PRINT procedure and the plus sign “+” for Integer. First, overload PRINT by overriding the IDL_Object::_overloadPrint method:

function integer::_overloadprint
   compile_opt idl2

   return, self.value
end

Now when we print an Integer we get its value instead of some cryptic reference to an object heap variable:

IDL> print, int1
       7

Next, overload the plus operator “+” so that we can add two Integers:

function integer::_overloadplus, left, right
   compile_opt idl2

   if ~isa(left, obj_class(self)) || ~isa(right, obj_class(self)) then $
      return, obj_new() $
   else $
      return, integer(value=left.value + right.value)
end

The parameters left and right are inherited from the IDL_Object::_overloadPlus method: they represent the two Integer objects to be added. They’re tested to make sure they’re Integers. If they are, the implicit GetProperty call is used to get their values, the sum of which is used to make a new Integer, which is returned. For example, define another Integer, int2, and add it to int1 to get a third Integer, int3:

IDL> int2 = integer(value=3)
IDL> int3 = int1 + int2
IDL> print, int3
       10

This operation wouldn’t be possible without operator overloading. A complete list of operators than can be overloaded in a user-defined class can be found in the IDL Help; search for “overload.” You can download the complete, IDLdoc-ed code for this Integer class from here.

Please login or register to post comments.