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

geojson-extent

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojson-extent - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

10

index.js
var geojsonCoords = require('geojson-coords'),
traverse = require('traverse'),
extent = require('extent');

@@ -12,2 +13,11 @@

module.exports.bboxify = function(_) {
return traverse(_).map(function(value) {
if (value && typeof value.type === 'string') {
value.bbox = getExtent(value).bbox();
this.update(value);
}
});
};
function getExtent(_) {

@@ -14,0 +24,0 @@ var bbox = [Infinity, Infinity, -Infinity, -Infinity],

5

package.json
{
"name": "geojson-extent",
"version": "0.2.0",
"version": "0.3.0",
"description": "compute the bounding box of geojson features",

@@ -34,3 +34,4 @@ "main": "index.js",

"geojson-coords": "0.0.0",
"rw": "~0.1.4"
"rw": "~0.1.4",
"traverse": "~0.6.6"
},

@@ -37,0 +38,0 @@ "devDependencies": {

@@ -48,1 +48,6 @@ ![](http://img.shields.io/travis/mapbox/geojson-extent.svg?style=flat)

Invalid objects will return `null`.
### `extent.bboxify(geojson)`
Add [bounding boxes](http://geojson.org/geojson-spec.html#bounding-boxes) to all
appropriate GeoJSON objects - Feature, FeatureCollection, and Geometry.

@@ -14,2 +14,171 @@ var test = require('tap').test,

test('bboxify', function(t) {
t.deepEqual(geojsonExtent.bboxify({
type: 'Point',
coordinates: [0, 0]
}), {
type: 'Point',
coordinates: [0, 0],
bbox: [0, 0, 0, 0]
}, 'a single point');
t.deepEqual(geojsonExtent.bboxify({ "type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
"properties": {"prop0": "value0"}
},
{ "type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
]
},
"properties": {
"prop0": "value0",
"prop1": 0.0
}
},
{ "type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
[100.0, 1.0], [100.0, 0.0] ]
]
},
"properties": {
"prop0": "value0",
"prop1": {"this": "that"}
}
}
]
}), {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"prop0": "value0"
},
"geometry": {
"type": "Point",
"coordinates": [
102,
0.5
],
"bbox": [
102,
0.5,
102,
0.5
]
},
"bbox": [
102,
0.5,
102,
0.5
]
},
{
"type": "Feature",
"properties": {
"prop0": "value0",
"prop1": 0
},
"geometry": {
"type": "LineString",
"coordinates": [
[
102,
0
],
[
103,
1
],
[
104,
0
],
[
105,
1
]
],
"bbox": [
102,
0,
105,
1
]
},
"bbox": [
102,
0,
105,
1
]
},
{
"type": "Feature",
"properties": {
"prop0": "value0",
"prop1": {
"this": "that"
}
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
100,
0
],
[
101,
0
],
[
101,
1
],
[
100,
1
],
[
100,
0
]
]
],
"bbox": [
100,
0,
101,
1
]
},
"bbox": [
100,
0,
101,
1
]
}
],
"bbox": [
100,
0,
105,
1
]
}, 'a single point');
t.end();
});
test('extent', function(t) {

@@ -16,0 +185,0 @@ t.deepEqual(geojsonExtent({

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