Changeset 1388 in josm


Ignore:
Timestamp:
Feb 9, 2009 10:05:19 AM (4 years ago)
Author:
stoecker
Message:

fix NMEA parsing: #1853

File:
1 edited

Legend:

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

    r1385 r1388  
    158158    } 
    159159    public int getParserChecksumErrors() { 
    160         return ps.checksum_errors; 
     160        return ps.checksum_errors+ps.no_checksum; 
    161161    } 
    162162    public int getParserMalformed() { 
     
    219219        protected int malformed = 0; 
    220220        protected int checksum_errors = 0; 
     221        protected int no_checksum = 0; 
    221222        protected int unknown = 0; 
    222223        protected int zero_coord = 0; 
     
    235236            // and result in a malformed packet. 
    236237            String[] chkstrings = s.split("\\*"); 
    237             byte[] chb = chkstrings[0].getBytes(); 
    238             int chk=0; 
    239             for(int i = 1; i < chb.length; i++) chk ^= chb[i]; 
    240             if(Integer.parseInt(chkstrings[1].substring(0,2),16) != chk) { 
    241                 //System.out.println("Checksum error"); 
    242                 ps.checksum_errors++; 
    243                 ps.p_Wp=null; 
    244                 return false; 
    245             } 
     238            if(chkstrings.length > 1) 
     239            { 
     240                byte[] chb = chkstrings[0].getBytes(); 
     241                int chk=0; 
     242                for(int i = 1; i < chb.length; i++) chk ^= chb[i]; 
     243                if(Integer.parseInt(chkstrings[1].substring(0,2),16) != chk) { 
     244                    //System.out.println("Checksum error"); 
     245                    ps.checksum_errors++; 
     246                    ps.p_Wp=null; 
     247                    return false; 
     248                } 
     249            } 
     250            else 
     251                ps.no_checksum++; 
    246252            // now for the content 
    247253            String[] e = chkstrings[0].split(","); 
     
    435441        } catch(Exception x) { 
    436442            // out of bounds and such 
     443            // x.printStackTrace(); 
    437444            // System.out.println("Malformed line: "+s.toString().trim()); 
    438445            ps.malformed++; 
     
    460467        int latdeg = Integer.parseInt(widthNorth.substring(0, latdegsep)); 
    461468        double latmin = Double.parseDouble(widthNorth.substring(latdegsep)); 
     469        if(latdeg < 0) // strange data with '-' sign 
     470            latmin *= -1.0; 
    462471        double lat = latdeg + latmin / 60; 
    463472        if ("S".equals(ns)) { 
     
    470479        int londeg = Integer.parseInt(lengthEast.substring(0, londegsep)); 
    471480        double lonmin = Double.parseDouble(lengthEast.substring(londegsep)); 
     481        if(londeg < 0) // strange data with '-' sign 
     482            lonmin *= -1.0; 
    472483        double lon = londeg + lonmin / 60; 
    473484        if ("W".equals(ew)) { 
Note: See TracChangeset for help on using the changeset viewer.