1205 GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0);
1208 StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
1210 #if POSTGIS_PGSQL_VERSION >= 95 1211 bool *recheck = (
bool *) PG_GETARG_POINTER(4);
1214 POSTGIS_DEBUG(4,
"[GIST] 'distance' function called");
1218 if ( strategy != 13 && strategy != 14 ) {
1219 elog(ERROR,
"unrecognized strategy number: %d", strategy);
1220 PG_RETURN_FLOAT8(FLT_MAX);
1226 POSTGIS_DEBUG(4,
"[GIST] null query_gbox_index!");
1227 PG_RETURN_FLOAT8(FLT_MAX);
1231 entry_box = (BOX2DF*)DatumGetPointer(entry->key);
1233 #if POSTGIS_PGSQL_VERSION >= 95 1236 if ( strategy == 14 )
1241 else if ( strategy == 13 )
1248 if (GIST_LEAF(entry))
1253 elog(ERROR,
"%s: reached unreachable code", __func__);
1258 if ( strategy == 14 )
1261 PG_RETURN_FLOAT8(distance);
1265 if (GIST_LEAF(entry))
1273 distance = (double)box2df_distance_node_centroid(entry_box, &query_box);
1277 PG_RETURN_FLOAT8(distance);
static double box2df_distance(const BOX2DF *a, const BOX2DF *b)
Calculate the box->box distance.
static double box2df_distance_leaf_centroid(const BOX2DF *a, const BOX2DF *b)
Calculate the centroid->centroid distance between the boxes.
int gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df)
Peak into a GSERIALIZED datum to find the bounding box.
Datum distance(PG_FUNCTION_ARGS)