|
From: <svn...@os...> - 2012-01-22 17:32:42
|
Author: simonegiannecchini
Date: 2012-01-22 09:32:30 -0800 (Sun, 22 Jan 2012)
New Revision: 38511
Modified:
branches/2.7.x/modules/plugin/imagemosaic/pom.xml
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/GranuleDescriptor.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormat.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormatFactory.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/MosaicConfigurationBean.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/PathType.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.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/ReadType.java
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/catalog/AbstractGranuleCatalog.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalog/GTDataStoreGranuleCatalog.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalog/GranuleCatalogFactory.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalog/GranuleCatalogVisitor.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalog/STRTreeGranuleCatalog.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalogbuilder/CatalogBuilder.java
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalogbuilder/CatalogBuilderConfiguration.java
branches/2.7.x/modules/plugin/imagemosaic/src/test/java/org/geotools/gce/imagemosaic/CatalogBuilderTest.java
Log:
GEOT-2867
Modified: branches/2.7.x/modules/plugin/imagemosaic/pom.xml
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/pom.xml 2012-01-21 14:19:53 UTC (rev 38510)
+++ branches/2.7.x/modules/plugin/imagemosaic/pom.xml 2012-01-22 17:32:30 UTC (rev 38511)
@@ -139,22 +139,16 @@
<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>
+ <artifactId>gt-image</artifactId>
<version>${project.version}</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.geotools</groupId>
- <artifactId>gt-jp2k</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.geotools</groupId>
<artifactId>gt-cql</artifactId>
<version>${project.version}</version>
<scope>test</scope>
Modified: branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/GranuleDescriptor.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/GranuleDescriptor.java 2012-01-21 14:19:53 UTC (rev 38510)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/GranuleDescriptor.java 2012-01-22 17:32:30 UTC (rev 38511)
@@ -17,7 +17,6 @@
package org.geotools.gce.imagemosaic;
import it.geosolutions.imageio.utilities.ImageIOUtilities;
-import it.geosolutions.imageio.utilities.Utilities;
import jaitools.imageutils.ROIGeometry;
import jaitools.media.jai.vectorbinarize.VectorBinarizeDescriptor;
import jaitools.media.jai.vectorbinarize.VectorBinarizeRIF;
@@ -38,8 +37,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;
@@ -59,6 +60,7 @@
import org.geotools.geometry.jts.JTS;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.image.ImageWorker;
+import org.geotools.image.io.ImageIOExt;
import org.geotools.image.jai.Registry;
import org.geotools.referencing.CRS;
import org.geotools.referencing.operation.builder.GridToEnvelopeMapper;
@@ -264,9 +266,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,
@@ -293,9 +298,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){
@@ -595,7 +620,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;
@@ -678,7 +704,7 @@
if (pluginName != null && pluginName.equals(ImageUtilities.DIRECT_KAKADU_PLUGIN)){
final int ssx = readParameters.getSourceXSubsampling();
final int ssy = readParameters.getSourceYSubsampling();
- newSubSamplingFactor = Utilities.getSubSamplingFactor2(ssx, ssy);
+ newSubSamplingFactor = ImageIOUtilities.getSubSamplingFactor2(ssx, ssy);
if (newSubSamplingFactor != 0) {
if (newSubSamplingFactor > maxDecimationFactor && maxDecimationFactor != -1){
newSubSamplingFactor = maxDecimationFactor;
@@ -887,7 +913,7 @@
} finally {
try {
- if (inStream != null) {
+ if (request.getReadType() != ReadType.JAI_IMAGEREAD && inStream != null) {
inStream.close();
}
} finally {
@@ -951,7 +977,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: branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormat.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormat.java 2012-01-21 14:19:53 UTC (rev 38510)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormat.java 2012-01-22 17:32:30 UTC (rev 38511)
@@ -101,6 +101,7 @@
*
* @source $URL$
*/
+@SuppressWarnings("rawtypes")
public final class ImageMosaicFormat extends AbstractGridFormat implements Format {
final static double DEFAULT_ARTIFACTS_FILTER_PTILE_THRESHOLD = 0.1;
@@ -264,6 +265,7 @@
return true;
}
+ @SuppressWarnings("unchecked")
private boolean checkForUrl( Object source, Hints hints){
try {
@@ -277,12 +279,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;
@@ -357,11 +358,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: branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormatFactory.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormatFactory.java 2012-01-21 14:19:53 UTC (rev 38510)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicFormatFactory.java 2012-01-22 17:32:30 UTC (rev 38511)
@@ -16,9 +16,6 @@
*/
package org.geotools.gce.imagemosaic;
-import it.geosolutions.imageio.plugins.jp2ecw.JP2GDALEcwImageReaderSpi;
-import it.geosolutions.imageio.plugins.jp2kakadu.JP2GDALKakaduImageReaderSpi;
-import it.geosolutions.imageio.plugins.jp2mrsid.JP2GDALMrSidImageReaderSpi;
import it.geosolutions.imageio.utilities.ImageIOUtilities;
import java.awt.RenderingHints;
@@ -33,9 +30,6 @@
import org.geotools.coverage.grid.io.AbstractGridFormat;
import org.geotools.coverage.grid.io.GridFormatFactorySpi;
-import org.geotools.coverageio.gdal.jp2ecw.JP2ECWFormatFactory;
-import org.geotools.coverageio.gdal.jp2kak.JP2KFormatFactory;
-import org.geotools.coverageio.gdal.jp2mrsid.JP2MrSIDFormatFactory;
import com.sun.media.imageioimpl.common.PackageUtil;
import com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReaderCodecLibSpi;
@@ -52,260 +46,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";
- static {
-
- replaceTIFF();
-
- if(JP2KAK()){
- replaceJP2KAK();
- }
-
- else{
- if(JP2ECW()){
- replaceECW();
- }
- if(JP2MRSID()){
- replaceMRSID();
- }
- if(JP2GDALKAK()){
- replaceGDALKAK();
- }
- }
-
- }
- /**
- * 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 JP2KAK() {
- 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 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 replaceJP2KAK() {
- try{
- Class.forName(KAKADU_SPI);
+ 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;
+ }
- // 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 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);
+ }
+
+ }
- 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);
+ 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);
+ }
+
+ }
- // 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 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 boolean JP2GDALKAK() {
- return new JP2KFormatFactory().isAvailable();
- }
+ 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 void replaceGDALKAK() {
- try{
- //check if our kakJP2 plugin is in the path
- final String kakJP2=JP2GDALKakaduImageReaderSpi.class.getName();
- Class.forName(kakJP2);
+ 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);
+ }
+
+ }
- // imageio kakJP2 reader
- final String imageioJ2KImageReaderCodecName=J2KImageReaderCodecLibSpi.class.getName();
-
- if(PackageUtil.isCodecLibAvailable()){
- boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, kakJP2, imageioJ2KImageReaderCodecName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+kakJP2+":"+imageioJ2KImageReaderCodecName);
- }
-
- // imageio kakJP2 reader
- final String imageioJ2KImageReaderName=J2KImageReaderSpi.class.getName();
-
-
- final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, kakJP2, imageioJ2KImageReaderName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+kakJP2+":"+imageioJ2KImageReaderName);
-
- } catch (ClassNotFoundException e) {
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.log(Level.WARNING, "Unable to load specific JPEG2000 reader spi",e);
- }
-
- }
+ /**
+ * @see GridFormatFactorySpi#createFormat().
+ */
+ public AbstractGridFormat createFormat() {
+ return new ImageMosaicFormat();
+ }
- private static void replaceMRSID() {
- try{
- //check if our mrsidJP2 plugin is in the path
- final String mrsidJP2=JP2GDALMrSidImageReaderSpi.class.getName();
- Class.forName(mrsidJP2);
+ /**
+ * Returns the implementation hints. The default implementation returns an
+ * empty map.
+ *
+ * @return An empty map.
+ */
+ public Map<RenderingHints.Key, ?> getImplementationHints() {
+ return Collections.emptyMap();
+ }
- // imageio tiff reader
- final String imageioJ2KImageReaderCodecName=J2KImageReaderCodecLibSpi.class.getName();
-
- if(PackageUtil.isCodecLibAvailable()){
- boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, mrsidJP2, imageioJ2KImageReaderCodecName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+mrsidJP2+":"+imageioJ2KImageReaderCodecName);
- }
-
- // imageio mrsidJP2 reader
- final String imageioJ2KImageReaderName=J2KImageReaderSpi.class.getName();
-
-
- final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, mrsidJP2, imageioJ2KImageReaderName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+mrsidJP2+":"+imageioJ2KImageReaderName);
-
- } catch (ClassNotFoundException e) {
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.log(Level.WARNING, "Unable to load specific JPEG2000 reader spi",e);
- }
-
- }
-
- private static boolean JP2MRSID() {
- return new JP2MrSIDFormatFactory().isAvailable();
- }
-
- private static void replaceECW() {
- try{
- //check if our ecwJP2 plugin is in the path
- final String ecwJP2=JP2GDALEcwImageReaderSpi.class.getName();
- Class.forName(ecwJP2);
-
- // imageio ecwJP2 reader
- final String imageioJ2KImageReaderCodecName=J2KImageReaderCodecLibSpi.class.getName();
-
- if(PackageUtil.isCodecLibAvailable()){
- boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, ecwJP2, imageioJ2KImageReaderCodecName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+ecwJP2+":"+imageioJ2KImageReaderCodecName);
- }
-
- // imageio ecwJP2 reader
- final String imageioJ2KImageReaderName=J2KImageReaderSpi.class.getName();
-
- final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, ecwJP2, imageioJ2KImageReaderName, "JPEG 2000");
- if(!succeeded)
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.warning("Unable to set ordering between jp2 readers spi-"+ecwJP2+":"+imageioJ2KImageReaderName);
-
- } catch (ClassNotFoundException e) {
- if (LOGGER.isLoggable(Level.WARNING))
- LOGGER.log(Level.WARNING, "Unable to load specific JPEG2000 reader spi",e);
- }
-
- }
-
- private static boolean JP2ECW() {
- return new JP2ECWFormatFactory().isAvailable();
- }
-
- /**
- * @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();
- }
+ /**
+ * 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;
+ }
+
+ return available;
+ }
}
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-21 14:19:53 UTC (rev 38510)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ImageMosaicReader.java 2012-01-22 17:32:30 UTC (rev 38511)
@@ -28,7 +28,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -141,8 +140,6 @@
boolean cachingIndex;
String elevationAttribute;
-
- String runtimeAttribute;
boolean imposedBBox;
@@ -523,14 +520,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();
Modified: branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/MosaicConfigurationBean.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/MosaicConfigurationBean.java 2012-01-21 14:19:53 UTC (rev 38510)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/MosaicConfigurationBean.java 2012-01-22 17:32:30 UTC (rev 38511)
@@ -34,6 +34,9 @@
*/
public class MosaicConfigurationBean {
+ /**
+ * Default constructor
+ */
public MosaicConfigurationBean() {
}
@@ -54,7 +57,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}.
@@ -71,7 +74,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;
@@ -81,9 +84,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
@@ -119,13 +119,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: branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/PathType.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/PathType.java 2012-01-21 14:19:53 UTC (rev 38510)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/PathType.java 2012-01-22 17:32:30 UTC (rev 38511)
@@ -32,7 +32,6 @@
* @author Simone Giannecchini, GeoSolutions SAS
* @author Stefan Alfons Krueger (alfonx), Wikisquare.de : Support for jar:file:foo.jar/bar.properties URLs
*
- *
* @source $URL: http://svn.osgeo.org/geotools/branches/2.7.x/build/maven/javadoc/../../../modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/PathType.java $
*/
public enum PathType {
@@ -67,19 +66,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: branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java 2012-01-21 14:19:53 UTC (rev 38510)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java 2012-01-22 17:32:30 UTC (rev 38511)
@@ -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: 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-21 14:19:53 UTC (rev 38510)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerResponse.java 2012-01-22 17:32:30 UTC (rev 38511)
@@ -126,6 +126,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{
@@ -289,7 +290,7 @@
}
@SuppressWarnings("unchecked")
- @Override
+ @Override
public void visit(Feature feature) {
super.visit(feature);
// if we got a NAN let's leave
@@ -905,7 +906,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: 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-21 14:19:53 UTC (rev 38510)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterManager.java 2012-01-22 17:32:30 UTC (rev 38511)
@@ -189,8 +189,6 @@
String elevationAttribute;
- String runtimeAttribute;
-
ImageLayout defaultImageLayout;
public RasterManager(final ImageMosaicReader reader) throws DataSourceException {
@@ -207,7 +205,6 @@
timeAttribute=parent.timeAttribute;
elevationAttribute=parent.elevationAttribute;
- runtimeAttribute=parent.runtimeAttribute;
coverageIdentifier=reader.getName();
hints = reader.getHints();
this.coverageIdentifier =reader.getName();
Modified: branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ReadType.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ReadType.java 2012-01-21 14:19:53 UTC (rev 38510)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/ReadType.java 2012-01-22 17:32:30 UTC (rev 38511)
@@ -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 rasterUrl
- * @param readDimension
- * @param tileDimension
- * a {@link Dimension} object that can be used to suggest specific
- * tile dimension for the raster to load. It can be <code>null</code>.
- *
- * @return a {@link RenderedImage} instance that matches the provided
- * request parameters as close as possible.
- *
- * @throws IOException
- * in case something bad occurs during the decoding process.
- */
+ /**
+ * Load the raster data from the underlying source with the specified read
+ * type.
+ *
+ * @param readParameters
+ * @param imageIndex
+ * @param rasterUrl
+ * @param readDimension
+ * @param hints {@link Hints} to control the read process
+ *
+ * @return a {@link RenderedImage} instance that matches the provided
+ * request parameters as close as possible.
+ *
+ * @throws IOException
+ * in case something bad occurs during the decoding process.
+ */
abstract RenderedImage read(
- final ImageReadParam readParameters,
- final int imageIndex,
- final URL rasterUrl,
- final Rectangle readDimension,
- final ImageReaderSpi spi,
- final Hints hints
- ) throws IOException;
-
- abstract RenderedImage read(
final ImageReadParam readParameters,
final int imageIndex,
final URL granuleUrl,
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-21 14:19:53 UTC (rev 38510)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/Utils.java 2012-01-22 17:32:30 UTC (rev 38511)
@@ -16,8 +16,6 @@
*/
package org.geotools.gce.imagemosaic;
-import it.geosolutions.imageio.stream.input.spi.URLImageInputStreamSpi;
-
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
@@ -57,7 +55,6 @@
import javax.imageio.ImageIO;
import javax.imageio.ImageReadParam;
import javax.imageio.ImageReader;
-import javax.imageio.spi.ImageInputStreamSpi;
import javax.imageio.stream.ImageInputStream;
import javax.media.jai.Histogram;
import javax.media.jai.Interpolation;
@@ -342,16 +339,11 @@
public static final boolean DEFAULT_PATH_BEHAVIOR = false;
/**
- * Default path behavior with respect to index caching.
+ * Default behavior with respect to index caching.
*/
private static final boolean DEFAULT_CACHING_BEHAVIOR = false;
-
- /**
- * Cached instance of {@link URLImageInputStreamSpi} for creating
- * {@link ImageInputStream} instances.
- */
- private static ImageInputStreamSpi CACHED_STREAM_SPI = new URLImageInputStreamSpi();
+
/**
* Creates a mosaic for the provided input parameters.
*
@@ -827,39 +819,6 @@
}
/**
- * Retrieves an {@link ImageInputStream} for the provided input {@link File}
- * .
- *
- * @param file
- * @return
- * @throws IOException
- */
- static ImageInputStream getInputStream(final File file) throws IOException {
- Utilities.ensureNonNull("file", file);
- final ImageInputStream inStream = ImageIO.createImageInputStream(file);
- if (inStream == null)
- return null;
- return inStream;
- }
-
- /**
- * Retrieves an {@link ImageInputStream} for the provided input {@link URL}.
- *
- * @param url
- * @return
- * @throws IOException
- */
- static ImageInputStream getInputStream(final URL url) throws IOException {
- Utilities.ensureNonNull("url", url);
- final ImageInputStream inStream = CACHED_STREAM_SPI
- .createInputStreamInstance(url, ImageIO.getUseCache(), ImageIO
- .getCacheDirectory());
- if (inStream == null)
- return null;
- return inStream;
- }
-
- /**
* Default priority for the underlying {@link Thread}.
*/
public static final int DEFAULT_PRIORITY = Thread.NORM_PRIORITY;
@@ -881,35 +840,67 @@
*/
public static boolean checkFileReadable(final File file) {
if (LOGGER.isLoggable(Level.FINE)) {
- final StringBuilder builder = new StringBuilder();
- builder.append("Checking file:").append(
- FilenameUtils.getFullPath(file.getAbsolutePath())).append(
- "\n");
- builder.append("canRead:").append(file.canRead()).append("\n");
- builder.append("isHidden:").append(file.isHidden()).append("\n");
- builder.append("isFile").append(file.isFile()).append("\n");
- builder.append("canWrite").append(file.canWrite()).append("\n");
- LOGGER.fine(builder.toString());
+ final String message = getFileInfo(file);
+ LOGGER.fine(message);
}
if (!file.exists() || !file.canRead() || !file.isFile())
return false;
return true;
}
+ /**
+ * Creates a human readable message that describe the provided {@link File} object in terms of its properties.
+ *
+ * <p>
+ * Useful for creating meaningful log messages.
+ *
+ * @param file the {@link File} object to create a descriptive message for
+ * @return a {@link String} containing a descriptive message about the provided {@link File}.
+ *
+ */
+ public static String getFileInfo(final File file) {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("Checking file:").append(
+ FilenameUtils.getFullPath(file.getAbsolutePath())).append(
+ "\n");
+ builder.append("isHidden:").append(file.isHidden()).append("\n");
+ builder.append("exists:").append(file.exists()).append("\n");
+ builder.append("isFile").append(file.isFile()).append("\n");
+ builder.append("canRead:").append(file.canRead()).append("\n");
+ builder.append("canWrite").append(file.canWrite()).append("\n");
+ builder.append("canExecute:").append(file.canExecute()).append("\n");
+ builder.append("isAbsolute:").append(file.isAbsolute()).append("\n");
+ builder.append("lastModified:").append(file.lastModified()).append("\n");
+ builder.append("length:").append(file.length());
+ final String message=builder.toString();
+ return message;
+ }
+
/**
* @param testingDirecto...
[truncated message content] |