This is an explicit interface for FeatureIterator. Sample use: SimpleFeatureIterator i = featureCollection.features() try { while( i.hasNext() ){ SimpleFeature feature = i.next(); } } finally { i.close(); } @author Jody Garnett @source $URL$
Sample use:
SimpleFeatureIterator i = featureCollection.features() try { while( i.hasNext() ){ SimpleFeature feature = i.next(); } } finally { i.close(); }
425426427428429430431432433434435436437438439440441442
String typeName = tmpFile.getName().substring(0, tmpFile.getName().lastIndexOf(".csv")); SimpleFeatureCollection fc = s.getFeatureSource(typeName).getFeatures(); assertEquals(features.size(), fc.size()); // Read int c = 0; SimpleFeatureIterator it = fc.features(); try { while (it.hasNext()) { SimpleFeature f = it.next(); assertNotNull(f); assertNotNull(f.getDefaultGeometry()); c++; } } finally { it.close(); } assertEquals(fc.size(), c); }
455456457458459460461462463464465466467468469470471472
String typeName = tmpFile.getName().substring(0, tmpFile.getName().lastIndexOf(".gmt")); SimpleFeatureCollection fc = s.getFeatureSource(typeName).getFeatures(); assertEquals(features.size(), fc.size()); // Read int c = 0; SimpleFeatureIterator it = fc.features(); try { while (it.hasNext()) { SimpleFeature f = it.next(); assertNotNull(f); assertNotNull(f.getDefaultGeometry()); c++; } } finally { it.close(); } assertEquals(fc.size(), c); }
487488489490491492493494495496497498499500501502503504
assertEquals(5, s.getTypeNames().length); SimpleFeatureCollection fc = s.getFeatureSource("waypoints").getFeatures(); assertEquals(features.size(), fc.size()); // Read int c = 0; SimpleFeatureIterator it = fc.features(); try { while (it.hasNext()) { SimpleFeature f = it.next(); assertNotNull(f); assertNotNull(f.getDefaultGeometry()); c++; } } finally { it.close(); } assertEquals(fc.size(), c); }
516517518519520521522523524525526527528529530531532533
assertEquals(1, s.getTypeNames().length); SimpleFeatureCollection fc = s.getFeatureSource("junk").getFeatures(); assertEquals(features.size(), fc.size()); // Read int c = 0; SimpleFeatureIterator it = fc.features(); try { while (it.hasNext()) { SimpleFeature f = it.next(); assertNotNull(f); assertNotNull(f.getDefaultGeometry()); c++; } } finally { it.close(); } assertEquals(fc.size(), c); }
545546547548549550551552553554555556557558559560561562
581582583584585586587588589590591592593594595596597598
assertEquals(1, s.getTypeNames().length); SimpleFeatureCollection fc = s.getFeatureSource("georss").getFeatures(); assertEquals(features.size(), fc.size()); // Read int c = 0; SimpleFeatureIterator it = fc.features(); try { while (it.hasNext()) { SimpleFeature f = it.next(); assertNotNull(f); assertNotNull(f.getDefaultGeometry()); c++; } } finally { it.close(); } assertEquals(fc.size(), c); }
628629630631632633634635636637638639640641642643644645
662663664665666667668669670671672673674675676677678679
}); SimpleFeatureCollection fc = s.getFeatureSource("junk").getFeatures(query); assertEquals(features.size(), fc.size()); // Read int c = 0; SimpleFeatureIterator it = fc.features(); try { while (it.hasNext()) { SimpleFeature f = it.next(); assertNotNull(f); assertNotNull(f.getDefaultGeometry()); c++; } } finally { it.close(); } assertEquals(fc.size(), c); }
690691692693694695696697698699700701702703704705706707708
assertEquals(1, s.getTypeNames().length); SimpleFeatureCollection fc = s.getFeatureSource("points").getFeatures(); assertEquals(features.size(), fc.size()); // Read int c = 0; SimpleFeatureIterator it = fc.features(); try { while(it.hasNext()) { SimpleFeature f = it.next(); assertNotNull(f); assertNotNull(f.getDefaultGeometry()); assertNotNull(f.getAttribute("name")); c++; } } finally { it.close(); } assertEquals(fc.size(), c); }
743744745746747748749750751752753754
// SUPPORT METHODS // --------------------------------------------------------------------------------------- private int countFeatures(SimpleFeatureCollection features) { int count = 0; SimpleFeatureIterator fi = features.features(); while(fi.hasNext()) { fi.next(); count++; } return count; }