Coder Social home page Coder Social logo

rluncasu / quadtile-index Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kartotherian/quadtile-index

0.0 1.0 0.0 16 KB

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

License: MIT License

JavaScript 100.00%

quadtile-index's Introduction

Build Status

quadtile-index

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

Quadtile index has many useful properties. For example, it makes zoom calculations much easier: for a tile at zoom N, the "parent" tile at zoom N-1 is simply math.Floor(index/4). A single index integer makes iteration easier as well - 0 .. 4^zoom-1 are all the tiles at the current zoom level, and makes it much simpler to subdivide work between multiple machines. Iterating tends to go over the tiles in one area before moving to a different area, which may benefit caching.

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 single 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)

quadtile-index's People

Contributors

nyurik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.