Remove more appeals to pglwgeom->type

git-svn-id: http://svn.osgeo.org/postgis/trunk@6314 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Paul Ramsey 2010-12-08 23:40:38 +00:00
parent be0118a664
commit b29ea47814
10 changed files with 40 additions and 33 deletions

View file

@ -920,7 +920,6 @@ extern LWGEOM* lwgeom_simplify(const LWGEOM *igeom, double dist);
extern char lwgeom_hasSRID(uchar type); /* true iff S bit is set */
extern char lwgeom_hasBBOX(uchar type); /* true iff B bit set */
extern int lwgeom_ndims(uchar type); /* returns 2,3 or 4 */
extern int lwgeom_hasZ(uchar type); /* has Z ? */
extern int lwgeom_hasM(uchar type); /* has M ? */
extern int lwgeom_getType(uchar type); /* returns the tttt value */
@ -1488,7 +1487,6 @@ extern void printLWPSURFACE(LWPSURFACE *psurf);
extern void printLWTIN(LWTIN *tin);
extern void printBYTES(uchar *a, int n);
extern void printMULTI(uchar *serialized);
extern void printType(uchar str);
extern float LWGEOM_Minf(float a, float b);

View file

@ -792,13 +792,6 @@ lwgeom_hasSRID(uchar type)
return TYPE_HASSRID(type);
}
/* Returns either 2,3, or 4 -- 2=2D, 3=3D, 4=4D */
int
lwgeom_ndims(uchar type)
{
return TYPE_NDIMS(type);
}
/* has M ? */
int lwgeom_hasM(uchar type)
{
@ -1895,11 +1888,6 @@ printMULTI(uchar *serialized)
lwinspected_release(inspected);
}
void
printType(uchar type)
{
lwnotice("type 0x%x ==> hasBBOX=%i, has_srid=%i, ndims=%i, type=%i",(uint32) type, lwgeom_hasBBOX(type), lwgeom_hasSRID(type),lwgeom_ndims(type), lwgeom_getType(type));
}
/**
* Get the srid from the LWGEOM.

View file

@ -313,7 +313,7 @@ asgeojson_multipoint_size(const LWMPOINT *mpoint, char *srs, GBOX *bbox, int pre
size = sizeof("{'type':'MultiPoint',");
if (srs) size += asgeojson_srs_size(srs);
if (bbox) size += asgeojson_bbox_size(TYPE_HASZ(mpoint->type), precision);
if (bbox) size += asgeojson_bbox_size(FLAGS_GET_Z(mpoint->flags), precision);
size += sizeof("'coordinates':[]}");
for (i=0; i<mpoint->ngeoms; i++)
@ -335,7 +335,7 @@ asgeojson_multipoint_buf(const LWMPOINT *mpoint, char *srs, char *output, GBOX *
ptr += sprintf(ptr, "{\"type\":\"MultiPoint\",");
if (srs) ptr += asgeojson_srs_buf(ptr, srs);
if (bbox) ptr += asgeojson_bbox_buf(ptr, bbox, TYPE_HASZ(mpoint->type), precision);
if (bbox) ptr += asgeojson_bbox_buf(ptr, bbox, FLAGS_GET_Z(mpoint->flags), precision);
ptr += sprintf(ptr, "\"coordinates\":[");
for (i=0; i<mpoint->ngeoms; i++)
@ -377,7 +377,7 @@ asgeojson_multiline_size(const LWMLINE *mline, char *srs, GBOX *bbox, int precis
size = sizeof("{'type':'MultiLineString',");
if (srs) size += asgeojson_srs_size(srs);
if (bbox) size += asgeojson_bbox_size(TYPE_HASZ(mline->type), precision);
if (bbox) size += asgeojson_bbox_size(FLAGS_GET_Z(mline->flags), precision);
size += sizeof("'coordinates':[]}");
for (i=0 ; i<mline->ngeoms; i++)
@ -400,7 +400,7 @@ asgeojson_multiline_buf(const LWMLINE *mline, char *srs, char *output, GBOX *bbo
ptr += sprintf(ptr, "{\"type\":\"MultiLineString\",");
if (srs) ptr += asgeojson_srs_buf(ptr, srs);
if (bbox) ptr += asgeojson_bbox_buf(ptr, bbox, TYPE_HASZ(mline->type), precision);
if (bbox) ptr += asgeojson_bbox_buf(ptr, bbox, FLAGS_GET_Z(mline->flags), precision);
ptr += sprintf(ptr, "\"coordinates\":[");
for (i=0; i<mline->ngeoms; i++)
@ -445,7 +445,7 @@ asgeojson_multipolygon_size(const LWMPOLY *mpoly, char *srs, GBOX *bbox, int pre
size = sizeof("{'type':'MultiPolygon',");
if (srs) size += asgeojson_srs_size(srs);
if (bbox) size += asgeojson_bbox_size(TYPE_HASZ(mpoly->type), precision);
if (bbox) size += asgeojson_bbox_size(FLAGS_GET_Z(mpoly->flags), precision);
size += sizeof("'coordinates':[]}");
for (i=0; i < mpoly->ngeoms; i++)
@ -473,7 +473,7 @@ asgeojson_multipolygon_buf(const LWMPOLY *mpoly, char *srs, char *output, GBOX *
ptr += sprintf(ptr, "{\"type\":\"MultiPolygon\",");
if (srs) ptr += asgeojson_srs_buf(ptr, srs);
if (bbox) ptr += asgeojson_bbox_buf(ptr, bbox, TYPE_HASZ(mpoly->type), precision);
if (bbox) ptr += asgeojson_bbox_buf(ptr, bbox, FLAGS_GET_Z(mpoly->flags), precision);
ptr += sprintf(ptr, "\"coordinates\":[");
for (i=0; i<mpoly->ngeoms; i++)
{
@ -522,7 +522,7 @@ asgeojson_collection_size(const LWCOLLECTION *col, char *srs, GBOX *bbox, int pr
size = sizeof("{'type':'GeometryCollection',");
if (srs) size += asgeojson_srs_size(srs);
if (bbox) size += asgeojson_bbox_size(TYPE_HASZ(col->type), precision);
if (bbox) size += asgeojson_bbox_size(FLAGS_GET_Z(col->flags), precision);
size += sizeof("'geometries':");
for (i=0; i<col->ngeoms; i++)
@ -545,7 +545,7 @@ asgeojson_collection_buf(const LWCOLLECTION *col, char *srs, char *output, GBOX
ptr += sprintf(ptr, "{\"type\":\"GeometryCollection\",");
if (srs) ptr += asgeojson_srs_buf(ptr, srs);
if (col->ngeoms && bbox) ptr += asgeojson_bbox_buf(ptr, bbox, TYPE_HASZ(col->type), precision);
if (col->ngeoms && bbox) ptr += asgeojson_bbox_buf(ptr, bbox, FLAGS_GET_Z(col->flags), precision);
ptr += sprintf(ptr, "\"geometries\":[");
for (i=0; i<col->ngeoms; i++)

View file

@ -416,7 +416,7 @@ lwgeom_size_point(const uchar *serialized_point)
result +=4;
}
result += lwgeom_ndims(type)*sizeof(double);
result += TYPE_NDIMS(type)*sizeof(double);
return result;
}

View file

@ -308,7 +308,7 @@ lwgeom_size_poly(const uchar *serialized_poly)
type = (uchar) serialized_poly[0];
ndims = lwgeom_ndims(type);
ndims = TYPE_NDIMS(type);
if ( lwgeom_getType(type) != POLYGONTYPE)
return -9999;

View file

@ -613,7 +613,7 @@ append_segment(LWGEOM *geom, POINTARRAY *pts, int type, int srid)
LWDEBUG(3, "append_segment: line to line");
newPoints = ptarray_construct(TYPE_HASZ(pts->flags), TYPE_HASM(pts->flags), pts->npoints + line->points->npoints - 1);
newPoints = ptarray_construct(FLAGS_GET_Z(pts->flags), FLAGS_GET_M(pts->flags), pts->npoints + line->points->npoints - 1);
for (i=0; i<line->points->npoints; i++)
{
getPoint4d_p(line->points, i, &pt);

View file

@ -123,8 +123,8 @@ ptarray_append_point(POINTARRAY *pa, POINT4D *pt, int repeated_points)
/* Return LW_SUCCESS and do nothing else if previous point in list is equal to this one */
if ( (pt->x == tmp.x) && (pt->y == tmp.y) &&
(TYPE_HASZ(pa->flags) ? pt->z == tmp.z : 1) &&
(TYPE_HASM(pa->flags) ? pt->m == tmp.m : 1) )
(FLAGS_GET_Z(pa->flags) ? pt->z == tmp.z : 1) &&
(FLAGS_GET_M(pa->flags) ? pt->m == tmp.m : 1) )
{
return LW_SUCCESS;
}

View file

@ -357,7 +357,7 @@ Datum LWGEOM_force_2d(PG_FUNCTION_ARGS)
LWGEOM *lwg_in, *lwg_out;
/* already 2d */
if ( lwgeom_ndims(pg_geom_in->type) == 2 ) PG_RETURN_POINTER(pg_geom_in);
if ( pglwgeom_ndims(pg_geom_in) == 2 ) PG_RETURN_POINTER(pg_geom_in);
lwg_in = pglwgeom_deserialize(pg_geom_in);
lwg_out = lwgeom_force_2d(lwg_in);
@ -378,7 +378,7 @@ Datum LWGEOM_force_3dz(PG_FUNCTION_ARGS)
LWGEOM *lwg_in, *lwg_out;
/* already 3d */
if ( lwgeom_ndims(pg_geom_in->type) == 3 && TYPE_HASZ(pg_geom_in->type) )
if ( pglwgeom_ndims(pg_geom_in) == 3 && pglwgeom_has_z(pg_geom_in) )
PG_RETURN_POINTER(pg_geom_in);
lwg_in = pglwgeom_deserialize(pg_geom_in);
@ -400,7 +400,7 @@ Datum LWGEOM_force_3dm(PG_FUNCTION_ARGS)
LWGEOM *lwg_in, *lwg_out;
/* already 3d */
if ( lwgeom_ndims(pg_geom_in->type) == 3 && TYPE_HASM(pg_geom_in->type) )
if ( pglwgeom_ndims(pg_geom_in) == 3 && pglwgeom_has_m(pg_geom_in) )
PG_RETURN_POINTER(pg_geom_in);
lwg_in = pglwgeom_deserialize(pg_geom_in);
@ -422,7 +422,7 @@ Datum LWGEOM_force_4d(PG_FUNCTION_ARGS)
LWGEOM *lwg_in, *lwg_out;
/* already 4d */
if ( lwgeom_ndims(pg_geom_in->type) == 4 )
if ( pglwgeom_ndims(pg_geom_in) == 4 )
PG_RETURN_POINTER(pg_geom_in);
lwg_in = pglwgeom_deserialize(pg_geom_in);

View file

@ -410,12 +410,24 @@ pglwgeom_get_type(const PG_LWGEOM *lwgeom)
return TYPE_GETTYPE(lwgeom->type);
}
int
bool
pglwgeom_has_bbox(const PG_LWGEOM *lwgeom)
{
return TYPE_HASBBOX(lwgeom->type);
}
bool
pglwgeom_has_z(const PG_LWGEOM *lwgeom)
{
return TYPE_HASZ(lwgeom->type);
}
bool
pglwgeom_has_m(const PG_LWGEOM *lwgeom)
{
return TYPE_HASM(lwgeom->type);
}
PG_LWGEOM* pglwgeom_drop_bbox(PG_LWGEOM *geom)
{
size_t size = VARSIZE(geom);
@ -444,3 +456,9 @@ size_t pglwgeom_size(const PG_LWGEOM *geom)
{
return serialized_lwgeom_size(SERIALIZED_FORM(geom));
};
int pglwgeom_ndims(const PG_LWGEOM *geom)
{
return TYPE_NDIMS(geom->type);
}

View file

@ -76,9 +76,12 @@ extern LWGEOM *pglwgeom_deserialize(PG_LWGEOM *pglwgeom);
extern PG_LWGEOM *pglwgeom_set_srid(PG_LWGEOM *pglwgeom, int32 newSRID);
extern int pglwgeom_get_srid(PG_LWGEOM *pglwgeom);
extern int pglwgeom_get_type(const PG_LWGEOM *lwgeom);
extern int pglwgeom_has_bbox(const PG_LWGEOM *lwgeom);
extern PG_LWGEOM* pglwgeom_drop_bbox(PG_LWGEOM *geom);
extern size_t pglwgeom_size(const PG_LWGEOM *geom);
extern int pglwgeom_ndims(const PG_LWGEOM *geom);
extern bool pglwgeom_has_bbox(const PG_LWGEOM *lwgeom);
extern bool pglwgeom_has_z(const PG_LWGEOM *lwgeom);
extern bool pglwgeom_has_m(const PG_LWGEOM *lwgeom);
extern Oid getGeometryOID(void);