Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Segment.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 | 345f3bba6f15 |
children |
comparison
equal
deleted
inserted
replaced
5175:cfc5540a4eec | 5379:61bf64b102bc |
---|---|
13 import java.util.Comparator; | 13 import java.util.Comparator; |
14 import java.util.List; | 14 import java.util.List; |
15 | 15 |
16 import org.apache.log4j.Logger; | 16 import org.apache.log4j.Logger; |
17 | 17 |
18 /** A Range with values and a reference point. */ | |
18 public class Segment | 19 public class Segment |
19 implements Serializable | 20 implements Serializable |
20 { | 21 { |
21 private static Logger log = Logger.getLogger(Segment.class); | 22 private static Logger log = Logger.getLogger(Segment.class); |
22 | 23 |
51 | 52 |
52 public boolean isUp() { | 53 public boolean isUp() { |
53 return from < to; | 54 return from < to; |
54 } | 55 } |
55 | 56 |
57 /** Checks whether given km lies inside the to/from bounds of this segment. */ | |
56 public boolean inside(double km) { | 58 public boolean inside(double km) { |
57 return from < to | 59 return from < to |
58 ? km >= from && km <= to | 60 ? km >= from && km <= to |
59 : km >= to && km <= from; | 61 : km >= to && km <= from; |
60 } | 62 } |
118 | 120 |
119 public double getReferencePoint() { | 121 public double getReferencePoint() { |
120 return referencePoint; | 122 return referencePoint; |
121 } | 123 } |
122 | 124 |
125 /** Use DoubleUtil to parse Segments. */ | |
123 public static List<Segment> parseSegments(String input) { | 126 public static List<Segment> parseSegments(String input) { |
124 | 127 |
125 final List<Segment> segments = new ArrayList<Segment>(); | 128 final List<Segment> segments = new ArrayList<Segment>(); |
126 | 129 |
127 DoubleUtil.parseSegments(input, new DoubleUtil.SegmentCallback() { | 130 DoubleUtil.parseSegments(input, new DoubleUtil.SegmentCallback() { |
174 // convert to Q if needed | 177 // convert to Q if needed |
175 if (!isQ && gauge != null) { | 178 if (!isQ && gauge != null) { |
176 | 179 |
177 DischargeTable dt = gauge.fetchMasterDischargeTable(); | 180 DischargeTable dt = gauge.fetchMasterDischargeTable(); |
178 | 181 |
182 //TODO: Change scale from 100 to 1 immediately after | |
183 // discharge table import changed to cm! | |
179 double [][] table = | 184 double [][] table = |
180 DischargeTables.loadDischargeTableValues(dt, 1); | 185 DischargeTables.loadDischargeTableValues(dt, 100); |
181 | 186 |
182 // need the original values for naming | 187 // need the original values for naming |
183 segment.backup(); | 188 segment.backup(); |
184 | 189 |
185 for (int i = 0; i < values.length; ++i) { | 190 for (int i = 0; i < values.length; ++i) { |
186 double w = values[i] / 100.0; | 191 //TODO: s.o. |
192 double w = values[i]; /* / 100.0; */ | |
187 double [] qs = DischargeTables.getQsForW(table, w); | 193 double [] qs = DischargeTables.getQsForW(table, w); |
188 if (qs.length == 0) { | 194 if (qs.length == 0) { |
189 log.warn("No Qs found for W = " + values[i]); | 195 log.warn("No Qs found for W = " + values[i]); |
190 report.addProblem("cannot.find.w.for.q", values[i]); | 196 report.addProblem("cannot.find.q.for.w", values[i]); |
191 values[i] = Double.NaN; | 197 values[i] = Double.NaN; |
192 success = false; | 198 success = false; |
193 } | 199 } |
194 else { | 200 else { |
195 values[i] = qs[0]; | 201 values[i] = qs[0]; |