PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ gserialized_gist_penalty_2d()

Datum gserialized_gist_penalty_2d ( PG_FUNCTION_ARGS  )

Definition at line 1146 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().

1147 {
1148  GISTENTRY *origentry = (GISTENTRY*) PG_GETARG_POINTER(0);
1149  GISTENTRY *newentry = (GISTENTRY*) PG_GETARG_POINTER(1);
1150  float *result = (float*) PG_GETARG_POINTER(2);
1151  BOX2DF *gbox_index_orig, *gbox_index_new;
1152  float size_union, size_orig;
1153 
1154  POSTGIS_DEBUG(4, "[GIST] 'penalty' function called");
1155 
1156  gbox_index_orig = (BOX2DF*)DatumGetPointer(origentry->key);
1157  gbox_index_new = (BOX2DF*)DatumGetPointer(newentry->key);
1158 
1159  /* Drop out if we're dealing with null inputs. Shouldn't happen. */
1160  if ( (gbox_index_orig == NULL) && (gbox_index_new == NULL) )
1161  {
1162  POSTGIS_DEBUG(4, "[GIST] both inputs NULL! returning penalty of zero");
1163  *result = 0.0;
1164  PG_RETURN_FLOAT8(*result);
1165  }
1166 
1167  /* Calculate the size difference of the boxes. */
1168  size_union = box2df_union_size(gbox_index_orig, gbox_index_new);
1169  size_orig = box2df_size(gbox_index_orig);
1170  *result = size_union - size_orig;
1171 
1172  POSTGIS_DEBUGF(4, "[GIST] 'penalty', union size (%.12f), original size (%.12f), penalty (%.12f)", size_union, size_orig, *result);
1173 
1174  PG_RETURN_POINTER(result);
1175 }
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: