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
1337
1338 POSTGIS_DEBUG(4, "[GIST] 'distance' function called");
1339
1340
1341
1342 if (strategy != 13 && strategy != 20)
1343 {
1344 elog(ERROR, "unrecognized strategy number: %d", strategy);
1345 PG_RETURN_FLOAT8(FLT_MAX);
1346 }
1347
1348
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
1356 entry_box = (GIDX *)DatumGetPointer(entry->key);
1357
1358
1360
1361
1362 if (GIST_LEAF(entry))
1363 *recheck = true;
1364
1366}
static double gidx_distance(const GIDX *a, const GIDX *b, int m_is_time)
Calculate the box->box distance.
static double distance(double x1, double y1, double x2, double y2)