From cd9e7563de41a0ac682b03750f0382d3009e7d5d Mon Sep 17 00:00:00 2001 From: Max Schenkelberg Date: Mon, 16 Jul 2012 10:00:28 -0500 Subject: [PATCH] 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 Change-Id: I8f87118b3e283acc5c19dc97497730b9cabec0f1 Former-commit-id: a9360b707878f7c434a7323ba45aaee63e23a234 [formerly 91148d4bfe159c346baaf33a4fb5bac0c174bd37] Former-commit-id: dcdffe345ddd20e0c44f36cd459eea6e4fcebf58 --- .../interpolation/GridDownscaler.java | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/interpolation/GridDownscaler.java b/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/interpolation/GridDownscaler.java index f156eb7920..0902da9077 100644 --- a/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/interpolation/GridDownscaler.java +++ b/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/interpolation/GridDownscaler.java @@ -64,10 +64,9 @@ public class GridDownscaler { /** * Get the {@link GeneralGridGeometry} [] of downscale levels that the - * GridDownscaler will use for downscaling it's source geometry. This array - * will NOT include the original source geometry in it but instead will - * contain only the downscaled geomerties. An empty array will be returned - * if no downscaling is recommended + * GridDownscaler will use for downscaling it's source geometry. The + * returned array will be at least of size one with the first item in the + * array being the rectangle for the source gridGeometry * * @param gridGeometry * @return @@ -87,9 +86,13 @@ public class GridDownscaler { } List downscaleSizes = new ArrayList(); + GridEnvelope ge = gridGeometry.getGridRange(); Envelope e = gridGeometry.getEnvelope(); + Rectangle currSize = new Rectangle(ge.getSpan(0), ge.getSpan(1)); + downscaleSizes.add(currSize); + while (currSize.width > minGridSize && currSize.height > minGridSize && (!checkSpacing || ((e.getSpan(0) / currSize.width) < MAX_GRID_SPACING_METERS && (e @@ -137,16 +140,37 @@ public class GridDownscaler { 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() { return downscaleGeometries.length; } + /** + * Returns the size of the downscale level passed in. + * + * @param downscaleLevel + * @return + */ 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 destination