Updated Aspect Fix Mode (markdown)

verdy-p 2016-11-23 06:19:08 +01:00
parent c3378ab649
commit 2dd3abc601

@ -4,8 +4,8 @@ Mapnik's `aspect_fix_mode` is both wonderful and evil. This page explains why.
Mapnik uses a bounding box (aka. envelope or bounding rectangle) to decide what data to query and where to place it on a given map.
A bounding box (BBOX) is made up of 2 x,y coordinate pairs representing the lower left corner and the upper right and is expressed as `minx,miny,maxx,maxy`. So a BBOX that represents the entire world is `-180,-90,180,90` if we are speaking in long/lat degrees. The coordinate values are specific to the spatial reference system you are using, so another common BBOX is the global extents in [web mercator](http://wiki.openstreetmap.org/wiki/Mercator): `-20037508.342789244,-20037508.342789244,20037508.342789244,20037508.342789244`. Curious how these were calculated? See [this code](https://github.com/mapbox/tilelive-mapnik/blob/2af055024e74414e75c714cbd47a115f43cfb3f2/lib/render.js#L8-L10):
their absolute values are measuring the exact length in meters of a path, along the equatorial parallel, on the reference WGS84 geoid modelizing the Earth surface at average sea level, from any longitude to its antipodic one (i.e. a path along 180 degrees of longitude), assuming that this equatorial parallel is a perfect circle (this is not exactly the case for the true Earth, but it is true for the reference geoid used in our web Mercator projection).
A bounding box (BBOX) is made up of 2 x,y coordinate pairs representing the lower left corner and the upper right and is expressed as `minx,miny,maxx,maxy`. So a BBOX that represents the entire world is `-180,-90,180,90` if we are speaking in long/lat degrees. The coordinate values are specific to the spatial reference system you are using, so another common BBOX is the global extents in [web mercator](http://wiki.openstreetmap.org/wiki/Mercator): `-20037508.342789244,-20037508.342789244,20037508.342789244,20037508.342789244`. Curious how these were calculated? See [this code](https://github.com/mapbox/tilelive-mapnik/blob/2af055024e74414e75c714cbd47a115f43cfb3f2/lib/render.js#L8-L12):
their absolute values are measuring the exact length in meters of a path, along the equatorial parallel, on the reference WGS84 geoid modelizing the Earth surface at average sea level, from any longitude to its antipodic one (i.e. a path along 180 degrees of longitude, or the half of the average equatorial circumference), assuming that this equatorial parallel is a perfect circle (this is not exactly the case for the true Earth, but it is true for the reference geoid used in our web Mercator projection).
With common tiling schemes it is easy to know the BBOX based on a given zoom level and x/y tile id and to know the reverse. Learn more at <http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/> and see some code that does this at <https://github.com/mapbox/node-sphericalmercator>.