quadtile-index

0.0.6 • Public • Published

Build Status

quadtile-index

Convert between x,y map tile coordinates and a bitwise-interleaved single integer

Quadtiles use a 2-bit tile interleaved addresses. An x and y coordinate value bit representation of up to 26 bits each can be converted to a single integer value up to 56 bits. The limit is due to JavaScript's maximum lossless integer representation. For example, two 8 bit values xxxx xxxx and yyyy yyyy would produce a singel xyxyxyxy xyxyxyxy xyxyxyxy xyxyxyxy index value.

The library will assert the validity of each value, and allows optional zoom for additional verification.

For more info, see quadtile indexes info

xyToIndex(x, y, [zoom])

Convert x,y into a single integer with alternating bits

indexToXY(index, [zoom])

Convert index into the x,y coordinates (as a [x,y] array)

isValidCoordinate(val, [zoom]), isValidIndex(index, [zoom]), isValidZoom(zoom)

Boolean validation functions

maxZoom

Constant: Maximum supported zoom level (26)

Package Sidebar

Install

npm i quadtile-index

Weekly Downloads

13

Version

0.0.6

License

MIT

Last publish

Collaborators

  • nyurik