const z = require('z-curve');
z.encode(lat, lng, scala);
z.decode(z_val);
在浏览器中测试: https://npm.runkit.com/z-curve
Encode a pair of latitude and longitude values into a z-curve.
const z = require('z-curve');
z.encode(32.05, 118.78333) === 471947;
Decode a hash string into pair of latitude and longitude values. A javascript object is returned with latitude
and longitude
keys.
const z = require('z-curve');
z.decode(471947);
// {
// lat: 32.16796875,
// lng: 118.65234375
// }
测试环境:
- CPU: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (8 核心 16 线程)
- Memory: 72 GB 2667 MHz DDR4
- GPU: Radeon Pro 580X 8 GB
- GeoHash Node 实现: https://github.com/sunng87/node-geohash
- IEEE 754 工具: https://baseconvert.com/ieee-754-floating-point