From f5df12145cdef445f15e8dc24e84ee43ee092fe0 Mon Sep 17 00:00:00 2001 From: Paul Mourer Date: Wed, 30 Oct 2024 08:31:04 -0600 Subject: [PATCH 1/7] Update self intersection argument, doc gen, add self intersection geojson test case, add self intersection test --- packages/turf-line-intersect/README.md | 7 +-- packages/turf-line-intersect/index.ts | 9 +-- packages/turf-line-intersect/test.ts | 61 ++++++++++++++++--- .../test/in/self-intersection-only.geojson | 30 +++++++++ .../test/out/self-intersection-only.geojson | 30 +++++++++ 5 files changed, 118 insertions(+), 19 deletions(-) create mode 100644 packages/turf-line-intersect/test/in/self-intersection-only.geojson create mode 100644 packages/turf-line-intersect/test/out/self-intersection-only.geojson diff --git a/packages/turf-line-intersect/README.md b/packages/turf-line-intersect/README.md index 2c9881046f..894e512b90 100644 --- a/packages/turf-line-intersect/README.md +++ b/packages/turf-line-intersect/README.md @@ -12,8 +12,8 @@ Takes any LineString or Polygon GeoJSON and returns the intersecting point(s). * `line2` **[GeoJSON][1]** any LineString or Polygon * `options` **[Object][2]** Optional parameters (optional, default `{}`) - * `options.removeDuplicates` **[boolean][3]** remove duplicate intersections (optional, default `true`) - * `options.ignoreSelfIntersections` **[boolean][3]** ignores self-intersections on input features (optional, default `false`) + * `options.removeDuplicates` **[boolean][3]** remove duplicate intersections (default `true`) (optional, default `true`) + * `options.ignoreSelfIntersections` **[boolean][3]** ignores self-intersections on input features (default `true`) (optional, default `true`) ### Examples @@ -21,9 +21,6 @@ Takes any LineString or Polygon GeoJSON and returns the intersecting point(s). var line1 = turf.lineString([[126, -11], [129, -21]]); var line2 = turf.lineString([[123, -18], [131, -14]]); var intersects = turf.lineIntersect(line1, line2); - -//addToMap -var addToMap = [line1, line2, intersects] ``` Returns **[FeatureCollection][4]<[Point][5]>** point(s) that intersect both diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index 3723bdba2f..add1700f98 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -18,16 +18,13 @@ import { sweeplineIntersections as findIntersections } from "./lib/sweepline-int * @param {GeoJSON} line1 any LineString or Polygon * @param {GeoJSON} line2 any LineString or Polygon * @param {Object} [options={}] Optional parameters - * @param {boolean} [options.removeDuplicates=true] remove duplicate intersections - * @param {boolean} [options.ignoreSelfIntersections=false] ignores self-intersections on input features + * @param {boolean} [options.removeDuplicates=true] remove duplicate intersections (default `true`) + * @param {boolean} [options.ignoreSelfIntersections=true] ignores self-intersections on input features (default `true`) * @returns {FeatureCollection} point(s) that intersect both * @example * var line1 = turf.lineString([[126, -11], [129, -21]]); * var line2 = turf.lineString([[123, -18], [131, -14]]); * var intersects = turf.lineIntersect(line1, line2); - * - * //addToMap - * var addToMap = [line1, line2, intersects] */ function lineIntersect< G1 extends LineString | MultiLineString | Polygon | MultiPolygon, @@ -40,7 +37,7 @@ function lineIntersect< ignoreSelfIntersections?: boolean; } = {} ): FeatureCollection { - const { removeDuplicates = true, ignoreSelfIntersections = false } = options; + const { removeDuplicates = true, ignoreSelfIntersections = true } = options; let features: Feature[] = []; if (line1.type === "FeatureCollection") features = features.concat(line1.features); diff --git a/packages/turf-line-intersect/test.ts b/packages/turf-line-intersect/test.ts index 40d45e91db..3f17e827b9 100644 --- a/packages/turf-line-intersect/test.ts +++ b/packages/turf-line-intersect/test.ts @@ -4,13 +4,9 @@ import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { truncate } from "@turf/truncate"; -import { - featureCollection, - // geometryCollection, - lineString, - polygon, -} from "@turf/helpers"; +import { featureCollection, lineString, polygon } from "@turf/helpers"; import { lineIntersect } from "./index.js"; +import { Feature, LineString, Point } from "geojson"; const directories = { in: path.join("test", "in") + path.sep, @@ -21,14 +17,18 @@ const fixtures = fs.readdirSync(directories.in).map((filename) => { return { filename, name: path.parse(filename).name, - geojson: loadJsonFileSync(directories.in + filename), + geojson: loadJsonFileSync( + directories.in + filename + ) as GeoJSON.FeatureCollection, }; }); test("turf-line-intersect", (t) => { for (const { filename, name, geojson } of fixtures) { const [line1, line2] = geojson.features; - const results = truncate(lineIntersect(line1, line2)); + const results: GeoJSON.FeatureCollection = truncate( + lineIntersect(line1, line2) + ); results.features.push(line1); results.features.push(line2); @@ -132,3 +132,48 @@ test("turf-line-intersect - polygon support #586", (t) => { t.equal(results.features.length, 1, "should return single point"); t.end(); }); + +test("turf-line-intersect - self intersection behavior", (t) => { + const line1: Feature = { + type: "Feature", + properties: {}, + geometry: { + type: "LineString", + coordinates: [ + [0, 0], + [0, 2], + [2, 1], + [-1, 1], + ], + }, + }; + const line2: Feature = { + type: "Feature", + properties: {}, + geometry: { + type: "LineString", + coordinates: [ + [3, 3], + [4, 4], + [5, 5], + ], + }, + }; + + const ignored = lineIntersect(line1, line2); + t.equal( + ignored.features.length, + 0, + "self intersections should be ignored by default" + ); + + const included = lineIntersect(line1, line2, { + ignoreSelfIntersections: false, + }); + t.equal( + included.features.length, + 1, + "self intersections should be included when ignoreSelfIntersections set to false" + ); + t.end(); +}); diff --git a/packages/turf-line-intersect/test/in/self-intersection-only.geojson b/packages/turf-line-intersect/test/in/self-intersection-only.geojson new file mode 100644 index 0000000000..ec5b6ebf7c --- /dev/null +++ b/packages/turf-line-intersect/test/in/self-intersection-only.geojson @@ -0,0 +1,30 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 0], + [0, 2], + [2, 1], + [-1, 1] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [3, 3], + [4, 4], + [5, 5] + ] + } + } + ] +} diff --git a/packages/turf-line-intersect/test/out/self-intersection-only.geojson b/packages/turf-line-intersect/test/out/self-intersection-only.geojson new file mode 100644 index 0000000000..ec5b6ebf7c --- /dev/null +++ b/packages/turf-line-intersect/test/out/self-intersection-only.geojson @@ -0,0 +1,30 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 0], + [0, 2], + [2, 1], + [-1, 1] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [3, 3], + [4, 4], + [5, 5] + ] + } + } + ] +} From a0be0c2a2c92d796f67a74c2cd812f1236585f2b Mon Sep 17 00:00:00 2001 From: Paul Mourer Date: Tue, 3 Dec 2024 19:50:15 -0700 Subject: [PATCH 2/7] Remove additional param clarifications --- packages/turf-line-intersect/README.md | 4 ++-- packages/turf-line-intersect/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/turf-line-intersect/README.md b/packages/turf-line-intersect/README.md index 894e512b90..7d735d7254 100644 --- a/packages/turf-line-intersect/README.md +++ b/packages/turf-line-intersect/README.md @@ -12,8 +12,8 @@ Takes any LineString or Polygon GeoJSON and returns the intersecting point(s). * `line2` **[GeoJSON][1]** any LineString or Polygon * `options` **[Object][2]** Optional parameters (optional, default `{}`) - * `options.removeDuplicates` **[boolean][3]** remove duplicate intersections (default `true`) (optional, default `true`) - * `options.ignoreSelfIntersections` **[boolean][3]** ignores self-intersections on input features (default `true`) (optional, default `true`) + * `options.removeDuplicates` **[boolean][3]** remove duplicate intersections (optional, default `true`) + * `options.ignoreSelfIntersections` **[boolean][3]** ignores self-intersections on input features (optional, default `true`) ### Examples diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index add1700f98..4262a9fa1c 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -18,8 +18,8 @@ import { sweeplineIntersections as findIntersections } from "./lib/sweepline-int * @param {GeoJSON} line1 any LineString or Polygon * @param {GeoJSON} line2 any LineString or Polygon * @param {Object} [options={}] Optional parameters - * @param {boolean} [options.removeDuplicates=true] remove duplicate intersections (default `true`) - * @param {boolean} [options.ignoreSelfIntersections=true] ignores self-intersections on input features (default `true`) + * @param {boolean} [options.removeDuplicates=true] remove duplicate intersections + * @param {boolean} [options.ignoreSelfIntersections=true] ignores self-intersections on input features * @returns {FeatureCollection} point(s) that intersect both * @example * var line1 = turf.lineString([[126, -11], [129, -21]]); From 7a54fec8815244096e72fd6a34e684b9d9fcdfc5 Mon Sep 17 00:00:00 2001 From: Paul Mourer Date: Tue, 3 Dec 2024 20:29:28 -0700 Subject: [PATCH 3/7] Add fixture for self intersecting multi-line in non-intersecting collection --- .../in/self-intersecting-multiline.geojson | 36 +++++++++++++++++++ .../out/self-intersecting-multiline.geojson | 36 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 packages/turf-line-intersect/test/in/self-intersecting-multiline.geojson create mode 100644 packages/turf-line-intersect/test/out/self-intersecting-multiline.geojson diff --git a/packages/turf-line-intersect/test/in/self-intersecting-multiline.geojson b/packages/turf-line-intersect/test/in/self-intersecting-multiline.geojson new file mode 100644 index 0000000000..9f08036d83 --- /dev/null +++ b/packages/turf-line-intersect/test/in/self-intersecting-multiline.geojson @@ -0,0 +1,36 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiLineString", + "coordinates": [ + [ + [0, 0], + [1, 2], + [0, 4] + ], + [ + [1, 0], + [0, 2], + [1, 4] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [3, 3], + [4, 4], + [5, 5] + ] + } + } + ] +} diff --git a/packages/turf-line-intersect/test/out/self-intersecting-multiline.geojson b/packages/turf-line-intersect/test/out/self-intersecting-multiline.geojson new file mode 100644 index 0000000000..9f08036d83 --- /dev/null +++ b/packages/turf-line-intersect/test/out/self-intersecting-multiline.geojson @@ -0,0 +1,36 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiLineString", + "coordinates": [ + [ + [0, 0], + [1, 2], + [0, 4] + ], + [ + [1, 0], + [0, 2], + [1, 4] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [3, 3], + [4, 4], + [5, 5] + ] + } + } + ] +} From e77c500320dec589faf9214d8433e4c9284d058c Mon Sep 17 00:00:00 2001 From: Paul Mourer Date: Tue, 3 Dec 2024 20:44:18 -0700 Subject: [PATCH 4/7] More test cases --- ...geojson => self-intersecting-line.geojson} | 0 .../in/self-intersecting-multipoly.geojson | 52 +++++++++++++++++++ .../test/in/self-intersecting-poly.geojson | 44 ++++++++++++++++ ...geojson => self-intersecting-line.geojson} | 0 .../out/self-intersecting-multipoly.geojson | 52 +++++++++++++++++++ .../test/out/self-intersecting-poly.geojson | 44 ++++++++++++++++ 6 files changed, 192 insertions(+) rename packages/turf-line-intersect/test/in/{self-intersection-only.geojson => self-intersecting-line.geojson} (100%) create mode 100644 packages/turf-line-intersect/test/in/self-intersecting-multipoly.geojson create mode 100644 packages/turf-line-intersect/test/in/self-intersecting-poly.geojson rename packages/turf-line-intersect/test/out/{self-intersection-only.geojson => self-intersecting-line.geojson} (100%) create mode 100644 packages/turf-line-intersect/test/out/self-intersecting-multipoly.geojson create mode 100644 packages/turf-line-intersect/test/out/self-intersecting-poly.geojson diff --git a/packages/turf-line-intersect/test/in/self-intersection-only.geojson b/packages/turf-line-intersect/test/in/self-intersecting-line.geojson similarity index 100% rename from packages/turf-line-intersect/test/in/self-intersection-only.geojson rename to packages/turf-line-intersect/test/in/self-intersecting-line.geojson diff --git a/packages/turf-line-intersect/test/in/self-intersecting-multipoly.geojson b/packages/turf-line-intersect/test/in/self-intersecting-multipoly.geojson new file mode 100644 index 0000000000..f907df2dc7 --- /dev/null +++ b/packages/turf-line-intersect/test/in/self-intersecting-multipoly.geojson @@ -0,0 +1,52 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "fill": "#ed333b", + "fill-opacity": 0.5 + }, + "geometry": { + "coordinates": [ + [ + [ + [2.8208987964653716, 5.206515064293427], + [2.8208987964653716, -4.530167455797994], + [6.383916833323553, -4.530167455797994], + [6.383916833323553, 5.206515064293427], + [2.8208987964653716, 5.206515064293427] + ] + ], + [ + [ + [-0.33343506038161763, 3.67541603033537], + [-0.33343506038161763, 2.1793088174136273], + [8.775841349855597, 2.1793088174136273], + [8.775841349855597, 3.67541603033537], + [-0.33343506038161763, 3.67541603033537] + ] + ] + ], + "type": "MultiPolygon" + }, + "id": 0 + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "coordinates": [ + [ + [-7.951422534380413, 5.231149187754099], + [-7.951422534380413, -4.552832252613101], + [-5.701165954657256, -4.552832252613101], + [-5.701165954657256, 5.231149187754099], + [-7.951422534380413, 5.231149187754099] + ] + ], + "type": "Polygon" + } + } + ] +} diff --git a/packages/turf-line-intersect/test/in/self-intersecting-poly.geojson b/packages/turf-line-intersect/test/in/self-intersecting-poly.geojson new file mode 100644 index 0000000000..241a878a9e --- /dev/null +++ b/packages/turf-line-intersect/test/in/self-intersecting-poly.geojson @@ -0,0 +1,44 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "coordinates": [ + [ + [-0.8680870854922205, 3.0368343508535673], + [-1.321147431010786, 5.333329344976903], + [1.0099462525165848, 5.611566335081363], + [0.47439299724965167, -1.9282285399474688], + [3.2162894164922875, -1.8166964568157766], + [2.707220996335252, 7.192842763774053], + [-3.8645185945755713, 6.519248925309753], + [-3.8571038955967083, 0.3483632770754781], + [-0.5093053180867742, 0.39824548653076874], + [4.4119165583018685, 0.21046777461485533], + [3.9804563423212755, 3.7937082620644844], + [-0.8680870854922205, 3.0368343508535673] + ] + ], + "type": "Polygon" + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "coordinates": [ + [ + [-7.4564971746842446, 6.278543929857676], + [-13.631981273628753, 6.323585458965155], + [-12.43687692686214, -2.589094309688946], + [-6.376915352576532, -3.0767722870515115], + [-7.4564971746842446, 6.278543929857676] + ] + ], + "type": "Polygon" + } + } + ] +} diff --git a/packages/turf-line-intersect/test/out/self-intersection-only.geojson b/packages/turf-line-intersect/test/out/self-intersecting-line.geojson similarity index 100% rename from packages/turf-line-intersect/test/out/self-intersection-only.geojson rename to packages/turf-line-intersect/test/out/self-intersecting-line.geojson diff --git a/packages/turf-line-intersect/test/out/self-intersecting-multipoly.geojson b/packages/turf-line-intersect/test/out/self-intersecting-multipoly.geojson new file mode 100644 index 0000000000..f907df2dc7 --- /dev/null +++ b/packages/turf-line-intersect/test/out/self-intersecting-multipoly.geojson @@ -0,0 +1,52 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "fill": "#ed333b", + "fill-opacity": 0.5 + }, + "geometry": { + "coordinates": [ + [ + [ + [2.8208987964653716, 5.206515064293427], + [2.8208987964653716, -4.530167455797994], + [6.383916833323553, -4.530167455797994], + [6.383916833323553, 5.206515064293427], + [2.8208987964653716, 5.206515064293427] + ] + ], + [ + [ + [-0.33343506038161763, 3.67541603033537], + [-0.33343506038161763, 2.1793088174136273], + [8.775841349855597, 2.1793088174136273], + [8.775841349855597, 3.67541603033537], + [-0.33343506038161763, 3.67541603033537] + ] + ] + ], + "type": "MultiPolygon" + }, + "id": 0 + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "coordinates": [ + [ + [-7.951422534380413, 5.231149187754099], + [-7.951422534380413, -4.552832252613101], + [-5.701165954657256, -4.552832252613101], + [-5.701165954657256, 5.231149187754099], + [-7.951422534380413, 5.231149187754099] + ] + ], + "type": "Polygon" + } + } + ] +} diff --git a/packages/turf-line-intersect/test/out/self-intersecting-poly.geojson b/packages/turf-line-intersect/test/out/self-intersecting-poly.geojson new file mode 100644 index 0000000000..241a878a9e --- /dev/null +++ b/packages/turf-line-intersect/test/out/self-intersecting-poly.geojson @@ -0,0 +1,44 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "coordinates": [ + [ + [-0.8680870854922205, 3.0368343508535673], + [-1.321147431010786, 5.333329344976903], + [1.0099462525165848, 5.611566335081363], + [0.47439299724965167, -1.9282285399474688], + [3.2162894164922875, -1.8166964568157766], + [2.707220996335252, 7.192842763774053], + [-3.8645185945755713, 6.519248925309753], + [-3.8571038955967083, 0.3483632770754781], + [-0.5093053180867742, 0.39824548653076874], + [4.4119165583018685, 0.21046777461485533], + [3.9804563423212755, 3.7937082620644844], + [-0.8680870854922205, 3.0368343508535673] + ] + ], + "type": "Polygon" + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "coordinates": [ + [ + [-7.4564971746842446, 6.278543929857676], + [-13.631981273628753, 6.323585458965155], + [-12.43687692686214, -2.589094309688946], + [-6.376915352576532, -3.0767722870515115], + [-7.4564971746842446, 6.278543929857676] + ] + ], + "type": "Polygon" + } + } + ] +} From 85590321b4b166956f2098fe930e875a27f03725 Mon Sep 17 00:00:00 2001 From: Paul Mourer Date: Tue, 10 Dec 2024 20:21:10 -0700 Subject: [PATCH 5/7] revert removal of example, add comment explaining test --- packages/turf-line-intersect/README.md | 2 ++ packages/turf-line-intersect/index.ts | 2 ++ packages/turf-line-intersect/test.ts | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/packages/turf-line-intersect/README.md b/packages/turf-line-intersect/README.md index 894e512b90..43af9becfc 100644 --- a/packages/turf-line-intersect/README.md +++ b/packages/turf-line-intersect/README.md @@ -21,6 +21,8 @@ Takes any LineString or Polygon GeoJSON and returns the intersecting point(s). var line1 = turf.lineString([[126, -11], [129, -21]]); var line2 = turf.lineString([[123, -18], [131, -14]]); var intersects = turf.lineIntersect(line1, line2); +//addToMap +var addToMap = [line1, line2, intersects] ``` Returns **[FeatureCollection][4]<[Point][5]>** point(s) that intersect both diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index add1700f98..f01f00c3b1 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -25,6 +25,8 @@ import { sweeplineIntersections as findIntersections } from "./lib/sweepline-int * var line1 = turf.lineString([[126, -11], [129, -21]]); * var line2 = turf.lineString([[123, -18], [131, -14]]); * var intersects = turf.lineIntersect(line1, line2); + * //addToMap + * var addToMap = [line1, line2, intersects] */ function lineIntersect< G1 extends LineString | MultiLineString | Polygon | MultiPolygon, diff --git a/packages/turf-line-intersect/test.ts b/packages/turf-line-intersect/test.ts index 3f17e827b9..c610925726 100644 --- a/packages/turf-line-intersect/test.ts +++ b/packages/turf-line-intersect/test.ts @@ -133,6 +133,10 @@ test("turf-line-intersect - polygon support #586", (t) => { t.end(); }); +/** + * ensures that the self intersection param behaves as expected - + * since it cannot be verified in the fixture format. + */ test("turf-line-intersect - self intersection behavior", (t) => { const line1: Feature = { type: "Feature", From cc80f9bddea4752af9c6d69cb9c874c7b9442612 Mon Sep 17 00:00:00 2001 From: Paul Mourer Date: Tue, 10 Dec 2024 20:29:03 -0700 Subject: [PATCH 6/7] re include newline in example --- packages/turf-line-intersect/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index 5e05b0ffb0..7e29778961 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -25,6 +25,7 @@ import { sweeplineIntersections as findIntersections } from "./lib/sweepline-int * var line1 = turf.lineString([[126, -11], [129, -21]]); * var line2 = turf.lineString([[123, -18], [131, -14]]); * var intersects = turf.lineIntersect(line1, line2); + * * //addToMap * var addToMap = [line1, line2, intersects] */ From 542bba72e306d74316ec101de80606b39afa0ba4 Mon Sep 17 00:00:00 2001 From: Paul Mourer Date: Tue, 10 Dec 2024 20:30:11 -0700 Subject: [PATCH 7/7] update readme --- packages/turf-line-intersect/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/turf-line-intersect/README.md b/packages/turf-line-intersect/README.md index 2c85985478..6e389836c5 100644 --- a/packages/turf-line-intersect/README.md +++ b/packages/turf-line-intersect/README.md @@ -21,6 +21,7 @@ Takes any LineString or Polygon GeoJSON and returns the intersecting point(s). var line1 = turf.lineString([[126, -11], [129, -21]]); var line2 = turf.lineString([[123, -18], [131, -14]]); var intersects = turf.lineIntersect(line1, line2); + //addToMap var addToMap = [line1, line2, intersects] ```