geojson-random
Advanced tools
Comparing version 0.2.2 to 0.3.0
@@ -1,3 +0,7 @@ | ||
# 1.0.1 | ||
# 0.3.0 | ||
* Add pointStream method | ||
# 0.2.2 | ||
* Fix `coordInBBBOX` function to fix the output of points within small bounding | ||
@@ -4,0 +8,0 @@ boxes. |
14
index.js
@@ -0,1 +1,3 @@ | ||
var from = require('from2'); | ||
module.exports = function() { | ||
@@ -14,3 +16,3 @@ throw new Error('call .point() or .polygon() instead'); | ||
var features = []; | ||
for (i = 0; i < count; i++) { | ||
for (var i = 0; i < count; i++) { | ||
features.push(feature(bbox ? point(position(bbox)) : point())); | ||
@@ -21,2 +23,12 @@ } | ||
module.exports.pointStream = function(count, bbox) { | ||
return from.obj(function(size, next) { | ||
if (--count) { | ||
next(null, feature(bbox ? point(position(bbox)) : point())); | ||
} else { | ||
next(null, null); | ||
} | ||
}); | ||
}; | ||
module.exports.polygon = function(count, num_vertices, max_radial_length, bbox) { | ||
@@ -23,0 +35,0 @@ if (typeof num_vertices !== 'number') num_vertices = 10; |
{ | ||
"name": "geojson-random", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "generate random geojson features", | ||
@@ -28,3 +28,7 @@ "main": "index.js", | ||
"tape": "~2.13.4" | ||
}, | ||
"dependencies": { | ||
"from2": "^2.1.0", | ||
"geojson-stream": "0.0.0" | ||
} | ||
} |
@@ -12,2 +12,5 @@ # geojson-random | ||
# special fast-mode for points | ||
geojson-random 10000 point-stream | ||
## api | ||
@@ -36,3 +39,3 @@ | ||
### `random.polygon(count, num_vertices, max_radial_length)` | ||
### `random.polygon(count, num_vertices, max_radial_length, bbox)` | ||
@@ -46,1 +49,2 @@ Return `count` polygons wrapped in a FeatureCollection. | ||
Default is `10`. | ||
* `bbox` (Optional) Bounding box in [minX, minY, maxX, maxY] order. |
Sorry, the diff of this file is not supported yet
8512
8
149
48
2
+ Addedfrom2@^2.1.0
+ Addedgeojson-stream@0.0.0
+ AddedJSONStream@0.7.4(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedfrom2@2.3.0(transitive)
+ Addedgeojson-stream@0.0.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedjsonparse@0.0.5(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedutil-deprecate@1.0.2(transitive)