Global Mapper v26.0

shift Layers a Fixed Distance ???

qudduq
qudduq Global Mapper UserTrusted User
edited June 2012 in SDK
shift Layers a Fixed Distance ???

Can be used in any function sdk?

Please sample.

cap2.PNG

Comments

  • global_mapper
    global_mapper Administrator
    edited June 2012
    You can use the GM_RepositionLayer function to provide a new set of control points with the shifted location. For vector data you only need 2 control points, say with input ("pixel") locations of 0,0 and 1,1 and the output (ground) locations of the shift added to that. So if you wanted to go 3 meters east and 2 meters south, the output points would be (-3,2) [note you have to negate the shift] and (-2,3). For raster layers just get the control point list from the GM_GetLayerInfo call, adjust each mGroundX and mGroundY value by the shift amount, then call GM_RepositionLayer with the new control points list.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • qudduq
    qudduq Global Mapper User Trusted User
    edited June 2012
    Thanks,

    Mike One more question?

    How do I use (in shp or dxf vector)
  • qudduq
    qudduq Global Mapper User Trusted User
    edited June 2012
    vector case :
    GM_RepositionLayer how to use ???

    Please sample code
  • global_mapper
    global_mapper Administrator
    edited June 2012
    Try something like the following to shift a layer handle (theLayerHandle in code below) 3 units to the east and 2 units to the south:

    GM_GroundControlPoint_t theGCPList[2];
    memset( theGCPList, 0, sizeof theGCPList );
    double theShiftX = 3.0;
    double theShiftY = -2.0;
    theGCPList[0].mPixelX = 0;
    theGCPList[0].mPixelY = 0;
    theGCPList[0].mGroundX = theGCPList[0].mPixelX - theShiftX;
    theGCPList[0].mGroundY = theGCPList[0].mPixelY - theShiftY;
    theGCPList[1].mPixelX = 1;
    theGCPList[1].mPixelY = 1;
    theGCPList[1].mGroundX = theGCPList[1].mPixelX - theShiftX;
    theGCPList[1].mGroundY = theGCPList[1].mPixelY - theShiftY;
    GM_RepositionLayer( theLayerHandle, theGCPList, 2, NULL );

    Note I just did this off the top of my head and haven't compiled or tested it, but you should get the idea.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com