Mercurial > gemma
comparison schema/isrs_functions.sql @ 1811:c21f72775f6b
Fix numerical problems in stretch area generation
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Tue, 15 Jan 2019 19:46:41 +0100 |
parents | 50548a6df009 |
children | f9f1babe52ae |
comparison
equal
deleted
inserted
replaced
1810:7ee9bdaac336 | 1811:c21f72775f6b |
---|---|
63 FROM axis) AS lines, | 63 FROM axis) AS lines, |
64 (SELECT ST_Collect(from_point.geom, to_point.geom) AS pts | 64 (SELECT ST_Collect(from_point.geom, to_point.geom) AS pts |
65 FROM from_point, to_point) AS points | 65 FROM from_point, to_point) AS points |
66 WHERE ST_Covers(ST_Buffer(lines.line, 0.0001), points.pts)), | 66 WHERE ST_Covers(ST_Buffer(lines.line, 0.0001), points.pts)), |
67 axis_substring AS ( | 67 axis_substring AS ( |
68 -- Use linear referencing to clip axis between distance marks | 68 -- Use linear referencing to clip axis between distance marks. |
69 SELECT ST_LineSubstring( | 69 -- Simplification is used to work-around the problem, that |
70 -- ST_LineSubstring might generate very small line segments at an | |
71 -- end of the resulting linestring, that significantly differ from | |
72 -- the direction of the input linestring due to finite precision | |
73 -- of the calculation. The generated small segment of the | |
74 -- resulting line leads to unexpected results of the buffer with | |
75 -- endcap=flat in the CTE below. | |
76 SELECT ST_SimplifyPreserveTopology(ST_LineSubstring( | |
70 axis_segment.line, | 77 axis_segment.line, |
71 ST_LineLocatePoint(axis_segment.line, from_point.geom), | 78 ST_LineLocatePoint(axis_segment.line, from_point.geom), |
72 ST_LineLocatePoint(axis_segment.line, to_point.geom) | 79 ST_LineLocatePoint(axis_segment.line, to_point.geom) |
73 ) AS line | 80 ), 0.0001) AS line |
74 FROM axis_segment, from_point, to_point), | 81 FROM axis_segment, from_point, to_point), |
75 range_area AS ( | 82 range_area AS ( |
76 -- Create a buffer around the clipped axis, as large as it could | 83 -- Create a buffer around the clipped axis, as large as it could |
77 -- potentially be intersecting with the area polygon that | 84 -- potentially be intersecting with the area polygon that |
78 -- intersects with the clipped axis. Get the intersection of that | 85 -- intersects with the clipped axis. Get the intersection of that |