svn - r33507 - in trunk/spike/coverage-api/src: main/java/org/geotools/coverage/io main/java/org/geotools/coverage/io/impl/range main/java/org/geotools/coverage/io/range test/java/org/geotools/coverage/io/range/impl

1 message Options
Embed this post
Permalink
svn_geotools

svn - r33507 - in trunk/spike/coverage-api/src: main/java/org/geotools/coverage/io main/java/org/geotools/coverage/io/impl/range main/java/org/geotools/coverage/io/range test/java/org/geotools/coverage/io/range/impl

Reply Threaded More More options
Print post
Permalink
Author: simonegiannecchini
Date: 2009-07-07 08:18:05 -0400 (Tue, 07 Jul 2009)
New Revision: 33507

Added:
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/DimensionlessAxisBin.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/IMAGE_PROCESSING_ELEMENTS.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/AxisBin.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/RangeUtilities.java
   trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/SyntheticDataTest.java
Removed:
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/BandIndexMeasure.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/BandRange.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/CMYK.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/CodeMeasure.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/EnumMeasure.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/HSV.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/SimpleScalarAxis.java
   trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/CodeMeasureTest.java
   trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/EnumMeasureTest.java
Modified:
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/RasterDataset.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/RasterDatasetReader.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/RasterSlice.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/base.ucls
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/DimensionlessAxis.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/WavelengthAxis.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/Axis.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/Band.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/BandType.java
   trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/FieldType.java
   trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/DimensionlessAxisTest.java
Log:
trying to simplify range management

Modified: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/RasterDataset.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/RasterDataset.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/RasterDataset.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -19,6 +19,8 @@
 import java.io.IOException;
 import java.util.Set;
 
+import javax.measure.quantity.Quantity;
+
 import org.geotools.coverage.io.domain.RasterDatasetDomainManager;
 import org.geotools.coverage.io.metadata.MetadataNode;
 import org.geotools.coverage.io.range.FieldType;
@@ -72,7 +74,7 @@
  * codomain for the underlying coverage.
  * @throws IOException in case something bad occurs
  */
- public FieldType getRangeDescription(final ProgressListener listener) throws IOException;
+ public <V, QA extends Quantity> FieldType<V, QA> getRangeDescription(final ProgressListener listener) throws IOException;
 
  public DomainManager getDomainManager(final ProgressListener listener) throws IOException;
 

Modified: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/RasterDatasetReader.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/RasterDatasetReader.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/RasterDatasetReader.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -2,7 +2,6 @@
 
 import java.io.IOException;
 import java.io.Serializable;
-import java.net.URI;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Map;
@@ -11,7 +10,6 @@
 import org.geotools.coverage.io.metadata.MetadataNode;
 import org.geotools.coverage.io.service.RasterService;
 import org.geotools.coverage.io.service.RasterServiceAction;
-import org.geotools.data.ServiceInfo;
 import org.geotools.data.DataAccessFactory.Param;
 import org.geotools.factory.Hints;
 import org.opengis.feature.type.Name;
@@ -85,8 +83,6 @@
  */
  public RasterDataset acquire(int index, Map<String, Serializable> params, Hints hints, ProgressListener listener)throws IOException;
 
- public void setTargetLocation(URI location)throws IOException;
-
  /**
  * This will free any cached info object or header information.
  * <p>
@@ -102,16 +98,6 @@
  public void close();
 
  /**
- * Description of the RasterStorage we are connected to here.
- * <p>
- * @todo TODO think about the equivalence with StreamMetadata once we define
- *       them
- *
- * @return Description of the RasterStorage we are connected to here.
- */
- public ServiceInfo getInfo(final ProgressListener listener);
-
- /**
  * Returns the {@link RasterService} which has been used to connect to this
  * RasterStorage.
  *

Modified: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/RasterSlice.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/RasterSlice.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/RasterSlice.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -4,6 +4,8 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.measure.quantity.Quantity;
+
 import org.geotools.coverage.io.range.Band;
 import org.geotools.coverage.io.range.BandType;
 import org.geotools.coverage.io.request.CoverageReadRequest;
@@ -13,13 +15,7 @@
 import org.geotools.data.Parameter;
 import org.omg.CORBA.DomainManager;
 import org.opengis.util.ProgressListener;
-/**
- * A {@link RasterSlice} is a 2D element in space/time/elevation with a certain number of Bands.
- * It may also have its own pyramid.
- *
- * @author Simone Giannecchini, GeoSolutions SAS
- *
- */
+
 public interface RasterSlice {
 
  /**
@@ -33,7 +29,7 @@
  */
  public List<Band> getBands(final ProgressListener listener) throws IOException;
 
- public Band getRangeSubset(final List<BandType>bands,final ProgressListener listener) throws IOException;
+ public <V, Q extends Quantity> List<Band> getRangeSubset(final List<BandType.BandKey<V, Q>>bands,final ProgressListener listener) throws IOException;
 
  public DomainManager getDomainManager(final ProgressListener listener) throws IOException;
 

Modified: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/base.ucls
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/base.ucls 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/base.ucls 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,5 +1,94 @@
 <class-diagram version="0.9.82" icons="true" always-add-relationships="true" generalizations="true" realizations="true"
   associations="true" dependencies="true" nesting-relationships="true">  
+  <interface corner="BOTTOM_RIGHT" language="java" name="org.geotools.coverage.io.RasterDatasetWriter"
+    project="gt-coverage-api-2.6-SNAPSHOT"
+    file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDatasetWriter.java" binary="false">    
+    <position x="165" y="139" width="141" height="45"/>    
+    <display autosize="true" package="true" initial-value="true" signature="true" visibility="true">      
+      <attributes public="false" package="false" protected="false" private="false"/>      
+      <operations public="false" package="false" protected="false" private="false"/>    
+    </display>  
+  </interface>  
+  <interface corner="BOTTOM_RIGHT" language="java" name="org.geotools.coverage.io.RasterDatasetReader"
+    project="gt-coverage-api-2.6-SNAPSHOT"
+    file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDatasetReader.java" binary="false">    
+    <position x="327" y="54" width="146" height="45"/>    
+    <display autosize="true" package="true" initial-value="true" signature="true" visibility="true">      
+      <attributes public="false" package="false" protected="false" private="false"/>      
+      <operations public="false" package="false" protected="false" private="false"/>    
+    </display>  
+  </interface>  
+  <interface corner="BOTTOM_RIGHT" language="java" name="org.geotools.coverage.io.RasterDataset"
+    project="gt-coverage-api-2.6-SNAPSHOT"
+    file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDataset.java" binary="false">    
+    <position x="327" y="224" width="110" height="45"/>    
+    <display autosize="true" package="true" initial-value="true" signature="true" visibility="true">      
+      <attributes public="false" package="false" protected="false" private="false"/>      
+      <operations public="false" package="false" protected="false" private="false"/>    
+    </display>  
+  </interface>  
+  <interface corner="BOTTOM_RIGHT" language="java" name="org.geotools.coverage.io.RasterSlice"
+    project="gt-coverage-api-2.6-SNAPSHOT"
+    file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterSlice.java" binary="false">    
+    <position x="327" y="309" width="110" height="45"/>    
+    <display autosize="true" package="true" initial-value="true" signature="true" visibility="true">      
+      <attributes public="false" package="false" protected="false" private="false"/>      
+      <operations public="false" package="false" protected="false" private="false"/>    
+    </display>  
+  </interface>  
+  <enumeration corner="BOTTOM_RIGHT" language="java" name="org.geotools.coverage.io.RasterDatasetAccessorCapabilities"
+    project="gt-coverage-api-2.6-SNAPSHOT"
+    file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDatasetAccessorCapabilities.java"
+    binary="false">    
+    <position x="367" y="139" width="226" height="45"/>    
+    <display autosize="true" package="true" initial-value="true" signature="true" visibility="true">      
+      <attributes public="false" package="false" protected="false" private="false"/>      
+      <operations public="false" package="false" protected="false" private="false"/>    
+    </display>  
+  </enumeration>  
+  <dependency>    
+    <bendpoint x="336" y="139"/>    
+    <source project="gt-coverage-api-2.6-SNAPSHOT" name="org.geotools.coverage.io.RasterDatasetReader"
+      file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDatasetReader.java"
+      binary="false"/>    
+    <target project="gt-coverage-api-2.6-SNAPSHOT" name="org.geotools.coverage.io.RasterDataset"
+      file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDataset.java" binary="false"/>  
+  </dependency>  
+  <dependency>    
+    <source project="gt-coverage-api-2.6-SNAPSHOT" name="org.geotools.coverage.io.RasterDatasetWriter"
+      file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDatasetWriter.java"
+      binary="false"/>    
+    <target project="gt-coverage-api-2.6-SNAPSHOT" name="org.geotools.coverage.io.RasterDataset"
+      file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDataset.java" binary="false"/>  
+  </dependency>  
+  <dependency>    
+    <source project="gt-coverage-api-2.6-SNAPSHOT" name="org.geotools.coverage.io.RasterDatasetReader"
+      file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDatasetReader.java"
+      binary="false"/>    
+    <target project="gt-coverage-api-2.6-SNAPSHOT" name="org.geotools.coverage.io.RasterDatasetAccessorCapabilities"
+      file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDatasetAccessorCapabilities.java"
+      binary="false"/>  
+  </dependency>  
+  <dependency>    
+    <source project="gt-coverage-api-2.6-SNAPSHOT" name="org.geotools.coverage.io.RasterDataset"
+      file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDataset.java" binary="false"/>    
+    <target project="gt-coverage-api-2.6-SNAPSHOT" name="org.geotools.coverage.io.RasterSlice"
+      file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterSlice.java" binary="false"/>  
+  </dependency>  
+  <generalization>    
+    <source project="gt-coverage-api-2.6-SNAPSHOT" name="org.geotools.coverage.io.RasterDatasetWriter"
+      file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDatasetWriter.java"
+      binary="false"/>    
+    <target project="gt-coverage-api-2.6-SNAPSHOT" name="org.geotools.coverage.io.RasterDatasetReader"
+      file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDatasetReader.java"
+      binary="false"/>  
+  </generalization>  
+  <dependency>    
+    <source project="gt-coverage-api-2.6-SNAPSHOT" name="org.geotools.coverage.io.RasterSlice"
+      file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterSlice.java" binary="false"/>    
+    <target project="gt-coverage-api-2.6-SNAPSHOT" name="org.geotools.coverage.io.RasterDataset"
+      file="/gt-coverage-api-2.6-SNAPSHOT/src/main/java/org/geotools/coverage/io/RasterDataset.java" binary="false"/>  
+  </dependency>  
   <classifier-display autosize="true" package="true" initial-value="true" signature="true" visibility="true">    
     <attributes public="false" package="false" protected="false" private="false"/>    
     <operations public="false" package="false" protected="false" private="false"/>  

Deleted: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/BandIndexMeasure.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/BandIndexMeasure.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/BandIndexMeasure.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,66 +0,0 @@
-package org.geotools.coverage.io.impl.range;
-
-import javax.measure.Measurable;
-import javax.measure.Measure;
-import javax.measure.converter.ConversionException;
-import javax.measure.quantity.Dimensionless;
-import javax.measure.unit.Unit;
-
-/**
- * {@link Measurable} subclass suitable for modeling a band index in a multiband
- * image axis.
- *
- * <p>
- * The band index is a measurement of a {@link Dimensionless} quantity since it
- * is just a convenience ordering.
- *
- * @author Simone Giannecchini, GeoSolutions
- */
-public class BandIndexMeasure extends Measure<String, Dimensionless>implements Measurable<Dimensionless> {
- private static final long serialVersionUID = 3895010709415779953L;
-
- private Long index = null;
-
- private String bandMnemonic = null;
-
- public BandIndexMeasure(final int index, final String bandMnemonic) {
- this.index = (long) index;
- this.bandMnemonic = bandMnemonic != null ? bandMnemonic : Long
- .toString(this.index);
- }
-
- public double doubleValue(Unit<Dimensionless> value) {
- return index;
- }
-
- public long longValue(Unit<Dimensionless> value) throws ArithmeticException {
- return index;
- }
-
- public int compareTo(Measurable<Dimensionless> o) {
- return this.index.compareTo(o.longValue(Unit.ONE));
- }
-
- @Override
- public Unit<Dimensionless> getUnit() {
- return Unit.ONE;
- }
-
- @Override
- public String getValue() {
- return this.bandMnemonic;
- }
-
- @Override
- public Measure<String, Dimensionless> to(Unit<Dimensionless> target) {
- if (target.isCompatible(Unit.ONE))
- return new BandIndexMeasure(this.index.intValue(),
- this.bandMnemonic);
- final StringBuilder buffer = new StringBuilder();
- buffer.append("Unable to perform requested conversion");
- buffer.append("\nsource UoM:").append("  ").append(Unit.ONE.toString());
- buffer.append("\ntarget UoM:").append("  ").append(target.toString());
- throw new ConversionException(buffer.toString());
-
- }
-}

Deleted: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/BandRange.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/BandRange.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/BandRange.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,10 +0,0 @@
-package org.geotools.coverage.io.impl.range;
-
-import javax.measure.Measure;
-import javax.measure.quantity.Quantity;
-
-import org.geotools.util.Range;
-
-public abstract class BandRange<T,QA extends Quantity> extends Measure<Range<Comparable<? super T>>, QA> {
-
-}

Deleted: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/CMYK.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/CMYK.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/CMYK.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,33 +0,0 @@
-package org.geotools.coverage.io.impl.range;
-
-import javax.measure.quantity.Dimensionless;
-import javax.measure.unit.Unit;
-
-import org.geotools.coverage.io.range.Axis;
-
-/**
- * Process Color is a subtractive model used when working with pigment. This
- * model is often used when printing.
- * <p>
- * This is a normal Java 5 enum capturing the closed set of CMYK names. It is
- * used as a basis for the definition of an Axis built around these constants.
- * <p>
- * Please understand that this is not the only possible subtractive color model
- * - a commercial alternative is the Pantone (tm)) colors.
- */
-public enum CMYK {
- CYAN, MAGENTA, YELLOW, KEY;
-
- /**
- * Axis covering the full {@link CMYK} range.
- */
- public static final Axis<CMYK,Dimensionless> AXIS
- = new Axis<CMYK,Dimensionless>("Process Color", EnumMeasure.valueOf( CMYK.class ), Unit.ONE );
-
- /**
- * Axis around {@link #KEY }.
- */
- public static final Axis<CMYK,Dimensionless> BLACK_AXIS =
- new Axis<CMYK,Dimensionless>("Process Black", EnumMeasure.valueOf(KEY), Unit.ONE );
-    
-}
\ No newline at end of file

Deleted: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/CodeMeasure.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/CodeMeasure.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/CodeMeasure.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,109 +0,0 @@
-package org.geotools.coverage.io.impl.range;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-import javax.measure.Measure;
-import javax.measure.quantity.Dimensionless;
-import javax.measure.unit.Unit;
-
-import org.opengis.util.CodeList;
-
-/**
- * Used to create Axis keys based on an open set of machine readable strings.
- * <p>
- * An Open set of strings are represented as a CodeList in the GeoTools library. This
- * forms a data dictionary (or "formal vocabulary") that is constructed at runtime.
- * Often applications use this facility to store a common data dictionary in a shared
- * database or website; while still providing a facility that is familiar to Java
- * developers. A CodeList walks and talks like an Enumeration; the only difference
- * for java developers is the ability to add new entries (as such it is very important
- * to use a default block in any switch statements concerning code lists.
- * <p>
- * This is a great tool for dealing well defined keys; where the definition is not
- * actually hardcoded into your application.
- * <p>
- * Please note that this Measure is considered Dimensionless; if your keys actually belong
- * to a domain you should use the appropriate value and Unit to define them.
- *
- * @param <V> CodeList provided an open set of machine readable strings
- */
-public class CodeMeasure<V extends CodeList<V>> extends Measure<V, Dimensionless> {
- private static final long serialVersionUID = 2403097126807167994L;
- private V value;
-
- /** Create a measure out of the provided Enum */
- private CodeMeasure( V value ){
- this.value = value;
- }
- @Override
- public double doubleValue(Unit<Dimensionless> unit) {
- return value.ordinal();
- }
-
- @Override
- public Unit<Dimensionless> getUnit() {
- return Unit.ONE;
- }
-
- @Override
- public V getValue() {
- return value;
- }
-
- @Override
- public Measure<V, Dimensionless> to(Unit<Dimensionless> unit) {
- return this;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((value == null) ? 0 : value.hashCode());
- return result;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- CodeMeasure<?> other = (CodeMeasure<?>) obj;
- if (value == null) {
- if (other.value != null)
- return false;
- } else if (!value.equals(other.value))
- return false;
- return true;
- }
- /**
- * Create a Measure wrapping around the provided CodeList element.
- * @param <E>
- * @param code
- * @return
- */
- public static <C extends CodeList<C>> Measure<C,Dimensionless> valueOf( C code ){
- return new CodeMeasure<C>( code );
- }
- /**
- * Create a List of Measures representing the provided codes.
- * @param <C>
- * @param codes
- * @return
- */
- public static <C extends CodeList<C>> List<Measure<C,Dimensionless>> valueOf( Collection<C> codes ){
- List<Measure<C,Dimensionless>> list = new ArrayList<Measure<C,Dimensionless>>();
- for( C entry : codes ){
- list.add( new CodeMeasure<C>( entry ));
- }
- return list;
- }
- public static <C extends CodeList<C>> List<Measure<C,Dimensionless>> valueOf( C[] codes ){
- return valueOf( Arrays.asList( codes ));
- }
-}
\ No newline at end of file

Modified: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/DimensionlessAxis.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/DimensionlessAxis.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/DimensionlessAxis.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,42 +1,15 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- *
- *    (C) 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.coverage.io.impl.range;
 
-import java.awt.color.ColorSpace;
-import java.awt.image.ColorModel;
-import java.awt.image.RenderedImage;
 import java.awt.image.SampleModel;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
 
-import javax.measure.Measure;
 import javax.measure.quantity.Dimensionless;
 import javax.measure.unit.Unit;
-import javax.media.jai.IHSColorSpace;
 
-import org.geotools.coverage.TypeMap;
 import org.geotools.coverage.io.range.Axis;
 import org.geotools.feature.NameImpl;
 import org.geotools.util.SimpleInternationalString;
-import org.opengis.coverage.ColorInterpretation;
 import org.opengis.coverage.SampleDimension;
 import org.opengis.feature.type.Name;
-import org.opengis.referencing.crs.SingleCRS;
 import org.opengis.util.InternationalString;
 
 /**
@@ -51,195 +24,28 @@
  * @todo add convenience constructor based on {@link SampleDimension} and or
  *       {@link SampleModel}
  */
-@SuppressWarnings("deprecation")
-public class DimensionlessAxis extends Axis<String,Dimensionless> {
-
- private static List<Measure<String, Dimensionless>> bandsNumberToList(final int bandsNumber) {
- final List<Measure<String, Dimensionless>> bins= new ArrayList<Measure<String, Dimensionless>>(bandsNumber);
-        for (int i = 0; i < bandsNumber; i++)
-         bins.add(new BandIndexMeasure(i,Integer.toString(i)));
-        return bins;
- }
+public class DimensionlessAxis extends Axis<Dimensionless> {
 
- private static List<Measure<String, Dimensionless>> bandsToList(final String[] bands) {
- final List<Measure<String, Dimensionless>> bins= new ArrayList<Measure<String, Dimensionless>>(bands.length);
-        for (int i = 0; i < bands.length; i++)
-         bins.add(new BandIndexMeasure(i,bands[i]));
-        return bins;
- }
 
-    private static List<Measure<String, Dimensionless>> bandsToList(List<String> bandsKeys) {
-
-        if (bandsKeys==null || bandsKeys.isEmpty())
-            throw new IllegalArgumentException("Specified band keys list is invalid");  
- return bandsToList(bandsKeys.toArray(new String[bandsKeys.size()]));
- }
-    
-    
-    /**
-     * Helper classes for creating {@link DimensionlessAxis} for the most common color models' bands.
+ /**
      *
-     * <p>
-     * Suypported colorspaces incluse RGBA, GRAY, GRAYA, HSV,HLS, LAB, LUV, IHS, CI_XYZ, CMY(K).
-     * Notice that RGB is not handled here but through a wavelength axis.
-     *
-     * <p>
-     * This method returns null if an unsupported {@link ColorModel} is provided.
-     *
-     * @param raster a {@link RenderedImage} implementation from which to extract needed info, usually {@link ColorModel} and {@link SampleModel}.
-     * @return a {@link DimensionlessAxis} or null if an unsupported {@link ColorModel} is provided.
      */
- public static DimensionlessAxis createFromRenderedImage(final RenderedImage raster){
- if(raster==null)
- throw new IllegalArgumentException("Provided null input image");
-
- final ColorModel cm= raster.getColorModel();
- if(cm==null)
- throw new IllegalArgumentException("Provided input image with null color model");
- final SampleModel sm= raster.getSampleModel();
- if(sm==null)
- throw new IllegalArgumentException("Provided input image with null SampleModel");
-
- //get the color interpretation for the three bands
- final ColorInterpretation firstBandCI = TypeMap.getColorInterpretation(cm, 0);
-
- // CMY - CMYK
- if(firstBandCI==ColorInterpretation.CYAN_BAND)
- {
- if(sm.getNumBands()==3)
- return new DimensionlessAxis(
- Arrays.asList("CYAN","MAGENTA","YELLOW"),
- new NameImpl("CMY-AXIS"),
- new SimpleInternationalString("Axis for CMY bands"));
- else
- return new DimensionlessAxis(
- Arrays.asList("CYAN","MAGENTA","YELLOW","BLACK"),
- new NameImpl("CMYK-AXIS"),
- new SimpleInternationalString("Axis for CMYK bands"));
- }
-
- // HSV
- if(firstBandCI==ColorInterpretation.HUE_BAND)
- {
- return new DimensionlessAxis(
- Arrays.asList("HUE","SATURATION","VALUE"),
- new NameImpl("HSV-AXIS"),
- new SimpleInternationalString("Axis for HSV bands"));
- }
-
- //RGBA
- if(firstBandCI==ColorInterpretation.RED_BAND)
- {
- return new DimensionlessAxis(
- Arrays.asList("RED","GREEN","BLUE","ALPHA"),
- new NameImpl("RGBA-AXIS"),
- new SimpleInternationalString("Axis for RGBA bands"));
- }
-
- //PALETTE
- if(firstBandCI==ColorInterpretation.PALETTE_INDEX)
- return new DimensionlessAxis(
- Arrays.asList("PALETTE_INDEX"),
- new NameImpl("PALETTE_INDEX-AXIS"),
- new SimpleInternationalString("Axis for PALETTE INDEX bands"));
-
- // GRAY, GRAY+ALPHA
- if(firstBandCI==ColorInterpretation.GRAY_INDEX)
- {
- if(sm.getNumBands()==2)
- return new DimensionlessAxis(
- Arrays.asList("GRAY","ALPHA"),
- new NameImpl("GA-AXIS"),
- new SimpleInternationalString("Axis for GRAY-ALPHA bands"));
- else
- return new DimensionlessAxis(
- Arrays.asList("GRAY"),
- new NameImpl("GRAY-AXIS"),
- new SimpleInternationalString("Axis for GRAY bands"));
-
- }
-
-
- final ColorSpace cs = cm.getColorSpace();
- //IHS
- if(cs instanceof IHSColorSpace)
- return new DimensionlessAxis(
- Arrays.asList("INTENSITY","HUE","SATURATION"),
- new NameImpl("IHS-AXIS"),
- new SimpleInternationalString("Axis for IHS bands"));
-
- //YCbCr, LUV, LAB, HLS, IEXYZ
- switch(cs.getType()){
- case ColorSpace.TYPE_YCbCr:
- return new DimensionlessAxis(
- Arrays.asList("LUMA","CHROMA-A","CHROMA-B"),
- new NameImpl("YCbCr-AXIS"),
- new SimpleInternationalString("Axis for YCbCr bands"));
- case ColorSpace.TYPE_Luv:
- return new DimensionlessAxis(
- Arrays.asList("LIGHTNESS","U","V"),
- new NameImpl("LUV-AXIS"),
- new SimpleInternationalString("Axis for LUV bands"));
- case ColorSpace.TYPE_Lab:
- return new DimensionlessAxis(
- Arrays.asList("LIGHTNESS","A","B"),
- new NameImpl("LAB-AXIS"),
- new SimpleInternationalString("Axis for LAB bands"));
- case ColorSpace.TYPE_HLS:
- return new DimensionlessAxis(
- Arrays.asList("HUE","LIGHTNESS","SATURATION"),
- new NameImpl("HLS-AXIS"),
- new SimpleInternationalString("Axis for HLS bands"));
- case ColorSpace.CS_CIEXYZ:
- return new DimensionlessAxis(
- Arrays.asList("X","Y","Z"),
- new NameImpl("XYZ-AXIS"),
- new SimpleInternationalString("Axis for XYZ bands"));
-
- default:
- return null;
-
-
- }
+    public DimensionlessAxis(final Name name,final InternationalString description) {
+     super(name,description,Unit.ONE );
     }
     
-
-    /**
+ /**
      *
      */
-    public DimensionlessAxis(final int bandsNumber, final Name name,final InternationalString description) {
-     super(name,description,bandsNumberToList(bandsNumber),Unit.ONE );
+    public DimensionlessAxis(final String name,final String description) {
+     super(new NameImpl(name),new SimpleInternationalString(description),Unit.ONE );
     }
-
-    /**
-     *
-     */
-    public DimensionlessAxis(final String[] bands, final Name name,final InternationalString description) {
-     super(name,description,bandsToList(bands),Unit.ONE );
-    }
-
-    /**
-     *
-     */
-    public DimensionlessAxis(final List<String> bandsKeys, final Name name,final InternationalString description) {
-     super(name,description,bandsToList(bandsKeys),Unit.ONE );
-    }
-
     
-
  /**
-     * @see org.geotools.coverage.io.range.Axis#getCoordinateReferenceSystem()
+     *
      */
-    public SingleCRS getCoordinateReferenceSystem() {
-        return null;
+    public DimensionlessAxis(final String name) {
+     super(new NameImpl(name),new SimpleInternationalString(name),Unit.ONE );
     }
 
-
-    /**
-     * @see org.geotools.coverage.io.range.Axis#getUnitOfMeasure()
-     */
-    public Unit<Dimensionless> getUnitOfMeasure() {
-        return Unit.ONE;
-    }
-
-}
+}
\ No newline at end of file

Added: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/DimensionlessAxisBin.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/DimensionlessAxisBin.java                        (rev 0)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/DimensionlessAxisBin.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -0,0 +1,70 @@
+/*
+ *    GeoTools - The Open Source Java GIS Toolkit
+ *    http://geotools.org
+ *
+ *    (C) 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.coverage.io.impl.range;
+
+import java.awt.image.SampleModel;
+
+import javax.measure.quantity.Dimensionless;
+import javax.measure.unit.Unit;
+
+import org.geotools.coverage.io.range.Axis;
+import org.geotools.coverage.io.range.AxisBin;
+import org.opengis.coverage.SampleDimension;
+import org.opengis.feature.type.Name;
+import org.opengis.referencing.crs.SingleCRS;
+import org.opengis.util.InternationalString;
+
+/**
+ * Implementation of {@link Axis} for multibands images.
+ *
+ * <p>
+ * This implementation of Axis can be seen as a stub implementation since in
+ * this case we do not really have an {@link Axis} for this kind of data, or
+ * rather we have an axis that just represents an ordinal or a certain set of .
+ *
+ * @author Simone Giannecchini, GeoSolutions
+ * @todo add convenience constructor based on {@link SampleDimension} and or
+ *       {@link SampleModel}
+ */
+public class DimensionlessAxisBin extends AxisBin<String,Dimensionless> {
+
+    /**
+     *
+     */
+    public DimensionlessAxisBin(final Name name,final InternationalString description,final Axis<Dimensionless> axis, final String bandName) {
+     super(name,description,axis,bandName );
+    }
+
+
+    
+
+ /**
+     * @see org.geotools.coverage.io.range.Axis#getCoordinateReferenceSystem()
+     */
+    public SingleCRS getCoordinateReferenceSystem() {
+        return null;
+    }
+
+
+    /**
+     * @see org.geotools.coverage.io.range.Axis#getUnitOfMeasure()
+     */
+    public Unit<Dimensionless> getUnitOfMeasure() {
+        return Unit.ONE;
+    }
+
+}


Property changes on: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/DimensionlessAxisBin.java
___________________________________________________________________
Added: svn:eol-style
   + native

Deleted: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/EnumMeasure.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/EnumMeasure.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/EnumMeasure.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,97 +0,0 @@
-package org.geotools.coverage.io.impl.range;
-
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.List;
-
-import javax.measure.Measure;
-import javax.measure.quantity.Dimensionless;
-import javax.measure.unit.Unit;
-
-/**
- * Used to create Axis keys based on a fixed set of machine readable strings.
- * <p>
- * Fixed set of strings are represented as an Enumeration in the GeoTools library. This
- * forms a data dictionary (or "formal vocabulary") that is well defined and closed
- * to further additions.
- * <p>
- * This is a great tool for dealing well defined keys such as RGB or CMKY; for most
- * data products you may wish to consider a CodeList instead.
- * <p>
- * Please note that this Measure is considered Dimensionless; if your keys actually belong
- * to a domain you should use the appropriate value and Unit to define them.
- *
- * @param <V> Enumeration provided a fixed set of machine readable strings
- */
-public class EnumMeasure<V extends Enum<V>> extends Measure<V, Dimensionless> {
- private static final long serialVersionUID = 2403097126807167994L;
- private V value;
-
- /** Create a measure out of the provided Enum */
- private EnumMeasure( V value ){
- this.value = value;
- }
- @Override
- public double doubleValue(Unit<Dimensionless> unit) {
- return value.ordinal();
- }
-
- @Override
- public Unit<Dimensionless> getUnit() {
- return Unit.ONE;
- }
-
- @Override
- public V getValue() {
- return value;
- }
-
- @Override
- public Measure<V, Dimensionless> to(Unit<Dimensionless> unit) {
- return this;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((value == null) ? 0 : value.hashCode());
- return result;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- EnumMeasure<?> other = (EnumMeasure<?>) obj;
- if (value == null) {
- if (other.value != null)
- return false;
- } else if (!value.equals(other.value))
- return false;
- return true;
- }
- /**
- * Create a Measure wrapping around the provided Enumeration.
- * @param <E>
- * @param enumeration
- * @return
- */
- public static <E extends Enum<E>> EnumMeasure<E> valueOf( E enumeration ){
- return new EnumMeasure<E>( enumeration );
- }
- public static <E extends Enum<E>> List<Measure<E,Dimensionless>> valueOf( Class<E> elementType ){
- return valueOf( EnumSet.allOf( elementType ));
- }
-
- public static <E extends Enum<E>> List<Measure<E,Dimensionless>> valueOf( EnumSet<E> set ){
- List<Measure<E,Dimensionless>> list = new ArrayList<Measure<E,Dimensionless>>();
- for( E entry : set ){
- list.add( new EnumMeasure<E>( entry ));
- }
- return list;
- }
-}
\ No newline at end of file

Deleted: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/HSV.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/HSV.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/HSV.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,52 +0,0 @@
-package org.geotools.coverage.io.impl.range;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.measure.quantity.Dimensionless;
-import javax.measure.unit.Unit;
-
-import org.geotools.coverage.io.range.Axis;
-import org.opengis.util.CodeList;
-
-/**
- * Process Color is a subtractive model used when working with pigment. This
- * model is often used when printing.
- * <p>
- * This is a normal Java 5 enum capturing the closed set of CMYK names. It is
- * used as a basis for the definition of an Axis built around these constants.
- * <p>
- * Please understand that this is not the only possible subtractive color model
- * - a commerical alternative is the Pantone (tm)) colors.
- */
-public class HSV extends CodeList<HSV> {
- private static final long serialVersionUID = 2772167658847829287L;
-
- private static List<HSV> ALL = new ArrayList<HSV>();
-
- public static HSV HUE = new HSV("Hue");
- public static HSV SATURATION = new HSV("Saturation");
- public static HSV VALUE = new HSV("Value");
-
- public HSV(String name) {
- super(name, ALL );
- }
-
- @Override
- public HSV[] family() {
- return ALL.toArray( new HSV[ ALL.size() ]);
- }
-
- /**
- * Axis covering the full {@link HSV} range.
- */
- public static final Axis<HSV,Dimensionless> AXIS
-     = new Axis<HSV,Dimensionless>("Additive Color", CodeMeasure.valueOf( ALL ), Unit.ONE );
-
- /**
- * Axis around {@link #KEY }.
- */
- public static final Axis<HSV,Dimensionless> INTENSITY_AXIS =
- new Axis<HSV,Dimensionless>("Intensity", CodeMeasure.valueOf(VALUE), Unit.ONE );
-
-}

Added: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/IMAGE_PROCESSING_ELEMENTS.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/IMAGE_PROCESSING_ELEMENTS.java                        (rev 0)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/IMAGE_PROCESSING_ELEMENTS.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -0,0 +1,1055 @@
+package org.geotools.coverage.io.impl.range;
+
+import java.awt.color.ColorSpace;
+import java.awt.image.ColorModel;
+import java.awt.image.RenderedImage;
+import java.awt.image.SampleModel;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.measure.quantity.Dimensionless;
+import javax.measure.unit.Unit;
+import javax.media.jai.IHSColorSpace;
+
+import org.geotools.coverage.TypeMap;
+import org.geotools.coverage.io.range.Axis;
+import org.geotools.coverage.io.range.BandType;
+import org.geotools.coverage.io.range.FieldType;
+import org.geotools.coverage.io.range.BandType.BandKey;
+import org.geotools.feature.NameImpl;
+import org.geotools.util.SimpleInternationalString;
+import org.opengis.coverage.ColorInterpretation;
+
+/**
+ * Process Color is a subtractive model used when working with pigment. This
+ * model is often used when printing.
+ * <p>
+ * This is a normal Java 5 enum capturing the closed set of CMYK names. It is
+ * used as a basis for the definition of an Axis built around these constants.
+ * <p>
+ * Please understand that this is not the only possible subtractive color model
+ * - a commercial alternative is the Pantone (tm)) colors.
+ *
+ */
+@SuppressWarnings("deprecation")
+public enum IMAGE_PROCESSING_ELEMENTS{
+
+ X {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return X_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.UNDEFINED,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ Y {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return Y_BIN;
+ }
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.UNDEFINED,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ Z {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return Z_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.UNDEFINED,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ A {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return A_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.UNDEFINED,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ B {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return B_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.UNDEFINED,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ LIGHTNESS {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return LIGHTNESS_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.LIGHTNESS_BAND,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ U {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return U_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.UNDEFINED,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ V {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return V_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.UNDEFINED,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ LUMA {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return LUMA_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.LIGHTNESS_BAND,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ CHROMA_A {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return CHROMA_A_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.UNDEFINED,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ CHROMA_B {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return CHROMA_B_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.UNDEFINED,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ INTENSITY {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return INTENSITY_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.UNDEFINED,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ ALPHA {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return ALPHA_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.ALPHA_BAND,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ GRAY {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return GRAY_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.GRAY_INDEX,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ UNDEFINED {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return UNDEFINED_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.UNDEFINED,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ PALETTE {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return PALETTE_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.PALETTE_INDEX,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ BLUE {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return BLUE_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.BLUE_BAND,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ GREEN {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return GREEN_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.GREEN_BAND,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ RED {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return RED_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.RED_BAND,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ VALUE {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return SATURATION_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.UNDEFINED,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ SATURATION {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return SATURATION_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.SATURATION_BAND,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ HUE {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return HUE_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.HUE_BAND,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ },
+ CYAN {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return CYAN_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.CYAN_BAND,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ }, MAGENTA {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return MAGENTA_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.MAGENTA_BAND,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ }, YELLOW {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return
+ YELLOW_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.YELLOW_BAND,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ }, KEY {
+ @Override
+ public DimensionlessAxisBin getAxisBin() {
+ return
+ KEY_BIN;
+ }
+
+ @Override
+ public BandType getBandType() {
+ return new BandType(
+ ColorInterpretation.BLACK_BAND,
+ null,
+ null,
+ null,
+ toString(),
+ toString(),
+ null);
+ }
+
+ @Override
+ public BandKey<String, Dimensionless> getBandKey() {
+ return new BandType.BandKey<String, Dimensionless>(Arrays.asList(getAxisBin()));
+ }
+ };
+
+ /**
+ * Axis covering the full {@link CMYK} range.
+ */
+ public static final Axis<Dimensionless> SYNTHETIC_COLOR_AXIS= new Axis<Dimensionless>("SyntheticColorAxis",  Unit.ONE );
+ private static final DimensionlessAxisBin KEY_BIN = new DimensionlessAxisBin(
+ new NameImpl("BLACK"),
+ new SimpleInternationalString("BLACK bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "BLACK");
+ private static final DimensionlessAxisBin YELLOW_BIN = new DimensionlessAxisBin(
+ new NameImpl("YELLOW"),
+ new SimpleInternationalString("YELLOW bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "YELLOW");
+ private static final DimensionlessAxisBin MAGENTA_BIN = new DimensionlessAxisBin(
+ new NameImpl("MAGENTA"),
+ new SimpleInternationalString("Magenta bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "MAGENTA");
+ private static final DimensionlessAxisBin CYAN_BIN = new DimensionlessAxisBin(
+ new NameImpl("CYAN"),
+ new SimpleInternationalString("CYAN bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "CYAN");
+ private static final DimensionlessAxisBin HUE_BIN = new DimensionlessAxisBin(
+ new NameImpl("HUE"),
+ new SimpleInternationalString("HUE bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "HUE");
+ private static final DimensionlessAxisBin SATURATION_BIN = new DimensionlessAxisBin(
+ new NameImpl("SATURATION"),
+ new SimpleInternationalString("SATURATION bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "SATURATION");
+ private static final DimensionlessAxisBin GREEN_BIN = new DimensionlessAxisBin(
+ new NameImpl("RED"),
+ new SimpleInternationalString("RED bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "RED");
+ private static final DimensionlessAxisBin BLUE_BIN = new DimensionlessAxisBin(
+ new NameImpl("BLUE"),
+ new SimpleInternationalString("BLUE bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "BLUE");
+ private static final DimensionlessAxisBin RED_BIN = GREEN_BIN;
+ private static final DimensionlessAxisBin PALETTE_BIN = new DimensionlessAxisBin(
+ new NameImpl("VALUE"),
+ new SimpleInternationalString("VALUE bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "VALUE");
+ private static final DimensionlessAxisBin UNDEFINED_BIN = new DimensionlessAxisBin(
+ new NameImpl("UNDEFINED"),
+ new SimpleInternationalString("UNDEFINED bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "UNDEFINED");
+ private static final DimensionlessAxisBin GRAY_BIN = new DimensionlessAxisBin(
+ new NameImpl("GRAY"),
+ new SimpleInternationalString("GRAY bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "GRAY");
+ private static final DimensionlessAxisBin ALPHA_BIN = new DimensionlessAxisBin(
+ new NameImpl("ALPHA"),
+ new SimpleInternationalString("ALPHA bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "ALPHA");
+ private static final DimensionlessAxisBin INTENSITY_BIN = new DimensionlessAxisBin(
+ new NameImpl("INTENSITY"),
+ new SimpleInternationalString("INTENSITY bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "INTENSITY");
+ private static final DimensionlessAxisBin CHROMA_B_BIN = new DimensionlessAxisBin(
+ new NameImpl("CHROMA-B"),
+ new SimpleInternationalString("CHROMA-B bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "CHROMA-B");
+ private static final DimensionlessAxisBin CHROMA_A_BIN = new DimensionlessAxisBin(
+ new NameImpl("CHROMA-A"),
+ new SimpleInternationalString("CHROMA-A bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "CHROMA-A");
+ private static final DimensionlessAxisBin LUMA_BIN = new DimensionlessAxisBin(
+ new NameImpl("LUMA"),
+ new SimpleInternationalString("LUMA bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "LUMA");
+ private static final DimensionlessAxisBin V_BIN = new DimensionlessAxisBin(
+ new NameImpl("V"),
+ new SimpleInternationalString("V bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "V");
+ private static final DimensionlessAxisBin U_BIN = new DimensionlessAxisBin(
+ new NameImpl("U"),
+ new SimpleInternationalString("U bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "U");
+ private static final DimensionlessAxisBin LIGHTNESS_BIN = new DimensionlessAxisBin(
+ new NameImpl("LIGHTNESS"),
+ new SimpleInternationalString("LIGHTNESS bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "LIGHTNESS");
+ private static final DimensionlessAxisBin B_BIN = new DimensionlessAxisBin(
+ new NameImpl("B"),
+ new SimpleInternationalString("B bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "B");
+ private static final DimensionlessAxisBin A_BIN = new DimensionlessAxisBin(
+ new NameImpl("A"),
+ new SimpleInternationalString("A bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "A");
+ private static final DimensionlessAxisBin Z_BIN = new DimensionlessAxisBin(
+ new NameImpl("Z"),
+ new SimpleInternationalString("Z bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "Z");
+ private static final DimensionlessAxisBin Y_BIN = new DimensionlessAxisBin(
+ new NameImpl("Y"),
+ new SimpleInternationalString("Y bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "Y");
+
+ public abstract DimensionlessAxisBin getAxisBin();
+
+ public abstract BandType getBandType();
+
+ public abstract BandKey<String, Dimensionless> getBandKey();
+
+ /**
+ * Helper classes for creating {@link DimensionlessAxis} for the most common color models' bands.
+ *
+ * <p>
+ * Suypported colorspaces incluse RGBA, GRAY, GRAYA, HSV,HLS, LAB, LUV, IHS, CI_XYZ, CMY(K).
+ * Notice that RGB is not handled here but through a wavelength axis.
+ *
+ * <p>
+ * This method returns null if an unsupported {@link ColorModel} is provided.
+ *
+ * @param raster a {@link RenderedImage} implementation from which to extract needed info, usually {@link ColorModel} and {@link SampleModel}.
+ * @return a {@link DimensionlessAxis} or null if an unsupported {@link ColorModel} is provided.
+ */
+ public static List<DimensionlessAxisBin> getBinsFromRenderedImage(final RenderedImage raster){
+ if(raster==null)
+ throw new NullPointerException("Provided null input image");
+
+ final ColorModel cm= raster.getColorModel();
+ if(cm==null)
+ throw new IllegalArgumentException("Provided input image with null color model");
+ final SampleModel sm= raster.getSampleModel();
+ if(sm==null)
+ throw new IllegalArgumentException("Provided input image with null SampleModel");
+
+ //get the color interpretation for the three bands
+ final ColorInterpretation firstBandCI = TypeMap.getColorInterpretation(cm, 0);
+
+ // CMY - CMYK
+ if(firstBandCI==ColorInterpretation.CYAN_BAND)
+ {
+ if(sm.getNumBands()==3)
+ {
+ return
+ Arrays.asList(
+ IMAGE_PROCESSING_ELEMENTS.CYAN.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.MAGENTA.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.YELLOW.getAxisBin()
+ );
+ }
+ else
+ {
+ return
+ Arrays.asList(
+ IMAGE_PROCESSING_ELEMENTS.CYAN.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.MAGENTA.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.YELLOW.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.KEY.getAxisBin()
+ );
+ }
+ }
+
+ // HSV
+ if(firstBandCI==ColorInterpretation.HUE_BAND)
+ {
+ return Collections.singletonList(IMAGE_PROCESSING_ELEMENTS.HUE.getAxisBin());
+ }
+
+ //RGBA
+ if(firstBandCI==ColorInterpretation.RED_BAND)
+ {
+ if(sm.getNumBands()==3)
+ {
+ return
+ Arrays.asList(
+ IMAGE_PROCESSING_ELEMENTS.RED.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.GREEN.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.BLUE.getAxisBin()
+ );
+ }
+ else
+ {
+ return
+ Arrays.asList(
+ IMAGE_PROCESSING_ELEMENTS.RED.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.GREEN.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.BLUE.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.ALPHA.getAxisBin()
+ );
+ }
+ }
+
+ //PALETTE
+ if(firstBandCI==ColorInterpretation.PALETTE_INDEX)
+ return Collections.singletonList(IMAGE_PROCESSING_ELEMENTS.PALETTE.getAxisBin());
+
+ // GRAY, GRAY+ALPHA
+ if(firstBandCI==ColorInterpretation.GRAY_INDEX)
+ {
+ if(sm.getNumBands()==2)
+ return Arrays.asList(
+ IMAGE_PROCESSING_ELEMENTS.GRAY.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.ALPHA.getAxisBin()
+ );
+ else
+ return Arrays.asList(
+ IMAGE_PROCESSING_ELEMENTS.GRAY.getAxisBin()
+ );
+
+ }
+
+
+ final ColorSpace cs = cm.getColorSpace();
+ //IHS
+ if(cs instanceof IHSColorSpace)
+ return Arrays.asList(
+ IMAGE_PROCESSING_ELEMENTS.INTENSITY.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.HUE.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.SATURATION.getAxisBin()
+ );
+
+ //YCbCr, LUV, LAB, HLS, IEXYZ
+ switch(cs.getType()){
+ case ColorSpace.TYPE_YCbCr:
+ return Arrays.asList(
+ IMAGE_PROCESSING_ELEMENTS.LUMA.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.CHROMA_A.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.CHROMA_B.getAxisBin()
+ );
+ case ColorSpace.TYPE_Luv:
+ return Arrays.asList(
+ IMAGE_PROCESSING_ELEMENTS.LIGHTNESS.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.U.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.V.getAxisBin()
+ );
+ case ColorSpace.TYPE_Lab:
+ return Arrays.asList(
+ IMAGE_PROCESSING_ELEMENTS.LIGHTNESS.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.A.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.B.getAxisBin()
+ );
+ case ColorSpace.TYPE_HLS:
+ return Arrays.asList(
+ IMAGE_PROCESSING_ELEMENTS.HUE.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.LIGHTNESS.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.SATURATION.getAxisBin()
+ );
+ case ColorSpace.CS_CIEXYZ:
+ return Arrays.asList(
+ IMAGE_PROCESSING_ELEMENTS.X.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.Y.getAxisBin(),
+ IMAGE_PROCESSING_ELEMENTS.Z.getAxisBin()
+ );
+
+ default:
+ return null;
+
+
+ }
+ }
+
+ public static FieldType<String,Dimensionless> getFieldTypeFromRenderedImage(final RenderedImage raster){
+ if(raster==null)
+ throw new NullPointerException("Provided null input image");
+
+ final ColorModel cm= raster.getColorModel();
+ if(cm==null)
+ throw new IllegalArgumentException("Provided input image with null color model");
+ final SampleModel sm= raster.getSampleModel();
+ if(sm==null)
+ throw new IllegalArgumentException("Provided input image with null SampleModel");
+
+ //get the color interpretation for the three bands
+ final ColorInterpretation firstBandCI = TypeMap.getColorInterpretation(cm, 0);
+
+ // get axis for this fieldtype and prepare the map for the band type
+ final HashMap<BandKey<String, Dimensionless>, BandType> bands= new HashMap<BandKey<String,Dimensionless>, BandType>();
+
+
+ // CMY - CMYK
+ if(firstBandCI==ColorInterpretation.CYAN_BAND)
+ {
+ if(sm.getNumBands()==3)
+ {
+ bands.put(IMAGE_PROCESSING_ELEMENTS.CYAN.getBandKey(), IMAGE_PROCESSING_ELEMENTS.CYAN.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.MAGENTA.getBandKey(), IMAGE_PROCESSING_ELEMENTS.MAGENTA.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.YELLOW.getBandKey(), IMAGE_PROCESSING_ELEMENTS.YELLOW.getBandType());
+ }
+ else
+ {
+ bands.put(IMAGE_PROCESSING_ELEMENTS.CYAN.getBandKey(), IMAGE_PROCESSING_ELEMENTS.CYAN.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.MAGENTA.getBandKey(), IMAGE_PROCESSING_ELEMENTS.MAGENTA.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.YELLOW.getBandKey(), IMAGE_PROCESSING_ELEMENTS.YELLOW.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.KEY.getBandKey(), IMAGE_PROCESSING_ELEMENTS.KEY.getBandType());
+
+ }
+ }
+
+ // HSV
+ if(firstBandCI==ColorInterpretation.HUE_BAND)
+ {
+ bands.put(IMAGE_PROCESSING_ELEMENTS.HUE.getBandKey(), IMAGE_PROCESSING_ELEMENTS.HUE.getBandType());
+ }
+
+ //RGB(A)
+ if(firstBandCI==ColorInterpretation.RED_BAND)
+ {
+ if(sm.getNumBands()==3)
+ {
+ bands.put(IMAGE_PROCESSING_ELEMENTS.RED.getBandKey(), IMAGE_PROCESSING_ELEMENTS.RED.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.GREEN.getBandKey(), IMAGE_PROCESSING_ELEMENTS.GREEN.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.BLUE.getBandKey(), IMAGE_PROCESSING_ELEMENTS.BLUE.getBandType());
+ }
+ else
+ {
+ bands.put(IMAGE_PROCESSING_ELEMENTS.RED.getBandKey(), IMAGE_PROCESSING_ELEMENTS.RED.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.GREEN.getBandKey(), IMAGE_PROCESSING_ELEMENTS.GREEN.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.BLUE.getBandKey(), IMAGE_PROCESSING_ELEMENTS.BLUE.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.ALPHA.getBandKey(), IMAGE_PROCESSING_ELEMENTS.ALPHA.getBandType());
+
+ }
+ }
+
+ //PALETTE
+ if(firstBandCI==ColorInterpretation.PALETTE_INDEX)
+ {
+ bands.put(IMAGE_PROCESSING_ELEMENTS.PALETTE.getBandKey(), IMAGE_PROCESSING_ELEMENTS.PALETTE.getBandType());
+ }
+
+ // GRAY, GRAY+ALPHA
+ if(firstBandCI==ColorInterpretation.GRAY_INDEX)
+ {
+ if(sm.getNumBands()==2)
+ {
+
+ bands.put(IMAGE_PROCESSING_ELEMENTS.GRAY.getBandKey(), IMAGE_PROCESSING_ELEMENTS.GRAY.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.ALPHA.getBandKey(), IMAGE_PROCESSING_ELEMENTS.ALPHA.getBandType());
+ }
+ else
+ bands.put(IMAGE_PROCESSING_ELEMENTS.GRAY.getBandKey(), IMAGE_PROCESSING_ELEMENTS.GRAY.getBandType());
+
+ }
+
+
+ final ColorSpace cs = cm.getColorSpace();
+ //IHS
+ if(cs instanceof IHSColorSpace){
+ bands.put(IMAGE_PROCESSING_ELEMENTS.INTENSITY.getBandKey(), IMAGE_PROCESSING_ELEMENTS.INTENSITY.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.HUE.getBandKey(), IMAGE_PROCESSING_ELEMENTS.HUE.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.SATURATION.getBandKey(), IMAGE_PROCESSING_ELEMENTS.SATURATION.getBandType());
+ }
+
+ if(bands.isEmpty()){
+ //YCbCr, LUV, LAB, HLS, IEXYZ
+ switch(cs.getType()){
+ case ColorSpace.TYPE_YCbCr:
+ bands.put(IMAGE_PROCESSING_ELEMENTS.LUMA.getBandKey(), IMAGE_PROCESSING_ELEMENTS.LUMA.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.CHROMA_A.getBandKey(), IMAGE_PROCESSING_ELEMENTS.CHROMA_A.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.CHROMA_B.getBandKey(), IMAGE_PROCESSING_ELEMENTS.CHROMA_B.getBandType());
+ break;
+
+ case ColorSpace.TYPE_Luv:
+ bands.put(IMAGE_PROCESSING_ELEMENTS.LIGHTNESS.getBandKey(), IMAGE_PROCESSING_ELEMENTS.LIGHTNESS.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.U.getBandKey(), IMAGE_PROCESSING_ELEMENTS.U.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.V.getBandKey(), IMAGE_PROCESSING_ELEMENTS.V.getBandType());
+ break;
+
+ case ColorSpace.TYPE_Lab:
+ bands.put(IMAGE_PROCESSING_ELEMENTS.LIGHTNESS.getBandKey(), IMAGE_PROCESSING_ELEMENTS.LIGHTNESS.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.A.getBandKey(), IMAGE_PROCESSING_ELEMENTS.A.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.B.getBandKey(), IMAGE_PROCESSING_ELEMENTS.B.getBandType());
+ break;
+
+ case ColorSpace.TYPE_HLS:
+ bands.put(IMAGE_PROCESSING_ELEMENTS.HUE.getBandKey(), IMAGE_PROCESSING_ELEMENTS.HUE.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.LIGHTNESS.getBandKey(), IMAGE_PROCESSING_ELEMENTS.LIGHTNESS.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.SATURATION.getBandKey(), IMAGE_PROCESSING_ELEMENTS.SATURATION.getBandType());
+ break;
+ case ColorSpace.CS_CIEXYZ:
+ bands.put(IMAGE_PROCESSING_ELEMENTS.X.getBandKey(), IMAGE_PROCESSING_ELEMENTS.X.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.Y.getBandKey(), IMAGE_PROCESSING_ELEMENTS.Y.getBandType());
+ bands.put(IMAGE_PROCESSING_ELEMENTS.Z.getBandKey(), IMAGE_PROCESSING_ELEMENTS.Z.getBandType());
+ break;
+
+ default:
+ throw new IllegalArgumentException("Unable to create FieldType for this rendered image");
+
+ }
+ }
+ //build the field type
+ return new FieldType<String, Dimensionless>(
+ new NameImpl("RenderedImageFieldType"),
+ new SimpleInternationalString("FieldType for rendered image"),
+ Unit.ONE,
+ Collections.singletonList(SYNTHETIC_COLOR_AXIS),
+ bands);
+ }
+
+ private final static DimensionlessAxisBin X_BIN=new DimensionlessAxisBin(
+ new NameImpl("X"),
+ new SimpleInternationalString("X bin"),
+ SYNTHETIC_COLOR_AXIS,
+ "X");
+}
\ No newline at end of file


Property changes on: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/IMAGE_PROCESSING_ELEMENTS.java
___________________________________________________________________
Added: svn:eol-style
   + native

Deleted: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/SimpleScalarAxis.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/SimpleScalarAxis.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/SimpleScalarAxis.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,54 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- *
- *    (C) 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.coverage.io.impl.range;
-
-import java.util.Collections;
-
-import org.geotools.coverage.io.range.Axis;
-import org.geotools.coverage.io.range.FieldType;
-import org.opengis.feature.type.Name;
-import org.opengis.util.InternationalString;
-
-/**
- * Implementation of a simple {@link Axis} which can be used when modeling scalar {@link FieldType}s like
- * temperature or pressure which do need extra {@link Axis} instances to describe their codomain.
- *
- * @author Simone Giannecchini, GeoSolutions
- *
- */
-public class SimpleScalarAxis extends DimensionlessAxis {
- public static final String DEFAUL_BAND_NAME="0";
-
- /**
- *
- * @param bandName
- * @param name
- * @param description
- */
- public SimpleScalarAxis(final String bandName,final Name name, final InternationalString description){
- super(Collections.singletonList(bandName), name, description);
- }
- /**
- *
- * @param name
- * @param description
- */
- public SimpleScalarAxis(final Name name, final InternationalString description){
- super(Collections.singletonList(DEFAUL_BAND_NAME), name, description);
- }
-
-}

Modified: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/WavelengthAxis.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/WavelengthAxis.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/impl/range/WavelengthAxis.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -7,17 +7,19 @@
 import java.util.Map;
 
 import javax.measure.Measure;
-import javax.measure.converter.UnitConverter;
 import javax.measure.quantity.Length;
 import javax.measure.unit.SI;
 import javax.measure.unit.Unit;
 
 import org.geotools.coverage.io.range.Axis;
+import org.geotools.coverage.io.range.AxisBin;
+import org.geotools.coverage.io.range.RangeUtilities;
 import org.geotools.feature.NameImpl;
 import org.geotools.referencing.crs.DefaultEngineeringCRS;
 import org.geotools.referencing.cs.DefaultCoordinateSystemAxis;
 import org.geotools.referencing.cs.DefaultLinearCS;
 import org.geotools.referencing.datum.DefaultEngineeringDatum;
+import org.geotools.util.MeasurementRange;
 import org.geotools.util.SimpleInternationalString;
 import org.opengis.feature.type.Name;
 import org.opengis.referencing.crs.SingleCRS;
@@ -27,159 +29,124 @@
 import org.opengis.util.InternationalString;
 
 
-public class WavelengthAxis<V> extends Axis<V,Length>{
+public class WavelengthAxis extends Axis<Length>{
+
  /**
- * A single band.
+ * Singleton instance of a {@link WavelengthAxis} that measures in nanometers.
  */
- public static class Band extends Measure<Double,Length>{
- private static final long serialVersionUID = -4651829687224844766L;
- private String description;
- private double minValue;
- private double maxValue;
- private String name;
-
- Band( String band, double value, String description ){
- this.name = band;
- this.minValue = value;
- this.maxValue = value;
- this.description = description;
+ public final static WavelengthAxis WAVELENGTH_AXIS_NM= new WavelengthAxis("WAVELENGTH_AXIS_NM",RangeUtilities.WAVELENGTH_UOM);
+
+    /**
+ * A bin for the wavelength axis
+ */
+ public static class WavelengthBin extends AxisBin<MeasurementRange<Double>,Length>{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3977921692927799401L;
+
+ public WavelengthBin( Name name, double value, InternationalString description, WavelengthAxis axis ){
+ super(
+ name,
+ description,
+ axis,
+ MeasurementRange.create(value, value, RangeUtilities.WAVELENGTH_UOM));
+
  }
- Band( String band, double from, double to, String description ) {
- this.name = band;
- this.minValue = from;
- this.maxValue = to;
- this.description = description;
+
+ public WavelengthBin( String name, double value, String description, WavelengthAxis axis ){
+ super(
+ new NameImpl(name),
+ new SimpleInternationalString(description),
+ axis,
+ MeasurementRange.create(value, value, RangeUtilities.WAVELENGTH_UOM));
+
+ }
+
+
+ public WavelengthBin( Name name, double from, double to, InternationalString description, WavelengthAxis axis ) {
+ super(
+ name,
+ description,
+ axis,
+ MeasurementRange.create(from, to, RangeUtilities.WAVELENGTH_UOM));
  }
- @Override
- public double doubleValue(Unit<Length> length) {
- UnitConverter converter = SI.MICRO(SI.METER).getConverterTo( length );
- return converter.convert( getValue() );
- }
+ public WavelengthBin( String name, double from, double to, String description, WavelengthAxis axis ) {
+ super(
+ new NameImpl(name),
+ new SimpleInternationalString(description),
+ axis,
+ MeasurementRange.create(from, to, RangeUtilities.WAVELENGTH_UOM));
+ }
+ }
 
- @Override
- public Unit<Length> getUnit() {
- return SI.NANO(SI.METER);
- }
+ /**
+ * Keys for this {@link Axis}.
+ */
+ private ArrayList<Measure<MeasurementRange<Double>, Length>> keys;
+
+ private NameImpl name;
 
- @Override
- public java.lang.Double getValue() {
- return (minValue + maxValue) / 2.0;
- }
- public String getName(){
- return name;
- }
- public String getDescription(){
- return description;
- }
- @Override
- public Measure<java.lang.Double, Length> to(Unit<Length> length) {
- return Measure.valueOf( doubleValue(length), length );
- }
- }
- /** Violet light between 380-450 nm */
- public static final Band COLOR_VIOLET
- = new Band( "Violet", 380, 450, "Visible light between 380-450 nm" );
+ /** LANDSAT7 definition of BLUE */
+ public static final WavelengthBin LANDSAT7_BLUE_AXIS_BIN= new WavelengthBin( "BLUE", 450, 520, "useful for soil/vegetation discrimination, forest type mapping, and identifying man-made features",WavelengthAxis.WAVELENGTH_AXIS_NM);
+
  /** Blue light between 450-495 nm */
- public static final Band COLOR_BLUE
- = new Band( "Blue", 450, 495, "Visible light between 450-495 nm" );
+ public static final WavelengthBin COLOR_BLUE_AXIS_BIN= new WavelengthBin( "Blue", 450, 495, "Visible light between 450-495 nm" ,WavelengthAxis.WAVELENGTH_AXIS_NM);
+
  /** Green light between 495-570 nm */
- public static final Band COLOR_GREEN
- = new Band( "Green", 495, 570, "Visible light between 495-570 nm" );
- /** Yellow between 570-590 nm */
- public static final Band COLOR_YELLOW
- = new Band( "Yellow", 570,590, "Visible light between 570-590 nm" );
+ public static final WavelengthBin COLOR_GREEN_AXIS_BIN= new WavelengthBin( "Green", 495, 570, "Visible light between 495-570 nm" ,WavelengthAxis.WAVELENGTH_AXIS_NM);
+
  /** Orange light between 590-620 nm */
- public static final Band COLOR_ORANGE
- = new Band( "Green", 590,620, "Visible light between 590-620 nm" );
+ public static final WavelengthBin COLOR_ORANGE_AXIS_BIN= new WavelengthBin( "Green", 590,620, "Visible light between 590-620 nm",WavelengthAxis.WAVELENGTH_AXIS_NM );
+
  /** Red between 620-750 nm */
- public static final Band COLOR_RED
- = new Band( "Yellow", 620, 750, "Visible light between 620-750 nm" );
-
-
- /** LANDSAT7 definition of BLUE */
- public static final Band BLUE
- = new Band( "BLUE", 450, 520, "useful for soil/vegetation discrimination, forest type mapping, and identifying man-made features");
-
+ public static final WavelengthBin COLOR_RED_AXIS_BIN= new WavelengthBin( "Yellow", 620, 750, "Visible light between 620-750 nm" ,WavelengthAxis.WAVELENGTH_AXIS_NM);
+
+ /** Violet light between 380-450 nm */
+ public static final WavelengthBin COLOR_VIOLET_AXIS_BIN= new WavelengthBin( "Violet", 380, 450, "Visible light between 380-450 nm" ,WavelengthAxis.WAVELENGTH_AXIS_NM);
+
+ /** Yellow between 570-590 nm */
+ public static final WavelengthBin COLOR_YELLOW_AXIS_BIN= new WavelengthBin( "Yellow", 570,590, "Visible light between 570-590 nm" ,WavelengthAxis.WAVELENGTH_AXIS_NM);
+
  /** LANDSAT7 definition of GREEN */
- public static  final Band GREEN
- = new Band( "GREEN", 520, 610, "penetrates clear water fairly well, and gives excellent contrast between clear and turbid (muddy) water.");
-
- /** LANDSAT7 definition of RED */
- public static  final Band RED
- = new Band("RED",  630, 690, "useful for identifying vegetation types, soils, and urban (city and town) features");
-
+ public static  final WavelengthBin GREEN_AXIS_BIN= new WavelengthBin( "GREEN", 520, 610, "penetrates clear water fairly well, and gives excellent contrast between clear and turbid (muddy) water.",WavelengthAxis.WAVELENGTH_AXIS_NM);
+
  /** LANDSAT7 definition of NIR */
- public static  final Band NIR =
- new Band("NIR", 750, 900, " good for mapping shorelines and biomass content");
-
+ public static  final WavelengthBin NIR_AXIS_BIN =new WavelengthBin("NIR", 750, 900, " good for mapping shorelines and biomass content",WavelengthAxis.WAVELENGTH_AXIS_NM);
+
+ /** LANDSAT7 definition of RED */
+ public static  final WavelengthBin RED_AXIS_BIN= new WavelengthBin("RED",  630, 690, "useful for identifying vegetation types, soils, and urban (city and town) features",WavelengthAxis.WAVELENGTH_AXIS_NM);
+
  /** LANDSAT7 definition of SWIR */
- public static  final Band SWIR =
- new Band("SWIR", 1550, 17560, "useful to measure the moisture content of soil and vegetation");
-
- /** LANDSAT7 definition of TIR */
- public static  final Band TIR
- = new Band("TIR", 10400, 12500, "useful to observe temperature");
+ public static  final WavelengthBin SWIR_AXIS_BIN =new WavelengthBin("SWIR", 1550, 17560, "useful to measure the moisture content of soil and vegetation",WavelengthAxis.WAVELENGTH_AXIS_NM);
 
  /** LANDSAT7 definition of SWIR2 */
- public static  final Band SWIR2
- = new Band("SWIR2", 2080, 23500, "useful to measure the moisture content of soil and vegetation");
-
- /**
- * Keys for this {@link Axis}.
- */
- private ArrayList<Measure<V, Length>> keys;
- private NameImpl name;
+ public static  final WavelengthBin SWIR2_AXIS_BIN= new WavelengthBin("SWIR2", 2080, 23500, "useful to measure the moisture content of soil and vegetation",WavelengthAxis.WAVELENGTH_AXIS_NM);
+
+ /** LANDSAT7 definition of TIR */
+ public static  final WavelengthBin TIR_AXIS_BIN= new WavelengthBin("TIR", 10400, 12500, "useful to observe temperature",WavelengthAxis.WAVELENGTH_AXIS_NM);
 
- /**
- * Bands associated with RGB images.
- * <p>
- * Currently this is defined using COLOR_RED, COLOR_GREEN and COLOR_BLUE.
- * This definition should be updated to use the standard sRGB definitions.
- */
- public static final WavelengthAxis<Double> RGB;
- static {
- final List<Band> RGB_BANDS = new ArrayList<Band>();
- RGB_BANDS.add( COLOR_RED );
- RGB_BANDS.add( COLOR_GREEN );
- RGB_BANDS.add( COLOR_BLUE );
-
- RGB = new WavelengthAxis<Double>("RGB-AXIS", RGB_BANDS );
- }
-
- /**
- * Bands associated with LANDSAT8 readings.
- */
- public static final WavelengthAxis<Double> LANDSAT7;
-
- static {
- final List<Band> LANDSAT_BANDS = new ArrayList<Band>();
- LANDSAT_BANDS.add(WavelengthAxis.BLUE);
- LANDSAT_BANDS.add(WavelengthAxis.GREEN);
- LANDSAT_BANDS.add(WavelengthAxis.RED);
- LANDSAT_BANDS.add(WavelengthAxis.NIR);
- LANDSAT_BANDS.add(WavelengthAxis.SWIR);
- LANDSAT_BANDS.add(WavelengthAxis.TIR);
- LANDSAT_BANDS.add(WavelengthAxis.SWIR2);
- LANDSAT7 = new WavelengthAxis<Double>("LANDSAT7-AXIS", LANDSAT_BANDS);
- }
-
  private static final DefaultEngineeringCRS CRS;
  static {
- CoordinateSystemAxis csAxis = new DefaultCoordinateSystemAxis(
+ final CoordinateSystemAxis csAxis = new DefaultCoordinateSystemAxis(
  new SimpleInternationalString("Light"),
  "\u03BB", // LAMBDA
  AxisDirection.OTHER,
- SI.MICRO(SI.METER));
- DefaultLinearCS lightCS = new DefaultLinearCS("Light",csAxis);
- Map<String,Object> datumProperties = new HashMap<String,Object>();
+ RangeUtilities.WAVELENGTH_UOM);
+ final DefaultLinearCS lightCS = new DefaultLinearCS("Light",csAxis);
+ final Map<String,Object> datumProperties = new HashMap<String,Object>();
  datumProperties.put("name", "light");
 
- EngineeringDatum lightDatum = new DefaultEngineeringDatum( datumProperties );
+ final EngineeringDatum lightDatum = new DefaultEngineeringDatum( datumProperties );
  CRS = new DefaultEngineeringCRS("Wave Length", lightDatum, lightCS );
  }
 
- public WavelengthAxis(String name, final List<? extends Measure<V, Length>> keys) {
- super(new NameImpl(name),new SimpleInternationalString(name),keys,Length.UNIT);
+ /**
+ *
+ */
+ public WavelengthAxis(final String name, final Unit<Length> uom) {
+ super(new NameImpl(name),new SimpleInternationalString(name),uom);
  }
  /**
  * These are units of length; as such the are
@@ -193,11 +160,11 @@
  return new SimpleInternationalString("Spectral Information");
  }
 
- public Measure<V, Length> getKey(int keyIndex) {
+ public Measure<MeasurementRange<Double>, Length> getKey(int keyIndex) {
  return this.keys.get(keyIndex);
  }
 
- public List<Measure<V, Length>> getKeys() {
+ public List<Measure<MeasurementRange<Double>, Length>> getKeys() {
  return Collections.unmodifiableList(keys);
  }
 

Modified: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/Axis.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/Axis.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/Axis.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -16,16 +16,11 @@
  */
 package org.geotools.coverage.io.range;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.measure.Measurable;
-import javax.measure.Measure;
 import javax.measure.quantity.Quantity;
 import javax.measure.unit.Unit;
 
 import org.geotools.feature.NameImpl;
+import org.geotools.referencing.CRS;
 import org.geotools.util.SimpleInternationalString;
 import org.opengis.feature.type.Name;
 import org.opengis.referencing.crs.SingleCRS;
@@ -34,46 +29,50 @@
 /**
  * Definition of one axis in a field for which we have some
  * measurements/observations/forecasts. The {@link Axis} data structure
- * describes the nature of each control variable for a certain {@link Field},
- * moreover it indicates as {@link Measurable}s the keys used to control each
- * Field subset.
+ * describes the nature of each control variable for a certain {@link FieldType}
  *
- * <p>
- * Note that in order to comply with the WCS spec we need to have the
- * possibility to encode {@link Measurable}s as {@link String}s.
  *
  * @author Simone Giannecchini, GeoSolutions
- * @param V Value being used to define this Axis
- * @param QA Quantity being represented by this Axis
  */
-public class Axis<V,Q extends Quantity>{
+public class Axis<Q extends Quantity>{
+
+
+
  private SingleCRS crs;
  private InternationalString description;
- private List<Measure<V,Q>> keys;
  private Name name;
  private Unit<Q> unit;
 
- public Axis( String name, Measure<V,Q> key, Unit<Q> unit){
- this( new NameImpl( name ), new SimpleInternationalString( name ), Collections.singletonList(key), unit, null );
+ public Axis( String name, Unit<Q> unit){
+ this( new NameImpl( name ), new SimpleInternationalString( name ),unit );
  }
 
- public Axis( String name, List<Measure<V,Q>> keys, Unit<Q> unit){
- this( new NameImpl( name ), new SimpleInternationalString( name ), keys, unit, null );
- }
-
- public Axis( Name name, InternationalString description, List<? extends Measure<V,Q>> keys, Unit<Q> unit){
- this( name, description, keys, unit, null );
- }
-
- public Axis( Name name, InternationalString description, List<? extends Measure<V,Q>> keys, Unit<Q> unit, SingleCRS crs ){
+ public Axis( Name name, InternationalString description, Unit<Q> unit){
  this.name = name;
  this.unit = unit;
  this.description = description;
- this.keys = new ArrayList<Measure<V,Q>>( keys );
+ }
+
+ @SuppressWarnings("unchecked")
+ public Axis( Name name, InternationalString description, SingleCRS crs ){
+ this(name, description,  getUoM(crs));
  this.crs = crs;
  }
 
-    /**
+ public Axis( String name, String description, SingleCRS crs ){
+ this(new NameImpl(name), new SimpleInternationalString(description),  crs);
+ }
+
+ public Axis( String name, SingleCRS crs ){
+ this(new NameImpl(name), new SimpleInternationalString(name),  crs);
+ }
+
+ @SuppressWarnings("unchecked")
+    private static Unit getUoM(SingleCRS crs) {
+ return crs.getCoordinateSystem().getAxis(0).getUnit();
+ }
+
+ /**
      * Retrieves the coordinate reference system for this {@link Axis}.
      *
      * <p>
@@ -99,24 +98,6 @@
  }
 
     /**
-     * Retrieves a specific key for this {@link Axis}.
-     *
-     * @return Retrieves a specific key for this {@link Axis}.
-     */
- public Measure<V, Q> getKey(int keyIndex) {
- return keys.get( keyIndex );
- }
-
-    /**
-     * Retrieves the list of keys for this {@link Axis}.
-     *
-     * @return Retrieves the list of keys for this {@link Axis}.
-     */
- public List<? extends Measure<V, Q>> getKeys() {
- return Collections.unmodifiableList(keys);
- }
-
-    /**
      * Retrieves the {@link Axis} name
      *
      * @return {@link org.opengis.feature.type.Name} of the {@link Axis}s
@@ -126,15 +107,6 @@
  }
 
     /**
-     * Retrieves the number of keys for this {@link Axis}.
-     *
-     * @return Retrieves the number of keys for this {@link Axis}.
-     */
- public int getNumKeys() {
- return keys.size();
- }
-
-    /**
      * Retrieves the Unit of measure for the various keys of this axis.
      *
      * In case this {@link Axis} is not made of measurable quantities
@@ -145,4 +117,67 @@
  return unit;
  }
 
+ public <V> boolean isBinCompatible(final AxisBin<V, Q> bin){
+ return bin.getAxis().equals(this);
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder= new StringBuilder();
+ builder.append("Axis description").append("\n");
+ builder.append("Name:").append("\t\t\t\t\t").append(name.toString()).append("\n");
+ builder.append("Description:").append("\t\t\t\t").append(description.toString()).append("\n");
+ builder.append("Unit:").append("\t\t\t\t\t").append(unit!=null?unit.toString():"null uom").append("\n");
+ builder.append("crs:").append("\t\t\t\t\t").append(crs!=null?crs.toString():"null crs").append("\n");
+ return builder.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((crs == null) ? 0 : crs.hashCode());
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((unit == null) ? 0 : unit.hashCode());
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+
+ Axis that = (Axis) obj;
+
+ if (crs == null) {
+ if (that.crs != null)
+ return false;
+ } else if (!CRS.equalsIgnoreMetadata(crs,that.crs))
+ return false;
+
+ if (description == null) {
+ if (that.description != null)
+ return false;
+ } else if (!description.toString().equalsIgnoreCase(that.description.toString()))
+ return false;
+
+ if (name == null) {
+ if (that.name != null)
+ return false;
+ } else if (!name.toString().equalsIgnoreCase(that.name.toString()))
+ return false;
+
+ if (unit == null) {
+ if (that.unit != null)
+ return false;
+ } else if (!unit.equals(that.unit))
+ return false;
+ return true;
+ }
 }

Added: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/AxisBin.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/AxisBin.java                        (rev 0)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/AxisBin.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -0,0 +1,73 @@
+package org.geotools.coverage.io.range;
+
+import javax.measure.quantity.Quantity;
+import javax.measure.unit.Unit;
+
+import org.opengis.feature.type.Name;
+import org.opengis.util.InternationalString;
+
+/**
+ *
+ * @author Simone Giannecchini, GeoSolutions S.A.S.
+ *
+ * @param <V>
+ * @param <QA>
+ */
+public abstract class AxisBin<V, QA extends Quantity>{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 227920699316120413L;
+
+ /**
+ * The {@link AxisBin} instance that is used as a reference by this {@link AxisBin}.
+ */
+ private Axis<QA> axis;
+
+ public AxisBin(
+ final Name name,
+ final InternationalString description,
+ final Axis<QA> axis,
+ final V value) {
+ this.description = description;
+ this.name = name;
+ this.axis=axis;
+ this.value=value;
+ }
+ private V value;
+ private InternationalString description;
+ private Name name;
+ public InternationalString getDescription(){
+ return description;
+ }
+
+ public Name getName(){
+ return name;
+ }
+
+
+ public Unit<QA> getUnit() {
+ return axis.getUnitOfMeasure();
+ }
+
+ public V getValue() {
+ return value;
+ }
+
+ public Axis<QA> getAxis(){
+ return axis;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder= new StringBuilder();
+ builder.append("Axis  bin description").append("\n");
+ builder.append("Name:").append("\t\t\t\t\t").append(name.toString()).append("\n");
+ builder.append("Description:").append("\t\t\t\t").append(description.toString()).append("\n");
+ builder.append("Value:").append("\t\t\t\t\t").append(value.toString()).append("\n");
+ builder.append("Axis:").append("\n").append(axis.toString()).append("\n");
+ return builder.toString();
+ }
+
+
+}


Property changes on: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/AxisBin.java
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/Band.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/Band.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/Band.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,17 +1,22 @@
 package org.geotools.coverage.io.range;
 
-import java.util.Set;
 
 import javax.media.jai.Histogram;
 
 import org.geotools.coverage.io.metadata.MetadataNode;
 import org.geotools.util.Range;
-import org.opengis.annotation.Extension;
+import org.opengis.coverage.ColorInterpretation;
+import org.opengis.coverage.SampleDimensionType;
 import org.opengis.feature.type.Name;
 import org.opengis.referencing.operation.MathTransform1D;
 import org.opengis.util.InternationalString;
 import org.opengis.util.ProgressListener;
-
+/**
+ *
+ * @author Simone Giannecchini, GeoSolutions
+ *
+ */
+@SuppressWarnings("deprecation")
 public abstract class Band {
 
 
@@ -80,9 +85,10 @@
  * @param metadataDomain
  * @return
  */
- public MetadataNode getMetadata(String metadataDomain){
- return null;
-
- }
+ public abstract MetadataNode getMetadata(String metadataDomain);
+
+ public abstract ColorInterpretation getColorInterpretation() ;
+
+ public abstract SampleDimensionType getSampleDimensionType() ;
 
 }

Modified: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/BandType.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/BandType.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/BandType.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,14 +1,15 @@
 package org.geotools.coverage.io.range;
 
+
+import java.util.ArrayList;
 import java.util.List;
 
-import javax.measure.Measure;
 import javax.measure.quantity.Quantity;
-import javax.measure.unit.Unit;
 
-import org.geotools.util.Range;
+import org.geotools.feature.NameImpl;
+import org.geotools.util.NumberRange;
+import org.geotools.util.SimpleInternationalString;
 import org.geotools.util.Utilities;
-import org.opengis.annotation.Extension;
 import org.opengis.coverage.ColorInterpretation;
 import org.opengis.coverage.Coverage;
 import org.opengis.coverage.SampleDimensionType;
@@ -35,17 +36,24 @@
  *   </TD></TR>
  * </TABLE>
  *
- * @version <A HREF="http://www.opengis.org/docs/01-004.pdf">Grid Coverage specification 1.0</A>
- * @author  Martin Desruisseaux (IRD)
- * @since   GeoAPI 1.0
+ * @author Simone Giannecchini, GeoSolutions S.A.S.
  */
-public interface BandType {
-    public static class BandKey<V,QA extends Quantity> {
+@SuppressWarnings("deprecation")
+public class BandType {
+
+ /**
+ *
+ * @author Simone Giannecchini, GeoSolutions S.A.S.
+ *
+ * @param <V>
+ * @param <QA>
+ */
+ public static class BandKey<V,QA extends Quantity> {
 
- private final List<Measure<V,QA>> bins;
+ private final List<AxisBin<V,QA>> bins;
 
- public BandKey(final List<Measure<V, QA>> bins) {
- this.bins = bins;
+ public BandKey(final List<? extends AxisBin<V, QA>> bins) {
+ this.bins = new ArrayList<AxisBin<V,QA>>(bins);
  }
 
 
@@ -69,8 +77,8 @@
  public String toString() {
  final StringBuilder builder= new StringBuilder();
  builder.append("Description of band key:").append("\n");
- for(Measure<V,QA> bin:bins){
- builder.append("Description of bin:\t\t").append(bin.toString()).append("\n");
+ for(AxisBin<V,QA> bin:bins){
+ builder.append("Description of bin:\n").append(bin.toString()).append("\n");
  }
  return builder.toString();
  }
@@ -78,90 +86,73 @@
 
  }
 
- /**
-     * Sample dimension title or description.
-     * This string may be null or empty if no description is present.
-     *
-     * @return A description for this sample dimension.
-     */
-    InternationalString getDescription();
-    
-    public Name getName() ;
+ public BandType(ColorInterpretation colorInterpretation,
+ double[] defaultNoDatavalues, NumberRange<Double> defaultRange,
+ MathTransform1D defaultSampleTransformation, String name,
+ String description,
+ SampleDimensionType sampleDimensionType) {
+ super();
+ this.defaultColorInterpretation = colorInterpretation;
+ this.defaultNoDatavalues = defaultNoDatavalues;
+ this.defaultRange = defaultRange;
+ this.defaultSampleTransformation = defaultSampleTransformation;
+ this.name = new NameImpl(name);
+ this.description = new SimpleInternationalString(description);
+ this.defaultSampleDimensionType = sampleDimensionType;
+ }
+ public BandType(ColorInterpretation colorInterpretation,
+ double[] defaultNoDatavalues, NumberRange<Double> defaultRange,
+ MathTransform1D defaultSampleTransformation, Name name,
+ InternationalString description,
+ SampleDimensionType sampleDimensionType) {
+ super();
+ this.defaultColorInterpretation = colorInterpretation;
+ this.defaultNoDatavalues = defaultNoDatavalues;
+ this.defaultRange = defaultRange;
+ this.defaultSampleTransformation = defaultSampleTransformation;
+ this.name = name;
+ this.description = description;
+ this.defaultSampleDimensionType = sampleDimensionType;
+ }
+ public ColorInterpretation getDefaultColorInterpretation() {
+ return defaultColorInterpretation;
+ }
 
-    /**
-     * A code value indicating grid value data type.
-     * This will also indicate the number of bits for the data type.
-     *
-     * @return A code value indicating grid value data type.
-     * TODO convert me into enum
-     */
-    SampleDimensionType getSampleDimensionType();
+ public double[] getDefaultNoDatavalues() {
+ return defaultNoDatavalues;
+ }
 
+ public NumberRange<Double> getDefaultRange() {
+ return defaultRange;
+ }
 
-    /**
-     * Color interpretation of the sample dimension.
-     * A sample dimension can be an index into a color palette or be a color model
-     * component. If the sample dimension is not assigned a color interpretation the
-     * value is {@link ColorInterpretation#UNDEFINED UNDEFINED}.
-     *
-     * @return The color interpretation of the sample dimension.
-     *
-     * @deprecated No replacement.
-     * TODO convert me into enum
-     */
-    ColorInterpretation getColorInterpretation();
+ public MathTransform1D getDefaultSampleTransformation() {
+ return defaultSampleTransformation;
+ }
 
-    /**
-     * Values to indicate no data values for the sample dimension.
-     * For low precision sample dimensions, this will often be no data values.
-     *
-     * @return The values to indicate no data values for the sample dimension.
-     *
-     * @see #getMinimumValue
-     * @see #getMaximumValue
-     */
-    double[] getDefaultNoDataValues();
+ public Name getName() {
+ return name;
+ }
 
-    /**
-     * The minimum value occurring in the sample dimension.
-     * If this value is not available, this value can be determined from the
-     * {@link org.opengis.coverage.processing.GridAnalysis#getMinValue} operation.
-     * This value can be empty if this value is not provided by the implementation.
-     *
-     * @return The minimum value occurring in the sample dimension.
-     *
-     * @see #getMaximumValue
-     * @see #getNoDataValues
-     */
-    Range<Double> getDefaultRange();
+ public InternationalString getDescription() {
+ return description;
+ }
 
+ private ColorInterpretation defaultColorInterpretation;
+
+ private double[] defaultNoDatavalues;
+
+ private NumberRange<Double> defaultRange;
+
+ private MathTransform1D defaultSampleTransformation;
+
+ private Name name;
+
+ private InternationalString description;
+
+ private SampleDimensionType defaultSampleDimensionType;
 
-    /**
-     * The unit information for this sample dimension.
-     * This interface typically is provided with grid coverages which represent
-     * digital elevation data.
-     * This value will be {@code null} if no unit information is available.
-     *
-     * @return The unit information for this sample dimension.
-     */
-    Unit<?> getUnit();
-
-    /**
-     * The transform which is applied to grid values for this sample dimension.
-     * This transform is often defined as
-     * <var>y</var> = {@linkplain #getOffset offset} + {@link #getScale scale}×<var>x</var> where
-     * <var>x</var> is the grid value and <var>y</var> is the geophysics value.
-     * However, this transform may also defines more complex relationship, for
-     * example a logarithmic one. In order words, this transform is a generalization of
-     * {@link #getScale}, {@link #getOffset} and {@link #getNoDataValues} methods.
-     *
-     * @return The transform from sample to geophysics values, or {@code null} if
-     *         it doesn't apply.
-     *
-     * @see #getScale
-     * @see #getOffset
-     * @see #getNoDataValues
-     */
-    @Extension
-    MathTransform1D getDefaultSampleTransformation();
-}
\ No newline at end of file
+ public SampleDimensionType getDefaultSampleDimensionType() {
+ return defaultSampleDimensionType;
+ }
+}

Modified: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/FieldType.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/FieldType.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/FieldType.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -6,7 +6,6 @@
 import java.util.List;
 import java.util.Map;
 
-import javax.measure.Measure;
 import javax.measure.quantity.Quantity;
 import javax.measure.unit.Unit;
 
@@ -14,37 +13,44 @@
 import org.opengis.coverage.SampleDimension;
 import org.opengis.feature.type.Name;
 import org.opengis.util.InternationalString;
-
+/**
+ *
+ * @author Simone Giannecchini, GeoSolutions
+ *
+ * @param <V>
+ * @param <QA>
+ */
 public class FieldType<V,QA extends Quantity> {
 
  /**
- * The {@link List} of {@link Axis} for this {@link Field}.
+ * The {@link List} of {@link Axis} for this {@link FieldType}.
  */
- private List <? extends Axis<?,?>>axes;
+ private List <Axis<QA>>axes;
+
  /**
- * The {@link Name} for this {@link Field}.
+ * The {@link Name} for this {@link FieldType}.
  */
  private Name name;
+
  /**
- * The {@link Unit} for this {@link Field}.
+ * The {@link Unit} for this {@link FieldType}.
  */
  private Unit<QA> uom;
+
  /**
- * The list of {@link Name}s for the {@link Axis} instances of this {@link Field}.
+ * The list of {@link Name}s for the {@link Axis} instances of this {@link FieldType}.
  */
  private List<Name> axesNames;
+
  /**
- * The description for this {@link Field}.
+ * The description for this {@link FieldType}.
  */
  private InternationalString description;
- /**
- * This {@link Map} holds the mapping between the Keys ( {@link Measure} instances) and the {@link SampleDimension}s
- * for this field.
- *
- */
- private Map<BandKey<V,QA>,BandType> bandTypes;
 
+
+ private HashMap<BandKey<V, QA>,BandType> bandTypes;
 
+
  /**
  *
  * @param name
@@ -57,26 +63,27 @@
  final Name fieldName,
         final InternationalString fieldDescription,
         final Unit<QA> UoM,
-        final List<? extends Axis<V,QA>> axes,
-        final Map<BandKey<V, QA>,BandType> bands) {
+        final List<Axis<QA>> axes, // axes definitions cannot be repeated
+        final Map<? extends BandKey<V, QA>,? extends BandType> bands
+        ) {
     this.name = fieldName;
     this.description = fieldDescription;
-    this.axes = new ArrayList<Axis<V,QA>>(axes);
+    this.axes = new ArrayList<Axis<QA>>(axes);
     this.uom = UoM;
         this.bandTypes = new HashMap<BandKey<V, QA>,BandType>(bands);
     axesNames = new ArrayList<Name>(axes.size());
-    for (Axis<?,?> axis : axes) {
+    for (Axis<QA> axis : axes) {
         axesNames.add(axis.getName());
     }
  }
 
  /**
- * {@link List} of all the axes of the {@link Field}
+ * {@link List} of all the axes of the {@link FieldType}
  *
  * @return a {@link List} of all the {@link Axis} instances for this
- *         {@link Field}
+ *         {@link FieldType}
  */
- public List<Axis<?,?>> getAxes() {
+ public List<? extends Axis<QA>> getAxes() {
  return Collections.unmodifiableList(axes);
  }
 
@@ -96,10 +103,11 @@
  *
  * @param name
  *                name of the Axis
+ * TODO improve me            
  * @return Axis instance or null if not found
  */
- public Axis<?,?> getAxis(Name name) {
-    for (Axis<?,?> axis : axes) {
+ public Axis<QA> getAxis(Name name) {
+    for (Axis<QA> axis : axes) {
         if (axis.getName().toString().equalsIgnoreCase(name.toString()) ||
                 axis.getName().getLocalPart().equalsIgnoreCase(name.getLocalPart()))
             return  axis;
@@ -108,14 +116,14 @@
  }
 
  /**
- * Retrieves the Unit of measure for the values described by this field.
+ * Retrieves the Unit of measure for the values described by this FieldType.
  *  
  * <p>
- * In case this {@link Field} is not made of measurable quantities we
+ * In case this {@link FieldType} is not made of measurable quantities we
  * return <code>null</code>
  *
- * @return the Unit of measure for the values described by this field or
- *         <code>null</code> in case this {@link Field} is not made of
+ * @return the Unit of measure for the values described by this FieldType or
+ *         <code>null</code> in case this {@link FieldType} is not made of
  *         measurable quantities
  */
  public Unit<? extends Quantity> getUnitOfMeasure() {
@@ -128,32 +136,28 @@
  public String toString(){
     final StringBuilder sb = new StringBuilder();
     final String lineSeparator = System.getProperty("line.separator", "\n");
-    sb.append("Name:").append(name.toString()).append(lineSeparator);
-    sb.append("Description:").append(description.toString()).append(lineSeparator);
-    sb.append("UoM:").append(uom.toString()).append(lineSeparator);
+    sb.append("FIELD TYPE description:").append(lineSeparator);
+    sb.append("Name:").append("\t\t").append(name.toString()).append(lineSeparator);
+    sb.append("Description:").append("\t").append(description.toString()).append(lineSeparator);
+    sb.append("UoM:").append("\t\t").append(uom.toString()).append(lineSeparator);
     sb.append("Axes:").append(lineSeparator);
-    for (Axis<?,?> axis : axes) {
-        sb.append("   axisName:").append(axis.getName().toString());
-        sb.append(" axisDescription:").append(axis.getDescription().toString());
-        sb.append(" axisUoM:").append(axis.getUnitOfMeasure().toString());
-        List<? extends Measure<?, ?>> axisKeys = axis.getKeys();
-        for (Measure<?, ?> measure: axisKeys){
-            sb.append(" key:").append(measure.toString());
-        }
-        sb.append(lineSeparator);
+    for (Axis<QA> axis : axes) {
+        sb.append(axis.toString()).append(lineSeparator);
     }
         
-        sb.append("SampleDimensions:").append(lineSeparator);
-        for (BandType band :  bandTypes.values()){
-            sb.append("BandType: ").append(band.toString());
+        sb.append("BandTypes:").append(lineSeparator);
+        for (BandKey<V,QA> bk :  bandTypes.keySet()){
+            sb.append("BandKey: ").append(bk.toString());
+            sb.append("BandType: ").append(bandTypes.get(bk).toString());
+            sb.append(lineSeparator);
         }    
     return sb.toString();
  }
 
  /**
- * Get the description of the {@link Field}
+ * Get the description of the {@link FieldType}
  *
- * @return description of the {@link Field}
+ * @return description of the {@link FieldType}
  */
  public InternationalString getDescription() {
  return description;
@@ -164,10 +168,20 @@
  *
  * @param key
  *                key of the SampleDimension
+ * TODO improve me
  * @return {@link SampleDimension} instance or null if not found
  */
- public BandType getBandType(BandKey<V,QA> key) {
- if(this.bandTypes.containsKey(key))
+ public BandType getBandType(final Name name) {
+ for(BandType type:bandTypes.values())
+ {
+ if(type.getName().equals(name))
+ return type;
+ }
+ throw new IllegalArgumentException("Unable to find SampleDimension for the specified key.");
+ }
+
+ public  BandType getBandType(final BandKey<V, QA> key) {
+ if(bandTypes.containsKey(key))
  return bandTypes.get(key);
  throw new IllegalArgumentException("Unable to find SampleDimension for the specified key.");
  }
@@ -179,8 +193,8 @@
  * @return Set of {@link SampleDimension} instances
  */
 
- public List<BandType> getBandTypes() {
-    return new ArrayList<BandType>(this.bandTypes.values());
+ public Map<BandKey<V, QA>,BandType> getBandTypes() {
+    return bandTypes;
  }
 
 }

Added: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/RangeUtilities.java
===================================================================
--- trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/RangeUtilities.java                        (rev 0)
+++ trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/RangeUtilities.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -0,0 +1,9 @@
+package org.geotools.coverage.io.range;
+
+import javax.measure.quantity.Length;
+import javax.measure.unit.SI;
+import javax.measure.unit.Unit;
+
+public class RangeUtilities {
+ public static final Unit<Length> WAVELENGTH_UOM=SI.NANO(SI.METER);
+}


Property changes on: trunk/spike/coverage-api/src/main/java/org/geotools/coverage/io/range/RangeUtilities.java
___________________________________________________________________
Added: svn:eol-style
   + native

Deleted: trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/CodeMeasureTest.java
===================================================================
--- trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/CodeMeasureTest.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/CodeMeasureTest.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,94 +0,0 @@
-/**
- *
- */
-package org.geotools.coverage.io.range.impl;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.measure.Measure;
-import javax.measure.quantity.Dimensionless;
-import javax.measure.unit.SI;
-import javax.measure.unit.Unit;
-
-import junit.framework.Assert;
-
-import org.geotools.coverage.io.impl.range.CodeMeasure;
-import org.geotools.coverage.io.range.Axis;
-import org.geotools.feature.NameImpl;
-import org.geotools.referencing.crs.DefaultEngineeringCRS;
-import org.geotools.referencing.cs.DefaultCoordinateSystemAxis;
-import org.geotools.referencing.cs.DefaultLinearCS;
-import org.geotools.referencing.datum.DefaultEngineeringDatum;
-import org.geotools.util.SimpleInternationalString;
-import org.junit.Test;
-import org.opengis.referencing.crs.SingleCRS;
-import org.opengis.referencing.cs.AxisDirection;
-import org.opengis.referencing.cs.CoordinateSystemAxis;
-import org.opengis.referencing.datum.EngineeringDatum;
-import org.opengis.util.CodeList;
-/**
- * @author Simone Giannecchini, GeoSolutions
- *
- */
-public class CodeMeasureTest extends Assert {
-
- /** Bands captured as an codelist used as an example below */
- private static List<Code> codes = new ArrayList<Code>();
- static class Code extends CodeList<Code> {
- private static final long serialVersionUID = -1103556579647561536L;
-
- public Code(String name) {
- super(name, codes );
- }
-
- public Code[] family() {
- return codes.toArray(new Code[codes.size()]);
- }
- }
- static {
- new Code("BLUE");
- new Code("GREEN");
- new Code("RED");
- new Code("NIR");
- new Code("SWIT");
- new Code("TIR");
- new Code("SWR2");
- }
- /**
- * This test uses use the default implementations
- * to express 7 bands of a landsat image.
- */
- @Test
- public void testLandsatAxis(){
- CoordinateSystemAxis csAxis = new DefaultCoordinateSystemAxis(
- new SimpleInternationalString("light"),
- "light",
- AxisDirection.OTHER,
- SI.MICRO(SI.METER));
-
- DefaultLinearCS lightCS = new DefaultLinearCS("light",csAxis);
- Map<String,Object> datumProperties = new HashMap<String,Object>();
- datumProperties.put("name", "light");
-
- EngineeringDatum lightDatum = new DefaultEngineeringDatum( datumProperties );
- SingleCRS lightCRS = new DefaultEngineeringCRS("wave length", lightDatum, lightCS );
-
- List<Measure<Code,Dimensionless>> keys = CodeMeasure.valueOf( codes );
-
- Axis<Code,Dimensionless> axis =
- new Axis<Code,Dimensionless>(
- new NameImpl("Bands"),
- new SimpleInternationalString("Expressed in wavelengths"),
- keys,
- Unit.ONE,
- lightCRS );
-
- assertEquals( lightCRS, axis.getCoordinateReferenceSystem() );
- assertEquals( 7, axis.getKeys().size() );
- }
-
-}

Modified: trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/DimensionlessAxisTest.java
===================================================================
--- trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/DimensionlessAxisTest.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/DimensionlessAxisTest.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,59 +1,59 @@
-package org.geotools.coverage.io.range.impl;
-
-import javax.measure.Measure;
-import javax.measure.quantity.Dimensionless;
-import javax.measure.unit.Unit;
-
-import junit.framework.Assert;
-
-import org.geotools.coverage.io.impl.range.BandIndexMeasure;
-import org.geotools.coverage.io.impl.range.DimensionlessAxis;
-import org.geotools.coverage.io.range.Axis;
-import org.geotools.feature.NameImpl;
-import org.geotools.util.SimpleInternationalString;
-import org.junit.Test;
-
-public class DimensionlessAxisTest extends Assert {
-
- /**
- * Toy Axis consisting of three bands named A, B and C.
- * <p>
- * This really is a toy example; if you have a formal
- * fixed data dictionary consider the use of a Java Enumeration
- * (and EnumMeasure), if you have an open ended data dictionary
- * consider a CodeList (and CodeMeasure).
- */
- @Test
- public void testTOY(){
- DimensionlessAxis TOY = new DimensionlessAxis(
- new String[]{"A","B","C"},
- new NameImpl("Color"),
- new SimpleInternationalString("Toy Example"));
-
- assertEquals( Unit.ONE, TOY.getUnitOfMeasure() );
- Measure<String, Dimensionless> key = TOY.getKey(0);
- assertEquals( "A", key.getValue() );
- assertTrue(key instanceof BandIndexMeasure );
- assertNull( TOY.getCoordinateReferenceSystem() );
- }
-
- /**
- * Depth represented as an axis of one band
- */
- @Test
- public void testElevation(){
- DimensionlessAxis HEIGHT = new DimensionlessAxis(1, new NameImpl("height"), new SimpleInternationalString("Height from sealevel"));
- assertEquals( Unit.ONE, HEIGHT.getUnitOfMeasure() );
- Measure<String, Dimensionless> key = HEIGHT.getKey(0);
- assertTrue(key instanceof BandIndexMeasure );
- assertEquals( "0", key.getValue() );
-
- // Make sure we can discover everything we need via the Axis API
- Axis<String, Dimensionless> axis = HEIGHT;
- assertEquals( Unit.ONE, axis.getUnitOfMeasure() );
- Measure<String, Dimensionless> measure = axis.getKey(0);
- assertEquals( Unit.ONE, measure.getUnit() );
- assertEquals( "0", key.getValue() );
- }
-
-}
+//package org.geotools.coverage.io.range.impl;
+//
+//import javax.measure.Measure;
+//import javax.measure.quantity.Dimensionless;
+//import javax.measure.unit.Unit;
+//
+//import junit.framework.Assert;
+//
+//import org.geotools.coverage.io.impl.range.BandIndexMeasure;
+//import org.geotools.coverage.io.impl.range.DimensionlessAxis;
+//import org.geotools.coverage.io.range.Axis;
+//import org.geotools.feature.NameImpl;
+//import org.geotools.util.SimpleInternationalString;
+//import org.junit.Test;
+//
+//public class DimensionlessAxisTest extends Assert {
+//
+// /**
+// * Toy Axis consisting of three bands named A, B and C.
+// * <p>
+// * This really is a toy example; if you have a formal
+// * fixed data dictionary consider the use of a Java Enumeration
+// * (and EnumMeasure), if you have an open ended data dictionary
+// * consider a CodeList (and CodeMeasure).
+// */
+// @Test
+// public void testTOY(){
+// DimensionlessAxis TOY = new DimensionlessAxis(
+// new String[]{"A","B","C"},
+// new NameImpl("Color"),
+// new SimpleInternationalString("Toy Example"));
+//
+// assertEquals( Unit.ONE, TOY.getUnitOfMeasure() );
+// Measure<String, Dimensionless> key = TOY.getKey(0);
+// assertEquals( "A", key.getValue() );
+// assertTrue(key instanceof BandIndexMeasure );
+// assertNull( TOY.getCoordinateReferenceSystem() );
+// }
+//
+// /**
+// * Depth represented as an axis of one band
+// */
+// @Test
+// public void testElevation(){
+// DimensionlessAxis HEIGHT = new DimensionlessAxis(1, new NameImpl("height"), new SimpleInternationalString("Height from sealevel"));
+// assertEquals( Unit.ONE, HEIGHT.getUnitOfMeasure() );
+// Measure<String, Dimensionless> key = HEIGHT.getKey(0);
+// assertTrue(key instanceof BandIndexMeasure );
+// assertEquals( "0", key.getValue() );
+//
+// // Make sure we can discover everything we need via the Axis API
+// Axis<String, Dimensionless> axis = HEIGHT;
+// assertEquals( Unit.ONE, axis.getUnitOfMeasure() );
+// Measure<String, Dimensionless> measure = axis.getKey(0);
+// assertEquals( Unit.ONE, measure.getUnit() );
+// assertEquals( "0", key.getValue() );
+// }
+//
+//}

Deleted: trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/EnumMeasureTest.java
===================================================================
--- trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/EnumMeasureTest.java 2009-07-07 11:06:11 UTC (rev 33506)
+++ trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/EnumMeasureTest.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -1,73 +0,0 @@
-/**
- *
- */
-package org.geotools.coverage.io.range.impl;
-
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.measure.Measure;
-import javax.measure.quantity.Dimensionless;
-import javax.measure.unit.SI;
-import javax.measure.unit.Unit;
-
-import junit.framework.Assert;
-
-import org.geotools.coverage.io.impl.range.EnumMeasure;
-import org.geotools.coverage.io.range.Axis;
-import org.geotools.feature.NameImpl;
-import org.geotools.referencing.crs.DefaultEngineeringCRS;
-import org.geotools.referencing.cs.DefaultCoordinateSystemAxis;
-import org.geotools.referencing.cs.DefaultLinearCS;
-import org.geotools.referencing.datum.DefaultEngineeringDatum;
-import org.geotools.util.SimpleInternationalString;
-import org.junit.Test;
-import org.opengis.coverage.SampleDimension;
-import org.opengis.referencing.cs.AxisDirection;
-import org.opengis.referencing.cs.CoordinateSystemAxis;
-import org.opengis.referencing.datum.EngineeringDatum;
-/**
- * @author Simone Giannecchini, GeoSolutions
- *
- */
-public class EnumMeasureTest extends Assert {
-
- /** Bands captured as an enumeration used as an example below */
- enum Band {
- BLUE,GREE,RED,NIR,SWIT,TIR,SWR2
- };
-
- /**
- * This test uses use the default implementations
- * to express 7 bands of a landsat image.
- */
- @Test
- public void testLandsatAxis(){
- CoordinateSystemAxis csAxis = new DefaultCoordinateSystemAxis(
- new SimpleInternationalString("light"),
- "light",
- AxisDirection.OTHER,
- SI.MICRO(SI.METER));
-
- DefaultLinearCS lightCS = new DefaultLinearCS("light",csAxis);
- Map<String,Object> datumProperties = new HashMap<String,Object>();
- datumProperties.put("name", "light");
-
- EngineeringDatum lightDatum = new DefaultEngineeringDatum( datumProperties );
- DefaultEngineeringCRS lightCRS = new DefaultEngineeringCRS("wave length", lightDatum, lightCS );
-
- List<Measure<Band, Dimensionless>> keys = EnumMeasure.valueOf( Band.class );
-
- Axis<Band, Dimensionless> axis =
- new Axis<Band,Dimensionless>(
- new NameImpl("Bands"),
- new SimpleInternationalString("Landsat bands by wavelength"),
- keys,
- Unit.ONE );
-
- Map<Measure<Integer,Dimensionless>,SampleDimension> samples = new HashMap<Measure<Integer,Dimensionless>, SampleDimension>();
- }
-
-}

Added: trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/SyntheticDataTest.java
===================================================================
--- trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/SyntheticDataTest.java                        (rev 0)
+++ trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/SyntheticDataTest.java 2009-07-07 12:18:05 UTC (rev 33507)
@@ -0,0 +1,95 @@
+package org.geotools.coverage.io.range.impl;
+
+import java.awt.RenderingHints;
+import java.awt.Transparency;
+import java.awt.color.ColorSpace;
+import java.awt.image.ComponentColorModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.RenderedImage;
+import java.util.List;
+
+import javax.measure.quantity.Dimensionless;
+import javax.media.jai.ImageLayout;
+import javax.media.jai.JAI;
+import javax.media.jai.operator.BandMergeDescriptor;
+import javax.media.jai.operator.ConstantDescriptor;
+
+import org.geotools.coverage.io.impl.range.DimensionlessAxisBin;
+import org.geotools.coverage.io.impl.range.IMAGE_PROCESSING_ELEMENTS;
+import org.geotools.coverage.io.range.Axis;
+import org.geotools.coverage.io.range.FieldType;
+import org.junit.Test;
+/**
+ * Tests for the axis class and its related classes
+ *
+ * @author Simone Giannecchini, GeoSolutions
+ *
+ */
+public class SyntheticDataTest extends org.junit.Assert{
+
+ public static RenderedImage band= ConstantDescriptor.create(512.0f, 512.0f, new Byte[]{0}, null);
+
+ @Test
+ public void testAxis(){
+ final Axis<Dimensionless> axis = IMAGE_PROCESSING_ELEMENTS.SYNTHETIC_COLOR_AXIS;
+ assertEquals(axis, IMAGE_PROCESSING_ELEMENTS.SYNTHETIC_COLOR_AXIS);
+ final Axis<Dimensionless> axis2= new Axis<Dimensionless>(
+ axis.getName(),
+ axis.getDescription(),
+ axis.getUnitOfMeasure());
+ assertEquals(axis, axis2);
+
+ }
+ @Test
+ public void testAxisBin(){
+
+ // get the bin for the single gray band
+ List<DimensionlessAxisBin> bins = IMAGE_PROCESSING_ELEMENTS.getBinsFromRenderedImage(band);
+ assertEquals(1, bins.size());
+ // we should be able to get the same bin using the enum keys
+ assertEquals(IMAGE_PROCESSING_ELEMENTS.GRAY.getAxisBin(), bins.get(0));
+
+ // now two bands
+ final RenderedImage twoBands= BandMergeDescriptor.create(band, band, null);
+ bins = IMAGE_PROCESSING_ELEMENTS.getBinsFromRenderedImage(twoBands);
+ assertEquals(2, bins.size());
+ // we should be able to get the same bin using the enum keys
+ assertEquals(IMAGE_PROCESSING_ELEMENTS.GRAY.getAxisBin(), bins.get(0));
+ // we should be able to get the same bin using the enum keys
+ assertEquals(IMAGE_PROCESSING_ELEMENTS.ALPHA.getAxisBin(), bins.get(1));
+
+ //RGB
+ final ImageLayout layout= new ImageLayout();
+ layout.setColorModel(
+ new ComponentColorModel(
+ ColorSpace.getInstance(ColorSpace.CS_sRGB),
+ false,
+ false,
+ Transparency.OPAQUE,
+ DataBuffer.TYPE_BYTE
+ )
+ );
+ final RenderingHints hints= new RenderingHints(JAI.KEY_IMAGE_LAYOUT,layout);
+ final RenderedImage rgb= BandMergeDescriptor.create(band, twoBands, hints);
+ bins = IMAGE_PROCESSING_ELEMENTS.getBinsFromRenderedImage(rgb);
+ assertEquals(3, bins.size());
+ // we should be able to get the same bin using the enum keys
+ assertEquals(IMAGE_PROCESSING_ELEMENTS.RED.getAxisBin(), bins.get(0));
+ // we should be able to get the same bin using the enum keys
+ assertEquals(IMAGE_PROCESSING_ELEMENTS.GREEN.getAxisBin(), bins.get(1));
+ // we should be able to get the same bin using the enum keys
+ assertEquals(IMAGE_PROCESSING_ELEMENTS.BLUE.getAxisBin(), bins.get(2));
+
+ }
+
+ @Test
+ public void testFieldType(){
+
+ // get the bin for the single gray band
+ final FieldType<String, Dimensionless> fieldType = IMAGE_PROCESSING_ELEMENTS.getFieldTypeFromRenderedImage(band);
+ assertNotNull(fieldType.getAxes());
+ assertEquals(1,fieldType.getAxes().size());
+ assertEquals(IMAGE_PROCESSING_ELEMENTS.SYNTHETIC_COLOR_AXIS,fieldType.getAxes().iterator().next());
+ System.out.println(fieldType);
+ }
+}


Property changes on: trunk/spike/coverage-api/src/test/java/org/geotools/coverage/io/range/impl/SyntheticDataTest.java
___________________________________________________________________
Added: svn:eol-style
   + native


------------------------------------------------------------------------------
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/blackberry
_______________________________________________
GeoTools-commits mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-commits