fix: SRID extraction returns NULL for a valid authority-less CRS - #1108
fix: SRID extraction returns NULL for a valid authority-less CRS#1108james-willis wants to merge 1 commit into
Conversation
…y-less CRS A valid CRS with no top-level authority code (e.g. a custom polar-stereographic WKT from CF/rioxarray) is fully usable but has no EPSG/SRID. CachedCrsToSRIDMapping:: get_srid now returns Result<Option<u32>>, yielding None for such a CRS instead of erroring; RS_SRID and ST_SRID surface that None as NULL. Only a genuinely malformed CRS string still errors (propagated from deserialize_crs). Authority-coded CRSes continue to return their integer SRID.
paleolimbot
left a comment
There was a problem hiding this comment.
No notes on the implementation, but do we want this? We could also update the error to say "Use ST_Crs() instead of ST_SRID() to support CRSes without authority/code or with a non-EPSG authority"?
|
I think this is the right thing. 2 reasons:
|
It's true that there's no other way to check if an item has a CRS that is identifiable (we could add
Yes, but they may get bogus results. For example We could also put in the documentation of |
|
I think the round trip example is contrived and I'm not worried about it. Maybe ST_SetSRID or ST_Intersects should be the one that rejects null CRS/SRID instead. I'm imagining users who want to filter on the presence of a CRS with a SRID, so they can get rid of SRID-less rows (CRSes with no SRID) |
How about this one:
Maybe, although there is precedent for our current behaviour (Sedona and PostGIS accept and propagate nulls with SQL semantics).
On the day we're asked for that feature we can always add a function (maybe |
A valid CRS with no top-level authority code (e.g. a custom polar-stereographic WKT from CF/rioxarray) is fully usable but has no EPSG/SRID.
RS_SRID/ST_SRIDon such a CRS now return NULL instead of erroring; a genuinely malformed CRS string still errors, and an authority-coded CRS still returns its integer SRID.