PostGIS  2.3.7dev-r@@SVN_REVISION@@
int clamp_srid ( int  srid)

Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from what went in.

Raises an error if SRID value is out of bounds.

Definition at line 378 of file lwutil.c.

References lwnotice(), SRID_MAXIMUM, SRID_UNKNOWN, and SRID_USER_MAXIMUM.

Referenced by gserialized_get_srid(), gserialized_set_srid(), gserialized_typmod_in(), lwgeom_from_wkb_state(), RASTER_asGDALRaster(), RASTER_asRaster(), RASTER_clip(), RASTER_fromGDALRaster(), RASTER_GDALWarp(), RASTER_nearestValue(), RASTER_setPixelValuesGeomval(), rt_raster_from_wkb(), rt_raster_get_srid(), rt_raster_set_srid(), and wkt_lexer_read_srid().

379 {
380  int newsrid = srid;
381 
382  if ( newsrid <= 0 ) {
383  if ( newsrid != SRID_UNKNOWN ) {
384  newsrid = SRID_UNKNOWN;
385  lwnotice("SRID value %d converted to the officially unknown SRID value %d", srid, newsrid);
386  }
387  } else if ( srid > SRID_MAXIMUM ) {
388  newsrid = SRID_USER_MAXIMUM + 1 +
389  /* -1 is to reduce likelyhood of clashes */
390  /* NOTE: must match implementation in postgis_restore.pl */
391  ( srid % ( SRID_MAXIMUM - SRID_USER_MAXIMUM - 1 ) );
392  lwnotice("SRID value %d > SRID_MAXIMUM converted to %d", srid, newsrid);
393  }
394 
395  return newsrid;
396 }
#define SRID_USER_MAXIMUM
Maximum valid SRID value for the user We reserve 1000 values for internal use.
Definition: liblwgeom.h:184
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:187
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:89
#define SRID_MAXIMUM
Maximum allowed SRID value in serialized geometry.
Definition: liblwgeom.h:178

Here is the call graph for this function:

Here is the caller graph for this function: