ProjectPoint problem
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.
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
-
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 -
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 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 -
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?
-
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
Categories
- 12.5K All Categories
- 5.5K Features Discussion
- 314 Downloading Imagery
- 1.3K Elevation Data
- 377 Georeferencing Imagery Discussion
- 611 GM Script Language
- 50 User Scripts
- 112 GPS Features
- 397 Projection Questions
- 803 Raster Data
- 1.3K Vector Data
- 6.5K Support
- 161 Announcement and News
- 893 Bug Report
- 557 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 542 Other Discussion
- 128 GIS Data Sources
- 26 Global Mapper Showcase
- 229 How I use Global Mapper
- 104 Global Mapper Forum Website