Global Mapper v25.0

The function GM_GetAreaFeature doesn't work!

JerryLia
JerryLia Global Mapper User
edited September 2007 in Technical Support
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? }
}
}

:confused:

Comments

  • global_mapper
    global_mapper Administrator
    edited September 2007
    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