log sql statements

This commit is contained in:
Motiejus Jakštys 2021-05-19 22:57:46 +03:00 committed by Motiejus Jakštys
parent 6ebb3fc37b
commit 53dd8516c5
2 changed files with 8 additions and 3 deletions

3
db
View File

@ -35,7 +35,8 @@ case ${1:-} in
-e POSTGRES_USER=osm \ -e POSTGRES_USER=osm \
-e POSTGRES_PASSWORD=osm \ -e POSTGRES_PASSWORD=osm \
--name "$name" \ --name "$name" \
postgis/postgis:13-3.1-alpine postgis/postgis:13-3.1-alpine \
-c log_statement=all
_wait_for_postgres _wait_for_postgres
;; ;;
stop) stop)

8
wm.sql
View File

@ -311,6 +311,7 @@ declare
i integer; i integer;
line geometry; line geometry;
lines geometry[]; lines geometry[];
bend geometry;
bends geometry[]; bends geometry[];
mutated boolean; mutated boolean;
l_type text; l_type text;
@ -324,15 +325,18 @@ begin
raise 'Unsupported geometry type %', l_type; raise 'Unsupported geometry type %', l_type;
end if; end if;
i = 1; i = 1;
mutated = true;
foreach line in array lines loop foreach line in array lines loop
mutated = true;
while mutated loop while mutated loop
execute format('create table if not exists integ_%safigures (way geometry)', i); execute format('create table if not exists integ_%safigures (way geometry)', i);
-- if anyone has suggestions how to insert a variable to a table without -- if anyone has suggestions how to insert a variable to a table without
-- such hackery, I'll be glad to know -- such hackery, I'll be glad to know
execute format('insert into integ_%safigures select $1;', i) using (select unnest(array[line])); execute format('insert into integ_%safigures select $1;', i) using (select unnest(array[line]));
raise notice 'inserting: %', st_astext(unnest(array[line]));
bends = detect_bends(line); bends = detect_bends(line);
execute format('create table if not exists integ_%sbbends (i bigint, way geometry)', i); execute format('create table if not exists 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; execute format('insert into integ_%sbbends (i, way) select generate_subscripts($1, 1), unnest($1)', i) using bends;
bends = fix_gentle_inflections(bends); bends = fix_gentle_inflections(bends);
@ -342,8 +346,8 @@ begin
execute format('create table if not exists integ_%sdselfcrossing (i bigint, way geometry)', i); execute format('create table if not exists 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; execute format('insert into integ_%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;
end loop; end loop;
i = i + 1;
end loop; end loop;
if l_type = 'ST_LineString' then if l_type = 'ST_LineString' then