Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mapbox/tile-cover
Generate the minimum number of tiles to cover a geojson geometry
https://github.com/mapbox/tile-cover
Last synced: about 2 months ago
JSON representation
Generate the minimum number of tiles to cover a geojson geometry
- Host: GitHub
- URL: https://github.com/mapbox/tile-cover
- Owner: mapbox
- License: mit
- Created: 2014-08-05T22:21:40.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-09-11T01:18:38.000Z (about 4 years ago)
- Last Synced: 2024-07-25T19:59:24.318Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.22 MB
- Stars: 189
- Watchers: 118
- Forks: 40
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
tile-cover
==========[![Build Status](https://travis-ci.org/mapbox/tile-cover.svg?branch=master)](https://travis-ci.org/mapbox/tile-cover)
Generate the minimum number of tiles to cover a [GeoJSON Geometry](http://geojson.org/geojson-spec.html#geometry-objects).
### Install
```bash
npm install @mapbox/tile-cover
```### Usage
```js
var cover = require('@mapbox/tile-cover');
var poly = JSON.parse(fs.readFileSync('./poly.geojson'));
var limits = {
min_zoom: 4,
max_zoom: 9
};cover.geojson(poly.geom, limits);
cover.tiles(poly.geom, limits);
cover.indexes(poly.geom, limits);
```# API
## geojson(geom, limits)
Given a [geometry](http://geojson.org/geojson-spec.html#geometry-objects), 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](http://geojson.org/geojson-spec.html#geometry-objects), 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.>`, An array of tiles given as [x, y, z] arrays
## indexes(geom, limits)Given a [geometry](http://geojson.org/geojson-spec.html#geometry-objects), 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.`, An array of tiles given as quadkeys.
### Tests
```bash
npm test
```### Benchmarks
```bash
node bench.js
```### Examples
##### Polygons:
![img](https://dl.dropbox.com/s/48cj16fvt8nyh3o/Screenshot%202014-08-06%2013.34.12.png)
##### Lines:
![img](https://dl.dropbox.com/s/u32bq56adqwhpyy/Screenshot%202014-08-06%2013.30.31.png)
##### Points:
![img](https://dl.dropbox.com/s/7kkmmm8owg1ezb0/Screenshot%202014-08-06%2014.02.01.png)