@turf/difference 7.0.0 → 7.1.0-alpha.70
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 +4 -6
- package/dist/cjs/index.cjs +1 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Finds the difference between multiple [polygons][1] by clipping the subsequent p
|
|
|
8
8
|
|
|
9
9
|
### Parameters
|
|
10
10
|
|
|
11
|
-
* `features` **[FeatureCollection][2]<([Polygon][
|
|
11
|
+
* `features` **[FeatureCollection][2]<([Polygon][1] | [MultiPolygon][3])>** input Polygon features
|
|
12
12
|
|
|
13
13
|
### Examples
|
|
14
14
|
|
|
@@ -40,17 +40,15 @@ var difference = turf.difference(turf.featureCollection([polygon1, polygon2]));
|
|
|
40
40
|
var addToMap = [polygon1, polygon2, difference];
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
Returns **([Feature][
|
|
43
|
+
Returns **([Feature][4]<([Polygon][1] | [MultiPolygon][3])> | null)** a Polygon or MultiPolygon feature showing the area of `polygon1` excluding the area of `polygon2` (if empty returns `null`)
|
|
44
44
|
|
|
45
45
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
46
46
|
|
|
47
47
|
[2]: https://tools.ietf.org/html/rfc7946#section-3.3
|
|
48
48
|
|
|
49
|
-
[3]: https://tools.ietf.org/html/rfc7946#section-3.1.
|
|
49
|
+
[3]: https://tools.ietf.org/html/rfc7946#section-3.1.7
|
|
50
50
|
|
|
51
|
-
[4]: https://tools.ietf.org/html/rfc7946#section-3.
|
|
52
|
-
|
|
53
|
-
[5]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
51
|
+
[4]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
54
52
|
|
|
55
53
|
<!-- 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. -->
|
|
56
54
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// index.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// index.ts
|
|
5
2
|
var _polygonclipping = require('polygon-clipping'); var _polygonclipping2 = _interopRequireDefault(_polygonclipping);
|
|
6
3
|
var _helpers = require('@turf/helpers');
|
|
7
4
|
var _meta = require('@turf/meta');
|
|
@@ -21,7 +18,6 @@ function difference(features) {
|
|
|
21
18
|
return _helpers.polygon.call(void 0, differenced[0], properties);
|
|
22
19
|
return _helpers.multiPolygon.call(void 0, differenced, properties);
|
|
23
20
|
}
|
|
24
|
-
__name(difference, "difference");
|
|
25
21
|
var turf_difference_default = difference;
|
|
26
22
|
|
|
27
23
|
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AACA,OAAO,qBAA+B;AACtC,SAAS,SAAS,oBAAoB;AACtC,SAAS,gBAAgB;AAmCzB,SAAS,WACP,UACwC;AACxC,QAAM,QAAqB,CAAC;AAE5B,WAAS,UAAU,CAAC,SAAS;AAC3B,UAAM,KAAK,KAAK,WAAmB;AAAA,EACrC,CAAC;AAED,MAAI,MAAM,SAAS,GAAG;AACpB,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEA,QAAM,aAAa,SAAS,SAAS,CAAC,EAAE,cAAc,CAAC;AAEvD,QAAM,cAAc,gBAAgB,WAAW,MAAM,CAAC,GAAG,GAAG,MAAM,MAAM,CAAC,CAAC;AAC1E,MAAI,YAAY,WAAW;AAAG,WAAO;AACrC,MAAI,YAAY,WAAW;AAAG,WAAO,QAAQ,YAAY,CAAC,GAAG,UAAU;AACvE,SAAO,aAAa,aAAa,UAAU;AAC7C;AAGA,IAAO,0BAAQ","sourcesContent":["import { Polygon, MultiPolygon, Feature, FeatureCollection } from \"geojson\";\nimport polygonClipping, { Geom } from \"polygon-clipping\";\nimport { polygon, multiPolygon } from \"@turf/helpers\";\nimport { geomEach } from \"@turf/meta\";\n\n/**\n * Finds the difference between multiple {@link Polygon|polygons} by clipping the subsequent polygon from the first.\n *\n * @name difference\n * @param {FeatureCollection<Polygon|MultiPolygon>} features input Polygon features\n * @returns {Feature<Polygon|MultiPolygon>|null} a Polygon or MultiPolygon feature showing the area of `polygon1` excluding the area of `polygon2` (if empty returns `null`)\n * @example\n * var polygon1 = turf.polygon([[\n * [128, -26],\n * [141, -26],\n * [141, -21],\n * [128, -21],\n * [128, -26]\n * ]], {\n * \"fill\": \"#F00\",\n * \"fill-opacity\": 0.1\n * });\n * var polygon2 = turf.polygon([[\n * [126, -28],\n * [140, -28],\n * [140, -20],\n * [126, -20],\n * [126, -28]\n * ]], {\n * \"fill\": \"#00F\",\n * \"fill-opacity\": 0.1\n * });\n *\n * var difference = turf.difference(turf.featureCollection([polygon1, polygon2]));\n *\n * //addToMap\n * var addToMap = [polygon1, polygon2, difference];\n */\nfunction difference(\n features: FeatureCollection<Polygon | MultiPolygon>\n): Feature<Polygon | MultiPolygon> | null {\n const geoms: Array<Geom> = [];\n\n geomEach(features, (geom) => {\n geoms.push(geom.coordinates as Geom);\n });\n\n if (geoms.length < 2) {\n throw new Error(\"Must have at least two features\");\n }\n\n const properties = features.features[0].properties || {};\n\n const differenced = polygonClipping.difference(geoms[0], ...geoms.slice(1));\n if (differenced.length === 0) return null;\n if (differenced.length === 1) return polygon(differenced[0], properties);\n return multiPolygon(differenced, properties);\n}\n\nexport { difference };\nexport default difference;\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// index.ts
|
|
5
2
|
import polygonClipping from "polygon-clipping";
|
|
6
3
|
import { polygon, multiPolygon } from "@turf/helpers";
|
|
@@ -21,7 +18,6 @@ function difference(features) {
|
|
|
21
18
|
return polygon(differenced[0], properties);
|
|
22
19
|
return multiPolygon(differenced, properties);
|
|
23
20
|
}
|
|
24
|
-
__name(difference, "difference");
|
|
25
21
|
var turf_difference_default = difference;
|
|
26
22
|
export {
|
|
27
23
|
turf_difference_default as default,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Polygon, MultiPolygon, Feature, FeatureCollection } from \"geojson\";\nimport polygonClipping, { Geom } from \"polygon-clipping\";\nimport { polygon, multiPolygon } from \"@turf/helpers\";\nimport { geomEach } from \"@turf/meta\";\n\n/**\n * Finds the difference between multiple {@link Polygon|polygons} by clipping the subsequent polygon from the first.\n *\n * @name difference\n * @param {FeatureCollection<Polygon|MultiPolygon>} features input Polygon features\n * @returns {Feature<Polygon|MultiPolygon>|null} a Polygon or MultiPolygon feature showing the area of `polygon1` excluding the area of `polygon2` (if empty returns `null`)\n * @example\n * var polygon1 = turf.polygon([[\n * [128, -26],\n * [141, -26],\n * [141, -21],\n * [128, -21],\n * [128, -26]\n * ]], {\n * \"fill\": \"#F00\",\n * \"fill-opacity\": 0.1\n * });\n * var polygon2 = turf.polygon([[\n * [126, -28],\n * [140, -28],\n * [140, -20],\n * [126, -20],\n * [126, -28]\n * ]], {\n * \"fill\": \"#00F\",\n * \"fill-opacity\": 0.1\n * });\n *\n * var difference = turf.difference(turf.featureCollection([polygon1, polygon2]));\n *\n * //addToMap\n * var addToMap = [polygon1, polygon2, difference];\n */\nfunction difference(\n features: FeatureCollection<Polygon | MultiPolygon>\n): Feature<Polygon | MultiPolygon> | null {\n const geoms: Array<Geom> = [];\n\n geomEach(features, (geom) => {\n geoms.push(geom.coordinates as Geom);\n });\n\n if (geoms.length < 2) {\n throw new Error(\"Must have at least two features\");\n }\n\n const properties = features.features[0].properties || {};\n\n const differenced = polygonClipping.difference(geoms[0], ...geoms.slice(1));\n if (differenced.length === 0) return null;\n if (differenced.length === 1) return polygon(differenced[0], properties);\n return multiPolygon(differenced, properties);\n}\n\nexport { difference };\nexport default difference;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Polygon, MultiPolygon, Feature, FeatureCollection } from \"geojson\";\nimport polygonClipping, { Geom } from \"polygon-clipping\";\nimport { polygon, multiPolygon } from \"@turf/helpers\";\nimport { geomEach } from \"@turf/meta\";\n\n/**\n * Finds the difference between multiple {@link Polygon|polygons} by clipping the subsequent polygon from the first.\n *\n * @name difference\n * @param {FeatureCollection<Polygon|MultiPolygon>} features input Polygon features\n * @returns {Feature<Polygon|MultiPolygon>|null} a Polygon or MultiPolygon feature showing the area of `polygon1` excluding the area of `polygon2` (if empty returns `null`)\n * @example\n * var polygon1 = turf.polygon([[\n * [128, -26],\n * [141, -26],\n * [141, -21],\n * [128, -21],\n * [128, -26]\n * ]], {\n * \"fill\": \"#F00\",\n * \"fill-opacity\": 0.1\n * });\n * var polygon2 = turf.polygon([[\n * [126, -28],\n * [140, -28],\n * [140, -20],\n * [126, -20],\n * [126, -28]\n * ]], {\n * \"fill\": \"#00F\",\n * \"fill-opacity\": 0.1\n * });\n *\n * var difference = turf.difference(turf.featureCollection([polygon1, polygon2]));\n *\n * //addToMap\n * var addToMap = [polygon1, polygon2, difference];\n */\nfunction difference(\n features: FeatureCollection<Polygon | MultiPolygon>\n): Feature<Polygon | MultiPolygon> | null {\n const geoms: Array<Geom> = [];\n\n geomEach(features, (geom) => {\n geoms.push(geom.coordinates as Geom);\n });\n\n if (geoms.length < 2) {\n throw new Error(\"Must have at least two features\");\n }\n\n const properties = features.features[0].properties || {};\n\n const differenced = polygonClipping.difference(geoms[0], ...geoms.slice(1));\n if (differenced.length === 0) return null;\n if (differenced.length === 1) return polygon(differenced[0], properties);\n return multiPolygon(differenced, properties);\n}\n\nexport { difference };\nexport default difference;\n"],"mappings":";AACA,OAAO,qBAA+B;AACtC,SAAS,SAAS,oBAAoB;AACtC,SAAS,gBAAgB;AAmCzB,SAAS,WACP,UACwC;AACxC,QAAM,QAAqB,CAAC;AAE5B,WAAS,UAAU,CAAC,SAAS;AAC3B,UAAM,KAAK,KAAK,WAAmB;AAAA,EACrC,CAAC;AAED,MAAI,MAAM,SAAS,GAAG;AACpB,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEA,QAAM,aAAa,SAAS,SAAS,CAAC,EAAE,cAAc,CAAC;AAEvD,QAAM,cAAc,gBAAgB,WAAW,MAAM,CAAC,GAAG,GAAG,MAAM,MAAM,CAAC,CAAC;AAC1E,MAAI,YAAY,WAAW;AAAG,WAAO;AACrC,MAAI,YAAY,WAAW;AAAG,WAAO,QAAQ,YAAY,CAAC,GAAG,UAAU;AACvE,SAAO,aAAa,aAAa,UAAU;AAC7C;AAGA,IAAO,0BAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/difference",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.1.0-alpha.70+948cdafaf",
|
|
4
4
|
"description": "turf difference module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -62,10 +62,11 @@
|
|
|
62
62
|
"write-json-file": "^5.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@turf/helpers": "^7.0.
|
|
66
|
-
"@turf/meta": "^7.0.
|
|
65
|
+
"@turf/helpers": "^7.1.0-alpha.70+948cdafaf",
|
|
66
|
+
"@turf/meta": "^7.1.0-alpha.70+948cdafaf",
|
|
67
|
+
"@types/geojson": "^7946.0.10",
|
|
67
68
|
"polygon-clipping": "^0.15.3",
|
|
68
69
|
"tslib": "^2.6.2"
|
|
69
70
|
},
|
|
70
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "948cdafaf70606d2e27fcc79973fa48ee1182067"
|
|
71
72
|
}
|