clean up debugging and test output

main
Motiejus Jakštys 2021-05-19 22:57:45 +03:00 committed by Motiejus Jakštys
parent 8cde484775
commit 2513567857
2 changed files with 2 additions and 7 deletions

View File

@ -18,14 +18,13 @@ insert into figures (name, way) values ('fig3-1',ST_GeomFromText('LINESTRING(0 0
insert into figures (name, way) values ('fig5',ST_GeomFromText('LINESTRING(0 39,19 52,27 77,26 104,41 115,49 115,65 103,65 75,53 45,63 15,91 0)'));
insert into figures (name, way) values ('inflection-1',ST_GeomFromText('LINESTRING(110 24,114 20,133 20,145 15,145 0,136 5,123 7,114 7,111 2)'));
-- tables are for manual inspection using, say, qgis
-- DETECT BENDS
drop table if exists bends;
create table bends (name text, way geometry);
insert into bends select 'fig3', unnest(detect_bends((select way from figures where name='fig3')));
insert into bends select 'fig5', unnest(detect_bends((select way from figures where name='fig5')));
insert into bends select 'inflection-1', unnest(detect_bends((select way from figures where name='inflection-1')));
-- DETECT BENDS
do $$
declare
vbends geometry[];
@ -41,13 +40,13 @@ begin
perform assert_equals(3, array_length(vbends, 1));
end $$ language plpgsql;
-- FIX BEND INFLECTIONS
drop table if exists inflections;
create table inflections (name text, way geometry);
insert into inflections select 'fig3', unnest(fix_gentle_inflections(detect_bends((select way from figures where name='fig3'))));
insert into inflections select 'fig5', unnest(fix_gentle_inflections(detect_bends((select way from figures where name='fig5'))));
insert into inflections select 'inflection-1', unnest(fix_gentle_inflections(detect_bends((select way from figures where name='inflection-1'))));
-- FIX BEND INFLECTIONS
do $$
declare
vbends geometry[];

4
wm.sql
View File

@ -148,19 +148,15 @@ begin
-- if inflection angle between ptail[1:3] "large", stop processing this bend
if abs(st_angle(phead[1], phead[2], phead[3]) - pi) > small_angle then
--raise notice 'quitting % because angle between % % %', st_astext(ptail), st_astext(phead[1]), st_astext(phead[2]), st_astext(phead[3]);
exit;
end if;
-- distance from head's first vertex should be larger than from second vertex
if st_distance(ptail, phead[2]) < st_distance(ptail, phead[3]) then
--raise notice 'quitting % because distance', st_astext(ptail);
exit;
end if;
-- detected a gentle inflection. Move head of the tail to the tail of head
--raise notice 'fixing a gentle inflection of angle %', degrees(abs(st_angle(phead[1], phead[2], phead[3]) - pi));
bends[i] = st_removepoint(bends[i], 0);
bends[i-1] = st_addpoint(bends[i-1], phead[3]);
end loop;