private static Geometry readGeometryCollection(BasicSliceInput input) { List<Geometry> geometries = new ArrayList<>(); while (input.available() > 0) { // skip length input.readInt(); GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte()); geometries.add(readGeometry(input, type)); } return GEOMETRY_FACTORY.createGeometryCollection(geometries.toArray(new Geometry[0])); }
/** * Creates a GeometryCollection from a set of Geometrys * * @param geoms the component Geometrys * @return a GeometryCollection */ public GeometryCollection geometryCollection(Geometry... geoms) { return geomFact.createGeometryCollection(geoms); }
public GeometryCollection createGeometryCollection(Geometry[] geometries) { return delegate.createGeometryCollection(geometries); }
@Override public GeometryCollection createGeometryCollection(Geometry[] geometries) { if (geometries != null && geometries.length == 1) { return new CollectionOfOne(geometries, this); } else { return super.createGeometryCollection(geometries); } }
private Geometry toPolygon(GeometryFactory gf, final List<Polygon> polygons) { if (polygons.size() == 0) { return gf.createGeometryCollection(null); } else if (polygons.size() == 1) { return polygons.get(0); } else { return gf.createMultiPolygon( (Polygon[]) polygons.toArray(new Polygon[polygons.size()])); } }
public GeometryCollection toGeometryCollection(BasicDBList obj) { List<Geometry> geoms = new ArrayList<Geometry>(); for (Object o : obj) { geoms.add(toGeometry((DBObject) o)); // JG: changed from toGeometry( obj ) } return geometryFactory.createGeometryCollection(geoms.toArray(new Geometry[geoms.size()])); }
@Override protected Geometry getEmpty() { if (EMPTY == null) { EMPTY = new GeometryFactory().createGeometryCollection(new Geometry[] {}); } return EMPTY; }
@Override public Geometry build(int jjtgeometryliteral) throws CQLException { List<Geometry> geometryList = popGeometryLiteral(jjtgeometryliteral); Geometry[] geometries = geometryList.toArray(new Geometry[geometryList.size()]); GeometryCollection geometryCollection = getGeometryFactory().createGeometryCollection(geometries); return geometryCollection; } }
@Override public boolean endObject() throws ParseException, IOException { if (delegate instanceof GeometryHandlerBase) { // end of a member geometry ((GeometryHandlerBase) delegate).endObject(); Geometry geomObject = ((GeometryHandlerBase) delegate).getValue(); if (geomObject != null) geoms.add(geomObject); delegate = NULL; } else { Geometry[] geometries = geoms.toArray(new Geometry[geoms.size()]); value = factory.createGeometryCollection(geometries); geoms = null; } return true; }
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); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { ArrayList geometries = new ArrayList(); if (node.hasChild(Geometry.class)) { geometries.addAll(node.getChildValues(Geometry.class)); } if (node.hasChild(Geometry[].class)) { Geometry[] g = (Geometry[]) node.getChildValue(Geometry[].class); for (int i = 0; i < g.length; i++) geometries.add(g[i]); } return factory.createGeometryCollection( (Geometry[]) geometries.toArray(new Geometry[geometries.size()])); }
private static Geometry smoothGeometryCollection( GeometryFactory factory, GeometrySmoother smoother, Geometry geom, double fit) { final int N = geom.getNumGeometries(); Geometry[] smoothed = new Geometry[N]; for (int i = 0; i < N; i++) { smoothed[i] = smooth(geom.getGeometryN(i), fit, factory, smoother); } return factory.createGeometryCollection(smoothed); }
/** * Helper method for {@link #intersection(Geometry, Geometry) intersection(Geometry, Geometry)} */ private static GeometryCollection intersection(GeometryCollection gc1, GeometryCollection gc2) { List<Geometry> ret = new ArrayList<Geometry>(); final int size = gc1.getNumGeometries(); for (int i = 0; i < size; i++) { Geometry g1 = gc1.getGeometryN(i); List<Geometry> partial = intersection(gc2, g1); ret.addAll(partial); } return gc1.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(ret)); }
private static final Geometry cloneGeometry(GeometryCollection geom, int dimension) { if (geom.getNumGeometries() == 0) { Geometry[] gs = new Geometry[0]; return geomFac.createGeometryCollection(gs); } ArrayList gs = new ArrayList(geom.getNumGeometries()); int n = geom.getNumGeometries(); for (int t = 0; t < n; t++) { gs.add(cloneGeometry(geom.getGeometryN(t), dimension)); } return geomFac.buildGeometry(gs); }
/** @see schema.Type#getValue(java.util.List) */ public Object getValue(Element element, ElementValue[] value, Attributes attrs, Map hints) throws SAXException { Element e = value[0].getElement(); if (e == null) { if (!element.isNillable()) throw new SAXException( "Internal error, ElementValues require an associated Element."); return null; } GeometryFactory gf = new GeometryFactory(DefaultCoordinateSequenceFactory.instance()); Geometry[] geoms = new Geometry[value.length]; for (int i = 0; i < value.length; i++) { geoms[i] = (Geometry) value[i].getValue(); } return gf.createGeometryCollection(geoms); }
@Test public void testCoordinateDimensionGeometryCollectionEmpty() { Geometry geom = gf.createGeometryCollection(new Geometry[0]); // empty GCs have no sequences to carry dimension, so always report dim=3 assertEquals(3, CoordinateSequences.coordinateDimension(geom)); }
@Test public void testCoordinateDimensionGeometryCollectionEmptyLite3D() { Geometry geom = liteGF.createGeometryCollection(new Geometry[0]); assertEquals(3, CoordinateSequences.coordinateDimension(geom)); }
public void testValidConstruction() throws Exception { Literal a = new LiteralExpressionImpl(new Double(10)); Literal b = new LiteralExpressionImpl("Label"); Literal c = new LiteralExpressionImpl(Integer.valueOf(10)); GeometryFactory gf = new GeometryFactory(new PrecisionModel()); Literal d = new LiteralExpressionImpl(gf.createGeometryCollection(null)); }
private GeometryCollection makeSampleGeometryCollection(final GeometryFactory geomFac) { try { Geometry polyg = buildShiftedGeometry(makeSamplePolygon(geomFac), 50, 50); Geometry lineString = buildShiftedGeometry(makeSampleLineString(geomFac), 50, 50); return geomFac.createGeometryCollection(new Geometry[] {polyg, lineString}); } catch (TopologyException te) { fail("Error creating sample polygon for testing " + te); } return null; }
@DescribeProcess( title = "Polygonize", description = "Creates a set of polygons from linestrings delineating them. The linestrings must be correctly noded (i.e. touch only at endpoints)." ) @DescribeResult(description = "The collection of created polygons") public static Geometry polygonize( @DescribeParameter(name = "geom", description = "Linework to polygonize") Geometry geom) { @SuppressWarnings("rawtypes") List lines = LineStringExtracter.getLines(geom); Polygonizer polygonizer = new Polygonizer(); polygonizer.add(lines); @SuppressWarnings("rawtypes") Collection polys = polygonizer.getPolygons(); Polygon[] polyArray = GeometryFactory.toPolygonArray(polys); return geom.getFactory().createGeometryCollection(polyArray); }