1531 GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0);
1532 StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
1533 char query_box_mem[GIDX_MAX_SIZE];
1534 GIDX *query_box = (GIDX*)query_box_mem;
1536 #if POSTGIS_PGSQL_VERSION >= 95
1537 bool *recheck = (
bool *) PG_GETARG_POINTER(4);
1542 POSTGIS_DEBUG(4,
"[GIST] 'distance' function called");
1546 if ( strategy != 13 && strategy != 20 ) {
1547 elog(ERROR,
"unrecognized strategy number: %d", strategy);
1548 PG_RETURN_FLOAT8(FLT_MAX);
1552 if ( gserialized_datum_get_gidx_p(PG_GETARG_DATUM(1), query_box) ==
LW_FAILURE )
1554 POSTGIS_DEBUG(4,
"[GIST] null query_gbox_index!");
1555 PG_RETURN_FLOAT8(FLT_MAX);
1559 entry_box = (GIDX*)DatumGetPointer(entry->key);
1561 #if POSTGIS_PGSQL_VERSION >= 95
1567 if (GIST_LEAF(entry))
1571 if ( strategy == 20 )
1573 elog(ERROR,
"You need PostgreSQL 9.5.0 or higher in order to use |=| with index");
1574 PG_RETURN_FLOAT8(FLT_MAX);
1578 if (GIST_LEAF(entry))
1581 distance = (double)gidx_distance_leaf_centroid(entry_box, query_box);
1586 distance = (double)gidx_distance_node_centroid(entry_box, query_box);
static double gidx_distance(const GIDX *a, const GIDX *b, int m_is_time)
Calculate the centroid->centroid distance between the boxes.
Datum distance(PG_FUNCTION_ARGS)