PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ clamp_srid()

int32_t clamp_srid ( int32_t  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 339 of file lwutil.c.

340 {
341  int newsrid = srid;
342 
343  if ( newsrid <= 0 ) {
344  if ( newsrid != SRID_UNKNOWN ) {
345  newsrid = SRID_UNKNOWN;
346  lwnotice("SRID value %d converted to the officially unknown SRID value %d", srid, newsrid);
347  }
348  } else if ( srid > SRID_MAXIMUM ) {
349  newsrid = SRID_USER_MAXIMUM + 1 +
350  /* -1 is to reduce likelihood of clashes */
351  /* NOTE: must match implementation in postgis_restore.pl */
352  ( srid % ( SRID_MAXIMUM - SRID_USER_MAXIMUM - 1 ) );
353  lwnotice("SRID value %d > SRID_MAXIMUM converted to %d", srid, newsrid);
354  }
355 
356  return newsrid;
357 }
#define SRID_USER_MAXIMUM
Maximum valid SRID value for the user We reserve 1000 values for internal use.
Definition: liblwgeom.h:212
#define SRID_MAXIMUM
Maximum allowed SRID value in serialized geometry.
Definition: liblwgeom.h:206
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:215
void lwnotice(const char *fmt,...)
Definition: lwutil.c:177

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

Referenced by gserialized1_set_srid(), gserialized2_set_srid(), gserialized_typmod_in(), lwgeom_from_wkb_state(), RASTER_asGDALRaster(), RASTER_asRaster(), RASTER_clip(), RASTER_Contour(), 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().

Here is the call graph for this function:
Here is the caller graph for this function: