@SuppressWarnings("unchecked") public <T> T[] toArray(T[] a) { List<T> list = new ArrayList<T>(); SimpleFeatureIterator i = features(); try { while (i.hasNext()) { list.add((T) i.next()); } return list.toArray(a); } finally { i.close(); } }
public FeatureReader<SimpleFeatureType, SimpleFeature> reader() throws IOException { return new DelegateFeatureReader<SimpleFeatureType, SimpleFeature>(getSchema(), features()); }
/** * This method computes reprojected bounds the hard way, but computing them feature by feature. * This method could be faster if computed the reprojected bounds by reprojecting the original * feature bounds a Shape object, thus getting the true shape of the reprojected envelope, and * then computing the minimum and maximum coordinates of that new shape. The result would not a * true representation of the new bounds. * * @see org.geotools.data.FeatureResults#getBounds() */ public ReferencedEnvelope getBounds() { SimpleFeatureIterator r = features(); try { Envelope newBBox = new Envelope(); Envelope internal; SimpleFeature feature; while (r.hasNext()) { feature = r.next(); final Geometry geom = ((Geometry) feature.getDefaultGeometry()); if (geom != null) { internal = geom.getEnvelopeInternal(); newBBox.expandToInclude(internal); } } return new ReferencedEnvelope(newBBox, target); } catch (Exception e) { throw new RuntimeException("Exception occurred while computing reprojected bounds", e); } finally { r.close(); } }
public void testLenient() throws Exception { CoordinateReferenceSystem lenientTarget; lenientTarget = CRS.parseWKT( "PROJCS[\"MGI (Ferro) / Austria GK West Zone\",GEOGCS[\"MGI (Ferro)\",DATUM[\"Militar_Geographische_Institut_Ferro\",SPHEROID[\"Bessel 1841\",6377397.155,299.1528128,AUTHORITY[\"EPSG\",\"7004\"]],AUTHORITY[\"EPSG\",\"6805\"]],PRIMEM[\"Ferro\",-17.66666666666667,AUTHORITY[\"EPSG\",\"8909\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4805\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",28],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",-5000000],AUTHORITY[\"EPSG\",\"31251\"],AXIS[\"Y\",EAST],AXIS[\"X\",NORTH]]"); SimpleFeatureIterator reproject = new ReprojectingFeatureCollection(delegate, lenientTarget).features(); reproject.close(); }
public FeatureReader<SimpleFeatureType, SimpleFeature> reader() throws IOException { return new DelegateFeatureReader<SimpleFeatureType, SimpleFeature>(getSchema(), features()); }
public FeatureReader reader() throws IOException { return new DelegateFeatureReader(getSchema(), features()); }
public void testNormal() throws Exception { SimpleFeatureIterator reproject = new ReprojectingFeatureCollection(delegate, target).features(); SimpleFeatureIterator reader = delegate.features(); try { 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) { 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); } } } finally { reproject.close(); reader.close(); } }
SimpleFeatureIterator r = features(); try { Envelope newBBox = new Envelope();
FeatureIterator r = features(); try { Envelope newBBox = new Envelope();