pub trait Projection: Send + Sync {
// Required methods
fn project(&self, geo: &GeoCoord) -> WorldCoord;
fn unproject(&self, world: &WorldCoord) -> GeoCoord;
// Provided methods
fn scale_factor(&self, _geo: &GeoCoord) -> f64 { ... }
fn projection_bounds(&self) -> GeoBounds { ... }
}Expand description
A map projection that converts between geographic and projected coordinates.
Implementations must be thread-safe (Send + Sync) so they can be
shared across rendering and engine threads.
Required Methods§
Sourcefn project(&self, geo: &GeoCoord) -> WorldCoord
fn project(&self, geo: &GeoCoord) -> WorldCoord
Project a geographic coordinate to world space (meters).
Sourcefn unproject(&self, world: &WorldCoord) -> GeoCoord
fn unproject(&self, world: &WorldCoord) -> GeoCoord
Inverse-project world coordinates back to geographic.
Provided Methods§
Sourcefn scale_factor(&self, _geo: &GeoCoord) -> f64
fn scale_factor(&self, _geo: &GeoCoord) -> f64
Local linear scale factor at the given geographic coordinate.
Returns the ratio of projected distance to true geodesic distance
at geo. For a conformal projection like Web Mercator this is
1 / cos(lat) (i.e. sec(lat)); for Equirectangular at the
equator it is 1.0.
Useful for computing meters-per-pixel, line-width scaling, and LOD thresholds.
The default implementation returns 1.0 (no distortion),
which is correct only at the standard parallel.
Sourcefn projection_bounds(&self) -> GeoBounds
fn projection_bounds(&self) -> GeoBounds
The geographic bounding box of valid input for this projection.
Coordinates outside this range may produce NaN or Infinity
when projected. For example, Web Mercator is valid only within
approximately 85.06 degrees latitude.
The default implementation returns the full geographic range (90 degrees lat, 180 degrees lon).