[Schmitzm-commits] r346 - in branches/1.0-gt2-2.6/src: org/geotools/renderer/lite/gridcoverage2d schmitzm/geotools/io skrueger/geotools/io

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Aug 31 13:37:01 CEST 2009


Author: alfonx
Date: 2009-08-31 13:37:01 +0200 (Mon, 31 Aug 2009)
New Revision: 346

Added:
   branches/1.0-gt2-2.6/src/org/geotools/renderer/lite/gridcoverage2d/CopyOfRasterSymbolizerSupport.java
Removed:
   branches/1.0-gt2-2.6/src/org/geotools/renderer/lite/gridcoverage2d/RasterSymbolizerSupport.java
Modified:
   branches/1.0-gt2-2.6/src/schmitzm/geotools/io/GeoImportUtil.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/io/GeoImportUtilURL.java
Log:
* ArcASCII mit GT neu

Added: branches/1.0-gt2-2.6/src/org/geotools/renderer/lite/gridcoverage2d/CopyOfRasterSymbolizerSupport.java
===================================================================
--- branches/1.0-gt2-2.6/src/org/geotools/renderer/lite/gridcoverage2d/CopyOfRasterSymbolizerSupport.java	2009-08-31 11:10:08 UTC (rev 345)
+++ branches/1.0-gt2-2.6/src/org/geotools/renderer/lite/gridcoverage2d/CopyOfRasterSymbolizerSupport.java	2009-08-31 11:37:01 UTC (rev 346)
@@ -0,0 +1,475 @@
+///*
+// *    GeoTools - OpenSource mapping toolkit
+// *    http://geotools.org
+// *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
+// *
+// *    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; either
+// *    version 2.1 of the License, or (at your option) any later version.
+// *
+// *    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.renderer.lite.gridcoverage2d;
+//
+//// J2SE dependencies
+//import java.awt.Color;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Map;
+//
+//import org.apache.log4j.Logger;
+//import org.geotools.coverage.Category;
+//import org.geotools.coverage.CoverageFactoryFinder;
+//import org.geotools.coverage.GridSampleDimension;
+//import org.geotools.coverage.grid.GridCoverage2D;
+//import org.geotools.coverage.grid.GridGeometry2D;
+//import org.geotools.styling.ColorMap;
+//import org.geotools.styling.ColorMapEntry;
+//import org.geotools.styling.RasterSymbolizer;
+//import org.geotools.util.NumberRange;
+//import org.opengis.coverage.SampleDimension;
+//import org.opengis.coverage.grid.GridCoverage;
+//import org.opengis.filter.expression.Expression;
+//
+//import schmitzm.geotools.styling.StylingUtil;
+//import schmitzm.lang.LangUtil;
+//
+///**
+// * A helper class for {@link GridCoverage} objects rendering SLD stylers
+// * support.
+// *
+// * @author Alessio Fabiani
+// * @author Simone Giannecchini
+// *
+// * @task Optimize and complete
+// * @source $URL:
+// *         http://svn.geotools.org/geotools/branches/coverages_branch/trunk/gt/module/render/src/org/geotools/renderer/lite/RasterSymbolizerSupport.java $
+// */
+//public final class CopyOfRasterSymbolizerSupport {
+////ms-01.sn
+//    private static Logger LOGGER = Logger.getLogger( CopyOfRasterSymbolizerSupport.class.getName() );
+//    /** Types for the recoloring process. */
+//    public static enum RECOLOR_MODE_TYPE {
+//      /** The way of geotools 2.4.4. The color map is used only for
+//       *  the {@link SampleDimension (Grid)SampleDimensions} already defined
+//       *  in the {@link GridCoverage2D}. */
+//      GT_CLASSIC,
+//      /** Alternative way of <a href="">Martin Schmitz</a>. The {@link GridCoverage2D}
+//       *  is resampled accordingly to the given color map. */
+//      MS_EXTENTION
+//    }
+//    /** The way the recoloring is processed. */
+//    public static RECOLOR_MODE_TYPE RECOLOR_MODE = RECOLOR_MODE_TYPE.MS_EXTENTION;
+////ms-01.en
+//
+//    /** The Styled Layer Descriptor * */
+//    private final RasterSymbolizer symbolizer;
+//
+//    /**
+//     * Constructor
+//     *
+//     * @param symbolizer
+//     *
+//     */
+//    public CopyOfRasterSymbolizerSupport(final RasterSymbolizer symbolizer) {
+//        this.symbolizer = symbolizer;
+//    }
+//
+//    public GridCoverage recolorCoverage(GridCoverage grid)
+//            throws IllegalArgumentException {
+//        if (!(grid instanceof GridCoverage2D)) {
+//            throw new IllegalArgumentException(
+//                    "Cannot Recolor GridCoverage: GridCoverage2D is needed.");
+//        }
+//
+//        // final ColorMap map = symbolizer.getColorMap();
+//        // if (map == null)
+//        // throw new IllegalArgumentException(
+//        // "Cannot Recolor GridCoverage: ColorMap is needed.");
+//        // final ColorMapEntry[] entries = map.getColorMapEntries();
+//        // if (entries == null || entries.length <= 0)
+//        // throw new IllegalArgumentException(
+//        // "Cannot Recolor GridCoverage: ColorMapEntries are needed.");
+//        // final int length = entries.length;
+//        // final Map colorMap = new HashMap();
+//        // for (int i = 0; i < length; i++)
+//        // colorMap.put(entries[i].getQuantity().getValue(null), entries[i]
+//        // .getQuantity().getValue(null));
+//        // return Operations.DEFAULT.recolor(grid, new Map[] { Collections
+//        // .singletonMap(null, colorMap) });
+//
+//        final GridCoverage2D gridCoverage = (GridCoverage2D) grid;
+//        final int numBands = gridCoverage.getNumSampleDimensions();
+//        final GridSampleDimension[] targetBands = new GridSampleDimension[numBands];
+//        final Map[] colorMaps = new Map[numBands];
+//        for (int band = 0; band < numBands; band++) { // TODO get separated
+////ms-01.sn
+////            LOGGER.debug("===== Debug original dimension =====");
+////            for ( Category c : (List<Category>)((GridSampleDimension)gridCoverage.getSampleDimension(band)).getCategories() )
+////              LOGGER.debug( c.toString() );
+//            if ( RECOLOR_MODE == RECOLOR_MODE.MS_EXTENTION ) {
+//              targetBands[band] = transformColormap(
+//                  (GridSampleDimension)gridCoverage.getSampleDimension(band), this.symbolizer);
+//              if ( targetBands[band] != gridCoverage.getSampleDimension(band))
+//                continue;
+//            }
+////ms-01.en
+//            // R,G,B colorMaps from
+//            // symbolizer
+//            final Map categories = getCategories(band);
+//            colorMaps[band] = categories;
+//
+//            /**
+//             * Temporary solution, until the Recolor Operation is ported ...
+//             */
+//            targetBands[band] = (GridSampleDimension) transformColormap(band,
+//                    gridCoverage.getSampleDimension(band), colorMaps);
+//        }
+//
+//        GridCoverage2D createed = CoverageFactoryFinder.getGridCoverageFactory(null).create(
+//                gridCoverage.getName(), gridCoverage.getRenderedImage(),
+//                (GridGeometry2D) gridCoverage.getGridGeometry(), targetBands,
+//                new GridCoverage[] { gridCoverage }, null);
+//        return createed;
+//    }
+//
+//    /**
+//     * HELPER FUNCTIONS
+//     */
+//    public float getOpacity() {
+//        float alpha = 1.0f;
+//        Expression exp = this.symbolizer.getOpacity();
+//        if (exp == null){
+//            return alpha;
+//        }
+//        Number number = (Number) exp.evaluate(null,Float.class);
+//        if (number == null){
+//            return alpha;
+//        }
+//        return number.floatValue();
+//    }
+//
+//    public Map getCategories(final int band) {
+//        final String[] labels = getLabels(band);
+//        final Color[] colors = getColors(band);
+//
+//        final Map categories = new HashMap();
+//
+//        /**
+//         * Checking Categories
+//         */
+//        final int labelsLength = labels.length;
+//        Color[] oldCmap;
+//        int length;
+//        Color[] newCmap;
+//        for (int i = 0; i < labelsLength; i++) {
+//            if (!categories.containsKey(labels[i])) {
+//                categories.put(labels[i], new Color[] { colors[i] });
+//            } else {
+//                oldCmap = (Color[]) categories.get(labels[i]);
+//                length = oldCmap.length;
+//                newCmap = new Color[length + 1];
+//                System.arraycopy(oldCmap, 0, newCmap, 0, length);
+//                newCmap[length] = colors[i];
+//                categories.put(labels[i], newCmap);
+//            }
+//        }
+//
+//        return categories;
+//    }
+//
+//    public String[] getLabels(final int band) {
+//        String[] labels = null;
+//        if (this.symbolizer.getColorMap() != null) {
+//            final ColorMapEntry[] colors = this.symbolizer.getColorMap()
+//                    .getColorMapEntries();
+//            final int numColors = colors.length;
+//            labels = new String[numColors];
+//            for (int ci = 0; ci < numColors; ci++) {
+//                labels[ci] = colors[ci].getLabel();
+//            }
+//        }
+//
+//        return labels;
+//    }
+//
+//    public Color[] getColors(final int band) {
+//        Color[] colorTable = null;
+//        if (this.symbolizer.getColorMap() != null) {
+//            final ColorMapEntry[] colors = this.symbolizer.getColorMap()
+//                    .getColorMapEntries();
+//            final int numColors = colors.length;
+//            colorTable = new Color[numColors];
+//            double opacity;
+//            for (int ci = 0; ci < numColors; ci++) {
+//                opacity = toOpacity( colors[ci].getOpacity() );
+//                colorTable[ci] = toColor( colors[ci].getColor(), opacity );
+//                if (colorTable[ci] == null){
+//                    return null;
+//                }
+//            }
+//        }
+//
+//        return colorTable;
+//    }
+//    public static Color toColor( Expression exp, double opacity ){
+//        if (exp == null){
+//            return null;
+//        }
+//        Color color = (Color) exp.evaluate(null, Color.class);
+//        int alpha = new Double(Math.ceil(255.0 * opacity)).intValue();
+//        if( color != null ){
+//            return new Color( color.getRed(), color.getGreen(), color.getBlue(), alpha );
+//        }
+//        else {
+//            // the value morphing code failed us .. let's try by hand
+//            Object obj = exp.evaluate( null );
+//            if (obj == null){
+//                return null;
+//            }
+//            Integer  intval = Integer.decode((String) obj);
+//            int i = intval.intValue();
+//            return new Color((i >> 16) & 0xFF, (i >> 8) & 0xFF, i & 0xFF, alpha);
+//        }
+//    }
+//    public static double toOpacity( Expression opacity ) {
+//        if (opacity == null) {
+//            return 1.0;
+//        }
+//
+//        Double value = (Double) opacity.evaluate(null, Double.class);
+//        if (value == null) {
+//            return 1.0;
+//        }
+//        return value.doubleValue();
+////
+////        opacity = (colors[ci].getOpacity() != null
+////                ? (colors[ci].getOpacity().getValue(null) instanceof String
+////                        ? Double.valueOf((String) colors[ci].getOpacity().getValue(null))
+////                        : (Double) colors[ci].getOpacity().getValue(null))
+////                : new Double(1.0));
+//    }
+////ms-01.sn
+//    /**
+//     * Transforms an {@link Expression} to a double value.
+//     */
+//    public static double toQuantiy( Expression quantity ) {
+//      if (quantity == null)
+//          return 0.0;
+//      Double value = (Double) quantity.evaluate(null, Double.class);
+//      if (value == null)
+//          return 0.0;
+//      return value.doubleValue();
+//    }
+//
+//    /**
+//     * Extends an array with new values.
+//     * @param source source array
+//     * @param newElem new elements the array is extended with
+//     * @return a new array object
+//     */
+//    private static <T> T[] extendArray(T[] source, T... newElem) {
+////ms: if SCHMITZM library is available:
+//      return LangUtil.extendArray(source, newElem);
+////ms: if SCHMITZM library is NOT available:
+////      T[] newArray =  java.util.Arrays.copyOf(source, source.length+newElem.length);
+////      for (int i=0; i<newElem.length; i++)
+////        newArray[source.length+i] = newElem[i];
+////      return newArray;
+//    }
+//
+//    public GridSampleDimension transformColormap(GridSampleDimension dimension, RasterSymbolizer symbolizer) {
+//      if ( symbolizer == null || symbolizer.getColorMap() == null )
+//        return dimension;
+//
+//      ColorMap             colorMap       = symbolizer.getColorMap();
+//      ColorMapEntry[]      colorMapEntry  = colorMap.getColorMapEntries();
+//      Map<String,Category> categories     = new HashMap<String,Category>();
+//      int                  sampleQuantMin = Integer.MAX_VALUE;
+//      int                  sampleQuantMax = Integer.MIN_VALUE;
+//      double               geoQuantMin    = Integer.MAX_VALUE;
+//      double               geoQuantMax    = Integer.MIN_VALUE;
+//
+//      //////////////////////////////////////////////////////////
+//      // Workaround, so that "sampleQuan" is unique, even if
+//      // the grid values are near to each other (e.g. 0.8 and
+//      // 1.2)
+//      int sampleQuanFactor = 10;
+//      for (int i=1; i<colorMapEntry.length; i++) {
+//        double geoQuant0 = toQuantiy(colorMapEntry[i-1].getQuantity());
+//        geoQuant0        = Math.abs(geoQuant0);
+//        double geoQuant1 = toQuantiy(colorMapEntry[i].getQuantity());
+//        geoQuant1        = Math.abs(geoQuant1);
+//        int sampleQuan0  = (int)Math.round(geoQuant0*sampleQuanFactor) + 1;
+//        int sampleQuan1  = (int)Math.round(geoQuant1*sampleQuanFactor) + 1;
+//        if ( sampleQuan0 == sampleQuan1 )
+//          sampleQuanFactor *= 10;
+//      }
+//      //////////////////////////////////////////////////////////
+//
+//      for ( ColorMapEntry cme : colorMap.getColorMapEntries() ) {
+//        double opacity     = toOpacity(cme.getOpacity());
+//        Color  color       = toColor(cme.getColor(), opacity);
+//        String label       = cme.getLabel();
+//        if ( label == null )
+//          label = "";
+//        // the color map defines the geophysics value
+//        double geoQuant    = toQuantiy(cme.getQuantity());
+//        geoQuantMin        = Math.min(geoQuantMin, geoQuant);
+//        geoQuantMax        = Math.max(geoQuantMax, geoQuant);
+//        // create a sample quantity which is different from the geophysics value,
+//        // so a GeophysicsCategory is created
+//        //int    sampleQuan  = (int)Math.round(geoQuant)*10 + 1;
+//        int    sampleQuan  = (int)Math.round(geoQuant*sampleQuanFactor) + 1;
+//        sampleQuantMin     = Math.min(sampleQuantMin, sampleQuan);
+//        sampleQuantMax     = Math.max(sampleQuantMax, sampleQuan);
+//
+//        // if a category for the label already exists, treat this
+//        // as a range definition; otherwise create a single value
+//        // Category
+//        Category oldCategory = categories.get(label);
+//        if ( oldCategory != null ) {
+//          int     newMax    = Math.max(sampleQuan, (int)oldCategory.getRange().getMaximum());
+//          int     newMin    = Math.min(sampleQuan, (int)oldCategory.getRange().getMinimum());
+//          double  newMaxGeo = Math.max(geoQuant, oldCategory.geophysics(true).getRange().getMaximum());
+//          double  newMinGeo = Math.min(geoQuant, oldCategory.geophysics(true).getRange().getMinimum());
+//          Color[] newColors = extendArray(oldCategory.getColors(), color);
+//          categories.put(label, new Category(
+//              label,
+//              newColors,
+//              new NumberRange(newMin,    newMax),
+//              new NumberRange(newMinGeo, newMaxGeo)
+//          ));
+//        } else
+//          categories.put(label, new Category(
+//              label,
+//              new Color[] {color},
+//              new NumberRange(sampleQuan, sampleQuan),
+//              new NumberRange(geoQuant,   geoQuant)
+//          ));
+//
+//      }
+//
+//      // if no categories are defined by color map do not resample; instead use
+//      // the existing categories (and the grid/image internal color definition)
+//      if ( categories.isEmpty() )
+//        return dimension;
+//
+//      // If NoData-Values are set, create a additional Categories
+//      double[] noDataValues = dimension.getNoDataValues();
+//      if ( noDataValues == null )
+//        noDataValues = new double[0];
+//      for (double noDataValue : noDataValues ) {
+//        int value   = sampleQuantMax + 10; // value not already used
+//        sampleQuantMin = Math.min(sampleQuantMin, (int)noDataValue);
+//        sampleQuantMax = Math.max(sampleQuantMax, (int)noDataValue);
+//        categories.put(String.valueOf("NoData_"+noDataValue), createNoDataCategory(value, noDataValue));
+//      }
+//
+//      // Declare "all" values smaller/greater the color map values
+//      // automatically as NoData
+//      final int lowerStart = Integer.MIN_VALUE;
+//      final int higherEnd  = Integer.MAX_VALUE;
+//      categories.put("_autoNoData1_", new Category(
+//          "_autoNoData1_",
+//          new Color[] { new Color(0,0,0,0) },
+//          new NumberRange(sampleQuantMax+1, sampleQuantMax+2),
+//          new NumberRange(geoQuantMax+1,    higherEnd)
+//      ));
+//      if ( sampleQuantMin <= sampleQuantMax )
+//        categories.put("_autoNoData2_", new Category(
+//            "_autoNoData2_",
+//            new Color[] { new Color(0,0,0,0) },
+//            //new NumberRange(colorMapMin-2, colorMapMin-1), // logischer, aber klappt nicht!?
+//            new NumberRange(sampleQuantMax+3, sampleQuantMax+4),
+//            new NumberRange(lowerStart,       geoQuantMin-1)
+//        ));
+//      //categories.put("_autoNoData2_", Category.NODATA);
+//
+//      // Create the GridSampleDimension
+//      GridSampleDimension gsd = new GridSampleDimension(
+//          dimension.getDescription().toString(),
+//          categories.values().toArray(new Category[0]),
+//          dimension.getUnits()
+//      ).geophysics(true);
+//
+////      LOGGER.debug("===== Debug new dimension =====");
+////      for ( Category c : (List<Category>)gsd.getCategories() )
+////        LOGGER.debug( c.toString() );
+//
+//      return gsd;
+//    }
+//
+//    /**
+//     * Creates a {@link Category} for a NoData-value, which will be displayed transparently.
+//     * @param value sample value
+//     * @param geoValue geophysics value representing the NoData
+//     */
+//    public static Category createNoDataCategory(int value, double geoValue) {
+////ms: if SCHMITZM library is available:
+//      return StylingUtil.createNoDataCategory(value, geoValue);
+////ms: if SCHMITZM library is NOT available:
+////      return new Category(
+////          Vocabulary.formatInternational(VocabularyKeys.NODATA),
+////          new Color[] { new Color(0,0,0,0) },
+////          new NumberRange(value, value),
+////          new NumberRange(geoValue, geoValue)
+////      );
+//    }
+////ms-01.en
+//
+//    /**
+//     * Transform the supplied RGB colors.
+//     */
+//    public SampleDimension transformColormap(final int band,
+//            SampleDimension dimension, final Map[] colorMaps) {
+//        if (colorMaps == null || colorMaps.length == 0) {
+//            return dimension;
+//        }
+//        boolean changed = false;
+//        final Map colorMap = colorMaps[Math.min(band, colorMaps.length - 1)];
+//        final List categoryList = ((GridSampleDimension) dimension)
+//                .getCategories();
+//        if (categoryList == null) {
+//            return dimension;
+//        }
+//        final Category categories[] = (Category[]) categoryList.toArray();
+//        Category category;
+//        Color[] colors;
+//        final int length = categories.length;
+//        NumberRange range;
+//        int lower;
+//        int upper;
+//        for (int j = length; --j >= 0;) {
+//            category = categories[j];
+//            colors = (Color[]) colorMap.get(category.getName().toString());
+//            if (colors == null) {
+//                if (!category.isQuantitative()) {
+//                    continue;
+//                }
+//                colors = (Color[]) colorMap.get(null);
+//                if (colors == null) {
+//                    continue;
+//                }
+//            }
+//            range = category.getRange();
+//            lower = ((Number) range.getMinValue()).intValue();
+//            upper = ((Number) range.getMaxValue()).intValue();
+//            if (!range.isMinIncluded())
+//                lower++;
+//            if (range.isMaxIncluded())
+//                upper++;
+//            category = category.recolor(colors);
+//            if (!categories[j].equals(category)) {
+//                categories[j] = category;
+//                changed = true;
+//            }
+//        }
+//        return changed ? new GridSampleDimension(dimension.getDescription(),
+//                categories, dimension.getUnits()) : dimension;
+//    }
+//}


Property changes on: branches/1.0-gt2-2.6/src/org/geotools/renderer/lite/gridcoverage2d/CopyOfRasterSymbolizerSupport.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Deleted: branches/1.0-gt2-2.6/src/org/geotools/renderer/lite/gridcoverage2d/RasterSymbolizerSupport.java
===================================================================
--- branches/1.0-gt2-2.6/src/org/geotools/renderer/lite/gridcoverage2d/RasterSymbolizerSupport.java	2009-08-31 11:10:08 UTC (rev 345)
+++ branches/1.0-gt2-2.6/src/org/geotools/renderer/lite/gridcoverage2d/RasterSymbolizerSupport.java	2009-08-31 11:37:01 UTC (rev 346)
@@ -1,475 +0,0 @@
-/*
- *    GeoTools - OpenSource mapping toolkit
- *    http://geotools.org
- *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
- *
- *    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; either
- *    version 2.1 of the License, or (at your option) any later version.
- *
- *    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.renderer.lite.gridcoverage2d;
-
-// J2SE dependencies
-import java.awt.Color;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.geotools.coverage.Category;
-import org.geotools.coverage.CoverageFactoryFinder;
-import org.geotools.coverage.GridSampleDimension;
-import org.geotools.coverage.grid.GridCoverage2D;
-import org.geotools.coverage.grid.GridGeometry2D;
-import org.geotools.styling.ColorMap;
-import org.geotools.styling.ColorMapEntry;
-import org.geotools.styling.RasterSymbolizer;
-import org.geotools.util.NumberRange;
-import org.opengis.coverage.SampleDimension;
-import org.opengis.coverage.grid.GridCoverage;
-import org.opengis.filter.expression.Expression;
-
-import schmitzm.geotools.styling.StylingUtil;
-import schmitzm.lang.LangUtil;
-
-/**
- * A helper class for {@link GridCoverage} objects rendering SLD stylers
- * support.
- *
- * @author Alessio Fabiani
- * @author Simone Giannecchini
- *
- * @task Optimize and complete
- * @source $URL:
- *         http://svn.geotools.org/geotools/branches/coverages_branch/trunk/gt/module/render/src/org/geotools/renderer/lite/RasterSymbolizerSupport.java $
- */
-public final class RasterSymbolizerSupport {
-//ms-01.sn
-    private static Logger LOGGER = Logger.getLogger( RasterSymbolizerSupport.class.getName() );
-    /** Types for the recoloring process. */
-    public static enum RECOLOR_MODE_TYPE {
-      /** The way of geotools 2.4.4. The color map is used only for
-       *  the {@link SampleDimension (Grid)SampleDimensions} already defined
-       *  in the {@link GridCoverage2D}. */
-      GT_CLASSIC,
-      /** Alternative way of <a href="">Martin Schmitz</a>. The {@link GridCoverage2D}
-       *  is resampled accordingly to the given color map. */
-      MS_EXTENTION
-    }
-    /** The way the recoloring is processed. */
-    public static RECOLOR_MODE_TYPE RECOLOR_MODE = RECOLOR_MODE_TYPE.MS_EXTENTION;
-//ms-01.en
-
-    /** The Styled Layer Descriptor * */
-    private final RasterSymbolizer symbolizer;
-
-    /**
-     * Constructor
-     *
-     * @param symbolizer
-     *
-     */
-    public RasterSymbolizerSupport(final RasterSymbolizer symbolizer) {
-        this.symbolizer = symbolizer;
-    }
-
-    public GridCoverage recolorCoverage(GridCoverage grid)
-            throws IllegalArgumentException {
-        if (!(grid instanceof GridCoverage2D)) {
-            throw new IllegalArgumentException(
-                    "Cannot Recolor GridCoverage: GridCoverage2D is needed.");
-        }
-
-        // final ColorMap map = symbolizer.getColorMap();
-        // if (map == null)
-        // throw new IllegalArgumentException(
-        // "Cannot Recolor GridCoverage: ColorMap is needed.");
-        // final ColorMapEntry[] entries = map.getColorMapEntries();
-        // if (entries == null || entries.length <= 0)
-        // throw new IllegalArgumentException(
-        // "Cannot Recolor GridCoverage: ColorMapEntries are needed.");
-        // final int length = entries.length;
-        // final Map colorMap = new HashMap();
-        // for (int i = 0; i < length; i++)
-        // colorMap.put(entries[i].getQuantity().getValue(null), entries[i]
-        // .getQuantity().getValue(null));
-        // return Operations.DEFAULT.recolor(grid, new Map[] { Collections
-        // .singletonMap(null, colorMap) });
-
-        final GridCoverage2D gridCoverage = (GridCoverage2D) grid;
-        final int numBands = gridCoverage.getNumSampleDimensions();
-        final GridSampleDimension[] targetBands = new GridSampleDimension[numBands];
-        final Map[] colorMaps = new Map[numBands];
-        for (int band = 0; band < numBands; band++) { // TODO get separated
-//ms-01.sn
-//            LOGGER.debug("===== Debug original dimension =====");
-//            for ( Category c : (List<Category>)((GridSampleDimension)gridCoverage.getSampleDimension(band)).getCategories() )
-//              LOGGER.debug( c.toString() );
-            if ( RECOLOR_MODE == RECOLOR_MODE.MS_EXTENTION ) {
-              targetBands[band] = transformColormap(
-                  (GridSampleDimension)gridCoverage.getSampleDimension(band), this.symbolizer);
-              if ( targetBands[band] != gridCoverage.getSampleDimension(band))
-                continue;
-            }
-//ms-01.en
-            // R,G,B colorMaps from
-            // symbolizer
-            final Map categories = getCategories(band);
-            colorMaps[band] = categories;
-
-            /**
-             * Temporary solution, until the Recolor Operation is ported ...
-             */
-            targetBands[band] = (GridSampleDimension) transformColormap(band,
-                    gridCoverage.getSampleDimension(band), colorMaps);
-        }
-
-        GridCoverage2D createed = CoverageFactoryFinder.getGridCoverageFactory(null).create(
-                gridCoverage.getName(), gridCoverage.getRenderedImage(),
-                (GridGeometry2D) gridCoverage.getGridGeometry(), targetBands,
-                new GridCoverage[] { gridCoverage }, null);
-        return createed;
-    }
-
-    /**
-     * HELPER FUNCTIONS
-     */
-    public float getOpacity() {
-        float alpha = 1.0f;
-        Expression exp = this.symbolizer.getOpacity();
-        if (exp == null){
-            return alpha;
-        }
-        Number number = (Number) exp.evaluate(null,Float.class);
-        if (number == null){
-            return alpha;
-        }
-        return number.floatValue();
-    }
-
-    public Map getCategories(final int band) {
-        final String[] labels = getLabels(band);
-        final Color[] colors = getColors(band);
-
-        final Map categories = new HashMap();
-
-        /**
-         * Checking Categories
-         */
-        final int labelsLength = labels.length;
-        Color[] oldCmap;
-        int length;
-        Color[] newCmap;
-        for (int i = 0; i < labelsLength; i++) {
-            if (!categories.containsKey(labels[i])) {
-                categories.put(labels[i], new Color[] { colors[i] });
-            } else {
-                oldCmap = (Color[]) categories.get(labels[i]);
-                length = oldCmap.length;
-                newCmap = new Color[length + 1];
-                System.arraycopy(oldCmap, 0, newCmap, 0, length);
-                newCmap[length] = colors[i];
-                categories.put(labels[i], newCmap);
-            }
-        }
-
-        return categories;
-    }
-
-    public String[] getLabels(final int band) {
-        String[] labels = null;
-        if (this.symbolizer.getColorMap() != null) {
-            final ColorMapEntry[] colors = this.symbolizer.getColorMap()
-                    .getColorMapEntries();
-            final int numColors = colors.length;
-            labels = new String[numColors];
-            for (int ci = 0; ci < numColors; ci++) {
-                labels[ci] = colors[ci].getLabel();
-            }
-        }
-
-        return labels;
-    }
-
-    public Color[] getColors(final int band) {
-        Color[] colorTable = null;
-        if (this.symbolizer.getColorMap() != null) {
-            final ColorMapEntry[] colors = this.symbolizer.getColorMap()
-                    .getColorMapEntries();
-            final int numColors = colors.length;
-            colorTable = new Color[numColors];
-            double opacity;
-            for (int ci = 0; ci < numColors; ci++) {
-                opacity = toOpacity( colors[ci].getOpacity() );
-                colorTable[ci] = toColor( colors[ci].getColor(), opacity );
-                if (colorTable[ci] == null){
-                    return null;
-                }
-            }
-        }
-
-        return colorTable;
-    }
-    public static Color toColor( Expression exp, double opacity ){
-        if (exp == null){
-            return null;
-        }
-        Color color = (Color) exp.evaluate(null, Color.class);
-        int alpha = new Double(Math.ceil(255.0 * opacity)).intValue();
-        if( color != null ){
-            return new Color( color.getRed(), color.getGreen(), color.getBlue(), alpha );
-        }
-        else {
-            // the value morphing code failed us .. let's try by hand
-            Object obj = exp.evaluate( null );
-            if (obj == null){
-                return null;
-            }
-            Integer  intval = Integer.decode((String) obj);
-            int i = intval.intValue();
-            return new Color((i >> 16) & 0xFF, (i >> 8) & 0xFF, i & 0xFF, alpha);
-        }
-    }
-    public static double toOpacity( Expression opacity ) {
-        if (opacity == null) {
-            return 1.0;
-        }
-
-        Double value = (Double) opacity.evaluate(null, Double.class);
-        if (value == null) {
-            return 1.0;
-        }
-        return value.doubleValue();
-//
-//        opacity = (colors[ci].getOpacity() != null
-//                ? (colors[ci].getOpacity().getValue(null) instanceof String
-//                        ? Double.valueOf((String) colors[ci].getOpacity().getValue(null))
-//                        : (Double) colors[ci].getOpacity().getValue(null))
-//                : new Double(1.0));
-    }
-//ms-01.sn
-    /**
-     * Transforms an {@link Expression} to a double value.
-     */
-    public static double toQuantiy( Expression quantity ) {
-      if (quantity == null)
-          return 0.0;
-      Double value = (Double) quantity.evaluate(null, Double.class);
-      if (value == null)
-          return 0.0;
-      return value.doubleValue();
-    }
-
-    /**
-     * Extends an array with new values.
-     * @param source source array
-     * @param newElem new elements the array is extended with
-     * @return a new array object
-     */
-    private static <T> T[] extendArray(T[] source, T... newElem) {
-//ms: if SCHMITZM library is available:
-      return LangUtil.extendArray(source, newElem);
-//ms: if SCHMITZM library is NOT available:
-//      T[] newArray =  java.util.Arrays.copyOf(source, source.length+newElem.length);
-//      for (int i=0; i<newElem.length; i++)
-//        newArray[source.length+i] = newElem[i];
-//      return newArray;
-    }
-
-    public GridSampleDimension transformColormap(GridSampleDimension dimension, RasterSymbolizer symbolizer) {
-      if ( symbolizer == null || symbolizer.getColorMap() == null )
-        return dimension;
-
-      ColorMap             colorMap       = symbolizer.getColorMap();
-      ColorMapEntry[]      colorMapEntry  = colorMap.getColorMapEntries();
-      Map<String,Category> categories     = new HashMap<String,Category>();
-      int                  sampleQuantMin = Integer.MAX_VALUE;
-      int                  sampleQuantMax = Integer.MIN_VALUE;
-      double               geoQuantMin    = Integer.MAX_VALUE;
-      double               geoQuantMax    = Integer.MIN_VALUE;
-
-      //////////////////////////////////////////////////////////
-      // Workaround, so that "sampleQuan" is unique, even if
-      // the grid values are near to each other (e.g. 0.8 and
-      // 1.2)
-      int sampleQuanFactor = 10;
-      for (int i=1; i<colorMapEntry.length; i++) {
-        double geoQuant0 = toQuantiy(colorMapEntry[i-1].getQuantity());
-        geoQuant0        = Math.abs(geoQuant0);
-        double geoQuant1 = toQuantiy(colorMapEntry[i].getQuantity());
-        geoQuant1        = Math.abs(geoQuant1);
-        int sampleQuan0  = (int)Math.round(geoQuant0*sampleQuanFactor) + 1;
-        int sampleQuan1  = (int)Math.round(geoQuant1*sampleQuanFactor) + 1;
-        if ( sampleQuan0 == sampleQuan1 )
-          sampleQuanFactor *= 10;
-      }
-      //////////////////////////////////////////////////////////
-
-      for ( ColorMapEntry cme : colorMap.getColorMapEntries() ) {
-        double opacity     = toOpacity(cme.getOpacity());
-        Color  color       = toColor(cme.getColor(), opacity);
-        String label       = cme.getLabel();
-        if ( label == null )
-          label = "";
-        // the color map defines the geophysics value
-        double geoQuant    = toQuantiy(cme.getQuantity());
-        geoQuantMin        = Math.min(geoQuantMin, geoQuant);
-        geoQuantMax        = Math.max(geoQuantMax, geoQuant);
-        // create a sample quantity which is different from the geophysics value,
-        // so a GeophysicsCategory is created
-        //int    sampleQuan  = (int)Math.round(geoQuant)*10 + 1;
-        int    sampleQuan  = (int)Math.round(geoQuant*sampleQuanFactor) + 1;
-        sampleQuantMin     = Math.min(sampleQuantMin, sampleQuan);
-        sampleQuantMax     = Math.max(sampleQuantMax, sampleQuan);
-
-        // if a category for the label already exists, treat this
-        // as a range definition; otherwise create a single value
-        // Category
-        Category oldCategory = categories.get(label);
-        if ( oldCategory != null ) {
-          int     newMax    = Math.max(sampleQuan, (int)oldCategory.getRange().getMaximum());
-          int     newMin    = Math.min(sampleQuan, (int)oldCategory.getRange().getMinimum());
-          double  newMaxGeo = Math.max(geoQuant, oldCategory.geophysics(true).getRange().getMaximum());
-          double  newMinGeo = Math.min(geoQuant, oldCategory.geophysics(true).getRange().getMinimum());
-          Color[] newColors = extendArray(oldCategory.getColors(), color);
-          categories.put(label, new Category(
-              label,
-              newColors,
-              new NumberRange(newMin,    newMax),
-              new NumberRange(newMinGeo, newMaxGeo)
-          ));
-        } else
-          categories.put(label, new Category(
-              label,
-              new Color[] {color},
-              new NumberRange(sampleQuan, sampleQuan),
-              new NumberRange(geoQuant,   geoQuant)
-          ));
-
-      }
-
-      // if no categories are defined by color map do not resample; instead use
-      // the existing categories (and the grid/image internal color definition)
-      if ( categories.isEmpty() )
-        return dimension;
-
-      // If NoData-Values are set, create a additional Categories
-      double[] noDataValues = dimension.getNoDataValues();
-      if ( noDataValues == null )
-        noDataValues = new double[0];
-      for (double noDataValue : noDataValues ) {
-        int value   = sampleQuantMax + 10; // value not already used
-        sampleQuantMin = Math.min(sampleQuantMin, (int)noDataValue);
-        sampleQuantMax = Math.max(sampleQuantMax, (int)noDataValue);
-        categories.put(String.valueOf("NoData_"+noDataValue), createNoDataCategory(value, noDataValue));
-      }
-
-      // Declare "all" values smaller/greater the color map values
-      // automatically as NoData
-      final int lowerStart = Integer.MIN_VALUE;
-      final int higherEnd  = Integer.MAX_VALUE;
-      categories.put("_autoNoData1_", new Category(
-          "_autoNoData1_",
-          new Color[] { new Color(0,0,0,0) },
-          new NumberRange(sampleQuantMax+1, sampleQuantMax+2),
-          new NumberRange(geoQuantMax+1,    higherEnd)
-      ));
-      if ( sampleQuantMin <= sampleQuantMax )
-        categories.put("_autoNoData2_", new Category(
-            "_autoNoData2_",
-            new Color[] { new Color(0,0,0,0) },
-            //new NumberRange(colorMapMin-2, colorMapMin-1), // logischer, aber klappt nicht!?
-            new NumberRange(sampleQuantMax+3, sampleQuantMax+4),
-            new NumberRange(lowerStart,       geoQuantMin-1)
-        ));
-      //categories.put("_autoNoData2_", Category.NODATA);
-
-      // Create the GridSampleDimension
-      GridSampleDimension gsd = new GridSampleDimension(
-          dimension.getDescription().toString(),
-          categories.values().toArray(new Category[0]),
-          dimension.getUnits()
-      ).geophysics(true);
-
-//      LOGGER.debug("===== Debug new dimension =====");
-//      for ( Category c : (List<Category>)gsd.getCategories() )
-//        LOGGER.debug( c.toString() );
-
-      return gsd;
-    }
-
-    /**
-     * Creates a {@link Category} for a NoData-value, which will be displayed transparently.
-     * @param value sample value
-     * @param geoValue geophysics value representing the NoData
-     */
-    public static Category createNoDataCategory(int value, double geoValue) {
-//ms: if SCHMITZM library is available:
-      return StylingUtil.createNoDataCategory(value, geoValue);
-//ms: if SCHMITZM library is NOT available:
-//      return new Category(
-//          Vocabulary.formatInternational(VocabularyKeys.NODATA),
-//          new Color[] { new Color(0,0,0,0) },
-//          new NumberRange(value, value),
-//          new NumberRange(geoValue, geoValue)
-//      );
-    }
-//ms-01.en
-
-    /**
-     * Transform the supplied RGB colors.
-     */
-    public SampleDimension transformColormap(final int band,
-            SampleDimension dimension, final Map[] colorMaps) {
-        if (colorMaps == null || colorMaps.length == 0) {
-            return dimension;
-        }
-        boolean changed = false;
-        final Map colorMap = colorMaps[Math.min(band, colorMaps.length - 1)];
-        final List categoryList = ((GridSampleDimension) dimension)
-                .getCategories();
-        if (categoryList == null) {
-            return dimension;
-        }
-        final Category categories[] = (Category[]) categoryList.toArray();
-        Category category;
-        Color[] colors;
-        final int length = categories.length;
-        NumberRange range;
-        int lower;
-        int upper;
-        for (int j = length; --j >= 0;) {
-            category = categories[j];
-            colors = (Color[]) colorMap.get(category.getName().toString());
-            if (colors == null) {
-                if (!category.isQuantitative()) {
-                    continue;
-                }
-                colors = (Color[]) colorMap.get(null);
-                if (colors == null) {
-                    continue;
-                }
-            }
-            range = category.getRange();
-            lower = ((Number) range.getMinValue()).intValue();
-            upper = ((Number) range.getMaxValue()).intValue();
-            if (!range.isMinIncluded())
-                lower++;
-            if (range.isMaxIncluded())
-                upper++;
-            category = category.recolor(colors);
-            if (!categories[j].equals(category)) {
-                categories[j] = category;
-                changed = true;
-            }
-        }
-        return changed ? new GridSampleDimension(dimension.getDescription(),
-                categories, dimension.getUnits()) : dimension;
-    }
-}

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/io/GeoImportUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/io/GeoImportUtil.java	2009-08-31 11:10:08 UTC (rev 345)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/io/GeoImportUtil.java	2009-08-31 11:37:01 UTC (rev 346)
@@ -40,6 +40,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
@@ -62,6 +63,7 @@
 import org.geotools.factory.Hints;
 import org.geotools.feature.FeatureCollection;
 import org.geotools.feature.FeatureCollections;
+import org.geotools.gce.arcgrid.ArcGridReader;
 import org.geotools.gce.geotiff.GeoTiffReader;
 import org.geotools.gce.image.WorldImageReader;
 import org.geotools.geometry.Envelope2D;
@@ -336,11 +338,13 @@
 	 * @param crs
 	 *            CoordinateReferenceSystem fuer das Raster (kann {@code null}
 	 *            sein)
+	 * @throws Exception 
+	 * @throws MalformedURLException 
 	 * @throws java.lang.Exception
 	 *             bei irgendeinem Fehler TODO
 	 */
 	public static GridCoverage2D readGridFromArcInfoASCII(File file,
-			CoordinateReferenceSystem crs) throws Exception {
+			CoordinateReferenceSystem crs) throws MalformedURLException, Exception  {
 		return readGridFromArcInfoASCII(file.toURI().toURL(), crs);
 
 		// ArcGridRaster reader = new ArcGridRaster( new BufferedReader( new
@@ -382,67 +386,6 @@
 	}
 
 	/**
-	 * Diese Methode importiert ein Raster aus einer Datei im
-	 * ArcInfoASCII-Grid-Format. Wenn kein CRS angegeben wird, wird versucht das
-	 * CRS aus einem prj-File (EPSG-Code "EPSG:..." oder WKT-Definition) zu
-	 * lesen. Ist dies nicht erfolgreich, wird {@link #DEFAULT_CRS} als CRS
-	 * verwendet.
-	 * 
-	 * @param url
-	 *            Link to Arc/Info GRID ASCII file
-	 * @param crs
-	 *            CoordinateReferenceSystem fuer das Raster (kann {@code null}
-	 *            sein)
-	 * @throws java.lang.Exception
-	 *             bei irgendeinem Fehler
-	 */
-	public static GridCoverage2D readGridFromArcInfoASCII(URL url,
-			CoordinateReferenceSystem crs) throws Exception {
-		ArcGridRaster reader = new ArcGridRaster(new BufferedReader(
-				new InputStreamReader(url.openStream())), false);
-		WritableRaster raster = reader.readRaster();
-		if (crs == null)
-			crs = determineProjection(IOUtil.changeUrlExt(url, "prj"));
-
-		LOGGER.debug("Position  " + reader.getXlCorner() + " / "
-				+ reader.getYlCorner());
-		LOGGER.debug("Size      " + reader.getNCols() + " / "
-				+ reader.getNRows());
-		LOGGER.debug("Min/Max   " + reader.getMinValue() + " / "
-				+ reader.getMaxValue());
-		LOGGER.debug("NoData    " + reader.getNoData());
-		LOGGER.debug("CellSize  " + reader.getCellSize());
-
-		Double x = reader.getXlCorner(); // Suedwestliche Ecke!
-		Double y = reader.getYlCorner(); // Suedwestliche Ecke!
-		if (y.isNaN() || x.isNaN()) {
-			throw new IllegalArgumentException(
-					"The parameters xlCorner and/or ylCorner could not be read. Hint: Check if the file defines 'xlcenter' instead of 'xlcorner'. If so, just replace all 'center' with 'corner' and try again.");
-		}
-
-		Double w = (reader.getNCols() * reader.getCellSize()); // reale Breite =
-		// RasterSpalten
-		// * Aufloesung
-		Double h = (reader.getNRows() * reader.getCellSize()); // reale Hoehe =
-		// RasterZeilen
-		// * Aufloesung
-		Envelope2D envelope = new Envelope2D(crs, new Rectangle2D.Double(x, y,
-				w, h));
-
-		// WICHTIG: Name des Rasters sollte Leer-String sein, da ansonsten das
-		// Coloring des Rasters nicht klappt.
-		// --> Name der Categories muss (warum auch immer) mit dem Namen
-		// des Rasters uebereinstimmen!!!
-		return new GridCoverageFactory().create("", raster, envelope);
-		//
-		// === OHNE ArcGridRaster ===
-		// // ArcGridReader reader = new ArcGridReader( new BufferedReader( new
-		// InputStreamReader( new FileInputStream(file) ) ));
-		// ArcGridReader reader = new ArcGridReader( file );
-		// return (GridCoverage2D)reader.read(null);
-	}
-
-	/**
 	 * Diese Methode erzeugt einen {@link AbstractGridCoverage2DReader} aus
 	 * einer Datei im GeoTIFF-Format. Zunaechst wird versucht, die
 	 * Geo-Informationen (Referenz+CRS) aus den TIFF-Metadaten zu ermitteln. Ist
@@ -626,7 +569,25 @@
 		return readGridRasterFromArcInfoASCII(file, null);
 	}
 
+	
+
+
 	/**
+	@param crs may be <code>null</code>
+	 */
+	public static GridCoverage2D readGridFromArcInfoASCII(Object input,
+			CoordinateReferenceSystem crs) throws Exception {
+		
+		Hints hints = new Hints();
+		hints.put(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM, crs);
+		
+		ArcGridReader reader = new ArcGridReader(input ,hints);
+		GridCoverage2D gc = (GridCoverage2D) reader.read(null);
+		return gc;
+	}
+	
+	
+	/**
 	 * Diese Methode importiert ein Raster aus einer Datei im
 	 * ArcInfoASCII-Grid-Format. Wenn kein CRS angegeben wird, wird versucht das
 	 * CRS aus einem prj-File (EPSG-Code "EPSG:..." oder WKT-Definition) zu
@@ -638,33 +599,39 @@
 	 * @param crs
 	 *            CoordinateReferenceSystem fuer das Raster (kann {@code null}
 	 *            sein)
+	 * @throws Exception 
 	 * @throws java.lang.Exception
 	 *             bei irgendeinem Fehler
 	 */
 	public static WritableGridRaster readGridRasterFromArcInfoASCII(File file,
 			CoordinateReferenceSystem crs) throws Exception {
-		ArcGridRaster reader = new ArcGridRaster(new BufferedReader(
-				new InputStreamReader(new FileInputStream(file))), false);
-		WritableRaster raster = reader.readRaster();
-		float x = (float) reader.getXlCorner(); // Suedwestliche Ecke!
-		float y = (float) reader.getYlCorner(); // Suedwestliche Ecke!
-		float w = (float) (reader.getNCols() * reader.getCellSize()); // reale
-		// Breite
-		// =
-		// RasterSpalten
-		// *
-		// Aufloesung
-		float h = (float) (reader.getNRows() * reader.getCellSize()); // reale
-		// Hoehe
-		// =
-		// RasterZeilen
-		// *
-		// Aufloesung
-		// Projektion einlesen
-		if (crs == null)
-			crs = determineProjection(file);
-		return new WritableGridRaster(raster,
-				new Rectangle2D.Float(x, y, w, h), crs);
+		
+		GridCoverage2D grid = readGridFromArcInfoASCII(file, crs);
+		WritableRaster raster = grid.getRenderedImage().copyData(null);
+		return new WritableGridRaster(raster,grid.getEnvelope2D()) ;
+		
+//		ArcGridRaster reader = new ArcGridRaster(new BufferedReader(
+//				new InputStreamReader(new FileInputStream(file))), false);
+//		WritableRaster raster = reader.readRaster();
+//		float x = (float) reader.getXlCorner(); // Suedwestliche Ecke!
+//		float y = (float) reader.getYlCorner(); // Suedwestliche Ecke!
+//		float w = (float) (reader.getNCols() * reader.getCellSize()); // reale
+//		// Breite
+//		// =
+//		// RasterSpalten
+//		// *
+//		// Aufloesung
+//		float h = (float) (reader.getNRows() * reader.getCellSize()); // reale
+//		// Hoehe
+//		// =
+//		// RasterZeilen
+//		// *
+//		// Aufloesung
+//		// Projektion einlesen
+//		if (crs == null)
+//			crs = determineProjection(file);
+//		return new WritableGridRaster(raster,
+//				new Rectangle2D.Float(x, y, w, h), crs);
 
 		// === OHNE ArcGridRaster ===
 		// GridCoverage2D grid = readGridFromArcInfoASCII(null,input);

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/io/GeoImportUtilURL.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/io/GeoImportUtilURL.java	2009-08-31 11:10:08 UTC (rev 345)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/io/GeoImportUtilURL.java	2009-08-31 11:37:01 UTC (rev 346)
@@ -31,6 +31,7 @@
 
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
+import java.io.File;
 import java.io.IOException;
 import java.net.URL;
 
@@ -41,6 +42,7 @@
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.coverage.grid.GridCoverageFactory;
 import org.geotools.factory.Hints;
+import org.geotools.gce.arcgrid.ArcGridReader;
 import org.geotools.gce.geotiff.GeoTiffReader;
 import org.geotools.geometry.Envelope2D;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
@@ -196,5 +198,50 @@
 		return gc;
 	}
 
+//		
+//		ArcGridRaster reader = new ArcGridRaster(new BufferedReader(
+//				new InputStreamReader(url.openStream())), false);
+//		WritableRaster raster = reader.readRaster();
+//		if (crs == null)
+//			crs = determineProjection(IOUtil.changeUrlExt(url, "prj"));
+//
+//		LOGGER.debug("Position  " + reader.getXlCorner() + " / "
+//				+ reader.getYlCorner());
+//		LOGGER.debug("Size      " + reader.getNCols() + " / "
+//				+ reader.getNRows());
+//		LOGGER.debug("Min/Max   " + reader.getMinValue() + " / "
+//				+ reader.getMaxValue());
+//		LOGGER.debug("NoData    " + reader.getNoData());
+//		LOGGER.debug("CellSize  " + reader.getCellSize());
+//
+//		Double x = reader.getXlCorner(); // Suedwestliche Ecke!
+//		Double y = reader.getYlCorner(); // Suedwestliche Ecke!
+//		if (y.isNaN() || x.isNaN()) {
+//			throw new IllegalArgumentException(
+//					"The parameters xlCorner and/or ylCorner could not be read. Hint: Check if the file defines 'xlcenter' instead of 'xlcorner'. If so, just replace all 'center' with 'corner' and try again.");
+//		}
+//
+//		Double w = (reader.getNCols() * reader.getCellSize()); // reale Breite =
+//		// RasterSpalten
+//		// * Aufloesung
+//		Double h = (reader.getNRows() * reader.getCellSize()); // reale Hoehe =
+//		// RasterZeilen
+//		// * Aufloesung
+//		Envelope2D envelope = new Envelope2D(crs, new Rectangle2D.Double(x, y,
+//				w, h));
+//
+//		// WICHTIG: Name des Rasters sollte Leer-String sein, da ansonsten das
+//		// Coloring des Rasters nicht klappt.
+//		// --> Name der Categories muss (warum auch immer) mit dem Namen
+//		// des Rasters uebereinstimmen!!!
+//		return new GridCoverageFactory().create("", raster, envelope);
+//		//
+//		// === OHNE ArcGridRaster ===
+//		// // ArcGridReader reader = new ArcGridReader( new BufferedReader( new
+//		// InputStreamReader( new FileInputStream(file) ) ));
+//		// ArcGridReader reader = new ArcGridReader( file );
+//		// return (GridCoverage2D)reader.read(null);
+	
 
+
 }



More information about the Schmitzm-commits mailing list