pub struct GeomEncoder<F>where
F: Float,{ /* private fields */ }Expand description
Implementations§
Source§impl<F> GeomEncoder<F>where
F: Float,
impl<F> GeomEncoder<F>where
F: Float,
Sourcepub fn new(geom_tp: GeomType) -> Self
pub fn new(geom_tp: GeomType) -> Self
Create a new geometry encoder.
geom_tpGeometry type.
Examples found in repository?
examples/simple.rs (line 7)
3fn main() -> Result<(), Error> {
4 let mut tile = Tile::new(4096);
5 let layer = tile.create_layer("First Layer");
6 // NOTE: normally, the Transform would come from MapGrid::tile_transform
7 let b = GeomEncoder::new(GeomType::Linestring)
8 .point(0.0, 0.0)?
9 .point(1024.0, 0.0)?
10 .point(1024.0, 2048.0)?
11 .point(2048.0, 2048.0)?
12 .point(2048.0, 4096.0)?
13 .encode()?;
14 let mut feature = layer.into_feature(b);
15 feature.set_id(1);
16 feature.add_tag_string("key", "value");
17 let layer = feature.into_layer();
18 tile.add_layer(layer)?;
19 let data = tile.to_bytes()?;
20 println!("encoded {} bytes: {:?}", data.len(), data);
21 Ok(())
22}Sourcepub fn point(self, x: F, y: F) -> Result<Self, Error>
pub fn point(self, x: F, y: F) -> Result<Self, Error>
Add a point, taking ownership (for method chaining).
Examples found in repository?
examples/simple.rs (line 8)
3fn main() -> Result<(), Error> {
4 let mut tile = Tile::new(4096);
5 let layer = tile.create_layer("First Layer");
6 // NOTE: normally, the Transform would come from MapGrid::tile_transform
7 let b = GeomEncoder::new(GeomType::Linestring)
8 .point(0.0, 0.0)?
9 .point(1024.0, 0.0)?
10 .point(1024.0, 2048.0)?
11 .point(2048.0, 2048.0)?
12 .point(2048.0, 4096.0)?
13 .encode()?;
14 let mut feature = layer.into_feature(b);
15 feature.set_id(1);
16 feature.add_tag_string("key", "value");
17 let layer = feature.into_layer();
18 tile.add_layer(layer)?;
19 let data = tile.to_bytes()?;
20 println!("encoded {} bytes: {:?}", data.len(), data);
21 Ok(())
22}Sourcepub fn complete_geom(&mut self) -> Result<(), Error>
pub fn complete_geom(&mut self) -> Result<(), Error>
Complete the current geometry (for multilinestring / multipolygon).
Sourcepub fn complete(self) -> Result<Self, Error>
pub fn complete(self) -> Result<Self, Error>
Complete the current geometry (for multilinestring / multipolygon).
Sourcepub fn encode(self) -> Result<GeomData, Error>
pub fn encode(self) -> Result<GeomData, Error>
Encode the geometry data, consuming the encoder.
Examples found in repository?
examples/simple.rs (line 13)
3fn main() -> Result<(), Error> {
4 let mut tile = Tile::new(4096);
5 let layer = tile.create_layer("First Layer");
6 // NOTE: normally, the Transform would come from MapGrid::tile_transform
7 let b = GeomEncoder::new(GeomType::Linestring)
8 .point(0.0, 0.0)?
9 .point(1024.0, 0.0)?
10 .point(1024.0, 2048.0)?
11 .point(2048.0, 2048.0)?
12 .point(2048.0, 4096.0)?
13 .encode()?;
14 let mut feature = layer.into_feature(b);
15 feature.set_id(1);
16 feature.add_tag_string("key", "value");
17 let layer = feature.into_layer();
18 tile.add_layer(layer)?;
19 let data = tile.to_bytes()?;
20 println!("encoded {} bytes: {:?}", data.len(), data);
21 Ok(())
22}Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for GeomEncoder<F>where
F: Freeze,
impl<F> RefUnwindSafe for GeomEncoder<F>where
F: RefUnwindSafe,
impl<F> Send for GeomEncoder<F>where
F: Send,
impl<F> Sync for GeomEncoder<F>where
F: Sync,
impl<F> Unpin for GeomEncoder<F>where
F: Unpin,
impl<F> UnwindSafe for GeomEncoder<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more