comparison 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
comparison
equal deleted inserted replaced
1107:005c2964f9af 1108:5b1198c27d43
12 import com.vividsolutions.jts.geom.Coordinate; 12 import com.vividsolutions.jts.geom.Coordinate;
13 import com.vividsolutions.jts.geom.Geometry; 13 import com.vividsolutions.jts.geom.Geometry;
14 14
15 import org.opengis.feature.simple.SimpleFeature; 15 import org.opengis.feature.simple.SimpleFeature;
16 import org.opengis.feature.simple.SimpleFeatureType; 16 import org.opengis.feature.simple.SimpleFeatureType;
17 import org.opengis.referencing.FactoryException;
18 import org.opengis.referencing.NoSuchAuthorityCodeException;
17 import org.opengis.referencing.crs.CoordinateReferenceSystem; 19 import org.opengis.referencing.crs.CoordinateReferenceSystem;
18 20
19 import org.geotools.data.DataStoreFactorySpi; 21 import org.geotools.data.DataStoreFactorySpi;
20 import org.geotools.data.FeatureStore; 22 import org.geotools.data.FeatureStore;
21 import org.geotools.data.DefaultTransaction; 23 import org.geotools.data.DefaultTransaction;
22 import org.geotools.data.Transaction; 24 import org.geotools.data.Transaction;
23 import org.geotools.data.shapefile.ShapefileDataStore; 25 import org.geotools.data.shapefile.ShapefileDataStore;
24 import org.geotools.data.shapefile.ShapefileDataStoreFactory; 26 import org.geotools.data.shapefile.ShapefileDataStoreFactory;
25 import org.geotools.feature.FeatureIterator; 27 import org.geotools.feature.FeatureIterator;
26 import org.geotools.feature.FeatureCollection; 28 import org.geotools.feature.FeatureCollection;
27 import org.geotools.feature.SchemaException;
28 import org.geotools.feature.simple.SimpleFeatureTypeBuilder; 29 import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
29 import org.geotools.geojson.feature.FeatureJSON; 30 import org.geotools.geojson.feature.FeatureJSON;
31 import org.geotools.referencing.CRS;
30 32
31 33
32 public class GeometryUtils { 34 public class GeometryUtils {
33 35
34 private GeometryUtils() { 36 private GeometryUtils() {
53 return "" + c[0].x + " " + c[1].y + " " + c[1].x + " " + c[0].y; 55 return "" + c[0].x + " " + c[1].y + " " + c[1].x + " " + c[0].y;
54 } 56 }
55 57
56 58
57 public static SimpleFeatureType buildFeatureType( 59 public static SimpleFeatureType buildFeatureType(
58 String name, 60 String name, String srs, Class geometryType)
59 String srs,
60 Class geometryType,
61 CoordinateReferenceSystem crs)
62 throws SchemaException
63 { 61 {
64 SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); 62 try {
63 SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
64 CoordinateReferenceSystem crs = CRS.decode(srs);
65 65
66 builder.setName("flys"); 66 builder.setName("flys");
67 builder.setNamespaceURI("http://www.intevation.de/"); 67 builder.setNamespaceURI("http://www.intevation.de/");
68 builder.setCRS(crs); 68 builder.setCRS(crs);
69 builder.setSRS(srs); 69 builder.setSRS(srs);
70 70
71 builder.add("geometry", geometryType, crs); 71 builder.add("geometry", geometryType, crs);
72 72
73 return builder.buildFeatureType(); 73 return builder.buildFeatureType();
74 }
75 catch (NoSuchAuthorityCodeException nsae) {
76 }
77 catch (FactoryException fe) {
78 }
79
80 return null;
74 } 81 }
75 82
76 83
77 public static List<SimpleFeature> parseGeoJSON( 84 public static List<SimpleFeature> parseGeoJSON(
78 String geojson, SimpleFeatureType ft 85 String geojson, SimpleFeatureType ft

http://dive4elements.wald.intevation.org