MercatorProjector
struct · ferroui-livecharts · v0.5.0
struct MercatorProjector
Projects longitude and latitude with the Mercator projection. Lands outside the bounds are extrapolated past the map area, which the chart clips.
Members
DEFAULT_MIN_LATITUDEDEFAULT_MAX_LATITUDEDEFAULT_MIN_LONGITUDEDEFAULT_MAX_LONGITUDEnewpreferred_ratiomap_widthmap_heightx_offsety_offsetto_mapto_coordinates
DEFAULT_MIN_LATITUDE
const DEFAULT_MIN_LATITUDE: f64
-65 degrees crops the empty band below the populated continents.
DEFAULT_MAX_LATITUDE
const DEFAULT_MAX_LATITUDE: f64
85 degrees, the usual Mercator limit, keeps Greenland whole.
DEFAULT_MIN_LONGITUDE
const DEFAULT_MIN_LONGITUDE: f64
DEFAULT_MAX_LONGITUDE
const DEFAULT_MAX_LONGITUDE: f64
new
fn new(map_width: f64, map_height: f64, offset_x: f64, offset_y: f64, bounds: GeographicBounds) -> Self
A projector of the map area of the given size at the given offset, framed on bounds.
preferred_ratio
fn preferred_ratio(bounds: GeographicBounds) -> [f64; 2]
The conformal aspect ratio, width to height, of the framed bounds (GetPreferredRatio):
about 1.355 for the default crop, 1 for the symmetric 85 degrees.
map_width
fn map_width(self: &Self) -> f64
map_height
fn map_height(self: &Self) -> f64
x_offset
fn x_offset(self: &Self) -> f64
y_offset
fn y_offset(self: &Self) -> f64
to_map
fn to_map(self: &Self, longitude: f64, latitude: f64) -> Point
The minimum longitude spans to the left edge and the maximum to the right; the Mercator images of the latitude bounds span the height. A latitude at a pole takes the last finite latitude, so that the poles of a map (Antarctica) stay finite.
to_coordinates
fn to_coordinates(self: &Self, screen: Point) -> Option<(f64, f64)>
The closed-form inverse: the linear longitude, then the inverse Gudermannian of the
Mercator value, 2 atan(e^n) - pi/2.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedPropertyValueAnyValueClassDefaultsErasedDestructorIntoEitherCloneDebugStructuralPartialEqPartialEq
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.