@turf/union 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 +5 -9
- 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,10 +8,10 @@ Takes input [(Multi)Polygon(s)][1] and returns a combined polygon. If the input
|
|
|
8
8
|
|
|
9
9
|
### Parameters
|
|
10
10
|
|
|
11
|
-
* `polygon1` **[Feature][3]<([Polygon][
|
|
12
|
-
* `options` **[Object][
|
|
11
|
+
* `polygon1` **[Feature][3]<([Polygon][1] | [MultiPolygon][2])>** input Polygon features
|
|
12
|
+
* `options` **[Object][4]** Optional Parameters (optional, default `{}`)
|
|
13
13
|
|
|
14
|
-
* `options.properties` **[Object][
|
|
14
|
+
* `options.properties` **[Object][4]** Translate Properties to output Feature (optional, default `{}`)
|
|
15
15
|
|
|
16
16
|
### Examples
|
|
17
17
|
|
|
@@ -37,7 +37,7 @@ var union = turf.union(turf.featureCollection([poly1, poly2]));
|
|
|
37
37
|
var addToMap = [poly1, poly2, union];
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
Returns **[Feature][3]<([Polygon][
|
|
40
|
+
Returns **[Feature][3]<([Polygon][1] | [MultiPolygon][2])>** a combined [Polygon][1] or [MultiPolygon][2] feature, or null if the inputs are empty
|
|
41
41
|
|
|
42
42
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
43
43
|
|
|
@@ -45,11 +45,7 @@ Returns **[Feature][3]<([Polygon][4] | [MultiPolygon][5])>** a combined [Polygon
|
|
|
45
45
|
|
|
46
46
|
[3]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
47
47
|
|
|
48
|
-
[4]: https://
|
|
49
|
-
|
|
50
|
-
[5]: https://tools.ietf.org/html/rfc7946#section-3.1.7
|
|
51
|
-
|
|
52
|
-
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
48
|
+
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
53
49
|
|
|
54
50
|
<!-- 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. -->
|
|
55
51
|
|
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 union(features, options = {}) {
|
|
|
21
18
|
else
|
|
22
19
|
return _helpers.multiPolygon.call(void 0, unioned, options.properties);
|
|
23
20
|
}
|
|
24
|
-
__name(union, "union");
|
|
25
21
|
var turf_union_default = union;
|
|
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":";AAAA,OAAO,qBAAqB;AAC5B,SAAS,cAAc,eAAe;AACtC,SAAS,gBAAgB;AAsCzB,SAAS,MACP,UACA,UAA8B,CAAC,GACY;AAC3C,QAAM,QAAgC,CAAC;AACvC,WAAS,UAAU,CAAC,SAAS;AAC3B,UAAM,KAAK,KAAK,WAAmC;AAAA,EACrD,CAAC;AAED,MAAI,MAAM,SAAS,GAAG;AACpB,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEA,QAAM,UAAU,gBAAgB,MAAM,MAAM,CAAC,GAAG,GAAG,MAAM,MAAM,CAAC,CAAC;AACjE,MAAI,QAAQ,WAAW;AAAG,WAAO;AACjC,MAAI,QAAQ,WAAW;AAAG,WAAO,QAAQ,QAAQ,CAAC,GAAG,QAAQ,UAAU;AAAA;AAClE,WAAO,aAAa,SAAS,QAAQ,UAAU;AACtD;AAGA,IAAO,qBAAQ","sourcesContent":["import polygonClipping from \"polygon-clipping\";\nimport { multiPolygon, polygon } from \"@turf/helpers\";\nimport { geomEach } from \"@turf/meta\";\nimport {\n FeatureCollection,\n Feature,\n Polygon,\n MultiPolygon,\n GeoJsonProperties,\n} from \"geojson\";\n\n/**\n * Takes input {@link (Multi)Polygon(s)} and returns a combined polygon. If the input polygons are not contiguous, this function returns a {@link MultiPolygon} feature.\n *\n * @name union\n * @param {Feature<Polygon|MultiPolygon>} polygon1 input Polygon features\n * @param {Object} [options={}] Optional Parameters\n * @param {Object} [options.properties={}] Translate Properties to output Feature\n * @returns {Feature<(Polygon|MultiPolygon)>} a combined {@link Polygon} or {@link MultiPolygon} feature, or null if the inputs are empty\n * @example\n * var poly1 = turf.polygon([[\n * [-82.574787, 35.594087],\n * [-82.574787, 35.615581],\n * [-82.545261, 35.615581],\n * [-82.545261, 35.594087],\n * [-82.574787, 35.594087]\n * ]], {\"fill\": \"#0f0\"});\n * var poly2 = turf.polygon([[\n * [-82.560024, 35.585153],\n * [-82.560024, 35.602602],\n * [-82.52964, 35.602602],\n * [-82.52964, 35.585153],\n * [-82.560024, 35.585153]\n * ]], {\"fill\": \"#00f\"});\n *\n * var union = turf.union(turf.featureCollection([poly1, poly2]));\n *\n * //addToMap\n * var addToMap = [poly1, poly2, union];\n */\nfunction union<P extends GeoJsonProperties = GeoJsonProperties>(\n features: FeatureCollection<Polygon | MultiPolygon>,\n options: { properties?: P } = {}\n): Feature<Polygon | MultiPolygon, P> | null {\n const geoms: polygonClipping.Geom[] = [];\n geomEach(features, (geom) => {\n geoms.push(geom.coordinates as polygonClipping.Geom);\n });\n\n if (geoms.length < 2) {\n throw new Error(\"Must have at least 2 geometries\");\n }\n\n const unioned = polygonClipping.union(geoms[0], ...geoms.slice(1));\n if (unioned.length === 0) return null;\n if (unioned.length === 1) return polygon(unioned[0], options.properties);\n else return multiPolygon(unioned, options.properties);\n}\n\nexport { union };\nexport default union;\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 { multiPolygon, polygon } from "@turf/helpers";
|
|
@@ -21,7 +18,6 @@ function union(features, options = {}) {
|
|
|
21
18
|
else
|
|
22
19
|
return multiPolygon(unioned, options.properties);
|
|
23
20
|
}
|
|
24
|
-
__name(union, "union");
|
|
25
21
|
var turf_union_default = union;
|
|
26
22
|
export {
|
|
27
23
|
turf_union_default as default,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import polygonClipping from \"polygon-clipping\";\nimport { multiPolygon, polygon } from \"@turf/helpers\";\nimport { geomEach } from \"@turf/meta\";\nimport {\n FeatureCollection,\n Feature,\n Polygon,\n MultiPolygon,\n GeoJsonProperties,\n} from \"geojson\";\n\n/**\n * Takes input {@link (Multi)Polygon(s)} and returns a combined polygon. If the input polygons are not contiguous, this function returns a {@link MultiPolygon} feature.\n *\n * @name union\n * @param {Feature<Polygon|MultiPolygon>} polygon1 input Polygon features\n * @param {Object} [options={}] Optional Parameters\n * @param {Object} [options.properties={}] Translate Properties to output Feature\n * @returns {Feature<(Polygon|MultiPolygon)>} a combined {@link Polygon} or {@link MultiPolygon} feature, or null if the inputs are empty\n * @example\n * var poly1 = turf.polygon([[\n * [-82.574787, 35.594087],\n * [-82.574787, 35.615581],\n * [-82.545261, 35.615581],\n * [-82.545261, 35.594087],\n * [-82.574787, 35.594087]\n * ]], {\"fill\": \"#0f0\"});\n * var poly2 = turf.polygon([[\n * [-82.560024, 35.585153],\n * [-82.560024, 35.602602],\n * [-82.52964, 35.602602],\n * [-82.52964, 35.585153],\n * [-82.560024, 35.585153]\n * ]], {\"fill\": \"#00f\"});\n *\n * var union = turf.union(turf.featureCollection([poly1, poly2]));\n *\n * //addToMap\n * var addToMap = [poly1, poly2, union];\n */\nfunction union<P extends GeoJsonProperties = GeoJsonProperties>(\n features: FeatureCollection<Polygon | MultiPolygon>,\n options: { properties?: P } = {}\n): Feature<Polygon | MultiPolygon, P> | null {\n const geoms: polygonClipping.Geom[] = [];\n geomEach(features, (geom) => {\n geoms.push(geom.coordinates as polygonClipping.Geom);\n });\n\n if (geoms.length < 2) {\n throw new Error(\"Must have at least 2 geometries\");\n }\n\n const unioned = polygonClipping.union(geoms[0], ...geoms.slice(1));\n if (unioned.length === 0) return null;\n if (unioned.length === 1) return polygon(unioned[0], options.properties);\n else return multiPolygon(unioned, options.properties);\n}\n\nexport { union };\nexport default union;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import polygonClipping from \"polygon-clipping\";\nimport { multiPolygon, polygon } from \"@turf/helpers\";\nimport { geomEach } from \"@turf/meta\";\nimport {\n FeatureCollection,\n Feature,\n Polygon,\n MultiPolygon,\n GeoJsonProperties,\n} from \"geojson\";\n\n/**\n * Takes input {@link (Multi)Polygon(s)} and returns a combined polygon. If the input polygons are not contiguous, this function returns a {@link MultiPolygon} feature.\n *\n * @name union\n * @param {Feature<Polygon|MultiPolygon>} polygon1 input Polygon features\n * @param {Object} [options={}] Optional Parameters\n * @param {Object} [options.properties={}] Translate Properties to output Feature\n * @returns {Feature<(Polygon|MultiPolygon)>} a combined {@link Polygon} or {@link MultiPolygon} feature, or null if the inputs are empty\n * @example\n * var poly1 = turf.polygon([[\n * [-82.574787, 35.594087],\n * [-82.574787, 35.615581],\n * [-82.545261, 35.615581],\n * [-82.545261, 35.594087],\n * [-82.574787, 35.594087]\n * ]], {\"fill\": \"#0f0\"});\n * var poly2 = turf.polygon([[\n * [-82.560024, 35.585153],\n * [-82.560024, 35.602602],\n * [-82.52964, 35.602602],\n * [-82.52964, 35.585153],\n * [-82.560024, 35.585153]\n * ]], {\"fill\": \"#00f\"});\n *\n * var union = turf.union(turf.featureCollection([poly1, poly2]));\n *\n * //addToMap\n * var addToMap = [poly1, poly2, union];\n */\nfunction union<P extends GeoJsonProperties = GeoJsonProperties>(\n features: FeatureCollection<Polygon | MultiPolygon>,\n options: { properties?: P } = {}\n): Feature<Polygon | MultiPolygon, P> | null {\n const geoms: polygonClipping.Geom[] = [];\n geomEach(features, (geom) => {\n geoms.push(geom.coordinates as polygonClipping.Geom);\n });\n\n if (geoms.length < 2) {\n throw new Error(\"Must have at least 2 geometries\");\n }\n\n const unioned = polygonClipping.union(geoms[0], ...geoms.slice(1));\n if (unioned.length === 0) return null;\n if (unioned.length === 1) return polygon(unioned[0], options.properties);\n else return multiPolygon(unioned, options.properties);\n}\n\nexport { union };\nexport default union;\n"],"mappings":";AAAA,OAAO,qBAAqB;AAC5B,SAAS,cAAc,eAAe;AACtC,SAAS,gBAAgB;AAsCzB,SAAS,MACP,UACA,UAA8B,CAAC,GACY;AAC3C,QAAM,QAAgC,CAAC;AACvC,WAAS,UAAU,CAAC,SAAS;AAC3B,UAAM,KAAK,KAAK,WAAmC;AAAA,EACrD,CAAC;AAED,MAAI,MAAM,SAAS,GAAG;AACpB,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEA,QAAM,UAAU,gBAAgB,MAAM,MAAM,CAAC,GAAG,GAAG,MAAM,MAAM,CAAC,CAAC;AACjE,MAAI,QAAQ,WAAW;AAAG,WAAO;AACjC,MAAI,QAAQ,WAAW;AAAG,WAAO,QAAQ,QAAQ,CAAC,GAAG,QAAQ,UAAU;AAAA;AAClE,WAAO,aAAa,SAAS,QAAQ,UAAU;AACtD;AAGA,IAAO,qBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/union",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.1.0-alpha.70+948cdafaf",
|
|
4
4
|
"description": "turf union module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,10 +63,11 @@
|
|
|
63
63
|
"write-json-file": "^5.0.0"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@turf/helpers": "^7.0.
|
|
67
|
-
"@turf/meta": "^7.0.
|
|
66
|
+
"@turf/helpers": "^7.1.0-alpha.70+948cdafaf",
|
|
67
|
+
"@turf/meta": "^7.1.0-alpha.70+948cdafaf",
|
|
68
|
+
"@types/geojson": "^7946.0.10",
|
|
68
69
|
"polygon-clipping": "^0.15.3",
|
|
69
70
|
"tslib": "^2.6.2"
|
|
70
71
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "948cdafaf70606d2e27fcc79973fa48ee1182067"
|
|
72
73
|
}
|