Ignore:
Timestamp:
2008-09-09T08:43:09+02:00 (18 years ago)
Author:
stoecker
Message:

added patches from bug #682 (proxy settings) and #1519 (NMEA)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/NmeaReader.java

    r814 r938  
    162162
    163163        private LatLon parseLatLon(String[] e) throws NumberFormatException {
    164                 String widthNorth = e[GPRMC.WIDTH_NORTH.position];
    165                 String lengthEast = e[GPRMC.LENGTH_EAST.position];
     164                String widthNorth = e[GPRMC.WIDTH_NORTH.position].trim();
     165                String lengthEast = e[GPRMC.LENGTH_EAST.position].trim();
    166166                if ("".equals(widthNorth) || "".equals(lengthEast)) {
    167167                        return null;
    168168                }
    169169
    170                 int latdeg = Integer.parseInt(widthNorth.substring(0, 2));
    171                 double latmin = Double.parseDouble(widthNorth.substring(2));
     170                // The format is xxDDLL.LLLL
     171                // xx optional whitespace
     172                // DD (int) degres
     173                // LL.LLLL (double) latidude
     174                int latdegsep = widthNorth.indexOf('.') - 2;
     175                if (latdegsep < 0) {
     176                        return null;
     177                }
     178                int latdeg = Integer.parseInt(widthNorth.substring(0, latdegsep));
     179                double latmin = Double.parseDouble(widthNorth.substring(latdegsep));
    172180                double lat = latdeg + latmin / 60;
    173181                if ("S".equals(e[GPRMC.WIDTH_NORTH_NAME.position])) {
     
    175183                }       
    176184
    177                 int londeg = Integer.parseInt(lengthEast.substring(0, 3));
    178                 double lonmin = Double.parseDouble(lengthEast.substring(3));
     185                int londegsep = lengthEast.indexOf('.') - 2;
     186                if (londegsep < 0) {
     187                        return null;
     188                }
     189                int londeg = Integer.parseInt(lengthEast.substring(0, londegsep));
     190                double lonmin = Double.parseDouble(lengthEast.substring(londegsep));
    179191                double lon = londeg + lonmin / 60;
    180192                if ("W".equals(e[GPRMC.LENGTH_EAST_NAME.position])) {
Note: See TracChangeset for help on using the changeset viewer.