comparison flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java @ 3286:f062b5a90e26

Add showpointlabel style attribute flys-artifacts/trunk@4948 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Thu, 12 Jul 2012 11:51:32 +0000
parents 33aa37e6d98f
children c8f670ae96e8
comparison
equal deleted inserted replaced
3285:dc083f61253a 3286:f062b5a90e26
1 package de.intevation.flys.utils; 1 package de.intevation.flys.utils;
2 2
3 import com.vividsolutions.jts.geom.Coordinate;
4 import com.vividsolutions.jts.geom.Envelope;
5 import com.vividsolutions.jts.geom.Geometry;
6
7 import de.intevation.flys.model.RiverAxis;
8
9 import java.io.File;
3 import java.io.IOException; 10 import java.io.IOException;
4 import java.io.File;
5 import java.io.Serializable; 11 import java.io.Serializable;
6 import java.net.MalformedURLException; 12 import java.net.MalformedURLException;
7 import java.util.ArrayList; 13 import java.util.ArrayList;
8 import java.util.HashMap; 14 import java.util.HashMap;
9 import java.util.List; 15 import java.util.List;
10 import java.util.Map; 16 import java.util.Map;
11 17
12 import org.apache.log4j.Logger; 18 import org.apache.log4j.Logger;
13 19 import org.geotools.data.DataStoreFactorySpi;
14 import com.vividsolutions.jts.geom.Coordinate; 20 import org.geotools.data.DefaultTransaction;
15 import com.vividsolutions.jts.geom.Envelope; 21 import org.geotools.data.FeatureWriter;
16 import com.vividsolutions.jts.geom.Geometry; 22 import org.geotools.data.Transaction;
17 23 import org.geotools.data.shapefile.ShapefileDataStore;
24 import org.geotools.data.shapefile.ShapefileDataStoreFactory;
25 import org.geotools.data.simple.SimpleFeatureIterator;
26 import org.geotools.feature.FeatureCollection;
27 import org.geotools.feature.FeatureIterator;
28 import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
29 import org.geotools.geojson.feature.FeatureJSON;
30 import org.geotools.geometry.jts.JTS;
31 import org.geotools.referencing.CRS;
18 import org.opengis.feature.simple.SimpleFeature; 32 import org.opengis.feature.simple.SimpleFeature;
19 import org.opengis.feature.simple.SimpleFeatureType; 33 import org.opengis.feature.simple.SimpleFeatureType;
20 import org.opengis.referencing.FactoryException; 34 import org.opengis.referencing.FactoryException;
21 import org.opengis.referencing.NoSuchAuthorityCodeException; 35 import org.opengis.referencing.NoSuchAuthorityCodeException;
22 import org.opengis.referencing.crs.CoordinateReferenceSystem; 36 import org.opengis.referencing.crs.CoordinateReferenceSystem;
23 import org.opengis.referencing.operation.MathTransform; 37 import org.opengis.referencing.operation.MathTransform;
24 import org.opengis.referencing.operation.TransformException; 38 import org.opengis.referencing.operation.TransformException;
25
26 import org.geotools.data.DataStoreFactorySpi;
27 import org.geotools.data.DefaultTransaction;
28 import org.geotools.data.FeatureWriter;
29 import org.geotools.data.Transaction;
30 import org.geotools.data.shapefile.ShapefileDataStore;
31 import org.geotools.data.shapefile.ShapefileDataStoreFactory;
32 import org.geotools.data.simple.SimpleFeatureIterator;
33 import org.geotools.feature.FeatureIterator;
34 import org.geotools.feature.FeatureCollection;
35 import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
36 import org.geotools.geojson.feature.FeatureJSON;
37 import org.geotools.geometry.jts.JTS;
38 import org.geotools.referencing.CRS;
39
40 import de.intevation.flys.model.RiverAxis;
41 39
42 40
43 public class GeometryUtils { 41 public class GeometryUtils {
44 42
45 private static final Logger logger = Logger.getLogger(GeometryUtils.class); 43 private static final Logger logger = Logger.getLogger(GeometryUtils.class);
132 return "" + lowerX + " " + lowerY + " " + upperX + " " + upperY; 130 return "" + lowerX + " " + lowerY + " " + upperX + " " + upperY;
133 } 131 }
134 132
135 133
136 public static SimpleFeatureType buildFeatureType( 134 public static SimpleFeatureType buildFeatureType(
137 String name, String srs, Class geometryType) 135 String name, String srs, Class<?> geometryType)
138 { 136 {
139 return buildFeatureType(name, srs, geometryType, null); 137 return buildFeatureType(name, srs, geometryType, null);
140 } 138 }
141 139
142 140
151 * as class. 149 * as class.
152 * 150 *
153 * @return a new SimpleFeatureType. 151 * @return a new SimpleFeatureType.
154 */ 152 */
155 public static SimpleFeatureType buildFeatureType( 153 public static SimpleFeatureType buildFeatureType(
156 String name, String srs, Class geometryType, Object[][] attrs) 154 String name, String srs, Class<?> geometryType, Object[][] attrs)
157 { 155 {
158 try { 156 try {
159 SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); 157 SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
160 CoordinateReferenceSystem crs = CRS.decode(srs); 158 CoordinateReferenceSystem crs = CRS.decode(srs);
161 159
166 164
167 builder.add("geometry", geometryType, crs); 165 builder.add("geometry", geometryType, crs);
168 166
169 if (attrs != null) { 167 if (attrs != null) {
170 for (Object[] attr: attrs) { 168 for (Object[] attr: attrs) {
171 builder.add((String) attr[0], (Class) attr[1]); 169 builder.add((String) attr[0], (Class<?>) attr[1]);
172 } 170 }
173 } 171 }
174 172
175 return builder.buildFeatureType(); 173 return builder.buildFeatureType();
176 } 174 }

http://dive4elements.wald.intevation.org