@turf/line-intersect 7.1.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/index.cjs +3 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -2
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +3 -5
- package/dist/esm/index.js.map +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
|
|
|
13
13
|
* `options` **[Object][2]** Optional parameters (optional, default `{}`)
|
|
14
14
|
|
|
15
15
|
* `options.removeDuplicates` **[boolean][3]** remove duplicate intersections (optional, default `true`)
|
|
16
|
-
* `options.ignoreSelfIntersections` **[boolean][3]** ignores self-intersections on input features (optional, default `
|
|
16
|
+
* `options.ignoreSelfIntersections` **[boolean][3]** ignores self-intersections on input features (optional, default `true`)
|
|
17
17
|
|
|
18
18
|
### Examples
|
|
19
19
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -7,19 +7,17 @@ var sweeplineIntersections = _sweeplineintersections2.default;
|
|
|
7
7
|
|
|
8
8
|
// index.ts
|
|
9
9
|
function lineIntersect(line1, line2, options = {}) {
|
|
10
|
-
const { removeDuplicates = true, ignoreSelfIntersections =
|
|
10
|
+
const { removeDuplicates = true, ignoreSelfIntersections = true } = options;
|
|
11
11
|
let features = [];
|
|
12
12
|
if (line1.type === "FeatureCollection")
|
|
13
13
|
features = features.concat(line1.features);
|
|
14
|
-
else if (line1.type === "Feature")
|
|
15
|
-
features.push(line1);
|
|
14
|
+
else if (line1.type === "Feature") features.push(line1);
|
|
16
15
|
else if (line1.type === "LineString" || line1.type === "Polygon" || line1.type === "MultiLineString" || line1.type === "MultiPolygon") {
|
|
17
16
|
features.push(_helpers.feature.call(void 0, line1));
|
|
18
17
|
}
|
|
19
18
|
if (line2.type === "FeatureCollection")
|
|
20
19
|
features = features.concat(line2.features);
|
|
21
|
-
else if (line2.type === "Feature")
|
|
22
|
-
features.push(line2);
|
|
20
|
+
else if (line2.type === "Feature") features.push(line2);
|
|
23
21
|
else if (line2.type === "LineString" || line2.type === "Polygon" || line2.type === "MultiLineString" || line2.type === "MultiPolygon") {
|
|
24
22
|
features.push(_helpers.feature.call(void 0, line2));
|
|
25
23
|
}
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts","../../lib/sweepline-intersections-export.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-line-intersect/dist/cjs/index.cjs","../../index.ts","../../lib/sweepline-intersections-export.ts"],"names":[],"mappings":"AAAA;ACAA,wCAAkD;ADElD;AACA;AECA,iJAAgB;AAET,IAAM,uBAAA,EAAyB,gCAAA;AFAtC;AACA;ACwBA,SAAS,aAAA,CAIP,KAAA,EACA,KAAA,EACA,QAAA,EAGI,CAAC,CAAA,EACqB;AAC1B,EAAA,MAAM,EAAE,iBAAA,EAAmB,IAAA,EAAM,wBAAA,EAA0B,KAAK,EAAA,EAAI,OAAA;AACpE,EAAA,IAAI,SAAA,EAA+B,CAAC,CAAA;AACpC,EAAA,GAAA,CAAI,KAAA,CAAM,KAAA,IAAS,mBAAA;AACjB,IAAA,SAAA,EAAW,QAAA,CAAS,MAAA,CAAO,KAAA,CAAM,QAAQ,CAAA;AAAA,EAAA,KAAA,GAAA,CAClC,KAAA,CAAM,KAAA,IAAS,SAAA,EAAW,QAAA,CAAS,IAAA,CAAK,KAAK,CAAA;AAAA,EAAA,KAAA,GAAA,CAEpD,KAAA,CAAM,KAAA,IAAS,aAAA,GACf,KAAA,CAAM,KAAA,IAAS,UAAA,GACf,KAAA,CAAM,KAAA,IAAS,kBAAA,GACf,KAAA,CAAM,KAAA,IAAS,cAAA,EACf;AACA,IAAA,QAAA,CAAS,IAAA,CAAK,8BAAA,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AAGA,IAAO,4BAAA,EAAQ,aAAA;AD/Cf;AACE;AACA;AACF,qFAAC","file":"/home/runner/work/turf/turf/packages/turf-line-intersect/dist/cjs/index.cjs","sourcesContent":[null,"import { feature, featureCollection, point } from \"@turf/helpers\";\nimport {\n Feature,\n FeatureCollection,\n LineString,\n MultiLineString,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport type { Intersection } from \"sweepline-intersections\";\nimport { sweeplineIntersections as findIntersections } from \"./lib/sweepline-intersections-export.js\";\n\n/**\n * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).\n *\n * @function\n * @param {GeoJSON} line1 any LineString or Polygon\n * @param {GeoJSON} line2 any LineString or Polygon\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.removeDuplicates=true] remove duplicate intersections\n * @param {boolean} [options.ignoreSelfIntersections=true] ignores self-intersections on input features\n * @returns {FeatureCollection<Point>} point(s) that intersect both\n * @example\n * var line1 = turf.lineString([[126, -11], [129, -21]]);\n * var line2 = turf.lineString([[123, -18], [131, -14]]);\n * var intersects = turf.lineIntersect(line1, line2);\n *\n * //addToMap\n * var addToMap = [line1, line2, intersects]\n */\nfunction lineIntersect<\n G1 extends LineString | MultiLineString | Polygon | MultiPolygon,\n G2 extends LineString | MultiLineString | Polygon | MultiPolygon,\n>(\n line1: FeatureCollection<G1> | Feature<G1> | G1,\n line2: FeatureCollection<G2> | Feature<G2> | G2,\n options: {\n removeDuplicates?: boolean;\n ignoreSelfIntersections?: boolean;\n } = {}\n): FeatureCollection<Point> {\n const { removeDuplicates = true, ignoreSelfIntersections = true } = options;\n let features: Feature<G1 | G2>[] = [];\n if (line1.type === \"FeatureCollection\")\n features = features.concat(line1.features);\n else if (line1.type === \"Feature\") features.push(line1);\n else if (\n line1.type === \"LineString\" ||\n line1.type === \"Polygon\" ||\n line1.type === \"MultiLineString\" ||\n line1.type === \"MultiPolygon\"\n ) {\n features.push(feature(line1));\n }\n\n if (line2.type === \"FeatureCollection\")\n features = features.concat(line2.features);\n else if (line2.type === \"Feature\") features.push(line2);\n else if (\n line2.type === \"LineString\" ||\n line2.type === \"Polygon\" ||\n line2.type === \"MultiLineString\" ||\n line2.type === \"MultiPolygon\"\n ) {\n features.push(feature(line2));\n }\n\n const intersections = findIntersections(\n featureCollection(features),\n ignoreSelfIntersections\n );\n\n let results: Intersection[] = [];\n if (removeDuplicates) {\n const unique: Record<string, boolean> = {};\n intersections.forEach((intersection) => {\n const key = intersection.join(\",\");\n if (!unique[key]) {\n unique[key] = true;\n results.push(intersection);\n }\n });\n } else {\n results = intersections;\n }\n return featureCollection(results.map((r) => point(r)));\n}\n\nexport { lineIntersect };\nexport default lineIntersect;\n","// Get around problems with moduleResolution node16 and some older libraries.\n// Manifests as \"This expression is not callable ... has no call signatures\"\n// https://stackoverflow.com/a/74709714\n\nimport lib from \"sweepline-intersections\";\n\nexport const sweeplineIntersections = lib as unknown as typeof lib.default;\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -3,12 +3,12 @@ import { LineString, MultiLineString, Polygon, MultiPolygon, FeatureCollection,
|
|
|
3
3
|
/**
|
|
4
4
|
* Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
6
|
+
* @function
|
|
7
7
|
* @param {GeoJSON} line1 any LineString or Polygon
|
|
8
8
|
* @param {GeoJSON} line2 any LineString or Polygon
|
|
9
9
|
* @param {Object} [options={}] Optional parameters
|
|
10
10
|
* @param {boolean} [options.removeDuplicates=true] remove duplicate intersections
|
|
11
|
-
* @param {boolean} [options.ignoreSelfIntersections=
|
|
11
|
+
* @param {boolean} [options.ignoreSelfIntersections=true] ignores self-intersections on input features
|
|
12
12
|
* @returns {FeatureCollection<Point>} point(s) that intersect both
|
|
13
13
|
* @example
|
|
14
14
|
* var line1 = turf.lineString([[126, -11], [129, -21]]);
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ import { LineString, MultiLineString, Polygon, MultiPolygon, FeatureCollection,
|
|
|
3
3
|
/**
|
|
4
4
|
* Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
6
|
+
* @function
|
|
7
7
|
* @param {GeoJSON} line1 any LineString or Polygon
|
|
8
8
|
* @param {GeoJSON} line2 any LineString or Polygon
|
|
9
9
|
* @param {Object} [options={}] Optional parameters
|
|
10
10
|
* @param {boolean} [options.removeDuplicates=true] remove duplicate intersections
|
|
11
|
-
* @param {boolean} [options.ignoreSelfIntersections=
|
|
11
|
+
* @param {boolean} [options.ignoreSelfIntersections=true] ignores self-intersections on input features
|
|
12
12
|
* @returns {FeatureCollection<Point>} point(s) that intersect both
|
|
13
13
|
* @example
|
|
14
14
|
* var line1 = turf.lineString([[126, -11], [129, -21]]);
|
package/dist/esm/index.js
CHANGED
|
@@ -7,19 +7,17 @@ var sweeplineIntersections = lib;
|
|
|
7
7
|
|
|
8
8
|
// index.ts
|
|
9
9
|
function lineIntersect(line1, line2, options = {}) {
|
|
10
|
-
const { removeDuplicates = true, ignoreSelfIntersections =
|
|
10
|
+
const { removeDuplicates = true, ignoreSelfIntersections = true } = options;
|
|
11
11
|
let features = [];
|
|
12
12
|
if (line1.type === "FeatureCollection")
|
|
13
13
|
features = features.concat(line1.features);
|
|
14
|
-
else if (line1.type === "Feature")
|
|
15
|
-
features.push(line1);
|
|
14
|
+
else if (line1.type === "Feature") features.push(line1);
|
|
16
15
|
else if (line1.type === "LineString" || line1.type === "Polygon" || line1.type === "MultiLineString" || line1.type === "MultiPolygon") {
|
|
17
16
|
features.push(feature(line1));
|
|
18
17
|
}
|
|
19
18
|
if (line2.type === "FeatureCollection")
|
|
20
19
|
features = features.concat(line2.features);
|
|
21
|
-
else if (line2.type === "Feature")
|
|
22
|
-
features.push(line2);
|
|
20
|
+
else if (line2.type === "Feature") features.push(line2);
|
|
23
21
|
else if (line2.type === "LineString" || line2.type === "Polygon" || line2.type === "MultiLineString" || line2.type === "MultiPolygon") {
|
|
24
22
|
features.push(feature(line2));
|
|
25
23
|
}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts","../../lib/sweepline-intersections-export.ts"],"sourcesContent":["import { feature, featureCollection, point } from \"@turf/helpers\";\nimport {\n Feature,\n FeatureCollection,\n LineString,\n MultiLineString,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport type { Intersection } from \"sweepline-intersections\";\nimport { sweeplineIntersections as findIntersections } from \"./lib/sweepline-intersections-export.js\";\n\n/**\n * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).\n *\n * @
|
|
1
|
+
{"version":3,"sources":["../../index.ts","../../lib/sweepline-intersections-export.ts"],"sourcesContent":["import { feature, featureCollection, point } from \"@turf/helpers\";\nimport {\n Feature,\n FeatureCollection,\n LineString,\n MultiLineString,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport type { Intersection } from \"sweepline-intersections\";\nimport { sweeplineIntersections as findIntersections } from \"./lib/sweepline-intersections-export.js\";\n\n/**\n * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).\n *\n * @function\n * @param {GeoJSON} line1 any LineString or Polygon\n * @param {GeoJSON} line2 any LineString or Polygon\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.removeDuplicates=true] remove duplicate intersections\n * @param {boolean} [options.ignoreSelfIntersections=true] ignores self-intersections on input features\n * @returns {FeatureCollection<Point>} point(s) that intersect both\n * @example\n * var line1 = turf.lineString([[126, -11], [129, -21]]);\n * var line2 = turf.lineString([[123, -18], [131, -14]]);\n * var intersects = turf.lineIntersect(line1, line2);\n *\n * //addToMap\n * var addToMap = [line1, line2, intersects]\n */\nfunction lineIntersect<\n G1 extends LineString | MultiLineString | Polygon | MultiPolygon,\n G2 extends LineString | MultiLineString | Polygon | MultiPolygon,\n>(\n line1: FeatureCollection<G1> | Feature<G1> | G1,\n line2: FeatureCollection<G2> | Feature<G2> | G2,\n options: {\n removeDuplicates?: boolean;\n ignoreSelfIntersections?: boolean;\n } = {}\n): FeatureCollection<Point> {\n const { removeDuplicates = true, ignoreSelfIntersections = true } = options;\n let features: Feature<G1 | G2>[] = [];\n if (line1.type === \"FeatureCollection\")\n features = features.concat(line1.features);\n else if (line1.type === \"Feature\") features.push(line1);\n else if (\n line1.type === \"LineString\" ||\n line1.type === \"Polygon\" ||\n line1.type === \"MultiLineString\" ||\n line1.type === \"MultiPolygon\"\n ) {\n features.push(feature(line1));\n }\n\n if (line2.type === \"FeatureCollection\")\n features = features.concat(line2.features);\n else if (line2.type === \"Feature\") features.push(line2);\n else if (\n line2.type === \"LineString\" ||\n line2.type === \"Polygon\" ||\n line2.type === \"MultiLineString\" ||\n line2.type === \"MultiPolygon\"\n ) {\n features.push(feature(line2));\n }\n\n const intersections = findIntersections(\n featureCollection(features),\n ignoreSelfIntersections\n );\n\n let results: Intersection[] = [];\n if (removeDuplicates) {\n const unique: Record<string, boolean> = {};\n intersections.forEach((intersection) => {\n const key = intersection.join(\",\");\n if (!unique[key]) {\n unique[key] = true;\n results.push(intersection);\n }\n });\n } else {\n results = intersections;\n }\n return featureCollection(results.map((r) => point(r)));\n}\n\nexport { lineIntersect };\nexport default lineIntersect;\n","// Get around problems with moduleResolution node16 and some older libraries.\n// Manifests as \"This expression is not callable ... has no call signatures\"\n// https://stackoverflow.com/a/74709714\n\nimport lib from \"sweepline-intersections\";\n\nexport const sweeplineIntersections = lib as unknown as typeof lib.default;\n"],"mappings":";AAAA,SAAS,SAAS,mBAAmB,aAAa;;;ACIlD,OAAO,SAAS;AAET,IAAM,yBAAyB;;;ADyBtC,SAAS,cAIP,OACA,OACA,UAGI,CAAC,GACqB;AAC1B,QAAM,EAAE,mBAAmB,MAAM,0BAA0B,KAAK,IAAI;AACpE,MAAI,WAA+B,CAAC;AACpC,MAAI,MAAM,SAAS;AACjB,eAAW,SAAS,OAAO,MAAM,QAAQ;AAAA,WAClC,MAAM,SAAS,UAAW,UAAS,KAAK,KAAK;AAAA,WAEpD,MAAM,SAAS,gBACf,MAAM,SAAS,aACf,MAAM,SAAS,qBACf,MAAM,SAAS,gBACf;AACA,aAAS,KAAK,QAAQ,KAAK,CAAC;AAAA,EAC9B;AAEA,MAAI,MAAM,SAAS;AACjB,eAAW,SAAS,OAAO,MAAM,QAAQ;AAAA,WAClC,MAAM,SAAS,UAAW,UAAS,KAAK,KAAK;AAAA,WAEpD,MAAM,SAAS,gBACf,MAAM,SAAS,aACf,MAAM,SAAS,qBACf,MAAM,SAAS,gBACf;AACA,aAAS,KAAK,QAAQ,KAAK,CAAC;AAAA,EAC9B;AAEA,QAAM,gBAAgB;AAAA,IACpB,kBAAkB,QAAQ;AAAA,IAC1B;AAAA,EACF;AAEA,MAAI,UAA0B,CAAC;AAC/B,MAAI,kBAAkB;AACpB,UAAM,SAAkC,CAAC;AACzC,kBAAc,QAAQ,CAAC,iBAAiB;AACtC,YAAM,MAAM,aAAa,KAAK,GAAG;AACjC,UAAI,CAAC,OAAO,GAAG,GAAG;AAChB,eAAO,GAAG,IAAI;AACd,gBAAQ,KAAK,YAAY;AAAA,MAC3B;AAAA,IACF,CAAC;AAAA,EACH,OAAO;AACL,cAAU;AAAA,EACZ;AACA,SAAO,kBAAkB,QAAQ,IAAI,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC;AACvD;AAGA,IAAO,8BAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/line-intersect",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "turf line-intersect module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -56,23 +56,23 @@
|
|
|
56
56
|
"test:tape": "tsx test.ts"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@turf/truncate": "^7.
|
|
59
|
+
"@turf/truncate": "^7.2.0",
|
|
60
60
|
"@types/benchmark": "^2.1.5",
|
|
61
|
-
"@types/tape": "^4.
|
|
61
|
+
"@types/tape": "^4.13.4",
|
|
62
62
|
"benchmark": "^2.1.4",
|
|
63
63
|
"load-json-file": "^7.0.1",
|
|
64
64
|
"npm-run-all": "^4.1.5",
|
|
65
|
-
"tape": "^5.
|
|
66
|
-
"tsup": "^8.
|
|
67
|
-
"tsx": "^4.
|
|
68
|
-
"typescript": "^5.
|
|
65
|
+
"tape": "^5.9.0",
|
|
66
|
+
"tsup": "^8.3.5",
|
|
67
|
+
"tsx": "^4.19.2",
|
|
68
|
+
"typescript": "^5.5.4",
|
|
69
69
|
"write-json-file": "^5.0.0"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@turf/helpers": "^7.
|
|
72
|
+
"@turf/helpers": "^7.2.0",
|
|
73
73
|
"@types/geojson": "^7946.0.10",
|
|
74
74
|
"sweepline-intersections": "^1.5.0",
|
|
75
|
-
"tslib": "^2.
|
|
75
|
+
"tslib": "^2.8.1"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "7b0f0374c4668cd569f8904c71e2ae7d941be867"
|
|
78
78
|
}
|