Skip to content

ajostergaard/node-quadtree

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-quadtree

Build Status

Description

Quadtree is a node module that encodes and decodes geospatial quadtrees.

The encoding algorithm orders the tiles using the bing maps ordering shown below:

Quadtree ordering

Installation

$ npm install quadtree

Usage

var quadtree = require('quadtree');

var coordinate = {
	lng: -27.093364,
	lat: -109.367523
};

var precision = 8;
var encoded = quadtree.encode(coordinate, precision); // returns "23323322"

var decoded = quadtree.decode(encoded); // returns { origin: { lng: -27.421875, lat: -89.6484375 }, error: { lng: 0.703125, lat: 0.3515625 } }

var neighbour = quadtree.neighbour(encoded, 1, 1); // returns "23323321"

var boundingBox = quadtree.bbox(encoded); // returns { minlng:-28.125, minlat: -90, maxlng: -26.71875, maxlat: -89.296875 }

var enveloped = quadtree.envelop(boundingBox, precision); // returns ["23323322", "23323323", "23323320", "23323321"]

quadtree.encode(coordinate, precision)

Encodes a coordinate into a quadtree of the specified precision.

quadtree.decode(quadtree)

Decodes a quadtree into an origin and error.

quadtree.neighbour(encoded, north, east)

Finds the neighbour of the given quadtree, walking a number of tiles in the supplied direction.

quadtree.bbox(encoded)

Returns the bounding box of the tile containing the supplied quadtree.

quadtree.envelop(bbox, precision)

Returns an array of quadtrees that are enveloped by the bbox at the supplied precision.

Contributors

Pair programmed by Roy Lines and James Bloomer.

About

geospatial quadtree encoding and decoding node module

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%