|
From: <svn...@os...> - 2012-01-23 08:22:11
|
Author: simonegiannecchini
Date: 2012-01-23 00:22:01 -0800 (Mon, 23 Jan 2012)
New Revision: 38517
Modified:
trunk/modules/plugin/imagemosaic/pom.xml
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/GranuleDescriptor.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormat.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormatFactory.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicReader.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/MosaicConfigurationBean.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/PathType.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerResponse.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterManager.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ReadType.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/Utils.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalog/AbstractGranuleCatalog.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalog/GTDataStoreGranuleCatalog.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalog/GranuleCatalogFactory.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalog/GranuleCatalogVisitor.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalog/STRTreeGranuleCatalog.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalogbuilder/CatalogBuilder.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalogbuilder/CatalogBuilderConfiguration.java
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/processing/ArtifactsFilterOpImage.java
trunk/modules/plugin/imagemosaic/src/test/java/org/geotools/gce/imagemosaic/CatalogBuilderTest.java
trunk/modules/plugin/imagemosaic/src/test/java/org/geotools/gce/imagemosaic/ImageMosaicReaderTest.java
Log:
GEOT-2867
Modified: trunk/modules/plugin/imagemosaic/pom.xml
===================================================================
--- trunk/modules/plugin/imagemosaic/pom.xml 2012-01-23 03:46:30 UTC (rev 38516)
+++ trunk/modules/plugin/imagemosaic/pom.xml 2012-01-23 08:22:01 UTC (rev 38517)
@@ -139,20 +139,14 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.geotools</groupId>
- <artifactId>gt-image</artifactId>
- <version>${project.version}</version>
+ <groupId>it.geosolutions.imageio-ext</groupId>
+ <artifactId>imageio-ext-streams</artifactId>
</dependency>
- <!--dependency>
- <groupId>org.geotools</groupId>
- <artifactId>gt-imageio-ext-gdal</artifactId>
- <version>${project.version}</version>
- </dependency-->
<dependency>
<groupId>org.geotools</groupId>
- <artifactId>gt-jp2k</artifactId>
+ <artifactId>gt-image</artifactId>
<version>${project.version}</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-cql</artifactId>
Modified: trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/GranuleDescriptor.java
===================================================================
--- trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/GranuleDescriptor.java 2012-01-23 03:46:30 UTC (rev 38516)
+++ trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/GranuleDescriptor.java 2012-01-23 08:22:01 UTC (rev 38517)
@@ -34,8 +34,10 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.imageio.ImageIO;
import javax.imageio.ImageReadParam;
import javax.imageio.ImageReader;
+import javax.imageio.spi.ImageInputStreamSpi;
import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.stream.ImageInputStream;
import javax.media.jai.BorderExtender;
@@ -265,9 +267,12 @@
ImageReaderSpi cachedReaderSPI;
SimpleFeature originator;
+
boolean handleArtifactsFiltering = false;
boolean filterMe = false;
+
+ ImageInputStreamSpi cachedStreamSPI;
private void init(final BoundingBox granuleBBOX, final URL granuleUrl,
final ImageReaderSpi suggestedSPI, final Geometry inclusionGeometry,
@@ -294,9 +299,29 @@
//
// get a stream
- inStream = Utils.getInputStream(granuleUrl);
- if(inStream == null)
- throw new IllegalArgumentException("Unable to get an input stream for the provided file "+granuleUrl.toString());
+ if(cachedStreamSPI==null){
+ cachedStreamSPI=ImageIOExt.getImageInputStreamSPI(granuleUrl, true);
+ if(cachedStreamSPI==null){
+ final File file = DataUtilities.urlToFile(granuleUrl);
+ if(file!=null){
+ if(LOGGER.isLoggable(Level.WARNING)){
+ LOGGER.log(Level.WARNING,Utils.getFileInfo(file));
+ }
+ }
+ throw new IllegalArgumentException("Unable to get an input stream for the provided granule "+granuleUrl.toString());
+ }
+ }
+ assert cachedStreamSPI!=null:"no cachedStreamSPI available!";
+ inStream = cachedStreamSPI.createInputStreamInstance(granuleUrl, ImageIO.getUseCache(), ImageIO.getCacheDirectory());
+ if(inStream == null){
+ final File file = DataUtilities.urlToFile(granuleUrl);
+ if(file!=null){
+ if(LOGGER.isLoggable(Level.WARNING)){
+ LOGGER.log(Level.WARNING,Utils.getFileInfo(file));
+ }
+ }
+ throw new IllegalArgumentException("Unable to get an input stream for the provided file "+granuleUrl.toString());
+ }
// get a reader and try to cache the suggested SPI first
if(cachedReaderSPI == null){
@@ -596,7 +621,8 @@
//
// get a stream
- inStream = Utils.getInputStream(granuleUrl);
+ assert cachedStreamSPI!=null:"no cachedStreamSPI available!";
+ inStream = cachedStreamSPI.createInputStreamInstance(granuleUrl, ImageIO.getUseCache(), ImageIO.getCacheDirectory());
if(inStream==null)
return null;
@@ -888,7 +914,7 @@
} finally {
try {
- if (inStream != null) {
+ if (request.getReadType() != ReadType.JAI_IMAGEREAD && inStream != null) {
inStream.close();
}
} finally {
@@ -952,7 +978,8 @@
try {
// get a stream
- inStream = Utils.getInputStream(granuleUrl);
+ assert cachedStreamSPI!=null:"no cachedStreamSPI available!";
+ inStream = cachedStreamSPI.createInputStreamInstance(granuleUrl, ImageIO.getUseCache(), ImageIO.getCacheDirectory());
if(inStream==null)
throw new IllegalArgumentException("Unable to create an inputstream for the granuleurl:"+(granuleUrl!=null?granuleUrl:"null"));
Modified: trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormat.java
===================================================================
--- trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormat.java 2012-01-23 03:46:30 UTC (rev 38516)
+++ trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormat.java 2012-01-23 08:22:01 UTC (rev 38517)
@@ -102,6 +102,7 @@
*
* @source $URL$
*/
+@SuppressWarnings("rawtypes")
public final class ImageMosaicFormat extends AbstractGridFormat implements Format {
final static double DEFAULT_ARTIFACTS_FILTER_PTILE_THRESHOLD = 0.1;
@@ -200,7 +201,7 @@
}
/**
- * @see org.geotools.data.coverage.grid.AbstractGridFormat#getImageioReader(Object)
+ * @see org.geotools.data.coverage.grid.AbstractGridFormat#getReader(Object)
*/
@Override
public ImageMosaicReader getReader( Object source ) {
@@ -265,6 +266,7 @@
return true;
}
+ @SuppressWarnings("unchecked")
private boolean checkForUrl( Object source, Hints hints){
try {
@@ -278,12 +280,11 @@
return false; // file does not exist
}
}
- // /////////////////////////////////////////////////////////////////////
+
//
// Load tiles informations, especially the bounds, which will be
// reused
//
- // /////////////////////////////////////////////////////////////////////
DataStore tileIndexStore = null;
CoordinateReferenceSystem crs=null;
boolean shapefile=true;
@@ -358,11 +359,9 @@
if(crs==null)
return false;
- // /////////////////////////////////////////////////////////////////////
- //
- // Now look for the properties file and try to parse relevant fields
- //
- // /////////////////////////////////////////////////////////////////////
+ //
+ // Now look for the properties file and try to parse relevant fields
+ //
URL propsUrl = null;
if(shapefile)
propsUrl=DataUtilities.changeUrlExt(sourceURL, "properties");
Modified: trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormatFactory.java
===================================================================
--- trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormatFactory.java 2012-01-23 03:46:30 UTC (rev 38516)
+++ trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormatFactory.java 2012-01-23 08:22:01 UTC (rev 38517)
@@ -47,362 +47,349 @@
* @source $URL$
*/
public final class ImageMosaicFormatFactory implements GridFormatFactorySpi {
-
- /** Logger. */
- private final static Logger LOGGER = org.geotools.util.logging.Logging.getLogger(ImageMosaicFormatFactory.class);
-
- private static final String KAKADU_SPI = "it.geosolutions.imageio.plugins.jp2k.JP2KKakaduImageReaderSpi";
-
- private static final String GDAL_SPI = "it.geosolutions.imageio.gdalframework.GDALImageReaderSpi";
-
- private static final String GDAL_JP2ECW_SPI = "it.geosolutions.imageio.plugins.jp2ecw.JP2GDALEcwImageReaderSpi";
-
- private static final String GDAL_JP2MrSID_SPI = "it.geosolutions.imageio.plugins.jp2mrsid.JP2GDALMrSidImageReaderSpi";
-
- private static final String GDAL_JP2KAKADU_SPI = "it.geosolutions.imageio.plugins.jp2kakadu.JP2GDALKakaduImageReaderSpi";
- static {
-
- replaceTIFF();
-
- if(hasJP2Kakadu()){
- replaceJP2Kakadu();
- }
-
- else{
- if(hasJP2GDALECW()){
- replaceECW();
- }
- if(hasJP2GDALMRSID()){
- replaceMRSID();
- }
- if(hasJP2GDALKakadu()){
- replaceGDALKakadu();
- }
- }
-
- }
- /**
- * Tells me if this plugin will work on not given the actual installation.
- *
- * <p>
- * Dependecies are mostly from JAI and ImageIO so if they are installed you
- * should not have many problems.
- *
- * @return False if something's missing, true otherwise.
- */
- public boolean isAvailable() {
- boolean available = true;
+ private static final String GDAL_JP2ECW_SPI = "it.geosolutions.imageio.plugins.jp2ecw.JP2GDALEcwImageReaderSpi";
+ private static final String GDAL_JP2KAKADU_SPI = "it.geosolutions.imageio.plugins.jp2kakadu.JP2GDALKakaduImageReaderSpi";
+ private static final String GDAL_JP2MrSID_SPI = "it.geosolutions.imageio.plugins.jp2mrsid.JP2GDALMrSidImageReaderSpi";
+ private static final String GDAL_SPI = "it.geosolutions.imageio.gdalframework.GDALImageReaderSpi";
+ private static final String KAKADU_SPI = "it.geosolutions.imageio.plugins.jp2k.JP2KKakaduImageReaderSpi";
+ /** Logger. */
+ private final static Logger LOGGER = org.geotools.util.logging.Logging.getLogger(ImageMosaicFormatFactory.class);
- // if these classes are here, then the runtine environment has
- // access to JAI and the JAI ImageI/O toolbox.
- try {
- Class.forName("javax.media.jai.JAI");
- Class.forName("com.sun.media.jai.operator.ImageReadDescriptor");
- } catch (ClassNotFoundException cnf) {
- available = false;
- }
+ static {
+
+ replaceTIFF();
+
+ if(hasJP2Kakadu()){
+ replaceJP2Kakadu();
+ }
+
+ else{
+ if(hasJP2GDALECW()){
+ replaceECW();
+ }
+ if(hasJP2GDALMRSID()){
+ replaceMRSID();
+ }
+ if(hasJP2GDALKakadu()){
+ replaceGDALKakadu();
+ }
+ }
+
+ }
- return available;
- }
+ private static boolean hasJP2GDALECW() {
+ try{
+ Class<?> cl = Class.forName(GDAL_JP2ECW_SPI);
+ Class<?> cGdal = Class.forName(GDAL_SPI);
+ Object jp2ecwSPI = cl.newInstance();
+ final Method method = cGdal.getDeclaredMethod("isAvailable", (Class[])null);
+ if (method != null){
+ return (Boolean) method.invoke(jp2ecwSPI,(Object[]) null);
+ }
+ } catch (ClassNotFoundException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
+ } catch (SecurityException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
+ } catch (NoSuchMethodException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
+ } catch (IllegalArgumentException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
+ } catch (IllegalAccessException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
+ } catch (InvocationTargetException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
+ } catch (InstantiationException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
+ }
+ return false;
+ }
+ private static boolean hasJP2GDALKakadu() {
+ try{
+ Class<?> cl = Class.forName(GDAL_JP2KAKADU_SPI);
+ Class<?> cGdal = Class.forName(GDAL_SPI);
+ Object jp2Kak = cl.newInstance();
+ final Method method = cGdal.getDeclaredMethod("isAvailable", (Class[])null);
+ if (method != null){
+ return (Boolean) method.invoke(jp2Kak,(Object[])null);
+ }
+ } catch (ClassNotFoundException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
+ } catch (SecurityException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
+ } catch (NoSuchMethodException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
+ } catch (IllegalArgumentException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
+ } catch (IllegalAccessException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
+ } catch (InvocationTargetException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
+ } catch (InstantiationException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
+ }
+ return false;
+ }
- private static boolean hasJP2Kakadu() {
- try{
- @SuppressWarnings("unused")
- Class<?> cl = Class.forName(KAKADU_SPI);
- Class<?> utilityClass = Class.forName("it.geosolutions.util.KakaduUtilities");
- final Method method = utilityClass.getDeclaredMethod("isKakaduAvailable", (Class[])null);
- if (method != null){
- Boolean isAvailable = (Boolean) method.invoke(null, null);
- return isAvailable.booleanValue();
- }
- } catch (ClassNotFoundException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load kakadu JPEG2000 reader spi",e);
- } catch (SecurityException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load kakadu JPEG2000 reader spi",e);
- } catch (NoSuchMethodException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load kakadu JPEG2000 reader spi",e);
- } catch (IllegalArgumentException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load kakadu JPEG2000 reader spi",e);
- } catch (IllegalAccessException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load kakadu JPEG2000 reader spi",e);
- } catch (InvocationTargetException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load kakadu JPEG2000 reader spi",e);
- }
- return false;
- }
-
- private static void replaceJP2Kakadu() {
- try{
- Class.forName(KAKADU_SPI);
-
- // imageio kakJP2 reader
- final String imageioJ2KImageReaderCodecName=J2KImageReaderCodecLibSpi.class.getName();
-
- if(PackageUtil.isCodecLibAvailable()){
- boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, KAKADU_SPI, imageioJ2KImageReaderCodecName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+KAKADU_SPI+":"+imageioJ2KImageReaderCodecName);
- }
-
- // imageio kakJP2 reader
- final String imageioJ2KImageReaderName=J2KImageReaderSpi.class.getName();
-
- final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, KAKADU_SPI, imageioJ2KImageReaderName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+KAKADU_SPI+":"+imageioJ2KImageReaderName);
-
- } catch (ClassNotFoundException e) {
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.log(Level.WARNING, "Unable to load specific JPEG2000 reader spi",e);
- }
- }
-
- private static void replaceTIFF() {
- try{
- //check if our tiff plugin is in the path
- final String customTiffName=it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReaderSpi.class.getName();
- Class.forName(customTiffName);
-
- // imageio tiff reader
- final String imageioTiffName=TIFFImageReaderSpi.class.getName();
-
- final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, customTiffName, imageioTiffName, "tiff");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between tiff readers spi");
-
- } catch (ClassNotFoundException e) {
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.log(Level.WARNING,"Unable to load specific TIFF reader spi",e);
- }
-
- }
-
- private static boolean hasJP2GDALKakadu() {
- try{
- @SuppressWarnings("unused")
- Class<?> cl = Class.forName(GDAL_JP2KAKADU_SPI);
- Class<?> cGdal = Class.forName(GDAL_SPI);
- Object jp2Kak = cl.newInstance();
- final Method method = cGdal.getDeclaredMethod("isAvailable", (Class[])null);
- if (method != null){
- Boolean isAvailable = (Boolean) method.invoke(jp2Kak, null);
- return isAvailable.booleanValue();
- }
- } catch (ClassNotFoundException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
- } catch (SecurityException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
- } catch (NoSuchMethodException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
- } catch (IllegalArgumentException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
- } catch (IllegalAccessException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
- } catch (InvocationTargetException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
- } catch (InstantiationException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 Kakadu Reader SPI", e);
- }
- return false;
+ private static boolean hasJP2GDALMRSID() {
+ try{
+ Class<?> cl = Class.forName(GDAL_JP2MrSID_SPI);
+ Class<?> cGdal = Class.forName(GDAL_SPI);
+ Object jp2MrSid = cl.newInstance();
+ final Method method = cGdal.getDeclaredMethod("isAvailable", (Class[])null);
+ if (method != null){
+ return (Boolean) method.invoke(jp2MrSid, (Object[])null);
+ }
+ } catch (ClassNotFoundException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
+ } catch (SecurityException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
+ } catch (NoSuchMethodException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
+ } catch (IllegalArgumentException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
+ } catch (IllegalAccessException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
+ } catch (InvocationTargetException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
+ } catch (InstantiationException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
}
+ return false;
+ }
- private static void replaceGDALKakadu() {
- try{
- //check if our kakJP2 plugin is in the path
+ private static boolean hasJP2Kakadu() {
+ try{
+ Class<?> cl = Class.forName(KAKADU_SPI);
+ Class<?> utilityClass = Class.forName("it.geosolutions.util.KakaduUtilities");
+ final Method method = utilityClass.getDeclaredMethod("isKakaduAvailable", (Class[])null);
+ if (method != null){
+ return (Boolean) method.invoke(null, (Object[])null);
+ }
+ } catch (ClassNotFoundException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load kakadu JPEG2000 reader spi",e);
+ } catch (SecurityException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load kakadu JPEG2000 reader spi",e);
+ } catch (NoSuchMethodException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load kakadu JPEG2000 reader spi",e);
+ } catch (IllegalArgumentException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load kakadu JPEG2000 reader spi",e);
+ } catch (IllegalAccessException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load kakadu JPEG2000 reader spi",e);
+ } catch (InvocationTargetException e) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.log(Level.FINE, "Unable to load kakadu JPEG2000 reader spi",e);
+ }
+ return false;
+ }
- Class.forName(GDAL_JP2KAKADU_SPI);
+ private static void replaceECW() {
+ try{
+ //check if our ecwJP2 plugin is in the path
+ Class.forName(GDAL_JP2ECW_SPI);
+
+ // imageio ecwJP2 reader
+ final String imageioJ2KImageReaderCodecName=J2KImageReaderCodecLibSpi.class.getName();
+
+ if(PackageUtil.isCodecLibAvailable()){
+ boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, GDAL_JP2ECW_SPI, imageioJ2KImageReaderCodecName, "JPEG 2000");
+ if(!succeeded)
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Unable to set ordering between jp2 readers spi-"+GDAL_JP2ECW_SPI+":"+imageioJ2KImageReaderCodecName);
+ }
+
+ // imageio ecwJP2 reader
+ final String imageioJ2KImageReaderName=J2KImageReaderSpi.class.getName();
+
+ final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, GDAL_JP2ECW_SPI, imageioJ2KImageReaderName, "JPEG 2000");
+ if(!succeeded)
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Unable to set ordering between jp2 readers spi-"+GDAL_JP2ECW_SPI+":"+imageioJ2KImageReaderName);
+
+ } catch (ClassNotFoundException e) {
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.log(Level.WARNING, "Unable to load specific JPEG2000 reader spi",e);
+ }
+
+ }
- // imageio kakJP2 reader
- final String imageioJ2KImageReaderCodecName=J2KImageReaderCodecLibSpi.class.getName();
-
- if(PackageUtil.isCodecLibAvailable()){
- boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, GDAL_JP2KAKADU_SPI, imageioJ2KImageReaderCodecName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+GDAL_JP2KAKADU_SPI+":"+imageioJ2KImageReaderCodecName);
- }
-
- // imageio kakJP2 reader
- final String imageioJ2KImageReaderName=J2KImageReaderSpi.class.getName();
-
-
- final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, GDAL_JP2KAKADU_SPI, imageioJ2KImageReaderName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+GDAL_JP2KAKADU_SPI+":"+imageioJ2KImageReaderName);
-
- } catch (ClassNotFoundException e) {
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.log(Level.WARNING, "Unable to load specific JPEG2000 reader spi",e);
- }
-
- }
+ private static void replaceGDALKakadu() {
+ try{
+ //check if our kakJP2 plugin is in the path
+
+ Class.forName(GDAL_JP2KAKADU_SPI);
+
+ // imageio kakJP2 reader
+ final String imageioJ2KImageReaderCodecName=J2KImageReaderCodecLibSpi.class.getName();
+
+ if(PackageUtil.isCodecLibAvailable()){
+ boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, GDAL_JP2KAKADU_SPI, imageioJ2KImageReaderCodecName, "JPEG 2000");
+ if(!succeeded)
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Unable to set ordering between jp2 readers spi-"+GDAL_JP2KAKADU_SPI+":"+imageioJ2KImageReaderCodecName);
+ }
+
+ // imageio kakJP2 reader
+ final String imageioJ2KImageReaderName=J2KImageReaderSpi.class.getName();
+
+
+ final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, GDAL_JP2KAKADU_SPI, imageioJ2KImageReaderName, "JPEG 2000");
+ if(!succeeded)
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Unable to set ordering between jp2 readers spi-"+GDAL_JP2KAKADU_SPI+":"+imageioJ2KImageReaderName);
+
+ } catch (ClassNotFoundException e) {
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.log(Level.WARNING, "Unable to load specific JPEG2000 reader spi",e);
+ }
+
+ }
- private static void replaceMRSID() {
- try{
- //check if our mrsidJP2 plugin is in the path
- Class.forName(GDAL_JP2MrSID_SPI );
+ private static void replaceJP2Kakadu() {
+ try{
+ Class.forName(KAKADU_SPI);
+
+ // imageio kakJP2 reader
+ final String imageioJ2KImageReaderCodecName=J2KImageReaderCodecLibSpi.class.getName();
+
+ if(PackageUtil.isCodecLibAvailable()){
+ boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, KAKADU_SPI, imageioJ2KImageReaderCodecName, "JPEG 2000");
+ if(!succeeded)
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Unable to set ordering between jp2 readers spi-"+KAKADU_SPI+":"+imageioJ2KImageReaderCodecName);
+ }
+
+ // imageio kakJP2 reader
+ final String imageioJ2KImageReaderName=J2KImageReaderSpi.class.getName();
+
+ final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, KAKADU_SPI, imageioJ2KImageReaderName, "JPEG 2000");
+ if(!succeeded)
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Unable to set ordering between jp2 readers spi-"+KAKADU_SPI+":"+imageioJ2KImageReaderName);
+
+ } catch (ClassNotFoundException e) {
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.log(Level.WARNING, "Unable to load specific JPEG2000 reader spi",e);
+ }
+ }
- // imageio tiff reader
- final String imageioJ2KImageReaderCodecName=J2KImageReaderCodecLibSpi.class.getName();
-
- if(PackageUtil.isCodecLibAvailable()){
- boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, GDAL_JP2MrSID_SPI , imageioJ2KImageReaderCodecName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+GDAL_JP2MrSID_SPI +":"+imageioJ2KImageReaderCodecName);
- }
-
- // imageio mrsidJP2 reader
- final String imageioJ2KImageReaderName=J2KImageReaderSpi.class.getName();
-
-
- final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, GDAL_JP2MrSID_SPI , imageioJ2KImageReaderName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+GDAL_JP2MrSID_SPI +":"+imageioJ2KImageReaderName);
-
- } catch (ClassNotFoundException e) {
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.log(Level.WARNING, "Unable to load specific JPEG2000 reader spi",e);
- }
-
- }
+ private static void replaceMRSID() {
+ try{
+ //check if our mrsidJP2 plugin is in the path
+ Class.forName(GDAL_JP2MrSID_SPI );
+
+ // imageio tiff reader
+ final String imageioJ2KImageReaderCodecName=J2KImageReaderCodecLibSpi.class.getName();
+
+ if(PackageUtil.isCodecLibAvailable()){
+ boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, GDAL_JP2MrSID_SPI , imageioJ2KImageReaderCodecName, "JPEG 2000");
+ if(!succeeded)
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Unable to set ordering between jp2 readers spi-"+GDAL_JP2MrSID_SPI +":"+imageioJ2KImageReaderCodecName);
+ }
+
+ // imageio mrsidJP2 reader
+ final String imageioJ2KImageReaderName=J2KImageReaderSpi.class.getName();
+
+
+ final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, GDAL_JP2MrSID_SPI , imageioJ2KImageReaderName, "JPEG 2000");
+ if(!succeeded)
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Unable to set ordering between jp2 readers spi-"+GDAL_JP2MrSID_SPI +":"+imageioJ2KImageReaderName);
+
+ } catch (ClassNotFoundException e) {
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.log(Level.WARNING, "Unable to load specific JPEG2000 reader spi",e);
+ }
+
+ }
- private static boolean hasJP2GDALMRSID() {
- try{
- @SuppressWarnings("unused")
- Class<?> cl = Class.forName(GDAL_JP2MrSID_SPI);
- Class<?> cGdal = Class.forName(GDAL_SPI);
- Object jp2MrSid = cl.newInstance();
- final Method method = cGdal.getDeclaredMethod("isAvailable", (Class[])null);
- if (method != null){
- Boolean isAvailable = (Boolean) method.invoke(jp2MrSid, null);
- return isAvailable.booleanValue();
- }
- } catch (ClassNotFoundException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
- } catch (SecurityException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
- } catch (NoSuchMethodException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
- } catch (IllegalArgumentException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
- } catch (IllegalAccessException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
- } catch (InvocationTargetException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
- } catch (InstantiationException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 MrSID Reader SPI", e);
- }
- return false;
- }
+ private static void replaceTIFF() {
+ try{
+ //check if our tiff plugin is in the path
+ final String customTiffName=it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReaderSpi.class.getName();
+ Class.forName(customTiffName);
+
+ // imageio tiff reader
+ final String imageioTiffName=TIFFImageReaderSpi.class.getName();
+
+ final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, customTiffName, imageioTiffName, "tiff");
+ if(!succeeded)
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Unable to set ordering between tiff readers spi");
+
+ } catch (ClassNotFoundException e) {
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.log(Level.WARNING,"Unable to load specific TIFF reader spi",e);
+ }
+
+ }
- private static void replaceECW() {
- try{
- //check if our ecwJP2 plugin is in the path
- Class.forName(GDAL_JP2ECW_SPI);
+ /**
+ * @see GridFormatFactorySpi#createFormat().
+ */
+ public AbstractGridFormat createFormat() {
+ return new ImageMosaicFormat();
+ }
- // imageio ecwJP2 reader
- final String imageioJ2KImageReaderCodecName=J2KImageReaderCodecLibSpi.class.getName();
-
- if(PackageUtil.isCodecLibAvailable()){
- boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, GDAL_JP2ECW_SPI, imageioJ2KImageReaderCodecName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+GDAL_JP2ECW_SPI+":"+imageioJ2KImageReaderCodecName);
- }
-
- // imageio ecwJP2 reader
- final String imageioJ2KImageReaderName=J2KImageReaderSpi.class.getName();
-
- final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, GDAL_JP2ECW_SPI, imageioJ2KImageReaderName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+GDAL_JP2ECW_SPI+":"+imageioJ2KImageReaderName);
-
- } catch (ClassNotFoundException e) {
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.log(Level.WARNING, "Unable to load specific JPEG2000 reader spi",e);
- }
-
- }
+ /**
+ * Returns the implementation hints. The default implementation returns an
+ * empty map.
+ *
+ * @return An empty map.
+ */
+ public Map<RenderingHints.Key, ?> getImplementationHints() {
+ return Collections.emptyMap();
+ }
- private static boolean hasJP2GDALECW() {
- try{
- @SuppressWarnings("unused")
- Class<?> cl = Class.forName(GDAL_JP2ECW_SPI);
- Class<?> cGdal = Class.forName(GDAL_SPI);
- Object jp2ecwSPI = cl.newInstance();
- final Method method = cGdal.getDeclaredMethod("isAvailable", (Class[])null);
- if (method != null){
- Boolean isAvailable = (Boolean) method.invoke(jp2ecwSPI, null);
- return isAvailable.booleanValue();
- }
- } catch (ClassNotFoundException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
- } catch (SecurityException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
- } catch (NoSuchMethodException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
- } catch (IllegalArgumentException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
- } catch (IllegalAccessException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
- } catch (InvocationTargetException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
- } catch (InstantiationException e) {
- if (LOGGER.isLoggable(Level.FINE))
- LOGGER.log(Level.FINE, "Unable to load GDAL JP2 ECW Reader SPI", e);
- }
- return false;
+ /**
+ * Tells me if this plugin will work on not given the actual installation.
+ *
+ * <p>
+ * Dependecies are mostly from JAI and ImageIO so if they are installed you
+ * should not have many problems.
+ *
+ * @return False if something's missing, true otherwise.
+ */
+ public boolean isAvailable() {
+ boolean available = true;
+
+ // if these classes are here, then the runtine environment has
+ // access to JAI and the JAI ImageI/O toolbox.
+ try {
+ Class.forName("javax.media.jai.JAI");
+ Class.forName("com.sun.media.jai.operator.ImageReadDescriptor");
+ } catch (ClassNotFoundException cnf) {
+ available = false;
}
-
- /**
- * @see GridFormatFactorySpi#createFormat().
- */
- public AbstractGridFormat createFormat() {
- return new ImageMosaicFormat();
- }
-
- /**
- * Returns the implementation hints. The default implementation returns an
- * empty map.
- *
- * @return An empty map.
- */
- public Map<RenderingHints.Key, ?> getImplementationHints() {
- return Collections.emptyMap();
- }
+
+ return available;
+ }
}
Modified: trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicReader.java
===================================================================
--- trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicReader.java 2012-01-23 03:46:30 UTC (rev 38516)
+++ trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicReader.java 2012-01-23 08:22:01 UTC (rev 38517)
@@ -141,8 +141,6 @@
boolean cachingIndex;
String elevationAttribute;
-
- String runtimeAttribute;
boolean imposedBBox;
@@ -523,14 +521,9 @@
// elevation param
final String elevationAttribute = configuration.getElevationAttribute();
if(elevationAttribute != null)
- this.elevationAttribute = elevationAttribute;
+ this.elevationAttribute = elevationAttribute;
- // runtime param
- final String runtimeAttribute = configuration.getRuntimeAttribute();
- if(runtimeAttribute != null)
- this.runtimeAttribute = runtimeAttribute;
-
// caching for the index
cachingIndex = configuration.isCaching();
@@ -791,54 +784,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);
}
Modified: trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/MosaicConfigurationBean.java
===================================================================
--- trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/MosaicConfigurationBean.java 2012-01-23 03:46:30 UTC (rev 38516)
+++ trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/MosaicConfigurationBean.java 2012-01-23 08:22:01 UTC (rev 38517)
@@ -35,6 +35,9 @@
*/
public class MosaicConfigurationBean {
+ /**
+ * Default constructor
+ */
public MosaicConfigurationBean() {
}
@@ -55,7 +58,7 @@
/**
* <code>true</code> it tells us if the mosaic points to absolute paths or to relative ones. (in case of <code>false</code>).
*/
- private boolean absolutePath;
+ private boolean absolutePath= Utils.DEFAULT_PATH_BEHAVIOR;
/**
* <code>true</code> if we need to expand to RGB(A) the single tiles in case they use a different {@link IndexColorModel}.
@@ -72,7 +75,7 @@
private int levelsNum;
/** location attribute name*/
- private String locationAttribute;
+ private String locationAttribute=Utils.DEFAULT_LOCATION_ATTRIBUTE;
/**Suggested SPI for the various tiles. May be null.**/
private String suggestedSPI;
@@ -82,9 +85,6 @@
/** elevation attribute name. <code>null</code> if absent.*/
private String elevationAttribute;
-
- /** runtime attribute name. <code>null</code> if absent.*/
- private String runtimeAttribute;
/**
* mosaic's dummy sample model useful to store dataType and number of bands. All the other fields
@@ -120,13 +120,6 @@
this.elevationAttribute = elevationAttribute;
}
- public String getRuntimeAttribute() {
- return runtimeAttribute;
- }
- public void setRuntimeAttribute(final String runtimeAttribute) {
- this.runtimeAttribute = runtimeAttribute;
- }
-
/** we want to use caching for our index.*/
private boolean caching = Utils.DEFAULT_CONFIGURATION_CACHING;
Modified: trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/PathType.java
===================================================================
--- trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/PathType.java 2012-01-23 03:46:30 UTC (rev 38516)
+++ trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/PathType.java 2012-01-23 08:22:01 UTC (rev 38517)
@@ -68,19 +68,6 @@
} catch (MalformedURLException e) {
return null;
}
-
-// // create a file for the provided location, relative to parent location
-// File rasterFile= new File(parentLocation,location);
-// if(!ImageMosaicUtils.checkFileReadable(rasterFile))
-// {
-// if (LOGGER.isLoggable(Level.INFO))
-// LOGGER.info("Unable to read image for file "+ rasterFile.getAbsolutePath());
-//
-// return null;
-//
-// }
-// return rasterFile;
-
}
},
Modified: trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java
===================================================================
--- trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java 2012-01-23 03:46:30 UTC (rev 38516)
+++ trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java 2012-01-23 08:22:01 UTC (rev 38517)
@@ -71,6 +71,7 @@
* @author Daniele Romagnoli, GeoSolutions
* @author Simone Giannecchini, GeoSolutions
*/
+@SuppressWarnings("rawtypes")
class RasterLayerRequest {
/** Logger. */
@@ -243,7 +244,6 @@
prepare();
}
- @SuppressWarnings({ "unchecked"})
private void setDefaultParameterValues() {
// get the read parameters for this format plus the ones for the basic format and set them to the default
@@ -465,7 +465,6 @@
* @param name
* the name of the parameter
*/
- @SuppressWarnings("unchecked")
private void extractParameter(ParameterValue<?> param, Identifier name) {
// //
Modified: trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerResponse.java
===================================================================
--- trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerResponse.java 2012-01-23 03:46:30 UTC (rev 38516)
+++ trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerResponse.java 2012-01-23 08:22:01 UTC (rev 38517)
@@ -125,6 +125,7 @@
* @author Daniele Romagnoli, GeoSolutions
* @author Stefan Alfons Krueger (alfonx), Wikisquare.de : Support for jar:file:foo.jar/bar.properties URLs
*/
+@SuppressWarnings("rawtypes")
class RasterLayerResponse{
private static final class SimplifiedGridSampleDimension extends GridSampleDimension implements SampleDimension{
@@ -287,7 +288,7 @@
}
@SuppressWarnings("unchecked")
- @Override
+ @Override
public void visit(Feature feature) {
super.visit(feature);
// if we got a NAN let's leave
@@ -324,18 +325,9 @@
*
*/
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>();
@@ -351,6 +343,15 @@
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()];
sources.toArray(imageSources);
@@ -903,7 +904,6 @@
true));
} else {
// convert to range and create a correct range filter
- @SuppressWarnings("rawtypes")
final NumberRange range= (NumberRange)elevation;
elevationF.add(
FeatureUtilities.DEFAULT_FILTER_FACTORY.and(
Modified: trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterManager.java
===================================================================
--- trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterManager.java 2012-01-23 03:46:30 UTC (rev 38516)
+++ trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterManager.java 2012-01-23 08:22:01 UTC (rev 38517)
@@ -190,8 +190,6 @@
String elevationAttribute;
- String runtimeAttribute;
-
ImageLayout defaultImageLayout;
public RasterManager(final ImageMosaicReader reader) throws DataSourceException {
@@ -208,7 +206,6 @@
timeAttribute=parent.timeAttribute;
elevationAttribute=parent.elevationAttribute;
- runtimeAttribute=parent.runtimeAttribute;
coverageIdentifier=reader.getName();
hints = reader.getHints();
this.coverageIdentifier =reader.getName();
Modified: trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ReadType.java
===================================================================
--- trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ReadType.java 2012-01-23 03:46:30 UTC (rev 38516)
+++ trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ReadType.java 2012-01-23 08:22:01 UTC (rev 38517)
@@ -16,7 +16,6 @@
*/
package org.geotools.gce.imagemosaic;
-import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.image.RenderedImage;
import java.io.IOException;
@@ -26,7 +25,6 @@
import javax.imageio.ImageReadParam;
import javax.imageio.ImageReader;
-import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.stream.ImageInputStream;
import javax.media.jai.RenderedOp;
@@ -59,23 +57,30 @@
final ImageReader reader,
final Hints hints,
final boolean closeElements) {
- //
+ //
// Using ImageReader to load the data directly
//
try{
+ //check source region
+ if(CoverageUtilities.checkEmptySourceRegion(readParameters, rasterDimensions)){
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Provided an emptu source region to this read method ");
+ return null;
+ }
+
+ // checks on url
+ if(granuleUrl==null){
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Provided a null URL to this read method ");
+ return null;
+ }
- if(reader==null)
- {
+ if(reader==null){
if (LOGGER.isLoggable(Level.WARNING))
LOGGER.warning("Unable to get reader for URL " + granuleUrl);
return null;
}
-
- //check source regione
- if(CoverageUtilities.checkEmptySourceRegion(readParameters, rasterDimensions))
- return null;
-
if (LOGGER.isLoggable(Level.FINER))
LOGGER.log(Level.FINER, "reading file: " + granuleUrl);
@@ -98,127 +103,11 @@
}
- }
-
- RenderedImage read(
- final ImageReadParam readP,
- final int imageIndex,
- final URL rasterURL,
- final Rectangle readDimension,
- final ImageReaderSpi spi,
- final Hints hints
- )throws IOException{
- //
- // Using ImageReader to load the data directly
- //
- ImageInputStream inStream=null;
- ImageReader reader=null;
- try{
- inStream = Utils.getInputStream(rasterURL);
- if(inStream==null)
- return null;
-
- reader=spi.createReaderInstance();
- if(reader==null)
- {
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to get reader for URL " + rasterURL);
- return null;
- }
-
- inStream.reset();
- reader.setInput(inStream);
-
- //check source regione
- if(CoverageUtilities.checkEmptySourceRegion(readP, readDimension))
- return null;
-
- if (LOGGER.isLoggable(Level.FINER))
- LOGGER.log(Level.FINER, "reading file: " + rasterURL);
-
- // read data
- return reader.read(imageIndex,readP);
- } catch (IOException e) {
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.log(Level.WARNING,"Unable to compute source area for URL "
- + rasterURL,e);
- return null;
- } finally {
- //close everything
- try {
- // reader
- reader.dispose();
- } catch (Throwable t) {
- // swallow the exception, we are just trying to close as much stuff as possible
- }
-
- try {
- // instream
- inStream.close();
- } catch (Throwable t) {
- // swallow the exception, we are just trying to close as much stuff as possible
- }
- }
- }
+ }
},
JAI_IMAGEREAD{
- @Override
- RenderedImage read(
- final ImageReadParam readP,
- final int imageIndex,
- final URL rasterUrl,
- final Rectangle readDimension,
- final ImageReaderSpi spi,
- final Hints hints
- ) throws IOException{
-
- //check source regionepbjMosaic,
- if(CoverageUtilities.checkEmptySourceRegion(readP, readDimension))
- return null;
-
-
-
- // read data
-// final ParameterBlock pbjImageRead = new ParameterBlock();
-// pbjImageRead.add(Utils.getInputStream(rasterUrl));
-// pbjImageRead.add(imageIndex);
-// pbjImageRead.add(false);
-// pbjImageRead.add(false);
-// pbjImageRead.add(false);
-// pbjImageRead.add(null);
-// pbjImageRead.add(null);
-// pbjImageRead.add(readP);
-// pbjImageRead.add(spi.createReaderInstance());
- final RenderedOp raster;
-// if(tileDimension != null){
-// if (hints != null){
- //build a proper layout
-// final ImageLayout layout = new ImageLayout();
-// layout.setTileWidth(tileDimension.width).setTileHeight(tileDimension.height);
-// raster = JAI.create("ImageRead", pbjImageRead,new RenderingHints(JAI.KEY_IMAGE_LAYOUT,layout));
-// raster = JAI.create("ImageRead", pbjImageRead, hints);
- raster = ImageReadDescriptor.create(
- Utils.getInputStream(rasterUrl),
- imageIndex,
- false,
- false,
- false,
- null,
- null,
- readP,
- spi.createReaderInstance(),
- hints);
-// }
-// else
-// raster = JAI.create("ImageRead", pbjImageRead);
- //force rendering (a-la JAI)
- if (raster != null)
- raster.getWidth();
- return raster;
- }
-
@Override
RenderedImage read(
final ImageReadParam readParameters,
@@ -232,12 +121,30 @@
try{
//check source regionepbjMosaic,
- if(CoverageUtilities.checkEmptySourceRegion(readParameters, rasterDimensions))
- return null;
-
+ if(CoverageUtilities.checkEmptySourceRegion(readParameters, rasterDimensions)){
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Provided an emptu source region to this read method ");
+ return null;
+ }
+
+ // checks on url
+ if(granuleUrl==null){
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Provided a null URL to this read method ");
+ return null;
+ }
+
+ if(reader==null){
+ if (LOGGER.isLoggable(Level.WARNING))
+ LOGGER.warning("Unable to get reader for URL " + granuleUrl);
+ return null;
+ }
+
+ // check input stream
+ final ImageInputStream inStream=(ImageInputStream) reader.getInput();
// read data
final RenderedOp raster = ImageReadDescriptor.create(
- Utils.getInputStream(granuleUrl),
+ inStream,
imageIndex,
false,
false,
@@ -251,7 +158,7 @@
if (raster != null)
raster.getWidth();
return raster;
- }catch (IOException e) {
+ }catch (Exception e) {
if(LOGGER.isLoggable(Level.INFO))
LOGGER.log(Level.INFO,e.getLocalizedMessage(),e);
return null;
@@ -271,17 +178,6 @@
final boolean closeElements) {
throw new UnsupportedOperationException(Errors.format(ErrorKeys.UNSUPPORTED_OPERATION_$1,"read"));
}
- @Override
- RenderedImage read(
- final ImageReadParam readP,
- final int imageIndex,
- final URL rasterUrl,
- final Rectangle readDimension,
- final ImageReaderSpi spi,
- final Hints hints
- )throws IOException{
- throw new UnsupportedOperationException(Errors.format(ErrorKeys.UNSUPPORTED_OPERATION_$1,"read"));
- }
};
/** Logger. */
@@ -300,34 +196,23 @@
return JAI_IMAGEREAD;
}
- /**
- * Load the raster data from the underlying source with the specified read
- * type.
- *
- * @param readParameters
- * @param imageIndex
- * @param rasterUr...
[truncated message content] |