ui
ui copied to clipboard
Map scale factor
I can get an accuracy figure from my location kit, and I'm asked to paint a circle over the map to indicate location accuracy. (As in, if there's a 0.001 degree uncertainty, there should be a corresponding size circle.)
I can't figure out how to size it.
So the map has some zoom and some scale, and I have a radius or distance in the map's coordinate space, and I want to project that into pixels.
Is there a method for this?
The default project is the WebMercator projection and on top of that there is a View translating pixel locations to/from projected coordinates. If you look at the code of one the MapViews you will see a view being created whenever there is need for this transformation.
What you are trying to do is something I want to add to the OsmSharp core features.
I managed to get something going that works. Thanks!
Are you interested in sharing some of this code? I probably have something different in mind for a permanent solution but it might help me to figure out what's best.
What I did is pretty naive and didn't take into account map projection. I did this to size a translucent circle:
private double ConvertDegreesToLengthApproximate(double degrees) { var zoomFactor = mapView.Map.Projection.ToZoomFactor (mapView.MapZoom); var alfa = mapView.Map.Projection.ToPixel (0, 0); var bravo = mapView.Map.Projection.ToPixel (degrees, degrees); var delta = new double[] { alfa [0] - bravo [0], alfa [1] - bravo [1] }; var pixels = zoomFactor * Math.Sqrt (delta [0] * delta [0] + delta [1] * delta [1]); return pixels; }
On Jul 15, 2014, at 11:28 AM, Ben Abelshausen [email protected] wrote:
Are you interested in sharing some of this code? I probably have something different in mind for a permanent solution but it might help me to figure out what's best.
— Reply to this email directly or view it on GitHub.