SDK 18-1 .NET Wrapper
Hi,
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.
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.
Answers
-
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.
-
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 BGM_Utility.GetPathProfileLOSEx(LayersAB, ref theParams);float[] theOutElevationsAB = theParams.mElevList;// Get Path Profiles from Layers C and DGM_Utility.GetPathProfileLOSEx(LayersCD, ref theParams);float[] theOutElevationsCD = theParams.mElevList; -
Thank you!
Categories
- 12.8K All Categories
- 5.7K Features Discussion
- 345 Downloading Imagery
- 1.3K Elevation Data
- 385 Georeferencing Imagery Discussion
- 638 GM Script Language
- 54 User Scripts
- 115 GPS Features
- 417 Projection Questions
- 826 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 178 Announcement and News
- 914 Bug Report
- 558 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 569 Other Discussion
- 131 GIS Data Sources
- 27 Global Mapper Showcase
- 238 How I use Global Mapper
- 107 Global Mapper Forum Website