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!



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 >

Blazing a trail: SaraniaSat-led Team Shapes the Future of Space-Based Analytics

Blazing a trail: SaraniaSat-led Team Shapes the Future of Space-Based Analytics

10/13/2025

On July 24, 2025, a unique international partnership of SaraniaSat, NV5 Geospatial Software, BruhnBruhn Innovation (BBI), Netnod, and Hewlett Packard Enterprise (HPE) achieved something unprecedented: a true demonstration of cloud-native computing onboard the International Space Station (ISS) (Fig. 1). Figure 1. Hewlett... Read More >

NV5 at ESA’s Living Planet Symposium 2025

NV5 at ESA’s Living Planet Symposium 2025

9/16/2025

We recently presented three cutting-edge research posters at the ESA Living Planet Symposium 2025 in Vienna, showcasing how NV5 technology and the ENVI® Ecosystem support innovation across ocean monitoring, mineral exploration, and disaster management. Explore each topic below and access the full posters to learn... Read More >

Monitor, Measure & Mitigate: Integrated Solutions for Geohazard Risk

Monitor, Measure & Mitigate: Integrated Solutions for Geohazard Risk

9/8/2025

Geohazards such as slope instability, erosion, settlement, or seepage pose ongoing risks to critical infrastructure. Roads, railways, pipelines, and utility corridors are especially vulnerable to these natural and human-influenced processes, which can evolve silently until sudden failure occurs. Traditional ground surveys provide only periodic... Read More >

1345678910Last
«November 2025»
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
9662 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.