PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ gserialized_distance_centroid_2d()

Datum gserialized_distance_centroid_2d ( PG_FUNCTION_ARGS  )

Definition at line 811 of file gserialized_gist_2d.c.

References box2df_distance_leaf_centroid(), box2df_to_string(), distance(), gserialized_datum_get_box2df_p(), gserialized_distance_box_2d(), LW_SUCCESS, and PG_FUNCTION_INFO_V1().

Referenced by gserialized_overlaps_box2df_box2df_2d().

812 {
813  BOX2DF b1, b2;
814  Datum gs1 = PG_GETARG_DATUM(0);
815  Datum gs2 = PG_GETARG_DATUM(1);
816 
817  POSTGIS_DEBUG(3, "entered function");
818 
819  /* Must be able to build box for each argument (ie, not empty geometry). */
820  if ( (gserialized_datum_get_box2df_p(gs1, &b1) == LW_SUCCESS) &&
822  {
823  double distance = box2df_distance_leaf_centroid(&b1, &b2);
824  POSTGIS_DEBUGF(3, "got boxes %s and %s", box2df_to_string(&b1), box2df_to_string(&b2));
825  PG_RETURN_FLOAT8(distance);
826  }
827  PG_RETURN_FLOAT8(FLT_MAX);
828 }
#define LW_SUCCESS
Definition: liblwgeom.h:80
static double box2df_distance_leaf_centroid(const BOX2DF *a, const BOX2DF *b)
Calculate the centroid->centroid distance between the boxes.
static char * box2df_to_string(const BOX2DF *a)
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)
Here is the call graph for this function:
Here is the caller graph for this function: