@turf/boolean-intersects 7.1.0-alpha.7 → 7.1.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 CHANGED
@@ -4,30 +4,44 @@
4
4
 
5
5
  ## booleanIntersects
6
6
 
7
- Boolean-intersects returns (TRUE) two geometries intersect.
7
+ Boolean-intersects returns (TRUE) if the intersection of the two geometries is NOT an empty set.
8
8
 
9
9
  ### Parameters
10
10
 
11
11
  * `feature1` **([Geometry][1] | [Feature][2]\<any>)** GeoJSON Feature or Geometry
12
12
  * `feature2` **([Geometry][1] | [Feature][2]\<any>)** GeoJSON Feature or Geometry
13
+ * `options` **[Object][3]** Optional parameters (optional, default `{}`)
14
+
15
+ * `options.ignoreSelfIntersections` **[boolean][4]** ignores self-intersections on input features (optional, default `false`)
13
16
 
14
17
  ### Examples
15
18
 
16
19
  ```javascript
17
- var point = turf.point([2, 2]);
18
- var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
20
+ var point1 = turf.point([2, 2]);
21
+ var point2 = turf.point([1, 2]);
22
+ var line = turf.lineString([[1, 1], [1, 3], [1, 4]]);
23
+
24
+ turf.booleanIntersects(line, point1);
25
+ //=false
19
26
 
20
- turf.booleanIntersects(line, point);
27
+ turf.booleanIntersects(line, point2);
21
28
  //=true
29
+
30
+ //addToMap
31
+ var addToMap = [point1, point2, line];
32
+ point1.properties['marker-color'] = '#f00'
33
+ point2.properties['marker-color'] = '#0f0'
22
34
  ```
23
35
 
24
- Returns **[boolean][3]** true/false
36
+ Returns **[boolean][4]** true if geometries intersect, false otherwise
25
37
 
26
38
  [1]: https://tools.ietf.org/html/rfc7946#section-3.1
27
39
 
28
40
  [2]: https://tools.ietf.org/html/rfc7946#section-3.2
29
41
 
30
- [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
42
+ [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
43
+
44
+ [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
31
45
 
32
46
  <!-- 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. -->
33
47
 
@@ -1,14 +1,18 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
2
2
  var _booleandisjoint = require('@turf/boolean-disjoint');
3
3
  var _meta = require('@turf/meta');
4
- function booleanIntersects(feature1, feature2) {
4
+ function booleanIntersects(feature1, feature2, options = {}) {
5
+ var _a;
6
+ const ignoreSelfIntersections = (_a = options.ignoreSelfIntersections) != null ? _a : false;
5
7
  let bool = false;
6
8
  _meta.flattenEach.call(void 0, feature1, (flatten1) => {
7
9
  _meta.flattenEach.call(void 0, feature2, (flatten2) => {
8
10
  if (bool === true) {
9
11
  return true;
10
12
  }
11
- bool = !_booleandisjoint.booleanDisjoint.call(void 0, flatten1.geometry, flatten2.geometry);
13
+ bool = !_booleandisjoint.booleanDisjoint.call(void 0, flatten1.geometry, flatten2.geometry, {
14
+ ignoreSelfIntersections
15
+ });
12
16
  });
13
17
  });
14
18
  return bool;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AACA,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAgB5B,SAAS,kBACP,UACA,UACA;AACA,MAAI,OAAO;AACX,cAAY,UAAU,CAAC,aAAa;AAClC,gBAAY,UAAU,CAAC,aAAa;AAClC,UAAI,SAAS,MAAM;AACjB,eAAO;AAAA,MACT;AACA,aAAO,CAAC,gBAAgB,SAAS,UAAU,SAAS,QAAQ;AAAA,IAC9D,CAAC;AAAA,EACH,CAAC;AACD,SAAO;AACT;AAGA,IAAO,kCAAQ","sourcesContent":["import { Feature, Geometry } from \"geojson\";\nimport { booleanDisjoint } from \"@turf/boolean-disjoint\";\nimport { flattenEach } from \"@turf/meta\";\n\n/**\n * Boolean-intersects returns (TRUE) two geometries intersect.\n *\n * @name booleanIntersects\n * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry\n * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry\n * @returns {boolean} true/false\n * @example\n * var point = turf.point([2, 2]);\n * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);\n *\n * turf.booleanIntersects(line, point);\n * //=true\n */\nfunction booleanIntersects(\n feature1: Feature<any> | Geometry,\n feature2: Feature<any> | Geometry\n) {\n let bool = false;\n flattenEach(feature1, (flatten1) => {\n flattenEach(feature2, (flatten2) => {\n if (bool === true) {\n return true;\n }\n bool = !booleanDisjoint(flatten1.geometry, flatten2.geometry);\n });\n });\n return bool;\n}\n\nexport { booleanIntersects };\nexport default booleanIntersects;\n"]}
1
+ {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AACA,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AA2B5B,SAAS,kBACP,UACA,UACA,UAEI,CAAC,GACL;AAnCF;AAoCE,QAAM,2BACJ,aAAQ,4BAAR,YAAmC;AAErC,MAAI,OAAO;AACX,cAAY,UAAU,CAAC,aAAa;AAClC,gBAAY,UAAU,CAAC,aAAa;AAClC,UAAI,SAAS,MAAM;AACjB,eAAO;AAAA,MACT;AACA,aAAO,CAAC,gBAAgB,SAAS,UAAU,SAAS,UAAU;AAAA,QAC5D;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACD,SAAO;AACT;AAGA,IAAO,kCAAQ","sourcesContent":["import { Feature, Geometry } from \"geojson\";\nimport { booleanDisjoint } from \"@turf/boolean-disjoint\";\nimport { flattenEach } from \"@turf/meta\";\n\n/**\n * Boolean-intersects returns (TRUE) if the intersection of the two geometries is NOT an empty set.\n *\n * @name booleanIntersects\n * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry\n * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.ignoreSelfIntersections=false] ignores self-intersections on input features\n * @returns {boolean} true if geometries intersect, false otherwise\n * @example\n * var point1 = turf.point([2, 2]);\n * var point2 = turf.point([1, 2]);\n * var line = turf.lineString([[1, 1], [1, 3], [1, 4]]);\n *\n * turf.booleanIntersects(line, point1);\n * //=false\n *\n * turf.booleanIntersects(line, point2);\n * //=true\n *\n * //addToMap\n * var addToMap = [point1, point2, line];\n * point1.properties['marker-color'] = '#f00'\n * point2.properties['marker-color'] = '#0f0'\n */\nfunction booleanIntersects(\n feature1: Feature<any> | Geometry,\n feature2: Feature<any> | Geometry,\n options: {\n ignoreSelfIntersections?: boolean;\n } = {}\n) {\n const ignoreSelfIntersections: boolean =\n options.ignoreSelfIntersections ?? false;\n\n let bool = false;\n flattenEach(feature1, (flatten1) => {\n flattenEach(feature2, (flatten2) => {\n if (bool === true) {\n return true;\n }\n bool = !booleanDisjoint(flatten1.geometry, flatten2.geometry, {\n ignoreSelfIntersections,\n });\n });\n });\n return bool;\n}\n\nexport { booleanIntersects };\nexport default booleanIntersects;\n"]}
@@ -1,19 +1,32 @@
1
1
  import { Feature, Geometry } from 'geojson';
2
2
 
3
3
  /**
4
- * Boolean-intersects returns (TRUE) two geometries intersect.
4
+ * Boolean-intersects returns (TRUE) if the intersection of the two geometries is NOT an empty set.
5
5
  *
6
6
  * @name booleanIntersects
7
7
  * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
8
8
  * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
9
- * @returns {boolean} true/false
9
+ * @param {Object} [options={}] Optional parameters
10
+ * @param {boolean} [options.ignoreSelfIntersections=false] ignores self-intersections on input features
11
+ * @returns {boolean} true if geometries intersect, false otherwise
10
12
  * @example
11
- * var point = turf.point([2, 2]);
12
- * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
13
+ * var point1 = turf.point([2, 2]);
14
+ * var point2 = turf.point([1, 2]);
15
+ * var line = turf.lineString([[1, 1], [1, 3], [1, 4]]);
13
16
  *
14
- * turf.booleanIntersects(line, point);
17
+ * turf.booleanIntersects(line, point1);
18
+ * //=false
19
+ *
20
+ * turf.booleanIntersects(line, point2);
15
21
  * //=true
22
+ *
23
+ * //addToMap
24
+ * var addToMap = [point1, point2, line];
25
+ * point1.properties['marker-color'] = '#f00'
26
+ * point2.properties['marker-color'] = '#0f0'
16
27
  */
17
- declare function booleanIntersects(feature1: Feature<any> | Geometry, feature2: Feature<any> | Geometry): boolean;
28
+ declare function booleanIntersects(feature1: Feature<any> | Geometry, feature2: Feature<any> | Geometry, options?: {
29
+ ignoreSelfIntersections?: boolean;
30
+ }): boolean;
18
31
 
19
32
  export { booleanIntersects, booleanIntersects as default };
@@ -1,19 +1,32 @@
1
1
  import { Feature, Geometry } from 'geojson';
2
2
 
3
3
  /**
4
- * Boolean-intersects returns (TRUE) two geometries intersect.
4
+ * Boolean-intersects returns (TRUE) if the intersection of the two geometries is NOT an empty set.
5
5
  *
6
6
  * @name booleanIntersects
7
7
  * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
8
8
  * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
9
- * @returns {boolean} true/false
9
+ * @param {Object} [options={}] Optional parameters
10
+ * @param {boolean} [options.ignoreSelfIntersections=false] ignores self-intersections on input features
11
+ * @returns {boolean} true if geometries intersect, false otherwise
10
12
  * @example
11
- * var point = turf.point([2, 2]);
12
- * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
13
+ * var point1 = turf.point([2, 2]);
14
+ * var point2 = turf.point([1, 2]);
15
+ * var line = turf.lineString([[1, 1], [1, 3], [1, 4]]);
13
16
  *
14
- * turf.booleanIntersects(line, point);
17
+ * turf.booleanIntersects(line, point1);
18
+ * //=false
19
+ *
20
+ * turf.booleanIntersects(line, point2);
15
21
  * //=true
22
+ *
23
+ * //addToMap
24
+ * var addToMap = [point1, point2, line];
25
+ * point1.properties['marker-color'] = '#f00'
26
+ * point2.properties['marker-color'] = '#0f0'
16
27
  */
17
- declare function booleanIntersects(feature1: Feature<any> | Geometry, feature2: Feature<any> | Geometry): boolean;
28
+ declare function booleanIntersects(feature1: Feature<any> | Geometry, feature2: Feature<any> | Geometry, options?: {
29
+ ignoreSelfIntersections?: boolean;
30
+ }): boolean;
18
31
 
19
32
  export { booleanIntersects, booleanIntersects as default };
package/dist/esm/index.js CHANGED
@@ -1,14 +1,18 @@
1
1
  // index.ts
2
2
  import { booleanDisjoint } from "@turf/boolean-disjoint";
3
3
  import { flattenEach } from "@turf/meta";
4
- function booleanIntersects(feature1, feature2) {
4
+ function booleanIntersects(feature1, feature2, options = {}) {
5
+ var _a;
6
+ const ignoreSelfIntersections = (_a = options.ignoreSelfIntersections) != null ? _a : false;
5
7
  let bool = false;
6
8
  flattenEach(feature1, (flatten1) => {
7
9
  flattenEach(feature2, (flatten2) => {
8
10
  if (bool === true) {
9
11
  return true;
10
12
  }
11
- bool = !booleanDisjoint(flatten1.geometry, flatten2.geometry);
13
+ bool = !booleanDisjoint(flatten1.geometry, flatten2.geometry, {
14
+ ignoreSelfIntersections
15
+ });
12
16
  });
13
17
  });
14
18
  return bool;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, Geometry } from \"geojson\";\nimport { booleanDisjoint } from \"@turf/boolean-disjoint\";\nimport { flattenEach } from \"@turf/meta\";\n\n/**\n * Boolean-intersects returns (TRUE) two geometries intersect.\n *\n * @name booleanIntersects\n * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry\n * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry\n * @returns {boolean} true/false\n * @example\n * var point = turf.point([2, 2]);\n * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);\n *\n * turf.booleanIntersects(line, point);\n * //=true\n */\nfunction booleanIntersects(\n feature1: Feature<any> | Geometry,\n feature2: Feature<any> | Geometry\n) {\n let bool = false;\n flattenEach(feature1, (flatten1) => {\n flattenEach(feature2, (flatten2) => {\n if (bool === true) {\n return true;\n }\n bool = !booleanDisjoint(flatten1.geometry, flatten2.geometry);\n });\n });\n return bool;\n}\n\nexport { booleanIntersects };\nexport default booleanIntersects;\n"],"mappings":";AACA,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAgB5B,SAAS,kBACP,UACA,UACA;AACA,MAAI,OAAO;AACX,cAAY,UAAU,CAAC,aAAa;AAClC,gBAAY,UAAU,CAAC,aAAa;AAClC,UAAI,SAAS,MAAM;AACjB,eAAO;AAAA,MACT;AACA,aAAO,CAAC,gBAAgB,SAAS,UAAU,SAAS,QAAQ;AAAA,IAC9D,CAAC;AAAA,EACH,CAAC;AACD,SAAO;AACT;AAGA,IAAO,kCAAQ;","names":[]}
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, Geometry } from \"geojson\";\nimport { booleanDisjoint } from \"@turf/boolean-disjoint\";\nimport { flattenEach } from \"@turf/meta\";\n\n/**\n * Boolean-intersects returns (TRUE) if the intersection of the two geometries is NOT an empty set.\n *\n * @name booleanIntersects\n * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry\n * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.ignoreSelfIntersections=false] ignores self-intersections on input features\n * @returns {boolean} true if geometries intersect, false otherwise\n * @example\n * var point1 = turf.point([2, 2]);\n * var point2 = turf.point([1, 2]);\n * var line = turf.lineString([[1, 1], [1, 3], [1, 4]]);\n *\n * turf.booleanIntersects(line, point1);\n * //=false\n *\n * turf.booleanIntersects(line, point2);\n * //=true\n *\n * //addToMap\n * var addToMap = [point1, point2, line];\n * point1.properties['marker-color'] = '#f00'\n * point2.properties['marker-color'] = '#0f0'\n */\nfunction booleanIntersects(\n feature1: Feature<any> | Geometry,\n feature2: Feature<any> | Geometry,\n options: {\n ignoreSelfIntersections?: boolean;\n } = {}\n) {\n const ignoreSelfIntersections: boolean =\n options.ignoreSelfIntersections ?? false;\n\n let bool = false;\n flattenEach(feature1, (flatten1) => {\n flattenEach(feature2, (flatten2) => {\n if (bool === true) {\n return true;\n }\n bool = !booleanDisjoint(flatten1.geometry, flatten2.geometry, {\n ignoreSelfIntersections,\n });\n });\n });\n return bool;\n}\n\nexport { booleanIntersects };\nexport default booleanIntersects;\n"],"mappings":";AACA,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AA2B5B,SAAS,kBACP,UACA,UACA,UAEI,CAAC,GACL;AAnCF;AAoCE,QAAM,2BACJ,aAAQ,4BAAR,YAAmC;AAErC,MAAI,OAAO;AACX,cAAY,UAAU,CAAC,aAAa;AAClC,gBAAY,UAAU,CAAC,aAAa;AAClC,UAAI,SAAS,MAAM;AACjB,eAAO;AAAA,MACT;AACA,aAAO,CAAC,gBAAgB,SAAS,UAAU,SAAS,UAAU;AAAA,QAC5D;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACD,SAAO;AACT;AAGA,IAAO,kCAAQ;","names":[]}
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@turf/boolean-intersects",
3
- "version": "7.1.0-alpha.7+0ce6ecca0",
3
+ "version": "7.1.0",
4
4
  "description": "turf boolean-intersects module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
7
7
  "Rowan Winsemius <@rowanwins>",
8
- "Denis Carriere <@DenisCarriere>"
8
+ "Denis Carriere <@DenisCarriere>",
9
+ "David Whittingham <@01100100>"
9
10
  ],
10
11
  "license": "MIT",
11
12
  "bugs": {
@@ -67,10 +68,11 @@
67
68
  "typescript": "^5.2.2"
68
69
  },
69
70
  "dependencies": {
70
- "@turf/boolean-disjoint": "^7.1.0-alpha.7+0ce6ecca0",
71
- "@turf/helpers": "^7.1.0-alpha.7+0ce6ecca0",
72
- "@turf/meta": "^7.1.0-alpha.7+0ce6ecca0",
71
+ "@turf/boolean-disjoint": "^7.1.0",
72
+ "@turf/helpers": "^7.1.0",
73
+ "@turf/meta": "^7.1.0",
74
+ "@types/geojson": "^7946.0.10",
73
75
  "tslib": "^2.6.2"
74
76
  },
75
- "gitHead": "0ce6ecca05829690270fec6d6bed2003495fe0ea"
77
+ "gitHead": "68915eeebc9278bb40dec3f1034499698a0561ef"
76
78
  }