Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/WaterlevelParser.java @ 8856:5e38e2924c07 3.2.x
Fix code style.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 18 Jan 2018 20:12:01 +0100 |
parents | 3bb1c62ad732 |
children | 2693bfaf503d 0a5239a1e46e |
comparison
equal
deleted
inserted
replaced
8855:d7c005e12af0 | 8856:5e38e2924c07 |
---|---|
95 column = current.getColumn(0); | 95 column = current.getColumn(0); |
96 column.setName(currentDescription); | 96 column.setName(currentDescription); |
97 column.setDescription(currentDescription); | 97 column.setDescription(currentDescription); |
98 | 98 |
99 // Try to extract and set the TimeInterval. | 99 // Try to extract and set the TimeInterval. |
100 Matcher m = WaterlevelDifferencesParser.YEARS_IN_COLUMN.matcher(currentDescription); | 100 Matcher m = WaterlevelDifferencesParser.YEARS_IN_COLUMN.matcher( |
101 currentDescription); | |
101 | 102 |
102 if (m.matches()) { | 103 if (m.matches()) { |
103 int startYear = Integer.parseInt(m.group(1)); | 104 int startYear = Integer.parseInt(m.group(1)); |
104 int endYear = Integer.parseInt(m.group(2)); | 105 int endYear = Integer.parseInt(m.group(2)); |
105 ImportTimeInterval time = new ImportTimeInterval( | 106 ImportTimeInterval time = new ImportTimeInterval( |
106 DateUtil.getStartDateFromYear(startYear), | 107 DateUtil.getStartDateFromYear(startYear), |
107 DateUtil.getEndDateFromYear(endYear) | 108 DateUtil.getEndDateFromYear(endYear) |
108 ); | 109 ); |
109 column.setTimeInterval(time); | 110 column.setTimeInterval(time); |
110 } else { | 111 } else { |
111 log.debug("No time interval in column header found: " + currentDescription); | 112 log.debug("No time interval in column header found: " |
113 + currentDescription); | |
112 } | 114 } |
113 | 115 |
114 current.setKind(7); | 116 current.setKind(7); |
115 } | 117 } |
116 | 118 |
123 // Set end of range to last station | 125 // Set end of range to last station |
124 // or expand range to minimal length in case it would be 0 | 126 // or expand range to minimal length in case it would be 0 |
125 // TODO: should otherwise be extended to | 127 // TODO: should otherwise be extended to |
126 // (first station of next range - INTERVAL_GAP), | 128 // (first station of next range - INTERVAL_GAP), |
127 // assuming always ascending stations | 129 // assuming always ascending stations |
128 BigDecimal lastStation = cValues.get(cValues.size() -1).getPosition(); | 130 BigDecimal lastStation = cValues.get(cValues.size() -1) |
131 .getPosition(); | |
129 if (lastStation.compareTo(currentRange.getA()) == 0) { | 132 if (lastStation.compareTo(currentRange.getA()) == 0) { |
130 currentRange.setB(new BigDecimal(lastStation.doubleValue() | 133 currentRange.setB(new BigDecimal(lastStation.doubleValue() |
131 + INTERVAL_GAP)); | 134 + INTERVAL_GAP)); |
132 } | 135 } |
133 else { | 136 else { |
177 String unitStr = m.group(1); | 180 String unitStr = m.group(1); |
178 String valueStr = m.group(2); | 181 String valueStr = m.group(2); |
179 try { | 182 try { |
180 if (currentQRange != null) { | 183 if (currentQRange != null) { |
181 // Finish off the last one. | 184 // Finish off the last one. |
182 List<ImportWstColumnValue> cValues = column.getColumnValues(); | 185 List<ImportWstColumnValue> cValues = column |
186 .getColumnValues(); | |
183 // Set end of range to last station. | 187 // Set end of range to last station. |
184 currentRange.setB(cValues.get(cValues.size() -1).getPosition()); | 188 currentRange.setB(cValues.get(cValues.size() -1) |
189 .getPosition()); | |
185 currentQRange.setRange(currentRange); | 190 currentQRange.setRange(currentRange); |
186 column.addColumnQRange(currentQRange); | 191 column.addColumnQRange(currentQRange); |
187 } | 192 } |
188 currentQRange = new ImportWstQRange(null, | 193 currentQRange = new ImportWstQRange(null, |
189 new BigDecimal(nf.parse(valueStr).doubleValue())); | 194 new BigDecimal(nf.parse(valueStr).doubleValue())); |