-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation for basic usage of geozero-shp #86
Comments
I'm going to move your issue to the geozero repository, since it seems to be about geozero. |
It is indeed about geozero-shp. I had multiple tabs opened with Rust |
There is a test for converting Shp to GeoJSON: geozero/geozero-shp/tests/reader.rs Line 49 in f8bcaaa
|
Hey, are there any updates on this? I created a new project, copied the test you mentioned in there and renamed it to However, the tests are passing and if I use the test as To reproduce, create a new binary with:
[package]
name = "geozero-test"
version = "0.1.0"
edition = "2021"
[dependencies]
geozero-shp = "0.4"
geozero = "0.11"
use geozero::geojson::GeoJsonWriter;
use std::str::from_utf8;
fn main() -> Result<(), geozero_shp::Error> {
let reader = geozero_shp::Reader::from_path("./tests/data/poly.shp")?;
let mut json: Vec<u8> = Vec::new();
let cnt = reader
.iter_features(&mut GeoJsonWriter::new(&mut json))?
.count();
assert_eq!(cnt, 10);
assert_eq!(
&from_utf8(&json).unwrap()[0..80],
r#"{
"type": "FeatureCollection",
"features": [{"type": "Feature", "properties": {""#
);
assert_eq!(
&from_utf8(&json).unwrap()[json.len()-100..],
"2],[479658.59375,4764670],[479640.09375,4764721],[479735.90625,4764752],[479750.6875,4764702]]]]}}]}"
);
Ok(())
} Edit: Using Rust 1.74 |
I just tried it, this is indeed really weird! Debugging... but if anyone has any ideas, please post |
Ah, silly me - I think you are copy/pasting test code from a development (unpublished) version. When I added this to cargo.toml, it worked (I have geozero cloned in a parallel dir). I think all this was done by @michaelkirk in bee32bc [patch.crates-io]
geozero = { path = "../../geozero/geozero" }
geozero-shp = { path = "../../geozero/geozero-shp" } |
Ah that makes sense, I did not work with patching yet. Thanks for the fast reponse! |
Just don't use it for any production code :) Patching is for experiments, and for when you have multiple crates in the same repo that depend on one another, and you need to modify them at the same time. |
Ok nice to know. I am now using |
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:
and when I run it, it doesn't seem that
GeoJsonWriter
is a valid thing to pass to theprocessor
argument:Is there any documentation or code examples where I can see how this crate is used?
Thank you.
The text was updated successfully, but these errors were encountered: