|
From: <svn...@os...> - 2012-01-22 18:53:22
|
Author: simonegiannecchini
Date: 2012-01-22 10:53:14 -0800 (Sun, 22 Jan 2012)
New Revision: 38513
Modified:
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/GranuleLoader.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicReader.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerResponse.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterManager.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/Utils.java
Log:
GEOT-2867
Modified: branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/GranuleLoader.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/GranuleLoader.java 2012-01-22 18:12:06 UTC (rev 38512)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/GranuleLoader.java 2012-01-22 18:53:14 UTC (rev 38513)
@@ -31,9 +31,11 @@
import org.opengis.referencing.operation.MathTransform2D;
/**
+ * Specific {@link Callable} implementation that can be used to load the result of a request on a
+ * single {@link GranuleDescriptor} via {@link GranuleLoadingResult}.
*
* @author Simone Giannecchini, GeoSolutions SAS
- *
+ *
*/
class GranuleLoader implements Callable<GranuleLoadingResult>{
Modified: branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicReader.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicReader.java 2012-01-22 18:12:06 UTC (rev 38512)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicReader.java 2012-01-22 18:53:14 UTC (rev 38513)
@@ -109,7 +109,7 @@
*/
public final class ImageMosaicReader extends AbstractGridCoverage2DReader implements GridCoverageReader, GridCoverageWriter {
- /** Logger. */
+ /** Logger. */
private final static Logger LOGGER = org.geotools.util.logging.Logging.getLogger(ImageMosaicReader.class);
/**
@@ -783,54 +783,7 @@
}
-// final boolean getRuntimeAttribute=name.equalsIgnoreCase("runtime_domain");
-// if(getRuntimeAttribute){
-// Query query;
-// try {
-// query = new DefaultQuery(rasterManager.granuleCatalog.getType().getTypeName());
-// query.setPropertyNames(Arrays.asList("runtime"));
-// final SortBy[] sortBy=new SortBy[]{
-// new SortByImpl(
-// FeatureUtilities.DEFAULT_FILTER_FACTORY.property("runtime"),
-// SortOrder.DESCENDING
-// )};
-// if(queryCapabilities.supportsSorting(sortBy))
-// query.setSortBy(sortBy);
-//// else
-//// manualSort=true;
-// final UniqueVisitor visitor= new UniqueVisitor("runtime");
-// rasterManager.granuleCatalog.computeAggregateFunction(query, visitor);
-//
-// // check result
-// final Set<Integer> result = new TreeSet<Integer>(new Comparator<Integer>() {
-//
-// public int compare(Integer o1, Integer o2) {
-// // Revert Order
-// if (o1 > 02)
-// return -1;
-// else if (o1 < o2)
-// return 1;
-// return 0;
-// }
-// });
-// result.addAll(visitor.getUnique());
-// if(result.size()<=0)
-// return null;
-// final StringBuilder buff= new StringBuilder();
-// for(Iterator<Integer> it=result.iterator();it.hasNext();){
-// final int value= it.next();
-// buff.append(value);
-// if(it.hasNext())
-// buff.append(",");
-// }
-// return buff.toString();
-// } catch (IOException e) {
-// if(LOGGER.isLoggable(Level.WARNING))
-// LOGGER.log(Level.WARNING,"Unable to parse attribute:"+name,e);
-// }
-//
-// }
-//
+
return super.getMetadataValue(name);
}
@@ -897,8 +850,12 @@
final FeatureCalc visitor = createExtremaQuery(metadataName,rasterManager.elevationAttribute);
// check result
- final Double result=(Double) visitor.getResult().getValue();
- return Double.toString(result);
+ final Object result = visitor.getResult().getValue();
+ if(result instanceof Number) {
+ return result.toString();
+ } else {
+ return null;
+ }
} catch (IOException e) {
if(LOGGER.isLoggable(Level.WARNING))
LOGGER.log(Level.WARNING,"Unable to compute extrema for ELEVATION_DOMAIN",e);
@@ -917,14 +874,14 @@
return null;
}
try {
- final Set<Double> result = extractDomain(elevationAttribute);
+ final Set<Number> result = extractDomain(elevationAttribute);
// check result
if(result.size()<=0)
- return null;
+ return "";
final StringBuilder buff= new StringBuilder();
- for(Iterator<Double> it=result.iterator();it.hasNext();){
- final double value= (Double) it.next();
+ for(Iterator<Number> it= result.iterator(); it.hasNext();){
+ final double value= ((Number) it.next()).doubleValue();
buff.append(value);
if(it.hasNext())
buff.append(",");
@@ -933,7 +890,7 @@
} catch (IOException e) {
if(LOGGER.isLoggable(Level.WARNING))
LOGGER.log(Level.WARNING,"Unable to parse attribute: ELEVATION_DOMAIN",e);
- return null;
+ return "";
}
}
Modified: branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerResponse.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerResponse.java 2012-01-22 18:12:06 UTC (rev 38512)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerResponse.java 2012-01-22 18:53:14 UTC (rev 38513)
@@ -242,10 +242,8 @@
* My specific {@link MaxVisitor} that keeps track of the feature used for the maximum.
* @author Simone Giannecchini, GeoSolutions SAS
*
- *
- * @source $URL: http://svn.osgeo.org/geotools/branches/2.7.x/build/maven/javadoc/../../../modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerResponse.java $
*/
- public static class MaxVisitor2 extends MaxVisitor{
+ static class MaxVisitor2 extends MaxVisitor{
private Comparable oldValue;
private int oldNanCount;
@@ -327,8 +325,18 @@
*
*/
class MosaicBuilder implements GranuleCatalogVisitor{
- private final int maxNumberOfGranules;
+ /**
+ * Default {@link Constructor}
+ */
+ public MosaicBuilder(final RasterLayerRequest request) {
+ this.request=request;
+ maxNumberOfGranules=request.getMaximumNumberOfGranules();
+ }
+
+ private final int maxNumberOfGranules;
+
+
private final List<Future<GranuleLoadingResult>> tasks= new ArrayList<Future<GranuleLoadingResult>>();
private int granulesNumber;
private List<ROI> rois = new ArrayList<ROI>();
@@ -344,14 +352,6 @@
private List<RenderedImage> sources = new ArrayList<RenderedImage>();
-
- /**
- * Default {@link Constructor}
- */
- public MosaicBuilder(final RasterLayerRequest request) {
- this.request=request;
- maxNumberOfGranules=request.getMaximumNumberOfGranules();
- }
public RenderedImage[] getSourcesAsArray() {
RenderedImage []imageSources = new RenderedImage[sources.size()];
@@ -701,12 +701,11 @@
// assemble granules
final RenderedImage mosaic = prepareResponse();
-
//postproc
RenderedImage finalRaster = postProcessRaster(mosaic);
-
//create the coverage
gridCoverage = prepareCoverage(finalRaster);
+
}
@@ -1316,115 +1315,115 @@
return new Rectangle2D.Double(minx, miny, maxx - minx, maxy - miny).getBounds();
}
- /**
- * This method is responsible for creating a coverage from the supplied {@link RenderedImage}.
- *
- * @param image
- * @return
- * @throws IOException
- */
- private GridCoverage2D prepareCoverage(RenderedImage image) throws IOException {
-
- // creating bands
+ /**
+ * This method is responsible for creating a coverage from the supplied {@link RenderedImage}.
+ *
+ * @param image
+ * @return
+ * @throws IOException
+ */
+ private GridCoverage2D prepareCoverage(RenderedImage image) throws IOException {
+
+ // creating bands
final SampleModel sm=image.getSampleModel();
final ColorModel cm=image.getColorModel();
- final int numBands = sm.getNumBands();
- final GridSampleDimension[] bands = new GridSampleDimension[numBands];
- Set<String> bandNames = new HashSet<String>();
- // setting bands names.
- for (int i = 0; i < numBands; i++) {
- // color interpretation
- final ColorInterpretation colorInterpretation=TypeMap.getColorInterpretation(cm, i);
- if(colorInterpretation==null)
- throw new IOException("Unrecognized sample dimension type");
+ final int numBands = sm.getNumBands();
+ final GridSampleDimension[] bands = new GridSampleDimension[numBands];
+ Set<String> bandNames = new HashSet<String>();
+ // setting bands names.
+ for (int i = 0; i < numBands; i++) {
+ // color interpretation
+ final ColorInterpretation colorInterpretation=TypeMap.getColorInterpretation(cm, i);
+ if(colorInterpretation==null)
+ throw new IOException("Unrecognized sample dimension type");
// make sure we create no duplicate band names
- String bandName = colorInterpretation.name();
+ String bandName = colorInterpretation.name();
if(colorInterpretation == ColorInterpretation.UNDEFINED || bandNames.contains(bandName)) {
bandName = "Band" + (i + 1);
- }
-
- // sample dimension type
- final SampleDimensionType st=TypeMap.getSampleDimensionType(sm, i);
-
- // set some no data values, as well as Min and Max values
- final double noData;
- double min=-Double.MAX_VALUE,max=Double.MAX_VALUE;
- if(backgroundValues!=null)
- {
- // sometimes background values are not specified as 1 per each band, therefore we need to be careful
- noData= backgroundValues[backgroundValues.length > i ? i:0];
- }
- else
- {
- if(st.compareTo(SampleDimensionType.REAL_32BITS)==0)
- noData= Float.NaN;
- else
- if(st.compareTo(SampleDimensionType.REAL_64BITS)==0)
- noData= Double.NaN;
- else
- if(st.compareTo(SampleDimensionType.SIGNED_16BITS)==0)
- {
- noData=Short.MIN_VALUE;
- min=Short.MIN_VALUE;
- max=Short.MAX_VALUE;
- }
- else
- if(st.compareTo(SampleDimensionType.SIGNED_32BITS)==0)
- {
- noData= Integer.MIN_VALUE;
+ }
+
+ // sample dimension type
+ final SampleDimensionType st=TypeMap.getSampleDimensionType(sm, i);
+
+ // set some no data values, as well as Min and Max values
+ final double noData;
+ double min=-Double.MAX_VALUE,max=Double.MAX_VALUE;
+ if(backgroundValues!=null)
+ {
+ // sometimes background values are not specified as 1 per each band, therefore we need to be careful
+ noData= backgroundValues[backgroundValues.length > i ? i:0];
+ }
+ else
+ {
+ if(st.compareTo(SampleDimensionType.REAL_32BITS)==0)
+ noData= Float.NaN;
+ else
+ if(st.compareTo(SampleDimensionType.REAL_64BITS)==0)
+ noData= Double.NaN;
+ else
+ if(st.compareTo(SampleDimensionType.SIGNED_16BITS)==0)
+ {
+ noData=Short.MIN_VALUE;
+ min=Short.MIN_VALUE;
+ max=Short.MAX_VALUE;
+ }
+ else
+ if(st.compareTo(SampleDimensionType.SIGNED_32BITS)==0)
+ {
+ noData= Integer.MIN_VALUE;
- min=Integer.MIN_VALUE;
- max=Integer.MAX_VALUE;
- }
- else
- if(st.compareTo(SampleDimensionType.SIGNED_8BITS)==0)
- {
- noData= -128;
- min=-128;
- max=127;
- }
- else
- {
- //unsigned
- noData= 0;
- min=0;
-
-
- // compute max
- if(st.compareTo(SampleDimensionType.UNSIGNED_1BIT)==0)
- max=1;
- else
- if(st.compareTo(SampleDimensionType.UNSIGNED_2BITS)==0)
- max=3;
- else
- if(st.compareTo(SampleDimensionType.UNSIGNED_4BITS)==0)
- max=7;
- else
- if(st.compareTo(SampleDimensionType.UNSIGNED_8BITS)==0)
- max=255;
- else
- if(st.compareTo(SampleDimensionType.UNSIGNED_16BITS)==0)
- max=65535;
- else
- if(st.compareTo(SampleDimensionType.UNSIGNED_32BITS)==0)
- max=Math.pow(2, 32)-1;
-
- }
-
-
- }
- bands[i] = new SimplifiedGridSampleDimension(
- bandName,
- st,
- colorInterpretation,
- noData,
- min,
- max,
- 1, //no scale
- 0, //no offset
- null
- ).geophysics(true);
- }
+ min=Integer.MIN_VALUE;
+ max=Integer.MAX_VALUE;
+ }
+ else
+ if(st.compareTo(SampleDimensionType.SIGNED_8BITS)==0)
+ {
+ noData= -128;
+ min=-128;
+ max=127;
+ }
+ else
+ {
+ //unsigned
+ noData= 0;
+ min=0;
+
+
+ // compute max
+ if(st.compareTo(SampleDimensionType.UNSIGNED_1BIT)==0)
+ max=1;
+ else
+ if(st.compareTo(SampleDimensionType.UNSIGNED_2BITS)==0)
+ max=3;
+ else
+ if(st.compareTo(SampleDimensionType.UNSIGNED_4BITS)==0)
+ max=7;
+ else
+ if(st.compareTo(SampleDimensionType.UNSIGNED_8BITS)==0)
+ max=255;
+ else
+ if(st.compareTo(SampleDimensionType.UNSIGNED_16BITS)==0)
+ max=65535;
+ else
+ if(st.compareTo(SampleDimensionType.UNSIGNED_32BITS)==0)
+ max=Math.pow(2, 32)-1;
+
+ }
+
+
+ }
+ bands[i] = new SimplifiedGridSampleDimension(
+ bandName,
+ st,
+ colorInterpretation,
+ noData,
+ min,
+ max,
+ 1, //no scale
+ 0, //no offset
+ null
+ ).geophysics(true);
+ }
return coverageFactory.create(
rasterManager.getCoverageIdentifier(),
@@ -1437,8 +1436,8 @@
hints),
bands,
null,
- null);
+ null);
- }
+ }
}
Modified: branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterManager.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterManager.java 2012-01-22 18:12:06 UTC (rev 38512)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterManager.java 2012-01-22 18:53:14 UTC (rev 38513)
@@ -134,7 +134,7 @@
// basic initialization
//
coverageGeographicBBox = Utils.getWGS84ReferencedEnvelope(coverageEnvelope);
- coverageGeographicCRS2D = coverageGeographicBBox==null?coverageGeographicBBox.getCoordinateReferenceSystem():null;
+ coverageGeographicCRS2D = coverageGeographicBBox!=null?coverageGeographicBBox.getCoordinateReferenceSystem():null;
//
// Get the original envelope 2d and its spatial reference system
Modified: branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/Utils.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/Utils.java 2012-01-22 18:12:06 UTC (rev 38512)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/Utils.java 2012-01-22 18:53:14 UTC (rev 38513)
@@ -103,11 +103,12 @@
* @source $URL: http://svn.osgeo.org/geotools/branches/2.7.x/build/maven/javadoc/../../../modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/Utils.java $
*/
public class Utils {
+
+ public final static String INDEXER_PROPERTIES = "indexer.properties";
/** EHCache instance to cache histograms */
private static Cache ehcache;
- public final static String INDEXER_PROPERTIES = "indexer.properties";
/** RGB to GRAY coefficients (for Luminance computation) */
public final static double RGB_TO_GRAY_MATRIX [][]= {{ 0.114, 0.587, 0.299, 0 }};
|