@turf/dissolve 7.0.0 → 7.1.0-alpha.7
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 +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 +6 -6
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 _helpers = require('@turf/helpers');
|
|
6
3
|
var _invariant = require('@turf/invariant');
|
|
7
4
|
var _meta = require('@turf/meta');
|
|
@@ -58,7 +55,6 @@ function dissolve(fc, options = {}) {
|
|
|
58
55
|
}
|
|
59
56
|
return _flatten.flatten.call(void 0, _helpers.featureCollection.call(void 0, outFeatures));
|
|
60
57
|
}
|
|
61
|
-
__name(dissolve, "dissolve");
|
|
62
58
|
var turf_dissolve_default = dissolve;
|
|
63
59
|
|
|
64
60
|
|
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,SAAS,mBAAmB,UAAU,oBAAoB;AAC1D,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,OAAO,qBAA+B;AAuBtC,SAAS,SACP,IACA,UAEI,CAAC,GACuB;AAE5B,YAAU,WAAW,CAAC;AACtB,MAAI,CAAC,SAAS,OAAO;AAAG,UAAM,IAAI,MAAM,oBAAoB;AAC5D,QAAM,EAAE,aAAa,IAAI;AAGzB,eAAa,IAAI,WAAW,UAAU;AAGtC,QAAM,cAAc,CAAC;AACrB,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,MACL;AAAA,QACE,gBAAgB,MAAM;AAAA,UACpB;AAAA;AAAA,UAEA,GAAG,SAAS,IAAI,SAAU,GAAG;AAC3B,mBAAO,EAAE,SAAS;AAAA,UACpB,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF,OAAO;AAEL,UAAM,qBAAmD,CAAC;AAC1D,gBAAY,IAAI,SAAU,SAAS;AACjC,UAAI,QAAQ,YAAY;AACtB,YACE,CAAC,OAAO,UAAU,eAAe;AAAA,UAC/B;AAAA,UACA,QAAQ,WAAW,YAAY;AAAA,QACjC,GACA;AACA,6BAAmB,QAAQ,WAAW,YAAY,CAAC,IACjD,CAAC;AAAA,QACL;AACA,2BAAmB,QAAQ,WAAW,YAAY,CAAC,EAAE,KAAK,OAAO;AAAA,MACnE;AAAA,IACF,CAAC;AACD,UAAM,OAAO,OAAO,KAAK,kBAAkB;AAG3C,aAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,YAAM,KAAK;AAAA,QACT,gBAAgB,MAAM;AAAA,UACpB;AAAA;AAAA,UAEC,mBAAmB,KAAK,CAAC,CAAC,EAAyB,IAAI,SAAU,GAAG;AACnE,mBAAO,EAAE,SAAS;AAAA,UACpB,CAAC;AAAA,QACH;AAAA,MACF;AACA,UAAI,MAAM,GAAG,YAAY;AACvB,WAAG,WAAW,YAAY,IAAI,KAAK,CAAC;AACpC,oBAAY,KAAK,EAAE;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAEA,SAAO,QAAQ,kBAAkB,WAAW,CAAC;AAC/C;AAGA,IAAO,wBAAQ","sourcesContent":["import { Feature, FeatureCollection, Polygon } from \"geojson\";\nimport { featureCollection, isObject, multiPolygon } from \"@turf/helpers\";\nimport { collectionOf } from \"@turf/invariant\";\nimport { featureEach } from \"@turf/meta\";\nimport { flatten } from \"@turf/flatten\";\nimport polygonClipping, { Geom } from \"polygon-clipping\";\n\n/**\n * Dissolves a FeatureCollection of {@link polygon} features, filtered by an optional property name:value.\n * Note that {@link mulitpolygon} features within the collection are not supported\n *\n * @name dissolve\n * @param {FeatureCollection<Polygon>} featureCollection input feature collection to be dissolved\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.propertyName] features with the same `propertyName` value will be dissolved.\n * @returns {FeatureCollection<Polygon>} a FeatureCollection containing the dissolved polygons\n * @example\n * var features = turf.featureCollection([\n * turf.polygon([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]], {combine: 'yes'}),\n * turf.polygon([[[0, -1], [0, 0], [1, 0], [1, -1], [0,-1]]], {combine: 'yes'}),\n * turf.polygon([[[1,-1],[1, 0], [2, 0], [2, -1], [1, -1]]], {combine: 'no'}),\n * ]);\n *\n * var dissolved = turf.dissolve(features, {propertyName: 'combine'});\n *\n * //addToMap\n * var addToMap = [features, dissolved]\n */\nfunction dissolve(\n fc: FeatureCollection<Polygon>,\n options: {\n propertyName?: string;\n } = {}\n): FeatureCollection<Polygon> {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n const { propertyName } = options;\n\n // Input validation\n collectionOf(fc, \"Polygon\", \"dissolve\");\n\n // Main\n const outFeatures = [];\n if (!propertyName) {\n return flatten(\n multiPolygon(\n polygonClipping.union.apply(\n null,\n // List of polygons expressed as Position[][][] a.k.a. Geom[]\n fc.features.map(function (f) {\n return f.geometry.coordinates;\n }) as [Geom, ...Geom[]]\n )\n )\n );\n } else {\n // Group polygons by the value of their property named by propertyName\n const uniquePropertyVals: { [key: string]: Feature[] } = {};\n featureEach(fc, function (feature) {\n if (feature.properties) {\n if (\n !Object.prototype.hasOwnProperty.call(\n uniquePropertyVals,\n feature.properties[propertyName]\n )\n ) {\n uniquePropertyVals[feature.properties[propertyName]] =\n [] as Feature[];\n }\n uniquePropertyVals[feature.properties[propertyName]].push(feature);\n }\n });\n const vals = Object.keys(uniquePropertyVals);\n\n // Export each group of polygons as a separate feature.\n for (let i = 0; i < vals.length; i++) {\n const mp = multiPolygon(\n polygonClipping.union.apply(\n null,\n // List of polygons expressed as Position[][][] a.k.a. Geom[]\n (uniquePropertyVals[vals[i]] as Feature<Polygon>[]).map(function (f) {\n return f.geometry.coordinates;\n }) as [Geom, ...Geom[]]\n )\n );\n if (mp && mp.properties) {\n mp.properties[propertyName] = vals[i];\n outFeatures.push(mp);\n }\n }\n }\n\n return flatten(featureCollection(outFeatures));\n}\n\nexport { dissolve };\nexport default dissolve;\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 { featureCollection, isObject, multiPolygon } from "@turf/helpers";
|
|
6
3
|
import { collectionOf } from "@turf/invariant";
|
|
@@ -58,7 +55,6 @@ function dissolve(fc, options = {}) {
|
|
|
58
55
|
}
|
|
59
56
|
return flatten(featureCollection(outFeatures));
|
|
60
57
|
}
|
|
61
|
-
__name(dissolve, "dissolve");
|
|
62
58
|
var turf_dissolve_default = dissolve;
|
|
63
59
|
export {
|
|
64
60
|
turf_dissolve_default as default,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, FeatureCollection, Polygon } from \"geojson\";\nimport { featureCollection, isObject, multiPolygon } from \"@turf/helpers\";\nimport { collectionOf } from \"@turf/invariant\";\nimport { featureEach } from \"@turf/meta\";\nimport { flatten } from \"@turf/flatten\";\nimport polygonClipping, { Geom } from \"polygon-clipping\";\n\n/**\n * Dissolves a FeatureCollection of {@link polygon} features, filtered by an optional property name:value.\n * Note that {@link mulitpolygon} features within the collection are not supported\n *\n * @name dissolve\n * @param {FeatureCollection<Polygon>} featureCollection input feature collection to be dissolved\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.propertyName] features with the same `propertyName` value will be dissolved.\n * @returns {FeatureCollection<Polygon>} a FeatureCollection containing the dissolved polygons\n * @example\n * var features = turf.featureCollection([\n * turf.polygon([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]], {combine: 'yes'}),\n * turf.polygon([[[0, -1], [0, 0], [1, 0], [1, -1], [0,-1]]], {combine: 'yes'}),\n * turf.polygon([[[1,-1],[1, 0], [2, 0], [2, -1], [1, -1]]], {combine: 'no'}),\n * ]);\n *\n * var dissolved = turf.dissolve(features, {propertyName: 'combine'});\n *\n * //addToMap\n * var addToMap = [features, dissolved]\n */\nfunction dissolve(\n fc: FeatureCollection<Polygon>,\n options: {\n propertyName?: string;\n } = {}\n): FeatureCollection<Polygon> {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n const { propertyName } = options;\n\n // Input validation\n collectionOf(fc, \"Polygon\", \"dissolve\");\n\n // Main\n const outFeatures = [];\n if (!propertyName) {\n return flatten(\n multiPolygon(\n polygonClipping.union.apply(\n null,\n // List of polygons expressed as Position[][][] a.k.a. Geom[]\n fc.features.map(function (f) {\n return f.geometry.coordinates;\n }) as [Geom, ...Geom[]]\n )\n )\n );\n } else {\n // Group polygons by the value of their property named by propertyName\n const uniquePropertyVals: { [key: string]: Feature[] } = {};\n featureEach(fc, function (feature) {\n if (feature.properties) {\n if (\n !Object.prototype.hasOwnProperty.call(\n uniquePropertyVals,\n feature.properties[propertyName]\n )\n ) {\n uniquePropertyVals[feature.properties[propertyName]] =\n [] as Feature[];\n }\n uniquePropertyVals[feature.properties[propertyName]].push(feature);\n }\n });\n const vals = Object.keys(uniquePropertyVals);\n\n // Export each group of polygons as a separate feature.\n for (let i = 0; i < vals.length; i++) {\n const mp = multiPolygon(\n polygonClipping.union.apply(\n null,\n // List of polygons expressed as Position[][][] a.k.a. Geom[]\n (uniquePropertyVals[vals[i]] as Feature<Polygon>[]).map(function (f) {\n return f.geometry.coordinates;\n }) as [Geom, ...Geom[]]\n )\n );\n if (mp && mp.properties) {\n mp.properties[propertyName] = vals[i];\n outFeatures.push(mp);\n }\n }\n }\n\n return flatten(featureCollection(outFeatures));\n}\n\nexport { dissolve };\nexport default dissolve;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, FeatureCollection, Polygon } from \"geojson\";\nimport { featureCollection, isObject, multiPolygon } from \"@turf/helpers\";\nimport { collectionOf } from \"@turf/invariant\";\nimport { featureEach } from \"@turf/meta\";\nimport { flatten } from \"@turf/flatten\";\nimport polygonClipping, { Geom } from \"polygon-clipping\";\n\n/**\n * Dissolves a FeatureCollection of {@link polygon} features, filtered by an optional property name:value.\n * Note that {@link mulitpolygon} features within the collection are not supported\n *\n * @name dissolve\n * @param {FeatureCollection<Polygon>} featureCollection input feature collection to be dissolved\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.propertyName] features with the same `propertyName` value will be dissolved.\n * @returns {FeatureCollection<Polygon>} a FeatureCollection containing the dissolved polygons\n * @example\n * var features = turf.featureCollection([\n * turf.polygon([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]], {combine: 'yes'}),\n * turf.polygon([[[0, -1], [0, 0], [1, 0], [1, -1], [0,-1]]], {combine: 'yes'}),\n * turf.polygon([[[1,-1],[1, 0], [2, 0], [2, -1], [1, -1]]], {combine: 'no'}),\n * ]);\n *\n * var dissolved = turf.dissolve(features, {propertyName: 'combine'});\n *\n * //addToMap\n * var addToMap = [features, dissolved]\n */\nfunction dissolve(\n fc: FeatureCollection<Polygon>,\n options: {\n propertyName?: string;\n } = {}\n): FeatureCollection<Polygon> {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n const { propertyName } = options;\n\n // Input validation\n collectionOf(fc, \"Polygon\", \"dissolve\");\n\n // Main\n const outFeatures = [];\n if (!propertyName) {\n return flatten(\n multiPolygon(\n polygonClipping.union.apply(\n null,\n // List of polygons expressed as Position[][][] a.k.a. Geom[]\n fc.features.map(function (f) {\n return f.geometry.coordinates;\n }) as [Geom, ...Geom[]]\n )\n )\n );\n } else {\n // Group polygons by the value of their property named by propertyName\n const uniquePropertyVals: { [key: string]: Feature[] } = {};\n featureEach(fc, function (feature) {\n if (feature.properties) {\n if (\n !Object.prototype.hasOwnProperty.call(\n uniquePropertyVals,\n feature.properties[propertyName]\n )\n ) {\n uniquePropertyVals[feature.properties[propertyName]] =\n [] as Feature[];\n }\n uniquePropertyVals[feature.properties[propertyName]].push(feature);\n }\n });\n const vals = Object.keys(uniquePropertyVals);\n\n // Export each group of polygons as a separate feature.\n for (let i = 0; i < vals.length; i++) {\n const mp = multiPolygon(\n polygonClipping.union.apply(\n null,\n // List of polygons expressed as Position[][][] a.k.a. Geom[]\n (uniquePropertyVals[vals[i]] as Feature<Polygon>[]).map(function (f) {\n return f.geometry.coordinates;\n }) as [Geom, ...Geom[]]\n )\n );\n if (mp && mp.properties) {\n mp.properties[propertyName] = vals[i];\n outFeatures.push(mp);\n }\n }\n }\n\n return flatten(featureCollection(outFeatures));\n}\n\nexport { dissolve };\nexport default dissolve;\n"],"mappings":";AACA,SAAS,mBAAmB,UAAU,oBAAoB;AAC1D,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,OAAO,qBAA+B;AAuBtC,SAAS,SACP,IACA,UAEI,CAAC,GACuB;AAE5B,YAAU,WAAW,CAAC;AACtB,MAAI,CAAC,SAAS,OAAO;AAAG,UAAM,IAAI,MAAM,oBAAoB;AAC5D,QAAM,EAAE,aAAa,IAAI;AAGzB,eAAa,IAAI,WAAW,UAAU;AAGtC,QAAM,cAAc,CAAC;AACrB,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,MACL;AAAA,QACE,gBAAgB,MAAM;AAAA,UACpB;AAAA;AAAA,UAEA,GAAG,SAAS,IAAI,SAAU,GAAG;AAC3B,mBAAO,EAAE,SAAS;AAAA,UACpB,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF,OAAO;AAEL,UAAM,qBAAmD,CAAC;AAC1D,gBAAY,IAAI,SAAU,SAAS;AACjC,UAAI,QAAQ,YAAY;AACtB,YACE,CAAC,OAAO,UAAU,eAAe;AAAA,UAC/B;AAAA,UACA,QAAQ,WAAW,YAAY;AAAA,QACjC,GACA;AACA,6BAAmB,QAAQ,WAAW,YAAY,CAAC,IACjD,CAAC;AAAA,QACL;AACA,2BAAmB,QAAQ,WAAW,YAAY,CAAC,EAAE,KAAK,OAAO;AAAA,MACnE;AAAA,IACF,CAAC;AACD,UAAM,OAAO,OAAO,KAAK,kBAAkB;AAG3C,aAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,YAAM,KAAK;AAAA,QACT,gBAAgB,MAAM;AAAA,UACpB;AAAA;AAAA,UAEC,mBAAmB,KAAK,CAAC,CAAC,EAAyB,IAAI,SAAU,GAAG;AACnE,mBAAO,EAAE,SAAS;AAAA,UACpB,CAAC;AAAA,QACH;AAAA,MACF;AACA,UAAI,MAAM,GAAG,YAAY;AACvB,WAAG,WAAW,YAAY,IAAI,KAAK,CAAC;AACpC,oBAAY,KAAK,EAAE;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAEA,SAAO,QAAQ,kBAAkB,WAAW,CAAC;AAC/C;AAGA,IAAO,wBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/dissolve",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.1.0-alpha.7+0ce6ecca0",
|
|
4
4
|
"description": "turf dissolve module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"write-json-file": "^5.0.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@turf/flatten": "^7.0.
|
|
68
|
-
"@turf/helpers": "^7.0.
|
|
69
|
-
"@turf/invariant": "^7.0.
|
|
70
|
-
"@turf/meta": "^7.0.
|
|
67
|
+
"@turf/flatten": "^7.1.0-alpha.7+0ce6ecca0",
|
|
68
|
+
"@turf/helpers": "^7.1.0-alpha.7+0ce6ecca0",
|
|
69
|
+
"@turf/invariant": "^7.1.0-alpha.7+0ce6ecca0",
|
|
70
|
+
"@turf/meta": "^7.1.0-alpha.7+0ce6ecca0",
|
|
71
71
|
"polygon-clipping": "^0.15.3",
|
|
72
72
|
"tslib": "^2.6.2"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "0ce6ecca05829690270fec6d6bed2003495fe0ea"
|
|
75
75
|
}
|