Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/parsers/StaFileParser.java @ 3660:976ead36192d
backend: Mention backend warnings in importer.
flys-backend/trunk@5254 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 23 Aug 2012 17:13:47 +0000 |
parents | d183ae164cfc |
children | 6553c8e364db |
comparison
equal
deleted
inserted
replaced
3659:36edf9a71cbd | 3660:976ead36192d |
---|---|
58 log.warn("STA file is empty."); | 58 log.warn("STA file is empty."); |
59 return false; | 59 return false; |
60 } | 60 } |
61 | 61 |
62 if (line.length() < 37) { | 62 if (line.length() < 37) { |
63 log.warn("first line in STA file is too short."); | 63 log.warn("First line in STA file is too short."); |
64 return false; | 64 return false; |
65 } | 65 } |
66 | 66 |
67 String gaugeName = line.substring(16, 37).trim(); | 67 String gaugeName = line.substring(16, 37).trim(); |
68 | 68 |
73 | 73 |
74 try { | 74 try { |
75 gaugeNumber = Long.parseLong(gaugeNumberString); | 75 gaugeNumber = Long.parseLong(gaugeNumberString); |
76 } | 76 } |
77 catch (NumberFormatException nfe) { | 77 catch (NumberFormatException nfe) { |
78 log.warn("'" + gaugeNumberString + | 78 log.warn("STA: '" + gaugeNumberString + |
79 "' is not a valid long number."); | 79 "' is not a valid long number."); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 gauge.setName(gaugeName); | 83 gauge.setName(gaugeName); |
89 } | 89 } |
90 | 90 |
91 String [] values = line.substring(38).trim().split("\\s+", 2); | 91 String [] values = line.substring(38).trim().split("\\s+", 2); |
92 | 92 |
93 if (values.length < 2) { | 93 if (values.length < 2) { |
94 log.warn("Not enough columns for aeo and datum"); | 94 log.warn("STA: Not enough columns for aeo and datum."); |
95 } | 95 } |
96 try { | 96 try { |
97 gauge.setAeo(new BigDecimal(values[0].replace(",", "."))); | 97 gauge.setAeo(new BigDecimal(values[0].replace(",", "."))); |
98 gauge.setDatum(new BigDecimal(values[1].replace(",", "."))); | 98 gauge.setDatum(new BigDecimal(values[1].replace(",", "."))); |
99 } | 99 } |
100 catch (NumberFormatException nfe) { | 100 catch (NumberFormatException nfe) { |
101 log.warn("cannot parse aeo or datum"); | 101 log.warn("STA: cannot parse aeo or datum."); |
102 return false; | 102 return false; |
103 } | 103 } |
104 | 104 |
105 line = in.readLine(); | 105 line = in.readLine(); |
106 | 106 |
108 log.warn("STA file has not enough lines"); | 108 log.warn("STA file has not enough lines"); |
109 return false; | 109 return false; |
110 } | 110 } |
111 | 111 |
112 if (line.length() < 36) { | 112 if (line.length() < 36) { |
113 log.warn("second line is too short"); | 113 log.warn("STA: second line is too short"); |
114 return false; | 114 return false; |
115 } | 115 } |
116 | 116 |
117 try { | 117 try { |
118 gauge.setStation( | 118 gauge.setStation( |
119 new BigDecimal(line.substring(29, 36).trim())); | 119 new BigDecimal(line.substring(29, 36).trim())); |
120 } | 120 } |
121 catch (NumberFormatException nfe) { | 121 catch (NumberFormatException nfe) { |
122 log.warn("parsing of the datum of the gauge failed"); | 122 log.warn("STA: parsing of the datum of the gauge failed"); |
123 return false; | 123 return false; |
124 } | 124 } |
125 | 125 |
126 // overread the next six lines | 126 // overread the next six lines |
127 for (int i = 0; i < 6; ++i) { | 127 for (int i = 0; i < 6; ++i) { |
146 BigDecimal value; | 146 BigDecimal value; |
147 try { | 147 try { |
148 value = new BigDecimal(m.group(2).replace(",", ".")); | 148 value = new BigDecimal(m.group(2).replace(",", ".")); |
149 } | 149 } |
150 catch (NumberFormatException nfe) { | 150 catch (NumberFormatException nfe) { |
151 log.warn("value not parseable in line " | 151 log.warn("STA: value not parseable in line " |
152 + in.getLineNumber()); | 152 + in.getLineNumber()); |
153 continue; | 153 continue; |
154 } | 154 } |
155 String typeString = m.group(3); | 155 String typeString = m.group(3); |
156 log.debug("\t type: " + typeString); | 156 log.debug("\t type: " + typeString); |