public void testSetsEnvelopeCrsFromQuery() throws Exception { Query query = new Query(Query.ALL); query.setCoordinateSystem(DefaultEngineeringCRS.CARTESIAN_2D); ReferencedEnvelope envelope = data.getFeatureSource("river").getBounds(query); assertEquals(DefaultEngineeringCRS.CARTESIAN_2D, envelope.getCoordinateReferenceSystem()); assertEquals( new ReferencedEnvelope(riverBounds, DefaultEngineeringCRS.CARTESIAN_2D), envelope); }
public void testGetBoundsSupportsEmptyBounds() throws Exception { SimpleFeatureType type = DataUtilities.createType(getName() + ".test", "id:0,geom:LineString,name:String"); SimpleFeature[] features = new SimpleFeature[3]; features[0] = SimpleFeatureBuilder.build(type, new Object[] {1, null, "r1"}, "test.f1"); features[1] = SimpleFeatureBuilder.build(type, new Object[] {2, null, "r2"}, "test.f2"); features[2] = SimpleFeatureBuilder.build(type, new Object[] {3, null, "r3"}, "test.f3"); data.addFeatures(features); SimpleFeatureSource featureSource = data.getFeatureSource("test"); assertTrue(featureSource.getBounds(Query.ALL).isEmpty()); } }
public void testNoCrs() throws Exception { Query query = new Query(Query.ALL); ReferencedEnvelope envelope = data.getFeatureSource("road").getBounds(query); assertNull(envelope.getCoordinateReferenceSystem()); }
public void testGetBounds() throws Exception { assertEquals(roadBounds, data.getFeatureSource("road").getBounds(Query.ALL)); }
public void testReprojectEnvelopeCrsFromQuery() throws Exception { Query query = new Query(Query.ALL); CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326"); CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3005"); query.setCoordinateSystemReproject(targetCRS); ReferencedEnvelope envelope = data.getFeatureSource("river").getBounds(query); assertEquals(targetCRS, envelope.getCoordinateReferenceSystem()); assertEquals( new ReferencedEnvelope(riverBounds, sourceCRS).transform(targetCRS, true), envelope); }
public void testSetReprojectEnvelopeCrsFromQuery() throws Exception { Query query = new Query(Query.ALL); query.setCoordinateSystem(DefaultEngineeringCRS.GENERIC_2D); query.setCoordinateSystemReproject(DefaultEngineeringCRS.CARTESIAN_2D); ReferencedEnvelope envelope = data.getFeatureSource("river").getBounds(query); assertEquals(DefaultEngineeringCRS.CARTESIAN_2D, envelope.getCoordinateReferenceSystem()); assertEquals( new ReferencedEnvelope(riverBounds, DefaultEngineeringCRS.GENERIC_2D) .transform(DefaultEngineeringCRS.CARTESIAN_2D, true), envelope); }
public void testSetsEnvelopeCrsFromFeatureType() throws Exception { Query query = new Query(Query.ALL); CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326"); ReferencedEnvelope envelope = data.getFeatureSource("river").getBounds(query); assertEquals(sourceCRS, envelope.getCoordinateReferenceSystem()); }
public void testGetBoundsFilter() throws Exception { // the Bounds of the queried features should be equal to the bounding // box of the road2 feature, because of the road2 FID filter Query query = new Query("road", rd2Filter); assertEquals( roadFeatures[1].getBounds(), data.getFeatureSource("road").getFeatures(query).getBounds()); }
public void testGetBoundsSupportsFeaturesWithoutGeometry() throws Exception { SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(data.getSchema("road")); featureBuilder.init(roadFeatures[0]); featureBuilder.set("geom", null); SimpleFeature feature = featureBuilder.buildFeature("road.rd0"); data.addFeature(feature); SimpleFeatureSource road = data.getFeatureSource("road"); assertEquals(roadBounds, road.getBounds(Query.ALL)); }