PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum boundary ( PG_FUNCTION_ARGS  )

Definition at line 900 of file postgis/lwgeom_geos.c.

References geometry_serialize(), GEOS2POSTGIS(), gserialized_get_srid(), gserialized_has_z(), gserialized_is_empty(), LINETYPE, lwerror(), LWGEOM2GEOS(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_geos_errmsg, lwgeom_geos_error(), lwnotice(), result, TRIANGLETYPE, and LWGEOM::type.

Referenced by test_rect_tree_contains_point().

901 {
902  GSERIALIZED *geom1;
903  GEOSGeometry *g1, *g3;
905  LWGEOM *lwgeom;
906  int srid;
907 
908 
909  geom1 = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
910 
911  /* Empty.Boundary() == Empty */
912  if ( gserialized_is_empty(geom1) )
913  PG_RETURN_POINTER(geom1);
914 
915  srid = gserialized_get_srid(geom1);
916 
917  lwgeom = lwgeom_from_gserialized(geom1);
918  if ( ! lwgeom ) {
919  lwerror("POSTGIS2GEOS: unable to deserialize input");
920  PG_RETURN_NULL();
921  }
922 
923  /* GEOS doesn't do triangle type, so we special case that here */
924  if (lwgeom->type == TRIANGLETYPE) {
925  lwgeom->type = LINETYPE;
926  result = geometry_serialize(lwgeom);
927  lwgeom_free(lwgeom);
928  PG_RETURN_POINTER(result);
929  }
930 
931  initGEOS(lwnotice, lwgeom_geos_error);
932 
933  g1 = LWGEOM2GEOS(lwgeom);
934  lwgeom_free(lwgeom);
935 
936  if ( 0 == g1 ) /* exception thrown at construction */
937  {
938  lwerror("First argument geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
939  PG_RETURN_NULL();
940  }
941 
942  g3 = (GEOSGeometry *)GEOSBoundary(g1);
943 
944  if (g3 == NULL)
945  {
946  GEOSGeom_destroy(g1);
947  lwerror("GEOSBoundary: %s", lwgeom_geos_errmsg);
948  PG_RETURN_NULL(); /* never get here */
949  }
950 
951  POSTGIS_DEBUGF(3, "result: %s", GEOSGeomToWKT(g3));
952 
953  GEOSSetSRID(g3, srid);
954 
955  result = GEOS2POSTGIS(g3, gserialized_has_z(geom1));
956 
957  if (result == NULL)
958  {
959  GEOSGeom_destroy(g1);
960 
961  GEOSGeom_destroy(g3);
962  elog(NOTICE,"GEOS2POSTGIS threw an error (result postgis geometry formation)!");
963  PG_RETURN_NULL(); /* never get here */
964  }
965 
966  GEOSGeom_destroy(g1);
967  GEOSGeom_destroy(g3);
968 
969  PG_FREE_IF_COPY(geom1, 0);
970 
971  PG_RETURN_POINTER(result);
972 }
#define LINETYPE
Definition: liblwgeom.h:61
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
#define TRIANGLETYPE
Definition: liblwgeom.h:73
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom)
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:25
char ** result
Definition: liblwgeom.h:218
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: g_serialized.c:140
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:54
void lwgeom_geos_error(const char *fmt,...)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
uint8_t type
Definition: liblwgeom.h:352
GSERIALIZED * GEOS2POSTGIS(GEOSGeom geom, char want3d)
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: g_serialized.c:70

Here is the call graph for this function:

Here is the caller graph for this function: