map-expressions 0.1.0

Deterministic map-label selection, projection, and collision handling
Documentation
  • Coverage
  • 100%
    42 out of 42 items documented0 out of 22 items with examples
  • Size
  • Source code size: 18.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 489.6 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • hidenoriuehara-art

map-expressions

map-expressions is a dependency-free Rust library for deterministic map-label layout. It provides:

  • validated latitude and longitude;
  • viewports that can cross the antimeridian;
  • normalized screen projection;
  • zoom-dependent feature visibility;
  • localized labels with explicit fallback;
  • priority-based collision suppression.

Example

use map_expressions::{GeoPoint, LabelPriority, LocalizedLabel, MapDisplay, MapFeature, Viewport};

let mut label = LocalizedLabel::new();
label.insert("ja", "駅")?;
label.insert("en", "Station")?;
let feature = MapFeature::new(
    "station",
    GeoPoint::new(35.6812, 139.7671)?,
    label,
    LabelPriority::Transit,
    8,
    18,
)?;
let viewport = Viewport::new(35.5, 139.4, 35.9, 140.0)?;
let placed = MapDisplay::layout(&[feature], viewport, 12, "en", "ja", 0.02)?;
assert_eq!(placed[0].text, "Station");
# Ok::<(), map_expressions::MapError>(())

Sources and scope

The design is informed by the Geospatial Information Authority of Japan's explanation of vector tiles and map expression and the experimental GSI Maps Vector.

This crate is independent and unofficial. It does not download or license map data, perform Web Mercator projection, render graphics, or guarantee that a map is suitable for navigation, surveying, emergency response, or legal boundaries.