Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/backend/SpatialInfo.java @ 5379:61bf64b102bc mapgenfix
Merge with default branch
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 22 Mar 2013 11:25:54 +0100 |
parents | dba703edfff1 |
children |
comparison
equal
deleted
inserted
replaced
5175:cfc5540a4eec | 5379:61bf64b102bc |
---|---|
2 | 2 |
3 import java.util.List; | 3 import java.util.List; |
4 | 4 |
5 import org.apache.log4j.Logger; | 5 import org.apache.log4j.Logger; |
6 | 6 |
7 import org.hibernate.HibernateException; | |
7 import org.hibernate.Query; | 8 import org.hibernate.Query; |
8 import org.hibernate.Session; | 9 import org.hibernate.Session; |
9 | 10 |
10 import de.intevation.flys.model.Building; | 11 import de.intevation.flys.model.Building; |
11 import de.intevation.flys.model.CrossSectionTrack; | 12 import de.intevation.flys.model.CrossSectionTrack; |
12 import de.intevation.flys.model.Fixpoint; | 13 import de.intevation.flys.model.Fixpoint; |
13 import de.intevation.flys.model.Line; | |
14 import de.intevation.flys.model.River; | 14 import de.intevation.flys.model.River; |
15 import de.intevation.flys.model.RiverAxis; | 15 import de.intevation.flys.model.RiverAxis; |
16 import de.intevation.flys.model.HWSLine; | |
16 | 17 |
17 | 18 |
18 public class SpatialInfo { | 19 public class SpatialInfo { |
19 | 20 |
20 private static Logger logger = Logger.getLogger(SpatialInfo.class); | 21 private static Logger logger = Logger.getLogger(SpatialInfo.class); |
40 } | 41 } |
41 | 42 |
42 logger.info("Spatial information of River '" + RIVERNAME + "'"); | 43 logger.info("Spatial information of River '" + RIVERNAME + "'"); |
43 spatial.doRiverAxisInfo(river); | 44 spatial.doRiverAxisInfo(river); |
44 spatial.doCrossSectionTracksInfo(river); | 45 spatial.doCrossSectionTracksInfo(river); |
45 spatial.doLinesInfo(river); | |
46 spatial.doBuildingsInfo(river); | 46 spatial.doBuildingsInfo(river); |
47 spatial.doFixpointsInfo(river); | 47 spatial.doFixpointsInfo(river); |
48 } | 48 } |
49 finally { | 49 finally { |
50 if (spatial != null) { | 50 if (spatial != null) { |
83 return list.get(0); | 83 return list.get(0); |
84 } | 84 } |
85 | 85 |
86 | 86 |
87 protected void doRiverAxisInfo(River river) { | 87 protected void doRiverAxisInfo(River river) { |
88 List<RiverAxis> axis = RiverAxis.getRiverAxis(river.getName()); | 88 try { |
89 if (axis != null && axis.size() > 0) { | 89 List<RiverAxis> axis = RiverAxis.getRiverAxis(river.getName()); |
90 logger.debug("TODO: Compute length and boundary."); | 90 if (axis != null && axis.size() > 0) { |
91 logger.debug("TODO: Compute length and boundary."); | |
92 } | |
93 else { | |
94 logger.warn("River has no RiverAxis."); | |
95 } | |
91 } | 96 } |
92 else { | 97 catch(HibernateException iae) { |
93 logger.warn("River has no RiverAxis."); | 98 logger.warn("No vaild river axis found for " + river.getName()); |
99 return; | |
94 } | 100 } |
101 | |
95 } | 102 } |
96 | 103 |
97 | 104 |
98 protected void doCrossSectionTracksInfo(River river) { | 105 protected void doCrossSectionTracksInfo(River river) { |
99 Query query = session.createQuery( | 106 Query query = session.createQuery( |
106 logger.warn("No CrossSectionTracks for '" + river.getName() + "' found!"); | 113 logger.warn("No CrossSectionTracks for '" + river.getName() + "' found!"); |
107 return; | 114 return; |
108 } | 115 } |
109 else { | 116 else { |
110 logger.info("River contains " + list.size() + " CrossSectionTracks."); | 117 logger.info("River contains " + list.size() + " CrossSectionTracks."); |
111 } | |
112 } | |
113 | |
114 | |
115 protected void doLinesInfo(River river) { | |
116 Query query = session.createQuery( | |
117 "from Line where river =:river"); | |
118 query.setParameter("river", river); | |
119 | |
120 List<Line> list = query.list(); | |
121 | |
122 if (list == null || list.size() == 0) { | |
123 logger.warn("No Lines for '" + river.getName() + "' found!"); | |
124 return; | |
125 } | |
126 else { | |
127 logger.info("River contains " + list.size() + " Lines."); | |
128 } | 118 } |
129 } | 119 } |
130 | 120 |
131 | 121 |
132 protected void doBuildingsInfo(River river) { | 122 protected void doBuildingsInfo(River river) { |
159 } | 149 } |
160 else { | 150 else { |
161 logger.info("River contains " + list.size() + " Fixpoints."); | 151 logger.info("River contains " + list.size() + " Fixpoints."); |
162 } | 152 } |
163 } | 153 } |
154 | |
155 @Deprecated | |
156 protected void doLinesInfo(River river) { | |
157 doHWSLinesInfo(river); | |
158 } | |
159 | |
160 protected void doHWSLinesInfo(River river) { | |
161 Query query = session.createQuery( | |
162 "from hws_lines where river =:river"); | |
163 query.setParameter("river", river); | |
164 | |
165 List<HWSLine> list = query.list(); | |
166 | |
167 if (list == null || list.size() == 0) { | |
168 logger.warn("No Lines for '" + river.getName() + "' found!"); | |
169 return; | |
170 } | |
171 else { | |
172 logger.info("River contains " + list.size() + " Lines."); | |
173 } | |
174 } | |
164 } | 175 } |
165 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : | 176 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |