PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ gserialized_gist_penalty_2d()

Datum gserialized_gist_penalty_2d ( PG_FUNCTION_ARGS  )

Definition at line 1251 of file gserialized_gist_2d.c.

References box2df_size(), box2df_union_size(), gserialized_gist_union_2d(), and PG_FUNCTION_INFO_V1().

Referenced by gserialized_gist_distance_2d().

1252 {
1253  GISTENTRY *origentry = (GISTENTRY*) PG_GETARG_POINTER(0);
1254  GISTENTRY *newentry = (GISTENTRY*) PG_GETARG_POINTER(1);
1255  float *result = (float*) PG_GETARG_POINTER(2);
1256  BOX2DF *gbox_index_orig, *gbox_index_new;
1257  float size_union, size_orig;
1258 
1259  POSTGIS_DEBUG(4, "[GIST] 'penalty' function called");
1260 
1261  gbox_index_orig = (BOX2DF*)DatumGetPointer(origentry->key);
1262  gbox_index_new = (BOX2DF*)DatumGetPointer(newentry->key);
1263 
1264  /* Drop out if we're dealing with null inputs. Shouldn't happen. */
1265  if ( (gbox_index_orig == NULL) && (gbox_index_new == NULL) )
1266  {
1267  POSTGIS_DEBUG(4, "[GIST] both inputs NULL! returning penalty of zero");
1268  *result = 0.0;
1269  PG_RETURN_FLOAT8(*result);
1270  }
1271 
1272  /* Calculate the size difference of the boxes. */
1273  size_union = box2df_union_size(gbox_index_orig, gbox_index_new);
1274  size_orig = box2df_size(gbox_index_orig);
1275  *result = size_union - size_orig;
1276 
1277  POSTGIS_DEBUGF(4, "[GIST] 'penalty', union size (%.12f), original size (%.12f), penalty (%.12f)", size_union, size_orig, *result);
1278 
1279  PG_RETURN_POINTER(result);
1280 }
static float box2df_size(const BOX2DF *a)
static float box2df_union_size(const BOX2DF *a, const BOX2DF *b)
Here is the call graph for this function:
Here is the caller graph for this function: