tile-cover
Advanced tools
Comparing version 2.4.0 to 2.4.1
40
index.js
var tilebelt = require('tilebelt'); | ||
/** | ||
* Given a geometry, create cells and return them in a format easily readable | ||
* by any software that reads GeoJSON. | ||
* | ||
* @alias geojson | ||
* @param {Object} geom GeoJSON geometry | ||
* @param {Object} limits an object with min_zoom and max_zoom properties | ||
* specifying the minimum and maximum level to be tiled. | ||
* @returns {Object} FeatureCollection of cells formatted as GeoJSON Features | ||
*/ | ||
module.exports.geojson = function (geom, limits) { | ||
@@ -10,3 +20,3 @@ var locked = getLocked(geom, limits); | ||
properties: {} | ||
} | ||
}; | ||
}); | ||
@@ -19,2 +29,12 @@ return { | ||
/** | ||
* Given a geometry, create cells and return them in their raw form, | ||
* as an array of cell identifiers. | ||
* | ||
* @alias tiles | ||
* @param {Object} geom GeoJSON geometry | ||
* @param {Object} limits an object with min_zoom and max_zoom properties | ||
* specifying the minimum and maximum level to be tiled. | ||
* @returns {Array<Array<number>>} An array of tiles given as [x, y, z] arrays | ||
*/ | ||
module.exports.tiles = function (geom, limits) { | ||
@@ -25,2 +45,13 @@ var locked = getLocked(geom, limits); | ||
/** | ||
* Given a geometry, create cells and return them as | ||
* [quadkey](http://msdn.microsoft.com/en-us/library/bb259689.aspx) indexes. | ||
* | ||
* @alias indexes | ||
* @param {Object} geom GeoJSON geometry | ||
* @param {Object} limits an object with min_zoom and max_zoom properties | ||
* specifying the minimum and maximum level to be tiled. | ||
* @returns {Array<String>} An array of tiles given as quadkeys. | ||
*/ | ||
module.exports.indexes = function (geom, limits) { | ||
@@ -35,2 +66,3 @@ var locked = getLocked(geom, limits); | ||
var locked, | ||
i, | ||
tileHash = {}; | ||
@@ -43,3 +75,3 @@ | ||
locked = []; | ||
for(var i = 0; i < geom.coordinates.length; i++) { | ||
for(i = 0; i < geom.coordinates.length; i++) { | ||
var tile = tilebelt.pointToTile(geom.coordinates[i][0], geom.coordinates[i][1], limits.max_zoom); | ||
@@ -56,3 +88,3 @@ var quadkey = tilebelt.tileToQuadkey(tile); | ||
} else if (geom.type === 'MultiLineString') { | ||
for(var i = 0; i < geom.coordinates.length; i++) { | ||
for(i = 0; i < geom.coordinates.length; i++) { | ||
lineCover(tileHash, geom.coordinates[i], limits.max_zoom); | ||
@@ -64,3 +96,3 @@ } | ||
} else if (geom.type === 'MultiPolygon') { | ||
for(var i = 0; i < geom.coordinates.length; i++) { | ||
for(i = 0; i < geom.coordinates.length; i++) { | ||
polyRingCover(tileHash, geom.coordinates[i], limits.max_zoom); | ||
@@ -67,0 +99,0 @@ } |
{ | ||
"name": "tile-cover", | ||
"version": "2.4.0", | ||
"version": "2.4.1", | ||
"description": "generate the minimum number of tiles to cover a geojson geometry", | ||
@@ -10,3 +10,4 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "tape test/*.js" | ||
"test": "tape test/*.js", | ||
"doc": "dox < index.js | doxme" | ||
}, | ||
@@ -31,10 +32,13 @@ "repository": { | ||
"benchmark": "^1.0.0", | ||
"tape": "^3.0.3", | ||
"turf-erase": "^1.2.0", | ||
"turf-intersect": "1.3.0", | ||
"turf-merge": "0.0.2" | ||
"dox": "^0.6.1", | ||
"doxme": "^1.8.2", | ||
"tape": "^3.5.0", | ||
"turf-area": "^1.1.1", | ||
"turf-erase": "^1.3.2", | ||
"turf-intersect": "1.4.2", | ||
"turf-merge": "1.0.2" | ||
}, | ||
"dependencies": { | ||
"tilebelt": "^0.7.0" | ||
"tilebelt": "^0.7.1" | ||
} | ||
} |
@@ -8,3 +8,3 @@ tile-cover | ||
###Install | ||
### Install | ||
@@ -15,3 +15,3 @@ ```bash | ||
###Usage | ||
### Usage | ||
@@ -30,4 +30,31 @@ ```js | ||
###Tests | ||
# API | ||
## geojson(geom, limits) | ||
Given a geometry, create cells and return them in a format easily readable by any software that reads GeoJSON. | ||
* `geom` (`Object`): GeoJSON geometry | ||
* `limits` (`Object`): an object with min_zoom and max_zoom properties specifying the minimum and maximum level to be tiled. | ||
**Returns** `Object`, FeatureCollection of cells formatted as GeoJSON Features | ||
## tiles(geom, limits) | ||
Given a geometry, create cells and return them in their raw form, as an array of cell identifiers. | ||
* `geom` (`Object`): GeoJSON geometry | ||
* `limits` (`Object`): an object with min_zoom and max_zoom properties specifying the minimum and maximum level to be tiled. | ||
**Returns** `Array.<Array.<number>>`, An array of tiles given as [x, y, z] arrays | ||
## indexes(geom, limits) | ||
Given a geometry, create cells and return them as quadkey indexes. | ||
* `geom` (`Object`): GeoJSON geometry | ||
* `limits` (`Object`): an object with min_zoom and max_zoom properties specifying the minimum and maximum level to be tiled. | ||
**Returns** `Array.<String>`, An array of tiles given as quadkeys. | ||
### Tests | ||
```bash | ||
@@ -37,3 +64,3 @@ npm test | ||
###Benchmarks | ||
### Benchmarks | ||
@@ -44,14 +71,14 @@ ```bash | ||
###Examples | ||
### Examples | ||
#####Polygons: | ||
##### Polygons: | ||
![img](https://dl.dropbox.com/s/48cj16fvt8nyh3o/Screenshot%202014-08-06%2013.34.12.png) | ||
#####Lines: | ||
##### Lines: | ||
![img](https://dl.dropbox.com/s/u32bq56adqwhpyy/Screenshot%202014-08-06%2013.30.31.png) | ||
#####Points: | ||
##### Points: | ||
![img](https://dl.dropbox.com/s/7kkmmm8owg1ezb0/Screenshot%202014-08-06%2014.02.01.png) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
19595
432
80
0
8
Updatedtilebelt@^0.7.1