/** * Creates an empty {@code GeometryCollection} for a coordinate reference system * * @param crs the coordinate reference system for the created {@code GeometryCollection} * @param <P> the type of {@code Position} * @return an empty {@code GeometryCollection} with the specified coordinate reference system */ public static <P extends Position> GeometryCollection<P, Geometry<P>> mkEmptyGeometryCollection(CoordinateReferenceSystem<P> crs) { return new GeometryCollection<>(crs); }
private boolean equals(GeometryCollection first, GeometryCollection second) { if (first.getNumGeometries() != second.getNumGeometries()) return false; for (int i = 0; i < first.getNumGeometries(); i++) { if (! equals(first.getGeometryN(i), second.getGeometryN(i))) return false; } return true; } }
private static GeometryCollection convertCollection(JGeometry geometry) { JGeometry[] elements = geometry.getElements(); if (elements == null || elements.length == 0) { return GeometryCollection.createEmpty(); } Geometry[] geometries = new Geometry[elements.length]; for (int i = 0; i < elements.length; i++) { geometries[i] = convert(elements[i]); } return new GeometryCollection(geometries); }
/** * Constructs a <code>GeometryCollection</code> from the specified <code>Geometry</code>s. * * @param geometries the <code>Geometry</code>s that are the elements of the constructed <code>GeometryCollection</code>. */ @SafeVarargs public GeometryCollection(G... geometries) { super(nestPositionSequences(geometries), getCrs(geometries)); check(geometries); this.geometries = Arrays.copyOf(geometries, geometries.length); }
private static org.postgis.GeometryCollection convert(GeometryCollection geometryCollection) { org.postgis.Geometry[] pgGeometries = new org.postgis.Geometry[geometryCollection.getNumGeometries()]; for (int i = 0; i < pgGeometries.length; i++) { pgGeometries[i] = convert(geometryCollection.getGeometryN(i)); } org.postgis.GeometryCollection pgGeometryCollection = new org.postgis.GeometryCollection(pgGeometries); pgGeometryCollection.setSrid(geometryCollection.getSRID()); return pgGeometryCollection; }
@Override public <G extends Geometry<P>> void visit(GeometryCollection<P,G> geom) { writeByteOrder(output); writeTypeCodeAndSrid(geom, output); output.putUInt(geom.getNumGeometries()); }
private static org.postgis.GeometryCollection convert(GeometryCollection geometryCollection) { org.postgis.Geometry[] pgGeometries = new org.postgis.Geometry[geometryCollection.getNumGeometries()]; for (int i = 0; i < pgGeometries.length; i++) { pgGeometries[i] = convert(geometryCollection.getGeometryN(i)); } org.postgis.GeometryCollection pgGeometryCollection = new org.postgis.GeometryCollection(pgGeometries); pgGeometryCollection.setSrid(geometryCollection.getSRID()); return pgGeometryCollection; }
public static <P extends Position> GeometryCollection<P, Geometry<P>> mkGeometryCollection(Geometry<P>... geometries) { return new GeometryCollection<P, Geometry<P>>(geometries); }
private static <P extends Position> GeometryCollection to(org.geolatte.geom.GeometryCollection<P, org.geolatte .geom.Geometry<P>> collection, GeometryFactory gFact) { Geometry[] geoms = new Geometry[collection.getNumGeometries()]; for (int i = 0; i < collection.getNumGeometries(); i++) { geoms[i] = to(collection.getGeometryN(i)); } return gFact.createGeometryCollection(geoms); }
private static GeometryCollection convertCollection(JGeometry geometry) { JGeometry[] elements = geometry.getElements(); if (elements == null || elements.length == 0) { return GeometryCollection.createEmpty(); } Geometry[] geometries = new Geometry[elements.length]; for (int i = 0; i < elements.length; i++) { geometries[i] = convert(elements[i]); } return new GeometryCollection(geometries); }
public static <P extends Position> GeometryCollection<P, Geometry<P>> mkGeometryCollection(List<Geometry<P>> geometries) { Geometry<P>[] geomArr = (Geometry<P>[]) new Geometry[geometries.size()]; return new GeometryCollection<P, Geometry<P>>(geometries.toArray(geomArr)); }
@Override @SuppressWarnings("unchecked") public <P extends Position, G extends Geometry<P>> SDOGeometry encode(G geom) { GeometryCollection<P, Geometry<P>> collection = (GeometryCollection<P, Geometry<P>>)geom; final SDOGeometry[] sdoElements = new SDOGeometry[collection.getNumGeometries()]; for (int i = 0; i < collection.getNumGeometries(); i++) { final Geometry component = collection.getGeometryN(i); sdoElements[i] = Encoders.encode(component); } final SDOGeometry ccollect = join(sdoElements); return ccollect; }
private GeometryCollection decodeGeometryCollection(int shapeIdx) { List<Geometry> geometries = Lists.newArrayList(); for (int i = shapeIdx; i < shapes.length; i++) { if (shapes[i].parentOffset == shapeIdx) { geometries.add(decode(i)); } } return new GeometryCollection(geometries.toArray(new Geometry[0])); }
public void visit(GeometryCollection collection, int parent) { Shape shape = new Shape(); shape.type = GEOMETRY_COLLECTION; shape.figureOffset = figures.size(); shape.parentOffset = parent; shapes.add(shape); parent = shapes.size() - 1; for (int i = 0; i < collection.getNumGeometries(); i++) { visit(collection.getGeometryN(i), parent); } }
/** * Creates a {@code GeometryCollection} from the specified {@code Geometry}s. * @param geometry the first constituent {@code Geometry} * @param geometries the rest of the constituent {@code Geometry}s * @param <P> the {@code Position} type * @return the {@code GeometryCollection} of the specified constituent {@code Geometry}s. */ @SuppressWarnings("unchecked") @SafeVarargs public static <P extends Position> GeometryCollection<P, Geometry<P>> geometrycollection(Geometry<P> geometry, Geometry<P>... geometries) { return new GeometryCollection<P, Geometry<P>>(combine(Geometry.class, geometry, geometries)); }
public void visit(GeometryCollection collection, int parent) { Shape shape = new Shape(); shape.type = GEOMETRY_COLLECTION; shape.figureOffset = figures.size(); shape.parentOffset = parent; shapes.add(shape); parent = shapes.size() - 1; for (int i = 0; i < collection.getNumGeometries(); i++) { visit(collection.getGeometryN(i), parent); } }
private GeometryCollection decodeGeometryCollection(int shapeIdx) { List<Geometry> geometries = Lists.newArrayList(); for (int i = shapeIdx; i < shapes.length; i++) { if (shapes[i].parentOffset == shapeIdx) { geometries.add(decode(i)); } } return new GeometryCollection(geometries.toArray(new Geometry[0])); }
private <P extends Position, G extends Geometry<P>> void addGeometries(GeometryCollection<P,G> collection, boolean withTag) { inGeometryCollection = true; for (int i = 0; i < collection.getNumGeometries(); i++) { if (i > 0) { addDelimiter(); } Geometry geom = collection.getGeometryN(i); if (withTag) { addGeometry(geom); } else { addGeometryText(geom); } } }
/** * Creates a {@code GeometryCollection} from the specified {@code GeometryToken}s and {@code CoordinateReferenceSystem}. * * @param crs the {@code CoordinateReferenceSystem} for the {@code GeometryCollection} * @param tokens the {@code GeometryTokens} for the constituent {@code Geometry}s of the returned {@code GeometryCollection} * @param <P> the {@code Position} type * @return the {@code GeometryCollection} of the specified constituent {@code Geometry}s and {@code CoordinateReferenceSystem} */ @SuppressWarnings("unchecked") @SafeVarargs public static <P extends Position> GeometryCollection<P, Geometry<P>> geometrycollection(CoordinateReferenceSystem<P> crs, GeometryToken<P>... tokens) { if (tokens.length == 0) return new GeometryCollection<P, Geometry<P>>(crs); Geometry<P>[] parts = new Geometry[tokens.length]; int idx = 0; for (GeometryToken t : tokens) { parts[idx++] = t.toGeometry(crs); } return new GeometryCollection<P, Geometry<P>>(parts); }
@Override protected void encode(Geometry<?> geom, int parentShapeIndex, CountingPositionSequenceBuilder<?> coordinates, List<Figure> figures, List<Shape> shapes) { if ( geom.isEmpty() ) { shapes.add( new Shape( parentShapeIndex, -1, this.openGisType ) ); return; } int thisShapeIndex = shapes.size(); Shape thisShape = createShape( parentShapeIndex, figures ); shapes.add( thisShape ); if (! (geom instanceof GeometryCollection)) { throw new IllegalArgumentException( "Expect GeometryCollection argument." ); } GeometryCollection gc = (GeometryCollection) geom; for ( int i = 0; i < gc.getNumGeometries(); i++ ) { Geometry component = gc.getGeometryN( i ); encodeComponent( component, thisShapeIndex, coordinates, figures, shapes ); } }