Skip to content

Commit

Permalink
Merge pull request #827 from n-lagomarsini/GEOT-5084
Browse files Browse the repository at this point in the history
[GEOT-5084] Add Raster Mask support
  • Loading branch information
aaime committed Apr 30, 2015
2 parents 1e572aa + 7e7eb4c commit abc9bfe
Show file tree
Hide file tree
Showing 39 changed files with 2,448 additions and 347 deletions.
Expand Up @@ -16,6 +16,8 @@
*/
package org.geotools.coverage.grid.io;

import it.geosolutions.imageio.maskband.DatasetLayout;

import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
Expand Down Expand Up @@ -162,6 +164,9 @@ public abstract class AbstractGridCoverage2DReader implements GridCoverage2DRead
protected ImageInputStreamSpi inStreamSPI;

private ImageLayout imageLayout;

/** Coverage {@link DatasetLayout} containing information about Overviews and Mask management*/
protected DatasetLayout dtLayout;

/**
* Default protected constructor. Useful for wrappers.
Expand Down Expand Up @@ -1079,7 +1084,12 @@ public int getNumOverviews(String coverageName) {
throw new IllegalArgumentException("The specified coverageName " + coverageName
+ "is not supported");
}
return overViewResolutions != null ? overViewResolutions.length : 0;
if (dtLayout == null) {
// Back to the default
return numOverviews;
}
return dtLayout.getNumInternalOverviews()
+ (dtLayout.getNumExternalOverviews() > 0 ? dtLayout.getNumExternalOverviews() : 0);
}

@Override
Expand All @@ -1088,6 +1098,19 @@ public int getNumOverviews() {
return getNumOverviews(coverageName);
}

public DatasetLayout getDatasetLayout() {
// Default implementation for backwards compatibility
return getDatasetLayout(coverageName);
}

public DatasetLayout getDatasetLayout(String coverageName) {
if (!checkName(coverageName)) {
throw new IllegalArgumentException("The specified coverageName " + coverageName
+ "is not supported");
}
return dtLayout;
}

public GridEnvelope getOverviewGridEnvelope(int overviewIndex) throws IOException {
return getOverviewGridEnvelope(coverageName, overviewIndex);
}
Expand Down
Expand Up @@ -2,7 +2,7 @@
* GeoTools - The Open Source Java GIS Toolkit
* http://geotools.org
*
* (C) 2013, Open Source Geospatial Foundation (OSGeo)
* (C) 2013-2015, Open Source Geospatial Foundation (OSGeo)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand All @@ -16,6 +16,8 @@
*/
package org.geotools.coverage.grid.io;

import it.geosolutions.imageio.maskband.DatasetLayout;

import java.awt.image.ColorModel;
import java.awt.image.SampleModel;
import java.io.IOException;
Expand Down Expand Up @@ -273,6 +275,7 @@ public interface GridCoverage2DReader extends GridCoverageReader {
*
* @return The number of predetermined overviews for the default coverage. Zero if none are available, -1 if infinite are available, otherwise a
* positive number.
* @deprecated It should be used getDatasetLayout().getNumInternalOverviews() instead
*/
int getNumOverviews();

Expand All @@ -285,9 +288,25 @@ public interface GridCoverage2DReader extends GridCoverageReader {
* positive number.
* @throws NullPointerException if the specified coverageName is <code>null</code>
* @throws IllegalArgumentException if the specified coverageName does not exist
* @deprecated It should be used getDatasetLayout().getNumInternalOverviews() instead
*/
int getNumOverviews(String coverageName);

/**
* Returns the {@link DatasetLayout} for the coverage.
*
* @return a {@link DatasetLayout} object containing info about Overview number and Image masks.
*/
DatasetLayout getDatasetLayout();

/**
* Returns the {@link DatasetLayout} for the specified coverage.
*
* @param coverageName the name of the coverage for which we do want to get the {@link DatasetLayout}
* @return a {@link DatasetLayout} object containing info about Overview number and Image masks.
*/
DatasetLayout getDatasetLayout(String coverageName);

/**
* Retrieve the {@link ImageLayout} for the default coverage.
* <p>
Expand Down

0 comments on commit abc9bfe

Please sign in to comment.