Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java @ 1119:faca1825818e
Write additional attributes ELEVATION and KILOMETER into crosssection track shapefiles.
flys-artifacts/trunk@2626 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 01 Sep 2011 07:04:01 +0000 |
parents | 5b1198c27d43 |
children | 66783d957201 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java Wed Aug 31 13:19:29 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java Thu Sep 01 07:04:01 2011 +0000 @@ -59,6 +59,25 @@ public static SimpleFeatureType buildFeatureType( String name, String srs, Class geometryType) { + return buildFeatureType(name, srs, geometryType, null); + } + + + /** + * Creates a new SimpleFeatureType using a SimpleFeatureTypeBuilder. + * + * @param name The name of the FeatureType. + * @param srs The SRS (e.g. "EPSG:31466"). + * @param geometryType The geometry type's class (e.g. Polygon.class). + * @param attrs Optional. An object with attribute-name/attribute-class + * pairs where index 0 specifies the name as string and index 1 the type + * as class. + * + * @return a new SimpleFeatureType. + */ + public static SimpleFeatureType buildFeatureType( + String name, String srs, Class geometryType, Object[][] attrs) + { try { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); CoordinateReferenceSystem crs = CRS.decode(srs); @@ -70,6 +89,12 @@ builder.add("geometry", geometryType, crs); + if (attrs != null) { + for (Object[] attr: attrs) { + builder.add((String) attr[0], (Class) attr[1]); + } + } + return builder.buildFeatureType(); } catch (NoSuchAuthorityCodeException nsae) {