201{
208 int output_guess_short_srid =
LW_FALSE;
209 const char *srs = NULL;
210 int32_t srid;
211
212
213 if (PG_ARGISNULL(0))
214 PG_RETURN_NULL();
215
216 geom = PG_GETARG_GSERIALIZED_P(0);
218
219
220 if ( PG_NARGS() > 1 && !PG_ARGISNULL(1) )
221 {
223 }
224
225
226
227
228
229
230
231
232 if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
233 {
234 int option = PG_GETARG_INT32(2);
239 }
240 else
241 output_guess_short_srid =
LW_TRUE;
242
245
246 if (srid !=
SRID_UNKNOWN && (output_short_crs || output_long_crs))
247 {
248 srs = GetSRSCacheBySRID(fcinfo, srid, !output_long_crs);
249
250 if (!srs)
251 {
252 elog(ERROR, "SRID %i unknown in spatial_ref_sys table", srid);
253 PG_RETURN_NULL();
254 }
255 }
256
259}
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
lwvarlena_t * lwgeom_to_geojson(const LWGEOM *geo, const char *srs, int precision, int has_bbox)
Takes a GEOMETRY and returns a GeoJson representation.
#define LW_TRUE
Return types for functions with status returns.
#define SRID_UNKNOWN
Unknown SRID value.
#define OUT_DEFAULT_DECIMAL_DIGITS