wip data import from OSM

This commit is contained in:
Motiejus Jakštys 2021-05-19 22:57:46 +03:00 committed by Motiejus Jakštys
parent e3f3a36e70
commit 7c6f57a89b
5 changed files with 41 additions and 2 deletions

23
Makefile Normal file
View File

@ -0,0 +1,23 @@
# HACK HACK
EMPTY :=
SPACE := $(EMPTY) $(EMPTY)
RIVERS ?= Visinčia Šalčia Žeimena Lakaja
.faux_filter-rivers: .faux_import-osm
./filter-rivers-query.awk $(RIVERS) | ./db -f -
touch $@
.faux_import-osm: lithuania-latest.osm.pbf .faux.db
PGPASSWORD=osm osm2pgsql \
-c --multi-geometry \
-H 127.0.0.1 -d osm -U osm \
$<
touch $@
.faux.db:
./db start
touch $@
lithuania-latest.osm.pbf:
wget http://download.geofabrik.de/europe/lithuania-latest.osm.pbf

1
db
View File

@ -28,6 +28,7 @@ _wait_for_postgres() {
case ${1:-} in
start)
_psql -qc '\q' 2>/dev/null && exit 0
docker run -d --rm \
-p 5432:5432 \
-e POSTGRES_DBNAME=osm \

12
filter-rivers-query.awk Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/awk -f
BEGIN {
print "DROP TABLE IF EXISTS rivers;";
printf "CREATE TABLE rivers AS SELECT name,way FROM planet_osm_line WHERE "
for (i = 1; i < ARGC; i++) {
printf "name='%s'", ARGV[i]
if (i != ARGC - 1)
printf " OR ";
}
print ";";
}

View File

@ -51,6 +51,9 @@ insert into selfcrossing select name, (self_crossing(ways)).* from inflections;
create table demo_selfcrossing3 (name text, i bigint, way geometry);
insert into demo_selfcrossing3 select name, generate_subscripts(ways, 1), unnest(ways) from selfcrossing;
-- COMBINED
drop table if exists demo_wm;
create table demo_wm (name text, i bigint, way geometry);
do $$
declare

4
wm.sql
View File

@ -296,9 +296,9 @@ begin
end loop;
if l_type = 'ST_LineString' then
return geoms[1];
return bends[1];
elseif l_type = 'ST_MultiLineString' then
return st_union(geoms);
return st_union(bends);
end if;
end
$$ language plpgsql;