PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWGEOM* lwgeom_sharedpaths ( const LWGEOM geom1,
const LWGEOM geom2 
)

Definition at line 1207 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().

1208 {
1209 #if POSTGIS_GEOS_VERSION < 33
1210  lwerror("The GEOS version this postgis binary "
1211  "was compiled against (%d) doesn't support "
1212  "'SharedPaths' function (3.3.0+ required)",
1214  return NULL;
1215 #else /* POSTGIS_GEOS_VERSION >= 33 */
1216  GEOSGeometry *g1, *g2, *g3;
1217  LWGEOM *out;
1218  int is3d, srid;
1219 
1220  srid = geom1->srid;
1221  error_if_srid_mismatch(srid, (int)(geom2->srid));
1222 
1223  is3d = (FLAGS_GET_Z(geom1->flags) || FLAGS_GET_Z(geom2->flags)) ;
1224 
1225  initGEOS(lwnotice, lwgeom_geos_error);
1226 
1227  g1 = (GEOSGeometry *)LWGEOM2GEOS(geom1);
1228  if ( 0 == g1 ) /* exception thrown at construction */
1229  {
1230  lwerror("First argument geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
1231  return NULL;
1232  }
1233 
1234  g2 = (GEOSGeometry *)LWGEOM2GEOS(geom2);
1235  if ( 0 == g2 ) /* exception thrown at construction */
1236  {
1237  lwerror("Second argument geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
1238  GEOSGeom_destroy(g1);
1239  return NULL;
1240  }
1241 
1242  g3 = GEOSSharedPaths(g1,g2);
1243 
1244  GEOSGeom_destroy(g1);
1245  GEOSGeom_destroy(g2);
1246 
1247  if (g3 == NULL)
1248  {
1249  lwerror("GEOSSharedPaths: %s", lwgeom_geos_errmsg);
1250  return NULL;
1251  }
1252 
1253  GEOSSetSRID(g3, srid);
1254  out = GEOS2LWGEOM(g3, is3d);
1255  GEOSGeom_destroy(g3);
1256 
1257  if (out == NULL)
1258  {
1259  lwerror("GEOS2LWGEOM threw an error");
1260  return NULL;
1261  }
1262 
1263  return out;
1264 #endif /* POSTGIS_GEOS_VERSION >= 33 */
1265 }
#define POSTGIS_GEOS_VERSION
Definition: sqldefines.h:10
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:317
uint8_t flags
Definition: liblwgeom.h:353
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom)
int32_t srid
Definition: liblwgeom.h:355
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,...)
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, char want3d)

Here is the call graph for this function:

Here is the caller graph for this function: