comparison artifacts/src/main/java/org/dive4elements/river/utils/GeometryUtils.java @ 8747:e9d912c97fa8

We expect that every river has only one RiverAxis of kind 1 This allowed to reduce code duplication and some cleanups.
author Tom Gottfried <tom@intevation.de>
date Fri, 05 Jun 2015 16:56:47 +0200
parents e4606eae8ea5
children 5e38e2924c07
comparison
equal deleted inserted replaced
8746:e701ef544ffa 8747:e9d912c97fa8
58 private GeometryUtils() { 58 private GeometryUtils() {
59 } 59 }
60 60
61 public static Envelope getRiverBoundary(String rivername) { 61 public static Envelope getRiverBoundary(String rivername) {
62 try { 62 try {
63 List<RiverAxis> axes = RiverAxis.getRiverAxis(rivername); 63 RiverAxis axis = RiverAxis.getRiverAxis(rivername);
64 if (axes != null && axes.size() > 0) { 64 if (axis != null) {
65 Envelope max = null; 65 return axis.getGeom().getEnvelopeInternal();
66
67 for (RiverAxis axis: axes) {
68 // TODO Take the correct EPSG into account. Maybe, we need to
69 // reproject the geometry.
70 Envelope env = axis.getGeom().getEnvelopeInternal();
71
72 if (max == null) {
73 max = env;
74 }
75 else {
76 max.expandToInclude(env);
77 }
78 }
79
80 return max;
81 } 66 }
82 } 67 }
83 catch(HibernateException iae) { 68 catch(HibernateException iae) {
84 log.warn("Exception, no valid river axis found for " + rivername); 69 log.warn("Exception, no valid river axis found for " + rivername);
85 return null; 70 return null;

http://dive4elements.wald.intevation.org