/** * Retreives the bounds for a feature source. * * <p>If the feautre source can calculate the bounds directly, those bounds are returned. * Otherwise, the underlying feature collection is retreived and asked to calculate bounds. If * that fails, an empty envelope is returned. * * @param fs The feature source. * @return The bounds. * @throws IOException Execption calculating bounds on feature source. */ public static ReferencedEnvelope getBoundingBoxEnvelope( FeatureSource<? extends FeatureType, ? extends Feature> fs) throws IOException { ReferencedEnvelope ev = fs.getBounds(); if ((ev == null) || ev.isNull()) { try { ev = fs.getFeatures().getBounds(); } catch (Throwable t) { LOGGER.log( Level.FINE, "Could not compute the data bounding box. Returning an empty envelope", t); ev = new ReferencedEnvelope(fs.getSchema().getCoordinateReferenceSystem()); } } return ev; } }
/** Returns {@code true} if lengths along all dimension are zero. */ public boolean isEmpty() { return super.isNull(); }
private boolean isNotEmpty(ReferencedEnvelope envelope) { return !envelope.isEmpty() && !envelope.isNull() && envelope.getWidth() > 0 && envelope.getHeight() > 0; }
@Test public void testExpandToIncludeNull() throws Exception { ReferencedEnvelope r1 = new ReferencedEnvelope(DefaultGeographicCRS.WGS84); ReferencedEnvelope r2 = new ReferencedEnvelope(DefaultGeographicCRS.WGS84); assertTrue(r1.isNull()); assertTrue(r2.isNull()); r1.expandToInclude(r2); assertTrue(r1.isNull()); }
if (env != null && !env.isNull()) { result.add(env);
if (bounds == null || bounds.isNull()) {
public static Integer getEnvelopeDimension(ReferencedEnvelope e, Configuration configuration) { if (e == null || e.isNull() || e.getCoordinateReferenceSystem() == null) { return null; } // check if srsDimension is turned off if (configuration.hasProperty(GMLConfiguration.NO_SRS_DIMENSION)) { return null; } return e.getCoordinateReferenceSystem().getCoordinateSystem().getDimension(); } }
if (layerBounds == null || layerBounds.isEmpty() || layerBounds.isNull()) { continue;
if (env != null && !env.isNull()) result.add(env);
GridFeatureBuilder gridFeatureBuilder) { if (bounds == null || bounds.isEmpty() || bounds.isNull()) { throw new IllegalArgumentException("bounds should not be null or empty");
GridFeatureBuilder lineFeatureBuilder) { if (bounds == null || bounds.isEmpty() || bounds.isNull()) { throw new IllegalArgumentException("The bounds should not be null or empty");
GridFeatureBuilder gridFeatureBuilder) { if (bounds == null || bounds.isEmpty() || bounds.isNull()) { throw new IllegalArgumentException("bounds should not be null or empty");
/** * Calculate bounds from features * * @return */ protected ReferencedEnvelope calculateBounds() { ReferencedEnvelope extent = ReferencedEnvelope.create(getSchema().getCoordinateReferenceSystem()); for (SimpleFeature feature : list) { if (feature == null) { continue; } ReferencedEnvelope bbox = ReferencedEnvelope.reference(feature.getBounds()); if (bbox == null || bbox.isEmpty() || bbox.isNull()) { continue; } extent.expandToInclude(bbox); } return extent; }
public void testFeatureSource() throws Exception { FeatureSource fs = dataStore.getFeatureSource(tname("empty")); assertNotNull(fs); ReferencedEnvelope bounds = fs.getBounds(); assertTrue(bounds.isNull()); int count = fs.getCount(Query.ALL); assertEquals(0, count); }
targetEnvelope.intersection(coveragesEnvelope), renderingEnvelope.getCoordinateReferenceSystem()); if (targetEnvelope.isEmpty() || targetEnvelope.isNull()) { return null;
public void testFeatureCollection() throws Exception { FeatureSource fs = dataStore.getFeatureSource(tname("empty")); FeatureCollection features = fs.getFeatures(); assertTrue(features.getBounds().isNull()); assertEquals(0, features.size()); try (FeatureIterator i = features.features()) { assertFalse(i.hasNext()); } } }
if (bbox == null || bbox.isNull() || bbox.isEmpty()) { return;
assertNotNull(typeName + " bounds", dataBounds); assertFalse(typeName + " bounds empty", dataBounds.isEmpty()); assertFalse(typeName + " bounds null", dataBounds.isNull()); DefaultGeographicCRS.WGS84, bounds.getCoordinateReferenceSystem())); assertFalse(typeName + " world empty", bounds.isEmpty()); assertFalse(typeName + " world null", bounds.isNull()); assertTrue( "reference point_test_2d bounds available", !reference.isEmpty() && !reference.isNull()); assertTrue( "bounds WGS84",
assertTrue("This is a null envelope", everything.isNull());