public void testIterator() throws Exception { FeatureIterator<SimpleFeature> i = collection.features(); assertNotNull(i); assertFeatureIterator( 0, 3, i, new SimpleFeatureAssertion() { public int toIndex(SimpleFeature feature) { return ((Number) feature.getAttribute(aname("intProperty"))).intValue(); } public void check(int index, SimpleFeature feature) { assertNotNull(feature); String fid = feature.getID(); int id = Integer.parseInt(fid.substring(fid.indexOf('.') + 1)); assertEquals(index, id); } }); }
public void testBounds() throws IOException { ReferencedEnvelope bounds = collection.getBounds(); assertNotNull(bounds); assertEquals(0d, bounds.getMinX(), 0.1); assertEquals(0d, bounds.getMinY(), 0.1); assertEquals(2d, bounds.getMaxX(), 0.1); assertEquals(2d, bounds.getMaxY(), 0.1); }
public void testSubCollection() throws Exception { FilterFactory ff = dataStore.getFilterFactory(); Filter f = ff.equals(ff.property(aname("intProperty")), ff.literal(1)); SimpleFeatureCollection sub = collection.subCollection(f); assertNotNull(sub); assertEquals(1, sub.size()); ReferencedEnvelope exp = new ReferencedEnvelope(1, 1, 1, 1, CRS.decode("EPSG:4326")); ReferencedEnvelope act = sub.getBounds(); assertEquals(exp.getMinX(), act.getMinX(), 0.1); assertEquals(exp.getMinY(), act.getMinY(), 0.1); assertEquals(exp.getMaxX(), act.getMaxX(), 0.1); assertEquals(exp.getMaxY(), act.getMaxY(), 0.1); }