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; }
LWGEOM* lwgeom_force_4d(const LWGEOM *geom) { return lwgeom_force_dims(geom, 1, 1); }
LWGEOM* lwgeom_force_3dz(const LWGEOM *geom) { return lwgeom_force_dims(geom, 1, 0); }
LWGEOM* lwgeom_force_3dm(const LWGEOM *geom) { return lwgeom_force_dims(geom, 0, 1); }
LWGEOM* lwgeom_force_2d(const LWGEOM *geom) { return lwgeom_force_dims(geom, 0, 0); }