comparison flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java @ 1774:092e1e5020bc

Added a new MapGenerator which only returns a map configuration document at the moment (work still in progress). flys-artifacts/trunk@3095 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 28 Oct 2011 05:54:25 +0000
parents eb3ab28d1c21
children cbeeaaad1056
comparison
equal deleted inserted replaced
1773:9be01e2e6897 1774:092e1e5020bc
10 import java.util.Map; 10 import java.util.Map;
11 11
12 import org.apache.log4j.Logger; 12 import org.apache.log4j.Logger;
13 13
14 import com.vividsolutions.jts.geom.Coordinate; 14 import com.vividsolutions.jts.geom.Coordinate;
15 import com.vividsolutions.jts.geom.Envelope;
15 import com.vividsolutions.jts.geom.Geometry; 16 import com.vividsolutions.jts.geom.Geometry;
16 17
17 import org.opengis.feature.simple.SimpleFeature; 18 import org.opengis.feature.simple.SimpleFeature;
18 import org.opengis.feature.simple.SimpleFeatureType; 19 import org.opengis.feature.simple.SimpleFeatureType;
19 import org.opengis.referencing.FactoryException; 20 import org.opengis.referencing.FactoryException;
42 43
43 private GeometryUtils() { 44 private GeometryUtils() {
44 } 45 }
45 46
46 47
47 public static String getRiverBounds(String rivername) { 48 public static Envelope getRiverBoundary(String rivername) {
48 RiverAxis axis = RiverAxis.getRiverAxis(rivername); 49 RiverAxis axis = RiverAxis.getRiverAxis(rivername);
49 if (axis != null) { 50 if (axis != null) {
50 // TODO Take the correct EPSG into account. Maybe, we need to 51 // TODO Take the correct EPSG into account. Maybe, we need to
51 // reproject the geometry. 52 // reproject the geometry.
52 Geometry geom = axis.getGeom().getBoundary(); 53 return axis.getGeom().getEnvelopeInternal();
53 return jtsBoundsToOLBounds(geom);
54 } 54 }
55 55
56 return null; 56 return null;
57 } 57 }
58 58
59 59
60 public static String getRiverBounds(String rivername) {
61 Envelope env = getRiverBoundary(rivername);
62
63 if (env == null) {
64 return jtsBoundsToOLBounds(env);
65 }
66
67 return null;
68 }
69
70
60 /** 71 /**
61 * Returns the boundary of Geometry <i>geom</i> in OpenLayers 72 * Returns the boundary of Envelope <i>env</i> in OpenLayers
62 * representation. 73 * representation.
63 * 74 *
64 * @param geom The geometry. 75 * @param env The envelope of a geometry.
65 * 76 *
66 * @return the OpenLayers boundary of <i>geom</i>. 77 * @return the OpenLayers boundary of <i>env</i>.
67 */ 78 */
68 public static String jtsBoundsToOLBounds(Geometry geom) { 79 public static String jtsBoundsToOLBounds(Envelope env) {
69 Coordinate[] c = geom != null ? geom.getCoordinates() : null; 80 return "" +
70 81 env.getMinX() + " " +
71 if (c == null || c.length < 2) { 82 env.getMinY() + " " +
72 return null; 83 env.getMaxX() + " " +
73 } 84 env.getMaxY();
74
75 return "" + c[0].x + " " + c[1].y + " " + c[1].x + " " + c[0].y;
76 } 85 }
77 86
78 87
79 public static String createOLBounds(Geometry a, Geometry b) { 88 public static String createOLBounds(Geometry a, Geometry b) {
80 Coordinate[] ca = a.getCoordinates(); 89 Coordinate[] ca = a.getCoordinates();

http://dive4elements.wald.intevation.org