PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ lwgeom_sharedpaths()

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

Definition at line 1554 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(), and LWGEOM::srid.

Referenced by ST_SharedPaths().

1555 {
1556  GEOSGeometry *g1, *g2, *g3;
1557  LWGEOM *out;
1558  int is3d, srid;
1559 
1560  srid = geom1->srid;
1561  error_if_srid_mismatch(srid, (int)(geom2->srid));
1562 
1563  is3d = (FLAGS_GET_Z(geom1->flags) || FLAGS_GET_Z(geom2->flags)) ;
1564 
1565  initGEOS(lwnotice, lwgeom_geos_error);
1566 
1567  g1 = (GEOSGeometry *)LWGEOM2GEOS(geom1, 0);
1568  if ( 0 == g1 ) /* exception thrown at construction */
1569  {
1570  lwerror("First argument geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
1571  return NULL;
1572  }
1573 
1574  g2 = (GEOSGeometry *)LWGEOM2GEOS(geom2, 0);
1575  if ( 0 == g2 ) /* exception thrown at construction */
1576  {
1577  lwerror("Second argument geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
1578  GEOSGeom_destroy(g1);
1579  return NULL;
1580  }
1581 
1582  g3 = GEOSSharedPaths(g1,g2);
1583 
1584  GEOSGeom_destroy(g1);
1585  GEOSGeom_destroy(g2);
1586 
1587  if (g3 == NULL)
1588  {
1589  lwerror("GEOSSharedPaths: %s", lwgeom_geos_errmsg);
1590  return NULL;
1591  }
1592 
1593  GEOSSetSRID(g3, srid);
1594  out = GEOS2LWGEOM(g3, is3d);
1595  GEOSGeom_destroy(g3);
1596 
1597  if (out == NULL)
1598  {
1599  lwerror("GEOS2LWGEOM threw an error");
1600  return NULL;
1601  }
1602 
1603  return out;
1604 }
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:89
uint8_t flags
Definition: liblwgeom.h:396
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:369
int32_t srid
Definition: liblwgeom.h:398
void lwgeom_geos_error(const char *fmt,...)
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
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:102
Here is the call graph for this function:
Here is the caller graph for this function: