Area Feature Name/Description Modification

nickgoodliff
Global Mapper UserTrusted User
in SDK
I need to alter the name and description for some area features based on some attribute, so that my export to KML will display correctly.
I have tried the following:
But my changes never seem to be saved, and I end up with a load of area features with "Unknown Area Type" as the description and no name.
Cheers
Nick
I have tried the following:
IntPtr theLayerHandlePtr = (IntPtr)(theLayerList.ToInt64() + i * IntPtr.Size);
IntPtr theLayerHandle = Marshal.PtrToStructure<IntPtr>(theLayerHandlePtr);
// Add the layer
// Get the layer info and copy it into our structure
GlobalMapperDLLWrapper.GM_LayerInfo_t theLayerInfo = new GlobalMapperDLLWrapper.GM_LayerInfo_t();
IntPtr theInfoPtr = GlobalMapperDLL.GM_GetLayerInfo(theLayerHandle);
theLayerInfo = Marshal.PtrToStructure<GM_LayerInfo_t>(theInfoPtr);
for (uint x = 0; x < theLayerInfo.mNumAreas; x++)
{
GM_AreaFeature_t areaFeature = new GM_AreaFeature_t();
IntPtr areaFeaturePtr = GlobalMapperDLL.GM_GetAreaFeature(theLayerHandle, x);
areaFeature = Marshal.PtrToStructure<GM_AreaFeature_t>(areaFeaturePtr);
var attrs = areaFeature.mFeatureInfo.getAttrValueList();
areaFeature.mFeatureInfo.mDesc = "";
foreach (var attr in attrs)
{
if (attr.mName == "NTM_ID")
areaFeature.mFeatureInfo.mName = attr.mVal;
areaFeature.mFeatureInfo.mDesc += attr.mName + ": " + attr.mVal + "<br />";
}
Marshal.StructureToPtr<GM_AreaFeature_t>(areaFeature, areaFeaturePtr, true);
}
But my changes never seem to be saved, and I end up with a load of area features with "Unknown Area Type" as the description and no name.
Cheers
Nick
Answers
-
I took a quick look at your code, and I didn't see anything that was obviously wrong. I recommend that you send an e-mail describing your problem to Blue Marble Geographics Support (geohelp@bluemarblegeo.com). This will ensure that the Developer Support team sees the problem and can provide you with a timely response. Thank you.
-
Hey I was working on some things with the SDK and thought about this question, If you haven't had it answered yet. If you want your layer description changes to be saved you should be using the function:
/// <summary>/// Sets the description for the layer/// </summary>/// <param name="aLayer">Layer to set description for</param>/// <param name="aDesc">Description to use (pass NULL to restore default)</param>/// <returns></returns>[DllImport(DLLFileName, EntryPoint = "GM_SetLayerDescription")]public static extern GM_Error_t32 GM_SetLayerDescription(GM_LayerHandle_t32 aLayer, // layer to set description forString aDesc // description to use (pass NULL to restore default));
If that function does not exist in the global mapper wrapper then add the above under the GlobalMapperDLL class in that file.
Hopefully that helps -
Thanks Aaron, but this is not quite what I am after. I need to set the name and description of each Area Feature in a layer, not the whole layer itself.
If there is anything you can do help on this that would be great.
Nick -
oops, I read part of the code wrong. I haven't played with this function yet but it might be what you are looking for:
/// <summary>/// Sets the list of attribute/values to use for the specified feature./// </summary>/// <param name="aLayer">IN: Layer the feature is in</param>/// <param name="aFeatureClassType">IN: Type of feature class (area, point, line)</param>/// <param name="aFeatureIndex">IN: Index of feature in layer</param>/// <param name="aAttrList">IN: New list of attributes to associate with feature</param>/// <param name="aNumAttrs">IN: Number of attributes in aAttrList</param>[DllImport(DLLFileName, EntryPoint = "GM_SetFeatureAttrList")]public static extern GM_Error_t32 GM_SetFeatureAttrList(GM_LayerHandle_t32 aLayer, // IN: Layer the feature is inGM_FeatureClassType_t8 aFeatureClassType, // IN: Type of feature class (area, point, line)UInt32 aFeatureIndex, // IN: Index of feature in layerIntPtr aAttrList, // (GM_AttrValue_t)IN: New list of attributes to associate with featureUInt16 aNumAttrs // IN: Number of attributes in aAttrList);
Again I haven't done anything with this function but if you add it to the wrapper in the same place I mentioned the other this should be what you are looking for. -
Hi Aaron,
I checkout the GlobalMapperInterface.h file and found a couple more functions that I have added to my c# wrapper:// Sets the description to use for the feature.GM_DLL_EXPORTED GM_Error_t32 __stdcall GM_SetFeatureDescription(GM_LayerHandle_t32 aLayer, // IN: Layer the feature is inGM_FeatureClassType_t8 aFeatureClassType, // IN: Type of feature class (area, point, line)uint32 aFeatureIndex, // IN: Index of feature in layerconst char* aDesc // IN: New description for feature (NULL to reset to default));// Sets the display label to use for the feature.GM_DLL_EXPORTED GM_Error_t32 __stdcall GM_SetFeatureLabel(GM_LayerHandle_t32 aLayer, // IN: Layer the feature is inGM_FeatureClassType_t8 aFeatureClassType, // IN: Type of feature class (area, point, line)uint32 aFeatureIndex, // IN: Index of feature in layerconst
The top one works perfectly and allows me to add info that is used for the KMZ export. The bottom one, SetFeatureLabel doesn't seem to do anything.
It would be great if there was a function for GM_SetFeatureName as that is all that I am missing!
Cheers
Nick
Categories
- 12.9K All Categories
- 5.7K Features Discussion
- 346 Downloading Imagery
- 1.3K Elevation Data
- 385 Georeferencing Imagery Discussion
- 646 GM Script Language
- 54 User Scripts
- 115 GPS Features
- 419 Projection Questions
- 833 Raster Data
- 1.4K Vector Data
- 6.6K Support
- 180 Announcement and News
- 929 Bug Report
- 561 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 577 Other Discussion
- 132 GIS Data Sources
- 27 Global Mapper Showcase
- 244 How I use Global Mapper
- 108 Global Mapper Forum Website