Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java @ 5441:7c1dd9c3f6bd
remove unit from sediment density and depths (always t/m3 respectively cm, otherwise a typo)
author | Tom Gottfried <tom.gottfried@intevation.de> |
---|---|
date | Tue, 26 Mar 2013 19:29:39 +0100 |
parents | 3694d8f48e16 |
children | b3dd14fc13a6 |
comparison
equal
deleted
inserted
replaced
5440:765013c837b1 | 5441:7c1dd9c3f6bd |
---|---|
18 import org.apache.log4j.Logger; | 18 import org.apache.log4j.Logger; |
19 | 19 |
20 import de.intevation.flys.importer.ImportDepth; | 20 import de.intevation.flys.importer.ImportDepth; |
21 import de.intevation.flys.importer.ImportSedimentDensity; | 21 import de.intevation.flys.importer.ImportSedimentDensity; |
22 import de.intevation.flys.importer.ImportSedimentDensityValue; | 22 import de.intevation.flys.importer.ImportSedimentDensityValue; |
23 import de.intevation.flys.importer.ImportUnit; | |
24 import de.intevation.flys.utils.DateGuesser; | 23 import de.intevation.flys.utils.DateGuesser; |
25 | 24 |
26 | 25 |
27 public class SedimentDensityParser extends LineParser { | 26 public class SedimentDensityParser extends LineParser { |
28 | 27 |
31 | 30 |
32 private int densitsyColumn = 1; | 31 private int densitsyColumn = 1; |
33 | 32 |
34 public static final NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE); | 33 public static final NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE); |
35 | 34 |
36 | |
37 public static final Pattern META_UNIT = | |
38 Pattern.compile("^Einheit: \\[(.*)\\].*"); | |
39 | 35 |
40 public static final Pattern META_DEPTH = | 36 public static final Pattern META_DEPTH = |
41 Pattern.compile("^Tiefe: (\\w++)-(\\w++)( (\\w++))?.*"); | 37 Pattern.compile("^Tiefe: (\\w++)-(\\w++)( (\\w++))?.*"); |
42 | 38 |
43 protected List<ImportSedimentDensity> sedimentDensities; | 39 protected List<ImportSedimentDensity> sedimentDensities; |
84 } | 80 } |
85 } | 81 } |
86 | 82 |
87 | 83 |
88 protected void handleMetaLine(String line) { | 84 protected void handleMetaLine(String line) { |
89 if (handleMetaUnit(line)) { | 85 if (handleMetaDepth(line)) { |
90 return; | |
91 } | |
92 else if (handleMetaDepth(line)) { | |
93 return; | 86 return; |
94 } | 87 } |
95 else if (handleMetaColumns(line)) { | 88 else if (handleMetaColumns(line)) { |
96 return; | 89 return; |
97 } | 90 } |
111 } | 104 } |
112 return false; | 105 return false; |
113 } | 106 } |
114 | 107 |
115 | 108 |
116 protected boolean handleMetaUnit(String line) { | |
117 Matcher m = META_UNIT.matcher(line); | |
118 | |
119 if (m.matches()) { | |
120 String unit = m.group(1); | |
121 | |
122 current.setUnit(new ImportUnit(unit)); | |
123 | |
124 return true; | |
125 } | |
126 | |
127 return false; | |
128 } | |
129 | |
130 | |
131 protected boolean handleMetaDepth(String line) { | 109 protected boolean handleMetaDepth(String line) { |
132 Matcher m = META_DEPTH.matcher(line); | 110 Matcher m = META_DEPTH.matcher(line); |
133 | 111 |
134 if (m.matches()) { | 112 if (m.matches()) { |
135 String lo = m.group(1); | 113 String lo = m.group(1); |
136 String up = m.group(2); | 114 String up = m.group(2); |
137 String unit = m.group(4); | |
138 | 115 |
139 log.info("Found sediment density depth: " + lo + " - " + up + " " + unit); | 116 log.info("Found sediment density depth: " + lo + " - " + up + " cm"); |
140 | 117 |
141 try { | 118 try { |
142 ImportDepth depth = new ImportDepth( | 119 ImportDepth depth = new ImportDepth( |
143 new BigDecimal(nf.parse(lo).doubleValue()), | 120 new BigDecimal(nf.parse(lo).doubleValue()), |
144 new BigDecimal(nf.parse(up).doubleValue()), | 121 new BigDecimal(nf.parse(up).doubleValue()) |
145 new ImportUnit(unit) | |
146 ); | 122 ); |
147 | 123 |
148 current.setDepth(depth); | 124 current.setDepth(depth); |
149 | 125 |
150 return true; | 126 return true; |