[postgis-devel] SRID ranges

Sandro Santilli strk at keybit.net
Fri Feb 10 04:25:20 PST 2012


So, we need to define some ranges for SRID values.
We have 24-bits assigned to SRID value in the typmod.
Those bits allow for 0 .. 16,777,215.
That's the full capacity.

Actually the current implementation is for SRID only taking
up 21 bits while keeping 1-bit for sign and 2 spare bits.
The sign bit we shouldn't be needing anymore since every
negative SRID is being converted to the unknown one (0).
The two spare bits may be useful for a future extension
in the serialized format w/out requiring dump/reload, but
the same could be derived from the type bitfield (6 bits
== 64 allowed types of which we only use 16 [which only
need 4 of those 6 bits])

Internally, we have a set of SRIDS which we don't lookup
into spatial_ref_sys but assign a special meaning to.
They go from 999000 to 999162. They could eventually expand
but most likely 200 slots are enough. 

The maximum SRID in our current spatial_ref_sys.sql is 900913.

So, current situation:

   0                       : unknown SRID
   1          -    900,913 : standard SRIDs
   900,913    -    998,999 : user SRIDs (up to spatial_ref_sys limit)
   999,000    -    999,162 : internally interpreted 
   999,163    -  2,097,152 : wasted (up to 21bit)
 2,097,153    - 16,777,215 : wasted (up to 24bit)

You can see most of the space is just wasted.

We should aim for a better balance, and possibly raising up
the SRID limit to account for user values in dumps exceeding
the syntetic 998999 limit in the new spatial_ref_sys [1]
[1] http://trac.osgeo.org/postgis/ticket/1505

I'll start with a couple of example proposal:

[Keeping the 21bit limit]
    0                       : unknown SRID
    1          -  1,000,000 : standard SRIDs
  1,000,001    -  2,000,000 : user SRIDs (up to spatial_ref_sys limit)
  2,000,001    -  2,097,152 : internally interpreted 

[Using all the 24 bits]
    0                       : unknown SRID
    1          -  1,000,000 : standard SRIDs
  1,000,001    - 16,000,000 : user SRIDs (up to spatial_ref_sys limit)
 16,000,001    - 16,777,215 : internally interpreted 

We'd still have an upper limit on spatial_ref_sys but would be larger
than the current 998,999 (2,000,000 or 16,000,000).

What do you think ?

--strk; 

  ,------o-. 
  |   __/  |    Delivering high quality PostGIS 2.0 !
  |  / 2.0 |    http://strk.keybit.net
  `-o------'




More information about the postgis-devel mailing list