Global Mapper Pro

error in new loadrectifiedlayer

leex
leex Global Mapper User
edited November 2009 in SDK
Hi all,

I try to load a rectified layer but I receive an error and in debug I fing my list of GCPs become null. Please let me know what I am doing wrong.


LastGMError = GlobalMapperDLL.GM_LoadRectifiedLayer(m_strImgLayer,out pLayer, GlobalMapperDLL.GM_LoadFlags_t32.GM_LoadFlags_HideAllPrompts, gcps, 4, aproj);

Wrapper function:

[DllImport(DLLFileName, EntryPoint = "GM_LoadRectifiedLayer")]
public static extern GM_Error_t32 GM_LoadRectifiedLayer
(
string aFilename,
out GM_LayerHandle_t32 aLayer,
GM_LoadFlags_t32 aLoadFlags,
GM_GroundControlPoint_t[] aGCPList,
UInt32 aNumGCPs,
GM_Projection_t aProj
);

Thanks in advance,
Florian

Comments

  • global_mapper
    global_mapper Administrator
    edited November 2009
    Florian,

    A see a couple of problems. First of all, you'll need to pass your GCP list as an IntPtr and create your in-memory array and pass in the address of it. You can't use a C# style array to pass directly to a C-style pointer like that.

    Also, your 'aProj' parameter should be declared as a 'ref' parameter so that the address of it will be passed.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • leex
    leex Global Mapper User
    edited November 2009
    Sorry Mike I am not a C developer. please you can tell me how I can receive a pointer of a GM structure, in that case GM_GroundControlPoint_t[] array.


    Many thanks,
    Florian
  • global_mapper
    global_mapper Administrator
    edited November 2009
    If you check the end of the Form1.cs file from the attached C# sample application you will find an example of calling the GM_AddAreaToVectorLayer function. The setup just before that sets up a mPointList value that is an IntPtr for an array of GM_Point_t structure. You can use the same technique for the GM_ControlPoint_t list.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • leex
    leex Global Mapper User
    edited November 2009
    Sorry Mike,

    Maybe I dont undestand very well, in your example:

    GM_Point_t theVertex = new GM_Point_t();
    for (UInt32 i = 0; i < theLineFeature.mNumPoints; i++)
    {
    IntPtr theVtxPtr = (IntPtr)( (UInt32)theLineFeature.mPointList + i * sizeof(GM_Point_t) );
    theVertex = (GM_Point_t)Marshal.PtrToStructure(theVtxPtr, typeof(GM_Point_t));
    }


    you receive a start IntPtr from theLineFeature.MpointList and after that you move in structure to find elements. I constract an array GM_GroundControlPoint_t[] and I dont know how to read
    the IntPtr of this array to pass it to a LoadRectifiedLayer function.


    Thanks,
    Florian


    I
  • global_mapper
    global_mapper Administrator
    edited November 2009
    Florian,

    You are looking at the wrong part of the sample code. Look at the bottom where 'theAreaPoints' array is setup, then assigned to an IntPtr in the line:

    theBuilding.mPointList = (IntPtr)thePointList;

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • leex
    leex Global Mapper User
    edited November 2009
    Thank you very much for your time.

    Florian
Sign In or Register to comment.