geozero
geozero copied to clipboard
Documentation for basic usage of geozero-shp
Hello, and thank you for this project.
I am trying to do a simple newbie program that, given an ESRI Shapefile as input, it outputs the geometries as GeoJSON.
I have been trying to use the geozero-shp crate, simply following the short example that can be found on its README, without any luck. It seems the example is incorrect, or it might have been outdated by outer changes on its dependencies.
I wrote this program:
use geozero::geojson::GeoJsonWriter;
fn main() {
let path = "/home/jose/Downloads/ne_10m_admin_0_sovereignty/ne_10m_admin_0_sovereignty.shp";
let reader = geozero_shp::Reader::from_path(path).unwrap();
let mut json: Vec<u8> = Vec::new();
let data = reader.iter_features(GeoJsonWriter::new(&mut json)).unwrap();
}
and when I run it, it doesn't seem that GeoJsonWriter
is a valid thing to pass to the processor
argument:
jose@uranium ~/C/e/shp_ingestor (master) [101]> cargo run -- /home/jose/Downloads/ne_10m_admin_0_sovereignty/ne_10m_admin_0_sovereignty.shp
Compiling shp_ingestor v0.1.0 (/home/jose/Code/experimental/shp_ingestor)
error[E0277]: the trait bound `GeoJsonWriter<'_, Vec<u8>>: geozero::feature_processor::FeatureProcessor` is not satisfied
--> src/main.rs:8:37
|
8 | let data = reader.iter_features(GeoJsonWriter::new(&mut json)).unwrap();
| ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `geozero::feature_processor::FeatureProcessor` is not implemented for `GeoJsonWriter<'_, Vec<u8>>`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `geozero::feature_processor::FeatureProcessor`:
geozero::ProcessorSink
geozero::multiplex::Multiplexer<P1, P2>
note: required by a bound in `Reader::<T>::iter_features`
--> /home/jose/.cargo/registry/src/github.com-1ecc6299db9ec823/geozero-shp-0.3.1/src/reader.rs:161:29
|
161 | pub fn iter_features<P: FeatureProcessor>(
| ^^^^^^^^^^^^^^^^ required by this bound in `Reader::<T>::iter_features`
error[E0277]: the trait bound `GeoJsonWriter<'_, Vec<u8>>: geozero::feature_processor::FeatureProcessor` is not satisfied
--> src/main.rs:8:16
|
8 | let data = reader.iter_features(GeoJsonWriter::new(&mut json)).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `geozero::feature_processor::FeatureProcessor` is not implemented for `GeoJsonWriter<'_, Vec<u8>>`
|
= help: the following other types implement trait `geozero::feature_processor::FeatureProcessor`:
geozero::ProcessorSink
geozero::multiplex::Multiplexer<P1, P2>
note: required by a bound in `ShapeRecordIterator`
--> /home/jose/.cargo/registry/src/github.com-1ecc6299db9ec823/geozero-shp-0.3.1/src/reader.rs:39:35
|
39 | pub struct ShapeRecordIterator<P: FeatureProcessor, T: Read + Seek> {
| ^^^^^^^^^^^^^^^^ required by this bound in `ShapeRecordIterator`
For more information about this error, try `rustc --explain E0277`.
error: could not compile `shp_ingestor` due to 2 previous errors
Is there any documentation or code examples where I can see how this crate is used?
Thank you.