@turf/boolean-equal 7.0.0-alpha.1 → 7.0.0-alpha.110
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 +6 -17
- package/dist/cjs/index.cjs +27 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/{js → cjs}/index.d.ts +4 -2
- package/dist/esm/index.d.mts +27 -0
- package/dist/esm/index.mjs +27 -0
- package/dist/esm/index.mjs.map +1 -0
- package/package.json +33 -30
- package/dist/es/index.js +0 -40
- package/dist/es/package.json +0 -1
- package/dist/js/index.js +0 -43
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## booleanEqual
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Determine whether two geometries of the same type have identical X,Y coordinate values.
|
|
8
8
|
See [http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm][1]
|
|
9
9
|
|
|
10
10
|
### Parameters
|
|
@@ -21,17 +21,11 @@ See [http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relatio
|
|
|
21
21
|
var pt1 = turf.point([0, 0]);
|
|
22
22
|
var pt2 = turf.point([0, 0]);
|
|
23
23
|
var pt3 = turf.point([1, 1]);
|
|
24
|
-
var pt4 = turf.point([0, 0], {prop: 'A'});
|
|
25
|
-
var pt5 = turf.point([0, 0], {prop: 'B'});
|
|
26
24
|
|
|
27
25
|
turf.booleanEqual(pt1, pt2);
|
|
28
26
|
//= true
|
|
29
27
|
turf.booleanEqual(pt2, pt3);
|
|
30
28
|
//= false
|
|
31
|
-
turf.booleanEqual(pt4, pt5);
|
|
32
|
-
//= false
|
|
33
|
-
turf.booleanEqual(pt4.geometry, pt5.geometry);
|
|
34
|
-
//= true
|
|
35
29
|
```
|
|
36
30
|
|
|
37
31
|
Returns **[boolean][6]** true if the objects are equal, false otherwise
|
|
@@ -48,26 +42,21 @@ Returns **[boolean][6]** true if the objects are equal, false otherwise
|
|
|
48
42
|
|
|
49
43
|
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
50
44
|
|
|
51
|
-
<!-- This file is automatically generated. Please don't edit it directly
|
|
52
|
-
if you find an error, edit the source file (likely index.js), and re-run
|
|
53
|
-
./scripts/generate-readmes in the turf project. -->
|
|
45
|
+
<!-- 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. -->
|
|
54
46
|
|
|
55
47
|
---
|
|
56
48
|
|
|
57
|
-
This module is part of the [Turfjs project](
|
|
58
|
-
module collection dedicated to geographic algorithms. It is maintained in the
|
|
59
|
-
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
|
60
|
-
PRs and issues.
|
|
49
|
+
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.
|
|
61
50
|
|
|
62
51
|
### Installation
|
|
63
52
|
|
|
64
|
-
Install this module individually:
|
|
53
|
+
Install this single module individually:
|
|
65
54
|
|
|
66
55
|
```sh
|
|
67
56
|
$ npm install @turf/boolean-equal
|
|
68
57
|
```
|
|
69
58
|
|
|
70
|
-
Or install the
|
|
59
|
+
Or install the all-encompassing @turf/turf module that includes all modules as functions:
|
|
71
60
|
|
|
72
61
|
```sh
|
|
73
62
|
$ npm install @turf/turf
|
|
@@ -76,4 +65,4 @@ $ npm install @turf/turf
|
|
|
76
65
|
|
|
77
66
|
### Diagrams
|
|
78
67
|
|
|
79
|
-

|
|
68
|
+

|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});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 _cleancoords = require('@turf/clean-coords');
|
|
7
|
+
var _invariant = require('@turf/invariant');
|
|
8
|
+
function booleanEqual(feature1, feature2, options = {}) {
|
|
9
|
+
let precision = options.precision;
|
|
10
|
+
precision = precision === void 0 || precision === null || isNaN(precision) ? 6 : precision;
|
|
11
|
+
if (typeof precision !== "number" || !(precision >= 0)) {
|
|
12
|
+
throw new Error("precision must be a positive number");
|
|
13
|
+
}
|
|
14
|
+
const type1 = _invariant.getGeom.call(void 0, feature1).type;
|
|
15
|
+
const type2 = _invariant.getGeom.call(void 0, feature2).type;
|
|
16
|
+
if (type1 !== type2)
|
|
17
|
+
return false;
|
|
18
|
+
const equality = new (0, _helpers.GeojsonEquality)({ precision });
|
|
19
|
+
return equality.compare(_cleancoords.cleanCoords.call(void 0, feature1), _cleancoords.cleanCoords.call(void 0, feature2));
|
|
20
|
+
}
|
|
21
|
+
__name(booleanEqual, "booleanEqual");
|
|
22
|
+
var turf_boolean_equal_default = booleanEqual;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
exports.booleanEqual = booleanEqual; exports.default = turf_boolean_equal_default;
|
|
27
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";;;;AACA,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AAsBxB,SAAS,aACP,UACA,UACA,UAEI,CAAC,GACI;AACT,MAAI,YAAY,QAAQ;AAExB,cACE,cAAc,UAAa,cAAc,QAAQ,MAAM,SAAS,IAC5D,IACA;AAEN,MAAI,OAAO,cAAc,YAAY,EAAE,aAAa,IAAI;AACtD,UAAM,IAAI,MAAM,qCAAqC;AAAA,EACvD;AAEA,QAAM,QAAQ,QAAQ,QAAQ,EAAE;AAChC,QAAM,QAAQ,QAAQ,QAAQ,EAAE;AAChC,MAAI,UAAU;AAAO,WAAO;AAE5B,QAAM,WAAW,IAAI,gBAAgB,EAAE,UAAqB,CAAC;AAC7D,SAAO,SAAS,QAAQ,YAAY,QAAQ,GAAG,YAAY,QAAQ,CAAC;AACtE;AAxBS;AA2BT,IAAO,6BAAQ","sourcesContent":["import { Feature, Geometry } from \"geojson\";\nimport { GeojsonEquality } from \"@turf/helpers\";\nimport { cleanCoords } from \"@turf/clean-coords\";\nimport { getGeom } from \"@turf/invariant\";\n\n/**\n * Determine whether two geometries of the same type have identical X,Y coordinate values.\n * See http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm\n *\n * @name booleanEqual\n * @param {Geometry|Feature} feature1 GeoJSON input\n * @param {Geometry|Feature} feature2 GeoJSON input\n * @param {Object} [options={}] Optional parameters\n * @param {number} [options.precision=6] decimal precision to use when comparing coordinates\n * @returns {boolean} true if the objects are equal, false otherwise\n * @example\n * var pt1 = turf.point([0, 0]);\n * var pt2 = turf.point([0, 0]);\n * var pt3 = turf.point([1, 1]);\n *\n * turf.booleanEqual(pt1, pt2);\n * //= true\n * turf.booleanEqual(pt2, pt3);\n * //= false\n */\nfunction booleanEqual(\n feature1: Feature<any> | Geometry,\n feature2: Feature<any> | Geometry,\n options: {\n precision?: number;\n } = {}\n): boolean {\n let precision = options.precision;\n\n precision =\n precision === undefined || precision === null || isNaN(precision)\n ? 6\n : precision;\n\n if (typeof precision !== \"number\" || !(precision >= 0)) {\n throw new Error(\"precision must be a positive number\");\n }\n\n const type1 = getGeom(feature1).type;\n const type2 = getGeom(feature2).type;\n if (type1 !== type2) return false;\n\n const equality = new GeojsonEquality({ precision: precision });\n return equality.compare(cleanCoords(feature1), cleanCoords(feature2));\n}\n\nexport { booleanEqual };\nexport default booleanEqual;\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Feature, Geometry } from
|
|
1
|
+
import { Feature, Geometry } from 'geojson';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Determine whether two geometries of the same type have identical X,Y coordinate values.
|
|
4
5
|
* See http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm
|
|
@@ -22,4 +23,5 @@ import { Feature, Geometry } from "geojson";
|
|
|
22
23
|
declare function booleanEqual(feature1: Feature<any> | Geometry, feature2: Feature<any> | Geometry, options?: {
|
|
23
24
|
precision?: number;
|
|
24
25
|
}): boolean;
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
export { booleanEqual, booleanEqual as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Feature, Geometry } from 'geojson';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Determine whether two geometries of the same type have identical X,Y coordinate values.
|
|
5
|
+
* See http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm
|
|
6
|
+
*
|
|
7
|
+
* @name booleanEqual
|
|
8
|
+
* @param {Geometry|Feature} feature1 GeoJSON input
|
|
9
|
+
* @param {Geometry|Feature} feature2 GeoJSON input
|
|
10
|
+
* @param {Object} [options={}] Optional parameters
|
|
11
|
+
* @param {number} [options.precision=6] decimal precision to use when comparing coordinates
|
|
12
|
+
* @returns {boolean} true if the objects are equal, false otherwise
|
|
13
|
+
* @example
|
|
14
|
+
* var pt1 = turf.point([0, 0]);
|
|
15
|
+
* var pt2 = turf.point([0, 0]);
|
|
16
|
+
* var pt3 = turf.point([1, 1]);
|
|
17
|
+
*
|
|
18
|
+
* turf.booleanEqual(pt1, pt2);
|
|
19
|
+
* //= true
|
|
20
|
+
* turf.booleanEqual(pt2, pt3);
|
|
21
|
+
* //= false
|
|
22
|
+
*/
|
|
23
|
+
declare function booleanEqual(feature1: Feature<any> | Geometry, feature2: Feature<any> | Geometry, options?: {
|
|
24
|
+
precision?: number;
|
|
25
|
+
}): boolean;
|
|
26
|
+
|
|
27
|
+
export { booleanEqual, booleanEqual as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.ts
|
|
5
|
+
import { GeojsonEquality } from "@turf/helpers";
|
|
6
|
+
import { cleanCoords } from "@turf/clean-coords";
|
|
7
|
+
import { getGeom } from "@turf/invariant";
|
|
8
|
+
function booleanEqual(feature1, feature2, options = {}) {
|
|
9
|
+
let precision = options.precision;
|
|
10
|
+
precision = precision === void 0 || precision === null || isNaN(precision) ? 6 : precision;
|
|
11
|
+
if (typeof precision !== "number" || !(precision >= 0)) {
|
|
12
|
+
throw new Error("precision must be a positive number");
|
|
13
|
+
}
|
|
14
|
+
const type1 = getGeom(feature1).type;
|
|
15
|
+
const type2 = getGeom(feature2).type;
|
|
16
|
+
if (type1 !== type2)
|
|
17
|
+
return false;
|
|
18
|
+
const equality = new GeojsonEquality({ precision });
|
|
19
|
+
return equality.compare(cleanCoords(feature1), cleanCoords(feature2));
|
|
20
|
+
}
|
|
21
|
+
__name(booleanEqual, "booleanEqual");
|
|
22
|
+
var turf_boolean_equal_default = booleanEqual;
|
|
23
|
+
export {
|
|
24
|
+
booleanEqual,
|
|
25
|
+
turf_boolean_equal_default as default
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, Geometry } from \"geojson\";\nimport { GeojsonEquality } from \"@turf/helpers\";\nimport { cleanCoords } from \"@turf/clean-coords\";\nimport { getGeom } from \"@turf/invariant\";\n\n/**\n * Determine whether two geometries of the same type have identical X,Y coordinate values.\n * See http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm\n *\n * @name booleanEqual\n * @param {Geometry|Feature} feature1 GeoJSON input\n * @param {Geometry|Feature} feature2 GeoJSON input\n * @param {Object} [options={}] Optional parameters\n * @param {number} [options.precision=6] decimal precision to use when comparing coordinates\n * @returns {boolean} true if the objects are equal, false otherwise\n * @example\n * var pt1 = turf.point([0, 0]);\n * var pt2 = turf.point([0, 0]);\n * var pt3 = turf.point([1, 1]);\n *\n * turf.booleanEqual(pt1, pt2);\n * //= true\n * turf.booleanEqual(pt2, pt3);\n * //= false\n */\nfunction booleanEqual(\n feature1: Feature<any> | Geometry,\n feature2: Feature<any> | Geometry,\n options: {\n precision?: number;\n } = {}\n): boolean {\n let precision = options.precision;\n\n precision =\n precision === undefined || precision === null || isNaN(precision)\n ? 6\n : precision;\n\n if (typeof precision !== \"number\" || !(precision >= 0)) {\n throw new Error(\"precision must be a positive number\");\n }\n\n const type1 = getGeom(feature1).type;\n const type2 = getGeom(feature2).type;\n if (type1 !== type2) return false;\n\n const equality = new GeojsonEquality({ precision: precision });\n return equality.compare(cleanCoords(feature1), cleanCoords(feature2));\n}\n\nexport { booleanEqual };\nexport default booleanEqual;\n"],"mappings":";;;;AACA,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AAsBxB,SAAS,aACP,UACA,UACA,UAEI,CAAC,GACI;AACT,MAAI,YAAY,QAAQ;AAExB,cACE,cAAc,UAAa,cAAc,QAAQ,MAAM,SAAS,IAC5D,IACA;AAEN,MAAI,OAAO,cAAc,YAAY,EAAE,aAAa,IAAI;AACtD,UAAM,IAAI,MAAM,qCAAqC;AAAA,EACvD;AAEA,QAAM,QAAQ,QAAQ,QAAQ,EAAE;AAChC,QAAM,QAAQ,QAAQ,QAAQ,EAAE;AAChC,MAAI,UAAU;AAAO,WAAO;AAE5B,QAAM,WAAW,IAAI,gBAAgB,EAAE,UAAqB,CAAC;AAC7D,SAAO,SAAS,QAAQ,YAAY,QAAQ,GAAG,YAAY,QAAQ,CAAC;AACtE;AAxBS;AA2BT,IAAO,6BAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/boolean-equal",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.110+1411d63a7",
|
|
4
4
|
"description": "turf boolean-equal module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -29,49 +29,52 @@
|
|
|
29
29
|
"equal",
|
|
30
30
|
"boolean-equal"
|
|
31
31
|
],
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"type": "commonjs",
|
|
33
|
+
"main": "dist/cjs/index.cjs",
|
|
34
|
+
"module": "dist/esm/index.mjs",
|
|
35
|
+
"types": "dist/cjs/index.d.ts",
|
|
34
36
|
"exports": {
|
|
35
37
|
"./package.json": "./package.json",
|
|
36
38
|
".": {
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
"import": {
|
|
40
|
+
"types": "./dist/esm/index.d.mts",
|
|
41
|
+
"default": "./dist/esm/index.mjs"
|
|
42
|
+
},
|
|
43
|
+
"require": {
|
|
44
|
+
"types": "./dist/cjs/index.d.ts",
|
|
45
|
+
"default": "./dist/cjs/index.cjs"
|
|
46
|
+
}
|
|
40
47
|
}
|
|
41
48
|
},
|
|
42
|
-
"types": "dist/js/index.d.ts",
|
|
43
49
|
"sideEffects": false,
|
|
44
50
|
"files": [
|
|
45
51
|
"dist"
|
|
46
52
|
],
|
|
47
53
|
"scripts": {
|
|
48
|
-
"bench": "tsx bench.
|
|
49
|
-
"build": "
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"test": "npm-run-all test:*",
|
|
54
|
-
"test:tape": "tsx test.js"
|
|
54
|
+
"bench": "tsx bench.ts",
|
|
55
|
+
"build": "tsup --config ../../tsup.config.ts",
|
|
56
|
+
"docs": "tsx ../../scripts/generate-readmes.ts",
|
|
57
|
+
"test": "npm-run-all --npm-path npm test:*",
|
|
58
|
+
"test:tape": "tsx test.ts"
|
|
55
59
|
},
|
|
56
60
|
"devDependencies": {
|
|
57
|
-
"@types/
|
|
58
|
-
"@types/tape": "
|
|
59
|
-
"benchmark": "
|
|
61
|
+
"@types/benchmark": "^2.1.5",
|
|
62
|
+
"@types/tape": "^4.2.32",
|
|
63
|
+
"benchmark": "^2.1.4",
|
|
60
64
|
"boolean-shapely": "*",
|
|
61
|
-
"glob": "
|
|
62
|
-
"load-json-file": "
|
|
63
|
-
"npm-run-all": "
|
|
64
|
-
"tape": "
|
|
65
|
-
"
|
|
66
|
-
"tsx": "
|
|
67
|
-
"typescript": "
|
|
65
|
+
"glob": "^10.3.10",
|
|
66
|
+
"load-json-file": "^7.0.1",
|
|
67
|
+
"npm-run-all": "^4.1.5",
|
|
68
|
+
"tape": "^5.7.2",
|
|
69
|
+
"tsup": "^8.0.1",
|
|
70
|
+
"tsx": "^4.6.2",
|
|
71
|
+
"typescript": "^5.2.2"
|
|
68
72
|
},
|
|
69
73
|
"dependencies": {
|
|
70
|
-
"@turf/clean-coords": "^7.0.0-alpha.
|
|
71
|
-
"@turf/helpers": "^7.0.0-alpha.
|
|
72
|
-
"@turf/invariant": "^7.0.0-alpha.
|
|
73
|
-
"
|
|
74
|
-
"tslib": "^2.3.0"
|
|
74
|
+
"@turf/clean-coords": "^7.0.0-alpha.110+1411d63a7",
|
|
75
|
+
"@turf/helpers": "^7.0.0-alpha.110+1411d63a7",
|
|
76
|
+
"@turf/invariant": "^7.0.0-alpha.110+1411d63a7",
|
|
77
|
+
"tslib": "^2.6.2"
|
|
75
78
|
},
|
|
76
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "1411d63a74c275c9216fe48e9d3cb2d48a359068"
|
|
77
80
|
}
|
package/dist/es/index.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import GeojsonEquality from "geojson-equality";
|
|
2
|
-
import cleanCoords from "@turf/clean-coords";
|
|
3
|
-
import { getGeom } from "@turf/invariant";
|
|
4
|
-
/**
|
|
5
|
-
* Determine whether two geometries of the same type have identical X,Y coordinate values.
|
|
6
|
-
* See http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm
|
|
7
|
-
*
|
|
8
|
-
* @name booleanEqual
|
|
9
|
-
* @param {Geometry|Feature} feature1 GeoJSON input
|
|
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
|
|
13
|
-
* @returns {boolean} true if the objects are equal, false otherwise
|
|
14
|
-
* @example
|
|
15
|
-
* var pt1 = turf.point([0, 0]);
|
|
16
|
-
* var pt2 = turf.point([0, 0]);
|
|
17
|
-
* var pt3 = turf.point([1, 1]);
|
|
18
|
-
*
|
|
19
|
-
* turf.booleanEqual(pt1, pt2);
|
|
20
|
-
* //= true
|
|
21
|
-
* turf.booleanEqual(pt2, pt3);
|
|
22
|
-
* //= false
|
|
23
|
-
*/
|
|
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;
|
|
35
|
-
if (type1 !== type2)
|
|
36
|
-
return false;
|
|
37
|
-
const equality = new GeojsonEquality({ precision: precision });
|
|
38
|
-
return equality.compare(cleanCoords(feature1), cleanCoords(feature2));
|
|
39
|
-
}
|
|
40
|
-
export default booleanEqual;
|
package/dist/es/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
package/dist/js/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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");
|
|
7
|
-
/**
|
|
8
|
-
* Determine whether two geometries of the same type have identical X,Y coordinate values.
|
|
9
|
-
* See http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm
|
|
10
|
-
*
|
|
11
|
-
* @name booleanEqual
|
|
12
|
-
* @param {Geometry|Feature} feature1 GeoJSON input
|
|
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
|
-
* @returns {boolean} true if the objects are equal, false otherwise
|
|
17
|
-
* @example
|
|
18
|
-
* var pt1 = turf.point([0, 0]);
|
|
19
|
-
* var pt2 = turf.point([0, 0]);
|
|
20
|
-
* var pt3 = turf.point([1, 1]);
|
|
21
|
-
*
|
|
22
|
-
* turf.booleanEqual(pt1, pt2);
|
|
23
|
-
* //= true
|
|
24
|
-
* turf.booleanEqual(pt2, pt3);
|
|
25
|
-
* //= false
|
|
26
|
-
*/
|
|
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;
|
|
38
|
-
if (type1 !== type2)
|
|
39
|
-
return false;
|
|
40
|
-
const equality = new geojson_equality_1.default({ precision: precision });
|
|
41
|
-
return equality.compare(clean_coords_1.default(feature1), clean_coords_1.default(feature2));
|
|
42
|
-
}
|
|
43
|
-
exports.default = booleanEqual;
|