Skip to content

Commit

Permalink
Remove pglwgeom_has_bbox, pglwgeom_has_z, pglwgeom_has_m
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/postgis/trunk@8039 b70326c6-7e19-0410-871a-916f4a2858ee
  • Loading branch information
pramsey committed Oct 29, 2011
1 parent e0f79d9 commit 84206a3
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 49 deletions.
18 changes: 0 additions & 18 deletions libpgcommon/lwgeom_pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,24 +209,6 @@ pglwgeom_get_zm(const GSERIALIZED *lwgeom)
return 2 * FLAGS_GET_Z(lwgeom->flags) + FLAGS_GET_M(lwgeom->flags);
}

bool
pglwgeom_has_bbox(const GSERIALIZED *lwgeom)
{
return FLAGS_GET_BBOX(lwgeom->flags);
}

bool
pglwgeom_has_z(const GSERIALIZED *lwgeom)
{
return FLAGS_GET_Z(lwgeom->flags);
}

bool
pglwgeom_has_m(const GSERIALIZED *lwgeom)
{
return FLAGS_GET_M(lwgeom->flags);
}

GSERIALIZED* pglwgeom_drop_bbox(GSERIALIZED *geom)
{
return gserialized_drop_gidx(geom);
Expand Down
3 changes: 0 additions & 3 deletions libpgcommon/lwgeom_pg.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ extern int pglwgeom_get_zm(const GSERIALIZED *lwgeom);
extern GSERIALIZED* pglwgeom_drop_bbox(GSERIALIZED *geom);
extern size_t pglwgeom_size(const GSERIALIZED *geom);
extern int pglwgeom_ndims(const GSERIALIZED *geom);
extern bool pglwgeom_has_bbox(const GSERIALIZED *lwgeom);
extern bool pglwgeom_has_z(const GSERIALIZED *lwgeom);
extern bool pglwgeom_has_m(const GSERIALIZED *lwgeom);
extern int pglwgeom_is_empty(const GSERIALIZED *geom);
/*
* Get the 2d bounding box of the given geometry, in FLOAT4 format.
Expand Down
18 changes: 9 additions & 9 deletions postgis/lwgeom_functions_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ Datum LWGEOM_force_3dz(PG_FUNCTION_ARGS)
LWGEOM *lwg_in, *lwg_out;

/* already 3d */
if ( pglwgeom_ndims(pg_geom_in) == 3 && pglwgeom_has_z(pg_geom_in) )
if ( pglwgeom_ndims(pg_geom_in) == 3 && gserialized_has_z(pg_geom_in) )
PG_RETURN_POINTER(pg_geom_in);

lwg_in = lwgeom_from_gserialized(pg_geom_in);
Expand All @@ -379,7 +379,7 @@ Datum LWGEOM_force_3dm(PG_FUNCTION_ARGS)
LWGEOM *lwg_in, *lwg_out;

/* already 3d */
if ( pglwgeom_ndims(pg_geom_in) == 3 && pglwgeom_has_m(pg_geom_in) )
if ( pglwgeom_ndims(pg_geom_in) == 3 && gserialized_has_m(pg_geom_in) )
PG_RETURN_POINTER(pg_geom_in);

lwg_in = lwgeom_from_gserialized(pg_geom_in);
Expand Down Expand Up @@ -433,7 +433,7 @@ Datum LWGEOM_force_collection(PG_FUNCTION_ARGS)
* automatic bbox addition FOR_COMPLEX_GEOMS.
*/
if ( gserialized_get_type(geom) == COLLECTIONTYPE &&
pglwgeom_has_bbox(geom) )
gserialized_has_bbox(geom) )
{
PG_RETURN_POINTER(geom);
}
Expand Down Expand Up @@ -485,7 +485,7 @@ Datum LWGEOM_force_multi(PG_FUNCTION_ARGS)
** automatic bbox addition FOR_COMPLEX_GEOMS.
*/
if ( lwtype_is_collection(gserialized_get_type(geom)) &&
pglwgeom_has_bbox(geom) )
gserialized_has_bbox(geom) )
{
PG_RETURN_POINTER(geom);
}
Expand Down Expand Up @@ -1906,8 +1906,8 @@ Datum LWGEOM_zmflag(PG_FUNCTION_ARGS)
int ret = 0;

in = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
if ( pglwgeom_has_z(in) ) ret += 2;
if ( pglwgeom_has_m(in) ) ret += 1;
if ( gserialized_has_z(in) ) ret += 2;
if ( gserialized_has_m(in) ) ret += 1;
PG_FREE_IF_COPY(in, 0);
PG_RETURN_INT16(ret);
}
Expand All @@ -1916,22 +1916,22 @@ PG_FUNCTION_INFO_V1(LWGEOM_hasz);
Datum LWGEOM_hasz(PG_FUNCTION_ARGS)
{
GSERIALIZED *in = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
PG_RETURN_BOOL(pglwgeom_has_z(in));
PG_RETURN_BOOL(gserialized_has_z(in));
}

PG_FUNCTION_INFO_V1(LWGEOM_hasm);
Datum LWGEOM_hasm(PG_FUNCTION_ARGS)
{
GSERIALIZED *in = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
PG_RETURN_BOOL(pglwgeom_has_m(in));
PG_RETURN_BOOL(gserialized_has_m(in));
}


PG_FUNCTION_INFO_V1(LWGEOM_hasBBOX);
Datum LWGEOM_hasBBOX(PG_FUNCTION_ARGS)
{
GSERIALIZED *in = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
char res = pglwgeom_has_bbox(in);
char res = gserialized_has_bbox(in);
PG_FREE_IF_COPY(in, 0);
PG_RETURN_BOOL(res);
}
Expand Down
4 changes: 2 additions & 2 deletions postgis/lwgeom_functions_lrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ Datum LWGEOM_locate_between_m(PG_FUNCTION_ARGS)
double start_measure = PG_GETARG_FLOAT8(1);
double end_measure = PG_GETARG_FLOAT8(2);
LWGEOM *lwin, *lwout;
int hasz = pglwgeom_has_z(gin);
int hasm = pglwgeom_has_m(gin);
int hasz = gserialized_has_z(gin);
int hasm = gserialized_has_m(gin);
int type;

if ( end_measure < start_measure )
Expand Down
24 changes: 12 additions & 12 deletions postgis/lwgeom_geos.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ Datum pgis_union_geometry_array(PG_FUNCTION_ARGS)
{
srid = gserialized_get_srid(pggeom);
gotsrid = 1;
if ( pglwgeom_has_z(pggeom) ) is3d = 1;
if ( gserialized_has_z(pggeom) ) is3d = 1;
}
else
{
Expand Down Expand Up @@ -474,7 +474,7 @@ Datum pgis_union_geometry_array(PG_FUNCTION_ARGS)
POSTGIS_DEBUGF(3, "geom %d @ %p", i, geom);

/* Check is3d flag */
if ( pglwgeom_has_z(geom) ) is3d = 1;
if ( gserialized_has_z(geom) ) is3d = 1;

/* Check SRID homogeneity and initialize geos result */
if ( ! geos_result )
Expand Down Expand Up @@ -586,7 +586,7 @@ Datum ST_UnaryUnion(PG_FUNCTION_ARGS)
if ( pglwgeom_is_empty(geom1) )
PG_RETURN_POINTER(geom1);

is3d = ( pglwgeom_has_z(geom1) );
is3d = ( gserialized_has_z(geom1) );

srid = gserialized_get_srid(geom1);

Expand Down Expand Up @@ -744,7 +744,7 @@ Datum boundary(PG_FUNCTION_ARGS)

GEOSSetSRID(g3, srid);

result = GEOS2POSTGIS(g3, pglwgeom_has_z(geom1));
result = GEOS2POSTGIS(g3, gserialized_has_z(geom1));

if (result == NULL)
{
Expand Down Expand Up @@ -805,7 +805,7 @@ Datum convexhull(PG_FUNCTION_ARGS)

GEOSSetSRID(g3, srid);

lwout = GEOS2LWGEOM(g3, pglwgeom_has_z(geom1));
lwout = GEOS2LWGEOM(g3, gserialized_has_z(geom1));

if (lwout == NULL)
{
Expand Down Expand Up @@ -879,7 +879,7 @@ Datum topologypreservesimplify(PG_FUNCTION_ARGS)

GEOSSetSRID(g3, gserialized_get_srid(geom1));

result = GEOS2POSTGIS(g3, pglwgeom_has_z(geom1));
result = GEOS2POSTGIS(g3, gserialized_has_z(geom1));

if (result == NULL)
{
Expand Down Expand Up @@ -1086,7 +1086,7 @@ Datum buffer(PG_FUNCTION_ARGS)

GEOSSetSRID(g3, gserialized_get_srid(geom1));

result = GEOS2POSTGIS(g3, pglwgeom_has_z(geom1));
result = GEOS2POSTGIS(g3, gserialized_has_z(geom1));

if (result == NULL)
{
Expand Down Expand Up @@ -1259,7 +1259,7 @@ Datum offsetcurve(PG_FUNCTION_ARGS)

GEOSSetSRID(g3, gserialized_get_srid(geom1));

result = GEOS2POSTGIS(g3, pglwgeom_has_z(geom1));
result = GEOS2POSTGIS(g3, gserialized_has_z(geom1));

if (result == NULL)
{
Expand Down Expand Up @@ -1387,7 +1387,7 @@ Datum pointonsurface(PG_FUNCTION_ARGS)

GEOSSetSRID(g3, gserialized_get_srid(geom1));

result = GEOS2POSTGIS(g3, pglwgeom_has_z(geom1));
result = GEOS2POSTGIS(g3, gserialized_has_z(geom1));

if (result == NULL)
{
Expand Down Expand Up @@ -1438,7 +1438,7 @@ Datum centroid(PG_FUNCTION_ARGS)

GEOSSetSRID(geosresult, gserialized_get_srid(geom));

result = GEOS2POSTGIS(geosresult, pglwgeom_has_z(geom));
result = GEOS2POSTGIS(geosresult, gserialized_has_z(geom));

if (result == NULL)
{
Expand Down Expand Up @@ -3236,7 +3236,7 @@ Datum GEOSnoop(PG_FUNCTION_ARGS)
geosgeom = (GEOSGeometry *)POSTGIS2GEOS(geom);
if ( ! geosgeom ) PG_RETURN_NULL();

lwgeom_result = GEOS2POSTGIS(geosgeom, pglwgeom_has_z(geom));
lwgeom_result = GEOS2POSTGIS(geosgeom, gserialized_has_z(geom));
GEOSGeom_destroy(geosgeom);


Expand Down Expand Up @@ -3369,7 +3369,7 @@ Datum linemerge(PG_FUNCTION_ARGS)

GEOSSetSRID(g3, gserialized_get_srid(geom1));

result = GEOS2POSTGIS(g3, pglwgeom_has_z(geom1));
result = GEOS2POSTGIS(g3, gserialized_has_z(geom1));

if (result == NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion postgis/lwgeom_gist.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ Datum LWGEOM_gist_consistent(PG_FUNCTION_ARGS)
** If not, pull the full toasted data out, and call the standard box
** retrieval function, which will calculate the box from scratch.
*/
if ( pglwgeom_has_bbox(query) )
if ( gserialized_has_bbox(query) )
{
pglwgeom_getbox2d_p(query, &box);
}
Expand Down
2 changes: 1 addition & 1 deletion postgis/lwgeom_inout.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ Datum LWGEOM_dropBBOX(PG_FUNCTION_ARGS)
GSERIALIZED *geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));

/* No box? we're done already! */
if ( ! pglwgeom_has_bbox(geom) )
if ( ! gserialized_has_bbox(geom) )
PG_RETURN_POINTER(geom);

PG_RETURN_POINTER(pglwgeom_drop_bbox(geom));
Expand Down
6 changes: 3 additions & 3 deletions postgis/lwgeom_ogc.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Datum LWGEOM_getTYPE(PG_FUNCTION_ARGS)
else
strcpy(result,"UNKNOWN");

if ( pglwgeom_has_m(lwgeom) && ! pglwgeom_has_z(lwgeom) )
if ( gserialized_has_m(lwgeom) && ! gserialized_has_z(lwgeom) )
strcat(result, "M");

size = strlen(result) + VARHDRSZ ;
Expand Down Expand Up @@ -636,7 +636,7 @@ Datum LWGEOM_z_point(PG_FUNCTION_ARGS)
PG_RETURN_NULL();

/* no Z in input */
if ( ! pglwgeom_has_z(geom) ) PG_RETURN_NULL();
if ( ! gserialized_has_z(geom) ) PG_RETURN_NULL();

getPoint3dz_p(point->point, 0, &p);

Expand Down Expand Up @@ -790,7 +790,7 @@ Datum LWGEOM_from_WKB(PG_FUNCTION_ARGS)
geom = (GSERIALIZED *)DatumGetPointer(DirectFunctionCall1(
LWGEOMFromWKB, PG_GETARG_DATUM(0)));

if ( gserialized_get_srid(geom) != SRID_UNKNOWN || pglwgeom_has_z(geom) != 0 )
if ( gserialized_get_srid(geom) != SRID_UNKNOWN || gserialized_has_z(geom) != 0 )
{
elog(WARNING, "OGC WKB expected, EWKB provided - use GeometryFromEWKB() for this");
}
Expand Down

0 comments on commit 84206a3

Please sign in to comment.