[][src]Struct geogrid::GeoGrid

pub struct GeoGrid { /* fields omitted */ }

GeoGrid represents some portion of a geographic map as a grid. The grid computes step size from the center of the bounds. Because earth is not flat there will be some distance distortion farther from the central latitude if the grid is spread over a large area.

Implementations

impl GeoGrid[src]

pub fn from_roads<NMatrix: AsRef<[NRow]> + Sync, NRow: AsRef<[Node]> + Sync>(
    roads: NMatrix,
    resolution: (usize, usize),
    scale: bool
) -> GeoGrid
[src]

Construct a GeoGrid from a slice of roads, where each road is a slice of nodes. This constructor will interpolate linearly between nodes within each row to set to 1. The grid's bounds will be exactly large enough to contain every given map node. Resolution is given as pair of (height, width) of the grid in pixels. If scale is true, then the aspect ratio of the original map will be maintained, potentially reducing one of the resolution dimensions. Otherwise, with scale false, the grid will stretch to the provided resolution.

pub fn from_nodes(nodes: &[Node], resolution: (f32, f32)) -> GeoGrid[src]

Construct a GeoGrid from provided slice of nodes using given resolution, expressed in units of (meters latitude per grid unit, meters longitude per grid unit).

pub fn resolution(&self) -> (f32, f32)[src]

Grid resolution, in meters per row and meters per column.

pub fn degree_resolution(&self) -> (f32, f32)[src]

Grid resolution, in degrees latitude per row and degrees longitude per column.

pub fn bbox(&self) -> Bounds[src]

Return the lat/lon boundaries of the grid.

pub fn size(&self) -> (usize, usize)[src]

Grid dimensions.

pub fn len(&self) -> usize[src]

Grid length, product of width and height.

pub fn is_empty(&self) -> bool[src]

Grid is 0x0.

pub fn clear_grid(&mut self)[src]

Clears the grid, but leaves all other fields intact. Maybe useful to save memory if you only need the distance transform and not the original grid.

pub fn real_size(&self) -> (f32, f32)[src]

Latitude and longitude covered, in meters. resolution * size.

pub fn grid(&self) -> &[u8][src]

Immutable access to the underlying grid.

pub fn grid_mut(&mut self) -> &mut [u8][src]

Mutable access to the underlying grid.

pub fn trace_shape<BMatrix: AsRef<[BRow]>, BRow: AsRef<[bool]>>(
    &self,
    shape: BMatrix,
    topleft: usize
) -> Vec<usize>
[src]

Trace provided shape from given top left index, returning locations of all the true cells.

pub fn to_lat_lon(&self, idx: usize) -> (f32, f32)[src]

Return lat, lon coordinates of given index in the grid.

pub fn near_lat_lon(&self, lat: f32, lon: f32) -> usize[src]

Return closest index in grid to given latitude, longitude.

pub fn bounded_subgrid(
    &self,
    north: f32,
    south: f32,
    east: f32,
    west: f32
) -> (usize, (usize, usize))
[src]

Return start index and a new size of a bounded subgrid specified by given rectangle in degrees.

pub fn l1dist_transform(&self) -> Vec<i32>[src]

Compute L1 distance transform of t matrix. Output is linearized matrix of same size as grid.

Trait Implementations

impl Clone for GeoGrid[src]

Auto Trait Implementations

impl RefUnwindSafe for GeoGrid

impl Send for GeoGrid

impl Sync for GeoGrid

impl Unpin for GeoGrid

impl UnwindSafe for GeoGrid

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.