Merge "Issue #626 Changed GridDownscaler to include full resolution grid in levels so level 0 is full grid to make more standard with how downscaling is done now" into development

Former-commit-id: 348eca2c4c [formerly e7bc3cec2a68d9041719126d484bb8f5c03eed2c]
Former-commit-id: 5cdf7b27f6
This commit is contained in:
Nate Jensen 2012-07-16 13:58:03 -05:00 committed by Gerrit Code Review
commit aef9a4a202

View file

@ -64,10 +64,9 @@ public class GridDownscaler {
/** /**
* Get the {@link GeneralGridGeometry} [] of downscale levels that the * Get the {@link GeneralGridGeometry} [] of downscale levels that the
* GridDownscaler will use for downscaling it's source geometry. This array * GridDownscaler will use for downscaling it's source geometry. The
* will NOT include the original source geometry in it but instead will * returned array will be at least of size one with the first item in the
* contain only the downscaled geomerties. An empty array will be returned * array being the rectangle for the source gridGeometry
* if no downscaling is recommended
* *
* @param gridGeometry * @param gridGeometry
* @return * @return
@ -87,9 +86,13 @@ public class GridDownscaler {
} }
List<Rectangle> downscaleSizes = new ArrayList<Rectangle>(); List<Rectangle> downscaleSizes = new ArrayList<Rectangle>();
GridEnvelope ge = gridGeometry.getGridRange(); GridEnvelope ge = gridGeometry.getGridRange();
Envelope e = gridGeometry.getEnvelope(); Envelope e = gridGeometry.getEnvelope();
Rectangle currSize = new Rectangle(ge.getSpan(0), ge.getSpan(1)); Rectangle currSize = new Rectangle(ge.getSpan(0), ge.getSpan(1));
downscaleSizes.add(currSize);
while (currSize.width > minGridSize while (currSize.width > minGridSize
&& currSize.height > minGridSize && currSize.height > minGridSize
&& (!checkSpacing || ((e.getSpan(0) / currSize.width) < MAX_GRID_SPACING_METERS && (e && (!checkSpacing || ((e.getSpan(0) / currSize.width) < MAX_GRID_SPACING_METERS && (e
@ -137,16 +140,37 @@ public class GridDownscaler {
this.interpolation = interpolation; this.interpolation = interpolation;
} }
/**
* Sets the {@link Interpolation} algorithm to be used when downscaling
*
* @param interpolation
*/
public void setInterpolation(Interpolation interpolation) {
this.interpolation = interpolation;
}
/**
* Returns the total number of levels, this includes the full resolution
* grid
*
* @return
*/
public int getNumberOfDownscaleLevels() { public int getNumberOfDownscaleLevels() {
return downscaleGeometries.length; return downscaleGeometries.length;
} }
/**
* Returns the size of the downscale level passed in.
*
* @param downscaleLevel
* @return
*/
public Rectangle getDownscaleSize(int downscaleLevel) { public Rectangle getDownscaleSize(int downscaleLevel) {
return downscaleGeometries[downscaleLevel]; return new Rectangle(downscaleGeometries[downscaleLevel]);
} }
/** /**
* Downscales the specified level into the destination object * Downscales the specified level into the destination object.
* *
* @param downscaleLevel * @param downscaleLevel
* @param destination * @param destination