use of org.geotools.util.NullProgressListener in project polymap4-core by Polymap4.
the class RFeatureCollection method accepts.
@Override
public void accepts(FeatureVisitor visitor, ProgressListener progress) throws IOException {
// prevent call of size() if no progress is given
float _size = progress != null ? size() : 0;
progress = progress != null ? progress : new NullProgressListener();
Iterator it = null;
try {
float position = 0;
progress.started();
for (it = iterator(); !progress.isCanceled() && it.hasNext(); ) {
if (_size > 0) {
progress.progress(position++ / _size);
}
try {
visitor.visit((Feature) it.next());
} catch (Exception e) {
log.warn("Error while visiting features.", e);
progress.exceptionOccurred(e);
}
}
} finally {
progress.complete();
}
}
use of org.geotools.util.NullProgressListener in project chordatlas by twak.
the class Footprints method test.
public static void test() throws IOException, SAXException, ParserConfigurationException {
// create the parser with the gml 2.0 configuration
org.geotools.xml.Configuration configuration = new org.geotools.gml2.GMLConfiguration();
org.geotools.xml.Parser parser = new org.geotools.xml.Parser(configuration);
InputStream xml = new FileInputStream("/home/twak/data/around_ucl_buildings.gml");
// parse
FeatureCollection fc = (FeatureCollection) parser.parse(xml);
fc.accepts(new AbstractFeatureVisitor() {
public void visit(Feature feature) {
System.out.println(feature);
// SimpleFeature f = (Feature) i.next();
//
// Point point = (Point) f.getDefaultGeometry();
// String name = (String) f.getAttribute( "name" );
}
}, new NullProgressListener());
}
Aggregations