@turf/combine
Advanced tools
Comparing version 4.7.3 to 5.0.4
@@ -1,22 +0,20 @@ | ||
/// <reference types="geojson" /> | ||
import { | ||
Point, | ||
LineString, | ||
Polygon, | ||
MultiPoint, | ||
MultiLineString, | ||
MultiPolygon, | ||
Feature, | ||
FeatureCollection | ||
} from '@turf/helpers' | ||
type Points = GeoJSON.FeatureCollection<GeoJSON.Point>; | ||
type LineStrings = GeoJSON.FeatureCollection<GeoJSON.LineString>; | ||
type Polygons = GeoJSON.FeatureCollection<GeoJSON.Polygon>; | ||
type MultiPoints = GeoJSON.FeatureCollection<GeoJSON.MultiPoint>; | ||
type MultiLineStrings = GeoJSON.FeatureCollection<GeoJSON.MultiLineString>; | ||
type MultiPolygons = GeoJSON.FeatureCollection<GeoJSON.MultiPolygon>; | ||
type Features = GeoJSON.FeatureCollection<any>; | ||
/** | ||
* http://turfjs.org/docs/#combine | ||
*/ | ||
declare function combine(features: FeatureCollection<Point>): MultiPoint; | ||
declare function combine(features: FeatureCollection<LineString>): MultiLineString; | ||
declare function combine(features: FeatureCollection<Polygon>): MultiPolygon; | ||
declare function combine(features: FeatureCollection<any>): Feature<any>; | ||
interface CombineStatic { | ||
/** | ||
* http://turfjs.org/docs/#combine | ||
*/ | ||
(features: Points): MultiPoints; | ||
(features: LineStrings): MultiLineStrings; | ||
(features: Polygons): MultiPolygons; | ||
(features: Features): Features; | ||
} | ||
declare const combine: CombineStatic; | ||
declare namespace combine { } | ||
export = combine; | ||
export default combine; |
41
index.js
@@ -1,2 +0,3 @@ | ||
var meta = require('@turf/meta'); | ||
import { feature, featureCollection } from '@turf/helpers'; | ||
import { featureEach } from '@turf/meta'; | ||
@@ -21,3 +22,3 @@ /** | ||
*/ | ||
module.exports = function (fc) { | ||
function combine(fc) { | ||
var groups = { | ||
@@ -43,3 +44,3 @@ MultiPoint: {coordinates: [], properties: []}, | ||
meta.featureEach(fc, function (feature) { | ||
featureEach(fc, function (feature) { | ||
if (!feature.geometry) return; | ||
@@ -53,22 +54,14 @@ if (groups[feature.geometry.type]) { | ||
return { | ||
type: 'FeatureCollection', | ||
features: Object.keys(groups) | ||
.filter(function (key) { | ||
return groups[key].coordinates.length; | ||
}) | ||
.sort() | ||
.map(function (key) { | ||
return { | ||
type: 'Feature', | ||
properties: { | ||
collectedProperties: groups[key].properties | ||
}, | ||
geometry: { | ||
type: key, | ||
coordinates: groups[key].coordinates | ||
} | ||
}; | ||
}) | ||
}; | ||
}; | ||
return featureCollection(Object.keys(groups) | ||
.filter(function (key) { | ||
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); | ||
})); | ||
} | ||
export default combine; |
{ | ||
"name": "@turf/combine", | ||
"version": "4.7.3", | ||
"version": "5.0.4", | ||
"description": "turf combine module", | ||
"main": "index.js", | ||
"main": "main", | ||
"module": "index", | ||
"jsnext:main": "index", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
"index.d.ts", | ||
"main.js" | ||
], | ||
"scripts": { | ||
"test": "node test.js", | ||
"bench": "node bench.js" | ||
"pretest": "rollup -c ../../rollup.config.js", | ||
"test": "node -r @std/esm test.js", | ||
"bench": "node -r @std/esm bench.js" | ||
}, | ||
@@ -33,9 +37,15 @@ "repository": { | ||
"devDependencies": { | ||
"@turf/helpers": "^4.7.3", | ||
"benchmark": "^2.1.4", | ||
"tape": "^4.6.3" | ||
"@std/esm": "*", | ||
"benchmark": "*", | ||
"rollup": "*", | ||
"tape": "*" | ||
}, | ||
"dependencies": { | ||
"@turf/meta": "^4.7.3" | ||
"@turf/helpers": "^5.0.4", | ||
"@turf/meta": "^5.0.4" | ||
}, | ||
"@std/esm": { | ||
"esm": "js", | ||
"cjs": true | ||
} | ||
} |
# @turf/combine | ||
# combine | ||
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
## combine | ||
Combines a [FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects) of [Point](http://geojson.org/geojson-spec.html#point), [LineString](http://geojson.org/geojson-spec.html#linestring), or [Polygon](http://geojson.org/geojson-spec.html#polygon) features | ||
@@ -6,0 +8,0 @@ into [MultiPoint](http://geojson.org/geojson-spec.html#multipoint), [MultiLineString](http://geojson.org/geojson-spec.html#multilinestring), or [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon) features. |
9367
6
136
54
2
4
+ Added@turf/helpers@^5.0.4
+ Added@turf/helpers@5.1.5(transitive)
+ Added@turf/meta@5.2.0(transitive)
- Removed@turf/meta@4.7.4(transitive)
Updated@turf/meta@^5.0.4