From 6bc6fa38badade4ba620f1189a1c0dbd75e88445 Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Sat, 13 Feb 2021 21:19:35 +1100 Subject: [PATCH 01/20] Rewrite line-intersect module --- packages/turf-line-intersect/bench.js | 12 +- packages/turf-line-intersect/index.ts | 134 ++++++------------ packages/turf-line-intersect/package.json | 5 +- packages/turf-line-intersect/test.js | 24 ++-- .../test/out/double-intersect.geojson | 4 +- .../test/out/multi-linestring.geojson | 20 +-- .../test/out/polygons-with-holes.geojson | 32 ++--- 7 files changed, 94 insertions(+), 137 deletions(-) diff --git a/packages/turf-line-intersect/bench.js b/packages/turf-line-intersect/bench.js index 4fcacc6759..7ef4482c99 100644 --- a/packages/turf-line-intersect/bench.js +++ b/packages/turf-line-intersect/bench.js @@ -2,7 +2,7 @@ const fs = require("fs"); const path = require("path"); const load = require("load-json-file"); const Benchmark = require("benchmark"); -const lineIntersect = require("./index"); +const lineIntersect = require("./index").default; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { @@ -16,11 +16,11 @@ const fixtures = fs.readdirSync(directory).map((filename) => { /** * Benchmark Results * - * 2-vertex-segment x 4,123,821 ops/sec ±12.92% (74 runs sampled) - * double-intersect x 53,118 ops/sec ±4.22% (72 runs sampled) - * multi-linestring x 16,417 ops/sec ±2.31% (77 runs sampled) - * polygons-with-holes x 9,739 ops/sec ±2.55% (85 runs sampled) - * same-coordinates x 51,303 ops/sec ±4.23% (71 runs sampled) + * 2-vertex-segment x 1,467,485 ops/sec ±1.74% (89 runs sampled) + * double-intersect x 307,665 ops/sec ±1.70% (91 runs sampled) + * multi-linestring x 81,337 ops/sec ±0.67% (94 runs sampled) + * polygons-with-holes x 27,711 ops/sec ±0.70% (92 runs sampled) + * same-coordinates x 521,277 ops/sec ±0.75% (92 runs sampled) */ const suite = new Benchmark.Suite("turf-line-intersect"); for (const { name, geojson } of fixtures) { diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index d8b0dc1671..2fbbd40461 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -10,10 +10,8 @@ import { Point, Polygon, } from "@turf/helpers"; -import { getCoords } from "@turf/invariant"; -import lineSegment from "@turf/line-segment"; -import { featureEach } from "@turf/meta"; -import rbush from "geojson-rbush"; + +import findIntersections from "sweepline-intersections"; /** * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s). @@ -21,6 +19,8 @@ import rbush from "geojson-rbush"; * @name lineIntersect * @param {GeoJSON} line1 any LineString or Polygon * @param {GeoJSON} line2 any LineString or Polygon + * @param {Object} [options={}] Optional parameters + * @param {number} [options.removeDuplicates=true] remove duplicate intersections * @returns {FeatureCollection} point(s) that intersect both * @example * var line1 = turf.lineString([[126, -11], [129, -21]]); @@ -35,100 +35,56 @@ function lineIntersect< G2 extends LineString | MultiLineString | Polygon | MultiPolygon >( line1: FeatureCollection | Feature | G1, - line2: FeatureCollection | Feature | G2 + line2: FeatureCollection | Feature | G2, + options: { + removeDuplicates?: boolean; + } = {} ): FeatureCollection { - const unique: any = {}; - const results: any[] = []; - - // First, normalize geometries to features - // Then, handle simple 2-vertex segments - if (line1.type === "LineString") { - line1 = feature(line1); + let removeDuplicates = true; + if ("removeDuplicates" in options) { + removeDuplicates = options.removeDuplicates; } - if (line2.type === "LineString") { - line2 = feature(line2); + + let features = []; + if (line1.type === "FeatureCollection") + features = features.concat(line1.features); + else if (line1.type === "Feature") features.push(line1); + else if ( + line1.type === "LineString" || + line1.type === "Polygon" || + line1.type === "MultiLineString" || + line1.type === "MultiPolygon" + ) { + features.push(feature(line1)); } - if ( - line1.type === "Feature" && - line2.type === "Feature" && - line1.geometry !== null && - line2.geometry !== null && - line1.geometry.type === "LineString" && - line2.geometry.type === "LineString" && - line1.geometry.coordinates.length === 2 && - line2.geometry.coordinates.length === 2 + + if (line2.type === "FeatureCollection") + features = features.concat(line2.features); + else if (line2.type === "Feature") features.push(line2); + else if ( + line2.type === "LineString" || + line2.type === "Polygon" || + line2.type === "MultiLineString" || + line2.type === "MultiPolygon" ) { - const intersect = intersects(line1, line2); - if (intersect) { - results.push(intersect); - } - return featureCollection(results); + features.push(feature(line2)); } - // Handles complex GeoJSON Geometries - const tree = rbush(); - tree.load(lineSegment(line2)); - featureEach(lineSegment(line1), (segment) => { - featureEach(tree.search(segment), (match) => { - const intersect = intersects(segment, match); - if (intersect) { - // prevent duplicate points https://github.com/Turfjs/turf/issues/688 - const key = getCoords(intersect).join(","); - if (!unique[key]) { - unique[key] = true; - results.push(intersect); - } + const intersections = findIntersections(featureCollection(features)); + let results = []; + if (removeDuplicates) { + const unique = {}; + intersections.forEach((intersection) => { + const key = intersection.join(","); + if (!unique[key]) { + unique[key] = true; + results.push(intersection); } }); - }); - return featureCollection(results); -} - -/** - * Find a point that intersects LineStrings with two coordinates each - * - * @private - * @param {Feature} line1 GeoJSON LineString (Must only contain 2 coordinates) - * @param {Feature} line2 GeoJSON LineString (Must only contain 2 coordinates) - * @returns {Feature} intersecting GeoJSON Point - */ -function intersects(line1: Feature, line2: Feature) { - const coords1: any = getCoords(line1); - const coords2: any = getCoords(line2); - if (coords1.length !== 2) { - throw new Error(" line1 must only contain 2 coordinates"); - } - if (coords2.length !== 2) { - throw new Error(" line2 must only contain 2 coordinates"); - } - const x1 = coords1[0][0]; - const y1 = coords1[0][1]; - const x2 = coords1[1][0]; - const y2 = coords1[1][1]; - const x3 = coords2[0][0]; - const y3 = coords2[0][1]; - const x4 = coords2[1][0]; - const y4 = coords2[1][1]; - const denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); - const numeA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); - const numeB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); - - if (denom === 0) { - if (numeA === 0 && numeB === 0) { - return null; - } - return null; - } - - const uA = numeA / denom; - const uB = numeB / denom; - - if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) { - const x = x1 + uA * (x2 - x1); - const y = y1 + uA * (y2 - y1); - return point([x, y]); + } else { + results = intersections; } - return null; + return featureCollection(results.map((r) => point(r))); } export default lineIntersect; diff --git a/packages/turf-line-intersect/package.json b/packages/turf-line-intersect/package.json index 8214cdfbb8..2146495d11 100644 --- a/packages/turf-line-intersect/package.json +++ b/packages/turf-line-intersect/package.json @@ -63,9 +63,6 @@ }, "dependencies": { "@turf/helpers": "^6.3.0", - "@turf/invariant": "^6.3.0", - "@turf/line-segment": "^6.3.0", - "@turf/meta": "^6.3.0", - "geojson-rbush": "3.x" + "sweepline-intersections": "^1.2.1" } } diff --git a/packages/turf-line-intersect/test.js b/packages/turf-line-intersect/test.js index 4341ea2c96..ae90347a40 100644 --- a/packages/turf-line-intersect/test.js +++ b/packages/turf-line-intersect/test.js @@ -6,7 +6,7 @@ const write = require("write-json-file"); const truncate = require("@turf/truncate").default; const { featureCollection, - geometryCollection, + // geometryCollection, lineString, polygon, } = require("@turf/helpers"); @@ -61,12 +61,10 @@ test("turf-line-intersect - prevent input mutation", (t) => { test("turf-line-intersect - Geometry Objects", (t) => { const line1 = lineString([ [7, 50], - [8, 50], [9, 50], ]); const line2 = lineString([ [8, 49], - [8, 50], [8, 51], ]); t.ok( @@ -78,13 +76,13 @@ test("turf-line-intersect - Geometry Objects", (t) => { .features.length, "support Feature Collection" ); - t.ok( - lineIntersect( - geometryCollection([line1.geometry]), - geometryCollection([line2.geometry]) - ).features.length, - "support Geometry Collection" - ); + // t.ok( + // lineIntersect( + // geometryCollection([line1.geometry]), + // geometryCollection([line2.geometry]) + // ).features.length, + // "support Geometry Collection" + // ); t.end(); }); @@ -102,6 +100,12 @@ test("turf-line-intersect - same point #688", (t) => { const results = lineIntersect(line1, line2); t.equal(results.features.length, 1, "should return single point"); + + const results2 = lineIntersect(line1, line2, { + removeDuplicates: false, + }); + t.equal(results2.features.length, 3, "should return three points"); + t.end(); }); diff --git a/packages/turf-line-intersect/test/out/double-intersect.geojson b/packages/turf-line-intersect/test/out/double-intersect.geojson index 1033548374..52acde8e47 100644 --- a/packages/turf-line-intersect/test/out/double-intersect.geojson +++ b/packages/turf-line-intersect/test/out/double-intersect.geojson @@ -6,7 +6,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [132.808697, -11.630938] + "coordinates": [119.832884, -19.58857] } }, { @@ -14,7 +14,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [119.832884, -19.58857] + "coordinates": [132.808697, -11.630938] } }, { diff --git a/packages/turf-line-intersect/test/out/multi-linestring.geojson b/packages/turf-line-intersect/test/out/multi-linestring.geojson index 120b5c2f2a..5a52196c66 100644 --- a/packages/turf-line-intersect/test/out/multi-linestring.geojson +++ b/packages/turf-line-intersect/test/out/multi-linestring.geojson @@ -6,7 +6,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [136.479474, -14.675333] + "coordinates": [117.006519, -20.917359] } }, { @@ -14,7 +14,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [136.389417, -14.506578] + "coordinates": [118.554586, -25.732946] } }, { @@ -22,7 +22,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [132.808697, -11.630938] + "coordinates": [119.832884, -19.58857] } }, { @@ -30,7 +30,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [135.006479, -11.91514] + "coordinates": [121.656735, -23.805914] } }, { @@ -38,7 +38,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [119.832884, -19.58857] + "coordinates": [132.658557, -18.734814] } }, { @@ -46,7 +46,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [117.006519, -20.917359] + "coordinates": [132.808697, -11.630938] } }, { @@ -54,7 +54,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [118.554586, -25.732946] + "coordinates": [135.006479, -11.91514] } }, { @@ -62,7 +62,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [121.656735, -23.805914] + "coordinates": [135.197772, -18.403004] } }, { @@ -70,7 +70,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [132.658557, -18.734814] + "coordinates": [136.389417, -14.506578] } }, { @@ -78,7 +78,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [135.197772, -18.403004] + "coordinates": [136.479474, -14.675333] } }, { diff --git a/packages/turf-line-intersect/test/out/polygons-with-holes.geojson b/packages/turf-line-intersect/test/out/polygons-with-holes.geojson index 9c30054b35..a39d1b3662 100644 --- a/packages/turf-line-intersect/test/out/polygons-with-holes.geojson +++ b/packages/turf-line-intersect/test/out/polygons-with-holes.geojson @@ -6,7 +6,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [122.447193, -17.011768] + "coordinates": [118.465639, -19.242649] } }, { @@ -14,7 +14,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [118.465639, -19.242649] + "coordinates": [120.170188, -33.654475] } }, { @@ -22,7 +22,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [120.170188, -33.654475] + "coordinates": [119.582432, -27.434744] } }, { @@ -30,7 +30,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [122.196098, -33.423855] + "coordinates": [120.17229, -21.344425] } }, { @@ -38,7 +38,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [126.041148, -32.826977] + "coordinates": [120.1132, -24.567108] } }, { @@ -46,7 +46,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [124.581243, -33.236589] + "coordinates": [120.201928, -30.393864] } }, { @@ -54,7 +54,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [123.377165, -29.942512] + "coordinates": [122.447193, -17.011768] } }, { @@ -62,7 +62,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [124.468085, -29.253959] + "coordinates": [122.196098, -33.423855] } }, { @@ -78,7 +78,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [120.201928, -30.393864] + "coordinates": [122.824274, -27.12517] } }, { @@ -86,7 +86,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [119.582432, -27.434744] + "coordinates": [123.053712, -24.567108] } }, { @@ -94,7 +94,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [122.824274, -27.12517] + "coordinates": [123.377165, -29.942512] } }, { @@ -102,7 +102,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [120.1132, -24.567108] + "coordinates": [123.320136, -18.187607] } }, { @@ -110,7 +110,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [123.053712, -24.567108] + "coordinates": [124.468085, -29.253959] } }, { @@ -118,7 +118,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [120.17229, -21.344425] + "coordinates": [124.392377, -19.890723] } }, { @@ -134,7 +134,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [124.392377, -19.890723] + "coordinates": [124.581243, -33.236589] } }, { @@ -142,7 +142,7 @@ "properties": {}, "geometry": { "type": "Point", - "coordinates": [123.320136, -18.187607] + "coordinates": [126.041148, -32.826977] } }, { From 1ed5100593907f469d18bd0e9d332c0ed517ed88 Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Wed, 17 Feb 2021 16:23:47 +1100 Subject: [PATCH 02/20] fix jsdoc --- packages/turf-line-intersect/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index 2fbbd40461..dbb945a63f 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -20,7 +20,7 @@ import findIntersections from "sweepline-intersections"; * @param {GeoJSON} line1 any LineString or Polygon * @param {GeoJSON} line2 any LineString or Polygon * @param {Object} [options={}] Optional parameters - * @param {number} [options.removeDuplicates=true] remove duplicate intersections + * @param {boolean} [options.removeDuplicates=true] remove duplicate intersections * @returns {FeatureCollection} point(s) that intersect both * @example * var line1 = turf.lineString([[126, -11], [129, -21]]); From f8e39fdd36ca258c9525947a0f088c57e42509ec Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Wed, 16 Jun 2021 22:35:36 +1000 Subject: [PATCH 03/20] update use of sweepline-intersections to not detect self-intersections --- packages/turf-line-intersect/index.ts | 2 +- packages/turf-line-intersect/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index dbb945a63f..da5f77a224 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -70,7 +70,7 @@ function lineIntersect< features.push(feature(line2)); } - const intersections = findIntersections(featureCollection(features)); + const intersections = findIntersections(featureCollection(features), false); let results = []; if (removeDuplicates) { const unique = {}; diff --git a/packages/turf-line-intersect/package.json b/packages/turf-line-intersect/package.json index 2146495d11..3925f9ff3e 100644 --- a/packages/turf-line-intersect/package.json +++ b/packages/turf-line-intersect/package.json @@ -63,6 +63,6 @@ }, "dependencies": { "@turf/helpers": "^6.3.0", - "sweepline-intersections": "^1.2.1" + "sweepline-intersections": "^1.3.1" } } From f7fe71547c4523a8007096496db33d2056c685e8 Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Sun, 20 Jun 2021 19:06:47 +1000 Subject: [PATCH 04/20] inline sweepline-intersections as es5 --- packages/turf-line-intersect/index.ts | 2 +- .../libs/sweepline-intersections.js | 336 ++++++++++++++++++ 2 files changed, 337 insertions(+), 1 deletion(-) create mode 100644 packages/turf-line-intersect/libs/sweepline-intersections.js diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index da5f77a224..d34b31391b 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -11,7 +11,7 @@ import { Polygon, } from "@turf/helpers"; -import findIntersections from "sweepline-intersections"; +import findIntersections from "./libs/sweepline-intersections"; /** * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s). diff --git a/packages/turf-line-intersect/libs/sweepline-intersections.js b/packages/turf-line-intersect/libs/sweepline-intersections.js new file mode 100644 index 0000000000..56225b0f11 --- /dev/null +++ b/packages/turf-line-intersect/libs/sweepline-intersections.js @@ -0,0 +1,336 @@ +// Inlined from +// https://github.com/rowanwins/sweepline-intersections +// Needed to go through babel to transform ES6 classes +var commonjsGlobal = + typeof globalThis !== "undefined" + ? globalThis + : typeof window !== "undefined" + ? window + : typeof global !== "undefined" + ? global + : typeof self !== "undefined" + ? self + : {}; + +function createCommonjsModule(fn, module) { + return (module = { exports: {} }), fn(module, module.exports), module.exports; +} + +var tinyqueue = createCommonjsModule(function (module, exports) { + (function (global, factory) { + module.exports = factory(); + })(commonjsGlobal, function () { + var TinyQueue = function TinyQueue(data, compare) { + if (data === void 0) data = []; + if (compare === void 0) compare = defaultCompare; + this.data = data; + this.length = this.data.length; + this.compare = compare; + + if (this.length > 0) { + for (var i = (this.length >> 1) - 1; i >= 0; i--) { + this._down(i); + } + } + }; + + TinyQueue.prototype.push = function push(item) { + this.data.push(item); + this.length++; + + this._up(this.length - 1); + }; + + TinyQueue.prototype.pop = function pop() { + if (this.length === 0) { + return undefined; + } + + var top = this.data[0]; + var bottom = this.data.pop(); + this.length--; + + if (this.length > 0) { + this.data[0] = bottom; + + this._down(0); + } + + return top; + }; + + TinyQueue.prototype.peek = function peek() { + return this.data[0]; + }; + + TinyQueue.prototype._up = function _up(pos) { + var ref = this; + var data = ref.data; + var compare = ref.compare; + var item = data[pos]; + + while (pos > 0) { + var parent = (pos - 1) >> 1; + var current = data[parent]; + + if (compare(item, current) >= 0) { + break; + } + + data[pos] = current; + pos = parent; + } + + data[pos] = item; + }; + + TinyQueue.prototype._down = function _down(pos) { + var ref = this; + var data = ref.data; + var compare = ref.compare; + var halfLength = this.length >> 1; + var item = data[pos]; + + while (pos < halfLength) { + var left = (pos << 1) + 1; + var best = data[left]; + var right = left + 1; + + if (right < this.length && compare(data[right], best) < 0) { + left = right; + best = data[right]; + } + + if (compare(best, item) >= 0) { + break; + } + + data[pos] = best; + pos = left; + } + + data[pos] = item; + }; + + function defaultCompare(a, b) { + return a < b ? -1 : a > b ? 1 : 0; + } + + return TinyQueue; + }); +}); + +function checkWhichEventIsLeft(e1, e2) { + if (e1.p.x > e2.p.x) return 1; + if (e1.p.x < e2.p.x) return -1; + if (e1.p.y !== e2.p.y) return e1.p.y > e2.p.y ? 1 : -1; + return 1; +} +function checkWhichSegmentHasRightEndpointFirst(seg1, seg2) { + if (seg1.rightSweepEvent.p.x > seg2.rightSweepEvent.p.x) return 1; + if (seg1.rightSweepEvent.p.x < seg2.rightSweepEvent.p.x) return -1; + if (seg1.rightSweepEvent.p.y !== seg2.rightSweepEvent.p.y) + return seg1.rightSweepEvent.p.y < seg2.rightSweepEvent.p.y ? 1 : -1; + return 1; +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +var Event = /*#__PURE__*/ (function () { + function Event(p, featureId, ringId, eventId) { + _classCallCheck(this, Event); + + this.p = { + x: p[0], + y: p[1], + }; + this.featureId = featureId; + this.ringId = ringId; + this.eventId = eventId; + this.otherEvent = null; + this.isLeftEndpoint = null; + } + + _createClass(Event, [ + { + key: "isSamePoint", + value: function isSamePoint(eventToCheck) { + return this.p.x === eventToCheck.p.x && this.p.y === eventToCheck.p.y; + }, + }, + ]); + + return Event; +})(); + +function fillEventQueue(geojson, eventQueue) { + if (geojson.type === "FeatureCollection") { + var features = geojson.features; + + for (var i = 0; i < features.length; i++) { + processFeature(features[i], eventQueue); + } + } else { + processFeature(geojson, eventQueue); + } +} +var featureId = 0; +var ringId = 0; +var eventId = 0; + +function processFeature(featureOrGeometry, eventQueue) { + var geom = + featureOrGeometry.type === "Feature" + ? featureOrGeometry.geometry + : featureOrGeometry; + var coords = geom.coordinates; // standardise the input + + if (geom.type === "Polygon" || geom.type === "MultiLineString") + coords = [coords]; + if (geom.type === "LineString") coords = [[coords]]; + + for (var i = 0; i < coords.length; i++) { + for (var ii = 0; ii < coords[i].length; ii++) { + var currentP = coords[i][ii][0]; + var nextP = null; + ringId = ringId + 1; + + for (var iii = 0; iii < coords[i][ii].length - 1; iii++) { + nextP = coords[i][ii][iii + 1]; + var e1 = new Event(currentP, featureId, ringId, eventId); + var e2 = new Event(nextP, featureId, ringId, eventId + 1); + e1.otherEvent = e2; + e2.otherEvent = e1; + + if (checkWhichEventIsLeft(e1, e2) > 0) { + e2.isLeftEndpoint = true; + e1.isLeftEndpoint = false; + } else { + e1.isLeftEndpoint = true; + e2.isLeftEndpoint = false; + } + + eventQueue.push(e1); + eventQueue.push(e2); + currentP = nextP; + eventId = eventId + 1; + } + } + } + + featureId = featureId + 1; +} + +function defaultCompare(a, b) { + return a < b ? -1 : a > b ? 1 : 0; +} + +var Segment = function Segment(event) { + _classCallCheck(this, Segment); + + this.leftSweepEvent = event; + this.rightSweepEvent = event.otherEvent; +}; + +function testSegmentIntersect(seg1, seg2) { + if (seg1 === null || seg2 === null) return false; + if ( + seg1.leftSweepEvent.ringId === seg2.leftSweepEvent.ringId && + (seg1.rightSweepEvent.isSamePoint(seg2.leftSweepEvent) || + seg1.rightSweepEvent.isSamePoint(seg2.leftSweepEvent) || + seg1.rightSweepEvent.isSamePoint(seg2.rightSweepEvent) || + seg1.leftSweepEvent.isSamePoint(seg2.leftSweepEvent) || + seg1.leftSweepEvent.isSamePoint(seg2.rightSweepEvent)) + ) + return false; + var x1 = seg1.leftSweepEvent.p.x; + var y1 = seg1.leftSweepEvent.p.y; + var x2 = seg1.rightSweepEvent.p.x; + var y2 = seg1.rightSweepEvent.p.y; + var x3 = seg2.leftSweepEvent.p.x; + var y3 = seg2.leftSweepEvent.p.y; + var x4 = seg2.rightSweepEvent.p.x; + var y4 = seg2.rightSweepEvent.p.y; + var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); + var numeA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); + var numeB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); + + if (denom === 0) { + if (numeA === 0 && numeB === 0) return false; + return false; + } + + var uA = numeA / denom; + var uB = numeB / denom; + + if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) { + var x = x1 + uA * (x2 - x1); + var y = y1 + uA * (y2 - y1); + return [x, y]; + } + + return false; +} + +function runCheck(eventQueue, ignoreSelfIntersections) { + ignoreSelfIntersections = ignoreSelfIntersections + ? ignoreSelfIntersections + : false; + var intersectionPoints = []; + var outQueue = new tinyqueue([], checkWhichSegmentHasRightEndpointFirst); + + while (eventQueue.length) { + var event = eventQueue.pop(); + + if (event.isLeftEndpoint) { + // debugEventAndSegments(event.p, outQueue.data) + var segment = new Segment(event); + + for (var i = 0; i < outQueue.data.length; i++) { + var otherSeg = outQueue.data[i]; + + if (ignoreSelfIntersections) { + if (otherSeg.leftSweepEvent.featureId === event.featureId) continue; + } + + var intersection = testSegmentIntersect(segment, otherSeg); + if (intersection !== false) intersectionPoints.push(intersection); + } + + outQueue.push(segment); + } else if (event.isLeftEndpoint === false) { + outQueue.pop(); // const seg = outQueue.pop() + // debugRemovingSegment(event.p, seg) + } + } + + return intersectionPoints; +} + +function sweeplineIntersections(geojson, ignoreSelfIntersections) { + var eventQueue = new tinyqueue([], checkWhichEventIsLeft); + fillEventQueue(geojson, eventQueue); + return runCheck(eventQueue, ignoreSelfIntersections); +} + +export default sweeplineIntersections; From 01217c9500961e1568ea002f96e577a597ee572d Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Sun, 20 Jun 2021 19:21:56 +1000 Subject: [PATCH 05/20] Add some ts config --- packages/turf-line-intersect/index.ts | 2 +- .../{libs => lib}/sweepline-intersections.js | 0 packages/turf-line-intersect/tsconfig.json | 7 +++++-- 3 files changed, 6 insertions(+), 3 deletions(-) rename packages/turf-line-intersect/{libs => lib}/sweepline-intersections.js (100%) diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index d34b31391b..a127d039da 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -11,7 +11,7 @@ import { Polygon, } from "@turf/helpers"; -import findIntersections from "./libs/sweepline-intersections"; +import findIntersections from "./lib/sweepline-intersections"; /** * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s). diff --git a/packages/turf-line-intersect/libs/sweepline-intersections.js b/packages/turf-line-intersect/lib/sweepline-intersections.js similarity index 100% rename from packages/turf-line-intersect/libs/sweepline-intersections.js rename to packages/turf-line-intersect/lib/sweepline-intersections.js diff --git a/packages/turf-line-intersect/tsconfig.json b/packages/turf-line-intersect/tsconfig.json index c3f78e4c94..b1ae7c38c0 100644 --- a/packages/turf-line-intersect/tsconfig.json +++ b/packages/turf-line-intersect/tsconfig.json @@ -3,5 +3,8 @@ "compilerOptions": { "outDir": "dist/js" }, - "files": ["index.ts"] -} + "files": [ + "index.ts", + "lib/sweepline-intersections.js", + ] +} \ No newline at end of file From 2e4c38c253f4d101da717f223d2901f2fe9c8f3e Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Sun, 20 Jun 2021 19:29:31 +1000 Subject: [PATCH 06/20] remove unused import --- packages/turf-line-intersect/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/turf-line-intersect/package.json b/packages/turf-line-intersect/package.json index 1e37a74f89..a1c4ca14a8 100644 --- a/packages/turf-line-intersect/package.json +++ b/packages/turf-line-intersect/package.json @@ -62,7 +62,6 @@ "write-json-file": "*" }, "dependencies": { - "@turf/helpers": "^6.4.0", - "sweepline-intersections": "^1.3.1" + "@turf/helpers": "^6.4.0" } } From dd025402e122ddadc512e485f3ed7c756037aee1 Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Sun, 20 Jun 2021 19:42:37 +1000 Subject: [PATCH 07/20] add allowJs --- packages/turf-line-intersect/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/turf-line-intersect/tsconfig.json b/packages/turf-line-intersect/tsconfig.json index b1ae7c38c0..c7a122fc1d 100644 --- a/packages/turf-line-intersect/tsconfig.json +++ b/packages/turf-line-intersect/tsconfig.json @@ -6,5 +6,6 @@ "files": [ "index.ts", "lib/sweepline-intersections.js", - ] + ], + "allowJs": true } \ No newline at end of file From 0790a03c510d086cf4567700f1b6533300afb96d Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Sun, 20 Jun 2021 19:50:59 +1000 Subject: [PATCH 08/20] adjust tsconfig --- packages/turf-line-intersect/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/turf-line-intersect/tsconfig.json b/packages/turf-line-intersect/tsconfig.json index c7a122fc1d..a492c4d4a8 100644 --- a/packages/turf-line-intersect/tsconfig.json +++ b/packages/turf-line-intersect/tsconfig.json @@ -1,11 +1,12 @@ { "extends": "../../tsconfig.shared.json", "compilerOptions": { + "allowJs": true, "outDir": "dist/js" }, "files": [ "index.ts", "lib/sweepline-intersections.js", ], - "allowJs": true + } \ No newline at end of file From 5cb1352f16b6f409b49b11bc0f78f99bbe84ebdd Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Sun, 20 Jun 2021 20:04:42 +1000 Subject: [PATCH 09/20] address some eslint issues --- packages/turf-line-intersect/lib/sweepline-intersections.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/turf-line-intersect/lib/sweepline-intersections.js b/packages/turf-line-intersect/lib/sweepline-intersections.js index 56225b0f11..f65f519dce 100644 --- a/packages/turf-line-intersect/lib/sweepline-intersections.js +++ b/packages/turf-line-intersect/lib/sweepline-intersections.js @@ -16,7 +16,7 @@ function createCommonjsModule(fn, module) { return (module = { exports: {} }), fn(module, module.exports), module.exports; } -var tinyqueue = createCommonjsModule(function (module, exports) { +var tinyqueue = createCommonjsModule(function (module) { (function (global, factory) { module.exports = factory(); })(commonjsGlobal, function () { @@ -241,10 +241,6 @@ function processFeature(featureOrGeometry, eventQueue) { featureId = featureId + 1; } -function defaultCompare(a, b) { - return a < b ? -1 : a > b ? 1 : 0; -} - var Segment = function Segment(event) { _classCallCheck(this, Segment); From a09c60c261150155c7b551710a0da3b99ff63761 Mon Sep 17 00:00:00 2001 From: Matt Fedderly Date: Wed, 4 Aug 2021 16:15:05 -0400 Subject: [PATCH 10/20] Some minor typing updates to get the build to pass --- packages/turf-line-intersect/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index a127d039da..ea7eb4ff02 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -42,10 +42,10 @@ function lineIntersect< ): FeatureCollection { let removeDuplicates = true; if ("removeDuplicates" in options) { - removeDuplicates = options.removeDuplicates; + removeDuplicates = options.removeDuplicates!; } - let features = []; + let features: Feature[] = []; if (line1.type === "FeatureCollection") features = features.concat(line1.features); else if (line1.type === "Feature") features.push(line1); @@ -71,9 +71,9 @@ function lineIntersect< } const intersections = findIntersections(featureCollection(features), false); - let results = []; + let results: any[] = []; if (removeDuplicates) { - const unique = {}; + const unique: { [key: string]: any } = {}; intersections.forEach((intersection) => { const key = intersection.join(","); if (!unique[key]) { From 9a5c3bf3160ed82008819f0a4ac75b8dbb5c5585 Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Mon, 17 Jan 2022 21:08:26 +1100 Subject: [PATCH 11/20] Fix imports after merge --- 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 c0e059d147..8240668142 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -1,3 +1,4 @@ +import { feature, featureCollection, point } from "@turf/helpers"; import { Feature, FeatureCollection, From eb6939d8e7da994a7502c574598c34d8296ff21a Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Mon, 17 Jan 2022 22:22:06 +1100 Subject: [PATCH 12/20] rejig ts config --- packages/turf-line-intersect/index.ts | 7 +- .../lib/sweepline-intersections.js | 332 ------------------ packages/turf-line-intersect/package.json | 1 + packages/turf-line-intersect/tsconfig.json | 8 +- .../types/sweepline-intersections.d.ts | 1 + 5 files changed, 11 insertions(+), 338 deletions(-) delete mode 100644 packages/turf-line-intersect/lib/sweepline-intersections.js create mode 100644 packages/turf-line-intersect/types/sweepline-intersections.d.ts diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index 8240668142..8cc421ff4b 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -9,7 +9,7 @@ import { Polygon, } from "geojson"; -import findIntersections from "./lib/sweepline-intersections"; +import findIntersections from "sweepline-intersections"; /** * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s). @@ -68,7 +68,10 @@ function lineIntersect< features.push(feature(line2)); } - const intersections = findIntersections(featureCollection(features), false); + const intersections: any[] = findIntersections( + featureCollection(features), + false + ); let results: any[] = []; if (removeDuplicates) { const unique: { [key: string]: any } = {}; diff --git a/packages/turf-line-intersect/lib/sweepline-intersections.js b/packages/turf-line-intersect/lib/sweepline-intersections.js deleted file mode 100644 index f65f519dce..0000000000 --- a/packages/turf-line-intersect/lib/sweepline-intersections.js +++ /dev/null @@ -1,332 +0,0 @@ -// Inlined from -// https://github.com/rowanwins/sweepline-intersections -// Needed to go through babel to transform ES6 classes -var commonjsGlobal = - typeof globalThis !== "undefined" - ? globalThis - : typeof window !== "undefined" - ? window - : typeof global !== "undefined" - ? global - : typeof self !== "undefined" - ? self - : {}; - -function createCommonjsModule(fn, module) { - return (module = { exports: {} }), fn(module, module.exports), module.exports; -} - -var tinyqueue = createCommonjsModule(function (module) { - (function (global, factory) { - module.exports = factory(); - })(commonjsGlobal, function () { - var TinyQueue = function TinyQueue(data, compare) { - if (data === void 0) data = []; - if (compare === void 0) compare = defaultCompare; - this.data = data; - this.length = this.data.length; - this.compare = compare; - - if (this.length > 0) { - for (var i = (this.length >> 1) - 1; i >= 0; i--) { - this._down(i); - } - } - }; - - TinyQueue.prototype.push = function push(item) { - this.data.push(item); - this.length++; - - this._up(this.length - 1); - }; - - TinyQueue.prototype.pop = function pop() { - if (this.length === 0) { - return undefined; - } - - var top = this.data[0]; - var bottom = this.data.pop(); - this.length--; - - if (this.length > 0) { - this.data[0] = bottom; - - this._down(0); - } - - return top; - }; - - TinyQueue.prototype.peek = function peek() { - return this.data[0]; - }; - - TinyQueue.prototype._up = function _up(pos) { - var ref = this; - var data = ref.data; - var compare = ref.compare; - var item = data[pos]; - - while (pos > 0) { - var parent = (pos - 1) >> 1; - var current = data[parent]; - - if (compare(item, current) >= 0) { - break; - } - - data[pos] = current; - pos = parent; - } - - data[pos] = item; - }; - - TinyQueue.prototype._down = function _down(pos) { - var ref = this; - var data = ref.data; - var compare = ref.compare; - var halfLength = this.length >> 1; - var item = data[pos]; - - while (pos < halfLength) { - var left = (pos << 1) + 1; - var best = data[left]; - var right = left + 1; - - if (right < this.length && compare(data[right], best) < 0) { - left = right; - best = data[right]; - } - - if (compare(best, item) >= 0) { - break; - } - - data[pos] = best; - pos = left; - } - - data[pos] = item; - }; - - function defaultCompare(a, b) { - return a < b ? -1 : a > b ? 1 : 0; - } - - return TinyQueue; - }); -}); - -function checkWhichEventIsLeft(e1, e2) { - if (e1.p.x > e2.p.x) return 1; - if (e1.p.x < e2.p.x) return -1; - if (e1.p.y !== e2.p.y) return e1.p.y > e2.p.y ? 1 : -1; - return 1; -} -function checkWhichSegmentHasRightEndpointFirst(seg1, seg2) { - if (seg1.rightSweepEvent.p.x > seg2.rightSweepEvent.p.x) return 1; - if (seg1.rightSweepEvent.p.x < seg2.rightSweepEvent.p.x) return -1; - if (seg1.rightSweepEvent.p.y !== seg2.rightSweepEvent.p.y) - return seg1.rightSweepEvent.p.y < seg2.rightSweepEvent.p.y ? 1 : -1; - return 1; -} - -function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -} - -function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } -} - -function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; -} - -var Event = /*#__PURE__*/ (function () { - function Event(p, featureId, ringId, eventId) { - _classCallCheck(this, Event); - - this.p = { - x: p[0], - y: p[1], - }; - this.featureId = featureId; - this.ringId = ringId; - this.eventId = eventId; - this.otherEvent = null; - this.isLeftEndpoint = null; - } - - _createClass(Event, [ - { - key: "isSamePoint", - value: function isSamePoint(eventToCheck) { - return this.p.x === eventToCheck.p.x && this.p.y === eventToCheck.p.y; - }, - }, - ]); - - return Event; -})(); - -function fillEventQueue(geojson, eventQueue) { - if (geojson.type === "FeatureCollection") { - var features = geojson.features; - - for (var i = 0; i < features.length; i++) { - processFeature(features[i], eventQueue); - } - } else { - processFeature(geojson, eventQueue); - } -} -var featureId = 0; -var ringId = 0; -var eventId = 0; - -function processFeature(featureOrGeometry, eventQueue) { - var geom = - featureOrGeometry.type === "Feature" - ? featureOrGeometry.geometry - : featureOrGeometry; - var coords = geom.coordinates; // standardise the input - - if (geom.type === "Polygon" || geom.type === "MultiLineString") - coords = [coords]; - if (geom.type === "LineString") coords = [[coords]]; - - for (var i = 0; i < coords.length; i++) { - for (var ii = 0; ii < coords[i].length; ii++) { - var currentP = coords[i][ii][0]; - var nextP = null; - ringId = ringId + 1; - - for (var iii = 0; iii < coords[i][ii].length - 1; iii++) { - nextP = coords[i][ii][iii + 1]; - var e1 = new Event(currentP, featureId, ringId, eventId); - var e2 = new Event(nextP, featureId, ringId, eventId + 1); - e1.otherEvent = e2; - e2.otherEvent = e1; - - if (checkWhichEventIsLeft(e1, e2) > 0) { - e2.isLeftEndpoint = true; - e1.isLeftEndpoint = false; - } else { - e1.isLeftEndpoint = true; - e2.isLeftEndpoint = false; - } - - eventQueue.push(e1); - eventQueue.push(e2); - currentP = nextP; - eventId = eventId + 1; - } - } - } - - featureId = featureId + 1; -} - -var Segment = function Segment(event) { - _classCallCheck(this, Segment); - - this.leftSweepEvent = event; - this.rightSweepEvent = event.otherEvent; -}; - -function testSegmentIntersect(seg1, seg2) { - if (seg1 === null || seg2 === null) return false; - if ( - seg1.leftSweepEvent.ringId === seg2.leftSweepEvent.ringId && - (seg1.rightSweepEvent.isSamePoint(seg2.leftSweepEvent) || - seg1.rightSweepEvent.isSamePoint(seg2.leftSweepEvent) || - seg1.rightSweepEvent.isSamePoint(seg2.rightSweepEvent) || - seg1.leftSweepEvent.isSamePoint(seg2.leftSweepEvent) || - seg1.leftSweepEvent.isSamePoint(seg2.rightSweepEvent)) - ) - return false; - var x1 = seg1.leftSweepEvent.p.x; - var y1 = seg1.leftSweepEvent.p.y; - var x2 = seg1.rightSweepEvent.p.x; - var y2 = seg1.rightSweepEvent.p.y; - var x3 = seg2.leftSweepEvent.p.x; - var y3 = seg2.leftSweepEvent.p.y; - var x4 = seg2.rightSweepEvent.p.x; - var y4 = seg2.rightSweepEvent.p.y; - var denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); - var numeA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); - var numeB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); - - if (denom === 0) { - if (numeA === 0 && numeB === 0) return false; - return false; - } - - var uA = numeA / denom; - var uB = numeB / denom; - - if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) { - var x = x1 + uA * (x2 - x1); - var y = y1 + uA * (y2 - y1); - return [x, y]; - } - - return false; -} - -function runCheck(eventQueue, ignoreSelfIntersections) { - ignoreSelfIntersections = ignoreSelfIntersections - ? ignoreSelfIntersections - : false; - var intersectionPoints = []; - var outQueue = new tinyqueue([], checkWhichSegmentHasRightEndpointFirst); - - while (eventQueue.length) { - var event = eventQueue.pop(); - - if (event.isLeftEndpoint) { - // debugEventAndSegments(event.p, outQueue.data) - var segment = new Segment(event); - - for (var i = 0; i < outQueue.data.length; i++) { - var otherSeg = outQueue.data[i]; - - if (ignoreSelfIntersections) { - if (otherSeg.leftSweepEvent.featureId === event.featureId) continue; - } - - var intersection = testSegmentIntersect(segment, otherSeg); - if (intersection !== false) intersectionPoints.push(intersection); - } - - outQueue.push(segment); - } else if (event.isLeftEndpoint === false) { - outQueue.pop(); // const seg = outQueue.pop() - // debugRemovingSegment(event.p, seg) - } - } - - return intersectionPoints; -} - -function sweeplineIntersections(geojson, ignoreSelfIntersections) { - var eventQueue = new tinyqueue([], checkWhichEventIsLeft); - fillEventQueue(geojson, eventQueue); - return runCheck(eventQueue, ignoreSelfIntersections); -} - -export default sweeplineIntersections; diff --git a/packages/turf-line-intersect/package.json b/packages/turf-line-intersect/package.json index 081d5febfd..b38b622913 100644 --- a/packages/turf-line-intersect/package.json +++ b/packages/turf-line-intersect/package.json @@ -68,6 +68,7 @@ "@turf/invariant": "^6.5.0", "@turf/line-segment": "^6.5.0", "@turf/meta": "^6.5.0", + "sweepline-intersections": "^1.3.1", "tslib": "^2.3.0" } } diff --git a/packages/turf-line-intersect/tsconfig.json b/packages/turf-line-intersect/tsconfig.json index a492c4d4a8..bd85546d18 100644 --- a/packages/turf-line-intersect/tsconfig.json +++ b/packages/turf-line-intersect/tsconfig.json @@ -1,12 +1,12 @@ { "extends": "../../tsconfig.shared.json", "compilerOptions": { + "strict": false, "allowJs": true, - "outDir": "dist/js" + "outDir": "dist/js", + "typeRoots": [ "./types"] }, "files": [ "index.ts", - "lib/sweepline-intersections.js", - ], - + ], } \ No newline at end of file diff --git a/packages/turf-line-intersect/types/sweepline-intersections.d.ts b/packages/turf-line-intersect/types/sweepline-intersections.d.ts new file mode 100644 index 0000000000..941186cf11 --- /dev/null +++ b/packages/turf-line-intersect/types/sweepline-intersections.d.ts @@ -0,0 +1 @@ +declare module "sweepline-intersections"; From c5f3dde3456d729109d0785f3e9498173bcd5e4b Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Tue, 18 Jan 2022 20:47:53 +1100 Subject: [PATCH 13/20] update yarn lock --- yarn.lock | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 6840489e18..8eeb1cd7f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9403,6 +9403,13 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== +sweepline-intersections@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/sweepline-intersections/-/sweepline-intersections-1.3.1.tgz#a1ec86e96d929f34c56ea02c84b8d93a6e3de8aa" + integrity sha512-5+e8gDZ7aWx/tymFqrUzAvMDhpMq1EM3gSFY9D08dIbMAEFB7X7g0J0piNkuxlhsSfbnyvvHqH5R+dBq4gRKZg== + dependencies: + tinyqueue "^2.0.0" + symbol-observable@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" @@ -9548,7 +9555,7 @@ tiny-lr@^1.1.0: object-assign "^4.1.0" qs "^6.4.0" -tinyqueue@^2.0.3: +tinyqueue@^2.0.0, tinyqueue@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/tinyqueue/-/tinyqueue-2.0.3.tgz#64d8492ebf39e7801d7bd34062e29b45b2035f08" integrity sha512-ppJZNDuKGgxzkHihX8v9v9G5f+18gzaTfrukGrq6ueg0lmH4nqVnA2IPG0AEH3jKEk2GRJCUhDoqpoiw3PHLBA== From 4005391031c1c73b9996ae082ba9e84b82ef5dc8 Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Fri, 18 Mar 2022 09:59:42 +1100 Subject: [PATCH 14/20] add extra option to line-intersect re self-intersections --- packages/turf-line-intersect/index.ts | 9 +++++++-- packages/turf-line-split/index.js | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index 8cc421ff4b..77f5d14071 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -19,6 +19,7 @@ import findIntersections from "sweepline-intersections"; * @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 * @returns {FeatureCollection} point(s) that intersect both * @example * var line1 = turf.lineString([[126, -11], [129, -21]]); @@ -36,13 +37,17 @@ function lineIntersect< line2: FeatureCollection | Feature | G2, options: { removeDuplicates?: boolean; + ignoreSelfIntersections? : boolean; } = {} ): FeatureCollection { let removeDuplicates = true; + let ignoreSelfIntersections = false; if ("removeDuplicates" in options) { removeDuplicates = options.removeDuplicates!; } - + if ("ignoreSelfIntersections" in options) { + ignoreSelfIntersections = options.ignoreSelfIntersections!; + } let features: Feature[] = []; if (line1.type === "FeatureCollection") features = features.concat(line1.features); @@ -70,7 +75,7 @@ function lineIntersect< const intersections: any[] = findIntersections( featureCollection(features), - false + ignoreSelfIntersections ); let results: any[] = []; if (removeDuplicates) { diff --git a/packages/turf-line-split/index.js b/packages/turf-line-split/index.js index 7f7eb6f44b..234ed647aa 100644 --- a/packages/turf-line-split/index.js +++ b/packages/turf-line-split/index.js @@ -51,7 +51,9 @@ function lineSplit(line, splitter) { case "MultiLineString": case "Polygon": case "MultiPolygon": - return splitLineWithPoints(line, lineIntersect(line, truncatedSplitter)); + return splitLineWithPoints(line, lineIntersect(line, truncatedSplitter, { + ignoreSelfIntersections: true + })); } } From 5bf86413e452bf23c48de2df2ddaf3f2e895ea74 Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Fri, 18 Mar 2022 10:09:55 +1100 Subject: [PATCH 15/20] run prettier --- packages/turf-line-intersect/index.ts | 2 +- packages/turf-line-split/index.js | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index 77f5d14071..95d1d51a99 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -37,7 +37,7 @@ function lineIntersect< line2: FeatureCollection | Feature | G2, options: { removeDuplicates?: boolean; - ignoreSelfIntersections? : boolean; + ignoreSelfIntersections?: boolean; } = {} ): FeatureCollection { let removeDuplicates = true; diff --git a/packages/turf-line-split/index.js b/packages/turf-line-split/index.js index 234ed647aa..70111057db 100644 --- a/packages/turf-line-split/index.js +++ b/packages/turf-line-split/index.js @@ -51,9 +51,12 @@ function lineSplit(line, splitter) { case "MultiLineString": case "Polygon": case "MultiPolygon": - return splitLineWithPoints(line, lineIntersect(line, truncatedSplitter, { - ignoreSelfIntersections: true - })); + return splitLineWithPoints( + line, + lineIntersect(line, truncatedSplitter, { + ignoreSelfIntersections: true, + }) + ); } } From 8b6821b91fddb5614bdd686f4653cfcd8b7fd0bf Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Fri, 18 Mar 2022 10:40:52 +1100 Subject: [PATCH 16/20] update the turf-line-split outputs --- .../test/out/polygon-with-holes.geojson | 109 +++++++----------- .../turf-line-split/test/out/polygon.geojson | 39 +++---- 2 files changed, 60 insertions(+), 88 deletions(-) diff --git a/packages/turf-line-split/test/out/polygon-with-holes.geojson b/packages/turf-line-split/test/out/polygon-with-holes.geojson index 5212c23295..1b715ddb8d 100644 --- a/packages/turf-line-split/test/out/polygon-with-holes.geojson +++ b/packages/turf-line-split/test/out/polygon-with-holes.geojson @@ -10,17 +10,13 @@ "geometry": { "type": "LineString", "coordinates": [ - [108.10546875, -24.607069137709694], - [116.103515625, -16.04581345375217], - [123.3984375, -14.689881366618762], - [123.80984529019764, -14.850144611823424] + [115.5887281750802, -33.66501705609563], + [113.99414062499999, -34.45221847282653] ] }, "bbox": [ - 108.10546875, - -27.50066352226305, - 123.80984529019764, - -11.796286982065407 + 113.99414062499999, -34.855911539501186, 115.5887281750802, + -33.261323989420966 ], "id": 0 }, @@ -33,16 +29,13 @@ "geometry": { "type": "LineString", "coordinates": [ - [123.80984529019764, -14.850144611823424], - [127.529296875, -16.299051014581817], - [131.8707236511523, -19.47488830290292] + [125.27477069463129, -28.883300057538364], + [115.5887281750802, -33.66501705609563] ] }, "bbox": [ - 123.80984529019764, - -19.47488830290292, - 131.8707236511523, - -14.850144611823424 + 115.5887281750802, -33.66501705609563, 125.27477069463129, + -28.883300057538364 ], "id": 1 }, @@ -55,18 +48,15 @@ "geometry": { "type": "LineString", "coordinates": [ - [131.8707236511523, -19.47488830290292], - [132.890625, -20.2209657795223], - [137.548828125, -22.67484735118852], - [144.05273437499997, -23.805449612314614], - [144.87133130139694, -24.083906137859618] + [108.10546875, -24.607069137709694], + [116.103515625, -16.04581345375217], + [123.3984375, -14.689881366618762], + [123.80984529019764, -14.850144611823424] ] }, "bbox": [ - 131.8707236511523, - -24.083906137859618, - 144.87133130139694, - -19.47488830290292 + 108.10546875, -24.607069137709694, 123.80984529019764, + -14.689881366618762 ], "id": 2 }, @@ -79,16 +69,14 @@ "geometry": { "type": "LineString", "coordinates": [ - [144.87133130139694, -24.083906137859618], - [150.380859375, -25.95804467331783], - [154.7611122904153, -29.8195405571525] + [123.80984529019764, -14.850144611823424], + [127.529296875, -16.299051014581817], + [131.8707236511523, -19.47488830290292] ] }, "bbox": [ - 144.87133130139694, - -29.8195405571525, - 154.7611122904153, - -24.083906137859618 + 123.80984529019764, -19.47488830290292, 131.8707236511523, + -14.850144611823424 ], "id": 3 }, @@ -101,17 +89,14 @@ "geometry": { "type": "LineString", "coordinates": [ - [154.7611122904153, -29.8195405571525], - [155.302734375, -30.29701788337204], - [160.3125, -37.64903402157864], - [152.83750336551705, -34.50536018265984] + [144.62835845465096, -31.052934], + [137.724609375, -28.14950321154457], + [127.705078125, -27.68352808378776], + [125.27477069463129, -28.883300057538364] ] }, "bbox": [ - 152.83750336551705, - -37.64903402157864, - 160.3125, - -29.8195405571525 + 125.27477069463129, -31.052934, 144.62835845465096, -27.68352808378776 ], "id": 4 }, @@ -124,15 +109,16 @@ "geometry": { "type": "LineString", "coordinates": [ - [152.83750336551705, -34.50536018265984], - [144.62835845465096, -31.052934] + [131.8707236511523, -19.47488830290292], + [132.890625, -20.2209657795223], + [137.548828125, -22.67484735118852], + [144.05273437499997, -23.805449612314614], + [144.87133130139694, -24.083906137859618] ] }, "bbox": [ - 144.62835845465096, - -34.50536018265984, - 152.83750336551705, - -31.052934 + 131.8707236511523, -24.083906137859618, 144.87133130139694, + -19.47488830290292 ], "id": 5 }, @@ -145,17 +131,14 @@ "geometry": { "type": "LineString", "coordinates": [ - [144.62835845465096, -31.052934], - [137.724609375, -28.14950321154457], - [127.705078125, -27.68352808378776], - [125.27477069463129, -28.883300057538364] + [144.87133130139694, -24.083906137859618], + [150.380859375, -25.95804467331783], + [154.7611122904153, -29.8195405571525] ] }, "bbox": [ - 125.27477069463129, - -31.052934, - 144.62835845465096, - -27.68352808378776 + 144.87133130139694, -29.8195405571525, 154.7611122904153, + -24.083906137859618 ], "id": 6 }, @@ -168,15 +151,14 @@ "geometry": { "type": "LineString", "coordinates": [ - [125.27477069463129, -28.883300057538364], - [115.5887281750802, -33.665017056095635] + [154.7611122904153, -29.8195405571525], + [155.302734375, -30.29701788337204], + [160.3125, -37.64903402157864], + [152.83750336551705, -34.50536018265984] ] }, "bbox": [ - 115.5887281750802, - -33.665017056095635, - 125.27477069463129, - -28.883300057538364 + 152.83750336551705, -37.64903402157864, 160.3125, -29.8195405571525 ] }, { @@ -188,15 +170,12 @@ "geometry": { "type": "LineString", "coordinates": [ - [115.5887281750802, -33.665017056095635], - [113.99414062499999, -34.45221847282653] + [152.83750336551705, -34.50536018265984], + [144.62835845465096, -31.052934] ] }, "bbox": [ - 113.99414062499999, - -34.45221847282653, - 115.5887281750802, - -33.665017056095635 + 144.62835845465096, -34.50536018265984, 152.83750336551705, -31.052934 ] }, { diff --git a/packages/turf-line-split/test/out/polygon.geojson b/packages/turf-line-split/test/out/polygon.geojson index 274c11c224..94bfa7965a 100644 --- a/packages/turf-line-split/test/out/polygon.geojson +++ b/packages/turf-line-split/test/out/polygon.geojson @@ -10,17 +10,15 @@ "geometry": { "type": "LineString", "coordinates": [ - [133.76953125, -5.44102230371796], - [133.38557423512307, -13.837223632933568] + [132.24601154296846, -33.23618973320634], + [131.66015625, -37.85750715625203] ] }, "bbox": [ - 129.37945207795372, - -13.837223632933568, - 137.77565340716933, - -5.44102230371796 + 129.64242518496138, -37.85750715625203, 134.26374260800708, + -33.23618973320634 ], - "id": 0 + "id": 1 }, { "type": "Feature", @@ -31,19 +29,12 @@ "geometry": { "type": "LineString", "coordinates": [ - [133.38557423512307, -13.837223632933568], - [133.2421875, -16.97274101999901], - [135.87890625, -20.2209657795223], - [137.548828125, -24.607069137709694], - [132.802734375, -28.84467368077178], - [132.24601154296846, -33.23618973320634] + [133.76953125, -5.44102230371796], + [133.38557423512307, -13.837223632933568] ] }, "bbox": [ - 132.24601154296846, - -33.23618973320634, - 137.548828125, - -13.837223632933568 + 133.38557423512307, -13.837223632933568, 133.76953125, -5.44102230371796 ] }, { @@ -55,15 +46,17 @@ "geometry": { "type": "LineString", "coordinates": [ - [132.24601154296846, -33.23618973320634], - [131.66015625, -37.85750715625203] + [133.38557423512307, -13.837223632933568], + [133.2421875, -16.97274101999901], + [135.87890625, -20.2209657795223], + [137.548828125, -24.607069137709694], + [132.802734375, -28.84467368077178], + [132.24601154296846, -33.23618973320634] ] }, "bbox": [ - 131.66015625, - -37.85750715625203, - 132.24601154296846, - -33.23618973320634 + 132.24601154296846, -33.23618973320634, 137.548828125, + -13.837223632933568 ] }, { From bb1ab42924398c6c6b7ac2122461d9958315cc37 Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Fri, 18 Mar 2022 11:11:00 +1100 Subject: [PATCH 17/20] fix prettier --- .../test/out/polygon-with-holes.geojson | 39 ++++++++++++++----- .../turf-line-split/test/out/polygon.geojson | 13 +++++-- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/packages/turf-line-split/test/out/polygon-with-holes.geojson b/packages/turf-line-split/test/out/polygon-with-holes.geojson index 1b715ddb8d..341df77682 100644 --- a/packages/turf-line-split/test/out/polygon-with-holes.geojson +++ b/packages/turf-line-split/test/out/polygon-with-holes.geojson @@ -15,7 +15,9 @@ ] }, "bbox": [ - 113.99414062499999, -34.855911539501186, 115.5887281750802, + 113.99414062499999, + -34.855911539501186, + 115.5887281750802, -33.261323989420966 ], "id": 0 @@ -34,7 +36,9 @@ ] }, "bbox": [ - 115.5887281750802, -33.66501705609563, 125.27477069463129, + 115.5887281750802, + -33.66501705609563, + 125.27477069463129, -28.883300057538364 ], "id": 1 @@ -55,7 +59,9 @@ ] }, "bbox": [ - 108.10546875, -24.607069137709694, 123.80984529019764, + 108.10546875, + -24.607069137709694, + 123.80984529019764, -14.689881366618762 ], "id": 2 @@ -75,7 +81,9 @@ ] }, "bbox": [ - 123.80984529019764, -19.47488830290292, 131.8707236511523, + 123.80984529019764, + -19.47488830290292, + 131.8707236511523, -14.850144611823424 ], "id": 3 @@ -96,7 +104,10 @@ ] }, "bbox": [ - 125.27477069463129, -31.052934, 144.62835845465096, -27.68352808378776 + 125.27477069463129, + -31.052934, + 144.62835845465096, + -27.68352808378776 ], "id": 4 }, @@ -117,7 +128,9 @@ ] }, "bbox": [ - 131.8707236511523, -24.083906137859618, 144.87133130139694, + 131.8707236511523, + -24.083906137859618, + 144.87133130139694, -19.47488830290292 ], "id": 5 @@ -137,7 +150,9 @@ ] }, "bbox": [ - 144.87133130139694, -29.8195405571525, 154.7611122904153, + 144.87133130139694, + -29.8195405571525, + 154.7611122904153, -24.083906137859618 ], "id": 6 @@ -158,7 +173,10 @@ ] }, "bbox": [ - 152.83750336551705, -37.64903402157864, 160.3125, -29.8195405571525 + 152.83750336551705, + -37.64903402157864, + 160.3125, + -29.8195405571525 ] }, { @@ -175,7 +193,10 @@ ] }, "bbox": [ - 144.62835845465096, -34.50536018265984, 152.83750336551705, -31.052934 + 144.62835845465096, + -34.50536018265984, + 152.83750336551705, + -31.052934 ] }, { diff --git a/packages/turf-line-split/test/out/polygon.geojson b/packages/turf-line-split/test/out/polygon.geojson index 94bfa7965a..07fc36a386 100644 --- a/packages/turf-line-split/test/out/polygon.geojson +++ b/packages/turf-line-split/test/out/polygon.geojson @@ -15,7 +15,9 @@ ] }, "bbox": [ - 129.64242518496138, -37.85750715625203, 134.26374260800708, + 129.64242518496138, + -37.85750715625203, + 134.26374260800708, -33.23618973320634 ], "id": 1 @@ -34,7 +36,10 @@ ] }, "bbox": [ - 133.38557423512307, -13.837223632933568, 133.76953125, -5.44102230371796 + 133.38557423512307, + -13.837223632933568, + 133.76953125, + -5.44102230371796 ] }, { @@ -55,7 +60,9 @@ ] }, "bbox": [ - 132.24601154296846, -33.23618973320634, 137.548828125, + 132.24601154296846, + -33.23618973320634, + 137.548828125, -13.837223632933568 ] }, From 472f471ccdd866edd81fb08cbf2594d0e1e40d92 Mon Sep 17 00:00:00 2001 From: Tim Welch Date: Sun, 20 Mar 2022 14:45:47 -0700 Subject: [PATCH 18/20] line-intersect additional type cleanup (#2273) * some cleanup * clarify Intersection type --- packages/turf-line-intersect/index.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index 95d1d51a99..ba18af3a18 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -40,15 +40,8 @@ function lineIntersect< ignoreSelfIntersections?: boolean; } = {} ): FeatureCollection { - let removeDuplicates = true; - let ignoreSelfIntersections = false; - if ("removeDuplicates" in options) { - removeDuplicates = options.removeDuplicates!; - } - if ("ignoreSelfIntersections" in options) { - ignoreSelfIntersections = options.ignoreSelfIntersections!; - } - let features: Feature[] = []; + const { removeDuplicates = true, ignoreSelfIntersections = false } = options; + let features: Feature[] = []; if (line1.type === "FeatureCollection") features = features.concat(line1.features); else if (line1.type === "Feature") features.push(line1); @@ -73,13 +66,19 @@ function lineIntersect< features.push(feature(line2)); } - const intersections: any[] = findIntersections( + /** + * Intersection point between two geometries + */ + type Intersection = [number, number]; + + const intersections = findIntersections( featureCollection(features), ignoreSelfIntersections - ); - let results: any[] = []; + ) as Intersection[]; + + let results: Intersection[] = []; if (removeDuplicates) { - const unique: { [key: string]: any } = {}; + const unique: Record = {}; intersections.forEach((intersection) => { const key = intersection.join(","); if (!unique[key]) { From c1af16d2daa0afa26da28a949b36d3af82387150 Mon Sep 17 00:00:00 2001 From: mfedderly Date: Sun, 20 Mar 2022 19:44:16 -0400 Subject: [PATCH 19/20] line-intersect-typescript-cleanup (#2274) --- packages/turf-line-intersect/index.ts | 10 ++-------- packages/turf-line-intersect/package.json | 4 ---- packages/turf-line-intersect/tsconfig.json | 9 ++------- .../types/sweepline-intersections.d.ts | 1 - 4 files changed, 4 insertions(+), 20 deletions(-) delete mode 100644 packages/turf-line-intersect/types/sweepline-intersections.d.ts diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index ba18af3a18..ced3c84f60 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -8,8 +8,7 @@ import { Point, Polygon, } from "geojson"; - -import findIntersections from "sweepline-intersections"; +import findIntersections, { Intersection } from "sweepline-intersections"; /** * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s). @@ -66,15 +65,10 @@ function lineIntersect< features.push(feature(line2)); } - /** - * Intersection point between two geometries - */ - type Intersection = [number, number]; - const intersections = findIntersections( featureCollection(features), ignoreSelfIntersections - ) as Intersection[]; + ); let results: Intersection[] = []; if (removeDuplicates) { diff --git a/packages/turf-line-intersect/package.json b/packages/turf-line-intersect/package.json index b38b622913..983adc8960 100644 --- a/packages/turf-line-intersect/package.json +++ b/packages/turf-line-intersect/package.json @@ -63,11 +63,7 @@ "write-json-file": "*" }, "dependencies": { - "@turf/geojson-rbush": "^3.2.0", "@turf/helpers": "^6.5.0", - "@turf/invariant": "^6.5.0", - "@turf/line-segment": "^6.5.0", - "@turf/meta": "^6.5.0", "sweepline-intersections": "^1.3.1", "tslib": "^2.3.0" } diff --git a/packages/turf-line-intersect/tsconfig.json b/packages/turf-line-intersect/tsconfig.json index bd85546d18..f1fb9dd127 100644 --- a/packages/turf-line-intersect/tsconfig.json +++ b/packages/turf-line-intersect/tsconfig.json @@ -1,12 +1,7 @@ { "extends": "../../tsconfig.shared.json", "compilerOptions": { - "strict": false, - "allowJs": true, - "outDir": "dist/js", - "typeRoots": [ "./types"] + "outDir": "dist/js" }, - "files": [ - "index.ts", - ], + "files": ["index.ts"] } \ No newline at end of file diff --git a/packages/turf-line-intersect/types/sweepline-intersections.d.ts b/packages/turf-line-intersect/types/sweepline-intersections.d.ts deleted file mode 100644 index 941186cf11..0000000000 --- a/packages/turf-line-intersect/types/sweepline-intersections.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module "sweepline-intersections"; From e7c5c03f96a8ec8384ed662955651b72e385fcaa Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Sat, 2 Apr 2022 14:24:11 +1100 Subject: [PATCH 20/20] bump sweepline-intersections to 1.4.0 --- packages/turf-line-intersect/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/turf-line-intersect/package.json b/packages/turf-line-intersect/package.json index 983adc8960..a84fe7bd20 100644 --- a/packages/turf-line-intersect/package.json +++ b/packages/turf-line-intersect/package.json @@ -64,7 +64,7 @@ }, "dependencies": { "@turf/helpers": "^6.5.0", - "sweepline-intersections": "^1.3.1", + "sweepline-intersections": "^1.4.0", "tslib": "^2.3.0" } } diff --git a/yarn.lock b/yarn.lock index 9fc8bbff40..4276354702 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9405,10 +9405,10 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== -sweepline-intersections@^1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/sweepline-intersections/-/sweepline-intersections-1.3.1.tgz#a1ec86e96d929f34c56ea02c84b8d93a6e3de8aa" - integrity sha512-5+e8gDZ7aWx/tymFqrUzAvMDhpMq1EM3gSFY9D08dIbMAEFB7X7g0J0piNkuxlhsSfbnyvvHqH5R+dBq4gRKZg== +sweepline-intersections@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/sweepline-intersections/-/sweepline-intersections-1.4.0.tgz#9a9843e0fd4829e83e48907506aef27256c564ab" + integrity sha512-OSqsMTRINvMQq9v/6KGaPnpXn2anbbm0lWR1bxa4OVScq7UBi7spK0jQE1q64/bYXZ478onjAa9lgdKLYL5HHQ== dependencies: tinyqueue "^2.0.0"