Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting proper plotmap aspect ratio #12

Open
michael-prange opened this issue Feb 7, 2022 · 8 comments
Open

Getting proper plotmap aspect ratio #12

michael-prange opened this issue Feb 7, 2022 · 8 comments

Comments

@michael-prange
Copy link
Contributor

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.

@pszufe
Copy link
Owner

pszufe commented Feb 7, 2022

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.

@michael-prange
Copy link
Contributor Author

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.

@pszufe
Copy link
Owner

pszufe commented Feb 7, 2022

Sounds great! should you need any support/instructions do not hesitate to ask.

@michael-prange
Copy link
Contributor Author

I just cloned and then committed my changes to the Master. Is this right? I'm a novice at GitHub.

@michael-prange
Copy link
Contributor Author

I see that I need to create a fork first. Just did that. Will now try to commit.

@michael-prange
Copy link
Contributor Author

Do you see my changes? if not, what do I need to do?

@michael-prange
Copy link
Contributor Author

I accidentally created two pull requests. The second one contains the changes of the first. Sorry about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants