The function GM_GetAreaFeature doesn't work!
JerryLia
Global Mapper User
I do what you say,first,I declare the GM_GetAreaFeature function such as:
[DllImport(DLLFileName, EntryPoint = "GM_GetAreaFeature")]
public static extern GM_AreaFeature_t GM_GetAreaFeature(IntPtr aLayerHandle, UInt32 aAreaIndex);
after that I count the number of polygon in a layer with it,the code is followed:
private void Menu_Counter_Click(object sender, EventArgs e)
{
bool lb_Loop = true;
GM_AreaFeature_t lt_AreaFeature;
//UInt32 i = 1;
//while (lb_Loop)
//{
// lt_AreaFeature = GlobalMapperDLL.GM_GetAreaFeature(m_OpenLayerPtr, i);
// i++;
// //if (lt_AreaFeature. == null)
// // lb_Loop = false;
//}
for (int i = 0;i< clsGlobalVARS.LayerHandles.Count; i++)
{
UInt32 j = 0;
IntPtr LayerPtr;
while(lb_Loop)
{
LayerPtr=(IntPtr)clsGlobalVARS.LayerHandles;
lt_AreaFeature = GlobalMapperDLL.GM_GetAreaFeature(LayerPtr, j);//an error ocurs:"The type signature is uncompatible with PInvoke of the method"
GlobalMapperDLL.GM_FreeAreaFeature(LayerPtr);
j++;
//How to know that the loop will be ended? }
}
}
[DllImport(DLLFileName, EntryPoint = "GM_GetAreaFeature")]
public static extern GM_AreaFeature_t GM_GetAreaFeature(IntPtr aLayerHandle, UInt32 aAreaIndex);
after that I count the number of polygon in a layer with it,the code is followed:
private void Menu_Counter_Click(object sender, EventArgs e)
{
bool lb_Loop = true;
GM_AreaFeature_t lt_AreaFeature;
//UInt32 i = 1;
//while (lb_Loop)
//{
// lt_AreaFeature = GlobalMapperDLL.GM_GetAreaFeature(m_OpenLayerPtr, i);
// i++;
// //if (lt_AreaFeature. == null)
// // lb_Loop = false;
//}
for (int i = 0;i< clsGlobalVARS.LayerHandles.Count; i++)
{
UInt32 j = 0;
IntPtr LayerPtr;
while(lb_Loop)
{
LayerPtr=(IntPtr)clsGlobalVARS.LayerHandles;
lt_AreaFeature = GlobalMapperDLL.GM_GetAreaFeature(LayerPtr, j);//an error ocurs:"The type signature is uncompatible with PInvoke of the method"
GlobalMapperDLL.GM_FreeAreaFeature(LayerPtr);
j++;
//How to know that the loop will be ended? }
}
}
Comments
-
Your declaration is incorrect. The GM_GetAreaFeature function returns a pointer to a GM_AreaFeature_t type (GM_AreaFeature_t*) and not an actual GM_AreaFeature_t object. You should make your return type reflect that (maybe an IntPtr that has to be marshalled to a local instance of the object?) and then you'll be ok.
To terminate the loop, either wait for NULL to be returned, or you can call GM_GetLayerInfo and just loop from 0 to mNumAreas from the structure returned by that call.
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Support
support@globalmapper.com
Categories
- 12.7K All Categories
- 5.6K Features Discussion
- 342 Downloading Imagery
- 1.3K Elevation Data
- 380 Georeferencing Imagery Discussion
- 628 GM Script Language
- 53 User Scripts
- 113 GPS Features
- 414 Projection Questions
- 819 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 177 Announcement and News
- 908 Bug Report
- 558 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 562 Other Discussion
- 129 GIS Data Sources
- 27 Global Mapper Showcase
- 233 How I use Global Mapper
- 107 Global Mapper Forum Website