diff --git a/IV/Makefile b/IV/Makefile index ed53810..f55b893 100644 --- a/IV/Makefile +++ b/IV/Makefile @@ -9,10 +9,17 @@ test: tests.sql .faux.db test-integration: .faux_filter-rivers ./db -f tests-integration.sql +.PHONY: clean clean: -./db stop -rm .faux_filter-rivers .faux_import-osm .faux.db +.PHONY: clean-tables +clean-tables: + for t in $$(./db -c '\dt' | awk '/demo_|integ_/{print $$3}'); do \ + ./db -c "drop table $$t"; \ + done + .faux_filter-rivers: .faux_import-osm ./db -v where="$(WHERE)" -f aggregate-rivers.sql touch $@ diff --git a/IV/wm.sql b/IV/wm.sql index a2b804d..4954f13 100644 --- a/IV/wm.sql +++ b/IV/wm.sql @@ -328,23 +328,23 @@ begin mutated = true; foreach line in array lines loop while mutated loop - execute format('drop table if exists demo_%safigures', i); - execute format('create table demo_%safigures (way geometry)', i); + execute format('drop table if exists integ_%safigures', i); + execute format('create table integ_%safigures (way geometry)', i); -- if anyone has suggestions how to insert a variable to a table without -- such hackery, I'll be glad to know - execute format('insert into demo_%safigures select $1;', i) using (select unnest(array[line])); + execute format('insert into integ_%safigures select $1;', i) using (select unnest(array[line])); bends = detect_bends(line); - execute format('drop table if exists demo_%sbbends', i); - execute format('create table demo_%sbbends (i bigint, way geometry)', i); - execute format('insert into demo_%sbbends (i, way) select generate_subscripts($1, 1), unnest($1)', i) using bends; + execute format('drop table if exists integ_%sbbends', i); + execute format('create table integ_%sbbends (i bigint, way geometry)', i); + execute format('insert into integ_%sbbends (i, way) select generate_subscripts($1, 1), unnest($1)', i) using bends; bends = fix_gentle_inflections(bends); - execute format('drop table if exists demo_%scinflections', i); - execute format('create table demo_%scinflections (i bigint, way geometry)', i); - execute format('insert into demo_%scinflections (i, way) select generate_subscripts($1, 1), unnest($1)', i) using bends; + execute format('drop table if exists integ_%scinflections', i); + execute format('create table integ_%scinflections (i bigint, way geometry)', i); + execute format('insert into integ_%scinflections (i, way) select generate_subscripts($1, 1), unnest($1)', i) using bends; select * from self_crossing(bends) into bends, mutated; - execute format('drop table if exists demo_%sdselfcrossing', i); - execute format('create table demo_%sdselfcrossing (i bigint, way geometry)', i); - execute format('insert into demo_%sdselfcrossing (i, way) select generate_subscripts($1, 1), unnest($1)', i) using bends; + execute format('drop table if exists integ_%sdselfcrossing', i); + execute format('create table integ_%sdselfcrossing (i bigint, way geometry)', i); + execute format('insert into integ_%sdselfcrossing (i, way) select generate_subscripts($1, 1), unnest($1)', i) using bends; line = st_linemerge(st_union(bends)); i = i + 1; end loop;