PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ gserialized_gist_distance()

Datum gserialized_gist_distance ( PG_FUNCTION_ARGS  )

Definition at line 1327 of file gserialized_gist_nd.c.

1328 {
1329  GISTENTRY *entry = (GISTENTRY *)PG_GETARG_POINTER(0);
1330  StrategyNumber strategy = (StrategyNumber)PG_GETARG_UINT16(2);
1331  char query_box_mem[GIDX_MAX_SIZE];
1332  GIDX *query_box = (GIDX *)query_box_mem;
1333  GIDX *entry_box;
1334  bool *recheck = (bool *)PG_GETARG_POINTER(4);
1335 
1336  double distance;
1337 
1338  POSTGIS_DEBUG(4, "[GIST] 'distance' function called");
1339 
1340  /* Strategy 13 is <<->> */
1341  /* Strategy 20 is |=| */
1342  if (strategy != 13 && strategy != 20)
1343  {
1344  elog(ERROR, "unrecognized strategy number: %d", strategy);
1345  PG_RETURN_FLOAT8(FLT_MAX);
1346  }
1347 
1348  /* Null box should never make this far. */
1349  if (gserialized_datum_get_gidx_p(PG_GETARG_DATUM(1), query_box) == LW_FAILURE)
1350  {
1351  POSTGIS_DEBUG(4, "[GIST] null query_gbox_index!");
1352  PG_RETURN_FLOAT8(FLT_MAX);
1353  }
1354 
1355  /* Get the entry box */
1356  entry_box = (GIDX *)DatumGetPointer(entry->key);
1357 
1358  /* Strategy 20 is |=| */
1359  distance = gidx_distance(entry_box, query_box, strategy == 20);
1360 
1361  /* Treat leaf node tests different from internal nodes */
1362  if (GIST_LEAF(entry))
1363  *recheck = true;
1364 
1365  PG_RETURN_FLOAT8(distance);
1366 }
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:110
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: