Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.1.0 to 0.2.0

.nyc_output/29336.json

13

index.js

@@ -1,4 +0,2 @@

module.exports = flatten;
function flatten(gj, up) {
function flatten(gj) {
switch ((gj && gj.type) || null) {

@@ -11,2 +9,3 @@ case 'FeatureCollection':

case 'Feature':
if (!gj.geometry) return gj;
return flatten(gj.geometry).map(function(geom) {

@@ -32,3 +31,5 @@ return {

case 'GeometryCollection':
return gj.geometries;
return gj.geometries.map(flatten).reduce(function(memo, geoms) {
return memo.concat(geoms);
}, []);
case 'Point':

@@ -38,5 +39,5 @@ case 'Polygon':

return [gj];
default:
return gj;
}
}
module.exports = flatten;
{
"name": "geojson-flatten",
"version": "0.1.0",
"version": "0.2.0",
"description": "transform geojson into single-parts",

@@ -13,3 +13,3 @@ "main": "index.js",

"scripts": {
"test": "node test/flatten.js",
"test": "tap --coverage test/flatten.js",
"make": "browserify -s geojsonFlatten index.js > geojson-flatten.js"

@@ -33,10 +33,10 @@ },

"dependencies": {
"concat-stream": "~1.2.1",
"minimist": "0.0.5",
"concat-stream": "~1.2.1",
"sharkdown": "~0.1.0"
},
"devDependencies": {
"tap": "~0.4.6",
"browserify": "~3.18.0"
"tap": "^2.3.1",
"browserify": "^12.0.1"
}
}
# geojson-flatten
[![build status](https://secure.travis-ci.org/mapbox/geojson-flatten.svg)](http://travis-ci.org/mapbox/geojson-flatten)
Flatten MultiPoint, MultiPolygon, MultiLineString, and GeometryCollection

@@ -4,0 +6,0 @@ geometries in [GeoJSON](http://geojson.org/) files into simple non-complex

@@ -5,14 +5,22 @@ var flatten = require('../'),

function f(_) {
return JSON.parse(fs.readFileSync(_, 'utf8'));
}
test('flatten', function(t) {
t.deepEqual(flatten(f('./test/multigeometry.input.geojson')), f('./test/multigeometry.output.geojson'),
'expands geometrycollection');
t.deepEqual(flatten(f('./test/point.input.geojson')), f('./test/point.input.geojson'),
'does not touch point');
t.deepEqual(flatten(f('./test/linestring.geojson')), f('./test/linestring.geojson'),
'does not touch line');
t.end();
test('flatten', function(group) {
fs.readdirSync(__dirname + '/fixture')
.filter(function(fix) { return fix.match(/input/); })
.forEach(function(fixture) {
group.test(fixture, function(t) {
var result = flatten(
JSON.parse(
fs.readFileSync(__dirname + '/fixture/' + fixture)));
if (process.env.UPDATE) {
fs.writeFileSync(__dirname + '/fixture/' + fixture.replace('input', 'output'),
JSON.stringify(result, null, 2));
}
t.deepEqual(result,
JSON.parse(
fs.readFileSync(
__dirname + '/fixture/' + fixture.replace('input', 'output'))));
t.end();
});
});
group.end();
});
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