@Override public ShapeCollection getBuffered(double distance, SpatialContext ctx) { List<Shape> bufColl = new ArrayList<Shape>(size()); for (Shape shape : shapes) { bufColl.add(shape.getBuffered(distance, ctx)); } return ctx.makeCollection(bufColl); }
public void writeCollection(DataOutput dataOutput, ShapeCollection col) throws IOException { byte type = (byte) 0;//TODO add type to ShapeCollection dataOutput.writeByte(type); dataOutput.writeInt(col.size()); for (int i = 0; i < col.size(); i++) { Shape s = col.get(i); if (type == 0) { writeShape(dataOutput, s); } else { boolean written = writeShapeByTypeIfSupported(dataOutput, s, type); if (!written) throw new IllegalArgumentException("Unsupported shape type "+s.getClass()); } } }
gen.writeFieldName("geometries"); gen.writeStartArray(); for (int i = 0; i < v.size(); i++) { write(gen, v.get(i));
ShapeCollection v = (ShapeCollection) shape; output.append("{\"type\":\"GeometryCollection\",\"geometries\":["); for (int i = 0; i < v.size(); i++) { if (i > 0) { output.append(',');
@Override public ODocument toDoc(ShapeCollection<Shape> shapes) { ODocument doc = new ODocument(getName()); List<ODocument> geometries = new ArrayList<ODocument>(shapes.size()); for (Shape s : shapes) { geometries.add(shapeFactory.toDoc(s)); } doc.field("geometries", geometries); return doc; } }
@Override public String asText(ShapeCollection<Shape> shapes) { Geometry[] geometries = new Geometry[shapes.size()]; int i = 0; for (Shape shape : shapes) { geometries[i] = SPATIAL_CONTEXT.getGeometryFrom(shape); i++; } return GEOMETRY_FACTORY.createGeometryCollection(geometries).toText(); }
protected JtsGeometry createMultiLine(ShapeCollection<JtsGeometry> geometries) { LineString[] multiLineString = new LineString[geometries.size()]; int i = 0; for (JtsGeometry geometry : geometries) { multiLineString[i] = (LineString) geometry.getGeom(); i++; } MultiLineString multiPoints = GEOMETRY_FACTORY.createMultiLineString(multiLineString); return SPATIAL_CONTEXT.makeShape(multiPoints); }
public Geometry toGeometry(Shape shape) { if(shape instanceof ShapeCollection){ ShapeCollection<Shape> shapes = (ShapeCollection<Shape>) shape; Geometry[] geometries = new Geometry[shapes.size()]; int i = 0; for (Shape shapeItem : shapes) { geometries[i] = SPATIAL_CONTEXT.getGeometryFrom(shapeItem); i++; } return GEOMETRY_FACTORY.createGeometryCollection(geometries); } else { return SPATIAL_CONTEXT.getGeometryFrom(shape); } }
protected JtsGeometry createMultiPolygon(ShapeCollection<Shape> geometries) { Polygon[] polygons = new Polygon[geometries.size()]; int i = 0; for (Shape geometry : geometries) { if (geometry instanceof JtsGeometry) { polygons[i] = (Polygon) ((JtsGeometry) geometry).getGeom(); } else { Rectangle rectangle = (Rectangle) geometry; Geometry geometryFrom = SPATIAL_CONTEXT.getGeometryFrom(rectangle); polygons[i] = (Polygon) geometryFrom; } i++; } MultiPolygon multiPolygon = GEOMETRY_FACTORY.createMultiPolygon(polygons); return SPATIAL_CONTEXT.makeShape(multiPolygon); }
protected JtsGeometry createMultiPoint(ShapeCollection<JtsPoint> geometries) { Coordinate[] points = new Coordinate[geometries.size()]; int i = 0; for (JtsPoint geometry : geometries) { points[i] = new Coordinate(geometry.getX(), geometry.getY()); i++; } MultiPoint multiPoints = GEOMETRY_FACTORY.createMultiPoint(points); return SPATIAL_CONTEXT.makeShape(multiPoints); }