PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ hausdorffdistance()

Datum hausdorffdistance ( PG_FUNCTION_ARGS  )

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

115{
116 GSERIALIZED *geom1;
117 GSERIALIZED *geom2;
118 GEOSGeometry *g1;
119 GEOSGeometry *g2;
120 double result;
121 int retcode;
122
123 geom1 = PG_GETARG_GSERIALIZED_P(0);
124 geom2 = PG_GETARG_GSERIALIZED_P(1);
125
126 if ( gserialized_is_empty(geom1) || gserialized_is_empty(geom2) )
127 PG_RETURN_NULL();
128
129 initGEOS(lwpgnotice, lwgeom_geos_error);
130
131 g1 = POSTGIS2GEOS(geom1);
132 if (!g1)
133 HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
134
135 g2 = POSTGIS2GEOS(geom2);
136 if (!g2)
137 {
138 GEOSGeom_destroy(g1);
139 HANDLE_GEOS_ERROR("Second argument geometry could not be converted to GEOS");
140 }
141
142 retcode = GEOSHausdorffDistance(g1, g2, &result);
143 GEOSGeom_destroy(g1);
144 GEOSGeom_destroy(g2);
145
146 if (retcode == 0) HANDLE_GEOS_ERROR("GEOSHausdorffDistance");
147
148 PG_FREE_IF_COPY(geom1, 0);
149 PG_FREE_IF_COPY(geom2, 1);
150
151 PG_RETURN_FLOAT8(result);
152}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
void lwgeom_geos_error(const char *fmt,...)
GEOSGeometry * POSTGIS2GEOS(const GSERIALIZED *pglwgeom)
#define HANDLE_GEOS_ERROR(label)

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

Here is the call graph for this function: