Struct geo_rasterize::Rasterizer[][src]

pub struct Rasterizer<Label> { /* fields omitted */ }
Expand description

Rasterizer rasterizes shapes like BinaryRasterizer but instead of making a boolean array, it produces an array of some generic type (Label) that implements Copy and Add though typically you’d use a numeric type.

You can call new or use LabelBuilder to construct Rasterizer instances. Constructing one requires a width, height and optional geo_to_pix transform in addition to background which specifies the default Label value used to fill the raster array. And you can provide a MergeAlgorithm value to specify what the rasterizer should do when two different shapes fill the same pixel. If you don’t supply anything, the rasterizer will use Replace by default.

use geo::{Geometry, Line, Point};
use ndarray::array;

let point = Point::new(3, 4);
let line = Line::new((0, 3), (3, 0));

let mut rasterizer = LabelBuilder::background(0).width(4).height(5).build()?;
rasterizer.rasterize(&point, 7)?;
rasterizer.rasterize(&line, 3)?;

let pixels = rasterizer.finish();
assert_eq!(
    pixels.mapv(|v| v as u8),
    array![
        [0, 0, 3, 0],
        [0, 3, 3, 0],
        [3, 3, 0, 0],
        [3, 0, 0, 0],
        [0, 0, 0, 7]
    ]
);

Implementations

Retrieve the transform.

Rasterize one shape, which can be any type that geo provides using any coordinate numeric type that can be converted into f64.

Retrieve the completed raster array.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.