mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-25 01:22:47 +00:00
Added lwgeom_addBBOX() and lwcollection_construct_empty()
git-svn-id: http://svn.osgeo.org/postgis/trunk@975 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
163159d776
commit
f8afcfa025
|
@ -5,9 +5,6 @@
|
|||
|
||||
#define INTEGRITY_CHECKS 1
|
||||
//#define DEBUG_ALLOCS 1
|
||||
|
||||
//liblwgeom.h
|
||||
|
||||
//#define DEBUG 1
|
||||
//#define DEBUG_CALLS 1
|
||||
|
||||
|
@ -252,6 +249,8 @@ extern void lwgeom_changed(LWGEOM *lwgeom);
|
|||
// with the HASBBOX flag and has a bbox, it
|
||||
// will be released.
|
||||
extern void lwgeom_dropBBOX(LWGEOM *lwgeom);
|
||||
// Compute a bbox if not already computed
|
||||
extern void lwgeom_addBBOX(LWGEOM *lwgeom);
|
||||
extern void lwgeom_dropSRID(LWGEOM *lwgeom);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
@ -983,6 +982,8 @@ extern LWPOLY *lwpoly_construct(int SRID, BOX2DFLOAT4 *bbox,
|
|||
unsigned int nrings, POINTARRAY **points);
|
||||
extern LWCOLLECTION *lwcollection_construct(unsigned int type, int SRID,
|
||||
BOX2DFLOAT4 *bbox, unsigned int ngeoms, LWGEOM **geoms);
|
||||
extern LWCOLLECTION *lwcollection_construct_empty(int SRID,
|
||||
char hasZ, char hasM);
|
||||
|
||||
// Return a char string with ASCII versionf of type flags
|
||||
extern const char *lwgeom_typeflags(unsigned char type);
|
||||
|
|
|
@ -46,6 +46,22 @@ lwcollection_construct(unsigned int type, int SRID, BOX2DFLOAT4 *bbox,
|
|||
return ret;
|
||||
}
|
||||
|
||||
LWCOLLECTION *
|
||||
lwcollection_construct_empty(int SRID, char hasZ, char hasM);
|
||||
{
|
||||
LWCOLLECTION *ret;
|
||||
|
||||
ret = lwalloc(sizeof(LWCOLLECTION));
|
||||
ret->type = lwgeom_makeType_full(hasz, hasm, (SRID!=-1),
|
||||
COLLECTIONTYPE, 0);
|
||||
ret->SRID = SRID;
|
||||
ret->ngeoms = 0;
|
||||
ret->geoms = NULL;
|
||||
ret->bbox = bbox;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
LWCOLLECTION *
|
||||
lwcollection_deserialize(char *srl)
|
||||
|
|
|
@ -317,6 +317,13 @@ lwgeom_add(const LWGEOM *to, uint32 where, const LWGEOM *what)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_CALLS
|
||||
lwnotice("lwgeom_add(%s, %d, %s) called",
|
||||
lwgeom_typename(TYPE_GETTYPE(to->type)),
|
||||
where,
|
||||
lwgeom_typename(TYPE_GETTYPE(what->type)));
|
||||
#endif
|
||||
|
||||
switch(TYPE_GETTYPE(to->type))
|
||||
{
|
||||
case POINTTYPE:
|
||||
|
@ -327,10 +334,24 @@ lwgeom_add(const LWGEOM *to, uint32 where, const LWGEOM *what)
|
|||
return (LWGEOM *)lwpoly_add((const LWPOLY *)to, where, what);
|
||||
|
||||
case MULTIPOINTTYPE:
|
||||
return (LWGEOM *)lwmpoint_add((const LWMPOINT *)to,
|
||||
where, what);
|
||||
|
||||
case MULTILINETYPE:
|
||||
return (LWGEOM *)lwmline_add((const LWMLINE *)to,
|
||||
where, what);
|
||||
|
||||
case MULTIPOLYGONTYPE:
|
||||
return (LWGEOM *)lwcollection_add((const LWCOLLECTION *)to, where, what);
|
||||
return (LWGEOM *)lwmpoly_add((const LWMPOLY *)to,
|
||||
where, what);
|
||||
|
||||
case COLLECTIONTYPE:
|
||||
return (LWGEOM *)lwcollection_add(
|
||||
(const LWCOLLECTION *)to, where, what);
|
||||
|
||||
default:
|
||||
lwerror("lwgeom_add: unknown geometry type: %d",
|
||||
TYPE_GETTYPE(to->type));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -417,6 +438,18 @@ lwgeom_dropBBOX(LWGEOM *lwgeom)
|
|||
lwgeom->bbox = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensure there's a box in the LWGEOM.
|
||||
* If the box is already there just return,
|
||||
* else compute it.
|
||||
*/
|
||||
void
|
||||
lwgeom_addBBOX(LWGEOM *lwgeom)
|
||||
{
|
||||
if ( lwgeom->bbox ) return;
|
||||
lwgeom->bbox = lwgeom_compute_bbox(lwgeom);
|
||||
}
|
||||
|
||||
void
|
||||
lwgeom_dropSRID(LWGEOM *lwgeom)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue