# @mapbox/tile-cover

> generate the minimum number of tiles to cover a geojson geometry

Latest version **3.0.2** (published 2017-04-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mapbox/tile-cover
pnpm add @mapbox/tile-cover
yarn add @mapbox/tile-cover
bun add @mapbox/tile-cover
```

## Health

**Score 33/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2017-04-07 |
| First published | 2017-02-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/mapbox__tile-cover) |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 196 |
| Author | morganherlocker |
| Maintainers | aaronlidman, aarthykc, ajithranka, aliceykuo, alinapaz, allierowan, alulsh, amishas157, amyleew, anandthakker, ansis, aparlato, apendleton, arunasank, batpad, benjamintd, bhousel, bkowshik, boblannon, brendanmcfarland, bsrinivasa, bsudekum, calfarome, camillacaros, captainbarbosa, chaupow, chetangowda, chrisloer, colleenmcginnis, danieljh, dannykath, danpat, danswick, dasulit, davidtheclark, deniskoronchik, dnomadb, dthompson, emilymcafee, emilymdubois, enf, fa7c0n, freenerd, geohacker, ghoshkaj, gretacb, ian29, ianshward, ilyasaf, ingalls, isiyu, jacquestardie, jfirebaugh, jothirnadh, jrpruit1, k-mahoney, kaibot3000, kaidalgleish, karenzshea, karitotp, katydecorah, kepta, kkaefer, kronick, l-r, laurier, lbud, lily-chai, lndsay, lucaswoj, lukasmartinelli, lxbarth, lyzidiamond, maning, manoharuss, mapbox-admin, mapbox-machine-user, mapsam, mateov, mattficke, mayaqgao, mcwhittemore, miccolis, miles-dev, mokob, mollymerp, morganherlocker, mourner, msirenko, nammala, natslaughter, nickcordella, nickidlugash, nikhilprabhakar, oini, oliikit, oxidase, pdgoodman, perrygeo, peterqliu, planemad, pratikyadav, rasagy, rclark, richrico, ridixcr, rub21, rumc, ryan-baumann, saikia.abhishek, samanbb, samely, sarahkleins, sbma44, scothis, sgillies, springmeyer, srividyacb, tcql, themarex, tony-cj, tristen, upendrayadav, uvollmer, vincents, virginiayung, willwhite, xrwang, yhahn, yunjieli, zmully |
| Keywords | tile, cover, geojson, index |

## Links

- npm: https://www.npmjs.com/package/@mapbox/tile-cover
- Repository: https://github.com/mapbox/tile-cover
- Issues: https://github.com/mapbox/tile-cover/issues
- npm.io page: https://npm.io/package/@mapbox/tile-cover

## Dependencies (1)

- [@mapbox/tilebelt](https://npm.io/package/@mapbox/tilebelt.md) ^1.0.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.0.2 (latest) — 2017-04-07
- 3.0.1 — 2017-02-07

## 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.<Array.<number>>`, 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.<String>`, 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)

---
_Source: https://npm.io/package/@mapbox/tile-cover · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
