PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ geography_closestpoint()

Datum geography_closestpoint ( PG_FUNCTION_ARGS  )

Definition at line 1410 of file geography_measurement.c.

1411 {
1412  GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0);
1413  GSERIALIZED *g2 = PG_GETARG_GSERIALIZED_P(1);
1414  LWGEOM *point, *lwg1, *lwg2;
1416 
1417  gserialized_error_if_srid_mismatch(g1, g2, __func__);
1418 
1419  lwg1 = lwgeom_from_gserialized(g1);
1420  lwg2 = lwgeom_from_gserialized(g2);
1421 
1422  /* Return NULL on empty/bad arguments. */
1423  if ( !lwg1 || !lwg2 || lwgeom_is_empty(lwg1) || lwgeom_is_empty(lwg2) )
1424  {
1425  PG_FREE_IF_COPY(g1, 0);
1426  PG_FREE_IF_COPY(g2, 1);
1427  PG_RETURN_NULL();
1428  }
1429 
1430  point = geography_tree_closestpoint(lwg1, lwg2, FP_TOLERANCE);
1431  result = geography_serialize(point);
1432  lwgeom_free(point);
1433  lwgeom_free(lwg1);
1434  lwgeom_free(lwg2);
1435 
1436  PG_FREE_IF_COPY(g1, 0);
1437  PG_FREE_IF_COPY(g2, 1);
1438  PG_RETURN_POINTER(result);
1439 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:262
void gserialized_error_if_srid_mismatch(const GSERIALIZED *g1, const GSERIALIZED *g2, const char *funcname)
Definition: gserialized.c:403
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155
#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:203

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: