Closed michaelkirk closed 3 years ago
Some combination of 2 and 3 seems like a good approach to me too. It would be good to convert POINT EMPTY
to geo_types::MultiPoint([])
wherever the context allows it. That way, when we convert back to wkt, the type of the object is reasonably maintained. So POINT EMPTY
-> geo_types::MultiPoint([])
-> MULTIPOINT EMPTY
instead of GEOMETRYCOLLECTION EMPTY
.
That way, when we convert back to wkt, the type of the object is reasonably maintained.
Good Point<T>
! 😐
One point of friction when mapping WKT to geo_types is
POINT EMPTY
.Similar EMPTY types present no such problem:
GEOMETRYCOLLECTION EMPTY
,LINESTRING EMPTY
,POLYGON EMPTY
all have intuitive corollaries in geo_types. (GeometryCollection(vec![])
,LineString(vec![])
,Polygon { exterior: vec![], interiors: vec![] }
You might say:
To which I say:
The conversion of which is not obvious to me.
A few options:
Do nothing. Whenever converting to geo-types, continue to error whenever we encounter a
POINT EMPTY
, force the caller to reconcile any confusion. This is great because we wash our hands of the problem, but I think we'd be doing a disservice to, as policy, force every user to re-invent this essential wheel from scratch.add a
deserialize_point -> Option<geo_types::Point>
method to complementdeserialize_geometry
.This would only solve the top level
POINT EMPTY
case, and would continue to error onGEOMETRYCOLLECTION(POINT EMPTY)
case. Would this half measure be worthwhile or only amplify the confusion?POINT EMPTY
toGEOMETRYCOLLECTION EMPTY
. This is at first a confusing alternative, but neatly makes a bunch of stuff "Just work". That is, parsing can continue, and, as far as I know, there are no operations for which aGEOMETRYCOLLECTION EMPTY
would behave differently from aPOINT EMPTY
. It just "feels weird" to lose that type information. FWIW, I think this is the approach postgis takes. You can read some rationale from https://gis.stackexchange.com/a/106942:deserialize_point -> Option<Point>
method, but when encountering an internal Point, as inGEOMETRYCOLLETION(POINT 1 1, POINT EMPTY)
convert it toGEOMETRYCOLLETION(POINT 1 1, GEOMETRYCOLLETION EMPTY)
. That seems preferable to discarding it sinceGEOMETRYCOLLECTION(POINT 1 1)
would have an observably different member count.