@Override public boolean isEmpty() { return env.isEmpty(); }
private void copyBounds(ReferencedEnvelope newBounds) { if (newBounds == null || newBounds.isEmpty()) { this.bounds = new ReferencedEnvelope(); } else { this.bounds = new ReferencedEnvelope(newBounds); } }
public CalcResult getResult() { if (bounds == null || bounds.isEmpty()) { return CalcResult.NULL_RESULT; } return new BoundsResult(bounds); }
/** * Checks if the view port bounds are empty (undefined). This will be {@code true} if either or * both of the world bounds and screen bounds are empty. * * @return {@code true} if empty */ public boolean isEmpty() { lock.readLock().lock(); try { return screenArea.isEmpty() || bounds.isEmpty(); } finally { lock.readLock().unlock(); } }
@Test public void testGeometryless() throws Exception { // build a feature type (it's already in the catalog, but we just want to // check it's built as expected // LINES is a feature type with a native SRS, so we want the bounds to be there Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); cb.setStore(cat.getDataStoreByName(MockData.GEOMETRYLESS.getPrefix())); FeatureTypeInfo fti = cb.buildFeatureType(toName(MockData.GEOMETRYLESS)); LayerInfo layer = cb.buildLayer(fti); cb.setupBounds(fti); // perform basic checks assertEquals(CatalogBuilder.DEFAULT_SRS, fti.getSRS()); assertNotNull(fti.getNativeBoundingBox()); assertTrue(fti.getNativeBoundingBox().isEmpty()); assertNotNull(fti.getLatLonBoundingBox()); assertFalse(fti.getLatLonBoundingBox().isEmpty()); assertNull(layer.getDefaultStyle()); }
/** * Sets the minimum width of the coordinate display label and the format string used to print * values. The map extent is used to estimate the number of digits required. * * @param env map extent */ private void setFormat(ReferencedEnvelope env) { if (env == null || env.isEmpty()) { intLen = DEFAULT_NUM_INTEGER_DIGITS; } else { setIntegerLen(env); } setLabelSizeAndFormat(); }
/** * Displays extent in world coordinates. * * @param extent the map pane extent * @param cache whether to cache a copy of {@code extent} */ private void displayExtent(ReferencedEnvelope extent, boolean cache) { if (extent == null || extent.isEmpty()) { label.setText("Undefined extent"); lastExtent = EMPTY_ENV; } else { label.setText( String.format( numFormat, extent.getMinX(), extent.getMaxX(), extent.getMinY(), extent.getMaxY())); if (cache) { lastExtent = new ReferencedEnvelope(extent); } } }
private boolean isNotEmpty(ReferencedEnvelope envelope) { return !envelope.isEmpty() && !envelope.isNull() && envelope.getWidth() > 0 && envelope.getHeight() > 0; }
private void init( Collection<OrthoLineDef> controls, GridFeatureBuilder lineFeatureBuilder, double vertexSpacing) { if (gridBounds == null || gridBounds.isEmpty()) { throw new IllegalArgumentException("gridBounds must not be null or empty"); } if (controls == null || controls.isEmpty()) { throw new IllegalArgumentException("required one or more line parameters"); } for (OrthoLineDef param : controls) { if (param.getOrientation() == LineOrientation.HORIZONTAL) { hasHorizontals = true; } else if (param.getOrientation() == LineOrientation.VERTICAL) { hasVerticals = true; } else { throw new IllegalArgumentException( "Only horizontal and vertical lines are supported"); } } densify = isValidDenseVertexSpacing(vertexSpacing); featureBuilder = new SimpleFeatureBuilder(lineFeatureBuilder.getType()); } }
/** * Called when a new map layer has been added. Sets the layer as selected (for queries) and, if * the layer table is being used, adds the new layer to the table. */ @Override public void layerAdded(MapLayerListEvent event) { paramsLock.writeLock().lock(); try { Layer layer = event.getElement(); if (layer instanceof ComponentListener) { addComponentListener((ComponentListener) layer); } setFullExtent(); MapViewport viewport = mapContent.getViewport(); if (viewport.getBounds().isEmpty()) { viewport.setBounds(fullExtent); } } finally { paramsLock.writeLock().unlock(); } drawLayers(false); repaint(); }
public void testBounds() throws Exception { SimpleFeatureCollection original = featureCollection; assertFalse(original.getBounds().isEmpty()); SimpleFeatureCollection forced = new ForceCoordinateSystemFeatureResults(original, utm32n); assertEquals(new ReferencedEnvelope(10, 10, 10, 10, utm32n), forced.getBounds()); }
/** * 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; }
/** * Tests that the conversion of different bound types to ReferencedEnvelope does not lose the * emptiness property * * @throws Exception */ @Test public void testEmptyEnvelopeConversion() throws Exception { // conversion of an empty OGC envelope should stay empty GeneralEnvelope ge = new GeneralEnvelope(new double[] {0, 0}, new double[] {-1, -1}); assertTrue(ge.isEmpty()); assertTrue(ReferencedEnvelope.create(ge, ge.getCoordinateReferenceSystem()).isEmpty()); assertTrue(ReferencedEnvelope.reference(ge).isEmpty()); // conversion of an empty Java Rectangle 2D should stay empty Rectangle2D r2d = new Rectangle2D.Double(0, 0, -1, -1); assertTrue(r2d.isEmpty()); assertTrue(ReferencedEnvelope.create(r2d, null).isEmpty()); // conversion of an empty ReferencedEnvelope should stay empty ReferencedEnvelope re = new ReferencedEnvelope(); assertTrue(re.isEmpty()); assertTrue(ReferencedEnvelope.create(re).isEmpty()); assertTrue(ReferencedEnvelope.create(re, re.getCoordinateReferenceSystem()).isEmpty()); assertTrue(ReferencedEnvelope.reference(re).isEmpty()); } }
public void testGetBounds() throws Exception { ReferencedEnvelope env = dataStore.getFeatureSource(tname(PERSON)).getBounds(); assertTrue(env.isEmpty()); }
@Test public void testEmpty() { DelayedSchemaFeatureCollection fc = new DelayedSchemaFeatureCollection(); assertEquals(DelayedSchemaFeatureCollection.PLACEHOLDER, fc.getSchema()); assertTrue(fc.getBounds().isEmpty()); fc.add(riverFeatures[0]); assertFalse(fc.getBounds().isEmpty()); assertEquals(riverType, fc.getSchema()); }
/** Test DefaultMapContext handles layers that return null bounds. */ @Test public void testNullLayerBounds() { Layer mapLayerBoundsNull = new MockLayer(null); mapContent.addLayer(mapLayerBoundsNull); ReferencedEnvelope maxBounds = mapContent.getMaxBounds(); assertNotNull(maxBounds); assertTrue(maxBounds.isEmpty()); }
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()); } }
@Test public void booleanCtor() { MapViewport vp = new MapViewport(true); assertTrue(vp.isEmpty()); assertTrue(vp.isMatchingAspectRatio()); assertTrue(vp.getBounds().isEmpty()); assertTrue(vp.getScreenArea().isEmpty()); }
@Test public void defaultCtor() { MapViewport vp = new MapViewport(); assertFalse(vp.isMatchingAspectRatio()); assertTrue(vp.isEmpty()); assertTrue(vp.getBounds().isEmpty()); assertTrue(vp.getScreenArea().isEmpty()); assertNull(vp.getCoordinateReferenceSystem()); }
/** Test DefaultMapContext handles layers that return null bounds. */ @Test public void testNPELayerBounds() throws IOException { MapLayer mapLayerBoundsNull = new MapLayer( new Layer() { public ReferencedEnvelope getBounds() { return null; } }); DefaultMapContext mapContext = new DefaultMapContext(DefaultGeographicCRS.WGS84); mapContext.addLayer(mapLayerBoundsNull); ReferencedEnvelope layerBounds = mapContext.getLayerBounds(); assertNull(layerBounds); ReferencedEnvelope maxBounds = mapContext.getMaxBounds(); assertNotNull(maxBounds); assertEquals(DefaultGeographicCRS.WGS84, maxBounds.getCoordinateReferenceSystem()); assertTrue(maxBounds.isEmpty()); } }