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§
pub use geozero;
Modules§
- Create and read a packed Hilbert R-Tree to enable fast bounding box spatial filtering.
Structs§
- Access to current feature
- FlatGeobuf dataset reader
- FlatGeobuf dataset writer
- Options for FlatGeobuf writer
- FlatGeobuf dataset HTTP reader
Enums§
Constants§
- ENUM_MAX_COLUMN_TYPEDeprecated
- ENUM_MAX_GEOMETRY_TYPEDeprecated
- ENUM_MIN_COLUMN_TYPEDeprecated
- ENUM_MIN_GEOMETRY_TYPEDeprecated
- ENUM_VALUES_COLUMN_TYPEDeprecated
- ENUM_VALUES_GEOMETRY_TYPEDeprecated
Traits§
- A fallible, streaming iterator.
- Feature processing API
- Feature properties processing API
- Geometry processing trait.
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 useroot_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 useroot_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 useroot_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 useroot_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 usesize_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 useroot_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 usesize_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 useroot_as_header_unchecked
.