Global Mapper v25.0

GM_SelectProjection C# Wrapper

rmartinez
rmartinez Global Mapper User
edited October 2011 in SDK
Hello,

I am having trouble figuring out how to wrap the GM_SelectProjection method in C#. Below is my current wrapper function.


[DllImport(DLLFileName, EntryPoint = "GM_SelectProjection")]
public static extern GM_Error_t32 GM_SelectProjection(
ref GM_Projection_t aSelProj,
ref GM_Projection_t aInitProj);


The GM_Projection_t is as defined in the c# example that can be downloaded from the SDK.

// This type is used to describe a single projection attribute value
public struct GM_ProjAttrValue_t
{
public PROJATTR mAttr; // Attribute
public double mValue; // Attribute value
};

// This type is used to fully describe a projection.
public struct GM_Projection_t
{
public PROJSYS ProjSys; // Projection system
public DATUM Datum; // Horizontal datum
public UNIT Unit; // Ground units
public UInt32 NumAttrs; // Number of attributes in attribute list
public GM_ProjAttrValue_t Attr1; // Attribute value list items
public GM_ProjAttrValue_t Attr2; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr3; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr4; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr5; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr6; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr7; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr8; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr9; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr10; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr11; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr12; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr13; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr14; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr15; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
public GM_ProjAttrValue_t Attr16; // Pointer to attribute list. Pointer to GM_ProjAttrValue_t
};


This somewhat works but the attribute values of the aSelProj are zero, excluding the ZONE and GM_PRJ_ATTR_STATE_PLANE_SCALE_FACTOR, when I select the following projection.

Projection: State Plane Coordinate System
Zone: Texa South Central (FIPS 4204)
Datum: NAD27
Planar Units: FEET (US SURVEY)


Also, the number of attibutes aSelProj.NumAttrs = 6 but according to the "Select Projection" dialog it looks like there is 12 attributes.

I have tried other projection selections, but the attribute values do not seem to be correct. What am I doing wrong?

Comments

  • global_mapper
    global_mapper Administrator
    edited October 2011
    The "Select Projection dialog will show the parameters of the base projection for the selected State Plane zone below the editable attributes, but those wouldn't come back in the GM_Projection_t structure as those attributes are all set by the ZONE attribute. They are just shown for information purposes, just like when you select a UTM zone the dialog shows all of the base Transverse Mercator projection for the zone, but ZONE is the only editable attribute as it determines all of the other values.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • rmartinez
    rmartinez Global Mapper User
    edited October 2011
    Mike,

    Now I realize the GM_SelectProjection only returns attributes that the user may edit.

    Thank you for the clarification.

    Rebecca