@turf/combine
Advanced tools
Comparing version 5.1.5 to 6.0.0
45
index.js
@@ -1,4 +0,5 @@ | ||
import { feature, featureCollection } from '@turf/helpers'; | ||
import { featureEach } from '@turf/meta'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var helpers_1 = require("@turf/helpers"); | ||
var meta_1 = require("@turf/meta"); | ||
/** | ||
@@ -24,7 +25,6 @@ * Combines a {@link FeatureCollection} of {@link Point}, {@link LineString}, or {@link Polygon} features | ||
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) { | ||
@@ -34,7 +34,7 @@ memo[item.replace('Multi', '')] = item; | ||
}, {}); | ||
function addToGroup(feature, key, multi) { | ||
if (!multi) { | ||
groups[key].coordinates.push(feature.geometry.coordinates); | ||
} else { | ||
} | ||
else { | ||
groups[key].coordinates = groups[key].coordinates.concat(feature.geometry.coordinates); | ||
@@ -44,24 +44,23 @@ } | ||
} | ||
featureEach(fc, function (feature) { | ||
if (!feature.geometry) return; | ||
meta_1.featureEach(fc, function (feature) { | ||
if (!feature.geometry) | ||
return; | ||
if (groups[feature.geometry.type]) { | ||
addToGroup(feature, feature.geometry.type, true); | ||
} else if (multiMapping[feature.geometry.type]) { | ||
} | ||
else if (multiMapping[feature.geometry.type]) { | ||
addToGroup(feature, multiMapping[feature.geometry.type], false); | ||
} | ||
}); | ||
return featureCollection(Object.keys(groups) | ||
return helpers_1.featureCollection(Object.keys(groups) | ||
.filter(function (key) { | ||
return groups[key].coordinates.length; | ||
}) | ||
return groups[key].coordinates.length; | ||
}) | ||
.sort() | ||
.map(function (key) { | ||
var geometry = { type: key, coordinates: groups[key].coordinates }; | ||
var properties = { collectedProperties: groups[key].properties }; | ||
return feature(geometry, properties); | ||
})); | ||
var geometry = { type: key, coordinates: groups[key].coordinates }; | ||
var properties = { collectedProperties: groups[key].properties }; | ||
return helpers_1.feature(geometry, properties); | ||
})); | ||
} | ||
export default combine; | ||
exports.default = combine; |
{ | ||
"name": "@turf/combine", | ||
"version": "5.1.5", | ||
"version": "6.0.0", | ||
"description": "turf combine module", | ||
"main": "main.js", | ||
"module": "main.es.js", | ||
"types": "index.d.ts", | ||
"main": "index", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts", | ||
"main.js", | ||
"main.es.js" | ||
"index.ts" | ||
], | ||
"scripts": { | ||
"pretest": "rollup -c ../../rollup.config.js", | ||
"test": "node -r @std/esm test.js", | ||
"posttest": "node -r @std/esm ../../scripts/validate-es5-dependencies.js", | ||
"bench": "node -r @std/esm bench.js", | ||
"prepare": "tsc", | ||
"pretest": "tsc", | ||
"test": "node test.js", | ||
"bench": "node bench.js", | ||
"docs": "node ../../scripts/generate-readmes" | ||
@@ -45,4 +41,4 @@ }, | ||
"dependencies": { | ||
"@turf/helpers": "^5.1.5", | ||
"@turf/meta": "^5.1.5" | ||
"@turf/helpers": "6.x", | ||
"@turf/meta": "6.x" | ||
}, | ||
@@ -49,0 +45,0 @@ "@std/esm": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8912
5
122
1
+ Added@turf/helpers@6.5.0(transitive)
+ Added@turf/meta@6.5.0(transitive)
- Removed@turf/helpers@5.1.5(transitive)
- Removed@turf/meta@5.2.0(transitive)
Updated@turf/helpers@6.x
Updated@turf/meta@6.x