Class GeneralGridGeometry

    • Constructor Detail

      • GeneralGridGeometry

        public GeneralGridGeometry​(GridGeometry other)
        Creates a new grid geometry with the same values than the given grid geometry. This is a copy constructor useful when the instance must be a GeneralGridGeometry.
        Parameters:
        other - The other grid geometry to copy.
        Since:
        2.5
      • GeneralGridGeometry

        public GeneralGridGeometry​(GridEnvelope gridRange,
                                   PixelInCell anchor,
                                   MathTransform gridToCRS,
                                   CoordinateReferenceSystem crs)
                            throws MismatchedDimensionException,
                                   IllegalArgumentException
        Constructs a new grid geometry from a grid range and a math transform mapping pixel center or corner. This is the most general constructor, the one that gives the maximal control over the grid geometry to be created.
        Parameters:
        gridRange - The valid coordinate range of a grid coverage, or null if none.
        anchor - CELL_CENTER for OGC conventions or CELL_CORNER for Java2D/JAI conventions.
        gridToCRS - The math transform which allows for the transformations from grid coordinates to real world earth coordinates. May be null, but this is not recommended.
        crs - The coordinate reference system for the "real world" coordinates, or null if unknown. This CRS is given to the envelope.
        Throws:
        MismatchedDimensionException - if the math transform and the CRS don't have consistent dimensions.
        IllegalArgumentException - if the math transform can't transform coordinates in the domain of the specified grid range.
        Since:
        2.5
      • GeneralGridGeometry

        public GeneralGridGeometry​(PixelInCell anchor,
                                   MathTransform gridToCRS,
                                   Bounds envelope,
                                   boolean gridMaxInclusive,
                                   boolean preserveGridToCRS)
                            throws MismatchedDimensionException,
                                   IllegalArgumentException
        Constructs a new grid geometry from an envelope and a math transform. According OGC specification, the math transform should map pixel center. But in Java2D/JAI conventions, the transform is rather expected to maps pixel corner. The convention to follow can be specified by the anchor argument.

        It is worth to point a few guidelines for the usage of the gridMaxInclusive parameter. In case we are using this contructor for a reprojection it might be worth using a false value for this parameter since we would not force to create a new raster that might be slightly bigger than the original one, causing problems with black or nodata collars appearing after a resample. In case we are trying to build a source raster area to be used at reading time, in that case we may want to provide true for gridMaxInclusive since we may want to read an area that is slightly bigger than what we need to be sure we actually reading something.

        Parameters:
        anchor - CELL_CENTER for OGC conventions or CELL_CORNER for Java2D/JAI conventions.
        gridToCRS - The math transform which allows for the transformations from grid coordinates to real world earth coordinates. May be null, but this is not recommended.
        envelope - The envelope (including CRS) of a grid coverage, or null if none.
        gridMaxInclusive - Tells us whether or not the resulting gridRange max values should be inclusive or not. See notes above.
        preserveGridToCRS - Tells us whether we should try to preserve the the gridToCRS or the envelope most part of the time we won't be able to preserve both for our purposes.
        Throws:
        MismatchedDimensionException - if the math transform and the envelope doesn't have consistent dimensions.
        IllegalArgumentException - if the math transform can't transform coordinates in the domain of the grid range.
        Since:
        2.7
      • GeneralGridGeometry

        public GeneralGridGeometry​(PixelInCell anchor,
                                   MathTransform gridToCRS,
                                   Bounds envelope)
                            throws MismatchedDimensionException,
                                   IllegalArgumentException
        Constructs a new grid geometry from an envelope and a math transform. According OGC specification, the math transform should map pixel center. But in Java2D/JAI conventions, the transform is rather expected to maps pixel corner. The convention to follow can be specified by the anchor argument.
        Parameters:
        anchor - CELL_CENTER for OGC conventions or CELL_CORNER for Java2D/JAI conventions.
        gridToCRS - The math transform which allows for the transformations from grid coordinates to real world earth coordinates. May be null, but this is not recommended.
        envelope - The envelope (including CRS) of a grid coverage, or null if none.
        Throws:
        MismatchedDimensionException - if the math transform and the envelope doesn't have consistent dimensions.
        IllegalArgumentException - if the math transform can't transform coordinates in the domain of the grid range.
        Since:
        2.5
      • GeneralGridGeometry

        public GeneralGridGeometry​(GridEnvelope gridRange,
                                   Bounds userRange)
                            throws MismatchedDimensionException
        Constructs a new grid geometry from an envelope. An affine transform will be computed automatically from the specified envelope using heuristic rules described in GridToEnvelopeMapper javadoc. More specifically, heuristic rules are applied for:

        Parameters:
        gridRange - The valid coordinate range of a grid coverage.
        userRange - The corresponding coordinate range in user coordinate. This rectangle must contains entirely all pixels, i.e. the rectangle's upper left corner must coincide with the upper left corner of the first pixel and the rectangle's lower right corner must coincide with the lower right corner of the last pixel.
        Throws:
        MismatchedDimensionException - if the grid range and the envelope doesn't have consistent dimensions.
        Since:
        2.2