geometries.getEnvelopeInternal(), type, geometries.getNumGeometries(), fileLength);
public void testBounds() throws Exception { GeometryFactory gf = new GeometryFactory(); Geometry[] g = new Geometry[4]; g[0] = gf.createPoint(new Coordinate(0, 0)); g[1] = gf.createPoint(new Coordinate(0, 10)); g[2] = gf.createPoint(new Coordinate(10, 0)); g[3] = gf.createPoint(new Coordinate(10, 10)); GeometryCollection gc = gf.createGeometryCollection(g); SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName("bounds"); tb.setCRS(null); tb.add("p1", Point.class); tb.add("p2", Point.class); tb.add("p3", Point.class); tb.add("p4", Point.class); SimpleFeatureType t = tb.buildFeatureType(); SimpleFeature f = SimpleFeatureBuilder.build(t, g, null); assertEquals(gc.getEnvelopeInternal(), f.getBounds()); g[1].getCoordinate().y = 20; g[2].getCoordinate().x = 20; f.setAttribute(1, g[1]); f.setAttribute(2, g[2]); gc = gf.createGeometryCollection(g); assertEquals(gc.getEnvelopeInternal(), f.getBounds()); }
public void testBounds() throws Exception { PrecisionModel pm = new PrecisionModel(); Geometry[] g = new Geometry[4]; GeometryFactory gf = new GeometryFactory(pm); g[0] = gf.createPoint(new Coordinate(0, 0)); g[1] = gf.createPoint(new Coordinate(0, 10)); g[2] = gf.createPoint(new Coordinate(10, 0)); g[3] = gf.createPoint(new Coordinate(10, 10)); GeometryCollection gc = gf.createGeometryCollection(g); SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName("bounds"); tb.setCRS(null); tb.add("p1", Point.class); SimpleFeatureType t = tb.buildFeatureType(); TreeSetFeatureCollection fc = new TreeSetFeatureCollection(null, t); SimpleFeatureBuilder b = new SimpleFeatureBuilder(t); for (int i = 0; i < g.length; i++) { b.add(g[i]); fc.add(b.buildFeature(null)); } assertEquals(gc.getEnvelopeInternal(), fc.getBounds()); }
public ShapefileHeader(GeometryCollection geometries,int dims) throws Exception { ShapeHandler handle; if (geometries.getNumGeometries() == 0) { handle = new PointHandler(); //default } else { handle = Shapefile.getShapeHandler(geometries.getGeometryN(0),dims); } int numShapes = geometries.getNumGeometries(); shapeType = handle.getShapeType(); version = Shapefile.VERSION; fileCode = Shapefile.SHAPEFILE_ID; bounds = geometries.getEnvelopeInternal(); fileLength = 0; for(int i=0;i<numShapes;i++){ fileLength+=handle.getLength(geometries.getGeometryN(i)); fileLength+=4;//for each header } fileLength+=50;//space used by this, the main header indexLength = 50+(4*numShapes); }
public void testEmptyGeometryCollection() throws Exception { GeometryCollection g = geometryFactory.createGeometryCollection(null); assertEquals(-1, g.getDimension()); assertEquals(new Envelope(), g.getEnvelopeInternal()); assertTrue(g.isSimple()); }