Crates.io | geo-quadkey-rs |
lib.rs | geo-quadkey-rs |
version | 0.1.1 |
source | src |
created_at | 2023-08-29 10:13:27.920193 |
updated_at | 2023-08-29 19:46:36.817243 |
description | geo-quadkey-rs is a Rust library for encoding and decoding geographical coordinates to and from QuadKeys, a tiling approach used by Microsoft's Bing Maps Tile System for interactive mapping solutions. |
homepage | https://github.com/masaishi/geo-quadkey-rs |
repository | https://github.com/masaishi/geo-quadkey-rs |
max_upload_size | |
id | 957863 |
size | 14,229 |
geo-quadkey-rs
is a Rust library for encoding and decoding geographical coordinates to and from QuadKeys, a tiling approach used by Microsoft's Bing Maps Tile System for interactive mapping solutions.
*Source: Microsoft Bing Maps Tile System
I referenced this repository made in Ruby was very helpful in creating this library: deg84/quadkey
Include geo-quadkey-rs
in your Cargo.toml
:
[dependencies]
geo-quadkey-rs = "0.1.0"
Then include it in your code:
extern crate geo_quadkey_rs;
use geo_quadkey_rs::Quadkey;
// Encode coordinates to a quadkey
let quadkey = Quadkey::encode(47.60357, -122.32945, 23);
// Decode a quadkey to coordinates
let (latitude, longitude, precision) = Quadkey::decode("12022001101101100101102");
// Find neighbors of a quadkey
let neighbors = Quadkey::neighbors("12022001101101100101102");
The Quadkey
struct provides the following methods:
encode(latitude: f64, longitude: f64, precision: usize) -> String
decode(quadkey: &str) -> (f64, f64, usize)
neighbors(quadkey: &str) -> Vec<String>
clip(n: f64, min_value: f64, max_value: f64) -> f64
map_size(precision: usize) -> f64
ground_resolution(latitude: f64, precision: usize) -> f64
coordinates_to_pixel(latitude: f64, longitude: f64, precision: usize) -> (i32, i32)
pixel_to_coordinates(pixel_x: i32, pixel_y: i32, precision: usize) -> (f64, f64)
pixel_to_tile(pixel_x: i32, pixel_y: i32) -> (i32, i32)
tile_to_pixel(tile_x: i32, tile_y: i32) -> (i32, i32)
tile_to_quadkey(tile_x: i32, tile_y: i32, precision: usize) -> String
quadkey_to_tile(quadkey: &str) -> (i32, i32, usize)
This project is licensed under the MIT License - see the LICENSE file for details.