1

Consider the following line (GeoJSON):

enter image description here

{
"type": "FeatureCollection",
"name": "longline",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 12.999790298013979, 51.989991736063956 ], [ 13.00086345470789, 51.989982154307761 ], [ 13.000786800658325, 51.989560557035155 ], [ 13.001649158715933, 51.989541393522764 ], [ 13.001725812765498, 51.989982154307761 ], [ 13.002703151897455, 51.989924663770587 ], [ 13.002559425554519, 51.98948390298559 ], [ 13.003623000492237, 51.989742610402871 ], [ 13.003402620099736, 51.990432496848953 ], [ 13.002894787021367, 51.990604968460474 ], [ 13.003479274149301, 51.991016983976891 ] ] } }
]
}

I have a second line that coincides exactly with a part of the longer line:

enter image description here

{
"type": "FeatureCollection",
"name": "shortline",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 12.999790298013979, 51.989991736063956 ], [ 13.000461224116039, 51.989985745652334 ] ] } }
]
}

What I'd like to do is erasing that shorter part from the longer line.

This needs to be done in a web application, so I cannot use desktop software or server-side scripts.

I am open to a pure JavaScript solution or to a solution that involves Turf.js.

Keep in mind that the shorter line might have multiple vetices (not just start and end).

0

Openlayers is a javascript library that can check for geometry intersections. see here

  • 1
    I am working with OL3. Finding the intersection is not the issue, the issue is getting rid of the intersecting part. – BritishSteel Oct 11 '17 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.