[OSM-dev] OSM data import using osm2pgsql... what's next.

Christian Quest cquest at openstreetmap.fr
Sat Aug 2 08:52:20 UTC 2014


2014-08-01 14:24 GMT+02:00 Loic Duros <loic.duros at gmail.com>:

> When you say that osm2pgsql will reproject OSM lat/lon into web mercator,
> and that real distance calculation will require reprojection, do you
> actually mean re-importing the data in a different manner in the database,
> or is there a way to do the conversion on the fly with a query or using
> custom client code?



By default osm2pgsql reprojects into web mercator, but you can avoid it and
ask to keep the spherical coordinates if this is a better choice for your
use.

It is possible to do on the fly reprojection with postgis using
ST_Transform... but this may cause a lot of calculations.
It your queries use a lot of distance calculations, you'll want to do them
with real "spherical" distances, and not the projected one that is not
linear. In web mercator the "distance" are pixel based, and not linear. The
same "distance" will be much small at the equator compared to iceland or
south africa...

You may also add a trigger in your osm2pgsql database to have 2 geometry
fields, one in web mercator projection, and the other one in spherical
coordinates and use the better in your queries depending on your need.

-- 
Christian Quest - OpenStreetMap France
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20140802/58fdb847/attachment.html>


More information about the dev mailing list