@turf/union 7.2.0 → 7.3.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/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +12 -13
package/dist/cjs/index.cjs
CHANGED
|
@@ -15,9 +15,9 @@ function union2(features, options = {}) {
|
|
|
15
15
|
if (unioned.length === 1) return _helpers.polygon.call(void 0, unioned[0], options.properties);
|
|
16
16
|
else return _helpers.multiPolygon.call(void 0, unioned, options.properties);
|
|
17
17
|
}
|
|
18
|
-
var
|
|
18
|
+
var index_default = union2;
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
exports.default =
|
|
22
|
+
exports.default = index_default; exports.union = union2;
|
|
23
23
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-union/dist/cjs/index.cjs","../../index.ts"],"names":["union"],"mappings":"AAAA;ACAA,8FAA0B;AAC1B,wCAAsC;AACtC,kCAAyB;AAyDzB,SAASA,MAAAA,CACP,QAAA,EACA,QAAA,EAA8B,CAAC,CAAA,EACY;AAC3C,EAAA,MAAM,MAAA,EAAyB,CAAC,CAAA;AAChC,EAAA,4BAAA,QAAS,EAAU,CAAC,IAAA,EAAA,GAAS;AAC3B,IAAA,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,WAA4B,CAAA;AAAA,EAC9C,CAAC,CAAA;AAED,EAAA,GAAA,CAAI,KAAA,CAAM,OAAA,EAAS,CAAA,EAAG;AACpB,IAAA,MAAM,IAAI,KAAA,CAAM,iCAAiC,CAAA;AAAA,EACnD;AAEA,EAAA,MAAM,QAAA,EAAmB,QAAA,CAAA,KAAA,CAAM,KAAA,CAAM,CAAC,CAAA,EAAG,GAAG,KAA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AAS,OAAA,CAAQ,UAAU,CAAA;AACtD;AAGA,IAAO,cAAA,EAAQA,MAAAA;AD7Df;AACE;AACA;AACF,wDAAC","file":"/home/runner/work/turf/turf/packages/turf-union/dist/cjs/index.cjs","sourcesContent":[null,"import * as polyclip from \"polyclip-ts\";\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 a collection of input polygons and returns a combined polygon. If the\n * input polygons are not contiguous, this function returns a multi-polygon\n * feature.\n *\n * @function\n * @param {FeatureCollection<Polygon|MultiPolygon>} features input polygon features\n * @param {Object} [options={}] Optional Parameters\n * @param {GeoJsonProperties} [options.properties={}] properties to assign to output feature\n * @returns {Feature<(Polygon|MultiPolygon)>|null} a combined polygon or multi-polygon feature, or null if there were no input polygons to combine\n * @example\n *\n * const poly1 = turf.polygon(\n * [\n * [\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 * ],\n * ],\n * { fill: \"#0f0\" }\n * );\n *\n * const poly2 = turf.polygon(\n * [\n * [\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 * ],\n * ],\n * );\n *\n * const union = turf.union(turf.featureCollection([poly1, poly2]));\n *\n * //addToMap\n * const addToMap = { poly1, poly2, union };\n *\n * poly1.properties.fill = \"#0f0\";\n * poly2.properties.fill = \"#00f\";\n * union.properties.stroke = \"red\";\n * union.properties[\"stroke-width\"] = 4;\n * union.properties.fill = \"transparent\";\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: polyclip.Geom[] = [];\n geomEach(features, (geom) => {\n geoms.push(geom.coordinates as polyclip.Geom);\n });\n\n if (geoms.length < 2) {\n throw new Error(\"Must have at least 2 geometries\");\n }\n\n const unioned = polyclip.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
|
@@ -15,9 +15,9 @@ function union2(features, options = {}) {
|
|
|
15
15
|
if (unioned.length === 1) return polygon(unioned[0], options.properties);
|
|
16
16
|
else return multiPolygon(unioned, options.properties);
|
|
17
17
|
}
|
|
18
|
-
var
|
|
18
|
+
var index_default = union2;
|
|
19
19
|
export {
|
|
20
|
-
|
|
20
|
+
index_default as default,
|
|
21
21
|
union2 as union
|
|
22
22
|
};
|
|
23
23
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import * as polyclip from \"polyclip-ts\";\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 a collection of input polygons and returns a combined polygon. If the\n * input polygons are not contiguous, this function returns a multi-polygon\n * feature.\n *\n * @function\n * @param {FeatureCollection<Polygon|MultiPolygon>} features input polygon features\n * @param {Object} [options={}] Optional Parameters\n * @param {GeoJsonProperties} [options.properties={}] properties to assign to output feature\n * @returns {Feature<(Polygon|MultiPolygon)>|null} a combined polygon or multi-polygon feature, or null if there were no input polygons to combine\n * @example\n *\n * const poly1 = turf.polygon(\n * [\n * [\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 * ],\n * ],\n * { fill: \"#0f0\" }\n * );\n *\n * const poly2 = turf.polygon(\n * [\n * [\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 * ],\n * ],\n * );\n *\n * const union = turf.union(turf.featureCollection([poly1, poly2]));\n *\n * //addToMap\n * const addToMap = { poly1, poly2, union };\n *\n * poly1.properties.fill = \"#0f0\";\n * poly2.properties.fill = \"#00f\";\n * union.properties.stroke = \"red\";\n * union.properties[\"stroke-width\"] = 4;\n * union.properties.fill = \"transparent\";\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: polyclip.Geom[] = [];\n geomEach(features, (geom) => {\n geoms.push(geom.coordinates as polyclip.Geom);\n });\n\n if (geoms.length < 2) {\n throw new Error(\"Must have at least 2 geometries\");\n }\n\n const unioned = polyclip.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,YAAY,cAAc;AAC1B,SAAS,cAAc,eAAe;AACtC,SAAS,gBAAgB;AAyDzB,SAASA,OACP,UACA,UAA8B,CAAC,GACY;AAC3C,QAAM,QAAyB,CAAC;AAChC,WAAS,UAAU,CAAC,SAAS;AAC3B,UAAM,KAAK,KAAK,WAA4B;AAAA,EAC9C,CAAC;AAED,MAAI,MAAM,SAAS,GAAG;AACpB,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEA,QAAM,UAAmB,eAAM,MAAM,CAAC,GAAG,GAAG,MAAM,MAAM,CAAC,CAAC;AAC1D,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,MAAI,QAAQ,WAAW,EAAG,QAAO,QAAQ,QAAQ,CAAC,GAAG,QAAQ,UAAU;AAAA,MAClE,QAAO,aAAa,SAAS,QAAQ,UAAU;AACtD;AAGA,IAAO,
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import * as polyclip from \"polyclip-ts\";\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 a collection of input polygons and returns a combined polygon. If the\n * input polygons are not contiguous, this function returns a multi-polygon\n * feature.\n *\n * @function\n * @param {FeatureCollection<Polygon|MultiPolygon>} features input polygon features\n * @param {Object} [options={}] Optional Parameters\n * @param {GeoJsonProperties} [options.properties={}] properties to assign to output feature\n * @returns {Feature<(Polygon|MultiPolygon)>|null} a combined polygon or multi-polygon feature, or null if there were no input polygons to combine\n * @example\n *\n * const poly1 = turf.polygon(\n * [\n * [\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 * ],\n * ],\n * { fill: \"#0f0\" }\n * );\n *\n * const poly2 = turf.polygon(\n * [\n * [\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 * ],\n * ],\n * );\n *\n * const union = turf.union(turf.featureCollection([poly1, poly2]));\n *\n * //addToMap\n * const addToMap = { poly1, poly2, union };\n *\n * poly1.properties.fill = \"#0f0\";\n * poly2.properties.fill = \"#00f\";\n * union.properties.stroke = \"red\";\n * union.properties[\"stroke-width\"] = 4;\n * union.properties.fill = \"transparent\";\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: polyclip.Geom[] = [];\n geomEach(features, (geom) => {\n geoms.push(geom.coordinates as polyclip.Geom);\n });\n\n if (geoms.length < 2) {\n throw new Error(\"Must have at least 2 geometries\");\n }\n\n const unioned = polyclip.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,YAAY,cAAc;AAC1B,SAAS,cAAc,eAAe;AACtC,SAAS,gBAAgB;AAyDzB,SAASA,OACP,UACA,UAA8B,CAAC,GACY;AAC3C,QAAM,QAAyB,CAAC;AAChC,WAAS,UAAU,CAAC,SAAS;AAC3B,UAAM,KAAK,KAAK,WAA4B;AAAA,EAC9C,CAAC;AAED,MAAI,MAAM,SAAS,GAAG;AACpB,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEA,QAAM,UAAmB,eAAM,MAAM,CAAC,GAAG,GAAG,MAAM,MAAM,CAAC,CAAC;AAC1D,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,MAAI,QAAQ,WAAW,EAAG,QAAO,QAAQ,QAAQ,CAAC,GAAG,QAAQ,UAAU;AAAA,MAClE,QAAO,aAAa,SAAS,QAAQ,UAAU;AACtD;AAGA,IAAO,gBAAQC;","names":["union","union"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/union",
|
|
3
|
-
"version": "7.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "7.3.1",
|
|
4
|
+
"description": "Combines two or more polygons into a single polygon.",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bugs": {
|
|
@@ -45,29 +45,28 @@
|
|
|
45
45
|
"bench": "tsx bench.ts",
|
|
46
46
|
"build": "tsup --config ../../tsup.config.ts",
|
|
47
47
|
"docs": "tsx ../../scripts/generate-readmes.ts",
|
|
48
|
-
"test": "
|
|
48
|
+
"test": "pnpm run /test:.*/",
|
|
49
49
|
"test:tape": "tsx test.ts",
|
|
50
50
|
"test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/benchmark": "^2.1.5",
|
|
54
|
-
"@types/tape": "^
|
|
54
|
+
"@types/tape": "^5.8.1",
|
|
55
55
|
"benchmark": "^2.1.4",
|
|
56
|
-
"glob": "^
|
|
56
|
+
"glob": "^11.1.0",
|
|
57
57
|
"load-json-file": "^7.0.1",
|
|
58
|
-
"npm-run-all": "^4.1.5",
|
|
59
58
|
"tape": "^5.9.0",
|
|
60
|
-
"tsup": "^8.
|
|
61
|
-
"tsx": "^4.19.
|
|
62
|
-
"typescript": "^5.
|
|
63
|
-
"write-json-file": "^
|
|
59
|
+
"tsup": "^8.4.0",
|
|
60
|
+
"tsx": "^4.19.4",
|
|
61
|
+
"typescript": "^5.8.3",
|
|
62
|
+
"write-json-file": "^6.0.0"
|
|
64
63
|
},
|
|
65
64
|
"dependencies": {
|
|
66
|
-
"@turf/helpers": "
|
|
67
|
-
"@turf/meta": "
|
|
65
|
+
"@turf/helpers": "7.3.1",
|
|
66
|
+
"@turf/meta": "7.3.1",
|
|
68
67
|
"@types/geojson": "^7946.0.10",
|
|
69
68
|
"polyclip-ts": "^0.16.8",
|
|
70
69
|
"tslib": "^2.8.1"
|
|
71
70
|
},
|
|
72
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "b7f1b4eafb760431e03955499d8eac9489438219"
|
|
73
72
|
}
|