svn - r33526 - in trunk/modules/unsupported/jp2kakadu/src: main/java/org/geotools/coverageio/jp2kak main/resources test/java/org/geotools/coverageio/jp2kak

1 message Options
Embed this post
Permalink
svn_geotools

svn - r33526 - in trunk/modules/unsupported/jp2kakadu/src: main/java/org/geotools/coverageio/jp2kak main/resources test/java/org/geotools/coverageio/jp2kak

Reply Threaded More More options
Print post
Permalink
Author: danieleromagnoli
Date: 2009-07-08 04:06:04 -0400 (Wed, 08 Jul 2009)
New Revision: 33526

Removed:
   trunk/modules/unsupported/jp2kakadu/src/main/resources/org/
   trunk/modules/unsupported/jp2kakadu/src/test/java/org/geotools/coverageio/jp2kak/AbstractJP2KTestCase.java
Modified:
   trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/JP2KFormat.java
   trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/JP2KFormatFactory.java
   trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/JP2KReader.java
   trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/RasterLayerRequest.java
   trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/RasterLayerResponse.java
   trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/RasterManager.java
   trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/ReadType.java
   trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/Utils.java
   trunk/modules/unsupported/jp2kakadu/src/test/java/org/geotools/coverageio/jp2kak/JP2KTest.java
   trunk/modules/unsupported/jp2kakadu/src/test/java/org/geotools/coverageio/jp2kak/ServiceTest.java
Log:
Aligning jp2kak module to 2.5.x

Modified: trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/JP2KFormat.java
===================================================================
--- trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/JP2KFormat.java 2009-07-08 07:28:27 UTC (rev 33525)
+++ trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/JP2KFormat.java 2009-07-08 08:06:04 UTC (rev 33526)
@@ -92,7 +92,7 @@
      * representing the suggested tileHeight.
      */
     public static final DefaultParameterDescriptor<String> SUGGESTED_TILE_SIZE = new DefaultParameterDescriptor<String>(
-            SUGGESTED_TILESIZE, String.class, null, "");
+            SUGGESTED_TILESIZE, String.class, null, "512,512");
 
     public static final String TILE_SIZE_SEPARATOR = ",";
 
@@ -100,13 +100,9 @@
     public static final ParameterDescriptor<Color> INPUT_TRANSPARENT_COLOR = new DefaultParameterDescriptor<Color>(
             "InputTransparentColor", Color.class, null, null);
 
-    /** Control the transparency of the output coverage. */
-//    public static final ParameterDescriptor<Color> OUTPUT_TRANSPARENT_COLOR = new DefaultParameterDescriptor<Color>(
-//            "OutputTransparentColor", Color.class, null, null);
-
-    /** Control the threading behavior for this plugin. This parameter contains the number of thread that we should use to load the granules. Default value is 0 which means not additional thread, max value is 8.*/
-    public static final ParameterDescriptor<Boolean> ALLOW_MULTITHREADING = new DefaultParameterDescriptor<Boolean>(
-            "AllowMultithreading", Boolean.class, new Boolean[]{Boolean.TRUE,Boolean.FALSE}, Boolean.FALSE);
+//    /** Control the threading behavior for this plugin. This parameter contains the number of thread that we should use to load the granules. Default value is 0 which means not additional thread, max value is 8.*/
+//    public static final ParameterDescriptor<Boolean> ALLOW_MULTITHREADING = new DefaultParameterDescriptor<Boolean>(
+//            "AllowMultithreading", Boolean.class, new Boolean[]{Boolean.TRUE,Boolean.FALSE}, Boolean.FALSE);
     
     /** Control the background values for the output coverage */
     public static final ParameterDescriptor<double[]> BACKGROUND_VALUES = new DefaultParameterDescriptor<double[]>(
@@ -147,7 +143,8 @@
                 USE_MULTITHREADING,
                 BACKGROUND_VALUES,
                 SUGGESTED_TILE_SIZE,
-                ALLOW_MULTITHREADING}));
+//                ALLOW_MULTITHREADING
+                }));
     }
 
     /**

Modified: trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/JP2KFormatFactory.java
===================================================================
--- trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/JP2KFormatFactory.java 2009-07-08 07:28:27 UTC (rev 33525)
+++ trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/JP2KFormatFactory.java 2009-07-08 08:06:04 UTC (rev 33526)
@@ -16,6 +16,8 @@
  */
 package org.geotools.coverageio.jp2kak;
 
+import it.geosolutions.imageio.imageioimpl.imagereadmt.ImageReadDescriptorMT;
+import it.geosolutions.imageio.utilities.ImageIOUtilities;
 import it.geosolutions.util.KakaduUtilities;
 
 import java.awt.RenderingHints;
@@ -24,6 +26,10 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.imageio.spi.ImageReaderSpi;
+import javax.media.jai.JAI;
+import javax.media.jai.ParameterBlockJAI;
+
 import org.geotools.coverage.grid.io.GridFormatFactorySpi;
 import org.opengis.coverage.grid.Format;
 
@@ -41,7 +47,35 @@
     /** Logger. */
     private final static Logger LOGGER = org.geotools.util.logging.Logging.getLogger(
             "org.geotools.coverageio.jp2kak");
+    
+    static{
+     try{
+     new ParameterBlockJAI("ImageReadMT");
+     } catch (final Exception e){
+     try{
+     ImageReadDescriptorMT.register(JAI.getDefaultInstance());
+     } catch (final Exception e1){
+     //TODO: Log a message
+     }
+     }
+    
+     try{
+ //check if our jp2k plugin is in the path
+ final String kakaduJp2Name=it.geosolutions.imageio.plugins.jp2k.JP2KKakaduImageReaderSpi.class.getName();
+ Class.forName(kakaduJp2Name);
 
+ // imageio jp2k reader
+ final String standardJp2Name=com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReaderSpi.class.getName();
+ final String jp2CodecLibName=com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReaderCodecLibSpi.class.getName();
+
+ ImageIOUtilities.replaceProvider(ImageReaderSpi.class, kakaduJp2Name, standardJp2Name, "JPEG2000");
+ ImageIOUtilities.replaceProvider(ImageReaderSpi.class, kakaduJp2Name, jp2CodecLibName, "JPEG2000");
+        
+ } catch (ClassNotFoundException e) {
+ LOGGER.log(Level.SEVERE,"Unable to load specific JP2K reader spi",e);
+ }
+    }
+
     /**
      * Tells me if the coverage plugin to access JP2K is available or not.
      *
@@ -81,7 +115,7 @@
      *
      * @return A {@link JP2KFormat}.;
      */
-    public Format createFormat() {
+    public JP2KFormat createFormat() {
         return new JP2KFormat();
     }
 

Modified: trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/JP2KReader.java
===================================================================
--- trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/JP2KReader.java 2009-07-08 07:28:27 UTC (rev 33525)
+++ trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/JP2KReader.java 2009-07-08 08:06:04 UTC (rev 33526)
@@ -20,7 +20,6 @@
 import it.geosolutions.imageio.plugins.jp2k.JP2KStreamMetadata;
 import it.geosolutions.imageio.plugins.jp2k.box.UUIDBox;
 import it.geosolutions.imageio.plugins.jp2k.box.UUIDBoxMetadataNode;
-import it.geosolutions.imageio.utilities.ImageIOUtilities;
 
 import java.awt.Rectangle;
 import java.awt.geom.AffineTransform;
@@ -33,10 +32,6 @@
 import java.net.URL;
 import java.net.URLDecoder;
 import java.util.Collection;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -44,7 +39,6 @@
 import javax.imageio.ImageReader;
 import javax.imageio.metadata.IIOMetadata;
 import javax.imageio.metadata.IIOMetadataNode;
-import javax.imageio.spi.ImageReaderSpi;
 
 import org.geotools.coverage.CoverageFactoryFinder;
 import org.geotools.coverage.grid.GeneralGridRange;
@@ -59,8 +53,8 @@
 import org.geotools.data.WorldFileReader;
 import org.geotools.factory.Hints;
 import org.geotools.geometry.GeneralEnvelope;
+import org.geotools.metadata.iso.spatial.PixelTranslation;
 import org.geotools.referencing.CRS;
-import org.geotools.referencing.operation.LinearTransform;
 import org.geotools.referencing.operation.transform.ProjectiveTransform;
 import org.geotools.resources.coverage.CoverageUtilities;
 import org.opengis.coverage.grid.Format;
@@ -70,6 +64,7 @@
 import org.opengis.parameter.GeneralParameterValue;
 import org.opengis.referencing.FactoryException;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.datum.PixelInCell;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.TransformException;
 
@@ -91,8 +86,6 @@
  /** Logger. */
  private final static Logger LOGGER = org.geotools.util.logging.Logging.getLogger(JP2KReader.class);
 
- final static ExecutorService multiThreadedLoader= new ThreadPoolExecutor(4,8,30,TimeUnit.SECONDS,new LinkedBlockingQueue<Runnable>());
-
  /** The system-dependent default name-separator character. */
     private final static char SEPARATOR = File.separatorChar;
 
@@ -100,25 +93,6 @@
             0xbd, 0x08, 0x3d, 0x4b, 0x43, 0xa5, 0xae, 0x8c, 0xd7, 0xd5, 0xa6,
             0xce, 0x03 };
 
-    static{
- try{
- //check if our tiff plugin is in the path
- final String kakaduJp2Name=it.geosolutions.imageio.plugins.jp2k.JP2KKakaduImageReaderSpi.class.getName();
- Class.forName(kakaduJp2Name);
-
- // imageio tiff reader
- final String standardJp2Name=com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReaderSpi.class.getName();
-
- final boolean succeeded=ImageIOUtilities.replaceProvider(ImageReaderSpi.class, kakaduJp2Name, standardJp2Name, "JPEG2000");
-         if(!succeeded)
-         LOGGER.warning("Unable to set ordering between tiff readers spi");
-        
- } catch (ClassNotFoundException e) {
- LOGGER.log(Level.SEVERE,"Unable to load specific TIFF reader spi",e);
- }
-        
- }
-    
     /**
      * Creates a new instance of a {@link JP2KReader}. I assume nothing about
      * file extension.
@@ -543,17 +517,13 @@
             // CELL_CENTER condition
             //
             // //
-            final AffineTransform tempTransform = new AffineTransform(
-                    (AffineTransform) raster2Model);
-            tempTransform.preConcatenate(Utils.CENTER_TO_CORNER);
-
+            
+            MathTransform tempTransform =PixelTranslation.translate(raster2Model, PixelInCell.CELL_CENTER, PixelInCell.CELL_CORNER);
             try {
-                final LinearTransform gridToWorldTransform = ProjectiveTransform
-                        .create(tempTransform);
                 final Envelope gridRange = new GeneralEnvelope(
                         originalGridRange.toRectangle());
                 final GeneralEnvelope coverageEnvelope = CRS.transform(
-                        gridToWorldTransform, gridRange);
+                 tempTransform, gridRange);
                 originalEnvelope = coverageEnvelope;
             } catch (TransformException e) {
                 if (LOGGER.isLoggable(Level.WARNING)) {

Modified: trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/RasterLayerRequest.java
===================================================================
--- trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/RasterLayerRequest.java 2009-07-08 07:28:27 UTC (rev 33525)
+++ trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/RasterLayerRequest.java 2009-07-08 08:06:04 UTC (rev 33526)
@@ -91,7 +91,11 @@
     /** Requesting a multithreading read */
     private boolean useMultithreading;
 
-    /**
+    public boolean isUseMultithreading() {
+ return useMultithreading;
+ }
+
+ /**
      * Set to {@code true} if this request will produce an empty result, and the
      * coverageResponse will produce a {@code null} coverage.
      */
@@ -130,11 +134,11 @@
 
  private Dimension tileDimensions;
 
- private boolean multithreadingAllowed;
+// private boolean multithreadingAllowed;
 
- public boolean isMultithreadingAllowed() {
- return multithreadingAllowed;
- }
+// public boolean isMultithreadingAllowed() {
+// return multithreadingAllowed;
+// }
 
  /**
      * Build a new {@code CoverageRequest} given a set of input parameters.
@@ -230,8 +234,19 @@
             readType = ((Boolean)value)? ReadType.JAI_IMAGEREAD: ReadType.DIRECT_READ;
             continue;
         }
+        
+        // //
+        //
+        // Use Multithreading parameter
+        //
+        // //
+        if (name.equals(JP2KFormat.USE_MULTITHREADING.getName())) {
+         if(value==null)
+         continue;
+            useMultithreading = ((Boolean) value).booleanValue();
+            continue;
+        }
 
-
         // //
         //
         // Overview Policy parameter
@@ -286,14 +301,14 @@
 // maximumNumberOfGranules=(Integer)value;
 // continue;
 // }
-
-
- if (name.equals(JP2KFormat.ALLOW_MULTITHREADING.getName())) {
-         if(value==null)
-         continue;
- multithreadingAllowed = ((Boolean) value).booleanValue();
- continue;
- }
+//
+//
+// if (name.equals(JP2KFormat.ALLOW_MULTITHREADING.getName())) {
+//         if(value==null)
+//         continue;
+// multithreadingAllowed = ((Boolean) value).booleanValue();
+// continue;
+// }
       
         // //
         //
@@ -454,15 +469,15 @@
 // maximumNumberOfGranules=param.intValue();
 // return;
 // }
-
-
- if (name.equals(JP2KFormat.ALLOW_MULTITHREADING.getName())) {
-         final Object value = param.getValue();
-         if(value==null)
-         return;
- multithreadingAllowed = ((Boolean) param.getValue()).booleanValue();
- return;
- }
+//
+//
+// if (name.equals(JP2KFormat.ALLOW_MULTITHREADING.getName())) {
+//         final Object value = param.getValue();
+//         if(value==null)
+//         return;
+// multithreadingAllowed = ((Boolean) param.getValue()).booleanValue();
+// return;
+// }
       
         // //
         //
@@ -601,7 +616,7 @@
         if (readType != ReadType.UNSPECIFIED){
          if (readType == ReadType.JAI_IMAGEREAD && useMultithreading){
          readType = ReadType.JAI_IMAGEREAD_MT;
-         multithreadingAllowed = false;
+//         multithreadingAllowed = false;
          }
          return ;
         }

Modified: trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/RasterLayerResponse.java
===================================================================
--- trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/RasterLayerResponse.java 2009-07-08 07:28:27 UTC (rev 33525)
+++ trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/RasterLayerResponse.java 2009-07-08 08:06:04 UTC (rev 33526)
@@ -21,13 +21,15 @@
 import java.awt.Rectangle;
 import java.awt.image.ColorModel;
 import java.awt.image.IndexColorModel;
+import java.awt.image.MultiPixelPackedSampleModel;
 import java.awt.image.RenderedImage;
 import java.awt.image.SampleModel;
 import java.io.File;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Constructor;
-import java.net.URISyntaxException;
 import java.net.URL;
+import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Callable;
@@ -99,6 +101,7 @@
  final Granule granule,
  final Dimension tilesDimension) {
  super();
+
  this.readParameters = Utils.cloneImageReadParam(readParameters);
  this.imageIndex = imageIndex;
  this.cropBBox = cropBBox;
@@ -190,10 +193,10 @@
  //
  //create a granule loader
  final GranuleLoader loader = new GranuleLoader(baseReadParameters, imageChoice, bbox, finalWorldToGridCorner,granule,request.getTileDimensions());
- if(!multithreadingAllowed)
+// if(!multithreadingAllowed)
  tasks.add(new FutureTask<RenderedImage>(loader));
- else
- tasks.add(JP2KReader.multiThreadedLoader.submit(loader));
+// else
+// tasks.add(JP2KReader.multiThreadedLoader.submit(loader));
 
  granulesNumber++;
  }
@@ -211,12 +214,12 @@
  for (Future<RenderedImage> future :tasks) {
  final RenderedImage loadedImage;
  try {
- if(!multithreadingAllowed)
- {
+// if(!multithreadingAllowed)
+// {
  //run the loading in this thread
- final FutureTask<RenderedImage> task=(FutureTask<RenderedImage>) future;
- task.run();
- }
+ final FutureTask<RenderedImage> task=(FutureTask<RenderedImage>) future;
+ task.run();
+// }
  loadedImage=future.get();
  if(loadedImage==null)
  {
@@ -341,8 +344,10 @@
 
  private ImageReadParam baseReadParameters= new ImageReadParam();
 
- private boolean multithreadingAllowed=false;
+ private boolean useMultithreading = false;
 
+// private boolean multithreadingAllowed=false;
+
  private boolean alphaIn=false;
 
  private String location;
@@ -365,20 +370,24 @@
  final RasterManager rasterManager) {
  this.request = request;
  inputURL = rasterManager.getInputURL();
- File tempFile;
+ File tempFile = null;
  try {
- tempFile = new File(this.inputURL.toURI());
- } catch (URISyntaxException e) {
+ if (inputURL.getProtocol().equalsIgnoreCase("file"))
+                    tempFile = new File(URLDecoder.decode(inputURL.getFile(),
+                            "UTF-8"));
+ else
+ throw new IllegalArgumentException("unsupported input:" + inputURL.toString());
+ }
+ catch (UnsupportedEncodingException e) {
  throw new IllegalArgumentException(e);
- }// TODO improve me
+ }
+
  location = tempFile.getAbsolutePath();
  coverageEnvelope = rasterManager.getCoverageEnvelope();
  this.coverageFactory = rasterManager.getCoverageFactory();
  this.rasterManager = rasterManager;
  transparentColor=request.getInputTransparentColor();
-// finalTransparentColor=request.getOutputTransparentColor();
- // are we doing multithreading?
- multithreadingAllowed= request.isMultithreadingAllowed();
+ useMultithreading = request.isUseMultithreading();
 
  }
 
@@ -431,10 +440,10 @@
  // assemble granules
  final RenderedImage image = assembleGranules();
 
-// RenderedImage finalRaster = postProcessRaster(image);
+ RenderedImage finalRaster = postProcessRaster(image);
 
  //create the coverage
- gridCoverage=prepareCoverage(image);
+ gridCoverage=prepareCoverage(finalRaster);
 
  //freeze
  frozen = true;
@@ -691,4 +700,18 @@
  rasterManager.decimationController.performDecimation(imageChoice,readParams, request);
  return imageChoice;
  }
+
+ private RenderedImage postProcessRaster(RenderedImage mosaic) {
+ // alpha on the final mosaic
+ if (transparentColor != null) {
+ if (LOGGER.isLoggable(Level.FINE))
+ LOGGER.fine("Support for alpha on final mosaic");
+ final ImageWorker w = new ImageWorker(mosaic);
+ if (mosaic.getSampleModel() instanceof MultiPixelPackedSampleModel)
+ w.forceComponentColorModel();
+ return w.makeColorTransparent(transparentColor).getRenderedImage();
+
+ }
+ return mosaic;
+ }
 }

Modified: trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/RasterManager.java
===================================================================
--- trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/RasterManager.java 2009-07-08 07:28:27 UTC (rev 33525)
+++ trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/RasterManager.java 2009-07-08 08:06:04 UTC (rev 33526)
@@ -410,7 +410,7 @@
 
  public RasterManager(final JP2KReader reader) throws DataSourceException {
 
- Utils.ensureNonNull("ImageMosaicReader", reader);
+ Utils.ensureNonNull("JP2KReader", reader);
  this.parent=reader;
  this.expandMe=parent.expandMe;
         inputURL = reader.sourceURL;

Modified: trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/ReadType.java
===================================================================
--- trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/ReadType.java 2009-07-08 07:28:27 UTC (rev 33525)
+++ trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/ReadType.java 2009-07-08 08:06:04 UTC (rev 33526)
@@ -31,8 +31,7 @@
  *
  */
 enum ReadType {
-
-
+
     DIRECT_READ{
      RenderedImage read(
      final ImageReadParam readP,

Modified: trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/Utils.java
===================================================================
--- trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/Utils.java 2009-07-08 07:28:27 UTC (rev 33525)
+++ trunk/modules/unsupported/jp2kakadu/src/main/java/org/geotools/coverageio/jp2kak/Utils.java 2009-07-08 08:06:04 UTC (rev 33526)
@@ -3,6 +3,8 @@
  */
 package org.geotools.coverageio.jp2kak;
 
+import it.geosolutions.imageio.imageioimpl.imagereadmt.CloneableImageReadParam;
+import it.geosolutions.imageio.imageioimpl.imagereadmt.DefaultCloneableImageReadParam;
 import it.geosolutions.imageio.stream.input.FileImageInputStreamExt;
 
 import java.awt.Color;
@@ -40,14 +42,21 @@
 import org.opengis.referencing.datum.PixelInCell;
 
 /**
- * Sparse utilities for the various mosaic classes. I use them to extract
+ * Sparse utilities for the various classes. I use them to extract
  * complex code from other places.
  *
  * @author Simone Giannecchini, GeoSolutions S.A.S.
  *
  */
 class Utils {
+
  /**
+ * Logger.
+ */
+ final static Logger LOGGER = org.geotools.util.logging.Logging
+ .getLogger(Utils.class.toString());
+
+ /**
  * {@link AffineTransform} that can be used to go from an image datum placed
  * at the center of pixels to one that is placed at ULC.
  */
@@ -67,11 +76,6 @@
  .getPixelTranslation(PixelInCell.CELL_CORNER));
 
  /**
- * Logger.
- */
- final static Logger LOGGER = org.geotools.util.logging.Logging
- .getLogger(Utils.class.toString());
- /**
  * Defaut wildcard for creating mosaics.
  */
  static final String DEFAULT_WILCARD = "*.*";
@@ -207,7 +211,7 @@
  // in which there is not a special ImageReadparam used.
 
  // Create a new ImageReadParam instance.
- ImageReadParam newParam = new ImageReadParam();
+ CloneableImageReadParam newParam = new DefaultCloneableImageReadParam();
 
  // Set all fields which need to be set.
 

Deleted: trunk/modules/unsupported/jp2kakadu/src/test/java/org/geotools/coverageio/jp2kak/AbstractJP2KTestCase.java
===================================================================
--- trunk/modules/unsupported/jp2kakadu/src/test/java/org/geotools/coverageio/jp2kak/AbstractJP2KTestCase.java 2009-07-08 07:28:27 UTC (rev 33525)
+++ trunk/modules/unsupported/jp2kakadu/src/test/java/org/geotools/coverageio/jp2kak/AbstractJP2KTestCase.java 2009-07-08 08:06:04 UTC (rev 33526)
@@ -1,79 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- *
- *    (C) 2007-2008, Open Source Geospatial Foundation (OSGeo)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- *
- */
-package org.geotools.coverageio.jp2kak;
-
-import java.util.logging.Logger;
-
-import javax.imageio.ImageIO;
-import javax.media.jai.JAI;
-
-import junit.framework.TestCase;
-
-import org.geotools.coverage.grid.io.GridFormatFactorySpi;
-
-/**
- * @author Daniele Romagnoli, GeoSolutions
- * @author Simone Giannecchini (simboss), GeoSolutions
- *
- * Base JP2K testing class.
- */
-public abstract class AbstractJP2KTestCase extends TestCase {
-    protected final static Logger LOGGER = org.geotools.util.logging.Logging
-            .getLogger("org.geotools.coverageio.jp2kak");
-
-    /**
-     * A String containing the name of the supported format. It will be used to
-     * customize the messages.
-     */
-    private String supportedFormat;
-
-    /**
-     * The {@code GridFormatFactorySpi} provided by the specific subclass to
-     * handle a specific format.
-     */
-    private GridFormatFactorySpi factorySpi;
-
-    public AbstractJP2KTestCase(String name) {
-        super(name);
-        this.supportedFormat = "JP2K";
-        this.factorySpi = new JP2KFormatFactory();
-    }
-
-    protected void setUp() throws Exception {
-        super.setUp();
-        ImageIO.setUseCache(false);
-        JAI.getDefaultInstance().getTileCache().setMemoryCapacity(
-                10 * 1024 * 1024);
-        JAI.getDefaultInstance().getTileCache().setMemoryThreshold(1.0f);
-        JAI.getDefaultInstance().getTileScheduler().setParallelism(2);
-        JAI.getDefaultInstance().getTileScheduler().setPrefetchParallelism(2);
-        JAI.getDefaultInstance().getTileScheduler().setPrefetchPriority(5);
-        JAI.getDefaultInstance().getTileScheduler().setPriority(5);
-    }
-
-    protected boolean testingEnabled() {
-        boolean available = factorySpi.isAvailable();
-
-        if (!available) {
-            LOGGER.warning(supportedFormat
-                    + " libraries are not available, skipping tests!");
-        }
-
-        return available;
-    }
-}

Modified: trunk/modules/unsupported/jp2kakadu/src/test/java/org/geotools/coverageio/jp2kak/JP2KTest.java
===================================================================
--- trunk/modules/unsupported/jp2kakadu/src/test/java/org/geotools/coverageio/jp2kak/JP2KTest.java 2009-07-08 07:28:27 UTC (rev 33525)
+++ trunk/modules/unsupported/jp2kakadu/src/test/java/org/geotools/coverageio/jp2kak/JP2KTest.java 2009-07-08 08:06:04 UTC (rev 33526)
@@ -21,12 +21,18 @@
 import java.io.FileNotFoundException;
 import java.util.logging.Logger;
 
+import javax.imageio.ImageIO;
+import javax.media.jai.JAI;
+import javax.media.jai.PlanarImage;
+
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.coverage.grid.GridGeometry2D;
 import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader;
-import org.geotools.coverage.grid.io.AbstractGridFormat;
 import org.geotools.geometry.GeneralEnvelope;
+import org.geotools.referencing.CRS;
 import org.geotools.test.TestData;
+import org.junit.Assert;
+import org.junit.Test;
 import org.opengis.parameter.GeneralParameterValue;
 import org.opengis.parameter.ParameterValue;
 
@@ -36,70 +42,89 @@
  *
  * Testing {@link JP2KReader}
  */
-public final class JP2KTest extends AbstractJP2KTestCase {
-    protected final static Logger LOGGER = org.geotools.util.logging.Logging.getLogger(
-    "org.geotools.coverageio.jp2kak");
+public final class JP2KTest extends Assert {
+    private final static Logger LOGGER = org.geotools.util.logging.Logging.getLogger(JP2KTest.class);
+ /**
+ * The {@code GridFormatFactorySpi} provided by the specific subclass to
+ * handle a specific format.
+ */
+ private final static JP2KFormatFactory factorySpi  = new JP2KFormatFactory();
+
+ /**
+ * A String containing the name of the supported format. It will be used to
+ * customize the messages.
+ */
+ private static final String supportedFormat="JP2K";;
     
     /**
-     * file name of a valid JP2K sample data to be used for tests.
-     */
-    private final static String fileName = "bogota.jp2";
-
-    /**
      * Creates a new instance of JP2KTest
      *
      * @param name
      */
-    public JP2KTest(String name) {
-        super(name);
+    public JP2KTest() {
     }
 
-    public static final void main(String[] args) throws Exception {
-        junit.textui.TestRunner.run(JP2KTest.class);
-    }
-
+    @Test
     public void test() throws Exception {
         if (!testingEnabled()) {
             return;
         }
 
-        // read in the grid coverage
-        if (fileName.equalsIgnoreCase("")) {
-            LOGGER.info("===================================================================\n"
-                + " Warning! No valid test File has been yet specified.\n"
-                + " Please provide a valid sample in the source code and repeat this test!\n"
-                + "========================================================================");
-
-            return;
-        }
         File file = null;
         try{
-            file = TestData.file(this, fileName);
+            file = TestData.file(this, "bogota.jp2");
         }catch (FileNotFoundException fnfe){
-            LOGGER.warning("test-data not found: " + fileName + "\nTests are skipped");
+            LOGGER.warning("test-data not found: bogota.jp2 \nTests are skipped");
             return;
         }
 
+        final JP2KFormat format= factorySpi.createFormat();
+        assertTrue(format.accepts(file));
+        
         final AbstractGridCoverage2DReader reader = new JP2KReader(file);
-        final ParameterValue gg = (ParameterValue) ((AbstractGridFormat) reader.getFormat()).READ_GRIDGEOMETRY2D
-            .createValue();
+        final ParameterValue<GridGeometry2D> gg = JP2KFormat.READ_GRIDGEOMETRY2D.createValue();
+        final ParameterValue<Boolean> useMT = JP2KFormat.USE_MULTITHREADING.createValue();
+        final ParameterValue<Boolean> useJAI = JP2KFormat.USE_JAI_IMAGEREAD.createValue();
+        useMT.setValue(true);
+        useJAI.setValue(true);
         final GeneralEnvelope oldEnvelope = reader.getOriginalEnvelope();
         gg.setValue(new GridGeometry2D(reader.getOriginalGridRange(), oldEnvelope));
-
-        final GridCoverage2D gc = (GridCoverage2D) reader.read(new GeneralParameterValue[] { gg });
-
+        final GridCoverage2D gc = (GridCoverage2D) reader.read(new GeneralParameterValue[] { gg,useJAI,useMT });
         assertNotNull(gc);
 
         if (TestData.isInteractiveTest()) {
+         // printing CRS information
+            LOGGER.info(gc.getCoordinateReferenceSystem().toWKT());
+            LOGGER.info(gc.getEnvelope().toString());
             gc.show();
         } else {
-            gc.getRenderedImage().getData();
+            PlanarImage.wrapRenderedImage(gc.getRenderedImage()).getTiles();
         }
+      
+        assertEquals(gc.getRenderedImage().getWidth(), 512);
+        assertEquals(gc.getRenderedImage().getHeight(), 512);
+        assertTrue(CRS.equalsIgnoreMetadata(gc.getCoordinateReferenceSystem(), CRS.parseWKT("PROJCS[\"Bogota 1975 / Colombia Bogota zone\", GEOGCS[\"Bogota 1975\",DATUM[\"Bogota 1975\", SPHEROID[\"International 1924\", 6378388.0, 297.0, AUTHORITY[\"EPSG\",\"7022\"]], TOWGS84[304.5, 306.5, -318.1, 0.0, 0.0, 0.0, 0.0],AUTHORITY[\"EPSG\",\"6218\"]],PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\", 0.017453292519943295],AXIS[\"Geodetic longitude\", EAST],AXIS[\"Geodetic latitude\", NORTH],AUTHORITY[\"EPSG\",\"4218\"]],PROJECTION[\"Transverse Mercator\", AUTHORITY[\"EPSG\",\"9807\"]],PARAMETER[\"central_meridian\", -74.08091666666668],PARAMETER[\"latitude_of_origin\", 4.599047222222223],PARAMETER[\"scale_factor\", 1.0],PARAMETER[\"false_easting\", 1000000.0],PARAMETER[\"false_northing\", 1000000.0],UNIT[\"m\", 1.0],AXIS[\"Easting\", EAST],AXIS[\"Northing\", NORTH],AUTHORITY[\"EPSG\",\"21892\"]]")));
+    }
 
-        if (TestData.isInteractiveTest()) {
-            // printing CRS information
-            LOGGER.info(gc.getCoordinateReferenceSystem().toWKT());
-            LOGGER.info(gc.getEnvelope().toString());
-        }
-    }
+ public void setUp() throws Exception {
+    ImageIO.setUseCache(false);
+    JAI.getDefaultInstance().getTileCache().setMemoryCapacity(
+            10 * 1024 * 1024);
+    JAI.getDefaultInstance().getTileCache().setMemoryThreshold(1.0f);
+    JAI.getDefaultInstance().getTileScheduler().setParallelism(2);
+    JAI.getDefaultInstance().getTileScheduler().setPrefetchParallelism(2);
+    JAI.getDefaultInstance().getTileScheduler().setPrefetchPriority(5);
+    JAI.getDefaultInstance().getTileScheduler().setPriority(5);
+ }
+
+ static boolean testingEnabled() {
+    boolean available = factorySpi.isAvailable();
+
+    if (!available) {
+        LOGGER.warning(supportedFormat
+                + " libraries are not available, skipping tests!");
+    }
+
+    return available;
+ }
 }

Modified: trunk/modules/unsupported/jp2kakadu/src/test/java/org/geotools/coverageio/jp2kak/ServiceTest.java
===================================================================
--- trunk/modules/unsupported/jp2kakadu/src/test/java/org/geotools/coverageio/jp2kak/ServiceTest.java 2009-07-08 07:28:27 UTC (rev 33525)
+++ trunk/modules/unsupported/jp2kakadu/src/test/java/org/geotools/coverageio/jp2kak/ServiceTest.java 2009-07-08 08:06:04 UTC (rev 33526)
@@ -21,6 +21,8 @@
 
 import org.geotools.coverage.grid.io.GridFormatFactorySpi;
 import org.geotools.coverage.grid.io.GridFormatFinder;
+import org.junit.Assert;
+import org.junit.Test;
 import org.opengis.referencing.FactoryException;
 import org.opengis.referencing.NoSuchAuthorityCodeException;
 
@@ -32,17 +34,13 @@
  * @author Simone Giannecchini (simboss), GeoSolutions
  *
  */
-public class ServiceTest extends AbstractJP2KTestCase {
-    public ServiceTest(java.lang.String testName) {
-        super(testName);
+public class ServiceTest extends Assert {
+    public ServiceTest() {
     }
 
-    public static void main(java.lang.String[] args) {
-        junit.textui.TestRunner.run(ServiceTest.class);
-    }
-
+    @Test
     public void testIsAvailable() throws NoSuchAuthorityCodeException, FactoryException {
-        if (!testingEnabled()) {
+        if (!JP2KTest.testingEnabled()) {
             return;
         }
 


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
GeoTools-commits mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-commits