@turf/union 7.2.0 → 7.3.0

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.
@@ -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 turf_union_default = union2;
18
+ var index_default = union2;
19
19
 
20
20
 
21
21
 
22
- exports.default = turf_union_default; exports.union = union2;
22
+ exports.default = index_default; exports.union = union2;
23
23
  //# sourceMappingURL=index.cjs.map
@@ -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,KAAA,CAAM,KAAA,CAAM,CAAC,CAAC,CAAA;AAC1D,EAAA,GAAA,CAAI,OAAA,CAAQ,OAAA,IAAW,CAAA,EAAG,OAAO,IAAA;AACjC,EAAA,GAAA,CAAI,OAAA,CAAQ,OAAA,IAAW,CAAA,EAAG,OAAO,8BAAA,OAAQ,CAAQ,CAAC,CAAA,EAAG,OAAA,CAAQ,UAAU,CAAA;AAAA,EAAA,KAClE,OAAO,mCAAA,OAAa,EAAS,OAAA,CAAQ,UAAU,CAAA;AACtD;AAGA,IAAO,mBAAA,EAAQA,MAAAA;AD7Df;AACE;AACA;AACF,6DAAC","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"]}
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,KAAA,CAAM,KAAA,CAAM,CAAC,CAAC,CAAA;AAC1D,EAAA,GAAA,CAAI,OAAA,CAAQ,OAAA,IAAW,CAAA,EAAG,OAAO,IAAA;AACjC,EAAA,GAAA,CAAI,OAAA,CAAQ,OAAA,IAAW,CAAA,EAAG,OAAO,8BAAA,OAAQ,CAAQ,CAAC,CAAA,EAAG,OAAA,CAAQ,UAAU,CAAA;AAAA,EAAA,KAClE,OAAO,mCAAA,OAAa,EAAS,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 turf_union_default = union2;
18
+ var index_default = union2;
19
19
  export {
20
- turf_union_default as default,
20
+ index_default as default,
21
21
  union2 as union
22
22
  };
23
23
  //# sourceMappingURL=index.js.map
@@ -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,qBAAQC;","names":["union","union"]}
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.2.0",
4
- "description": "turf union module",
3
+ "version": "7.3.0",
4
+ "description": "Combines two or more polygons into a single polygon.",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
7
7
  "bugs": {
@@ -51,23 +51,23 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/benchmark": "^2.1.5",
54
- "@types/tape": "^4.13.4",
54
+ "@types/tape": "^5.8.1",
55
55
  "benchmark": "^2.1.4",
56
- "glob": "^10.3.10",
56
+ "glob": "^11.0.2",
57
57
  "load-json-file": "^7.0.1",
58
58
  "npm-run-all": "^4.1.5",
59
59
  "tape": "^5.9.0",
60
- "tsup": "^8.3.5",
61
- "tsx": "^4.19.2",
62
- "typescript": "^5.5.4",
63
- "write-json-file": "^5.0.0"
60
+ "tsup": "^8.4.0",
61
+ "tsx": "^4.19.4",
62
+ "typescript": "^5.8.3",
63
+ "write-json-file": "^6.0.0"
64
64
  },
65
65
  "dependencies": {
66
- "@turf/helpers": "^7.2.0",
67
- "@turf/meta": "^7.2.0",
66
+ "@turf/helpers": "7.3.0",
67
+ "@turf/meta": "7.3.0",
68
68
  "@types/geojson": "^7946.0.10",
69
69
  "polyclip-ts": "^0.16.8",
70
70
  "tslib": "^2.8.1"
71
71
  },
72
- "gitHead": "7b0f0374c4668cd569f8904c71e2ae7d941be867"
72
+ "gitHead": "9f58a103e8f9a587ab640307ed03ba5233913ddd"
73
73
  }