georust / geozero

Zero-Copy reading and writing of geospatial data.
Apache License 2.0
342 stars 35 forks source link

GeometryCollection.to_geo() returns only the last geometry #11

Closed audunska closed 2 years ago

audunska commented 3 years ago

We hit upon this by passing geometries from postgres using geozero: When a GeometryCollection is stored as a postgis Geometry field in the database, and fetched through geozero using the Decode impl, only the last geometry was returned. I'd expect the full collection to be returned instead.

Reproducing repository: https://github.com/audunska/geozero-bug

pka commented 3 years ago

GeoWriter does not support geometry collections yet. Does your sequence work with wkb.to_json() instead of wkb.to_geo()?

audunska commented 3 years ago

Thanks for the reply!

GeoWriter does not support geometry collections yet.

In that case it would be nice to have an error instead of just writing wrong data. We spent some time chasing down this. Is this documented anywhere?

Does your sequence work with wkb.to_json() instead of wkb.to_geo()?

That seems to work, yes.

michaelkirk commented 2 years ago

I hit this while working on #19

I updated the title to clarify it's about the target (.to_geo) not the source (WKB or WKT)

audunska commented 2 years ago

I've been contemplating fixing this a few times. We'd need a stack of geometries in GeoWriter, and it gets into some tricky state machine logic. Is it acceptable to extend the GeoWriter with a stack?

pka commented 2 years ago

I've been contemplating fixing this a few times. We'd need a stack of geometries in GeoWriter, and it gets into some tricky state machine logic. Is it acceptable to extend the GeoWriter with a stack?

A geometry stack is acceptable (and with line_strings we already have kind of a stack).

michaelkirk commented 2 years ago

Hi @audunska - is this something you're actively working on?

If so, I'm happy to wait a bit longer, otherwise I might take a pass at it.

audunska commented 2 years ago

Hi @audunska - is this something you're actively working on?

If so, I'm happy to wait a bit longer, otherwise I might take a pass at it.

I am not working on it right now, so please go ahead!