Skip to main content

Transform

Struct Transform 

Source
pub struct Transform { /* private fields */ }

Implementations§

Source§

impl Transform

Source

pub fn ease_to( &mut self, camera: &CameraOptions, animation: &AnimationOptions, ) -> CameraCommandId

Change any combination of center, zoom, bearing, pitch and edgeInsets, with a smooth animation between old and new values. Omitted options keep their current animations and timing.

Source§

impl Transform

Source

pub fn apply_camera_delta( &mut self, delta: &CameraDelta, ) -> Result<CameraCommandId, CameraError>

Moves the camera relative to where it is, as a gesture does (the C API’s mln_map_apply_camera_delta). See CameraDelta.

Source

pub fn update_camera(&mut self, update: &CameraUpdate) -> CameraCommandId

Moves the camera to absolute values, as a command or a gesture (the C API’s mln_map_update_camera). See CameraUpdate.

Source

pub fn is_gesture_in_progress(&self) -> bool

Source§

impl Transform

Source

pub fn set_terrain(&mut self, terrain: Option<TerrainGround>)

Sets the terrain the camera stands on, or None without terrain, which turns off every rule of the camera over terrain. Once the terrain goes, the view fits the flat map again, a clamped center goes to sea level, keeping its location and zoom, and a gesture holds the altitude from where that leaves it.

Source

pub fn follow_terrain(&mut self) -> bool

Moves the camera onto the terrain’s ground. While there is ground, the view’s near and far planes fit the lowest ground of the tile under the center, and a camera at rest whose center is clamped stands on the ground there, unless it is still loading. A camera that a command moves takes the altitude its frames give it, which ease onto the ground, and a gesture that holds the altitude lifts it just over the ground as it is now, eye and near plane. Once there is no ground, the planes fit the flat map again, and a clamped center goes back to sea level, once.

At rest it reads only the height and floor at the center (Elevation::at and Elevation::min_at), which are what the renderer compares to tell whether a frame’s camera stood on its newest ground. The terrain moves the camera, not a command, so this reports no camera change. Returns whether the view changed.

Source§

impl Transform

Source

pub fn in_transition(&self) -> bool

Whether any camera command is still animating.

Source

pub fn update_transitions(&mut self, now: Option<Instant>)

Moves the camera to where its commands are at now, and ends the ones that have run out; None, for a map without a clock, ends them all.

Source

pub fn cancel_transitions_with_id(&mut self, transition_id: u64) -> bool

Cancels the commands whose AnimationOptions::transition_id equals transition_id, leaves the others running, and returns whether any command ended.

Source

pub fn close(&mut self)

Ends the running commands as closed, without a camera change. A map’s owner calls it before it drops the map, so that it hears every command’s end.

Source§

impl Transform

Source

pub fn new(constrain_mode: ConstrainMode, viewport_mode: ViewportMode) -> Self

Source

pub fn drain_events(&mut self) -> Drain<'_, TransformEvent> ⓘ

Drains what the transform reported since the last call, oldest first. The transform keeps its buffer for what it reports next.

Source

pub fn has_events(&self) -> bool

Whether the transform reported something that drain_events hasn’t drained.

Source

pub fn resize(&mut self, size: Size) -> Result<(), Error>

Source

pub fn camera_options(&self, padding: Option<EdgeInsets>) -> CameraOptions

Returns the current camera options.

Source

pub fn jump_to(&mut self, camera: &CameraOptions) -> CameraCommandId

Change any combination of center, zoom, bearing, and pitch, without a transition. Omitted options keep their current animations.

Source

pub fn move_by( &mut self, offset: &ScreenCoordinate, animation: &AnimationOptions, ) -> Result<CameraCommandId, Error>

Pans the map by the given amount. Fails with ErrorKind::InvalidArgument for a NaN or infinite offset.

Source

pub fn move_by_with_anchor( &mut self, offset: &ScreenCoordinate, anchor: Option<ScreenCoordinate>, animation: &AnimationOptions, ) -> Result<CameraCommandId, Error>

Moves the map by offset. A drag on the globe turns the planet so that the location under anchor follows the cursor. The ground under the cursor before the move follows it, on the plane at that ground’s height, or on the globe the sphere: sea level on the flat map, the drawn ground over terrain (Self::set_terrain); without an anchor, or with one that grabs no ground, the map moves on the plane or the sphere at the center’s altitude. On the globe, with the bearing held, steps that follow one another, each starting at the anchor of the one before with the camera as it left it, hold the location the first of them grabbed, wherever VerticalPerspectiveProjection::drag_center_holding has a center that does. Fails as move_by does.

Source

pub fn set_limits(&mut self, limits: CameraLimits) -> Result<(), Error>

Sets the limits the camera moves within (see TransformState::set_limits).

Source

pub fn set_projection_definition(&mut self, definition: &ProjectionDefinition)

Source

pub fn set_constrain_mode(&mut self, mode: ConstrainMode)

Source

pub fn set_viewport_mode(&mut self, mode: ViewportMode)

Source

pub fn set_center_clamped_to_ground(&mut self, clamped: bool)

Sets whether the center stands on the terrain. The map hands the setting to set_terrain on its next update.

Source

pub fn set_frame_time(&mut self, time: Option<Instant>)

Puts the camera’s animations on the host’s frame clock: commands start at the latest frame’s time rather than at Instant::now() when they are made, and the map samples them at it. Each frame then shows its animations exactly one frame further on, whenever the input or the map’s update ran, and an animation started between frames moves by that frame’s interval on the next one: no frame repeats the camera, and none skips ahead. None goes back to Instant::now().

Orbis starts animations on the first frame after the call, which keeps the camera still for that frame; a glide that continues a drag would pause there.

Source

pub fn is_camera_moving(&self) -> bool

Whether a gesture or a command moves the camera: the renderer draws such frames for speed rather than crispness.

Source

pub fn state(&self) -> &TransformState

Source

pub fn view(&self) -> &View

The view the camera shows now.

Source

pub fn lat_lng_to_screen_coordinate(&self, lat_lng: &LatLng) -> ScreenCoordinate

Source

pub fn screen_coordinate_to_lat_lng( &self, point: &ScreenCoordinate, wrap_mode: WrapMode, ) -> Result<LatLng, Error>

The location under point, in screen coordinates (y down). Fails with ErrorKind::InvalidArgument for a NaN or infinite point.

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
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool