1148{
1149 GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0);
1150 BOX2DF query_box;
1151 BOX2DF *entry_box;
1152 StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
1154 bool *recheck = (bool *) PG_GETARG_POINTER(4);
1155
1156 POSTGIS_DEBUG(4, "[GIST] 'distance' function called");
1157
1158
1159
1160 if ( strategy != 13 && strategy != 14 ) {
1161 elog(ERROR, "unrecognized strategy number: %d", strategy);
1162 PG_RETURN_FLOAT8(FLT_MAX);
1163 }
1164
1165
1167 {
1168 POSTGIS_DEBUG(4, "[GIST] null query_gbox_index!");
1169 PG_RETURN_FLOAT8(FLT_MAX);
1170 }
1171
1172
1173 entry_box = (BOX2DF*)DatumGetPointer(entry->key);
1174
1175
1176 if ( strategy == 14 )
1177 {
1179 }
1180
1181 else if ( strategy == 13 )
1182 {
1183
1184
1185
1187
1188 if (GIST_LEAF(entry))
1189 *recheck = true;
1190 }
1191 else
1192 {
1193 elog(ERROR, "%s: reached unreachable code", __func__);
1194 PG_RETURN_NULL();
1195 }
1196
1198}
static double box2df_distance(const BOX2DF *a, const BOX2DF *b)
Calculate the box->box distance.
int gserialized_datum_get_box2df_p(Datum gsdatum, BOX2DF *box2df)
static double distance(double x1, double y1, double x2, double y2)