Question

Cut and shorten linestrings around object


Example. I have 1 linestring going into the object and 1 linestring coming out from the object.

 

Use case 1: I should simply shorten both linestrings so that there will be a buffer around object. So I should shorten linestring 1 from the end and linestring 2 from the start

 

Use case 2: I should cut both linestrings using area and then shorten all 4 a bit next to the area. But how do I know which way the linestrings are and how to shorten specifically from the end or from the start? image


3 replies

Userlevel 4
Badge +36

Buffer the object (Bufferer), and clip the lines (Clipper), keeping the outside geometries.

Buffer_and_Clip 

This helps for use case #1 and mostly to use case #2 as well but with that I should also know which side of the remaining lines stays as-is. Is there any attribute to tell that directly, I mean if linestring has the original startingpoint or endingpoint?

Userlevel 4
Badge +36

You can write the coordinates of the start (or end) point of the original linestring to attributes with a CoordinateExtractor, and afterwards compare the coordinates of the start (or end) point of the clipped linestring to determine which side was clipped.

Reply