From 0ffd09fc6f275fa40f90e8069c536c28b3a8df62 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Wed, 1 Oct 2014 23:08:07 +0000 Subject: [PATCH] #2941, Geography can create a non-4326 geography but geography typmod won't allow it git-svn-id: http://svn.osgeo.org/postgis/trunk@13027 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis/gserialized_typmod.c | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/postgis/gserialized_typmod.c b/postgis/gserialized_typmod.c index 77c3f362e..caa669df9 100644 --- a/postgis/gserialized_typmod.c +++ b/postgis/gserialized_typmod.c @@ -29,6 +29,7 @@ #include "lwgeom_pg.h" /* For debugging macros. */ #include "geography.h" /* For utility functions. */ #include "lwgeom_export.h" /* For export functions. */ +#include "lwgeom_transform.h" /* for srid_is_latlon */ Datum geography_typmod_in(PG_FUNCTION_ARGS); @@ -241,33 +242,8 @@ static uint32 gserialized_typmod_in(ArrayType *arr, int is_geography) POSTGIS_DEBUGF(3, "srid: %d", srid); if ( srid != SRID_UNKNOWN ) { - /* TODO: Check that the value - * provided is in fact a lonlat - * entry in spatial_ref_sysj - */ - /* For now, we only accept SRID_DEFAULT. */ - if ( is_geography && srid != SRID_DEFAULT ) - { - ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("Currently, only %d is accepted as an SRID for GEOGRAPHY", SRID_DEFAULT))); - } - else - { - TYPMOD_SET_SRID(typmod, srid); - } + TYPMOD_SET_SRID(typmod, srid); } -#if 0 /* keep the default instead */ - else - { - if ( is_geography ) - { - ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("UNKNOWN SRID is not for GEOGRAPHY"))); - } - } -#endif /* keep the default for unknown */ } } @@ -286,6 +262,10 @@ Datum geography_typmod_in(PG_FUNCTION_ARGS) { ArrayType *arr = (ArrayType *) DatumGetPointer(PG_GETARG_DATUM(0)); uint32 typmod = gserialized_typmod_in(arr, LW_TRUE); + int srid = TYPMOD_GET_SRID(typmod); + /* Check the SRID is legal (geographic coordinates) */ + srid_is_latlong(fcinfo, srid); + PG_RETURN_INT32(typmod); } -- 2.50.1