# map-engine-rust 🦀🗺️
Zero-dependency map engine core in **Rust** — a port of the TypeScript
[maps-engine](https://github.com/gnoudisme/maps-engine).
Provides the math every slippy-map needs, without any rendering or DOM:
| `projection` | Web Mercator lon/lat ↔ pixel math |
| `tile` | XYZ tile ids, bounds, quadkeys, children/parent |
| `geo` | Haversine distance, bearing, destination point |
| `geofence` | Polygon & circle geofences, point-in-polygon |
| `view` | Camera state: center, zoom, bearing, pitch |
| `cluster` | Grid-based marker clustering |
| `heatmap` | Heatmap intensity grids |
| `draw` | Drawing session with undo/redo |
| `measure` | Distance/area measurement + human formatting |
| `navigation` | Turn-by-turn maneuver detection (VI/EN), progress tracking |
| `geojson` | Minimal GeoJSON types |
## Usage
```toml
[dependencies]
map_engine = "0.1.0"
```
```rust
use map_engine::{LonLat, projection, tile, geo};
let hanoi = LonLat::new(105.85, 21.02);
// Web Mercator projection
let (px, py) = projection::to_pixels(hanoi.lon, hanoi.lat, 14);
// Tile containing the point
let t = tile::Tile::from_lon_lat(hanoi.lon, hanoi.lat, 14);
println!("tile {}/{}/{} quadkey {}", t.x, t.y, t.z, t.quadkey());
// Distance
let haiphong = LonLat::new(106.68, 20.86);
println!("{:.1} km", geo::haversine(hanoi, haiphong) / 1000.0);
```
## Development
```bash
cargo test # 43 unit tests
cargo clippy # lint, must be clean
cargo fmt --check # formatting
```
---
# map-engine-rust 🦀🗺️ (Tiếng Việt)
Nhân bản đồ (map engine) thuần **Rust**, không phụ thuộc thư viện ngoài —
port từ bản TypeScript [maps-engine](https://github.com/gnoudisme/maps-engine).
Cung cấp toàn bộ phép toán mà bản đồ trượt (slippy-map) cần, không dính dáng
gì đến render hay DOM. Xem bảng module ở trên.
## Dùng thử
```bash
cargo test # 43 test
cargo clippy # lint phải sạch
cargo fmt --check # format
```
## License
MIT