Global Mapper v25.0

Avoid Projection Dialog

ikabott
ikabott Global Mapper UserTrusted User
edited December 2009 in SDK
Hi,

(1) I would like to set the default projection so the projection dialog does not show when I load a layer.

(2) I will almost always work with the RD (Dutch Grid) Proj. To create a GM_Projection_t, do I have to set the Proj, Datum, Unit, and all the attributes or is there any way to let the SDK fill those parametes (as the Projection dialog must do internally)?

Thanks a lot
Oscar

Comments

  • global_mapper
    global_mapper Administrator
    edited November 2009
    Oscar,

    What you can do is use the GM_SetQueryProjectionCallback function to provide your own function to call when the projection for a layer cannot automatically be determined. Then you just fill in the provided GM_Projection_t structure as below:

    aProj.mProjSys = GM_PRJ_DUTCH_GRID;
    aProj.mDatum = GM_DATUM_DUTCH;
    aProj.mUnits = GM_PRJ_UNITS_METERS;
    aProj.mNumAttrs = 0;

    When you use the GM_PRJ_DUTCH_GRID projection the parameters are implied.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • ikabott
    ikabott Global Mapper User Trusted User
    edited December 2009
    I am working in c#, I extended the wrapper in with the following function:

    [DllImport(DLLFileName, EntryPoint = "GM_SetQueryProjectionCallback")]
    public static extern void GM_SetQueryProjectionCallback(GM_QueryProjectionCallbackFunc aCallbackFunc);

    As expected, the GM_QueryProjectionCallbackFunc is unknown. The only reference I found in GlobalMapperInterface.h is:

    typedef boolean (__stdcall *GM_QueryProjectionCallbackFunc)
    (
    GM_Projection_t* aProj, // OUT: projection structure to fill in
    const GM_Point_t* aInitialPos, // IN: optional coordinate in projection
    GM_ElevUnits_t8* aElevUnits // OUT: optional, set to elevation
    );

    I don't know what to do with this, to tell you the truth.

    What kind of function must the callback be? Void? returning a projection?

    Thanks
    Oscar
  • ikabott
    ikabott Global Mapper User Trusted User
    edited December 2009
    Further information,

    I have created the type
    public delegate bool GM_QueryProjectionCallbackFunc(out GM_Projection_t aProj, GM_Point_t aInitialPos, out GM_ElevUnits_t8 aElevUnits) in the wrapper.

    In my application I set the callback as:
    GlobalMapperDLL.GM_QueryProjectionCallbackFunc myCallbackDelegate = new GlobalMapperDLL.GM_QueryProjectionCallbackFunc(setDutchProjection);
    GlobalMapperDLL.GM_SetQueryProjectionCallback(myCallbackDelegate);

    And the function itself is:
    private static bool setDutchProjection(out GM_Projection_t aProj, GM_Point_t aInitialPos, out GlobalMapperDLL.GM_ElevUnits_t8 aElevUnits)
    {
    aProj = new GM_Projection_t();

    aProj.mProjSys = PROJSYS.GM_PRJ_DUTCH_GRID;
    aProj.mDatum = DATUM.GM_DATUM_DUTCH;
    aProj.mUnit = UNIT.GM_PRJ_UNIT_METERS;
    aProj.mNumAttrs = 0;

    aElevUnits = GlobalMapperDLL.GM_ElevUnits_t8.GM_ElevUnit_Meters;

    return true;
    }

    All trying to imitate the GlobalMapperInterfac.h definition mentioned in the previous message.

    It launches a GM_LoadError when calling GM_LoadLayer

    Any idea?

    Thanks
    Oscar
  • global_mapper
    global_mapper Administrator
    edited December 2009
    Oscar,

    I think you are close, you just need to correct your callback function declaration. Try the following (note the pointer parameters should be 'ref' so that pointers are passed and the 'boolean' type in the SDK maps to 'Byte' in C#, not the C# 'bool' which is 4 bytes):


    // Message callback function declaration
    public delegate Byte GM_QueryProjectionCallbackDef
    (
    ref GM_Projection_t aProj, // OUT: projection structure to fill in
    ref GM_Point_t aInitialPos, // IN: optional coordinate in projection
    ref GM_ElevUnits_t8 aElevUnits // OUT: optional, set to elevation
    );

    [DllImport(DLLFileName, EntryPoint = "GM_SetQueryProjectionCallback")]
    public static extern void GM_SetQueryProjectionCallback
    (
    GM_QueryProjectionCallbackDef aCallBackFunc
    );


    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com