0.7.1 • Published 1 year ago

tilequery v0.7.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

tilequery

Query remote vector tiles and return point features within a bounding box or point buffer. The returned geojson is only as accurate as the data in the tiles, but the less tiles that need queried the faster the response, so the two factors need to be taken into account when utilizing tilequery.

Polygons and lines will be returned if queried but cut at the tile boundaries. The full list of attributes will be returned however.

A pre-built version is available in docs/dist and can be used directly in the browser with the global variable tilequery. For node, simply use const tilequery = require("tilequery").

Example

const tilequery = require("tilequery");

(async function testTilequery() {
  const now = Date.now()
  const features = await tilequery({
    point: [-82.54, 39.11], 
    radius: 1,
    units: 'miles',
    tiles: 'https://reyemtm.github.io/tilequery/tiles/{z}/{x}/{y}.mvt',
    layer: 'test', 
    zoom: 14,
    buffer: true
  });

  console.log("timer:", Date.now() - now, "ms")
  console.log("features found:", features.features.length)
})()

Margins of Error in Vector Tiles

Keep in mind the margin of error per zoom level. The table below shows the margin of error for 40 points queried using tilequery starting at zoom level 4 compared to the original GeoJSON. Tiles were created with geojson-vt using default settings and errors were checked using Turf JS and turf.distance().

Zoom LevelError (ft)
4811.6139
5322.6163
6170.7157
778.1861
840.4505
918.8305
109.0808
115.4247
122.6212
131.1149
140.5900
150.2986
160.1576
170.0682
180.0347

Version Notes

  • 0.5.0 - removed requirement of id field
  • 0.4.0 - Help wanted to convert to ES6.
  • 0.3.2 - Replaced turf.buffer() with turf.circle() due to distance errors in turf.buffer()

Related

https://github.com/stevage/QueryRemoteTiles#readme

https://github.com/mapbox/vtquery

0.7.1

1 year ago

0.5.0

2 years ago

0.7.0

1 year ago

0.6.0

2 years ago

0.2.1

2 years ago

0.3.4

2 years ago

0.3.3

3 years ago

0.3.2

3 years ago