[postgis-users] find_srid and null values

Nicolas RIBOT nri at scot.cnes.fr
Mon Aug 26 09:26:35 PDT 2002


Hi all,

I have a question concerning the find_srid() function.
This function returns null if there are no entries in the
spatial_ref_sys OpenGIS metadata table.

By default (or habit), geometries constructed with no relevant
projection system are assigned -1 for their SRID.

I'm using a Java program to update such geometries. To be generic, this
program uses the following query to update a geometry:

update <table_name> 
set <geo_column>=geometryFromText('POLYGON((....))',
 	find_srid('<database>','<table_name>','<geo_column')) where
oid=xxx

In this case, the find_srid produces a null result, geometryFromText
too, and this leads to the removal of the geometry in the table
(geo_column set to null).

What would be the best solution ?:
	Changing find_srid to return -1 when no projection info is
found,
	or changing addGeometryColumn() to automatically add an entry to
spatial_ref_sys if called with an unknown SRID ?

The problem is that it is possible to create a table and to call
addGeometryColumn() on it, setting an SRID to -1 even if their is no
corresponding entry in the spatial_ref_sys table.

I could, of course, make 2 queries: the first one retrieving the SRID,
the second one udpating the row, but It would be slower.

Any suggestion ?

Thanx,
Nicolas Ribot




More information about the postgis-users mailing list