Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/PRFParser.java @ 5924:454b7b455cb6
PRFParser: Documentation.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 08 May 2013 14:58:16 +0200 |
parents | 4dd33b86dc61 |
children | 59f6a47822a4 |
comparison
equal
deleted
inserted
replaced
5923:131f5f58ff7d | 5924:454b7b455cb6 |
---|---|
80 | 80 |
81 firstShift = Math.pow(10, firstFractionPlaces); | 81 firstShift = Math.pow(10, firstFractionPlaces); |
82 secondShift = Math.pow(10, secondFractionPlaces); | 82 secondShift = Math.pow(10, secondFractionPlaces); |
83 } | 83 } |
84 | 84 |
85 /** | |
86 * @param kmData where data points will be added to. | |
87 * @param line Line to parse. | |
88 * @return -1 at invalid lines, 1 if maxRepetitions values have been | |
89 * read, 0 otherwise. | |
90 */ | |
85 public int extractData(String line, List<XY> kmData) { | 91 public int extractData(String line, List<XY> kmData) { |
86 int L = line.length(); | 92 int L = line.length(); |
87 if (L <= deleteChars) { | 93 if (L <= deleteChars) { |
88 return -1; | 94 return -1; |
89 } | 95 } |
90 | 96 |
91 int pos = deleteChars; | 97 int pos = deleteChars; |
92 | 98 |
93 boolean debug = log.isDebugEnabled(); | 99 boolean debug = log.isDebugEnabled(); |
94 | 100 |
95 | 101 // Repetitions are values per line ( ... 10.0 12.5 15.3 ... ) |
96 int rep = 0; | 102 int rep = 0; |
97 for (;rep < maxRepetitions; ++rep) { | 103 for (;rep < maxRepetitions; ++rep) { |
98 if (pos >= L || pos + firstIntegerPlaces >= L) { | 104 if (pos >= L || pos + firstIntegerPlaces >= L) { |
99 break; | 105 break; |
100 } | 106 } |
101 String first = line.substring( | 107 String first = line.substring( |
102 pos, pos + firstIntegerPlaces); | 108 pos, pos + firstIntegerPlaces); |
103 | 109 |
104 String second = line.substring( | 110 String second = line.substring( |
105 pos + firstIntegerPlaces, | 111 pos + firstIntegerPlaces, |
106 Math.min(L, pos+firstIntegerPlaces+secondIntegerPlaces)); | 112 Math.min(L, pos + firstIntegerPlaces + secondIntegerPlaces)); |
107 | 113 |
108 double x, y; | 114 double x, y; |
109 try { | 115 try { |
110 x = Double.parseDouble(first); | 116 x = Double.parseDouble(first); |
111 y = Double.parseDouble(second); | 117 y = Double.parseDouble(second); |
178 ? ((int)(km*shift))/shift | 184 ? ((int)(km*shift))/shift |
179 : km; | 185 : km; |
180 } | 186 } |
181 } // class KMFormat | 187 } // class KMFormat |
182 | 188 |
189 /** Mapping stations (km) to measured points. */ | |
183 protected Map<Double, List<XY>> data; | 190 protected Map<Double, List<XY>> data; |
184 | 191 |
185 protected Integer year; | 192 protected Integer year; |
186 | 193 |
187 protected String description; | 194 protected String description; |