@turf/difference 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
|
@@ -16,9 +16,9 @@ function difference2(features) {
|
|
|
16
16
|
if (differenced.length === 1) return _helpers.polygon.call(void 0, differenced[0], properties);
|
|
17
17
|
return _helpers.multiPolygon.call(void 0, differenced, properties);
|
|
18
18
|
}
|
|
19
|
-
var
|
|
19
|
+
var index_default = difference2;
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
exports.default =
|
|
23
|
+
exports.default = index_default; exports.difference = difference2;
|
|
24
24
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-difference/dist/cjs/index.cjs","../../index.ts"],"names":["difference"],"mappings":"AAAA;ACCA,8FAA0B;AAC1B,wCAAsC;AACtC,kCAAyB;AAmCzB,SAASA,WAAAA,CACP,QAAA,EACwC;AACxC,EAAA,MAAM,MAAA,EAA8B,CAAC,CAAA;AAErC,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,WAAA,EAAa,QAAA,CAAS,QAAA,CAAS,CAAC,CAAA,CAAE,WAAA,GAAc,CAAC,CAAA;AAEvD,EAAA,MAAM,YAAA,EAAuB,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AQ,CAAY,CAAC,CAAA,EAAG,UAAU,CAAA;AACvE,EAAA,OAAO,mCAAA,WAAa,EAAa,UAAU,CAAA;AAC7C;AAGA,IAAO,cAAA,EAAQA,WAAAA;ADzCf;AACE;AACA;AACF,kEAAC","file":"/home/runner/work/turf/turf/packages/turf-difference/dist/cjs/index.cjs","sourcesContent":[null,"import { Polygon, MultiPolygon, Feature, FeatureCollection } from \"geojson\";\nimport * as polyclip from \"polyclip-ts\";\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 * @function\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<polyclip.Geom> = [];\n\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 two features\");\n }\n\n const properties = features.features[0].properties || {};\n\n const differenced = polyclip.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
|
@@ -16,9 +16,9 @@ function difference2(features) {
|
|
|
16
16
|
if (differenced.length === 1) return polygon(differenced[0], properties);
|
|
17
17
|
return multiPolygon(differenced, properties);
|
|
18
18
|
}
|
|
19
|
-
var
|
|
19
|
+
var index_default = difference2;
|
|
20
20
|
export {
|
|
21
|
-
|
|
21
|
+
index_default as default,
|
|
22
22
|
difference2 as difference
|
|
23
23
|
};
|
|
24
24
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Polygon, MultiPolygon, Feature, FeatureCollection } from \"geojson\";\nimport * as polyclip from \"polyclip-ts\";\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 * @function\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<polyclip.Geom> = [];\n\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 two features\");\n }\n\n const properties = features.features[0].properties || {};\n\n const differenced = polyclip.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,YAAY,cAAc;AAC1B,SAAS,SAAS,oBAAoB;AACtC,SAAS,gBAAgB;AAmCzB,SAASA,YACP,UACwC;AACxC,QAAM,QAA8B,CAAC;AAErC,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,aAAa,SAAS,SAAS,CAAC,EAAE,cAAc,CAAC;AAEvD,QAAM,cAAuB,oBAAW,MAAM,CAAC,GAAG,GAAG,MAAM,MAAM,CAAC,CAAC;AACnE,MAAI,YAAY,WAAW,EAAG,QAAO;AACrC,MAAI,YAAY,WAAW,EAAG,QAAO,QAAQ,YAAY,CAAC,GAAG,UAAU;AACvE,SAAO,aAAa,aAAa,UAAU;AAC7C;AAGA,IAAO,
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Polygon, MultiPolygon, Feature, FeatureCollection } from \"geojson\";\nimport * as polyclip from \"polyclip-ts\";\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 * @function\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<polyclip.Geom> = [];\n\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 two features\");\n }\n\n const properties = features.features[0].properties || {};\n\n const differenced = polyclip.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,YAAY,cAAc;AAC1B,SAAS,SAAS,oBAAoB;AACtC,SAAS,gBAAgB;AAmCzB,SAASA,YACP,UACwC;AACxC,QAAM,QAA8B,CAAC;AAErC,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,aAAa,SAAS,SAAS,CAAC,EAAE,cAAc,CAAC;AAEvD,QAAM,cAAuB,oBAAW,MAAM,CAAC,GAAG,GAAG,MAAM,MAAM,CAAC,CAAC;AACnE,MAAI,YAAY,WAAW,EAAG,QAAO;AACrC,MAAI,YAAY,WAAW,EAAG,QAAO,QAAQ,YAAY,CAAC,GAAG,UAAU;AACvE,SAAO,aAAa,aAAa,UAAU;AAC7C;AAGA,IAAO,gBAAQC;","names":["difference","difference"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/difference",
|
|
3
|
-
"version": "7.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "7.3.1",
|
|
4
|
+
"description": "Finds the difference between multiple polygons by clipping the subsequent polygon from the first.",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bugs": {
|
|
@@ -45,28 +45,27 @@
|
|
|
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
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/benchmark": "^2.1.5",
|
|
53
|
-
"@types/tape": "^
|
|
53
|
+
"@types/tape": "^5.8.1",
|
|
54
54
|
"benchmark": "^2.1.4",
|
|
55
|
-
"glob": "^
|
|
55
|
+
"glob": "^11.1.0",
|
|
56
56
|
"load-json-file": "^7.0.1",
|
|
57
|
-
"npm-run-all": "^4.1.5",
|
|
58
57
|
"tape": "^5.9.0",
|
|
59
|
-
"tsup": "^8.
|
|
60
|
-
"tsx": "^4.19.
|
|
61
|
-
"typescript": "^5.
|
|
62
|
-
"write-json-file": "^
|
|
58
|
+
"tsup": "^8.4.0",
|
|
59
|
+
"tsx": "^4.19.4",
|
|
60
|
+
"typescript": "^5.8.3",
|
|
61
|
+
"write-json-file": "^6.0.0"
|
|
63
62
|
},
|
|
64
63
|
"dependencies": {
|
|
65
|
-
"@turf/helpers": "
|
|
66
|
-
"@turf/meta": "
|
|
64
|
+
"@turf/helpers": "7.3.1",
|
|
65
|
+
"@turf/meta": "7.3.1",
|
|
67
66
|
"@types/geojson": "^7946.0.10",
|
|
68
67
|
"polyclip-ts": "^0.16.8",
|
|
69
68
|
"tslib": "^2.8.1"
|
|
70
69
|
},
|
|
71
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "b7f1b4eafb760431e03955499d8eac9489438219"
|
|
72
71
|
}
|