From e76efda4367c117cc302b20ecb1bb88740d1ca2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Wed, 19 May 2021 22:57:45 +0300 Subject: [PATCH] fix example inflection-1 --- tests.sql | 3 +-- wm.sql | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tests.sql b/tests.sql index f8d3931..630fcf1 100644 --- a/tests.sql +++ b/tests.sql @@ -16,7 +16,7 @@ create table figures (name text, way geometry); insert into figures (name, way) values ('fig3',ST_GeomFromText('LINESTRING(0 0,12 0,13 4,20 2,20 0,32 0,33 10,38 16,43 15,44 10,44 0,60 0)')); insert into figures (name, way) values ('fig3-1',ST_GeomFromText('LINESTRING(0 0,12 0,13 4,20 2,20 0,32 0,33 10,38 16,43 15,44 10,44 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,91 0)')); -insert into figures (name, way) values ('inflection-1',ST_GeomFromText('LINESTRING(129 45,131 56,130 82,128 99,147 104,149 89,147 68,141 52)')); +insert into figures (name, way) values ('inflection-1',ST_GeomFromText('LINESTRING(100 14,114 20,133 20,145 15,145 0,136 5,123 7,114 7,111 2)')); drop table if exists bends; create table bends (way geometry); @@ -35,7 +35,6 @@ begin perform assert_equals('LINESTRING(20 2,20 0,32 0,33 10)', st_astext(bends[3])); perform assert_equals('LINESTRING(32 0,33 10,38 16,43 15,44 10,44 0)', st_astext(bends[4])); - perform assert_equals(4, array_length(detect_bends((select way from figures where name='fig3-1')), 1)); select detect_bends((select way from figures where name='fig5')) into bends; diff --git a/wm.sql b/wm.sql index 89e93ac..aa10e0c 100644 --- a/wm.sql +++ b/wm.sql @@ -99,18 +99,21 @@ begin -- Then edges (A,B) and (E,F) are shared with the neighboring bends. -- -- - -- Assume this curve: + -- Assume this curve (figure `inflection-1`): -- -- A______B - -- ---' `---.___. E - -- C D | - -- _I | - -- '---.________ | - -- H G'---+ F + -- ---' `-------. C + -- | + -- G___ F | + -- / `-----.____+ D + -- E -- -- After processing the curve following the definition of a bend, the bend - -- [A-G] would be detected. Assuming inflection point G and H are "small", - -- the bend would be extended by two edges to [A,I]. + -- [A-E] would be detected. Assuming inflection point E and F are "small", + -- the bend needs to be extended by two edges to [A,G]. + -- + -- Assuming the direction in this example is clock-wise, the first set of + -- `p` variables will be: p1=C, p2=B, p3=A. for p in (select geom from st_dumppoints(prev_bend) order by path[1] desc) loop p3 = p2; p2 = p1;