Node Promiscuous Modules

    @mapbox/tile-cover
    DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/mapbox__tile-cover package

    3.0.2 • Public • Published

    tile-cover

    Build Status

    Generate the minimum number of tiles to cover a GeoJSON Geometry.

    Install

    npm install @mapbox/tile-cover

    Usage

    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, 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

    npm test

    Benchmarks

    node bench.js

    Examples

    Polygons:

    img

    Lines:

    img

    Points:

    img

    Install

    npm i @mapbox/tile-cover

    DownloadsWeekly Downloads

    6,648

    Version

    3.0.2

    License

    MIT

    Last publish

    Collaborators

    • mapbox-machine-user
    • mapbox-npm-ci
    • mapbox-npm-advanced-actions
    • mapbox-npm-09
    • mapbox-npm-08
    • mapbox-npm-07
    • mapbox-npm-06
    • mapbox-npm-05
    • mapbox-npm-04
    • mapbox-npm-03
    • mapbox-npm-02
    • mapbox-npm-01
    • mapbox-npm
    • mapbox-admin