809 char b1mem[GIDX_MAX_SIZE];
810 GIDX *b1 = (GIDX*)b1mem;
811 char b2mem[GIDX_MAX_SIZE];
812 GIDX *b2 = (GIDX*)b2mem;
814 #if POSTGIS_PGSQL_VERSION < 95 817 Datum gs1 = PG_GETARG_DATUM(0);
818 Datum gs2 = PG_GETARG_DATUM(1);
819 double box_distance = FLT_MAX;
822 if ( (gserialized_datum_get_gidx_p(gs1, b1) ==
LW_SUCCESS) &&
823 (gserialized_datum_get_gidx_p(gs2, b2) ==
LW_SUCCESS) )
825 box_distance = gidx_distance_leaf_centroid(b1, b2);
826 POSTGIS_DEBUGF(3,
"got boxes %s and %s", gidx_to_string(b1), gidx_to_string(b2));
828 PG_RETURN_FLOAT8(box_distance);
899 gserialized_get_gidx_p(geom1, b1);
900 gserialized_get_gidx_p(geom2, b2);
906 distance += (m2-m1)*(m2-m1);
912 PG_FREE_IF_COPY(geom1, 0);
913 PG_FREE_IF_COPY(geom2, 1);
914 PG_RETURN_FLOAT8(sqrt(distance));
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
void lwpoint_free(LWPOINT *pt)
void lwgeom_free(LWGEOM *geom)
LWGEOM * lwgeom_closest_line_3d(const LWGEOM *lw1, const LWGEOM *lw2)
double lwgeom_length_2d(const LWGEOM *geom)
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
double lwgeom_interpolate_point(const LWGEOM *lwin, const LWPOINT *lwpt)
Find the measure value at the location on the line closest to the point.
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
Datum distance(PG_FUNCTION_ARGS)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
double lwgeom_length(const LWGEOM *geom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
LWPOINT * lwline_get_lwpoint(const LWLINE *line, int where)
Returns freshly allocated LWPOINT that corresponds to the index where.
LWGEOM * lwgeom_closest_line(const LWGEOM *lw1, const LWGEOM *lw2)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
static double gidx_distance_m(const GIDX *a, const GIDX *b)