GitXplorerGitXplorer
k

node-morton

public
22 stars
5 forks
0 issues

Commits

List of commits on branch master.
Unverified
4f64121bb4994055df571015f89d05c158d92a37

Use Error object instead strings

iikokostya committed 8 years ago
Unverified
5f0c231ff33cf110969479fa248507f0967674f0

Modernize, add tests

ttmcw committed 11 years ago
Unverified
b0ebe7b0f9dbf931ef02ab6bf52bb7161185fa4d

add travis file

kkkaefer committed 13 years ago
Unverified
8927492e4837e768bd6df50944861d841ea60b6e

bump to version v1.0.3

kkkaefer committed 13 years ago
Unverified
14b66a0952951f23e1cd0b11ef8d791b366ba59c

switch to mocha

kkkaefer committed 13 years ago
Unverified
cbb039f67eb5c67aed529d271b62d2b100a97f14

add reversal functions

kkkaefer committed 14 years ago

README

The README file for this repository.

Build Status

NAME

node-morton - Calculates morton numbers and Z-order codes for spatial indexing.

USAGE

Install with npm install morton.

var morton = require('morton');

morton(32, 436);          // => 167456

morton.code(1, 0, 1);     // => 140737488355328
morton.code(2, 0, 2);     // => 140737488355328
morton.code(3, 0, 4);     // => 140737488355328
morton.code(4, 0, 8);     // => 140737488355328

morton.range(1, 0, 0);    // => [              0,   70368744177663 ]
morton.range(1, 1, 0);    // => [  70368744177664, 140737488355327 ]
morton.range(1, 0, 1);    // => [ 140737488355328, 211106232532991 ]
morton.range(1, 1, 1);    // => [ 211106232532992, 281474976710655 ]

Note: input numbers must be smaller than 2^24 (16777216). Since the resulting output has twice as many bits, you'll get back numbers that are up to 2^48 (281474976710656). JavaScript can still represent these numbers without losing precision, however, you can't use bitwise operators on these numbers if your input numbers are potentially bigger than 2^15 (32768) because JavaScript only supports bitwise operators on 32 bit signed integers.

morton.code(z, x, y) returns a 48-bit Z-order code.

morton.range(z, x, y) will return an array of the lower and upper bound of the Z-order rectangle. See also Z-order curves in Wikipedia.

[x, y] = morton.reverse(c) reverses c = morton(x, y).

[x, y] = morton.decode(z, c) reverses c = morton.code(z, x, y).

TESTS

npm install
npm test

CONTRIBUTORS

ACKNOWLEDGEMENTS

Thanks to Sean Eron Anderson for his Bit Twiddling Hacks page.

LICENSE

node-morton is BSD licensed.