Global Mapper v25.0

ProjectPoint problem

kalden
kalden Global Mapper User
edited August 2010 in SDK
I am having a problem converting a pixel location to a ground point. If I pass in 0,0 for the pixel location, I get a valid ground point out but not the value I would expect. The ground point does not come out to be the top left corner of the map. It is close, but the min Y value is larger than I would expect.

This is causing an issue with a mouse panning feature I am implementing in my application. I track the pixel delta while dragging the mouse and then convert that to a ground point. I then use that ground point to adjust the map bounding box to be rendered and pan the view.

Comments

  • global_mapper
    global_mapper Administrator
    edited August 2010
    What you are likely seeing is a result of aspect ratio being maintained by default. This means that if the aspect ratio of your draw rectangle does not match that of your pixel rectangle, the draw rectangle is expanded in one direction so that the aspect ratios match (this avoids stretched drawings). You can avoid this (although I wouldn't recommend it) by passing in the GM_DrawFlags_DontMaintainAspectRatio flag to the draw function, or by making sure the aspect ratio of your draw/conversion rectangle match prior to passing them into the SDK.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • kalden
    kalden Global Mapper User
    edited August 2010
    just out of curiosity, how does the global mapper application handle this? I assume it is doing the same thing when clicking and dragging the map.

    If I could convert my pixel delta to a meters delta I think I could avoid this aspect ratio problem, but I don't see a way to do that.
  • global_mapper
    global_mapper Administrator
    edited August 2010
    Global Mapper always maintains the view rectangle at the same aspect ratio as the draw pixel rectangle. It is pretty simple to do this, you don't have to worry about meters per pixel, just the ratio of the width and height in pixels to the ratio of the width and height in whatever units your view rectangle is in (this would be your current view projection). Note that you never modify the pixel rectangle, always the view rectangle, and you always grow in one direction or the other to get the aspect ratios to match.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • kalden
    kalden Global Mapper User
    edited August 2010
    Thanks for the help. This works perfectly. I am only using one map though. When working with multiple layers, is there a simple way to get a geographic bounding box that will encompass all layers? I could just manually create this by looping through all the layer info, but is there a API call for this?
  • global_mapper
    global_mapper Administrator
    edited August 2010
    There is not an API to get the enclosing bounding box for multiple layers, you would just need to loop through all of the loaded layers and calculate the union of the bounding boxes. The C++ sample application does this in the GM_MapWindow class.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com