Socket
Socket
Sign inDemoInstall

geojson-flatten

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojson-flatten - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

CHANGELOG.md

80

index.js

@@ -1,40 +0,42 @@

function flatten(gj) {
switch ((gj && gj.type) || null) {
case 'FeatureCollection':
gj.features = gj.features.reduce(function(mem, feature) {
return mem.concat(flatten(feature));
}, []);
return gj;
case 'Feature':
if (!gj.geometry) return gj;
return flatten(gj.geometry).map(function(geom) {
return {
type: 'Feature',
properties: JSON.parse(JSON.stringify(gj.properties)),
geometry: geom
};
});
case 'MultiPoint':
return gj.coordinates.map(function(_) {
return { type: 'Point', coordinates: _ };
});
case 'MultiPolygon':
return gj.coordinates.map(function(_) {
return { type: 'Polygon', coordinates: _ };
});
case 'MultiLineString':
return gj.coordinates.map(function(_) {
return { type: 'LineString', coordinates: _ };
});
case 'GeometryCollection':
return gj.geometries.map(flatten).reduce(function(memo, geoms) {
return memo.concat(geoms);
}, []);
case 'Point':
case 'Polygon':
case 'LineString':
return [gj];
}
export default function flatten(gj) {
switch ((gj && gj.type) || null) {
case "FeatureCollection":
gj.features = gj.features.reduce(function(mem, feature) {
return mem.concat(flatten(feature));
}, []);
return gj;
case "Feature":
if (!gj.geometry) return gj;
return flatten(gj.geometry).map(function(geom) {
var data = {
type: "Feature",
properties: JSON.parse(JSON.stringify(gj.properties)),
geometry: geom
};
if (gj.id !== undefined) {
data.id = gj.id;
}
return data;
});
case "MultiPoint":
return gj.coordinates.map(function(_) {
return { type: "Point", coordinates: _ };
});
case "MultiPolygon":
return gj.coordinates.map(function(_) {
return { type: "Polygon", coordinates: _ };
});
case "MultiLineString":
return gj.coordinates.map(function(_) {
return { type: "LineString", coordinates: _ };
});
case "GeometryCollection":
return gj.geometries.map(flatten).reduce(function(memo, geoms) {
return memo.concat(geoms);
}, []);
case "Point":
case "Polygon":
case "LineString":
return [gj];
}
}
module.exports = flatten;
{
"name": "geojson-flatten",
"version": "0.2.2",
"version": "0.2.3",
"description": "transform geojson into single-parts",
"main": "index.js",
"source": "index.js",
"main": "dist/index.js",
"umd:main": "dist/index.umd.js",
"unpkg": "dist/index.umd.js",
"module": "dist/index.es.js",
"files": [
"index.js",
"dist",
"geojson-flatten"

@@ -18,7 +23,10 @@ ],

"test": "eslint index.js && tap --coverage test/flatten.js",
"make": "browserify -s geojsonFlatten index.js > geojson-flatten.js"
"pretest": "microbundle --name geojsonFlatten",
"prepare": "microbundle --name geojsonFlatten",
"make": "browserify -s geojsonFlatten index.js > geojson-flatten.js",
"release": "standard-version"
},
"repository": {
"type": "git",
"url": "git://github.com/mapbox/geojson-flatten.git"
"url": "git://github.com/node-geojson/geojson-flatten.git"
},

@@ -33,15 +41,15 @@ "keywords": [

"bugs": {
"url": "https://github.com/mapbox/geojson-flatten/issues"
"url": "https://github.com/node-geojson/geojson-flatten/issues"
},
"homepage": "https://github.com/mapbox/geojson-flatten",
"homepage": "https://github.com/node-geojson/geojson-flatten",
"dependencies": {
"concat-stream": "~1.6.0",
"get-stdin": "^6.0.0",
"minimist": "1.2.0"
},
"devDependencies": {
"tap": "^10.3.2",
"browserify": "^14.3.0",
"eslint": "~1.00.0",
"eslint-config-unstyled": "^1.1.0"
"eslint": "^5.12.1",
"microbundle": "^0.9.0",
"standard-version": "^4.4.0",
"tap": "^12.4.0"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc