Refine search
/** * Creates a new envelope from an existing bounding box. * * <p>NOTE: if the bounding box is empty, the resulting ReferencedEnvelope will not be. In case * this is needed use {@link #create(org.opengis.geometry.Envelope, CoordinateReferenceSystem) * ReferencedEnvelope.create(bbox, bbox.getCoordinateReferenceSystem())} * * @param bbox The bounding box to initialize from. * @throws MismatchedDimensionException if the CRS dimension is not valid. * @since 2.4 */ public ReferencedEnvelope(final BoundingBox bbox) throws MismatchedDimensionException { this( bbox.getMinX(), bbox.getMaxX(), bbox.getMinY(), bbox.getMaxY(), bbox.getCoordinateReferenceSystem()); }
/** * Gets the bounding box for the features in this feature collection. * * @return the envelope of the geometries contained by this feature collection. */ public ReferencedEnvelope getBounds() { if (bounds == null) { bounds = new ReferencedEnvelope(); for (Iterator i = contents.values().iterator(); i.hasNext(); ) { BoundingBox geomBounds = ((SimpleFeature) i.next()).getBounds(); // IanS - as of 1.3, JTS expandToInclude ignores "null" Envelope // and simply adds the new bounds... // This check ensures this behavior does not occur. if (!geomBounds.isEmpty()) { bounds.include(geomBounds); } } } return bounds; }
public void setBounds(BoundingBox bounds) { this.crs = bounds.getCoordinateReferenceSystem(); this.x = bounds.getMinX(); this.y = bounds.getMinY(); this.width = bounds.getWidth(); this.height = bounds.getHeight(); }
/** Sets this envelope to the specified bounding box. */ public void init(BoundingBox bounds) { init( bounds.getMinimum(0), bounds.getMaximum(0), bounds.getMinimum(1), bounds.getMaximum(1), bounds.getMinimum(2), bounds.getMaximum(2)); this.crs = bounds.getCoordinateReferenceSystem(); }
requestCRS = CRS.getHorizontalCRS(requestedBBox.getCoordinateReferenceSystem()); try { && !destinationToSourceTransform.isIdentity()) { final GeneralEnvelope temp = new GeneralEnvelope(CRS.transform(requestedBBox, coverageProperties.crs2D)); temp.setCoordinateReferenceSystem(coverageProperties.crs2D); cropBBox = new ReferencedEnvelope(temp); needsReprojection = true; new ReferencedEnvelope( requestedBBox.getMinX(), requestedBBox.getMaxX(), requestedBBox.getMinY(), requestedBBox.getMaxY(), coverageProperties.crs2D); if (!cropBBox.intersects((BoundingBox) coverageProperties.bbox)) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine( new ReferencedEnvelope( ((ReferencedEnvelope) cropBBox).intersection(coverageProperties.bbox), coverageProperties.crs2D); if (!CRS.equalsIgnoreMetadata(coverageProperties.geographicCRS2D, requestCRS)) {
private void inspectCoordinateReferenceSystems() throws DataSourceException { requestCRS = CRS.getHorizontalCRS(requestedBBox.getCoordinateReferenceSystem()); if (!CRS.equalsIgnoreMetadata(requestCRS, rasterManager.spatialDomainManager.coverageCRS2D)) try { destinationToSourceTransform = CRS.findMathTransform( requestCRS, rasterManager.spatialDomainManager.coverageCRS2D, true); } catch (FactoryException e) { PixelInCell.CELL_CORNER); requestedBBox = new ReferencedEnvelope( CRS.transform( tempTransform, new GeneralEnvelope(requestedRasterArea)));
@Test public void testReprojectToTargetCRS() throws Exception { DiffBounds cmd = geogig.command(DiffBounds.class).setOldVersion("HEAD^") .setNewVersion("HEAD"); DiffSummary<BoundingBox, BoundingBox> defaultCrs = cmd.call(); CoordinateReferenceSystem target = CRS.decode("EPSG:26986"); cmd.setCRS(target); DiffSummary<BoundingBox, BoundingBox> reprojected = cmd.call(); assertEquals(target, reprojected.getLeft().getCoordinateReferenceSystem()); assertEquals(target, reprojected.getRight().getCoordinateReferenceSystem()); assertEquals(target, reprojected.getMergedResult().get().getCoordinateReferenceSystem()); assertFalse(defaultCrs.getLeft().isEmpty()); assertFalse(defaultCrs.getRight().isEmpty()); assertFalse(defaultCrs.getMergedResult().get().isEmpty()); ReferencedEnvelope e = new ReferencedEnvelope(defaultCrs.getLeft()); ReferencedEnvelope expected = e.transform(target, true); assertEquals(expected, reprojected.getLeft()); }
public static void print(GeoGIG geogig, Console console, DiffSummary<BoundingBox, BoundingBox> diffBounds) throws IOException { BoundingBox left = diffBounds.getLeft(); BoundingBox right = diffBounds.getRight(); Optional<BoundingBox> mergedResult = diffBounds.getMergedResult(); BoundingBox both = new ReferencedEnvelope(); if (mergedResult.isPresent()) { both = mergedResult.get(); } Ansi ansi = AnsiDecorator.newAnsi(console.isAnsiSupported()); ansi.a("left: ").a(bounds(left)).newline(); ansi.a("right: ").a(bounds(right)).newline(); ansi.a("both: ").a(bounds(both)).newline(); ansi.a("CRS: ").a(CRS.toSRS(left.getCoordinateReferenceSystem())).newline(); console.print(ansi.toString()); }
@Override public void endTree(NodeRef left, NodeRef right) { String name = left == null ? right.name() : left.name(); if (NodeRef.ROOT.equals(name)) { BoundingBox lbounds = new ReferencedEnvelope(this.leftEnv); BoundingBox rbounds = new ReferencedEnvelope(this.rightEnv); BoundingBox merged; if (lbounds.isEmpty()) { merged = rbounds; } else if (rbounds.isEmpty()) { merged = lbounds; } else { merged = new ReferencedEnvelope(lbounds); merged.include(rbounds); } this.diffBoundsResult = new DiffSummary<BoundingBox, BoundingBox>(lbounds, rbounds, merged); } }
private ReferencedEnvelope extractAndCombineBBox(Filter filter) { // TODO extract eventual bbox from query here final BBOXFilterExtractor bboxExtractor = new GTDataStoreGranuleCatalog.BBOXFilterExtractor(); filter.accept(bboxExtractor, null); ReferencedEnvelope requestedBBox=bboxExtractor.getBBox(); // add eventual bbox from the underlying index to constrain search if(requestedBBox!=null){ // intersection final Envelope intersection = requestedBBox.intersection(ReferencedEnvelope.reference(wrappedCatalogue.getBounds())); // create intersection final ReferencedEnvelope referencedEnvelope= new ReferencedEnvelope(intersection,wrappedCatalogue.getBounds().getCoordinateReferenceSystem()); } else return ReferencedEnvelope.reference(wrappedCatalogue.getBounds()); return requestedBBox; }
public Object visit(BBOX filter, Object extraData) { // grab the original envelope data BoundingBox boundaries = filter.getBounds(); // parse the srs, it might be a code or a WKT definition CoordinateReferenceSystem crs = boundaries.getCoordinateReferenceSystem(); // if no srs is specified we can't transform anyways if (crs == null) return super.visit(filter, extraData); // grab the property data PropertyName propertyName = null; // get the expression as is to preserve namespace context if (filter.getExpression1() instanceof PropertyName) { propertyName = (PropertyName) filter.getExpression1(); } else if (filter.getExpression2() instanceof PropertyName) { propertyName = (PropertyName) filter.getExpression2(); } CoordinateReferenceSystem targetCrs = findPropertyCRS(propertyName); // if there is a mismatch, reproject and replace if (crs != null && targetCrs != null && !CRS.equalsIgnoreMetadata(crs, targetCrs)) { ReferencedEnvelope envelope = ReferencedEnvelope.reference(boundaries); try { envelope = envelope.transform(targetCrs, true); } catch (TransformException e) { throw new RuntimeException(e); } catch (FactoryException e) { throw new RuntimeException(e); } boundaries = envelope; } return getFactory(extraData).bbox(propertyName, boundaries); }
private LayerDiffSummary toSummary(@NonNull String path, @Nullable RevTree left, @Nullable RevTree right, @NonNull DiffObjectCount count, @NonNull DiffSummary<BoundingBox, BoundingBox> bounds) { BoundingBox lb = bounds.getLeft(); BoundingBox rb = bounds.getRight(); ReferencedEnvelope leftBounds = lb.isEmpty() ? null : new ReferencedEnvelope(lb); ReferencedEnvelope rightBounds = rb.isEmpty() ? null : new ReferencedEnvelope(rb); LayerDiffSummary s = LayerDiffSummary.builder()// .path(path)// .leftTreeish(left.getId())// .rightTreeish(right.getId())// .leftBounds(leftBounds)// .rightBounds(rightBounds)// .featuresAdded(count.getFeaturesAdded())// .featuresChanged(count.getFeaturesChanged())// .featuresRemoved(count.getFeaturesRemoved())// .build(); return s; }
/** * Make sure that the specified bounding box uses the same CRS than this one. * * @param bbox The other bounding box to test for compatibility. * @throws MismatchedReferenceSystemException if the CRS are incompatibles. */ private void ensureCompatibleReferenceSystem(final BoundingBox bbox) throws MismatchedReferenceSystemException { if (crs != null) { final CoordinateReferenceSystem other = bbox.getCoordinateReferenceSystem(); if (other != null) { if (!CRS.equalsIgnoreMetadata(crs, other)) { throw new MismatchedReferenceSystemException( Errors.format(ErrorKeys.MISMATCHED_COORDINATE_REFERENCE_SYSTEM)); } } } }
+ " AUTHORITY[\"EPSG\",\"4939\"]]"; CoordinateReferenceSystem gda94 = CRS.parseWKT(wkt); ReferencedEnvelope bounds = new ReferencedEnvelope3D( assertEquals(DefaultGeographicCRS.WGS84, worldBounds.getCoordinateReferenceSystem()); assertEquals( DefaultGeographicCRS.WGS84, ((BoundingBox) worldBounds2).getCoordinateReferenceSystem());
/** * Include the provided bounding box, expanding as necessary. * * @since 2.4 */ public void include(final BoundingBox bbox) { if (crs == null) { this.crs = bbox.getCoordinateReferenceSystem(); } else { ensureCompatibleReferenceSystem(bbox); } expandToInclude(ReferencedEnvelope.reference(bbox)); } /**
destinationRasterArea = new GeneralGridEnvelope( CRS.transform( requestedWorldToGrid, new GeneralEnvelope(cropBBox)), CRS.transform(cropBBox, requestedBBox.getCoordinateReferenceSystem()); cropBBOXInRequestCRS.setCoordinateReferenceSystem( requestedBBox.getCoordinateReferenceSystem()); CRS.transform(requestedWorldToGrid, cropBBOXInRequestCRS), PixelInCell.CELL_CORNER, false)
if(bounds.isEmpty()) { throw new IllegalArgumentException("Cannot create a mosaic out of an empty index"); this.crs=bounds.getCoordinateReferenceSystem(); if(envelope==null) this.originalEnvelope=new GeneralEnvelope(bounds);
"", GetCoverage.SRS_STARTER + CRS.lookupIdentifier( boundingBox.getCoordinateReferenceSystem(), false)); new StringBuilder(Double.toString(boundingBox.getLowerCorner().getOrdinate(0))) .append(" ") .append(boundingBox.getLowerCorner().getOrdinate(1)) .toString()); new StringBuilder(Double.toString(boundingBox.getUpperCorner().getOrdinate(0))) .append(" ") .append(boundingBox.getUpperCorner().getOrdinate(1)) .toString()); end("ows:BoundingBox");
/** Returns the specified bounding box as a JTS envelope. */ private static Envelope getJTSEnvelope(final BoundingBox bbox) { if (bbox == null) { throw new NullPointerException("Provided bbox envelope was null"); } if (bbox instanceof Envelope) { return (Envelope) bbox; } // safe creation if empty bounds return ReferencedEnvelope.create(bbox, bbox.getCoordinateReferenceSystem()); }