public Sample[] getSamples() { Sample[] ret = new Sample[width * height]; long t0 = System.currentTimeMillis(); CoordinateReferenceSystem crs = gg.getCoordinateReferenceSystem2D(); try { MathTransform tr = CRS.findMathTransform(crs, DefaultGeographicCRS.WGS84);
public TemplateTile(TileRequest req, Graph graph) { super(req); this.samples = new Sample[width * height]; CoordinateReferenceSystem crs = gg.getCoordinateReferenceSystem2D(); int i = 0; try {
targetRange, gg.getGridToCRS(), gg.getCoordinateReferenceSystem2D());
/** * Returns the two-dimensional part of this grid coverage CRS. If the {@linkplain * #getCoordinateReferenceSystem complete CRS} is two-dimensional, then this method returns the * same CRS. Otherwise it returns a CRS for the two first axis having a {@linkplain * GridRange#length length} greater than 1 in the grid range. Note that those axis are garanteed * to appears in the same order than in the complete CRS. * * @return The two-dimensional part of the grid coverage CRS. * @see #getCoordinateReferenceSystem */ public CoordinateReferenceSystem getCoordinateReferenceSystem2D() { return gridGeometry.getCoordinateReferenceSystem2D(); }
/** * Transforms a point represented by a GridCoordinates2D object from grid to world coordinates. * The coordinates returned are those of the centre of the grid cell in which the point lies. * * <p>Users needing more control over the nature of the conversion (e.g. calculating cell corner * coordinates) can use the {@code MathsTransform} provided by {@linkplain * GridGeometry2D#getGridToCRS2D(PixelOrientation) } which is accessed via {@linkplain * #getGridGeometry()}. * * @param point The point in world coordinate system. * @return A new point in the grid coordinate system as a GridCoordinates2D object * @throws TransformException if the transformation failed. * @throws IllegalArgumentException if the point lies outside the coverage * @since 2.6 */ public final DirectPosition gridToWorld(final GridCoordinates2D point) throws TransformException { if (getGridRange2D().contains(point)) { Point2D trPoint = getGridToCRS2D().transform(point, null); return new DirectPosition2D( getCoordinateReferenceSystem2D(), trPoint.getX(), trPoint.getY()); } else { throw new IllegalArgumentException( Errors.format(ErrorKeys.POINT_OUTSIDE_COVERAGE_$1, point)); } }
/** * Returns the two-dimensional part of this grid coverage CRS. This is usually (but not * always) identical to the {@linkplain #getCoordinateReferenceSystem full CRS}. * * @see #getCoordinateReferenceSystem */ public CoordinateReferenceSystem getCoordinateReferenceSystem2D() { return gridGeometry.getCoordinateReferenceSystem2D(); }
/** * Returns the two-dimensional part of this grid coverage CRS. If the * {@linkplain #getCoordinateReferenceSystem complete CRS} is two-dimensional, then this * method returns the same CRS. Otherwise it returns a CRS for the two first axis having * a {@linkplain GridRange#length length} greater than 1 in the grid range. Note that those * axis are garanteed to appears in the same order than in the complete CRS. * * @return The two-dimensional part of the grid coverage CRS. * * @see #getCoordinateReferenceSystem */ public CoordinateReferenceSystem getCoordinateReferenceSystem2D() { return gridGeometry.getCoordinateReferenceSystem2D(); }
CoordinateReferenceSystem targetCRS = dst.getCoordinateReferenceSystem2D();
/** * Returns a two-dimensional CRS for the given coverage. This method performs a <cite>best * effort</cite>; the returned CRS is not garanteed to be the most appropriate one. * * @param coverage The coverage for which to obtains a two-dimensional CRS. * @return The two-dimensional CRS. * @throws TransformException if the CRS can't be reduced to two dimensions. */ public static CoordinateReferenceSystem getCRS2D(final Coverage coverage) throws TransformException { if (coverage instanceof GridCoverage2D) { return ((GridCoverage2D) coverage).getCoordinateReferenceSystem2D(); } if (coverage instanceof GridCoverage) { final GridGeometry2D geometry = GridGeometry2D.wrap(((GridCoverage) coverage).getGridGeometry()); if (geometry.isDefined(GridGeometry2D.CRS_BITMASK)) { return geometry.getCoordinateReferenceSystem2D(); } else try { return geometry.reduce(coverage.getCoordinateReferenceSystem()); } catch (FactoryException exception) { // Ignore; we will fallback on the code below. } } return CRSUtilities.getCRS2D(coverage.getCoordinateReferenceSystem()); }
synchronized (this) { if (arbitraryToInternal == null) { final CoordinateReferenceSystem targetCRS = getCoordinateReferenceSystem2D(); arbitraryToInternal = new TransformedDirectPosition(sourceCRS, targetCRS, null);
final CoordinateReferenceSystem crs = gg.getCoordinateReferenceSystem2D();
GridGeometry2D.wrap(((GridCoverage) coverage).getGridGeometry()); if (geometry.isDefined(GridGeometry2D.CRS_BITMASK)) { returnedCRS = geometry.getCoordinateReferenceSystem2D(); } else try {
/** * Transforms a point represented by a GridCoordinates2D object from grid * to world coordinates. The coordinates returned are those of the centre * of the grid cell in which the point lies. * <p> * Users needing more control over the nature of the conversion (e.g. calculating * cell corner coordinates) can use the {@code MathsTransform} provided by * {@linkplain GridGeometry2D#getGridToCRS2D(PixelOrientation) } * which is accessed via {@linkplain #getGridGeometry()}. * * @param point The point in world coordinate system. * @return A new point in the grid coordinate system as a GridCoordinates2D object * * @throws TransformException if the transformation failed. * * @throws IllegalArgumentException if the point lies outside the coverage * * @since 2.6 */ public final DirectPosition gridToWorld(final GridCoordinates2D point) throws TransformException { if (getGridRange2D().contains(point)) { Point2D trPoint = getGridToCRS2D().transform(point, null); return new DirectPosition2D(getCoordinateReferenceSystem2D(), trPoint.getX(), trPoint.getY()); } else { throw new IllegalArgumentException( Errors.format(ErrorKeys.POINT_OUTSIDE_COVERAGE_$1, point)); } }
CoordinateReferenceSystem targetCRS = dstGridGeometry.getCoordinateReferenceSystem2D(); if (!CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) { src2dstCRSTransform = CRS.findMathTransform(sourceCRS, targetCRS, true);
range = new GridEnvelope2D(sourceRegion); final AffineTransform tr = (AffineTransform) gg.getGridToCRS2D(); final CoordinateReferenceSystem crs = gg.getCoordinateReferenceSystem2D(); final double inNoData = getCandidateNoData(gc);
/** * Returns a two-dimensional CRS for the given coverage. This method performs a * <cite>best effort</cite>; the returned CRS is not garanteed to be the most * appropriate one. * * @param coverage The coverage for which to obtains a two-dimensional CRS. * @return The two-dimensional CRS. * @throws TransformException if the CRS can't be reduced to two dimensions. */ public static CoordinateReferenceSystem getCRS2D(final Coverage coverage) throws TransformException { if (coverage instanceof GridCoverage2D) { return ((GridCoverage2D) coverage).getCoordinateReferenceSystem2D(); } if (coverage instanceof GridCoverage) { final GridGeometry2D geometry = GridGeometry2D.wrap(((GridCoverage) coverage).getGridGeometry()); if (geometry.isDefined(GridGeometry2D.CRS_BITMASK)) { return geometry.getCoordinateReferenceSystem2D(); } else try { return geometry.reduce(coverage.getCoordinateReferenceSystem()); } catch (FactoryException exception) { // Ignore; we will fallback on the code below. } } return CRSUtilities.getCRS2D(coverage.getCoordinateReferenceSystem()); }
synchronized (this) { if (arbitraryToInternal == null) { final CoordinateReferenceSystem targetCRS = getCoordinateReferenceSystem2D(); arbitraryToInternal = new TransformedDirectPosition(sourceCRS, targetCRS, null);
GridGeometry2D.wrap(((GridCoverage) coverage).getGridGeometry()); if (geometry.isDefined(GridGeometry2D.CRS_BITMASK)) { returnedCRS= geometry.getCoordinateReferenceSystem2D(); } else try { returnedCRS= geometry.reduce(coverage.getCoordinateReferenceSystem());