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

◆ gserialized_gist_distance()

Datum gserialized_gist_distance ( PG_FUNCTION_ARGS  )

Definition at line 1330 of file gserialized_gist_nd.c.

1331{
1332 GISTENTRY *entry = (GISTENTRY *)PG_GETARG_POINTER(0);
1333 StrategyNumber strategy = (StrategyNumber)PG_GETARG_UINT16(2);
1334 char query_box_mem[GIDX_MAX_SIZE];
1335 GIDX *query_box = (GIDX *)query_box_mem;
1336 GIDX *entry_box;
1337 bool *recheck = (bool *)PG_GETARG_POINTER(4);
1338
1339 double distance;
1340
1341 POSTGIS_DEBUG(4, "[GIST] 'distance' function called");
1342
1343 /* Strategy 13 is <<->> */
1344 /* Strategy 20 is |=| */
1345 if (strategy != 13 && strategy != 20)
1346 {
1347 elog(ERROR, "unrecognized strategy number: %d", strategy);
1348 PG_RETURN_FLOAT8(FLT_MAX);
1349 }
1350
1351 /* Null box should never make this far. */
1352 if (gserialized_datum_get_gidx_p(PG_GETARG_DATUM(1), query_box) == LW_FAILURE)
1353 {
1354 POSTGIS_DEBUG(4, "[GIST] null query_gbox_index!");
1355 PG_RETURN_FLOAT8(FLT_MAX);
1356 }
1357
1358 /* Get the entry box */
1359 entry_box = (GIDX *)PG_DETOAST_DATUM(entry->key);
1360
1361 /* Strategy 20 is |=| */
1362 distance = gidx_distance(entry_box, query_box, strategy == 20);
1363
1364 /* Treat leaf node tests different from internal nodes */
1365 if (GIST_LEAF(entry))
1366 *recheck = true;
1367
1368 PG_RETURN_FLOAT8(distance);
1369}
static double gidx_distance(const GIDX *a, const GIDX *b, int m_is_time)
Calculate the box->box distance.
#define LW_FAILURE
Definition liblwgeom.h:96
static double distance(double x1, double y1, double x2, double y2)
Definition lwtree.c:1032

References distance(), gidx_distance(), and LW_FAILURE.

Here is the call graph for this function: