@turf/combine
Advanced tools
+42
-24
@@ -1,2 +0,2 @@ | ||
| import { feature, featureCollection } from "@turf/helpers"; | ||
| import { feature, featureCollection, } from "@turf/helpers"; | ||
| import { featureEach } from "@turf/meta"; | ||
@@ -23,28 +23,46 @@ /** | ||
| var groups = { | ||
| MultiPoint: { coordinates: [], properties: [] }, | ||
| MultiLineString: { coordinates: [], properties: [] }, | ||
| MultiPolygon: { coordinates: [], properties: [] }, | ||
| MultiPoint: { | ||
| coordinates: [], | ||
| properties: [], | ||
| }, | ||
| MultiLineString: { | ||
| coordinates: [], | ||
| properties: [], | ||
| }, | ||
| MultiPolygon: { | ||
| coordinates: [], | ||
| properties: [], | ||
| }, | ||
| }; | ||
| var multiMapping = Object.keys(groups).reduce(function (memo, item) { | ||
| memo[item.replace("Multi", "")] = item; | ||
| return memo; | ||
| }, {}); | ||
| function addToGroup(feature, key, multi) { | ||
| if (!multi) { | ||
| groups[key].coordinates.push(feature.geometry.coordinates); | ||
| } | ||
| else { | ||
| groups[key].coordinates = groups[key].coordinates.concat(feature.geometry.coordinates); | ||
| } | ||
| groups[key].properties.push(feature.properties); | ||
| } | ||
| featureEach(fc, function (feature) { | ||
| if (!feature.geometry) | ||
| return; | ||
| if (groups[feature.geometry.type]) { | ||
| addToGroup(feature, feature.geometry.type, true); | ||
| var _a, _b, _c; | ||
| var _d; | ||
| switch ((_d = feature.geometry) === null || _d === void 0 ? void 0 : _d.type) { | ||
| case "Point": | ||
| groups.MultiPoint.coordinates.push(feature.geometry.coordinates); | ||
| groups.MultiPoint.properties.push(feature.properties); | ||
| break; | ||
| case "MultiPoint": | ||
| (_a = groups.MultiPoint.coordinates).push.apply(_a, feature.geometry.coordinates); | ||
| groups.MultiPoint.properties.push(feature.properties); | ||
| break; | ||
| case "LineString": | ||
| groups.MultiLineString.coordinates.push(feature.geometry.coordinates); | ||
| groups.MultiLineString.properties.push(feature.properties); | ||
| break; | ||
| case "MultiLineString": | ||
| (_b = groups.MultiLineString.coordinates).push.apply(_b, feature.geometry.coordinates); | ||
| groups.MultiLineString.properties.push(feature.properties); | ||
| break; | ||
| case "Polygon": | ||
| groups.MultiPolygon.coordinates.push(feature.geometry.coordinates); | ||
| groups.MultiPolygon.properties.push(feature.properties); | ||
| break; | ||
| case "MultiPolygon": | ||
| (_c = groups.MultiPolygon.coordinates).push.apply(_c, feature.geometry.coordinates); | ||
| groups.MultiPolygon.properties.push(feature.properties); | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| else if (multiMapping[feature.geometry.type]) { | ||
| addToGroup(feature, multiMapping[feature.geometry.type], false); | ||
| } | ||
| }); | ||
@@ -51,0 +69,0 @@ return featureCollection(Object.keys(groups) |
@@ -0,1 +1,2 @@ | ||
| import { MultiLineString, MultiPoint, MultiPolygon } from "@turf/helpers"; | ||
| import { Point, LineString, Polygon, FeatureCollection } from "@turf/helpers"; | ||
@@ -20,8 +21,10 @@ /** | ||
| */ | ||
| declare function combine(fc: FeatureCollection<Point | LineString | Polygon>): FeatureCollection<{ | ||
| type: string; | ||
| coordinates: any; | ||
| declare function combine(fc: FeatureCollection<Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon>): FeatureCollection<{ | ||
| type: "MultiPoint" | "MultiLineString" | "MultiPolygon"; | ||
| coordinates: number[][] | number[][][] | number[][][][]; | ||
| }, { | ||
| collectedProperties: any; | ||
| collectedProperties: { | ||
| [name: string]: any; | ||
| }[]; | ||
| }>; | ||
| export default combine; |
+41
-23
@@ -25,28 +25,46 @@ "use strict"; | ||
| var groups = { | ||
| MultiPoint: { coordinates: [], properties: [] }, | ||
| MultiLineString: { coordinates: [], properties: [] }, | ||
| MultiPolygon: { coordinates: [], properties: [] }, | ||
| MultiPoint: { | ||
| coordinates: [], | ||
| properties: [], | ||
| }, | ||
| MultiLineString: { | ||
| coordinates: [], | ||
| properties: [], | ||
| }, | ||
| MultiPolygon: { | ||
| coordinates: [], | ||
| properties: [], | ||
| }, | ||
| }; | ||
| var multiMapping = Object.keys(groups).reduce(function (memo, item) { | ||
| memo[item.replace("Multi", "")] = item; | ||
| return memo; | ||
| }, {}); | ||
| function addToGroup(feature, key, multi) { | ||
| if (!multi) { | ||
| groups[key].coordinates.push(feature.geometry.coordinates); | ||
| } | ||
| else { | ||
| groups[key].coordinates = groups[key].coordinates.concat(feature.geometry.coordinates); | ||
| } | ||
| groups[key].properties.push(feature.properties); | ||
| } | ||
| meta_1.featureEach(fc, function (feature) { | ||
| if (!feature.geometry) | ||
| return; | ||
| if (groups[feature.geometry.type]) { | ||
| addToGroup(feature, feature.geometry.type, true); | ||
| var _a, _b, _c; | ||
| var _d; | ||
| switch ((_d = feature.geometry) === null || _d === void 0 ? void 0 : _d.type) { | ||
| case "Point": | ||
| groups.MultiPoint.coordinates.push(feature.geometry.coordinates); | ||
| groups.MultiPoint.properties.push(feature.properties); | ||
| break; | ||
| case "MultiPoint": | ||
| (_a = groups.MultiPoint.coordinates).push.apply(_a, feature.geometry.coordinates); | ||
| groups.MultiPoint.properties.push(feature.properties); | ||
| break; | ||
| case "LineString": | ||
| groups.MultiLineString.coordinates.push(feature.geometry.coordinates); | ||
| groups.MultiLineString.properties.push(feature.properties); | ||
| break; | ||
| case "MultiLineString": | ||
| (_b = groups.MultiLineString.coordinates).push.apply(_b, feature.geometry.coordinates); | ||
| groups.MultiLineString.properties.push(feature.properties); | ||
| break; | ||
| case "Polygon": | ||
| groups.MultiPolygon.coordinates.push(feature.geometry.coordinates); | ||
| groups.MultiPolygon.properties.push(feature.properties); | ||
| break; | ||
| case "MultiPolygon": | ||
| (_c = groups.MultiPolygon.coordinates).push.apply(_c, feature.geometry.coordinates); | ||
| groups.MultiPolygon.properties.push(feature.properties); | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| else if (multiMapping[feature.geometry.type]) { | ||
| addToGroup(feature, multiMapping[feature.geometry.type], false); | ||
| } | ||
| }); | ||
@@ -53,0 +71,0 @@ return helpers_1.featureCollection(Object.keys(groups) |
+4
-4
| { | ||
| "name": "@turf/combine", | ||
| "version": "6.3.0", | ||
| "version": "6.4.0", | ||
| "description": "turf combine module", | ||
@@ -58,6 +58,6 @@ "author": "Turf Authors", | ||
| "dependencies": { | ||
| "@turf/helpers": "^6.3.0", | ||
| "@turf/meta": "^6.3.0" | ||
| "@turf/helpers": "^6.4.0", | ||
| "@turf/meta": "^6.4.0" | ||
| }, | ||
| "gitHead": "57c8877e1e2d67effc2cdd23385c02b2a6615a49" | ||
| "gitHead": "1e62773cfc88c627cca8effcb5c14cfb65a905ac" | ||
| } |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
12165
17.72%189
26%1
Infinity%Updated
Updated