Ticket #1519: nmea-stabilization.patch
| File nmea-stabilization.patch, 1.7 KB (added by , 18 years ago) |
|---|
-
src/org/openstreetmap/josm/io/NmeaReader.java
161 161 } 162 162 163 163 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(); 166 166 if ("".equals(widthNorth) || "".equals(lengthEast)) { 167 167 return null; 168 168 } 169 169 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)); 172 180 double lat = latdeg + latmin / 60; 173 181 if ("S".equals(e[GPRMC.WIDTH_NORTH_NAME.position])) { 174 182 lat = -lat; 175 183 } 176 184 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)); 179 191 double lon = londeg + lonmin / 60; 180 192 if ("W".equals(e[GPRMC.LENGTH_EAST_NAME.position])) { 181 193 lon = -lon;
