if (cnode.getValue() instanceof Geometry) {
geoms.add(cnode.getValue());
}
}
GeometryCollection gc = null;
if (MultiPoint.class.isAssignableFrom(clazz)) {
gc = gFactory.createMultiPoint((Point[]) geoms.toArray(new Point[geoms.size()]));
}
else if (MultiLineString.class.isAssignableFrom(clazz)) {
gc = gFactory.createMultiLineString(
(LineString[]) geoms.toArray(new LineString[geoms.size()]));
}
else if (MultiPolygon.class.isAssignableFrom(clazz)) {
gc = gFactory.createMultiPolygon((Polygon[]) geoms.toArray(new Polygon[geoms.size()]));
}
else {
gc = gFactory.createGeometryCollection((Geometry[]) geoms.toArray(
new Geometry[geoms.size()]));
}
//set an srs if there is one
CoordinateReferenceSystem crs = crs(node);
if (crs != null) {
gc.setUserData(crs);
// since we're setting the CRS on the UserData object, might as well set the SRID for the geom
// collection
try {
gc.setSRID(CRS.lookupEpsgCode(crs, true));
} catch (FactoryException e) {
// as long as the provided CRS is valid, this block will be unreachable
}
}