@turf/boolean-equal 6.5.0 → 7.0.0-alpha.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
@@ -5,14 +5,17 @@
5
5
  ## booleanEqual
6
6
 
7
7
  Determine whether two geometries of the same type have identical X,Y coordinate values.
8
- See [https://desktop.arcgis.com/en/arcmap/latest/manage-data/using-sql-with-gdbs/spatial-relationships.htm][1]
8
+ See [http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm][1]
9
9
 
10
- **Parameters**
10
+ ### Parameters
11
11
 
12
- - `feature1` **([Geometry][2] \| [Feature][3])** GeoJSON input
13
- - `feature2` **([Geometry][2] \| [Feature][3])** GeoJSON input
12
+ * `feature1` **([Geometry][2] | [Feature][3])** GeoJSON input
13
+ * `feature2` **([Geometry][2] | [Feature][3])** GeoJSON input
14
+ * `options` **[Object][4]** Optional parameters (optional, default `{}`)
14
15
 
15
- **Examples**
16
+ * `options.precision` **[number][5]** decimal precision to use when comparing coordinates (optional, default `6`)
17
+
18
+ ### Examples
16
19
 
17
20
  ```javascript
18
21
  var pt1 = turf.point([0, 0]);
@@ -25,15 +28,19 @@ turf.booleanEqual(pt2, pt3);
25
28
  //= false
26
29
  ```
27
30
 
28
- Returns **[boolean][4]** true if the objects are equal, false otherwise
31
+ Returns **[boolean][6]** true if the objects are equal, false otherwise
29
32
 
30
- [1]: https://desktop.arcgis.com/en/arcmap/latest/manage-data/using-sql-with-gdbs/spatial-relationships.htm
33
+ [1]: http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm
31
34
 
32
35
  [2]: https://tools.ietf.org/html/rfc7946#section-3.1
33
36
 
34
37
  [3]: https://tools.ietf.org/html/rfc7946#section-3.2
35
38
 
36
- [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
39
+ [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
40
+
41
+ [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
42
+
43
+ [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
37
44
 
38
45
  <!-- This file is automatically generated. Please don't edit it directly:
39
46
  if you find an error, edit the source file (likely index.js), and re-run
@@ -63,4 +70,4 @@ $ npm install @turf/turf
63
70
 
64
71
  ### Diagrams
65
72
 
66
- ![esri-equals](diagrams/esri-equals.gif)
73
+ ![esri-equals](diagrams/esri-equals.gif)
package/dist/es/index.js CHANGED
@@ -8,6 +8,8 @@ import { getGeom } from "@turf/invariant";
8
8
  * @name booleanEqual
9
9
  * @param {Geometry|Feature} feature1 GeoJSON input
10
10
  * @param {Geometry|Feature} feature2 GeoJSON input
11
+ * @param {Object} [options={}] Optional parameters
12
+ * @param {number} [options.precision=6] decimal precision to use when comparing coordinates
11
13
  * @returns {boolean} true if the objects are equal, false otherwise
12
14
  * @example
13
15
  * var pt1 = turf.point([0, 0]);
@@ -19,12 +21,20 @@ import { getGeom } from "@turf/invariant";
19
21
  * turf.booleanEqual(pt2, pt3);
20
22
  * //= false
21
23
  */
22
- function booleanEqual(feature1, feature2) {
23
- var type1 = getGeom(feature1).type;
24
- var type2 = getGeom(feature2).type;
24
+ function booleanEqual(feature1, feature2, options = {}) {
25
+ let precision = options.precision;
26
+ precision =
27
+ precision === undefined || precision === null || isNaN(precision)
28
+ ? 6
29
+ : precision;
30
+ if (typeof precision !== "number" || !(precision >= 0)) {
31
+ throw new Error("precision must be a positive number");
32
+ }
33
+ const type1 = getGeom(feature1).type;
34
+ const type2 = getGeom(feature2).type;
25
35
  if (type1 !== type2)
26
36
  return false;
27
- var equality = new GeojsonEquality({ precision: 6 });
37
+ const equality = new GeojsonEquality({ precision: precision });
28
38
  return equality.compare(cleanCoords(feature1), cleanCoords(feature2));
29
39
  }
30
40
  export default booleanEqual;
@@ -1,4 +1,4 @@
1
- import { Feature, Geometry } from "@turf/helpers";
1
+ import { Feature, Geometry } from "geojson";
2
2
  /**
3
3
  * Determine whether two geometries of the same type have identical X,Y coordinate values.
4
4
  * See http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm
@@ -6,6 +6,8 @@ import { Feature, Geometry } from "@turf/helpers";
6
6
  * @name booleanEqual
7
7
  * @param {Geometry|Feature} feature1 GeoJSON input
8
8
  * @param {Geometry|Feature} feature2 GeoJSON input
9
+ * @param {Object} [options={}] Optional parameters
10
+ * @param {number} [options.precision=6] decimal precision to use when comparing coordinates
9
11
  * @returns {boolean} true if the objects are equal, false otherwise
10
12
  * @example
11
13
  * var pt1 = turf.point([0, 0]);
@@ -17,5 +19,7 @@ import { Feature, Geometry } from "@turf/helpers";
17
19
  * turf.booleanEqual(pt2, pt3);
18
20
  * //= false
19
21
  */
20
- declare function booleanEqual(feature1: Feature<any> | Geometry, feature2: Feature<any> | Geometry): boolean;
22
+ declare function booleanEqual(feature1: Feature<any> | Geometry, feature2: Feature<any> | Geometry, options?: {
23
+ precision?: number;
24
+ }): boolean;
21
25
  export default booleanEqual;
package/dist/js/index.js CHANGED
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var geojson_equality_1 = __importDefault(require("geojson-equality"));
7
- var clean_coords_1 = __importDefault(require("@turf/clean-coords"));
8
- var invariant_1 = require("@turf/invariant");
3
+ const tslib_1 = require("tslib");
4
+ const geojson_equality_1 = tslib_1.__importDefault(require("geojson-equality"));
5
+ const clean_coords_1 = tslib_1.__importDefault(require("@turf/clean-coords"));
6
+ const invariant_1 = require("@turf/invariant");
9
7
  /**
10
8
  * Determine whether two geometries of the same type have identical X,Y coordinate values.
11
9
  * See http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm
@@ -13,6 +11,8 @@ var invariant_1 = require("@turf/invariant");
13
11
  * @name booleanEqual
14
12
  * @param {Geometry|Feature} feature1 GeoJSON input
15
13
  * @param {Geometry|Feature} feature2 GeoJSON input
14
+ * @param {Object} [options={}] Optional parameters
15
+ * @param {number} [options.precision=6] decimal precision to use when comparing coordinates
16
16
  * @returns {boolean} true if the objects are equal, false otherwise
17
17
  * @example
18
18
  * var pt1 = turf.point([0, 0]);
@@ -24,12 +24,20 @@ var invariant_1 = require("@turf/invariant");
24
24
  * turf.booleanEqual(pt2, pt3);
25
25
  * //= false
26
26
  */
27
- function booleanEqual(feature1, feature2) {
28
- var type1 = invariant_1.getGeom(feature1).type;
29
- var type2 = invariant_1.getGeom(feature2).type;
27
+ function booleanEqual(feature1, feature2, options = {}) {
28
+ let precision = options.precision;
29
+ precision =
30
+ precision === undefined || precision === null || isNaN(precision)
31
+ ? 6
32
+ : precision;
33
+ if (typeof precision !== "number" || !(precision >= 0)) {
34
+ throw new Error("precision must be a positive number");
35
+ }
36
+ const type1 = invariant_1.getGeom(feature1).type;
37
+ const type2 = invariant_1.getGeom(feature2).type;
30
38
  if (type1 !== type2)
31
39
  return false;
32
- var equality = new geojson_equality_1.default({ precision: 6 });
40
+ const equality = new geojson_equality_1.default({ precision: precision });
33
41
  return equality.compare(clean_coords_1.default(feature1), clean_coords_1.default(feature2));
34
42
  }
35
43
  exports.default = booleanEqual;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/boolean-equal",
3
- "version": "6.5.0",
3
+ "version": "7.0.0-alpha.0",
4
4
  "description": "turf boolean-equal module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -66,10 +66,11 @@
66
66
  "typescript": "*"
67
67
  },
68
68
  "dependencies": {
69
- "@turf/clean-coords": "^6.5.0",
70
- "@turf/helpers": "^6.5.0",
71
- "@turf/invariant": "^6.5.0",
72
- "geojson-equality": "0.1.6"
69
+ "@turf/clean-coords": "^7.0.0-alpha.0",
70
+ "@turf/helpers": "^7.0.0-alpha.0",
71
+ "@turf/invariant": "^7.0.0-alpha.0",
72
+ "geojson-equality": "0.1.6",
73
+ "tslib": "^2.3.0"
73
74
  },
74
- "gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
75
+ "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
75
76
  }