Mercurial > gemma
changeset 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 | 7ee9bdaac336 |
children | 4910bcfab319 |
files | schema/isrs_functions.sql |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/schema/isrs_functions.sql Tue Jan 15 18:09:10 2019 +0100 +++ b/schema/isrs_functions.sql Tue Jan 15 19:46:41 2019 +0100 @@ -65,12 +65,19 @@ FROM from_point, to_point) AS points WHERE ST_Covers(ST_Buffer(lines.line, 0.0001), points.pts)), axis_substring AS ( - -- Use linear referencing to clip axis between distance marks - SELECT ST_LineSubstring( + -- Use linear referencing to clip axis between distance marks. + -- Simplification is used to work-around the problem, that + -- ST_LineSubstring might generate very small line segments at an + -- end of the resulting linestring, that significantly differ from + -- the direction of the input linestring due to finite precision + -- of the calculation. The generated small segment of the + -- resulting line leads to unexpected results of the buffer with + -- endcap=flat in the CTE below. + SELECT ST_SimplifyPreserveTopology(ST_LineSubstring( axis_segment.line, ST_LineLocatePoint(axis_segment.line, from_point.geom), ST_LineLocatePoint(axis_segment.line, to_point.geom) - ) AS line + ), 0.0001) AS line FROM axis_segment, from_point, to_point), range_area AS ( -- Create a buffer around the clipped axis, as large as it could