diff flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java @ 1107:005c2964f9af

Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles. flys-artifacts/trunk@2610 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 30 Aug 2011 14:13:06 +0000
parents e9f66d63bdd0
children 5b1198c27d43
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Tue Aug 30 11:09:54 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Tue Aug 30 14:13:06 2011 +0000
@@ -14,9 +14,9 @@
 
 import org.opengis.feature.simple.SimpleFeature;
 import org.opengis.feature.simple.SimpleFeatureType;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
 
 import org.geotools.data.DataStoreFactorySpi;
-import org.geotools.data.DataUtilities;
 import org.geotools.data.FeatureStore;
 import org.geotools.data.DefaultTransaction;
 import org.geotools.data.Transaction;
@@ -27,7 +27,6 @@
 import org.geotools.feature.SchemaException;
 import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
 import org.geotools.geojson.feature.FeatureJSON;
-import org.geotools.referencing.crs.DefaultGeographicCRS;
 
 
 public class GeometryUtils {
@@ -55,38 +54,26 @@
     }
 
 
-    /**
-     * Returns a SimpleFeatureType used while parsing the GeoJSON string that
-     * represents the barriers entered by the user.
-     *
-     * @param srs The SRS that is used by the GeoJSON string.
-     *
-     * @return a SimpleFeatureType.
-     */
-    public static SimpleFeatureType buildBarriersFeatureType(String srs) {
+    public static SimpleFeatureType buildFeatureType(
+        String                    name,
+        String                    srs,
+        Class                     geometryType,
+        CoordinateReferenceSystem crs)
+    throws SchemaException
+    {
         SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
 
         builder.setName("flys");
         builder.setNamespaceURI("http://www.intevation.de/");
+        builder.setCRS(crs);
         builder.setSRS(srs);
-        builder.setDefaultGeometry("geometry");
 
-        builder.add("geometry", org.opengis.geometry.Geometry.class);
+        builder.add("geometry", geometryType, crs);
 
         return builder.buildFeatureType();
     }
 
 
-    public static SimpleFeatureType buildFeatureType(
-        String name, String srid, String geometryType)
-    throws SchemaException
-    {
-        String schema = "geom:" + geometryType + ":srid=" + srid;
-
-        return DataUtilities.createType(name, schema);
-    }
-
-
     public static List<SimpleFeature> parseGeoJSON(
         String geojson, SimpleFeatureType ft
     ) {
@@ -125,9 +112,7 @@
 
         ShapefileDataStore newDataStore =
             (ShapefileDataStore)dataStoreFactory.createNewDataStore(params);
-
         newDataStore.createSchema(featureType);
-        newDataStore.forceSchemaCRS(DefaultGeographicCRS.WGS84);
 
         Transaction transaction = new DefaultTransaction("create");
 

http://dive4elements.wald.intevation.org