diff --git a/packages/turf-boolean-parallel/index.ts b/packages/turf-boolean-parallel/index.ts index 1c18d58305..5b055138dd 100644 --- a/packages/turf-boolean-parallel/index.ts +++ b/packages/turf-boolean-parallel/index.ts @@ -53,7 +53,7 @@ function booleanParallel( function isParallel(segment1: Position[], segment2: Position[]) { var slope1 = bearingToAzimuth(rhumbBearing(segment1[0], segment1[1])); var slope2 = bearingToAzimuth(rhumbBearing(segment2[0], segment2[1])); - return slope1 === slope2; + return slope1 === slope2 || (slope2 - slope1) % 180 === 0; } /** diff --git a/packages/turf-boolean-parallel/test/true/opposites.geojson b/packages/turf-boolean-parallel/test/true/opposites.geojson new file mode 100644 index 0000000000..7911a6359e --- /dev/null +++ b/packages/turf-boolean-parallel/test/true/opposites.geojson @@ -0,0 +1,27 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 0], + [1, 0] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 0], + [0, 0] + ] + } + } + ] +} diff --git a/packages/turf-boolean-parallel/test/true/verticals.geojson b/packages/turf-boolean-parallel/test/true/verticals.geojson new file mode 100644 index 0000000000..074b854941 --- /dev/null +++ b/packages/turf-boolean-parallel/test/true/verticals.geojson @@ -0,0 +1,27 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 0], + [0, 1] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 0], + [1, 1] + ] + } + } + ] +} diff --git a/packages/turf-boolean-parallel/test/true/verticals3d.geojson b/packages/turf-boolean-parallel/test/true/verticals3d.geojson new file mode 100644 index 0000000000..a6ab7a2819 --- /dev/null +++ b/packages/turf-boolean-parallel/test/true/verticals3d.geojson @@ -0,0 +1,27 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [-10, 20, 0], + [-10, 10, 0] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [-20, 20, 0], + [-20, 10, 0] + ] + } + } + ] +}