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

◆ geography_closestpoint()

Datum geography_closestpoint ( PG_FUNCTION_ARGS  )

Definition at line 1407 of file geography_measurement.c.

1408{
1409 GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0);
1410 GSERIALIZED *g2 = PG_GETARG_GSERIALIZED_P(1);
1411 LWGEOM *point, *lwg1, *lwg2;
1413
1414 gserialized_error_if_srid_mismatch(g1, g2, __func__);
1415
1416 lwg1 = lwgeom_from_gserialized(g1);
1417 lwg2 = lwgeom_from_gserialized(g2);
1418
1419 /* Return NULL on empty/bad arguments. */
1420 if ( !lwg1 || !lwg2 || lwgeom_is_empty(lwg1) || lwgeom_is_empty(lwg2) )
1421 {
1422 PG_FREE_IF_COPY(g1, 0);
1423 PG_FREE_IF_COPY(g2, 1);
1424 PG_RETURN_NULL();
1425 }
1426
1427 point = geography_tree_closestpoint(lwg1, lwg2, FP_TOLERANCE);
1428 result = geography_serialize(point);
1429 lwgeom_free(point);
1430 lwgeom_free(lwg1);
1431 lwgeom_free(lwg2);
1432
1433 PG_FREE_IF_COPY(g1, 0);
1434 PG_FREE_IF_COPY(g2, 1);
1435 PG_RETURN_POINTER(result);
1436}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
void gserialized_error_if_srid_mismatch(const GSERIALIZED *g1, const GSERIALIZED *g2, const char *funcname)
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
#define FP_TOLERANCE
Floating point comparators.
LWGEOM * geography_tree_closestpoint(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2, double threshold)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition lwinline.h:199

References FP_TOLERANCE, geography_tree_closestpoint(), gserialized_error_if_srid_mismatch(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_is_empty(), and result.

Here is the call graph for this function: