[Schmitzm-commits] r354 - branches/1.0-gt2-2.6/src/schmitzm/geotools/io
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Aug 31 15:05:46 CEST 2009
Author: alfonx
Date: 2009-08-31 15:05:45 +0200 (Mon, 31 Aug 2009)
New Revision: 354
Modified:
branches/1.0-gt2-2.6/src/schmitzm/geotools/io/GeoExportUtil.java
Log:
Migrating to GT2.6...
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/io/GeoExportUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/io/GeoExportUtil.java 2009-08-31 12:52:25 UTC (rev 353)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/io/GeoExportUtil.java 2009-08-31 13:05:45 UTC (rev 354)
@@ -31,9 +31,7 @@
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
-import java.awt.image.Raster;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
@@ -45,9 +43,11 @@
import org.geotools.data.Transaction;
import org.geotools.data.shapefile.ShapefileDataStore;
import org.geotools.feature.FeatureCollection;
+import org.geotools.gce.arcgrid.ArcGridWriter;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.metadata.Identifier;
+import org.opengis.parameter.GeneralParameterValue;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import schmitzm.data.WritableGridRaster;
@@ -119,20 +119,30 @@
* @throws java.lang.Exception bei irgendeinem Fehler
*/
public static void writeGridToArcInfoASCII(GridCoverage2D grid, File outFile) throws Exception {
- Raster raster = grid.getRenderedImage().getData();
- Rectangle2D rect = grid.getEnvelope2D();
- // Geo-Koordinaten
- double x = rect.getX();
- double y = rect.getY();
- // Zellenbreite
- double cellsize = rect.getWidth() / raster.getWidth();
- // Exportieren
-// throw new UnsupportedOperationException("GeoExportUtil.writeGridToArcInfoASCII(.) has still to be breaked from ArcGridRaster dependency!");
- ArcGridRaster writer = new ArcGridRaster(new PrintWriter( new FileOutputStream(outFile) ));
- writer.writeRaster(raster, x, y, cellsize, false);
- // Projektion schreiben
- writeProjectionFile( grid.getCoordinateReferenceSystem(),
- IOUtil.changeFileExt(outFile,"prj"));
+
+ ArcGridWriter arcGridWriter = new ArcGridWriter(outFile);
+ GeneralParameterValue[] parameters = new GeneralParameterValue[] {};
+ arcGridWriter.write(grid, parameters);
+ arcGridWriter.dispose();
+
+// Raster raster = grid.getRenderedImage().getData();
+// Rectangle2D rect = grid.getEnvelope2D();
+// // Geo-Koordinaten
+// double x = rect.getX();
+// double y = rect.getY();
+// // Zellenbreite
+// double cellsize = rect.getWidth() / raster.getWidth();
+// // Exportieren
+//// throw new UnsupportedOperationException("GeoExportUtil.writeGridToArcInfoASCII(.) has still to be breaked from ArcGridRaster dependency!");
+// ArcGridRaster writer = new ArcGridRaster(new PrintWriter( new FileOutputStream(outFile) ));
+// writer.writeRaster(raster, x, y, cellsize, false);
+
+
+
+ // Die peojektion wird vom ArcGridWriter automaitsch mit-geschrieben!
+// // Projektion schreiben
+// writeProjectionFile( grid.getCoordinateReferenceSystem(),
+// IOUtil.changeFileExt(outFile,"prj"));
}
/**
@@ -172,12 +182,22 @@
* @throws java.lang.Exception bei irgendeinem Fehler
*/
public static void writeGridRasterToArcInfoASCII(WritableGridRaster grid, File outFile) throws Exception {
- // Exportieren
- ArcGridRaster writer = new ArcGridRaster(new PrintWriter(new FileOutputStream(outFile)));
- writer.writeRaster(grid, grid.getX(), grid.getY(), grid.getCellWidth(), false);
- // Projektion schreiben
- writeProjectionFile( grid.getCoordinateReferenceSystem(),
- IOUtil.changeFileExt(outFile,"prj"));
+
+ ArcGridWriter arcGridWriter = new ArcGridWriter(outFile);
+ GeneralParameterValue[] parameters = new GeneralParameterValue[] {};
+
+ arcGridWriter.write(grid, parameters);
+ arcGridWriter.dispose();
+
+ // Hinweis: .prj wird vom ArcGridWriter automaitsch geschrieben
+
+//
+// // Exportieren
+// ArcGridRaster writer = new ArcGridRaster(new PrintWriter(new FileOutputStream(outFile)));
+// writer.writeRaster(grid, grid.getX(), grid.getY(), grid.getCellWidth(), false);
+// // Projektion schreiben
+// writeProjectionFile( grid.getCoordinateReferenceSystem(),
+// IOUtil.changeFileExt(outFile,"prj"));
}
/**
More information about the Schmitzm-commits
mailing list