PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum gserialized_gist_penalty_2d ( PG_FUNCTION_ARGS  )

Definition at line 1120 of file gserialized_gist_2d.c.

References box2df_size(), box2df_union_size(), and result.

1121 {
1122  GISTENTRY *origentry = (GISTENTRY*) PG_GETARG_POINTER(0);
1123  GISTENTRY *newentry = (GISTENTRY*) PG_GETARG_POINTER(1);
1124  float *result = (float*) PG_GETARG_POINTER(2);
1125  BOX2DF *gbox_index_orig, *gbox_index_new;
1126  float size_union, size_orig;
1127 
1128  POSTGIS_DEBUG(4, "[GIST] 'penalty' function called");
1129 
1130  gbox_index_orig = (BOX2DF*)DatumGetPointer(origentry->key);
1131  gbox_index_new = (BOX2DF*)DatumGetPointer(newentry->key);
1132 
1133  /* Drop out if we're dealing with null inputs. Shouldn't happen. */
1134  if ( (gbox_index_orig == NULL) && (gbox_index_new == NULL) )
1135  {
1136  POSTGIS_DEBUG(4, "[GIST] both inputs NULL! returning penalty of zero");
1137  *result = 0.0;
1138  PG_RETURN_FLOAT8(*result);
1139  }
1140 
1141  /* Calculate the size difference of the boxes. */
1142  size_union = box2df_union_size(gbox_index_orig, gbox_index_new);
1143  size_orig = box2df_size(gbox_index_orig);
1144  *result = size_union - size_orig;
1145 
1146  POSTGIS_DEBUGF(4, "[GIST] 'penalty', union size (%.12f), original size (%.12f), penalty (%.12f)", size_union, size_orig, *result);
1147 
1148  PG_RETURN_POINTER(result);
1149 }
char ** result
Definition: liblwgeom.h:218
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: