[postgis-devel] Motion approved: SRID <= 0 as UNKNOWN (+ thoughts)
strk at keybit.net
Thu Oct 6 06:59:03 PDT 2011
So, with this SRID <= 0 is officially UNKNOWN.
Let's see the consequences of this (a few thoughts).
In input, we can convert any literal SRID <= 0 to our internal
rapresentation for UNKNOWN.
At the SQL level SRID input can occur in:
- EWKT/EWKB parsing
- Constructors taking SRID value as argument (GeomFromXXY)
- Explicit setting (ST_SetSRID)
All of the SQL level results in convertion to the deserialized level
(LWGEOM). At that level, we are currently required to encode SRID
as an integer. That integer will be our LWGEOM-level representation
for UNKNOWN. It's currently defined by a SRID_UNKNOWN macro.
The same literal value we're required to output from ST_SRID
(since nobody liked returning NULL...)
Serialized format has support for omitting the SRID completely, and
that'd be our serialized-level representation for UNKNOWN.
I've committed a clamp_srid function converting <=0 numbers to SRID_UNKNOWN.
We may use it wherever we want to ensure correct interpretation is given
to the number. I've added use of it in EWKT/EWKB parser, but there are
other means to inject <=0 srids, as shown above.
I guess tweaking the _serializer_ and _deserializer_ would give us the
widest coverage at the storage level and allow for easily "clean"
geometries serialized with explicit negative srids as appropriate with
a single round trip (postgis_noop?). But as we've a LWGEOM level to deal
with too, I'd like to find a way to ensure things are straight also
at _that_ level.
Also, it might be helpful to catch non-conformant unknown srid values as
soon as possible in query chains for the sake of raising a WARNING or NOTICE
thus helping PostGIS clients to conform.
If we accept them silently the user will be confused as of why
ST_SRID(ST_SETSDIR(g, -2)) gives something != -2.
A warning message would also instruct the caller about the value
of SRID_UNKNOWN as that value is, after all, exposed by ST_SRID().
We could put such a warning within clamp_srid.
() Free GIS & Flash consultant/developer
More information about the postgis-devel