Project and Deproject point problem

OseiOsei Global Mapper UserPosts: 119Trusted User
edited January 2009 in SDK
Merry christmas and a happy new year.
I have a slight problem that has entangled my mind. I am using 1.29 of the SDK.

I have a point [x,y] = [336000,651000]
I project the point from UTM Zone 30 to UTM Zone 36. f

f([x,y]) = [-3970893.963,819098.648]

This is the same value I get when I do the projection on the point in the Global Mapper Application (GM9).
However, when I project the point back from UTM Zone 36 to UTM Zone 30, I get

f-Inverse(f[x,y]) = [332712.461,649096.716]

I was hoping to get back [x,y] (ie [336000,651000]) but I get a different value (the one above).
Am I wrong to hope for the same value or is there something I am getting wrong? In GM9, I get back the original coordinates.

Thanks in advance for your time and effort. Once again, best wishes for the season.

Comments

  • OseiOsei Global Mapper User Posts: 119Trusted User
    edited December 2008
    Please find attached the code. Also in the [code.xps].zip file attached.

    private bool ProjectPoint(ref double x, ref double y)
    {
    GM_Projection_t lambert = new GM_Projection_t();
    lambert.ProjSys = PROJSYS.GM_PRJ_UTM;
    lambert.Unit = UNIT.GM_PRJ_UNIT_METERS;
    lambert.Datum = DATUM.GM_DATUM_WGS_84;
    lambert.NumAttrs = 1;
    lambert.Attr1.mAttr = PROJATTR.ZONE;
    lambert.Attr1.mValue = 36;
    /*lambert.ProjSys = PROJSYS.GM_PRJ_LAMBERT_II;
    lambert.Datum = DATUM.GM_DATUM_NTF_FRANCE_PARIS;
    lambert.Unit = UNIT.GM_PRJ_UNIT_METERS;
    //lambert.NumAttrs = 6;
    */
    GM_Projection_t utm = new GM_Projection_t();
    utm.ProjSys = PROJSYS.GM_PRJ_UTM;
    utm.Unit = UNIT.GM_PRJ_UNIT_METERS;
    utm.Datum = DATUM.GM_DATUM_WGS_84;
    utm.NumAttrs = 1;
    utm.Attr1.mAttr = PROJATTR.ZONE;
    utm.Attr1.mValue = 30;

    IntPtr ipLambert = Marshal.AllocCoTaskMem(Marshal.SizeOf(lambert));
    Marshal.StructureToPtr(lambert, ipLambert, false);

    IntPtr ipUTM = Marshal.AllocCoTaskMem(Marshal.SizeOf(utm));
    Marshal.StructureToPtr(utm, ipUTM, false);

    bool result;


    if (checkBox1.Checked)
    {
    result = (GlobalMapperDLL.GM_Error_t32.GM_Error_None == GlobalMapperDLL.GM_ProjectPoint(x, y, out x, out y, ipUTM, ipLambert));
    }
    else
    {
    result= (GlobalMapperDLL.GM_Error_t32.GM_Error_None == GlobalMapperDLL.GM_ProjectPoint(x, y, out x, out y, ipLambert, ipUTM));
    }

    Marshal.FreeCoTaskMem(ipLambert);
    Marshal.FreeCoTaskMem(ipUTM);

    if(!result)
    MessageBox.Show("Could not perform projection");

    return result;
    }
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited December 2008
    The UTM projection gets very non-reversable once you get more than a couple of zones away from the central meridian. So converting coordinates between UTM zones that are that far apart can result in some strange coordinates. In general I wouldn't trust the results of converting between different UTM zones that are more than about 3 zones apart.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • OseiOsei Global Mapper User Posts: 119Trusted User
    edited January 2009
    I would like to know if there is anything being done differently in the SDK such that the Global Mapper application can reverse the coordinates correctly. Or better still, is there anything that I can do to make the SDK behave like the GM application. I am asking because users may make mistake in changing projections hence we want to make sure they can always return to their previous state.

    Thanks in adavnce for your help.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited January 2009
    I was actually getting the same results in Global Mapper that you were getting in the SDK and not something closer, which is what I would expect as they should be using the same conversion routines. The one thing that might be different in the SDK is if you don't have the 'nadcon' folder with all of the datum conversion files along with your GlobalMapperInterface.dll file then datum conversions that use those files (such as NTF France) would not be as accurate with the SDK as with Global Mapper.

    In Global Mapper coordinate are always kept in the native coordinate system specified for a data set, then reprojected on the fly as needed for display and such. That way there is not a problem with a loss of precision as different projection systems are used as the original coordinates in the native coordinate system are always maintained and used for any later conversions.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • OseiOsei Global Mapper User Posts: 119Trusted User
    edited January 2009
    Thanks a lot for your responses. We will make sure UTM Zones are not changed beyond 3 zones apart. That fixes the problem. Once again thanks.
Sign In or Register to comment.