@turf/boolean-equal 6.5.0 → 7.0.0-alpha.1
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 +22 -9
- package/dist/es/index.js +14 -4
- package/dist/js/index.d.ts +6 -2
- package/dist/js/index.js +18 -10
- package/package.json +12 -10
package/README.md
CHANGED
|
@@ -4,36 +4,49 @@
|
|
|
4
4
|
|
|
5
5
|
## booleanEqual
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
See [
|
|
7
|
+
Determines whether two geometries or features of the same type have identical X,Y coordinate values and properties.
|
|
8
|
+
See [http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm][1]
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### Parameters
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
**
|
|
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]);
|
|
19
22
|
var pt2 = turf.point([0, 0]);
|
|
20
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'});
|
|
21
26
|
|
|
22
27
|
turf.booleanEqual(pt1, pt2);
|
|
23
28
|
//= true
|
|
24
29
|
turf.booleanEqual(pt2, pt3);
|
|
25
30
|
//= false
|
|
31
|
+
turf.booleanEqual(pt4, pt5);
|
|
32
|
+
//= false
|
|
33
|
+
turf.booleanEqual(pt4.geometry, pt5.geometry);
|
|
34
|
+
//= true
|
|
26
35
|
```
|
|
27
36
|
|
|
28
|
-
Returns **[boolean][
|
|
37
|
+
Returns **[boolean][6]** true if the objects are equal, false otherwise
|
|
29
38
|
|
|
30
|
-
[1]:
|
|
39
|
+
[1]: http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm
|
|
31
40
|
|
|
32
41
|
[2]: https://tools.ietf.org/html/rfc7946#section-3.1
|
|
33
42
|
|
|
34
43
|
[3]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
35
44
|
|
|
36
|
-
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/
|
|
45
|
+
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
46
|
+
|
|
47
|
+
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
48
|
+
|
|
49
|
+
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
37
50
|
|
|
38
51
|
<!-- This file is automatically generated. Please don't edit it directly:
|
|
39
52
|
if you find an error, edit the source file (likely index.js), and re-run
|
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
|
-
|
|
24
|
-
|
|
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
|
-
|
|
37
|
+
const equality = new GeojsonEquality({ precision: precision });
|
|
28
38
|
return equality.compare(cleanCoords(feature1), cleanCoords(feature2));
|
|
29
39
|
}
|
|
30
40
|
export default booleanEqual;
|
package/dist/js/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Feature, Geometry } from "
|
|
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
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
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": "
|
|
3
|
+
"version": "7.0.0-alpha.1",
|
|
4
4
|
"description": "turf boolean-equal module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"exports": {
|
|
35
35
|
"./package.json": "./package.json",
|
|
36
36
|
".": {
|
|
37
|
+
"types": "./dist/js/index.d.ts",
|
|
37
38
|
"import": "./dist/es/index.js",
|
|
38
39
|
"require": "./dist/js/index.js"
|
|
39
40
|
}
|
|
@@ -44,13 +45,13 @@
|
|
|
44
45
|
"dist"
|
|
45
46
|
],
|
|
46
47
|
"scripts": {
|
|
47
|
-
"bench": "
|
|
48
|
+
"bench": "tsx bench.js",
|
|
48
49
|
"build": "npm-run-all build:*",
|
|
49
50
|
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
|
|
50
51
|
"build:js": "tsc",
|
|
51
|
-
"docs": "
|
|
52
|
+
"docs": "tsx ../../scripts/generate-readmes",
|
|
52
53
|
"test": "npm-run-all test:*",
|
|
53
|
-
"test:tape": "
|
|
54
|
+
"test:tape": "tsx test.js"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@types/geojson-equality": "^0.2.0",
|
|
@@ -61,15 +62,16 @@
|
|
|
61
62
|
"load-json-file": "*",
|
|
62
63
|
"npm-run-all": "*",
|
|
63
64
|
"tape": "*",
|
|
64
|
-
"ts-node": "*",
|
|
65
65
|
"tslint": "*",
|
|
66
|
+
"tsx": "*",
|
|
66
67
|
"typescript": "*"
|
|
67
68
|
},
|
|
68
69
|
"dependencies": {
|
|
69
|
-
"@turf/clean-coords": "^
|
|
70
|
-
"@turf/helpers": "^
|
|
71
|
-
"@turf/invariant": "^
|
|
72
|
-
"geojson-equality": "0.1.6"
|
|
70
|
+
"@turf/clean-coords": "^7.0.0-alpha.1",
|
|
71
|
+
"@turf/helpers": "^7.0.0-alpha.1",
|
|
72
|
+
"@turf/invariant": "^7.0.0-alpha.1",
|
|
73
|
+
"geojson-equality": "0.1.6",
|
|
74
|
+
"tslib": "^2.3.0"
|
|
73
75
|
},
|
|
74
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "cf7a0c507b017ca066acffd0ce23bda5b393fb5a"
|
|
75
77
|
}
|