more explicit intermediate steps

This commit is contained in:
Motiejus Jakštys 2021-03-21 16:52:31 +02:00
parent e41869b0ca
commit 37a3259965
4 changed files with 21 additions and 14 deletions

View File

@ -9,6 +9,10 @@ test: tests.sql .faux.db
test-integration: .faux_filter-rivers test-integration: .faux_filter-rivers
./db -f tests-integration.sql ./db -f tests-integration.sql
clean:
-./db stop
-rm .faux_filter-rivers .faux_import-osm .faux.db
.faux_filter-rivers: .faux_import-osm .faux_filter-rivers: .faux_import-osm
./db -v where="$(WHERE)" -f aggregate-rivers.sql ./db -v where="$(WHERE)" -f aggregate-rivers.sql
touch $@ touch $@

View File

@ -24,7 +24,7 @@ begin
end end
$$ language plpgsql; $$ language plpgsql;
create temporary table aggregate_rivers_tmp (osm_id bigint, name text, way geometry) on commit drop; create temporary table aggregate_rivers_tmp (osm_id bigint, name text, way geometry);
create index aggregate_rivers_tmp_id on aggregate_rivers_tmp(osm_id); create index aggregate_rivers_tmp_id on aggregate_rivers_tmp(osm_id);
create index aggregate_rivers_tmp_gix on aggregate_rivers_tmp using gist(way) include(name); create index aggregate_rivers_tmp_gix on aggregate_rivers_tmp using gist(way) include(name);
@ -34,3 +34,4 @@ insert into aggregate_rivers_tmp
drop table if exists agg_rivers; drop table if exists agg_rivers;
create table agg_rivers as (select * from aggregate_rivers()); create table agg_rivers as (select * from aggregate_rivers());
drop table aggregate_rivers_tmp;

View File

@ -1,3 +1,5 @@
\i wm.sql \i wm.sql
select ST_SimplifyWM_DEBUG(way) from agg_rivers; drop table if exists agg_rivers_wm;
create table agg_rivers_wm (name text, way geometry);
insert into agg_rivers_wm (name, way) select name, ST_SimplifyWM_DEBUG(way) from agg_rivers where name='Visinčia';

View File

@ -328,23 +328,23 @@ begin
mutated = true; mutated = true;
foreach line in array lines loop foreach line in array lines loop
while mutated loop while mutated loop
execute format('drop table if exists demo_%sfigures0', i); execute format('drop table if exists demo_%safigures', i);
execute format('create table demo_%sfigures0 (way geometry)', i); execute format('create table demo_%safigures (way geometry)', i);
-- if anyone has suggestions how to insert a variable to a table without such -- if anyone has suggestions how to insert a variable to a table without such
-- hackery, I'll be glad to know -- hackery, I'll be glad to know
execute format('insert into demo_%sfigures0 select $1;', i) using (select unnest(array[line])); execute format('insert into demo_%safigures select $1;', i) using (select unnest(array[line]));
bends = detect_bends(line); bends = detect_bends(line);
execute format('drop table if exists demo_%sbends1', i); execute format('drop table if exists demo_%sbbends', i);
execute format('create table demo_%sbends1 (i bigint, way geometry)', i); execute format('create table demo_%sbbends (i bigint, way geometry)', i);
execute format('insert into demo_%sbends1 (i, way) select generate_subscripts($1, 1), unnest($1)', i) using bends; execute format('insert into demo_%sbbends (i, way) select generate_subscripts($1, 1), unnest($1)', i) using bends;
bends = fix_gentle_inflections(bends); bends = fix_gentle_inflections(bends);
execute format('drop table if exists demo_%sinflections2', i); execute format('drop table if exists demo_%scinflections', i);
execute format('create table demo_%sinflections2 (i bigint, way geometry)', i); execute format('create table demo_%scinflections (i bigint, way geometry)', i);
execute format('insert into demo_%sinflections2 (i, way) select generate_subscripts($1, 1), unnest($1)', i) using bends; execute format('insert into demo_%scinflections (i, way) select generate_subscripts($1, 1), unnest($1)', i) using bends;
select * from self_crossing(bends) into bends, mutated; select * from self_crossing(bends) into bends, mutated;
execute format('drop table if exists demo_%sselfcrossing3', i); execute format('drop table if exists demo_%sdselfcrossing', i);
execute format('create table demo_%sselfcrossing3 (i bigint, way geometry)', i); execute format('create table demo_%sdselfcrossing (i bigint, way geometry)', i);
execute format('insert into demo_%sselfcrossing3 (i, way) select generate_subscripts($1, 1), unnest($1)', i) using bends; execute format('insert into demo_%sdselfcrossing (i, way) select generate_subscripts($1, 1), unnest($1)', i) using bends;
line = st_linemerge(st_union(bends)); line = st_linemerge(st_union(bends));
i = i + 1; i = i + 1;
end loop; end loop;