@turf/line-intersect 7.0.0-alpha.1 → 7.0.0-alpha.111

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 CHANGED
@@ -10,6 +10,10 @@ Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
10
10
 
11
11
  * `line1` **[GeoJSON][1]** any LineString or Polygon
12
12
  * `line2` **[GeoJSON][1]** any LineString or Polygon
13
+ * `options` **[Object][2]** Optional parameters (optional, default `{}`)
14
+
15
+ * `options.removeDuplicates` **[boolean][3]** remove duplicate intersections (optional, default `true`)
16
+ * `options.ignoreSelfIntersections` **[boolean][3]** ignores self-intersections on input features (optional, default `false`)
13
17
 
14
18
  ### Examples
15
19
 
@@ -22,34 +26,33 @@ var intersects = turf.lineIntersect(line1, line2);
22
26
  var addToMap = [line1, line2, intersects]
23
27
  ```
24
28
 
25
- Returns **[FeatureCollection][2]<[Point][3]>** point(s) that intersect both
29
+ Returns **[FeatureCollection][4]<[Point][5]>** point(s) that intersect both
26
30
 
27
31
  [1]: https://tools.ietf.org/html/rfc7946#section-3
28
32
 
29
- [2]: https://tools.ietf.org/html/rfc7946#section-3.3
33
+ [2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
34
+
35
+ [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
36
+
37
+ [4]: https://tools.ietf.org/html/rfc7946#section-3.3
30
38
 
31
- [3]: https://tools.ietf.org/html/rfc7946#section-3.1.2
39
+ [5]: https://tools.ietf.org/html/rfc7946#section-3.1.2
32
40
 
33
- <!-- This file is automatically generated. Please don't edit it directly:
34
- if you find an error, edit the source file (likely index.js), and re-run
35
- ./scripts/generate-readmes in the turf project. -->
41
+ <!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
36
42
 
37
43
  ---
38
44
 
39
- This module is part of the [Turfjs project](http://turfjs.org/), an open source
40
- module collection dedicated to geographic algorithms. It is maintained in the
41
- [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
42
- PRs and issues.
45
+ This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
43
46
 
44
47
  ### Installation
45
48
 
46
- Install this module individually:
49
+ Install this single module individually:
47
50
 
48
51
  ```sh
49
52
  $ npm install @turf/line-intersect
50
53
  ```
51
54
 
52
- Or install the Turf module that includes it as a function:
55
+ Or install the all-encompassing @turf/turf module that includes all modules as functions:
53
56
 
54
57
  ```sh
55
58
  $ npm install @turf/turf
@@ -0,0 +1,49 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // index.ts
5
+ var _helpers = require('@turf/helpers');
6
+ var _sweeplineintersections = require('sweepline-intersections'); var _sweeplineintersections2 = _interopRequireDefault(_sweeplineintersections);
7
+ function lineIntersect(line1, line2, options = {}) {
8
+ const { removeDuplicates = true, ignoreSelfIntersections = false } = options;
9
+ let features = [];
10
+ if (line1.type === "FeatureCollection")
11
+ features = features.concat(line1.features);
12
+ else if (line1.type === "Feature")
13
+ features.push(line1);
14
+ else if (line1.type === "LineString" || line1.type === "Polygon" || line1.type === "MultiLineString" || line1.type === "MultiPolygon") {
15
+ features.push(_helpers.feature.call(void 0, line1));
16
+ }
17
+ if (line2.type === "FeatureCollection")
18
+ features = features.concat(line2.features);
19
+ else if (line2.type === "Feature")
20
+ features.push(line2);
21
+ else if (line2.type === "LineString" || line2.type === "Polygon" || line2.type === "MultiLineString" || line2.type === "MultiPolygon") {
22
+ features.push(_helpers.feature.call(void 0, line2));
23
+ }
24
+ const intersections = _sweeplineintersections2.default.call(void 0,
25
+ _helpers.featureCollection.call(void 0, features),
26
+ ignoreSelfIntersections
27
+ );
28
+ let results = [];
29
+ if (removeDuplicates) {
30
+ const unique = {};
31
+ intersections.forEach((intersection) => {
32
+ const key = intersection.join(",");
33
+ if (!unique[key]) {
34
+ unique[key] = true;
35
+ results.push(intersection);
36
+ }
37
+ });
38
+ } else {
39
+ results = intersections;
40
+ }
41
+ return _helpers.featureCollection.call(void 0, results.map((r) => _helpers.point.call(void 0, r)));
42
+ }
43
+ __name(lineIntersect, "lineIntersect");
44
+ var turf_line_intersect_default = lineIntersect;
45
+
46
+
47
+
48
+ exports.default = turf_line_intersect_default; exports.lineIntersect = lineIntersect;
49
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";;;;AAAA,SAAS,SAAS,mBAAmB,aAAa;AAUlD,OAAO,uBAAyC;AAoBhD,SAAS,cAIP,OACA,OACA,UAGI,CAAC,GACqB;AAC1B,QAAM,EAAE,mBAAmB,MAAM,0BAA0B,MAAM,IAAI;AACrE,MAAI,WAA+B,CAAC;AACpC,MAAI,MAAM,SAAS;AACjB,eAAW,SAAS,OAAO,MAAM,QAAQ;AAAA,WAClC,MAAM,SAAS;AAAW,aAAS,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;AAAW,aAAS,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;AAxDS;AA2DT,IAAO,8BAAQ","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 findIntersections, { Intersection } from \"sweepline-intersections\";\n\n/**\n * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).\n *\n * @name lineIntersect\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=false] 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 = false } = 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"]}
@@ -1,4 +1,5 @@
1
- import { Feature, FeatureCollection, LineString, MultiLineString, MultiPolygon, Point, Polygon } from "geojson";
1
+ import { LineString, MultiLineString, Polygon, MultiPolygon, FeatureCollection, Feature, Point } from 'geojson';
2
+
2
3
  /**
3
4
  * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
4
5
  *
@@ -21,4 +22,5 @@ declare function lineIntersect<G1 extends LineString | MultiLineString | Polygon
21
22
  removeDuplicates?: boolean;
22
23
  ignoreSelfIntersections?: boolean;
23
24
  }): FeatureCollection<Point>;
24
- export default lineIntersect;
25
+
26
+ export { lineIntersect as default, lineIntersect };
@@ -0,0 +1,26 @@
1
+ import { LineString, MultiLineString, Polygon, MultiPolygon, FeatureCollection, Feature, Point } from 'geojson';
2
+
3
+ /**
4
+ * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
5
+ *
6
+ * @name lineIntersect
7
+ * @param {GeoJSON} line1 any LineString or Polygon
8
+ * @param {GeoJSON} line2 any LineString or Polygon
9
+ * @param {Object} [options={}] Optional parameters
10
+ * @param {boolean} [options.removeDuplicates=true] remove duplicate intersections
11
+ * @param {boolean} [options.ignoreSelfIntersections=false] ignores self-intersections on input features
12
+ * @returns {FeatureCollection<Point>} point(s) that intersect both
13
+ * @example
14
+ * var line1 = turf.lineString([[126, -11], [129, -21]]);
15
+ * var line2 = turf.lineString([[123, -18], [131, -14]]);
16
+ * var intersects = turf.lineIntersect(line1, line2);
17
+ *
18
+ * //addToMap
19
+ * var addToMap = [line1, line2, intersects]
20
+ */
21
+ declare function lineIntersect<G1 extends LineString | MultiLineString | Polygon | MultiPolygon, G2 extends LineString | MultiLineString | Polygon | MultiPolygon>(line1: FeatureCollection<G1> | Feature<G1> | G1, line2: FeatureCollection<G2> | Feature<G2> | G2, options?: {
22
+ removeDuplicates?: boolean;
23
+ ignoreSelfIntersections?: boolean;
24
+ }): FeatureCollection<Point>;
25
+
26
+ export { lineIntersect as default, lineIntersect };
@@ -0,0 +1,49 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // index.ts
5
+ import { feature, featureCollection, point } from "@turf/helpers";
6
+ import findIntersections from "sweepline-intersections";
7
+ function lineIntersect(line1, line2, options = {}) {
8
+ const { removeDuplicates = true, ignoreSelfIntersections = false } = options;
9
+ let features = [];
10
+ if (line1.type === "FeatureCollection")
11
+ features = features.concat(line1.features);
12
+ else if (line1.type === "Feature")
13
+ features.push(line1);
14
+ else if (line1.type === "LineString" || line1.type === "Polygon" || line1.type === "MultiLineString" || line1.type === "MultiPolygon") {
15
+ features.push(feature(line1));
16
+ }
17
+ if (line2.type === "FeatureCollection")
18
+ features = features.concat(line2.features);
19
+ else if (line2.type === "Feature")
20
+ features.push(line2);
21
+ else if (line2.type === "LineString" || line2.type === "Polygon" || line2.type === "MultiLineString" || line2.type === "MultiPolygon") {
22
+ features.push(feature(line2));
23
+ }
24
+ const intersections = findIntersections(
25
+ featureCollection(features),
26
+ ignoreSelfIntersections
27
+ );
28
+ let results = [];
29
+ if (removeDuplicates) {
30
+ const unique = {};
31
+ intersections.forEach((intersection) => {
32
+ const key = intersection.join(",");
33
+ if (!unique[key]) {
34
+ unique[key] = true;
35
+ results.push(intersection);
36
+ }
37
+ });
38
+ } else {
39
+ results = intersections;
40
+ }
41
+ return featureCollection(results.map((r) => point(r)));
42
+ }
43
+ __name(lineIntersect, "lineIntersect");
44
+ var turf_line_intersect_default = lineIntersect;
45
+ export {
46
+ turf_line_intersect_default as default,
47
+ lineIntersect
48
+ };
49
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.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 findIntersections, { Intersection } from \"sweepline-intersections\";\n\n/**\n * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).\n *\n * @name lineIntersect\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=false] 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 = false } = 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"],"mappings":";;;;AAAA,SAAS,SAAS,mBAAmB,aAAa;AAUlD,OAAO,uBAAyC;AAoBhD,SAAS,cAIP,OACA,OACA,UAGI,CAAC,GACqB;AAC1B,QAAM,EAAE,mBAAmB,MAAM,0BAA0B,MAAM,IAAI;AACrE,MAAI,WAA+B,CAAC;AACpC,MAAI,MAAM,SAAS;AACjB,eAAW,SAAS,OAAO,MAAM,QAAQ;AAAA,WAClC,MAAM,SAAS;AAAW,aAAS,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;AAAW,aAAS,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;AAxDS;AA2DT,IAAO,8BAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/line-intersect",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.0-alpha.111+08576cb50",
4
4
  "description": "turf line-intersect module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -27,46 +27,51 @@
27
27
  "line",
28
28
  "intersect"
29
29
  ],
30
- "main": "dist/js/index.js",
31
- "module": "dist/es/index.js",
30
+ "type": "commonjs",
31
+ "main": "dist/cjs/index.cjs",
32
+ "module": "dist/esm/index.mjs",
33
+ "types": "dist/cjs/index.d.ts",
32
34
  "exports": {
33
35
  "./package.json": "./package.json",
34
36
  ".": {
35
- "types": "./dist/js/index.d.ts",
36
- "import": "./dist/es/index.js",
37
- "require": "./dist/js/index.js"
37
+ "import": {
38
+ "types": "./dist/esm/index.d.mts",
39
+ "default": "./dist/esm/index.mjs"
40
+ },
41
+ "require": {
42
+ "types": "./dist/cjs/index.d.ts",
43
+ "default": "./dist/cjs/index.cjs"
44
+ }
38
45
  }
39
46
  },
40
- "types": "dist/js/index.d.ts",
41
47
  "sideEffects": false,
42
48
  "files": [
43
49
  "dist"
44
50
  ],
45
51
  "scripts": {
46
- "bench": "tsx bench.js",
47
- "build": "npm-run-all build:*",
48
- "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
49
- "build:js": "tsc",
50
- "docs": "tsx ../../scripts/generate-readmes",
51
- "test": "npm-run-all test:*",
52
- "test:tape": "tsx test.js"
52
+ "bench": "tsx bench.ts",
53
+ "build": "tsup --config ../../tsup.config.ts",
54
+ "docs": "tsx ../../scripts/generate-readmes.ts",
55
+ "test": "npm-run-all --npm-path npm test:*",
56
+ "test:tape": "tsx test.ts"
53
57
  },
54
58
  "devDependencies": {
55
- "@turf/truncate": "^7.0.0-alpha.1",
56
- "@types/tape": "*",
57
- "benchmark": "*",
58
- "load-json-file": "*",
59
- "npm-run-all": "*",
60
- "tape": "*",
61
- "tslint": "*",
62
- "tsx": "*",
63
- "typescript": "*",
64
- "write-json-file": "*"
59
+ "@turf/truncate": "^7.0.0-alpha.111+08576cb50",
60
+ "@types/benchmark": "^2.1.5",
61
+ "@types/tape": "^4.2.32",
62
+ "benchmark": "^2.1.4",
63
+ "load-json-file": "^7.0.1",
64
+ "npm-run-all": "^4.1.5",
65
+ "tape": "^5.7.2",
66
+ "tsup": "^8.0.1",
67
+ "tsx": "^4.6.2",
68
+ "typescript": "^5.2.2",
69
+ "write-json-file": "^5.0.0"
65
70
  },
66
71
  "dependencies": {
67
- "@turf/helpers": "^7.0.0-alpha.1",
68
- "sweepline-intersections": "^1.4.0",
69
- "tslib": "^2.3.0"
72
+ "@turf/helpers": "^7.0.0-alpha.111+08576cb50",
73
+ "sweepline-intersections": "^1.5.0",
74
+ "tslib": "^2.6.2"
70
75
  },
71
- "gitHead": "cf7a0c507b017ca066acffd0ce23bda5b393fb5a"
76
+ "gitHead": "08576cb50376e0199aea02dbd887e3af83672246"
72
77
  }
package/dist/es/index.js DELETED
@@ -1,61 +0,0 @@
1
- import { feature, featureCollection, point } from "@turf/helpers";
2
- import findIntersections from "sweepline-intersections";
3
- /**
4
- * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
5
- *
6
- * @name lineIntersect
7
- * @param {GeoJSON} line1 any LineString or Polygon
8
- * @param {GeoJSON} line2 any LineString or Polygon
9
- * @param {Object} [options={}] Optional parameters
10
- * @param {boolean} [options.removeDuplicates=true] remove duplicate intersections
11
- * @param {boolean} [options.ignoreSelfIntersections=false] ignores self-intersections on input features
12
- * @returns {FeatureCollection<Point>} point(s) that intersect both
13
- * @example
14
- * var line1 = turf.lineString([[126, -11], [129, -21]]);
15
- * var line2 = turf.lineString([[123, -18], [131, -14]]);
16
- * var intersects = turf.lineIntersect(line1, line2);
17
- *
18
- * //addToMap
19
- * var addToMap = [line1, line2, intersects]
20
- */
21
- function lineIntersect(line1, line2, options = {}) {
22
- const { removeDuplicates = true, ignoreSelfIntersections = false } = options;
23
- let features = [];
24
- if (line1.type === "FeatureCollection")
25
- features = features.concat(line1.features);
26
- else if (line1.type === "Feature")
27
- features.push(line1);
28
- else if (line1.type === "LineString" ||
29
- line1.type === "Polygon" ||
30
- line1.type === "MultiLineString" ||
31
- line1.type === "MultiPolygon") {
32
- features.push(feature(line1));
33
- }
34
- if (line2.type === "FeatureCollection")
35
- features = features.concat(line2.features);
36
- else if (line2.type === "Feature")
37
- features.push(line2);
38
- else if (line2.type === "LineString" ||
39
- line2.type === "Polygon" ||
40
- line2.type === "MultiLineString" ||
41
- line2.type === "MultiPolygon") {
42
- features.push(feature(line2));
43
- }
44
- const intersections = findIntersections(featureCollection(features), ignoreSelfIntersections);
45
- let results = [];
46
- if (removeDuplicates) {
47
- const unique = {};
48
- intersections.forEach((intersection) => {
49
- const key = intersection.join(",");
50
- if (!unique[key]) {
51
- unique[key] = true;
52
- results.push(intersection);
53
- }
54
- });
55
- }
56
- else {
57
- results = intersections;
58
- }
59
- return featureCollection(results.map((r) => point(r)));
60
- }
61
- export default lineIntersect;
@@ -1 +0,0 @@
1
- {"type":"module"}
package/dist/js/index.js DELETED
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const helpers_1 = require("@turf/helpers");
5
- const sweepline_intersections_1 = tslib_1.__importDefault(require("sweepline-intersections"));
6
- /**
7
- * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
8
- *
9
- * @name lineIntersect
10
- * @param {GeoJSON} line1 any LineString or Polygon
11
- * @param {GeoJSON} line2 any LineString or Polygon
12
- * @param {Object} [options={}] Optional parameters
13
- * @param {boolean} [options.removeDuplicates=true] remove duplicate intersections
14
- * @param {boolean} [options.ignoreSelfIntersections=false] ignores self-intersections on input features
15
- * @returns {FeatureCollection<Point>} point(s) that intersect both
16
- * @example
17
- * var line1 = turf.lineString([[126, -11], [129, -21]]);
18
- * var line2 = turf.lineString([[123, -18], [131, -14]]);
19
- * var intersects = turf.lineIntersect(line1, line2);
20
- *
21
- * //addToMap
22
- * var addToMap = [line1, line2, intersects]
23
- */
24
- function lineIntersect(line1, line2, options = {}) {
25
- const { removeDuplicates = true, ignoreSelfIntersections = false } = options;
26
- let features = [];
27
- if (line1.type === "FeatureCollection")
28
- features = features.concat(line1.features);
29
- else if (line1.type === "Feature")
30
- features.push(line1);
31
- else if (line1.type === "LineString" ||
32
- line1.type === "Polygon" ||
33
- line1.type === "MultiLineString" ||
34
- line1.type === "MultiPolygon") {
35
- features.push(helpers_1.feature(line1));
36
- }
37
- if (line2.type === "FeatureCollection")
38
- features = features.concat(line2.features);
39
- else if (line2.type === "Feature")
40
- features.push(line2);
41
- else if (line2.type === "LineString" ||
42
- line2.type === "Polygon" ||
43
- line2.type === "MultiLineString" ||
44
- line2.type === "MultiPolygon") {
45
- features.push(helpers_1.feature(line2));
46
- }
47
- const intersections = sweepline_intersections_1.default(helpers_1.featureCollection(features), ignoreSelfIntersections);
48
- let results = [];
49
- if (removeDuplicates) {
50
- const unique = {};
51
- intersections.forEach((intersection) => {
52
- const key = intersection.join(",");
53
- if (!unique[key]) {
54
- unique[key] = true;
55
- results.push(intersection);
56
- }
57
- });
58
- }
59
- else {
60
- results = intersections;
61
- }
62
- return helpers_1.featureCollection(results.map((r) => helpers_1.point(r)));
63
- }
64
- exports.default = lineIntersect;