Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedOverview.java @ 8779:50ff99266e0e
Issue1854: Filter BedOverview down to river distance.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 03 Dec 2015 14:44:35 +0100 |
parents | 2e11fc7f5d35 |
children | 85f36f9f1bd3 |
comparison
equal
deleted
inserted
replaced
8778:bbf6cf555e89 | 8779:50ff99266e0e |
---|---|
93 " JOIN station s" + | 93 " JOIN station s" + |
94 " ON so.stationid = s.stationid " + | 94 " ON so.stationid = s.stationid " + |
95 " JOIN gewaesser g " + | 95 " JOIN gewaesser g " + |
96 " ON s.gewaesserid = g.gewaesserid " + | 96 " ON s.gewaesserid = g.gewaesserid " + |
97 "WHERE" + | 97 "WHERE" + |
98 " g.name = :name AND" + | 98 " g.name = :name" + |
99 " so.km IS NOT NULL " + | 99 " AND so.km IS NOT NULL" + |
100 " AND so.km BETWEEN :from AND :to " + | |
100 "ORDER by" + | 101 "ORDER by" + |
101 " so.km, so.datum"; | 102 " so.km, so.datum"; |
102 | 103 |
103 protected String riverName; | 104 protected String riverName; |
105 protected String SeddbRiverName; | |
104 | 106 |
105 protected KMIndex<List<Date>> entries; | 107 protected KMIndex<List<Date>> entries; |
106 | 108 |
107 public BedOverview() { | 109 public BedOverview() { |
108 entries = new KMIndex<List<Date>>(); | 110 entries = new KMIndex<List<Date>>(); |
109 } | 111 } |
110 | 112 |
111 public BedOverview(String riverName) { | 113 public BedOverview(String riverName) { |
112 this(); | 114 this(); |
113 this.riverName = RiverFactory.getRiver(riverName).nameForSeddb(); | 115 this.riverName = riverName; |
116 this.SeddbRiverName = RiverFactory.getRiver(riverName).nameForSeddb(); | |
114 } | 117 } |
115 | 118 |
116 private static final boolean epsilonEquals(double a, double b) { | 119 private static final boolean epsilonEquals(double a, double b) { |
117 return Math.abs(a - b) < EPSILON; | 120 return Math.abs(a - b) < EPSILON; |
118 } | 121 } |
119 | 122 |
120 protected void loadData(Session session) { | 123 protected void loadData(Session session) { |
124 double [] fromTo = RiverFactory.getRiver(riverName) | |
125 .determineMinMaxDistance(); | |
126 | |
121 SQLQuery query = session.createSQLQuery(SQL_SQ) | 127 SQLQuery query = session.createSQLQuery(SQL_SQ) |
122 .addScalar("km", StandardBasicTypes.DOUBLE) | 128 .addScalar("km", StandardBasicTypes.DOUBLE) |
123 .addScalar("datum", StandardBasicTypes.DATE); | 129 .addScalar("datum", StandardBasicTypes.DATE); |
124 | 130 |
125 query.setString("name", riverName); | 131 query.setString("name", SeddbRiverName); |
132 query.setDouble("from", fromTo[0]); | |
133 query.setDouble("to", fromTo[1]); | |
126 | 134 |
127 List<Object []> list = query.list(); | 135 List<Object []> list = query.list(); |
128 | 136 |
129 if (list.isEmpty()) { | 137 if (list.isEmpty()) { |
130 log.warn("No river '" + riverName + "' found."); | 138 log.warn("No river '" + SeddbRiverName + "' found."); |
131 } | 139 } |
132 | 140 |
133 Double prevKm = -Double.MAX_VALUE; | 141 Double prevKm = -Double.MAX_VALUE; |
134 List<Date> dates = new ArrayList<Date>(); | 142 List<Date> dates = new ArrayList<Date>(); |
135 | 143 |
173 | 181 |
174 Element sqElement = document.createElement("bed"); | 182 Element sqElement = document.createElement("bed"); |
175 | 183 |
176 Element riverElement = document.createElement("river"); | 184 Element riverElement = document.createElement("river"); |
177 | 185 |
178 riverElement.setAttribute("name", riverName); | 186 riverElement.setAttribute("name", SeddbRiverName); |
179 | 187 |
180 sqElement.appendChild(riverElement); | 188 sqElement.appendChild(riverElement); |
181 | 189 |
182 SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); | 190 SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); |
183 | 191 |