Skip to content

Commit

Permalink
Merge pull request osm2pgsql-dev#546 from pnorman/epsg_3857
Browse files Browse the repository at this point in the history
Switch to EPSG:3857
  • Loading branch information
lonvia committed Feb 28, 2016
2 parents 8245308 + a42d3aa commit 097c472
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 8 deletions.
1 change: 0 additions & 1 deletion 900913.sql

This file was deleted.

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,4 @@ endif()

install(TARGETS osm2pgsql DESTINATION bin)
install(FILES docs/osm2pgsql.1 DESTINATION share/man/man1)
install(FILES default.style empty.style 900913.sql DESTINATION share/osm2pgsql)
install(FILES default.style empty.style DESTINATION share/osm2pgsql)
2 changes: 1 addition & 1 deletion docs/export.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Osm2pgsql can be used in combination with [ogr2ogr](http://www.gdal.org/ogr2ogr.
An example command to export to GeoJSON would be

ogr2ogr -f "GeoJSON" roads.geojson -t_srs EPSG:4326 \
PG:"dbname=gis" -s_srs EPSG:900913 \
PG:"dbname=gis" -s_srs EPSG:3857 \
-sql "SELECT name,highway,oneway,toll,way FROM planet_osm_line WHERE highway IS NOT NULL"

Care should be taken if exporting to shapefiles, as characters may be present
Expand Down
16 changes: 16 additions & 0 deletions docs/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ Some osm2pgsql changes have slightly changed the database schema it expects. If
updating an old database, a migration may be needed. The migrations here assume
the default `planet_osm` prefix.

It is frequently better to reimport as this will also recluster the tables and
remove table or index bloat.

## 0.91 default projection ##

The default projection was moved from 900913 to 3857. This does not effect
users using `-l` or `-E`, but if using no projection options or `-m` a
migration is needed.

```sql
ALTER TABLE planet_osm_roads ALTER COLUMN way TYPE geometry(LineString,3857) USING ST_SetSRID(way,3857);
ALTER TABLE planet_osm_point ALTER COLUMN way TYPE geometry(Point,3857) USING ST_SetSRID(way,3857);
ALTER TABLE planet_osm_line ALTER COLUMN way TYPE geometry(LineString,3857) USING ST_SetSRID(way,3857);
ALTER TABLE planet_osm_polygon ALTER COLUMN way TYPE geometry(Geometry,3857) USING ST_SetSRID(way,3857);
```

## 0.88.0 z_order changes ##

0.88.0 z_order logic was changed, requuiring an increase in z_order values. To
Expand Down
4 changes: 2 additions & 2 deletions docs/osm2pgsql.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH OSM2PGSQL 1 "April 06, 2013"
.TH OSM2PGSQL 1 "February 27, 2016"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
osm2pgsql \- Openstreetmap data to PostgreSQL converter.
Expand Down Expand Up @@ -241,7 +241,7 @@ Verbose output.
.SH SUPPORTED PROJECTIONS
Latlong (\-l) SRS: 4326 (none)
.br
Spherical Mercator (\-m) SRS:900913 +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over
Spherical Mercator (\-m) SRS:3857 +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over
.br
EPSG-defined (\-E) SRS: +init=epsg:(as given in parameter)
.PP
Expand Down
2 changes: 1 addition & 1 deletion reprojection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class merc_reprojection_t : public reprojection
public:
osmium::geom::Coordinates reproject(osmium::Location loc) const override
{
/* The latitude co-ordinate is clipped at slightly larger than the 900913 'world'
/* The latitude co-ordinate is clipped at slightly larger than the 3857 'world'
* extent of +-85.0511 degrees to ensure that the points appear just outside the
* edge of the map. */
double lat = loc.lat_without_check();
Expand Down
2 changes: 1 addition & 1 deletion reprojection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <osmium/geom/projection.hpp>
#include <osmium/osm/location.hpp>

enum Projection { PROJ_LATLONG = 4326, PROJ_SPHERE_MERC = 900913 };
enum Projection { PROJ_LATLONG = 4326, PROJ_SPHERE_MERC = 3857 };

class reprojection : public boost::noncopyable
{
Expand Down
2 changes: 1 addition & 1 deletion tests/test-output-pgsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void test_regression_simple() {
db->check_number(143.81, "SELECT ST_Area(ST_Transform(way,4326)::geography) FROM osm2pgsql_test_polygon WHERE osm_id = 157261342");

// Check a point's location
db->check_count(1, "SELECT count(*) FROM osm2pgsql_test_point WHERE ST_DWithin(way, 'SRID=900913;POINT(1062645.12 5972593.4)'::geometry, 0.1)");
db->check_count(1, "SELECT count(*) FROM osm2pgsql_test_point WHERE ST_DWithin(way, 'SRID=3857;POINT(1062645.12 5972593.4)'::geometry, 0.1)");
}

void test_latlong() {
Expand Down

0 comments on commit 097c472

Please sign in to comment.