LWCOLLECTION* lwcollection_simplify(const LWCOLLECTION *igeom, double dist) { int i; LWCOLLECTION *out = lwcollection_construct_empty(igeom->type, igeom->srid, FLAGS_GET_Z(igeom->flags), FLAGS_GET_M(igeom->flags)); if( lwcollection_is_empty(igeom) ) return out; /* should we return NULL instead ? */ for( i = 0; i < igeom->ngeoms; i++ ) { LWGEOM *ngeom = lwgeom_simplify(igeom->geoms[i], dist); if ( ngeom ) out = lwcollection_add_lwgeom(out, ngeom); } return out; }
int lwgeom_is_empty(const LWGEOM *geom) { int result = LW_FALSE; LWDEBUGF(4, "lwgeom_is_empty: got type %s", lwtype_name(geom->type)); switch (geom->type) { case POINTTYPE: return lwpoint_is_empty((LWPOINT*)geom); break; case LINETYPE: return lwline_is_empty((LWLINE*)geom); break; case CIRCSTRINGTYPE: return lwcircstring_is_empty((LWCIRCSTRING*)geom); break; case POLYGONTYPE: return lwpoly_is_empty((LWPOLY*)geom); break; case TRIANGLETYPE: return lwtriangle_is_empty((LWTRIANGLE*)geom); break; case MULTIPOINTTYPE: case MULTILINETYPE: case MULTIPOLYGONTYPE: case COMPOUNDTYPE: case CURVEPOLYTYPE: case MULTICURVETYPE: case MULTISURFACETYPE: case POLYHEDRALSURFACETYPE: case TINTYPE: case COLLECTIONTYPE: return lwcollection_is_empty((LWCOLLECTION *)geom); break; default: lwerror("lwgeom_is_empty: unsupported input geometry type: %s", lwtype_name(geom->type)); break; } return result; }
static LWCOLLECTION* lwcollection_set_effective_area(const LWCOLLECTION *igeom,int set_area, double trshld) { LWDEBUG(2, "Entered lwcollection_set_effective_area"); int i; int set_m; if(set_area) set_m=1; else set_m=FLAGS_GET_M(igeom->flags); LWCOLLECTION *out = lwcollection_construct_empty(igeom->type, igeom->srid, FLAGS_GET_Z(igeom->flags), set_m); if( lwcollection_is_empty(igeom) ) return out; /* should we return NULL instead ? */ for( i = 0; i < igeom->ngeoms; i++ ) { LWGEOM *ngeom = lwgeom_set_effective_area(igeom->geoms[i],set_area,trshld); if ( ngeom ) out = lwcollection_add_lwgeom(out, ngeom); } return out; }
LWCOLLECTION* lwcollection_force_dims(const LWCOLLECTION *col, int hasz, int hasm) { LWCOLLECTION *colout; /* Return 2D empty */ if( lwcollection_is_empty(col) ) { colout = lwcollection_construct_empty(col->type, col->srid, hasz, hasm); } else { int i; LWGEOM **geoms = NULL; geoms = lwalloc(sizeof(LWGEOM*) * col->ngeoms); for( i = 0; i < col->ngeoms; i++ ) { geoms[i] = lwgeom_force_dims(col->geoms[i], hasz, hasm); } colout = lwcollection_construct(col->type, col->srid, NULL, col->ngeoms, geoms); } return colout; }