Skip to content

Commit

Permalink
osm2pgsql free version recoded by frodrigo (#1)
Browse files Browse the repository at this point in the history
* Deals With /

* Magasin, Boutique -> rm

* community_centre alternatives

* Gares

* Salle des fêtes

* Océan

* Monument aux Morts

* Maison de quartier

* -public

* -building=yes

* No place bigger than than city

* Remove addressable highway

* Remove some *=yes

* Add key2

* Remove key1 without value

* rank is value between 0 and 1

* Rename poi.csv to def.csv

* Rewrite extraction process without osm2pgsql

* Fix city_code to citycode
  • Loading branch information
cquest committed Apr 25, 2016
1 parent c0897e5 commit 158912f
Show file tree
Hide file tree
Showing 10 changed files with 574 additions and 670 deletions.
2 changes: 2 additions & 0 deletions 10-def.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
psql < def.sql
psql -c "COPY def FROM STDIN CSV HEADER" < def.csv
6 changes: 6 additions & 0 deletions 20-communes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
URL=http://osm13.openstreetmap.fr/~cquest/openfla/export/communes-20150101-5m-shp.zip
[ -f communes-20150101-5m-shp.zip ] || wget $URL && unzip communes-20150101-5m-shp.zip
shp2pgsql -d communes-20150101-5m.shp > communes.sql
rm communes-20150101-5m.* LICENCE.txt communes-descriptif.txt
psql < communes.sql
psql -c 'CREATE INDEX idx_com_geom ON "communes-20150101-5m" USING gist(geom);'
10 changes: 10 additions & 0 deletions 30-extract-poi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PBF=http://download.geofabrik.de/europe/france-latest.osm.pbf
[ -f france-latest.osm.pbf ] || wget $PBF

FILTER="`tail -n +2 def.csv | cut -d ',' -f 1,2,3 | sort | sed -e 's/\([-_a-z0-9]\+\),\([-_a-z0-9]\+\),\([-_a-z0-9]*\)/( \1=\2 and \3= ) or/' | tr '\n' ' ' | sed -e 's/ and =//g' | sed -e 's/ or \$//'`"
osmconvert france-latest.osm.pbf -o=france-latest.o5m
osmfilter france-latest.o5m --keep="$FILTER" -o=france-poi.o5m
osmconvert france-poi.o5m --all-to-nodes --max-objects=1000000000 -o=france-poi-all-to-nodes.o5m
osmfilter france-poi-all-to-nodes.o5m --keep="$FILTER" -o=france-poi.o5m
KEY="`tail -n +2 def.csv | cut -d ',' -f 1 | sort -u | tr '\n' ' '`"
osmconvert france-poi.o5m --csv="@id @lon @lat name $KEY" --csv-headline > poi.csv
8 changes: 8 additions & 0 deletions 40-poi2addok.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
psql < poi.sql
tail -n +2 poi.csv | psql -c "COPY poi FROM STDIN WITH NULL ''"

psql -c "SELECT AddGeometryColumn ('public','poi','geom',0,'POINT',2);"
psql -c "UPDATE poi SET geom = ST_MakePoint(lon, lat);"
psql -c "CREATE INDEX idx_poi_geom ON poi USING gist(geom);"

psql < poi2addok.sql
Loading

0 comments on commit 158912f

Please sign in to comment.