pub struct WebMercator;Expand description
Web Mercator projection utilities.
project/unproject are fast, allocation-free wrappers over the
Projection trait implementation.
Implementations§
Source§impl WebMercator
impl WebMercator
Sourcepub fn project(geo: &GeoCoord) -> WorldCoord
pub fn project(geo: &GeoCoord) -> WorldCoord
Project a geographic coordinate to Web Mercator world coordinates (meters).
Input is assumed to already be in valid Web Mercator range.
Sourcepub fn project_checked(geo: &GeoCoord) -> Option<WorldCoord>
pub fn project_checked(geo: &GeoCoord) -> Option<WorldCoord>
Checked variant of project.
Returns None when geo is outside Web Mercator valid range.
Sourcepub fn project_clamped(geo: &GeoCoord) -> WorldCoord
pub fn project_clamped(geo: &GeoCoord) -> WorldCoord
Project with automatic Mercator clamping/wrapping.
Latitude is clamped to +/-85.051129 and longitude wrapped to
[-180, 180] before projection.
Sourcepub fn unproject(world: &WorldCoord) -> GeoCoord
pub fn unproject(world: &WorldCoord) -> GeoCoord
Inverse-project Web Mercator coordinates back to geographic coordinates.
Sourcepub fn max_extent() -> f64
pub fn max_extent() -> f64
The maximum extent of Web Mercator along one axis, in meters.
Equals R * PI where R is the projection sphere radius.
Sourcepub fn world_size() -> f64
pub fn world_size() -> f64
Full width/height of the Web Mercator world square, in meters.
Trait Implementations§
Source§impl Projection for WebMercator
impl Projection for WebMercator
Source§fn scale_factor(&self, geo: &GeoCoord) -> f64
fn scale_factor(&self, geo: &GeoCoord) -> f64
Scale factor for Web Mercator: sec(lat) = 1 / cos(lat).
Approaches infinity near the poles, which is why the projection is limited to approximately 85.06 degrees latitude.
Source§fn projection_bounds(&self) -> GeoBounds
fn projection_bounds(&self) -> GeoBounds
Web Mercator is valid within approximately 85.06 degrees latitude and 180 degrees longitude.