From c5019f6762cc4ac4cfe131816dd4ffa67b5274dd Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 6 Oct 2011 13:35:46 +0000 Subject: [PATCH] Add clamp_srid internal function returning UNKNOWN for <= 0 values. git-svn-id: http://svn.osgeo.org/postgis/trunk@7954 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/liblwgeom_internal.h | 16 ++++++++++++---- liblwgeom/lwutil.c | 7 +++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/liblwgeom/liblwgeom_internal.h b/liblwgeom/liblwgeom_internal.h index 8ac7ce024..1ee1f7916 100644 --- a/liblwgeom/liblwgeom_internal.h +++ b/liblwgeom/liblwgeom_internal.h @@ -1,11 +1,12 @@ /********************************************************************** - * $Id: liblwgeom_internal.h 4497 2009-09-14 18:33:54Z pramsey $ * * PostGIS - Spatial Types for PostgreSQL * http://postgis.refractions.net - * Copyright 2001-2006 Refractions Research Inc. - * Copyright 2007-2008 Mark Cave-Ayland - * Copyright 2008 Paul Ramsey + * + * Copyright (C) 2001-2006 Refractions Research Inc. + * Copyright (C) 2007-2008 Mark Cave-Ayland + * Copyright (C) 2008 Paul Ramsey + * Copyright (C) 2011 Sandro Santilli * * This is free software; you can redistribute and/or modify it under * the terms of the GNU General Public Licence. See the COPYING file. @@ -114,6 +115,13 @@ #define SIZE_SET(varsize, size) (((varsize) & 0x00000003)|(((size) & 0x3FFFFFFF) << 2 )) +/* + * Return a valid srid from an arbitrary integer, + * raising a notice if what comes out is different from + * what went in. + */ +int clamp_srid(int srid); + /* * Internal prototypes */ diff --git a/liblwgeom/lwutil.c b/liblwgeom/lwutil.c index d47e8bfce..3cf389aa6 100644 --- a/liblwgeom/lwutil.c +++ b/liblwgeom/lwutil.c @@ -369,3 +369,10 @@ error_if_srid_mismatch(int srid1, int srid2) lwerror("Operation on mixed SRID geometries"); } } + +int +clamp_srid(int srid) +{ + if ( srid <= 0 ) return SRID_UNKNOWN; + return srid; +} -- 2.50.0