PostGIS  2.5.0dev-r@@SVN_REVISION@@
Datum hausdorffdistance ( PG_FUNCTION_ARGS  )

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

References gserialized_is_empty(), HANDLE_GEOS_ERROR, lwgeom_geos_error(), and POSTGIS2GEOS().

172 {
173  GSERIALIZED *geom1;
174  GSERIALIZED *geom2;
175  GEOSGeometry *g1;
176  GEOSGeometry *g2;
177  double result;
178  int retcode;
179 
180  POSTGIS_DEBUG(2, "hausdorff_distance called");
181 
182  geom1 = PG_GETARG_GSERIALIZED_P(0);
183  geom2 = PG_GETARG_GSERIALIZED_P(1);
184 
185  if ( gserialized_is_empty(geom1) || gserialized_is_empty(geom2) )
186  PG_RETURN_NULL();
187 
188  initGEOS(lwpgnotice, lwgeom_geos_error);
189 
190  g1 = (GEOSGeometry *)POSTGIS2GEOS(geom1);
191  if (!g1)
192  HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
193 
194  g2 = (GEOSGeometry *)POSTGIS2GEOS(geom2);
195  if (!g2)
196  {
197  GEOSGeom_destroy(g1);
199  "Second argument geometry could not be converted to GEOS");
200  }
201 
202  retcode = GEOSHausdorffDistance(g1, g2, &result);
203  GEOSGeom_destroy(g1);
204  GEOSGeom_destroy(g2);
205 
206  if (retcode == 0) HANDLE_GEOS_ERROR("GEOSHausdorffDistance");
207 
208  PG_FREE_IF_COPY(geom1, 0);
209  PG_FREE_IF_COPY(geom2, 1);
210 
211  PG_RETURN_FLOAT8(result);
212 }
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Definition: g_serialized.c:178
void lwgeom_geos_error(const char *fmt,...)
GEOSGeometry * POSTGIS2GEOS(GSERIALIZED *pglwgeom)
#define HANDLE_GEOS_ERROR(label)

Here is the call graph for this function: