Struct galileo::MapView

source ·
pub struct MapView { /* private fields */ }
Expand description

Map view specifies the area of the map that should be drawn. In other words, it sets the position of “camera” that looks at the map.

The main view parameters are:

  • position - coordinates of the point in the center of the map
  • resolution - number of map units in a single pixel at the center of the map
  • size - size of the rendering area in pixels
  • crs - coordinate system that the map will be rendered to. This specifies the geographic projection that the map is displayed in. Note, that currently geographic CRSs are not supported, and a map with such a view will not be drawn.

The view can also specify rotation along x (tilt) and z (rotation) axis.

Implementations§

source§

impl MapView

source

pub fn new(position: &impl GeoPoint<Num = f64>, resolution: f64) -> Self

Creates a new view with the given position and resolution with default CRS (web-mercator EPSG:3857).

source

pub fn new_with_crs( position: &impl GeoPoint<Num = f64>, resolution: f64, crs: Crs ) -> Self

Creates a new view with the given CRS.

source

pub fn new_projected( position: &impl CartesianPoint2d<Num = f64>, resolution: f64 ) -> Self

Creates a new view, taking position value as projected coordinates. Default CRS is used (EPSG:3857).

source

pub fn new_projected_with_crs( position: &impl CartesianPoint2d<Num = f64>, resolution: f64, crs: Crs ) -> Self

Creates a new view, taking position value as projected coordinates.

source

pub fn crs(&self) -> &Crs

CRS of the view.

source

pub fn position(&self) -> Option<GeoPoint2d>

Position of the center point of the map (screen).

If the projected position cannot be projected into geographic coordinates, None is returned.

source

pub fn resolution(&self) -> f64

Resolution at the center of the map.

source

pub fn with_resolution(&self, resolution: f64) -> Self

Creates a new view, same as the current one, but with the given resolution.

source

pub fn size(&self) -> Size

Size of the view in pixels.

source

pub fn with_size(&self, new_size: Size) -> Self

Creates a new view, same as the current one, but with the given size.

source

pub fn get_bbox(&self) -> Option<Rect>

Returns bounding rectangle of the view (in projected coordinates).

source

pub fn map_to_scene_transform(&self) -> Option<OMatrix<f64, U4, U4>>

Returns transformation matrix that transforms map coordinates to scene coordinates.

Scene coordinates are [-1.0, 1.0] coordinates of the render area with Y going from bottom to top.

source

pub fn map_to_scene_mtx(&self) -> Option<[[f32; 4]; 4]>

Returns transformation matrix that transforms map coordinates to scene coordinates.

Scene coordinates are [-1.0, 1.0] coordinates of the render area with Y going from bottom to top.

source

pub fn rotation_x(&self) -> f64

Rotation angle around X axis in radians (tilt).

source

pub fn rotation_z(&self) -> f64

Rotation angle around Z axis in radians.

source

pub fn with_rotation_x(&self, rotation_x: f64) -> Self

Creates a new view, same as the current one, but with the given rotation x.

source

pub fn with_rotation_z(&self, rotation_z: f64) -> Self

Creates a new view, same as the current one, but with the given rotation z.

source

pub fn with_rotation(&self, rotation_x: f64, rotation_z: f64) -> Self

Creates a new view, same as the current one, but with the given rotation values.

source

pub fn screen_to_map(&self, px_position: Point2d) -> Option<Point2d>

Projects the given screen point into map coordinates at the 0 elevation.

Returns None if the point is outside of map (this can be possible, if the map is tilted and the point is above the horizon, or if the point is outside the projection bounds).

source

pub fn screen_to_map_geo(&self, px_position: Point2d) -> Option<GeoPoint2d>

Projects the given screen point into map coordinates at the 0 elevation, and then projects them into geographic coordinates.

Returns None if the point is outside of map (this can be possible, if the map is tilted and the point is above the horizon, or if the point is outside the projection bounds).

source

pub fn translate_by_pixels(&self, from: Point2d, to: Point2d) -> Self

Creates a new view, same as the current one, but translated so that point from on the current view becomes the point to in the new view.

source

pub fn translate(&self, delta: Vector2<f64>) -> Self

Move the vew by the given projected coorinates delta.

Trait Implementations§

source§

impl Clone for MapView

source§

fn clone(&self) -> MapView

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MapView

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CoordinateMetadata for T
where T: ?Sized,

§

fn crs_id(&self) -> Option<MdIdentifier>

§

fn crs(&self) -> Option<Crs>

§

fn coordinate_epoch(&self) -> Option<DataEpoch>

§

fn is_valid(&self) -> bool

§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSync for T
where T: Sync,