61 bool use_spheroid =
true;
65 g = PG_GETARG_GSERIALIZED_P(0);
80 g_out = geography_serialize(lwgeom_out);
81 PG_RETURN_POINTER(g_out);
85 spheroid_init_from_srid(fcinfo, srid, &
s);
88 use_spheroid = PG_GETARG_BOOL(1);
107 uint32_t size = mpoints->
ngeoms;
111 for (i = 0; i < size; i++) {
162 elog(ERROR,
"ST_Centroid(geography) unhandled geography type");
166 PG_FREE_IF_COPY(g, 0);
169 g_out = geography_serialize(lwgeom_out);
171 PG_RETURN_POINTER(g_out);
LWPOINT * geography_centroid_from_mpoly(const LWMPOLY *mpoly, bool use_spheroid, SPHEROID *s)
Split polygons into triangles and use centroid of the triangle with the triangle area as weight to ca...
LWPOINT * geography_centroid_from_mline(const LWMLINE *mline, SPHEROID *s)
Split lines into segments and calculate with middle of segment as weighted point.
LWPOINT * geography_centroid_from_wpoints(const int32_t srid, const POINT3DM *points, const uint32_t size)
Convert lat-lon-points to x-y-z-coordinates, calculate a weighted average point and return lat-lon-co...
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
void lwmpoly_free(LWMPOLY *mpoly)
double lwpoint_get_x(const LWPOINT *point)
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
LWMPOLY * lwgeom_as_lwmpoly(const LWGEOM *lwgeom)
LWMLINE * lwmline_construct_empty(int32_t srid, char hasz, char hasm)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
LWMLINE * lwgeom_as_lwmline(const LWGEOM *lwgeom)
LWMPOLY * lwmpoly_add_lwpoly(LWMPOLY *mobj, const LWPOLY *obj)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
void lwmline_free(LWMLINE *mline)
LWPOLY * lwgeom_as_lwpoly(const LWGEOM *lwgeom)
LWMPOLY * lwmpoly_construct_empty(int32_t srid, char hasz, char hasm)
double lwpoint_get_y(const LWPOINT *point)
static uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.