Ticket #1448: nmea_exception.patch
File nmea_exception.patch, 1.9 KB (added by , 16 years ago) |
---|
-
src/org/openstreetmap/josm/io/NmeaReader.java
139 139 140 140 try { 141 141 rd = new BufferedReader(new InputStreamReader(source)); 142 143 // Used to store an exception that was thrown in the previous loop. 144 // We want to ignore errors in the last line in the file. 145 // If we come around the loop again (i.e. the file contains 146 // another line), then throw the stored exception. 147 RuntimeException re = null; 148 142 149 while ((nmeaWithChecksum = rd.readLine()) != null) { 143 String[] nmeaAndChecksum = nmeaWithChecksum.split("\\*"); 144 String nmea = nmeaAndChecksum[0]; 145 // XXX: No need for it: String checksum = nmeaAndChecksum[1]; 146 String[] e = nmea.split(","); 147 if (NMEA_TYPE.GPRMC.equals(e[TYPE])) { 148 LatLon latLon = parseLatLon(e); 149 if (latLon == null) { 150 continue; 150 try { 151 if (re != null) 152 throw re; 153 String[] nmeaAndChecksum = nmeaWithChecksum.split("\\*"); 154 String nmea = nmeaAndChecksum[0]; 155 // XXX: No need for it: String checksum = nmeaAndChecksum[1]; 156 String[] e = nmea.split(","); 157 if (NMEA_TYPE.GPRMC.equals(e[TYPE])) { 158 LatLon latLon = parseLatLon(e); 159 if (latLon == null) { 160 continue; 161 } 162 WayPoint currentWayPoint = new WayPoint(latLon); 163 currentTrackSeg.add(currentWayPoint); 151 164 } 152 WayPoint currentWayPoint = new WayPoint(latLon); 153 currentTrackSeg.add(currentWayPoint); 165 } catch (final RuntimeException e) { 166 // Store the exception. 167 if (re == null) { 168 re = e; 169 } else { 170 // If we already have an exception stored (can't happen), 171 // throw it, instead of overwriting it. 172 throw re; 173 } 154 174 } 155 175 } 156 176 rd.close();