@Test public void testGetEnvelope() throws FactoryException, TransformException { GeneralEnvelope envelope = new GeneralEnvelope(DefaultGeographicCRS.WGS84); envelope.setEnvelope(0, 0, 10, 10); GeneralEnvelope wgs84 = new GeneralEnvelope(Utilities.getEnvelopeAsWGS84(envelope, true)); GeneralEnvelope wgs84_2 = new GeneralEnvelope(Utilities.getEnvelopeAsWGS84(envelope, false)); assertFalse(wgs84.isEmpty()); assertTrue(wgs84.contains(envelope, true)); assertFalse(wgs84_2.isEmpty()); assertTrue(wgs84_2.contains(envelope, true)); envelope = new GeneralEnvelope(CRS.decode("EPSG:3857")); envelope.setEnvelope(0, 0, 10, 10); wgs84 = new GeneralEnvelope(Utilities.getEnvelopeAsWGS84(envelope, true)); wgs84_2 = new GeneralEnvelope(Utilities.getEnvelopeAsWGS84(envelope, false)); assertFalse(wgs84.isEmpty()); assertFalse(wgs84_2.isEmpty()); }
public static Envelope getEnvelopeAsWGS84(final Envelope envelope, boolean get2D) throws FactoryException, TransformException { if (envelope == null) throw new IllegalArgumentException("Specified envelope is null"); Envelope requestedWGS84; final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem(); if (!CRS.equalsIgnoreMetadata(crs, DefaultGeographicCRS.WGS84)) { GeneralEnvelope env = CRS.transform(envelope, DefaultGeographicCRS.WGS84); if (get2D) { requestedWGS84 = new Envelope2D(env); ((Envelope2D) requestedWGS84) .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); } else { requestedWGS84 = env; ((GeneralEnvelope) requestedWGS84) .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); } return requestedWGS84; } else { if (get2D) return new Envelope2D(envelope); else return new GeneralEnvelope(envelope); } }
Utilities { public static Envelope getEnvelopeAsWGS84(final Envelope envelope, boolean get2D) throws FactoryException, TransformException { if (envelope == null) throw new IllegalArgumentException("Specified envelope is null"); Envelope requestedWGS84; final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem(); if (!CRS.equalsIgnoreMetadata(crs, DefaultGeographicCRS.WGS84)) { GeneralEnvelope env = CRS.transform(envelope, DefaultGeographicCRS.WGS84); if (get2D) { requestedWGS84 = new Envelope2D(env); ((Envelope2D) requestedWGS84) .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); } else { requestedWGS84 = env; ((GeneralEnvelope) requestedWGS84) .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); } return requestedWGS84; } else { if (get2D) return new Envelope2D(envelope); else return new GeneralEnvelope(envelope); } } }
Utilities { public static Envelope getEnvelopeAsWGS84(final Envelope envelope, boolean get2D) throws FactoryException, TransformException { if (envelope == null) throw new IllegalArgumentException("Specified envelope is null"); Envelope requestedWGS84; final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem(); if (!CRS.equalsIgnoreMetadata(crs, DefaultGeographicCRS.WGS84)) { GeneralEnvelope env = CRS.transform(envelope, DefaultGeographicCRS.WGS84); if (get2D) { requestedWGS84 = new Envelope2D(env); ((Envelope2D) requestedWGS84) .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); } else { requestedWGS84 = env; ((GeneralEnvelope) requestedWGS84) .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); } return requestedWGS84; } else { if (get2D) return new Envelope2D(envelope); else return new GeneralEnvelope(envelope); } } private  Utilities(); }
Utilities { public static Envelope getEnvelopeAsWGS84(final Envelope envelope, boolean get2D) throws FactoryException, TransformException { if (envelope == null) throw new IllegalArgumentException("Specified envelope is null"); Envelope requestedWGS84; final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem(); if (!CRS.equalsIgnoreMetadata(crs, DefaultGeographicCRS.WGS84)) { GeneralEnvelope env = CRS.transform(envelope, DefaultGeographicCRS.WGS84); if (get2D) { requestedWGS84 = new Envelope2D(env); ((Envelope2D) requestedWGS84) .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); } else { requestedWGS84 = env; ((GeneralEnvelope) requestedWGS84) .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); } return requestedWGS84; } else { if (get2D) return new Envelope2D(envelope); else return new GeneralEnvelope(envelope); } } private  Utilities(); static ReferenceIdentifier[] getIdentifiers(final String nameIdentifier); static DefaultGeodeticDatum getDefaultGeodeticDatum(
            final String name,
            final double equatorialRadius,
            final double inverseFlattening,
            Unit unit); static File getFileFromCustomInput(Object input); @SuppressWarnings("deprecation") static CoordinateReferenceSystem getMercator2SPProjectedCRS(
            final double standardParallel,
            final double centralMeridian,
            final double natOriginLat,
            GeographicCRS sourceCRS,
            Hints hints); static GeographicCRS getBaseCRS(
            final double equatorialRadius, final double inverseFlattening); static String getAttributeValue(NamedNodeMap attributes, String attributeName); static Unit<? extends Quantity<?>> parseUnit(final String uom); static Envelope getEnvelopeAsWGS84(final Envelope envelope, boolean get2D); static GeneralEnvelope getRequestedEnvelope2D(GeneralEnvelope requestedEnvelope); static Rectangle getCropRegion(
            GeneralEnvelope envelope, final MathTransform gridToWorldTransform); static GeneralEnvelope getIntersection(
            final Envelope2D baseEnvelope2D,
            final CoordinateReferenceSystem spatialReferenceSystem2D,
            GeneralEnvelope requestedEnvelope2D,
            Rectangle requestedDim,
            MathTransform2D readGridToWorld,
            final Envelope2D wgs84BaseEnvelope2D); static MathTransform getOriginalGridToWorld(
            MathTransform raster2Model, final PixelInCell pixInCell); static GeneralEnvelope evaluateRequestedParams(
            GridEnvelope originalGridRange,
            Envelope2D baseEnvelope2D,
            CoordinateReferenceSystem spatialReferenceSystem2D,
            MathTransform originalGridToWorld,
            GeneralEnvelope requestedEnvelope,
            Rectangle sourceRegion,
            Rectangle requestedDim,
            MathTransform2D readGridToWorld,
            Envelope2D wgs84BaseEnvelope2D); static GridCoverage createCoverageFromImage(
            final GridCoverageFactory coverageFactory,
            final String coverageName,
            int imageIndex,
            PlanarImage image,
            MathTransform raster2Model,
            final CoordinateReferenceSystem spatialReferenceSystem2D,
            GeneralEnvelope coverageEnvelope2D,
            final GridSampleDimension[] sampleDimensions); static void setDecimationParameters(
            ImageReadParam readP,
            GridEnvelope baseGridRange,
            double[] requestedRes,
            double[] highestRes); static NameImpl buildCoverageName(URL input); static void setReadParameters(
            OverviewPolicy overviewPolicy,
            ImageReadParam readParam,
            GeneralEnvelope requestedEnvelope,
            Rectangle requestedDim,
            double[] highestRes,
            GridEnvelope gridRange,
            PixelInCell pixelInCell); static GridCoverage createCoverage(
            ImageReaderSpi spi,
            Object input,
            final int imageIndex,
            ImageReadParam imageReadParam,
            final boolean useJAI,
            final boolean useMultithreading,
            final boolean newTransform,
            final GridSampleDimension[] sampleDimensions,
            final String coverageName,
            GridCoverageFactory coverageFactory,
            MathTransform raster2Model,
            CoordinateReferenceSystem coordinateReferenceSystem,
            GeneralEnvelope coverageEnvelope2D); @SuppressWarnings("PMD.CloseResource") // stream managed in the returned delayed read op static PlanarImage readImage(
            final ImageReaderSpi spi,
            final Object input,
            final int imageIndex,
            final boolean useJAI,
            final ImageReadParam imageReadParam,
            final boolean useMultithreading); static GridCoverage compute(
            Object input,
            final int imageIndex,
            final boolean needTransformation,
            final boolean isEmptyRequest,
            final boolean useJAI,
            ImageReadParam imageReadParam,
            final boolean useMultithreading,
            final GridSampleDimension[] sampleDimensions,
            final ImageReaderSpi imageReaderSpi,
            final String coverageName,
            final GridCoverageFactory coverageFactory,
            final MathTransform raster2Model,
            final CoordinateReferenceSystem coordinateReferenceSystem,
            final GeneralEnvelope envelope2D); static final boolean ensureValidString(final String... strings); static String buildIso8601Time(String date, String time); static boolean checkFileReadable(final File file); static String getFileInfo(final File file); static Properties loadPropertiesFromURL(URL propsURL); }
Utilities { public static Envelope getEnvelopeAsWGS84(final Envelope envelope, boolean get2D) throws FactoryException, TransformException { if (envelope == null) throw new IllegalArgumentException("Specified envelope is null"); Envelope requestedWGS84; final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem(); if (!CRS.equalsIgnoreMetadata(crs, DefaultGeographicCRS.WGS84)) { GeneralEnvelope env = CRS.transform(envelope, DefaultGeographicCRS.WGS84); if (get2D) { requestedWGS84 = new Envelope2D(env); ((Envelope2D) requestedWGS84) .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); } else { requestedWGS84 = env; ((GeneralEnvelope) requestedWGS84) .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); } return requestedWGS84; } else { if (get2D) return new Envelope2D(envelope); else return new GeneralEnvelope(envelope); } } private  Utilities(); static ReferenceIdentifier[] getIdentifiers(final String nameIdentifier); static DefaultGeodeticDatum getDefaultGeodeticDatum(
            final String name,
            final double equatorialRadius,
            final double inverseFlattening,
            Unit unit); static File getFileFromCustomInput(Object input); @SuppressWarnings("deprecation") static CoordinateReferenceSystem getMercator2SPProjectedCRS(
            final double standardParallel,
            final double centralMeridian,
            final double natOriginLat,
            GeographicCRS sourceCRS,
            Hints hints); static GeographicCRS getBaseCRS(
            final double equatorialRadius, final double inverseFlattening); static String getAttributeValue(NamedNodeMap attributes, String attributeName); static Unit<? extends Quantity<?>> parseUnit(final String uom); static Envelope getEnvelopeAsWGS84(final Envelope envelope, boolean get2D); static GeneralEnvelope getRequestedEnvelope2D(GeneralEnvelope requestedEnvelope); static Rectangle getCropRegion(
            GeneralEnvelope envelope, final MathTransform gridToWorldTransform); static GeneralEnvelope getIntersection(
            final Envelope2D baseEnvelope2D,
            final CoordinateReferenceSystem spatialReferenceSystem2D,
            GeneralEnvelope requestedEnvelope2D,
            Rectangle requestedDim,
            MathTransform2D readGridToWorld,
            final Envelope2D wgs84BaseEnvelope2D); static MathTransform getOriginalGridToWorld(
            MathTransform raster2Model, final PixelInCell pixInCell); static GeneralEnvelope evaluateRequestedParams(
            GridEnvelope originalGridRange,
            Envelope2D baseEnvelope2D,
            CoordinateReferenceSystem spatialReferenceSystem2D,
            MathTransform originalGridToWorld,
            GeneralEnvelope requestedEnvelope,
            Rectangle sourceRegion,
            Rectangle requestedDim,
            MathTransform2D readGridToWorld,
            Envelope2D wgs84BaseEnvelope2D); static GridCoverage createCoverageFromImage(
            final GridCoverageFactory coverageFactory,
            final String coverageName,
            int imageIndex,
            PlanarImage image,
            MathTransform raster2Model,
            final CoordinateReferenceSystem spatialReferenceSystem2D,
            GeneralEnvelope coverageEnvelope2D,
            final GridSampleDimension[] sampleDimensions); static void setDecimationParameters(
            ImageReadParam readP,
            GridEnvelope baseGridRange,
            double[] requestedRes,
            double[] highestRes); static NameImpl buildCoverageName(URL input); static void setReadParameters(
            OverviewPolicy overviewPolicy,
            ImageReadParam readParam,
            GeneralEnvelope requestedEnvelope,
            Rectangle requestedDim,
            double[] highestRes,
            GridEnvelope gridRange,
            PixelInCell pixelInCell); static GridCoverage createCoverage(
            ImageReaderSpi spi,
            Object input,
            final int imageIndex,
            ImageReadParam imageReadParam,
            final boolean useJAI,
            final boolean useMultithreading,
            final boolean newTransform,
            final GridSampleDimension[] sampleDimensions,
            final String coverageName,
            GridCoverageFactory coverageFactory,
            MathTransform raster2Model,
            CoordinateReferenceSystem coordinateReferenceSystem,
            GeneralEnvelope coverageEnvelope2D); @SuppressWarnings("PMD.CloseResource") // stream managed in the returned delayed read op static PlanarImage readImage(
            final ImageReaderSpi spi,
            final Object input,
            final int imageIndex,
            final boolean useJAI,
            final ImageReadParam imageReadParam,
            final boolean useMultithreading); static GridCoverage compute(
            Object input,
            final int imageIndex,
            final boolean needTransformation,
            final boolean isEmptyRequest,
            final boolean useJAI,
            ImageReadParam imageReadParam,
            final boolean useMultithreading,
            final GridSampleDimension[] sampleDimensions,
            final ImageReaderSpi imageReaderSpi,
            final String coverageName,
            final GridCoverageFactory coverageFactory,
            final MathTransform raster2Model,
            final CoordinateReferenceSystem coordinateReferenceSystem,
            final GeneralEnvelope envelope2D); static final boolean ensureValidString(final String... strings); static String buildIso8601Time(String date, String time); static boolean checkFileReadable(final File file); static String getFileInfo(final File file); static Properties loadPropertiesFromURL(URL propsURL);  }