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

Fix writing WKT with z/m dimensions #237

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

kylebarron
Copy link
Member

No description provided.

@@ -35,7 +35,7 @@ pub(crate) mod conversion {
}

fn to_ewkt(&self, srid: Option<i32>) -> Result<String> {
self.to_wkt_with_opts(WktDialect::Ewkt, CoordDimensions::xyzm(), srid)
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure the right way to fix this, but as I understand it, setting CoordDimensions says "this output will have these given geometries", and so defaulting to xyzm seems incorrect.


let geojson = r#"{"type": "LineString", "coordinates": [[1,1],[2,2]]}"#;
let mut wkt_data: Vec<u8> = Vec::new();
let mut out = WktWriter::with_dims(&mut wkt_data, CoordDimensions::xyz());
let mut out = WktWriter::with_dims(&mut wkt_data, CoordDimensions::xy());
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what this is supposed to test. Is it supposed to test that setting xyz doesn't matter? I thought at first below was a typo and that the LineString was meant to be 3d, but this entire test is otherwise the exact same as the one before it.

Comment on lines +276 to +279
let ewkt = Ewkb(blob)
.to_wkt_with_opts(WktDialect::Ewkt, CoordDimensions::xyz(), Some(4326))
.unwrap();
assert_eq!(ewkt, "SRID=4326;MULTIPOINT Z(10 -20 100,0 -0.5 101)")
Copy link
Member Author

Choose a reason for hiding this comment

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

Similarly, the API just isn't sufficient... There's no way to get the coordinate dimension from the EWKB without consuming it. And so there's no way right now to know the SRID and CoordDimensions of the input and pass that on to the writer at the beginning.

michaelkirk
michaelkirk previously approved these changes Sep 18, 2024
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.

These changes seem reasonable, but I didn't write the original code, so I'm not sure of the original motivations.

@michaelkirk
Copy link
Member

That failing test looks significant:

left: "POLYHEDRALSURFACE Z( Z( Z(0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)), Z( Z(0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)), Z( Z(0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)), Z( Z(1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)), Z( Z(0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)), Z( Z(0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)))"

@kylebarron
Copy link
Member Author

My initial reaction is that it's really hard to fix ZM handling in isolation because it needs some bigger architectural changes to geozero

@michaelkirk
Copy link
Member

My initial reaction is that it's really hard to fix ZM handling in isolation

I don't doubt it! It leaves me not sure what to do about this PR though.

@michaelkirk michaelkirk dismissed their stale review September 18, 2024 17:20

Not sure what to do about that failing test.

kylebarron added a commit to geoarrow/geoarrow-rs that referenced this pull request Sep 26, 2024
### Change list

- Convert geo-traits scalars to `wkt::Wkt`
- This is prep work for direct transformation of geoarrow scalars to
`wkt::Wkt` objects.
- This does not go through geozero, partially because I hit issues with
multidimensional writing in georust/geozero#237
- This supersedes #788,
though it hasn't yet piped through to a full `ToWkt` trait implemented
on arrays. cc @b4l
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