Package org.geotools.geometry

Examples of org.geotools.geometry.GeneralEnvelope.intersect()


        try {
                final GeneralEnvelope cropBBOXInRequestCRS = CRS.transform(cropBBox,
                        requestedBBox.getCoordinateReferenceSystem());
        cropBBOXInRequestCRS.setCoordinateReferenceSystem(requestedBBox.getCoordinateReferenceSystem());
        //make sure it falls within the requested envelope
        cropBBOXInRequestCRS.intersect(requestedBBox);
       
        //now go back to raster space
        destinationRasterArea =  new GeneralGridEnvelope(CRS.transform(requestedWorldToGrid,cropBBOXInRequestCRS),PixelInCell.CELL_CORNER,false).toRectangle();
        //intersect with the original requested raster space to be sure that we stay within the requested raster area
        XRectangle2D.intersect(destinationRasterArea, requestedRasterArea, destinationRasterArea);
View Full Code Here


                validArea = targetBox;
            } else if (targetBox == null) {
                validArea = sourceBox;
            } else {
                final GeneralEnvelope area = new GeneralEnvelope(sourceBox);
                area.intersect(new GeneralEnvelope(sourceBox));
                try {
                    validArea = new GeographicBoundingBoxImpl(area);
                } catch (TransformException e) {
                    // Should never happen, because we know that 'area' CRS is WGS84.
                    throw new AssertionError(e);
View Full Code Here

        final GeneralEnvelope oldEnvelope = (GeneralEnvelope) gc.getEnvelope();
        // intersect the envelopes in order to prepare for cropping the coverage
        // down to the neded resolution
        final GeneralEnvelope intersectionEnvelope = new GeneralEnvelope(envelope);
        intersectionEnvelope.setCoordinateReferenceSystem(envelope.getCoordinateReferenceSystem());
        intersectionEnvelope.intersect((GeneralEnvelope) oldEnvelope);

        // Do we have something to show? After the crop I could get a null
        // coverage which would mean nothing to show.
        if (intersectionEnvelope.isEmpty()) {
            return null;
View Full Code Here

    //
    // //
    final GeneralEnvelope intersectionEnvelope = new GeneralEnvelope((Envelope) destinationEnvelope);
    intersectionEnvelope.setCoordinateReferenceSystem(source.getCoordinateReferenceSystem());
    // intersect the envelopes
    intersectionEnvelope.intersect(sourceEnvelope);
    if (intersectionEnvelope.isEmpty())
      throw new CannotCropException(Errors.format(ErrorKeys.CANT_CROP));

        // intersect the ROI with the intersection envelope and throw an error if they do not intersect
        if(cropRoi != null) {
View Full Code Here

            // intersect the requested area with the bounds of this
            // layer in native crs
            if (!adjustedRequestedEnvelope.intersects(baseEnvelope2D, true))
                return null;
            adjustedRequestedEnvelope.intersect(baseEnvelope2D);
            adjustedRequestedEnvelope.setCoordinateReferenceSystem(spatialReferenceSystem2D);

            // //
            //
            // transform the intersection envelope from the destination world
View Full Code Here

            try {
                final GeneralEnvelope cropBBOXInRequestCRS = CRS.transform(cropBBox,
                        requestedBBox.getCoordinateReferenceSystem());
                cropBBOXInRequestCRS.setCoordinateReferenceSystem(requestedBBox.getCoordinateReferenceSystem());
                // make sure it falls within the requested envelope
                cropBBOXInRequestCRS.intersect(requestedBBox);

                // now go back to raster space
                destinationRasterArea = new GeneralGridEnvelope(CRS.transform(requestedWorldToGrid,
                        cropBBOXInRequestCRS), PixelInCell.CELL_CORNER, false).toRectangle();
                // intersect with the original requested raster space to be sure that we stay within the requested raster area
View Full Code Here

            }

            // now we have enough info to read the coverage, grab the parameters
            // and add the grid geometry info
            final GeneralEnvelope intersectionEnvelopeInSourceCRS = new GeneralEnvelope(requestedEnvelopeInSourceCRS);
            intersectionEnvelopeInSourceCRS.intersect(originalEnvelope);
            final GeneralEnvelope intersectionEnvelope=
              bboxToNativeTx.isIdentity()?
                  new GeneralEnvelope(intersectionEnvelopeInSourceCRS):
                  CRS.transform(bboxToNativeTx.inverse(), intersectionEnvelopeInSourceCRS);
            intersectionEnvelope.setCoordinateReferenceSystem(targetCRS);
View Full Code Here

                }
            }
        }
       
        // just do the intersection since
        envelope.intersect(coverageBounds);
       
        if (envelope.isEmpty()) {
            return null;
        }
       
View Full Code Here

            final CoordinateReferenceSystem nativeCRS = reader.getCrs();
            if(!CRS.equalsIgnoreMetadata(requestCRS, nativeCRS)) {
                requestedEnvelope = CRS.transform(CRS.findMathTransform(requestCRS, nativeCRS, true), requestedEnvelope);
            }
            // intersect with the native envelope, we cannot read outside of it
            requestedEnvelope.intersect(reader.getOriginalEnvelope());
           
            // check if we are still reading anything
            if(!requestedEnvelope.isEmpty()) {
                MathTransform crsToGrid = meta.getGrid().getGridToCRS().inverse();
                GeneralEnvelope requestedGrid = CRS.transform(crsToGrid, requestedEnvelope);
View Full Code Here

            // now we have enough info to read the coverage, grab the parameters
            // and add the grid geometry info
            final GeneralEnvelope intersectionEnvelopeInSourceCRS = new GeneralEnvelope(
                    requestedEnvelopeInNativeCRS);
            intersectionEnvelopeInSourceCRS.intersect(originalEnvelope);

            final GridGeometry2D requestedGridGeometry = new GridGeometry2D(
                    PixelInCell.CELL_CENTER, gridToCRS, intersectionEnvelopeInSourceCRS, null);

            final ParameterValueGroup readParametersDescriptor = reader.getFormat()
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.