Crate flatgeobuf

source ·
Expand description

FlatGeobuf is a performant binary encoding for geographic data based on flatbuffers that can hold a collection of Simple Features including circular interpolations as defined by SQL-MM Part 3.

§Reading a FlatGeobuf file

use flatgeobuf::*;
use geozero::ToJson;

let mut filein = BufReader::new(File::open("countries.fgb")?);
let mut fgb = FgbReader::open(&mut filein)?.select_all()?;
while let Some(feature) = fgb.next()? {
    println!("{}", feature.property::<String>("name").unwrap());
    println!("{}", feature.to_json()?);
}

§Reading FlatGeobuf via HTTP

use flatgeobuf::*;
use geozero::ToWkt;

let mut fgb = HttpFgbReader::open("https://flatgeobuf.org/test/data/countries.fgb")
    .await?
    .select_bbox(8.8, 47.2, 9.5, 55.3)
    .await?;
while let Some(feature) = fgb.next().await? {
    let props = feature.properties()?;
    println!("{}", props["name"]);
    println!("{}", feature.to_wkt()?);
}

§Writing a FlatGeobuf file

use flatgeobuf::*;
use geozero::geojson::GeoJsonReader;
use geozero::GeozeroDatasource;

let mut fgb = FgbWriter::create("countries", GeometryType::MultiPolygon)?;
let mut fin = BufReader::new(File::open("countries.geojson")?);
let mut reader = GeoJsonReader(&mut fin);
reader.process(&mut fgb)?;
let mut fout = BufWriter::new(File::create("countries.fgb")?);
fgb.write(&mut fout)?;

Re-exports§

Modules§

Structs§

Enums§

Constants§

Traits§

Functions§

  • Read FlatGeobuf geometry
  • Verifies that a buffer of bytes contains a Feature and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use root_as_feature_unchecked.
  • Assumes, without verification, that a buffer of bytes contains a Feature and returns it.
  • Verifies, with the given options, that a buffer of bytes contains a Feature and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use root_as_feature_unchecked.
  • Verifies that a buffer of bytes contains a Header and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use root_as_header_unchecked.
  • Assumes, without verification, that a buffer of bytes contains a Header and returns it.
  • Verifies, with the given options, that a buffer of bytes contains a Header and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use root_as_header_unchecked.
  • Verifies that a buffer of bytes contains a size prefixed Feature and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use size_prefixed_root_as_feature_unchecked.
  • Assumes, without verification, that a buffer of bytes contains a size prefixed Feature and returns it.
  • Verifies, with the given verifier options, that a buffer of bytes contains a size prefixed Feature and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use root_as_feature_unchecked.
  • Verifies that a buffer of bytes contains a size prefixed Header and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use size_prefixed_root_as_header_unchecked.
  • Assumes, without verification, that a buffer of bytes contains a size prefixed Header and returns it.
  • Verifies, with the given verifier options, that a buffer of bytes contains a size prefixed Header and returns it. Note that verification is still experimental and may not catch every error, or be maximally performant. For the previous, unchecked, behavior use root_as_header_unchecked.

Type Aliases§