Translating OpenStreetMap data to HTML5 Canvas with Rust and WebAssembly
mary.codes
mary.codes
A practical solution would be to reproject the data to the Mercator projection or the appropriate local UTM Zone, ensuring accurate distances in cartesian units with no visible distortions of angles.
Alternatively, a quite straightforward method would involve scaling the longitudinal axis by the cosine of the latitude (cos φ [1]) at the center latitude of the area of interest. This adjustment provides a good approximation for small extents, like theme parks, without delving deeply into map projections.
[1] https://en.wikipedia.org/wiki/Longitude#Length_of_a_degree_o...
Or is this already considered in modern projection methods?
I call this the tangent-plane projection (which hints at your picture), where distances can be simply calculated by 2D Pythagoras in the EW-scaled coordinates. I recently discovered it is more often known as Equirectangular Projection:
https://en.wikipedia.org/wiki/Equirectangular_projection
More details at this excellent resource for GIS coordinate geometry:
Otherwise it's a sea of hacks which doesn't get rid of latitude-induced distortions anyway.
After that being very annoyed with lat/long stuff I moved to N-vector representation.
You are right that this is an issue if you start plotting e.g. circles using a naive algorithm as the x and y scales in degrees are simply not the same in meters. Which is an issue if you want to draw circles and rectangles on a map.
The solution to that is to do it in meters and then translate the points from some origin using e.g. the Haversine distance. A related issue you have there is that distance algorithms aren't accurate either but it's close enough as an approximation over small distances.
I have some algorithms for that in my jillesvangurp/geogeometry library. I also have some UTM coordinate conversion algorithms in there that I recently added.
Historically this is the reason web mapping picked up Mercator in the first place, since it preserves angles and relatives sizes (conformal) at city scales, which is the primary use case of those.
WGS84 is a CRS first, not meant to be used as cartographic projection for a known local scope. (for some Plate carée is more of a plot than a projection)
I’m not talking about converting between local CRS for surveying an local plate consistency. You just want the display to look not visibly distorted in a way that’s not intentional. Florida is still quite forgiving here. Eurodisney not so much.
https://commons.wikimedia.org/wiki/File:Plate_Carr%C3%A9e_wi...
way[building][!name];foreach{(._;>;);out;}
can be replaced with way[building][!name];(._;>;);out;
The "(._;>;);" stanza is sort of dense and seems opaque without knowing what it's doing, but it's straightforward, returning the union "();" of the previous result "._;" and the children of the previous result ">;".The change I propose above adjusts the ">;" to operate on all of the "way[building][!name];" results together, rather than each element one at the time.
out geom
does a similar operation in fewer charactersYou are probably talking about https://news.ycombinator.com/item?id=39339182
Most vector tile sets today generated from OSM are hours behind the current state of the map data in the best case, much more commonly they are months behind.
https://mary.codes/blog/recipes/the_secret_to_the_creamiest_...
I love grits, but have never tried baking soda (or even heard of it). Gonna have to try this.
Is this really true for Rust compiled to WebAssembly in the browser?
During compilation from Rust to WebAssembly you have the opportunity to apply ahead-of-time optimizations that would be too expensive or impossible to apply to JavaScript during execution, so this can improve performance pretty significantly over JavaScript.
> PMTiles readers use HTTP Range Requests to fetch only the relevant tile or metadata inside a PMTiles archive on-demand.
My only regret is not putting more effort into getting WebGL working, I just used the plain canvas and it was a bit of a bottleneck.
demo: https://files.george.honeywood.org.uk/final-deliverable/#16/...
blog: https://george.honeywood.org.uk/blog/map-from-the-ground-up/
To me, that seems like the wrong design for performance... Drawing you probably want to use webgl shaders for so you can do zooming and panning at 60 fps...
And downloading the data as XML seems like a bad idea if you're drawing city-sized areas because the XML will be huge and contain plenty more detail than you need. Instead you need a server-side component to pack simplified and quantized polygon data for the necessary scale into a binary datastructure for sending to the client.
And thats exactly how bing/google maps/apple maps work...