OpenStreetMapXPlot.jl
OpenStreetMapXPlot.jl copied to clipboard
Getting proper plotmap aspect ratio
When I load an OSM file and issue the plotmap command without height and width arguments, the aspect ratio is automatically set as 1:1, namely, 600 x 600. I feel that the default behavior should be that a meter in the horizontal axis is the same scale as a meter on the vertical axis. I've played around with how to extract the OSM bounding box in meters, but have failed. Can someone provide some hints? I'd like to update plotmap to do this. I would also add the behavior that if only one of the height and width arguments is provided, then the other dimension would be automatically chosen to preserve the aspect ratio.
I agree that this is a missing component here!
The corners of maps bouding box are stored in the .bounds
field. You need to convert the LLA
coordinates (measured in latitude, longitude, altitude) to ENU
coordinates (measured in meters around a reference point)
This is the code for the Reno map that comes with OpenStreetMapX
mx = get_map_data(joinpath(dirname(pathof(OpenStreetMapX)),"..","test/data/reno_east3.osm"),use_cache=false)
p1 = ENU(LLA(mx.bounds.min_y, mx.bounds.min_x), mx.bounds)
p2 = ENU(LLA(mx.bounds.max_y, mx.bounds.max_x), mx.bounds)
Since the ENU
coordinates are measured in meters (here measured from the center of the bounding box), now calculating their distances is simple (note that we ignore the Earth's curvature here):
julia> width = abs(p2.east - p1.east)
8211.713309253431
julia> height = abs(p2.north - p1.north)
4818.504061294725
Hence the size of the reno_east3.osm
is 8211 x 4818 meters (width x height)
If you want to do a PR helping with this functionality it will be very welcome.
Thanks. I'll add this code this afternoon. I've just created a new function plot_nodes_as_symbols! that is similar to plot_nodes!, but allows arbitrary symbol strings to be plotted at node locations instead of numbers. You'll see that code shortly.
Sounds great! should you need any support/instructions do not hesitate to ask.
I just cloned and then committed my changes to the Master. Is this right? I'm a novice at GitHub.
I see that I need to create a fork first. Just did that. Will now try to commit.
Do you see my changes? if not, what do I need to do?
Now you need to make a Pull Request
https://reflectoring.io/github-fork-and-pull/ https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request
I accidentally created two pull requests. The second one contains the changes of the first. Sorry about that.