PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwgeom_pointonsurface()

LWGEOM * lwgeom_pointonsurface ( const LWGEOM geom)

Definition at line 1006 of file liblwgeom/lwgeom_geos.c.

1007{
1008 LWGEOM *result;
1009 int32_t srid = RESULT_SRID(geom);
1010 uint8_t is3d = FLAGS_GET_Z(geom->flags);
1011 GEOSGeometry *g1, *g3;
1012
1013 if (srid == SRID_INVALID) return NULL;
1014
1015 if (lwgeom_is_empty(geom))
1016 {
1017 LWPOINT *lwp = lwpoint_construct_empty(srid, is3d, lwgeom_has_m(geom));
1018 return lwpoint_as_lwgeom(lwp);
1019 }
1020
1021 initGEOS(lwnotice, lwgeom_geos_error);
1022
1023 if (!(g1 = LWGEOM2GEOS(geom, AUTOFIX))) GEOS_FAIL();
1024
1025 g3 = GEOSPointOnSurface(g1);
1026
1027 if (!g3) GEOS_FREE_AND_FAIL(g1);
1028 GEOSSetSRID(g3, srid);
1029
1030 if (!(result = GEOS2LWGEOM(g3, is3d)))
1031 GEOS_FREE_AND_FAIL(g1, g3);
1032
1033 GEOS_FREE(g1, g3);
1034
1035 return result;
1036}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
#define GEOS_FREE(...)
#define AUTOFIX
#define RESULT_SRID(...)
#define GEOS_FAIL()
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
#define GEOS_FREE_AND_FAIL(...)
void lwgeom_geos_error(const char *fmt,...)
void(*) LWGEOM GEOS2LWGEOM)(const GEOSGeometry *geom, uint8_t want3d)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
Definition lwgeom.c:372
#define SRID_INVALID
Definition liblwgeom.h:219
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:165
LWPOINT * lwpoint_construct_empty(int32_t srid, char hasz, char hasm)
Definition lwpoint.c:151
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition lwgeom.c:969
void lwnotice(const char *fmt,...) __attribute__((format(printf
Write a notice out to the notice handler.
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition lwinline.h:199
lwflags_t flags
Definition liblwgeom.h:461

References AUTOFIX, LWGEOM::flags, FLAGS_GET_Z, GEOS_FAIL, GEOS_FREE, GEOS_FREE_AND_FAIL, LWGEOM2GEOS(), lwgeom_geos_error(), lwgeom_has_m(), lwgeom_is_empty(), lwnotice(), lwpoint_as_lwgeom(), lwpoint_construct_empty(), result, RESULT_SRID, and SRID_INVALID.

Referenced by pointonsurface().

Here is the call graph for this function:
Here is the caller graph for this function: