Skip to content

Commit

Permalink
#945, expose and add selectivity to the 3d/4d index (&&&) bindings
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/postgis/trunk@10796 b70326c6-7e19-0410-871a-916f4a2858ee
  • Loading branch information
pramsey committed Dec 4, 2012
1 parent e31140d commit 651570c
Show file tree
Hide file tree
Showing 13 changed files with 2,355 additions and 45 deletions.
2 changes: 2 additions & 0 deletions NEWS
Expand Up @@ -57,6 +57,8 @@ PostGIS 2.1.0
- #1895, new r-tree node splitting algorithm (Alex Korotkov)
- #1709, ST_NotSameAlignmentReason(raster, raster)
- #1293, ST_Resize(raster) to resize rasters based upon width/height
- #945, improved join selectivity, N-D selectivity calculations, user
accessible selectivity and stats reader functions for testing

* Enhancements *
- #823, tiger geocoder: Make loader_generate_script download portion
Expand Down
31 changes: 31 additions & 0 deletions liblwgeom/g_box.c
Expand Up @@ -142,6 +142,37 @@ int gbox_same(const GBOX *g1, const GBOX *g2)
return LW_TRUE;
}

int gbox_is_valid(const GBOX *gbox)
{
/* X */
if ( ! isfinite(gbox->xmin) || isnan(gbox->xmin) ||
! isfinite(gbox->xmax) || isnan(gbox->xmax) )
return LW_FALSE;

/* Y */
if ( ! isfinite(gbox->ymin) || isnan(gbox->ymin) ||
! isfinite(gbox->ymax) || isnan(gbox->ymax) )
return LW_FALSE;

/* Z */
if ( FLAGS_GET_GEODETIC(gbox->flags) || FLAGS_GET_Z(gbox->flags) )
{
if ( ! isfinite(gbox->zmin) || isnan(gbox->zmin) ||
! isfinite(gbox->zmax) || isnan(gbox->zmax) )
return LW_FALSE;
}

/* M */
if ( FLAGS_GET_M(gbox->flags) )
{
if ( ! isfinite(gbox->mmin) || isnan(gbox->mmin) ||
! isfinite(gbox->mmax) || isnan(gbox->mmax) )
return LW_FALSE;
}

return LW_TRUE;
}

int gbox_merge_point3d(const POINT3D *p, GBOX *gbox)
{
if ( gbox->xmin > p->x ) gbox->xmin = p->x;
Expand Down
5 changes: 5 additions & 0 deletions liblwgeom/liblwgeom.h.in
Expand Up @@ -1626,6 +1626,11 @@ extern int gbox_same(const GBOX *g1, const GBOX *g2);
*/
extern void gbox_float_round(GBOX *gbox);

/**
* Return false if any of the dimensions is NaN or infinite
*/
extern int gbox_is_valid(const GBOX *gbox);

/**
* Utility function to get type number from string. For example, a string 'POINTZ'
* would return type of 1 and z of 1 and m of 0. Valid
Expand Down
12 changes: 12 additions & 0 deletions libpgcommon/gserialized_gist.c
Expand Up @@ -49,6 +49,16 @@ char* gidx_to_string(GIDX *a)
#endif


static uint8_t
gserialized_datum_get_flags(Datum gsdatum)
{
GSERIALIZED *gpart;
POSTGIS_DEBUG(4, "entered function");
gpart = (GSERIALIZED*)PG_DETOAST_DATUM_SLICE(gsdatum, 0, 40);
POSTGIS_DEBUGF(4, "got flags %d", gpart->flags);
return gpart->flags;
}

/**
* Given a #GSERIALIZED datum, as quickly as possible (peaking into the top
* of the memory) return the gbox extents. Does not deserialize the geometry,
Expand All @@ -66,6 +76,8 @@ gserialized_datum_get_gbox_p(Datum gsdatum, GBOX *gbox)
return LW_FAILURE;

gbox_from_gidx(gidx, gbox);
gbox->flags = gserialized_datum_get_flags(gsdatum);

return LW_SUCCESS;
}

Expand Down
1 change: 1 addition & 0 deletions postgis/Makefile.in
Expand Up @@ -55,6 +55,7 @@ PG_OBJS= \
gserialized_typmod.o \
gserialized_gist_2d.o \
gserialized_gist_nd.o \
gserialized_estimate.o \
geography_inout.o \
geography_btree.o \
geography_estimate.o \
Expand Down
6 changes: 3 additions & 3 deletions postgis/geography.sql.in.c
Expand Up @@ -52,7 +52,7 @@ CREATE OR REPLACE FUNCTION geography_send(geography)
-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION geography_analyze(internal)
RETURNS bool
AS 'MODULE_PATHNAME','geography_analyze'
AS 'MODULE_PATHNAME','gserialized_analyze_nd'
LANGUAGE 'c' VOLATILE STRICT;

-- Availability: 1.5.0
Expand Down Expand Up @@ -255,8 +255,8 @@ CREATE OR REPLACE FUNCTION geography_overlaps(geography, geography)
CREATE OPERATOR && (
LEFTARG = geography, RIGHTARG = geography, PROCEDURE = geography_overlaps,
COMMUTATOR = '&&',
RESTRICT = geography_gist_selectivity,
JOIN = geography_gist_join_selectivity
RESTRICT = gserialized_gist_sel_nd,
JOIN = gserialized_gist_joinsel_nd
);


Expand Down

0 comments on commit 651570c

Please sign in to comment.