Issue #626 Changed downscaler so it can scale from any level to another level instead of always using full resolution level. Fixed Float.NaN reference in AbstractDataWrapper. Fixed GLMesh leak in AbstractTileSet.

Change-Id: I5e36d3a7632f54c19c81818c270b28ac60a385ac

Former-commit-id: cc0a1fbca3 [formerly 0f59e9ea9e204bc49e14135249ef859903a2cbcb]
Former-commit-id: f635e9c332
This commit is contained in:
Max Schenkelberg 2012-07-31 11:22:40 -05:00
parent f7a864a2c0
commit 079a11565a
3 changed files with 22 additions and 26 deletions

View file

@ -489,17 +489,17 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
} }
drawableImages.add(di); drawableImages.add(di);
} else {
rsc.issueRefresh();
} }
if (image == null || image.getStatus() != Status.LOADED if (image == null || image.getStatus() != Status.LOADED) {
|| tile.coverage.getMesh() == null) { rsc.issueRefresh();
needDrawLower = true; needDrawLower = true;
}
if (tile.coverage.getMesh() == null) {
tile.coverage.setMesh(target.getExtension( tile.coverage.setMesh(target.getExtension(
IMapMeshExtension.class).constructMesh( IMapMeshExtension.class).constructMesh(
tile.imageGeometry, mapDescriptor.getGridGeometry())); tile.imageGeometry, mapDescriptor.getGridGeometry()));
target.setNeedsRefresh(true);
} }
} }

View file

@ -103,39 +103,33 @@ public class GridDownscaler {
return downscaleSizes.toArray(new Rectangle[downscaleSizes.size()]); return downscaleSizes.toArray(new Rectangle[downscaleSizes.size()]);
} }
private DataSource dataSource; private Envelope sourceEnvelope;
private GeneralGridGeometry sourceGeometry;
private Rectangle[] downscaleGeometries; private Rectangle[] downscaleGeometries;
private Interpolation interpolation; private Interpolation interpolation;
/** /**
* Constructs a GridDownscaler for the given source geometry and data source * Constructs a GridDownscaler for the given source geometry using the
* using the default interpolation method * default interpolation method
* *
* @param sourceGeometry * @param sourceGeometry
* @param dataSource * @param dataSource
*/ */
public GridDownscaler(GeneralGridGeometry sourceGeometry, public GridDownscaler(GeneralGridGeometry sourceGeometry) {
DataSource dataSource) { this(sourceGeometry, new NearestNeighborInterpolation());
this(sourceGeometry, dataSource, new NearestNeighborInterpolation());
} }
/** /**
* Constructs a GridDownscaler for the given source * Constructs a GridDownscaler for the given source
* {@link GeneralGridGeometry} and {@link DataSource} using the specified * {@link GeneralGridGeometry} using the specified {@link Interpolation}
* {@link Interpolation}
* *
* @param sourceGeometry * @param sourceGeometry
* @param dataSource
* @param interpolation * @param interpolation
*/ */
public GridDownscaler(GeneralGridGeometry sourceGeometry, public GridDownscaler(GeneralGridGeometry sourceGeometry,
DataSource dataSource, Interpolation interpolation) { Interpolation interpolation) {
this.sourceGeometry = sourceGeometry; this.sourceEnvelope = sourceGeometry.getEnvelope();
this.dataSource = dataSource;
this.downscaleGeometries = getDownscaleSizes(sourceGeometry); this.downscaleGeometries = getDownscaleSizes(sourceGeometry);
this.interpolation = interpolation; this.interpolation = interpolation;
} }
@ -176,16 +170,18 @@ public class GridDownscaler {
* @param destination * @param destination
* @throws TransformException * @throws TransformException
*/ */
public void downscale(int downscaleLevel, DataDestination destination) public void downscale(int fromLevel, int toLevel, DataSource source,
throws TransformException { DataDestination destination) throws TransformException {
Rectangle destSize = getDownscaleSize(downscaleLevel); Rectangle sourceSize = getDownscaleSize(fromLevel);
GeneralGridGeometry sourceGeometry = new GeneralGridGeometry(
new GridEnvelope2D(sourceSize), sourceEnvelope);
Rectangle destSize = getDownscaleSize(toLevel);
GeneralGridGeometry destGeometry = new GeneralGridGeometry( GeneralGridGeometry destGeometry = new GeneralGridGeometry(
new GridEnvelope2D(destSize), sourceGeometry.getEnvelope()); new GridEnvelope2D(destSize), sourceEnvelope);
GridReprojection reprojection = new GridReprojection(sourceGeometry, GridReprojection reprojection = new GridReprojection(sourceGeometry,
destGeometry); destGeometry);
try { try {
reprojection reprojection.reprojectedGrid(interpolation, source, destination);
.reprojectedGrid(interpolation, dataSource, destination);
} catch (FactoryException e) { } catch (FactoryException e) {
throw new TransformException( throw new TransformException(
"Error creating transforms required for downscaling", e); "Error creating transforms required for downscaling", e);

View file

@ -86,7 +86,7 @@ public abstract class AbstractDataWrapper implements DataSource,
public double getDataValue(int x, int y) { public double getDataValue(int x, int y) {
if (y < 0 || y > ny - 1) { if (y < 0 || y > ny - 1) {
// outside y range // outside y range
return Float.NaN; return Double.NaN;
} else if (x < 0 || x > nx - 1) { } else if (x < 0 || x > nx - 1) {
// outside x range // outside x range
if (wrapX > 0) { if (wrapX > 0) {