-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
When one consecutive pair of nodes in a LineString passes all the way through a Polygon, it is still only clipped once, instead of twice.
var line = turfLinestring([[-1,-1], [5,5]]);
var poly = turfPolygon([[[0,0], [0,2], [1,2], [1,0], [0,0]]]);
var result = turfLineSliceAtIntersection(line, poly);
console.log(JSON.stringify(result));
// '{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-1,-1],[1,1]]},"properties":{}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[1,1],[5,5]]},"properties":{}}]}'A similar error occurs in cases with concave polygons, where a single line segment passes through the polygon multiple times. Interestingly, in this case the correct number of segments are output, but many of them overlap.
var line = turfLinestring([[0,-0.5], [3.5,3]]);
var poly = turfPolygon([[[0,0], [0,2], [1,2], [2,2], [2,1], [1,1], [1,0], [0,0]]]);
var result = turfLineSliceAtIntersection(line, poly);
console.log(JSON.stringify(result));
// {"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"LineString","coordinates":[[0,-0.5],[2,1.5]]},"properties":{}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[2,1.5],[1.5,1]]},"properties":{}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[1.5,1],[1,0.5]]},"properties":{}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[1,0.5],[0.5,0]]},"properties":{}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[0.5,0],[3.5,3]]},"properties":{}}]}Metadata
Metadata
Assignees
Labels
No labels