[][src]Struct geobuf::encode::Encoder

pub struct Encoder { /* fields omitted */ }

GeoJSON to Geobuf encoder

Implementations

impl Encoder[src]

pub fn encode(
    geojson: &JSONValue,
    precision: u32,
    dim: u32
) -> Result<Data, &'static str>
[src]

Returns a Geobuf encoded object from the given geojson value

Arguments

  • geojson - A serde_json::Value that contains a valid geojson object.
  • precision - max number of digits after the decimal point in coordinates.
  • dim - number of dimensions in coordinates.

Example

use geobuf::encode::Encoder;
use geobuf::geobuf_pb::Data_Geometry_Type;
use serde_json;

let geojson = serde_json::from_str(r#"{"type": "Point", "coordinates": [100.0, 0.0]}"#).unwrap();
let geobuf = Encoder::encode(&geojson, 6, 2).unwrap();
assert_eq!(geobuf.get_dimensions(), 2);
assert_eq!(geobuf.get_precision(), 6);
assert_eq!(geobuf.get_geometry().get_field_type(), Data_Geometry_Type::POINT);

Auto Trait Implementations

impl RefUnwindSafe for Encoder

impl Send for Encoder

impl Sync for Encoder

impl Unpin for Encoder

impl UnwindSafe for Encoder

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, 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.