1 | Index: src/org/openstreetmap/josm/io/NmeaReader.java
|
---|
2 | ===================================================================
|
---|
3 | --- src/org/openstreetmap/josm/io/NmeaReader.java (Revision 1014)
|
---|
4 | +++ src/org/openstreetmap/josm/io/NmeaReader.java (Arbeitskopie)
|
---|
5 | @@ -8,6 +8,7 @@
|
---|
6 | import java.io.InputStream;
|
---|
7 | import java.io.InputStreamReader;
|
---|
8 | import java.util.ArrayList;
|
---|
9 | +import java.util.Arrays;
|
---|
10 | import java.util.Collection;
|
---|
11 |
|
---|
12 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
13 | @@ -139,6 +140,9 @@
|
---|
14 | String nmea = nmeaAndChecksum[0];
|
---|
15 | // XXX: No need for it: String checksum = nmeaAndChecksum[1];
|
---|
16 | String[] e = nmea.split(",");
|
---|
17 | + if (e.length == 0) {
|
---|
18 | + continue;
|
---|
19 | + }
|
---|
20 | if (NMEA_TYPE.GPRMC.equals(e[TYPE])) {
|
---|
21 | LatLon latLon = parseLatLon(e);
|
---|
22 | if (latLon == null) {
|
---|
23 | @@ -156,7 +160,11 @@
|
---|
24 | }
|
---|
25 |
|
---|
26 | private LatLon parseLatLon(String[] e) throws NumberFormatException {
|
---|
27 | - String widthNorth = e[GPRMC.WIDTH_NORTH.position].trim();
|
---|
28 | + // If the array looks bogus don't try to get valuable information from it
|
---|
29 | + if (e.length != 13) {
|
---|
30 | + return null;
|
---|
31 | + }
|
---|
32 | + String widthNorth = e[GPRMC.WIDTH_NORTH.position].trim();
|
---|
33 | String lengthEast = e[GPRMC.LENGTH_EAST.position].trim();
|
---|
34 | if ("".equals(widthNorth) || "".equals(lengthEast)) {
|
---|
35 | return null;
|
---|