Skip to content
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

geojson lines writer #193

Merged
merged 6 commits into from
Feb 9, 2024
Merged

Conversation

kylebarron
Copy link
Member

@kylebarron kylebarron commented Jan 17, 2024

This works for features but not geometries because it's hard to know when to insert the \n to end the line.

Copy link
Member

@michaelkirk michaelkirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, sorry that this sat here so long. I forgot about it.

Feel free to merge after addressing that last small change.

geozero/src/geojson/geojson_line_writer.rs Show resolved Hide resolved
@kylebarron
Copy link
Member Author

It turns out that passing idx instead of 0 fails the test for the feature, but it also doesn't pass the geometry test. For example, when logging to stdout I see:

failures:

---- geojson::geojson_line_writer::tests::good_geometries stdout ----
a: {"type": "Point", "coordinates": [1.1,1.2]}
b: { "type": "Point", "coordinates": [1.1, 1.2] }
a: ,{"type": "Point", "coordinates": [2.1,2.2]}
b: { "type": "Point", "coordinates": [2.1, 2.2] }
thread 'geojson::geojson_line_writer::tests::good_geometries' panicked at geozero/src/geojson/geojson_line_writer.rs:227:73:
called `Result::unwrap()` on an `Err` value: Error("expected value", line: 1, column: 1)

Because the idx passed into begin_point is >0, a comma gets added here

fn comma(&mut self, idx: usize) -> Result<()> {
if idx > 0 {
self.out.write_all(b",")?;
}
Ok(())
}

@kylebarron
Copy link
Member Author

kylebarron commented Feb 8, 2024

I found a workaround and added a comment. Let me know if that solution is ok. Also, I don't have merge access.

@michaelkirk michaelkirk merged commit 0fc71ba into georust:main Feb 9, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants