PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ gserialized_geography_from_lwgeom()

GSERIALIZED * gserialized_geography_from_lwgeom ( LWGEOM lwgeom,
int32  geog_typmod 
)

Definition at line 74 of file geography_inout.c.

References geography_in(), geography_valid_type(), LW_TRUE, lwgeom_force_geodetic(), lwgeom_nudge_geodetic(), lwgeom_set_geodetic(), PG_FUNCTION_INFO_V1(), postgis_valid_typmod(), LWGEOM::srid, SRID_DEFAULT, and LWGEOM::type.

Referenced by geography_from_binary(), geography_from_text(), geography_in(), and geography_recv().

75 {
76  GSERIALIZED *g_ser = NULL;
77 
78  /* Set geodetic flag */
79  lwgeom_set_geodetic(lwgeom, true);
80 
81  /* Check that this is a type we can handle */
82  geography_valid_type(lwgeom->type);
83 
84  /* Force the geometry to have valid geodetic coordinate range. */
85  lwgeom_nudge_geodetic(lwgeom);
86  if ( lwgeom_force_geodetic(lwgeom) == LW_TRUE )
87  {
88  ereport(NOTICE, (
89  errmsg_internal("Coordinate values were coerced into range [-180 -90, 180 90] for GEOGRAPHY" ))
90  );
91  }
92 
93  /* Force default SRID to the default */
94  if ( (int)lwgeom->srid <= 0 )
95  lwgeom->srid = SRID_DEFAULT;
96 
97  /*
98  ** Serialize our lwgeom and set the geodetic flag so subsequent
99  ** functions do the right thing.
100  */
101  g_ser = geography_serialize(lwgeom);
102 
103  /* Check for typmod agreement */
104  if ( geog_typmod >= 0 )
105  {
106  g_ser = postgis_valid_typmod(g_ser, geog_typmod);
107  POSTGIS_DEBUG(3, "typmod and geometry were consistent");
108  }
109  else
110  {
111  POSTGIS_DEBUG(3, "typmod was -1");
112  }
113 
114  return g_ser;
115 }
GSERIALIZED * postgis_valid_typmod(GSERIALIZED *gser, int32_t typmod)
Check the consistency of the metadata we want to enforce in the typmod: srid, type and dimensionality...
#define SRID_DEFAULT
Definition: liblwgeom.h:179
int lwgeom_nudge_geodetic(LWGEOM *geom)
Gently move coordinates of LWGEOM if they are close enough into geodetic range.
Definition: lwgeodetic.c:2991
int32_t srid
Definition: liblwgeom.h:383
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
int lwgeom_force_geodetic(LWGEOM *geom)
Force coordinates of LWGEOM into geodetic range (-180, -90, 180, 90)
Definition: lwgeodetic.c:2809
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
Definition: lwgeom.c:858
void geography_valid_type(uint8_t type)
The geography type only support POINT, LINESTRING, POLYGON, MULTI* variants of same, and GEOMETRYCOLLECTION.
uint8_t type
Definition: liblwgeom.h:380
Here is the call graph for this function:
Here is the caller graph for this function: