The yellow dotted line show such a segment (called 'soldner_segment'), which only contains 2 points (Start/End).
The goal is to split the yellow line into 3 portions.
With
CastToMultiLineString(ST_Intersection(b_source.soldner_polygon, a_source.soldner_segment)) AS soldner_segment_mauer
What I have not figured out is how to:
- extract from 'soldner_segment' the portion not contained in 'soldner_segment_mauer'
My first attempt was:
soldner_segment_diff=CastToMultiLineString(ST_Difference(CastToMultiLineString(soldner_segment),soldner_segment_mauer))
No doubt the solution has been staring at my without blinking (and thus not noticed)...
Will try ST_SymDifference as the next attempt tomorrow.
Mark
Yellow is the portion that should end at the top of the polygon.
Red is the correct result from the area inside the polygon
Green is the portion that should start at the bottom of the polygon.
2 Streets have 2 Linestrings, 1 only 1 Linestring (no green portion)
-- correct result:SRID=3068;MULTILINESTRING((24810.59736691505 23664.22581131355,24819.85698453766 23644.2248388537),(24835.38784578578 23610.67784579614,24846.64252081577 23586.3675065906))
--incorrect result:
SRID=3068;MULTILINESTRING((24810.59736691505 23664.22581131355,24825.88165313041 23631.21142560983),(24825.88165313041 23631.21142560983,24846.64252081577 23586.36750659061))
Since the same command (ST_Difference) is being used in both cases, with the same data - but always with same results
- I fail to see what the cause is
Weird is also that the left line only returns a single LINESTRING, when the other 2 return MULTILINESTRINGs.
Is a puzzlement ...
The archive contains the extracted Database and the sql-scripts (yours - which has the added real Polygon/Linestring and mine).
It also contains a geotif of the map for that area and the QGIS project.
Mark
bye Sandro
bye Sandro
a more robust approach:
1. precalculating all intersection points between polygon
rings and segments.
(temporarily saved as a single MultiPoint)
2. Snapping all segments against the above multipoint.
3. Snapping the polygon against the same multipoint.
these two steps together will ensure that now all
intersections are always explicitly represented by
some vertex, thus completely avoiding any furher need
to interpolate coordinates "on the fly" (the most
obvious cause introducing unexpected shifts).