protected Double[][] reprojectCoverageData(Double[][] values,
			int requestedCoverageWidth, int requestedCoverageHeight,
			BoundingBox requestBoundingBox,
			ProjectionTransform transformRequestToCoverage,
			BoundingBox coverageBoundingBox) {

		final double requestedWidthUnitsPerPixel = (requestBoundingBox
				.getMaxLongitude() - requestBoundingBox.getMinLongitude())
				/ requestedCoverageWidth;
		final double requestedHeightUnitsPerPixel = (requestBoundingBox
				.getMaxLatitude() - requestBoundingBox.getMinLatitude())
				/ requestedCoverageHeight;

		final double tilesDistanceWidth = coverageBoundingBox.getMaxLongitude()
				- coverageBoundingBox.getMinLongitude();
		final double tilesDistanceHeight = coverageBoundingBox.getMaxLatitude()
				- coverageBoundingBox.getMinLatitude();

		final int width = values[0].length;
		final int height = values.length;

		Double[][] projectedValues = new Double[requestedCoverageHeight][requestedCoverageWidth];

		// Retrieve each coverage data value in the unprojected coverage data
		for (int y = 0; y < requestedCoverageHeight; y++) {
			for (int x = 0; x < requestedCoverageWidth; x++) {

				double longitude = requestBoundingBox.getMinLongitude()
						+ (x * requestedWidthUnitsPerPixel);
				double latitude = requestBoundingBox.getMaxLatitude()
						- (y * requestedHeightUnitsPerPixel);
				ProjCoordinate fromCoord = new ProjCoordinate(longitude,
						latitude);
				ProjCoordinate toCoord = transformRequestToCoverage
						.transform(fromCoord);
				double projectedLongitude = toCoord.x;
				double projectedLatitude = toCoord.y;

				int xPixel = (int) Math
						.round(((projectedLongitude - coverageBoundingBox
								.getMinLongitude()) / tilesDistanceWidth)
								* width);
				int yPixel = (int) Math
						.round(((coverageBoundingBox.getMaxLatitude() - projectedLatitude) / tilesDistanceHeight)
								* height);

				xPixel = Math.max(0, xPixel);
				xPixel = Math.min(width - 1, xPixel);

				yPixel = Math.max(0, yPixel);
				yPixel = Math.min(height - 1, yPixel);

				Double coverageData = values[yPixel][xPixel];
				projectedValues[y][x] = coverageData;
			}
		}

		return projectedValues;
	}
protected Double [ ] [ ] reprojectCoverageData ( Double [ ] [ ] values , int requestedCoverageWidth , int requestedCoverageHeight , BoundingBox requestBoundingBox , ProjectionTransform transformRequestToCoverage , BoundingBox coverageBoundingBox ) { final double requestedWidthUnitsPerPixel = ( requestBoundingBox . getMaxLongitude ( ) - requestBoundingBox . getMinLongitude ( ) ) / requestedCoverageWidth ; final double requestedHeightUnitsPerPixel = ( requestBoundingBox . getMaxLatitude ( ) - requestBoundingBox . getMinLatitude ( ) ) / requestedCoverageHeight ; final double tilesDistanceWidth = coverageBoundingBox . getMaxLongitude ( ) - coverageBoundingBox . getMinLongitude ( ) ; final double tilesDistanceHeight = coverageBoundingBox . getMaxLatitude ( ) - coverageBoundingBox . getMinLatitude ( ) ; final int width = values [ 0 ] . length ; final int height = values . length ; Double [ ] [ ] projectedValues = new Double [ requestedCoverageHeight ] [ requestedCoverageWidth ] ; for ( int y = 0 ; y < requestedCoverageHeight ; y ++ ) { for ( int x = 0 ; x < requestedCoverageWidth ; x ++ ) { double longitude = requestBoundingBox . getMinLongitude ( ) + ( x * requestedWidthUnitsPerPixel ) ; double latitude = requestBoundingBox . getMaxLatitude ( ) - ( y * requestedHeightUnitsPerPixel ) ; ProjCoordinate fromCoord = new ProjCoordinate ( longitude , latitude ) ; ProjCoordinate toCoord = transformRequestToCoverage . transform ( fromCoord ) ; double projectedLongitude = toCoord . x ; double projectedLatitude = toCoord . y ; int xPixel = ( int ) Math . round ( ( ( projectedLongitude - coverageBoundingBox . getMinLongitude ( ) ) / tilesDistanceWidth ) * width ) ; int yPixel = ( int ) Math . round ( ( ( coverageBoundingBox . getMaxLatitude ( ) - projectedLatitude ) / tilesDistanceHeight ) * height ) ; xPixel = Math . max ( 0 , xPixel ) ; xPixel = Math . min ( width - 1 , xPixel ) ; yPixel = Math . max ( 0 , yPixel ) ; yPixel = Math . min ( height - 1 , yPixel ) ; Double coverageData = values [ yPixel ] [ xPixel ] ; projectedValues [ y ] [ x ] = coverageData ; } } return projectedValues ; }
Reproject the coverage data to the requested projection

@param values
coverage data values
@param requestedCoverageWidth
requested coverage data width
@param requestedCoverageHeight
requested coverage data height
@param requestBoundingBox
request bounding box in the request projection
@param transformRequestToCoverage
transformation from request to coverage data
@param coverageBoundingBox
coverage data bounding box
@return projected coverage data