From 50614c6e24e4bdf6e99bf1c2a6182ba7de7920b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Wed, 19 May 2021 22:57:49 +0300 Subject: [PATCH] remove some debug statements --- test.sql | 16 ++-------------- wm.sql | 29 +++++++++++------------------ 2 files changed, 13 insertions(+), 32 deletions(-) diff --git a/test.sql b/test.sql index bd8ca80..3cb5f55 100644 --- a/test.sql +++ b/test.sql @@ -1,12 +1,7 @@ \i wm.sql ---do $$ ---begin --- SET AUTOCOMMIT TO ON; ---end $$ language plpgsql; - -- https://stackoverflow.com/questions/19982373/which-tools-libraries-do-you-use-to-unit-test-your-pl-pgsql -CREATE OR REPLACE FUNCTION assert_equals(expected anyelement, actual anyelement) RETURNS void AS $$ +create or replace function assert_equals(expected anyelement, actual anyelement) returns void as $$ begin if expected = actual or (expected is null and actual is null) then --do nothing @@ -51,22 +46,16 @@ insert into wm_figures (name, way) values ('fig6-combi', ST_Union( ST_Translate((select way from wm_figures where name='fig6'), 80, 90) )); --- TODO: there is a bug and it does not go through `self_crossing` function. insert into wm_figures (name, way) values ('selfcrossing-1-rev',ST_Reverse( ST_Translate((select way from wm_figures where name='selfcrossing-1'), 0, 60))); - delete from wm_debug where name in (select distinct name from wm_figures); delete from wm_demo where name in (select distinct name from wm_figures); insert into wm_demo (name, way) select name, ST_SimplifyWM(way, .1, null, name) from wm_figures where name not in ('fig8', 'isolated-1'); insert into wm_demo (name, way) select name, ST_SimplifyWM(way, 14, null, name) from wm_figures where name in ('fig8', 'isolated-1', 'isolated-2'); drop function if exists wm_debug_get; -create function wm_debug_get( - _stage text, - _name text, - OUT ways geometry[] -) as $$ +create function wm_debug_get( _stage text, _name text, OUT ways geometry[]) as $$ declare begin ways = array((select way from wm_debug where stage=_stage and name=_name order by id)); @@ -75,7 +64,6 @@ end $$ language plpgsql; do $$ declare fig6b1 geometry; declare fig6b2 geometry; - declare sclong geometry; declare scshort geometry; begin diff --git a/wm.sql b/wm.sql index b89e6e6..542e5e8 100644 --- a/wm.sql +++ b/wm.sql @@ -539,25 +539,17 @@ begin end if; end if; - if st_intersects(tmpbendattr.bend, tmpint) then - insert into wm_manual(name, way) values - ('intersecter', tmpbendattr.bend), - ('intersectee', tmpint); - raise notice '[%] % intersects with %', dbggen, i, i+n; - continue bendloop; - end if; + continue bendloop when st_intersects(tmpbendattr.bend, tmpint); end loop; - -- no intersections within intersect_patience. Mutate bend. + -- No intersections within intersect_patience, mutate bend! mutated = true; bendattrs[i] = tmpbendattr; - -- remove last vertex of the previous bend and - -- first vertex of the next bend, because bends always - -- share a line segment together - -- this is duplicated in a few places, because PostGIS - -- does not allow (?) mutating an array when passed to a - -- function. + -- remove last vertex of the previous bend and first vertex of the next + -- bend, because bends always share a line segment together this is + -- duplicated in a few places, because PostGIS does not allow (?) + -- mutating an array when passed to a function. tmpbendattr.bend = st_removepoint( bendattrs[i-1].bend, st_npoints(bendattrs[i-1].bend)-1 @@ -807,10 +799,11 @@ begin end loop; lines[i] = st_linemerge(st_union(bends)); if st_geometrytype(lines[i]) != 'ST_LineString' then - insert into wm_manual(name, way) - select 'non-linestring-' || a.path[1], a.geom - from st_dump(lines[i]) a - order by a.path[1]; + -- For manual debugging: + --insert into wm_manual(name, way) + --select 'non-linestring-' || a.path[1], a.geom + --from st_dump(lines[i]) a + --order by a.path[1]; raise 'Got % (in %) instead of ST_LineString. ' 'Does the exaggerated bend intersect with the line? ' 'If so, try increasing intersect_patience.',