org.opengis.geometry.BoundingBox Java Examples
The following examples show how to use
org.opengis.geometry.BoundingBox.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BBox.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Gets the filter configuration. * * @return the filter configuration */ @Override public FilterName getFilterConfiguration() { FilterName filterName = new FilterName("BBOX", Boolean.class); filterName.addParameter( new FilterNameParameter( "property", ExpressionTypeEnum.PROPERTY, BoundingBox.class)); filterName.addParameter( new FilterNameParameter( "boundingbox", ExpressionTypeEnum.LITERAL, BoundingBox.class)); return filterName; }
Example #2
Source File: FilterUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Create a bounding box filter from a bounding box. * * @param attribute the geometry attribute or null in the case of default "the_geom". * @param bbox the {@link BoundingBox}. * @return the filter. * @throws CQLException */ public static Filter getBboxFilter( String attribute, BoundingBox bbox ) throws CQLException { double w = bbox.getMinX(); double e = bbox.getMaxX(); double s = bbox.getMinY(); double n = bbox.getMaxY(); return getBboxFilter(attribute, w, e, s, n); }
Example #3
Source File: SceneFeatureIteratorTest.java From geowave with Apache License 2.0 | 5 votes |
private Matcher<SimpleFeature> inBounds(final BoundingBox bounds) { return new BaseMatcher<SimpleFeature>() { @Override public boolean matches(final Object item) { final SimpleFeature feature = (SimpleFeature) item; return feature.getBounds().intersects(bounds); } @Override public void describeTo(final Description description) { description.appendText("feature should be in bounds " + bounds); } }; }
Example #4
Source File: SceneFeatureIteratorTest.java From geowave with Apache License 2.0 | 5 votes |
private Matcher<SimpleFeature> inBounds(final BoundingBox bounds) { return new BaseMatcher<SimpleFeature>() { @Override public boolean matches(final Object item) { final SimpleFeature feature = (SimpleFeature) item; return feature.getBounds().intersects(bounds); } @Override public void describeTo(final Description description) { description.appendText("feature should be in bounds " + bounds); } }; }
Example #5
Source File: ExtractGeometryFilterVisitor.java From geowave with Apache License 2.0 | 5 votes |
@Override public Object visit(final BBOX filter, final Object data) { if (attributeOfInterest.equals(filter.getExpression1().toString())) { final Geometry bbox = bbox(data); final BoundingBox referencedBBox = filter.getBounds(); Geometry bounds = new GeometryFactory().toGeometry( new Envelope( referencedBBox.getMinX(), referencedBBox.getMaxX(), referencedBBox.getMinY(), referencedBBox.getMaxY())); if ((crs != null) && (referencedBBox.getCoordinateReferenceSystem() != null) && !crs.equals(referencedBBox.getCoordinateReferenceSystem())) { try { bounds = JTS.transform( bounds, CRS.findMathTransform(referencedBBox.getCoordinateReferenceSystem(), crs, true)); } catch (MismatchedDimensionException | TransformException | FactoryException e) { LOGGER.error("Unable to transforma bbox", e); } } if (bbox != null) { return bbox.union(bounds); } else { return new ExtractGeometryFilterVisitorResult(bounds, CompareOperation.INTERSECTS); } } else { return new ExtractGeometryFilterVisitorResult(infinity(), null); } }
Example #6
Source File: ReferencedEnvelopeValues.java From sldeditor with GNU General Public License v3.0 | 4 votes |
@Override public List<Class<?>> getType() { return Arrays.asList(ReferencedEnvelope.class, Envelope.class, BoundingBox.class); }
Example #7
Source File: ReferencedEnvlopeValuesTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link * com.sldeditor.rendertransformation.types.ReferencedEnvelopeValues#ReferencedEnvelopeValues()}. */ @Test void testReferencedEnvelopeValues() { ReferencedEnvelopeValues testObj = new ReferencedEnvelopeValues(); testObj.createInstance(); assertEquals( Arrays.asList(ReferencedEnvelope.class, Envelope.class, BoundingBox.class), testObj.getType()); CoordinateReferenceSystem crs = null; ReferencedEnvelope envelope = new ReferencedEnvelope(-1.0, 1.0, -1.0, 1.0, crs); testObj.setDefaultValue(envelope); assertNull(testObj.getExpression()); // ReferencedEnvelope value testObj.setValue((Envelope) crs); assertNull(testObj.getExpression()); // Literal expression Expression expectedExpression = ff.literal(crs); testObj.setValue(expectedExpression); assertEquals(expectedExpression, testObj.getExpression()); // Attribute expression expectedExpression = ff.property("test"); testObj.setValue(expectedExpression); assertEquals(expectedExpression, testObj.getExpression()); // Not set testObj.setValue(""); assertNull(testObj.getExpression()); FieldConfigBase field = testObj.getField( new FieldConfigCommonData( ReferencedEnvelopeValues.class, FieldIdEnum.INITIAL_GAP, "label", true, false, false)); assertEquals(FieldConfigBoundingBox.class, field.getClass()); // Increase code coverage TestReferencedEnvelopeValues testObj2 = new TestReferencedEnvelopeValues(); testObj2.populateSymbolType(null); }
Example #8
Source File: FilterToElasticHelper.java From elasticgeo with GNU General Public License v3.0 | 4 votes |
private void visitGeoPointBinarySpatialOperator(BinarySpatialOperator filter, Expression e1, Expression e2, boolean swapped, Object extraData) { e1.accept(delegate, extraData); key = (String) delegate.field; e2.accept(delegate, extraData); final Geometry geometry = delegate.currentGeometry; if (geometry instanceof Polygon && ((!swapped && filter instanceof Within) || (swapped && filter instanceof Contains) || filter instanceof Intersects)) { final Polygon polygon = (Polygon) geometry; final List<List<Double>> points = new ArrayList<>(); for (final Coordinate coordinate : polygon.getCoordinates()) { points.add(ImmutableList.of(coordinate.x, coordinate.y)); } delegate.queryBuilder = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_polygon", ImmutableMap.of(key, ImmutableMap.of("points", points))))); } else if (filter instanceof BBOX) { final BoundingBox envelope = ((BBOX) filter).getBounds(); final double minY = clipLat(envelope.getMinY()); final double maxY = clipLat(envelope.getMaxY()); final double minX, maxX; if (envelope.getWidth() < 360) { minX = clipLon(envelope.getMinX()); maxX = clipLon(envelope.getMaxX()); } else { minX = -180; maxX = 180; } delegate.queryBuilder = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_bounding_box", ImmutableMap.of(key, ImmutableMap.of("top_left", ImmutableList.of(minX, maxY), "bottom_right", ImmutableList.of(maxX, minY)))))); } else { FilterToElastic.LOGGER.fine(filter.getClass().getSimpleName() + " is unsupported for geo_point types"); delegate.fullySupported = false; delegate.queryBuilder = MATCH_ALL; } }
Example #9
Source File: ExportTimeBasedKmz.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private KmlFeature createKmlFeature() { if (view.isRGB()) { return null; } TimeSeriesMapper timeSeriesMapper = TimeSeriesMapper.getInstance(); AbstractTimeSeries timeSeries = timeSeriesMapper.getTimeSeries(view.getProduct()); List<Band> bands = timeSeries.getBandsForVariable( AbstractTimeSeries.rasterToVariableName(view.getRaster().getName())); if (bands.isEmpty()) { return null; } RasterDataNode refRaster = bands.get(0); final KmlFolder folder = new KmlFolder(refRaster.getName(), refRaster.getDescription()); for (RasterDataNode raster : bands) { final GeoCoding geoCoding = raster.getGeoCoding(); final PixelPos upperLeftPP = new PixelPos(0, 0); final PixelPos lowerRightPP = new PixelPos(raster.getSceneRasterWidth(), raster.getSceneRasterHeight()); final GeoPos upperLeftGP = geoCoding.getGeoPos(upperLeftPP, null); final GeoPos lowerRightGP = geoCoding.getGeoPos(lowerRightPP, null); double north = upperLeftGP.getLat(); double south = lowerRightGP.getLat(); double east = lowerRightGP.getLon(); double west = upperLeftGP.getLon(); if (geoCoding.isCrossingMeridianAt180()) { east += 360; } final BoundingBox referencedEnvelope = new ReferencedEnvelope(west, east, north, south, DefaultGeographicCRS.WGS84); TimeCoding timeCoding = timeSeries.getRasterTimeMap().get(raster); if (timeCoding != null) { final ProductData.UTC startTime = timeCoding.getStartTime(); final ProductData.UTC endTime = timeCoding.getEndTime(); final ImageManager imageManager = ImageManager.getInstance(); final ImageInfo imageInfo = raster.getImageInfo(ProgressMonitor.NULL); final RenderedImage levelImage = imageManager.createColoredBandImage(new RasterDataNode[]{raster}, imageInfo, level); final String name = raster.getName(); final KmlGroundOverlay groundOverlay = new KmlGroundOverlay(name, levelImage, referencedEnvelope, startTime, endTime); groundOverlay.setIconName(name + raster.getProduct().getRefNo()); folder.addChild(groundOverlay); } } return folder; }
Example #10
Source File: SimpleFeatureWrapper.java From geowave with Apache License 2.0 | 4 votes |
@Override public BoundingBox getBounds() { return simpleFeature.getBounds(); }