private GeometryCollection readGeometryCollection() throws IOException, ParseException { int numGeom = dis.readInt(); Geometry[] geoms = new Geometry[numGeom]; for (int i = 0; i < numGeom; i++) { geoms[i] = readGeometry(); } return factory.createGeometryCollection(geoms); }
/** * Creates a <code>GeometryCollection</code> using the next token in the stream. * * @return a <code>GeometryCollection</code> specified by the next token in the stream * @throws ParseException if the coordinates used to create a <code>Polygon</code> shell and * holes do not form closed linestrings, or if an unexpected token was encountered * @throws IOException if an I/O error occurs */ private GeometryCollection readGeometryCollectionText() throws IOException, ParseException { String nextToken = getNextEmptyOrOpener(); if (nextToken.equals(EMPTY)) { return geometryFactory.createGeometryCollection(new Geometry[] {}); } ArrayList geometries = new ArrayList(); Geometry geometry = readGeometryTaggedText(); geometries.add(geometry); nextToken = getNextCloserOrComma(); while (nextToken.equals(COMMA)) { geometry = readGeometryTaggedText(); geometries.add(geometry); nextToken = getNextCloserOrComma(); } Geometry[] array = new Geometry[geometries.size()]; return geometryFactory.createGeometryCollection((Geometry[]) geometries.toArray(array)); } }
public static GeometryCollection multiGeometry() { return gf.createGeometryCollection(new Geometry[] {point(), lineString(), polygon()}); }
GeometryCollection geoms = gf.createGeometryCollection(toGeometryArray(list)); geoms.setSRID(SRID);