Crates.io | uvoxid |
lib.rs | uvoxid |
version | 0.2.0 |
created_at | 2025-09-17 14:22:15.960769+00 |
updated_at | 2025-09-18 18:12:16.151657+00 |
description | UVoxID: 192-bit spatial addressing scheme for encoding/decoding micrometer + lat/lon coordinates. |
homepage | |
repository | https://github.com/JDPlumbing/uvoxid-rs |
max_upload_size | |
id | 1843412 |
size | 31,524 |
Universal Voxel Identifier (UVoxID) — a deterministic, 192-bit encoding scheme for spherical spatial coordinates at micrometer precision.
Think of it as a globally consistent voxel address system: every point in space has a permanent ID, valid from Earth’s core to interstellar distances.
(radius, latitude, longitude)
→ one integer.cargo add uvoxid
Or add manually to Cargo.toml
:
[dependencies]
uvoxid = "0.1"
use uvoxid::{encode_uvoxid, decode_uvoxid};
fn main() {
// Earth mean radius in µm
let earth_r_um: u64 = 6_371_000_000_000;
// At equator, prime meridian
let id = encode_uvoxid(earth_r_um, 0, 0);
println!("UVoxID: {:#x}", id);
let (r, lat, lon) = decode_uvoxid(id);
println!("Decoded: r = {} µm, lat = {} µ° , lon = {} µ°", r, lat, lon);
}
Output:
UVoxID: 0x59fb8c83f100000000000055d4a8000000000aba950
Decoded: r = 6371000000000 µm, lat = 0 µ°, lon = 0 µ°
encode_uvoxid(r_um: u64, lat_microdeg: i64, lon_microdeg: i64) -> UvoxId
r_um
: radius in micrometers (µm), stored as an unsigned 64-bit value.lat_microdeg
: latitude in millionths of a degree (−90e6 to +90e6). Encoded internally as a u64
offset by +90,000,000.lon_microdeg
: longitude in millionths of a degree (−180e6 to +180e6). Encoded internally as a u64
offset by +180,000,000.UvoxId
(192-bit packed struct with (r, lat, lon)
).decode_uvoxid(id: UvoxId) -> (u64, i64, i64)
Input: a UvoxId
struct (192-bit packed).
Output: (r_um, lat_microdeg, lon_microdeg)
with offsets reversed so you get back the signed coordinates you passed in.
Run tests:
cargo test
Format code:
cargo fmt
MIT © JD Plumbing