SDK 18-1 .NET Wrapper

obadaobada Posts: 5

I am trying to get path profile elevations using the new managed component for .NET users. It is working good for the most part; however, I don't seem to figure out a fix for the following two issues:

1- Loading a layer using GM_LayerList_t.LoadLayerList(....), then passing the output to GM_Utility.GetPathProfile(...) works fine; however, if NULL is passed to the function as the documentation suggests for top most loaded layers, I get "Object reference not set to an instance of an object" exception.

Working example:

theLayerList = GM_LayerList_t.LoadLayerList([fileName], GM_LoadFlags_t32.LoadFlags_HideAllPrompts);
var gmError = GM_Utility.GetPathProfile(theLayerList[0], lon1, lat1, lon2, lat2, out elevList, numSamplePoints, defaultVal);

Not working example:

theLayerList = GM_LayerList_t.LoadLayerList([fileName], GM_LoadFlags_t32.LoadFlags_HideAllPrompts);
var gmError = GM_Utility.GetPathProfile(null, lon1, lat1, lon2, lat2, out elevList, numSamplePoints, defaultVal);

2- Is there anyway to force GetPathProfile to look at a specific group of layers, not necessarily the top most ones, when getting the elevations. As far as I can tell, there are only two options: either passing a GM_Layer_t object representing one layer, or null for top most loaded layers. I am looking for a third option where I can get elevations given a specific group of loaded layers.

Assume I have two functions running at the same time. One gets elevations for path X from Layer A, and Layer B. The other one gets elevations for the same path X from Layer C, and Layer D. For this example, Layer A, B, C, and D are in the same area, but Layers C, D are from a different source than Layers A, B.

Since both functions are running at the same time, and I am using the top most loaded layers for getting elevations, there is a chance of Layers C, D being loaded on top of Layers A, B before elevations are retrieved from A, B, and vice versa.

How do you fix this race condition issue?

You help is much appreciated. Thanks a lot in advance.

Best Answers

  • aaroncaaronc Posts: 22
    Answer ✓
    Yes, this looks like a bug. The null case was simply never checked for. It has been fixed but the fix won't be available Online immediately so I will send you the dll directly for now.  The install should be updated with the latest build later today.
  • aaroncaaronc Posts: 22
    Answer ✓
    Just a note, The current download for the site should contain that bug fix of the first part of your question.

    After dealing with the first part I somehow missed the second part of your question:

    GM_Utility.GetPathProfileLOSEx should give you the ability to pass in multiple layers it performs both a Path profile and a line of sight analysis but the LOS can be ignored.

    Here is a sample of how you could get the values:

                    GM_PathProfileLOSParams_t theParams = new GM_PathProfileLOSParams_t();
                    theParams.mStartX = startX;
                    theParams.mStartY = startY;
                    theParams.mEndX = endX;
                    theParams.mEndY = endY;
                    theParams.mDfltElev = defaultElevation;
                    theParams.mListSize = theNumElevationPoints;

                    // Get Path Profiles from Layers A and B
                    GM_Utility.GetPathProfileLOSEx(LayersAB, ref theParams);
                    float[] theOutElevationsAB = theParams.mElevList;

                    // Get Path Profiles from Layers C and D
                    GM_Utility.GetPathProfileLOSEx(LayersCD, ref theParams);
                    float[] theOutElevationsCD = theParams.mElevList;


Sign In or Register to comment.