diff flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java @ 1108:5b1198c27d43

Export riveraxis and crosssections to shapefiles for WSPLGEN. flys-artifacts/trunk@2612 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 30 Aug 2011 15:17:43 +0000
parents 005c2964f9af
children faca1825818e
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Tue Aug 30 14:13:06 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Tue Aug 30 15:17:43 2011 +0000
@@ -14,6 +14,8 @@
 
 import org.opengis.feature.simple.SimpleFeature;
 import org.opengis.feature.simple.SimpleFeatureType;
+import org.opengis.referencing.FactoryException;
+import org.opengis.referencing.NoSuchAuthorityCodeException;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 
 import org.geotools.data.DataStoreFactorySpi;
@@ -24,9 +26,9 @@
 import org.geotools.data.shapefile.ShapefileDataStoreFactory;
 import org.geotools.feature.FeatureIterator;
 import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.SchemaException;
 import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
 import org.geotools.geojson.feature.FeatureJSON;
+import org.geotools.referencing.CRS;
 
 
 public class GeometryUtils {
@@ -55,22 +57,27 @@
 
 
     public static SimpleFeatureType buildFeatureType(
-        String                    name,
-        String                    srs,
-        Class                     geometryType,
-        CoordinateReferenceSystem crs)
-    throws SchemaException
+        String name, String srs, Class geometryType)
     {
-        SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
+        try {
+            SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
+            CoordinateReferenceSystem crs    = CRS.decode(srs);
 
-        builder.setName("flys");
-        builder.setNamespaceURI("http://www.intevation.de/");
-        builder.setCRS(crs);
-        builder.setSRS(srs);
+            builder.setName("flys");
+            builder.setNamespaceURI("http://www.intevation.de/");
+            builder.setCRS(crs);
+            builder.setSRS(srs);
 
-        builder.add("geometry", geometryType, crs);
+            builder.add("geometry", geometryType, crs);
 
-        return builder.buildFeatureType();
+            return builder.buildFeatureType();
+        }
+        catch (NoSuchAuthorityCodeException nsae) {
+        }
+        catch (FactoryException fe) {
+        }
+
+        return null;
     }
 
 

http://dive4elements.wald.intevation.org