PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwgeom_sharedpaths()

LWGEOM* lwgeom_sharedpaths ( const LWGEOM geom1,
const LWGEOM geom2 
)

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

References error_if_srid_mismatch(), LWGEOM::flags, FLAGS_GET_Z, GEOS2LWGEOM(), lwerror(), LWGEOM2GEOS(), lwgeom_geos_errmsg, lwgeom_geos_error(), lwnotice(), POSTGIS_GEOS_VERSION, and LWGEOM::srid.

Referenced by ST_SharedPaths().

1485 {
1486 #if POSTGIS_GEOS_VERSION < 33
1487  lwerror("The GEOS version this postgis binary "
1488  "was compiled against (%d) doesn't support "
1489  "'SharedPaths' function (3.3.0+ required)",
1491  return NULL;
1492 #else /* POSTGIS_GEOS_VERSION >= 33 */
1493  GEOSGeometry *g1, *g2, *g3;
1494  LWGEOM *out;
1495  int is3d, srid;
1496 
1497  srid = geom1->srid;
1498  error_if_srid_mismatch(srid, (int)(geom2->srid));
1499 
1500  is3d = (FLAGS_GET_Z(geom1->flags) || FLAGS_GET_Z(geom2->flags)) ;
1501 
1502  initGEOS(lwnotice, lwgeom_geos_error);
1503 
1504  g1 = (GEOSGeometry *)LWGEOM2GEOS(geom1, 0);
1505  if ( 0 == g1 ) /* exception thrown at construction */
1506  {
1507  lwerror("First argument geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
1508  return NULL;
1509  }
1510 
1511  g2 = (GEOSGeometry *)LWGEOM2GEOS(geom2, 0);
1512  if ( 0 == g2 ) /* exception thrown at construction */
1513  {
1514  lwerror("Second argument geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
1515  GEOSGeom_destroy(g1);
1516  return NULL;
1517  }
1518 
1519  g3 = GEOSSharedPaths(g1,g2);
1520 
1521  GEOSGeom_destroy(g1);
1522  GEOSGeom_destroy(g2);
1523 
1524  if (g3 == NULL)
1525  {
1526  lwerror("GEOSSharedPaths: %s", lwgeom_geos_errmsg);
1527  return NULL;
1528  }
1529 
1530  GEOSSetSRID(g3, srid);
1531  out = GEOS2LWGEOM(g3, is3d);
1532  GEOSGeom_destroy(g3);
1533 
1534  if (out == NULL)
1535  {
1536  lwerror("GEOS2LWGEOM threw an error");
1537  return NULL;
1538  }
1539 
1540  return out;
1541 #endif /* POSTGIS_GEOS_VERSION >= 33 */
1542 }
#define POSTGIS_GEOS_VERSION
Definition: sqldefines.h:10
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:61
uint8_t flags
Definition: liblwgeom.h:381
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:341
int32_t srid
Definition: liblwgeom.h:383
void lwgeom_geos_error(const char *fmt,...)
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:124
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, char want3d)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
Here is the call graph for this function:
Here is the caller graph for this function: