Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/utils/ShapeFileWriter.java @ 727:22dc921cd8b1
Added generic Export for all Columns which are in an ResultValue.
gnv-artifacts/trunk@763 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 12 Mar 2010 11:28:36 +0000 |
parents | 6eccb68a8b99 |
children | f82e57a60124 |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/ShapeFileWriter.java Wed Mar 10 15:04:30 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/ShapeFileWriter.java Fri Mar 12 11:28:36 2010 +0000 @@ -33,6 +33,7 @@ import com.vividsolutions.jts.io.WKTReader; import de.intevation.gnv.geobackend.base.Result; +import de.intevation.gnv.geobackend.base.ResultDescriptor; /** * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) @@ -206,17 +207,22 @@ SimpleFeatureBuilder featureBuilder = null; FeatureCollection<SimpleFeatureType, SimpleFeature> collection = FeatureCollections.newCollection(); - + int j = 0; for (Result result: data) { + j++; try { Geometry g = wktReader.read(result.getString(0)); + ResultDescriptor rd = result.getResultDescriptor(); + int columns = rd.getColumnCount(); if (type == null){ try { geomType = g.getGeometryType().toUpperCase(); - type = DataUtilities.createType( - name, - "geom:"+g.getGeometryType()+":srid=4326"); - // TODO add other AttributeTypes + String schema = "geom:"+g.getGeometryType()+":srid=4326"; + for (int i = 1; i < columns; i++){ + schema+=","+rd.getColumnName(i)+ + ":"+rd.getColumnClassName(i); + } + type = DataUtilities.createType(name, schema); } catch (SchemaException se) { log.error(se.getLocalizedMessage(), se); @@ -225,10 +231,13 @@ featureBuilder = new SimpleFeatureBuilder(type); } featureBuilder.add(g); + for (int i = 1; i < columns; i++){ + featureBuilder.add(result.getObject(i)); + } SimpleFeature feature = featureBuilder.buildFeature(null); collection.add(feature); } catch (ParseException e) { - log.error(e,e); + log.error("cannot create geometry "+j+" for "+result.getString(0)); } catch (java.lang.IllegalArgumentException e){ log.error("cannot create geometry for "+result.getString(0)); }