@Test public void testFeatureSimple() throws Exception { Template template = cfg.getTemplate("FeatureSimple.ftl"); StringWriter out = new StringWriter(); template.process(features.iterator().next(), out); // replace ',' with '.' for locales which use a comma for decimal point assertEquals( "one\n1\n1.1\nPOINT (1 1)", out.toString().replace(',', '.').replaceAll("\r\n", "\n").replaceAll("\r", "\n")); }
@Test public void testFeatureDynamic() throws Exception { Template template = cfg.getTemplate("FeatureDynamic.ftl"); StringWriter out = new StringWriter(); template.process(features.iterator().next(), out); // replace ',' with '.' for locales which use a comma for decimal point assertEquals( "string=one\nint=1\ndouble=1.1\ngeom=POINT (1 1)\n", out.toString().replace(',', '.').replaceAll("\r\n", "\n").replaceAll("\r", "\n")); }
public void testNormal() throws Exception { Iterator reproject = new ReprojectFeatureResults(delegate, target).iterator(); Iterator reader = delegate.iterator(); while (reader.hasNext()) { SimpleFeature normal = (SimpleFeature) reader.next(); SimpleFeature reprojected = (SimpleFeature) reproject.next(); Point p1 = (Point) normal.getAttribute("defaultGeom"); Point p2 = (Point) reprojected.getAttribute("defaultGeom"); if (p1 != null) { assertEquals(crs, p1.getUserData()); assertEquals(target, p2.getUserData()); p1 = (Point) transformer.transform(p1); assertTrue(p1.equalsExact(p2)); } else { assertNull(p2); } LineString l1 = (LineString) normal.getAttribute("otherGeom"); LineString l2 = (LineString) reprojected.getAttribute("otherGeom"); if (l1 != null) { l1 = (LineString) transformer.transform(l1); assertTrue(l1.equalsExact(l2)); } else { assertNull(l2); } } }
public void accepts(org.opengis.feature.FeatureVisitor visitor, org.opengis.util.ProgressListener progress) { Iterator iterator = null; if (progress == null) progress = new NullProgressListener(); try{ float size = size(); float position = 0; progress.started(); for( iterator = iterator(); !progress.isCanceled() && iterator.hasNext(); progress.progress( position++/size )){ try { SimpleFeature feature = (SimpleFeature) iterator.next(); visitor.visit(feature); } catch( Exception erp ){ progress.exceptionOccurred( erp ); } } } finally { progress.complete(); close( iterator ); } }
/** * Accepts a visitor, which then visits each feature in the collection. * @throws IOException */ public void accepts(FeatureVisitor visitor, ProgressListener progress ) throws IOException { Iterator iterator = null; if (progress == null) progress = new NullProgressListener(); try{ float size = size(); float position = 0; progress.started(); for( iterator = iterator(); !progress.isCanceled() && iterator.hasNext(); progress.progress( position++/size )){ try { Feature feature = (Feature) iterator.next(); visitor.visit(feature); } catch( Exception erp ){ progress.exceptionOccurred( erp ); } } } finally { progress.complete(); close( iterator ); } }