3104{
3106 bool fits = PG_GETARG_BOOL(1);
3107 LWGEOM *lwgeom_out = NULL;
3108
3110 int hasz;
3111 int hasm;
3112 int32_t srid;
3113
3116
3117 if (fits)
3118 {
3119 GSERIALIZED *geom_in = PG_GETARG_GSERIALIZED_P(0);
3124 srid = lwgeom_in->
srid;
3125 }
3126 else
3127 {
3134 {
3136 }
3137 }
3138
3139 if (!lwgeom_out)
3140 {
3153 }
3154
3155 geom_out = geometry_serialize(lwgeom_out);
3157
3158 PG_RETURN_POINTER(geom_out);
3159}
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_datum_get_internals_p(Datum gsdatum, GBOX *gbox, lwflags_t *flags, uint8_t *type, int32_t *srid)
Peak into a GSERIALIZED datum to find its bounding box and some other metadata.
void lwgeom_free(LWGEOM *geom)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
#define FLAGS_GET_Z(flags)
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
#define FLAGS_GET_M(flags)
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
LWGEOM * lwgeom_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
#define LW_TRUE
Return types for functions with status returns.