Ignore:
Timestamp:
2014-09-10T02:29:55+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #10489 - Add additional attributes to GPX Export for nodes + GPX code improvements

File:
1 edited

Legend:

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

    r7299 r7518  
    1515import org.openstreetmap.josm.Main;
    1616import org.openstreetmap.josm.data.coor.LatLon;
     17import org.openstreetmap.josm.data.gpx.GpxConstants;
    1718import org.openstreetmap.josm.data.gpx.GpxData;
    1819import org.openstreetmap.josm.data.gpx.ImmutableGpxTrack;
     
    287288                    // As this sentence has no complete time only use it
    288289                    // if there is no time so far
    289                     currentwp.attr.put("time", DateUtils.fromDate(d));
     290                    currentwp.put(GpxConstants.PT_TIME, DateUtils.fromDate(d));
    290291                }
    291292                // elevation
     
    299300                        // device sends nonstandard data.
    300301                        if(!accu.isEmpty()) { // FIX ? same check
    301                             currentwp.attr.put("ele", accu);
     302                            currentwp.put(GpxConstants.PT_ELE, accu);
    302303                        }
    303304                    }
     
    308309                if(!accu.isEmpty()) {
    309310                    sat = Integer.parseInt(accu);
    310                     currentwp.attr.put("sat", accu);
     311                    currentwp.put(GpxConstants.PT_SAT, accu);
    311312                }
    312313                // h-dilution
    313314                accu=e[GPGGA.HDOP.position];
    314315                if(!accu.isEmpty()) {
    315                     currentwp.attr.put("hdop", Float.parseFloat(accu));
     316                    currentwp.put(GpxConstants.PT_HDOP, Float.parseFloat(accu));
    316317                }
    317318                // fix
     
    321322                    switch(fixtype) {
    322323                    case 0:
    323                         currentwp.attr.put("fix", "none");
     324                        currentwp.put(GpxConstants.PT_FIX, "none");
    324325                        break;
    325326                    case 1:
    326327                        if(sat < 4) {
    327                             currentwp.attr.put("fix", "2d");
     328                            currentwp.put(GpxConstants.PT_FIX, "2d");
    328329                        } else {
    329                             currentwp.attr.put("fix", "3d");
     330                            currentwp.put(GpxConstants.PT_FIX, "3d");
    330331                        }
    331332                        break;
    332333                    case 2:
    333                         currentwp.attr.put("fix", "dgps");
     334                        currentwp.put(GpxConstants.PT_FIX, "dgps");
    334335                        break;
    335336                    default:
     
    345346                    if(!accu.isEmpty()) {
    346347                        Double.parseDouble(accu);
    347                         currentwp.attr.put("course", accu);
     348                        currentwp.put("course", accu);
    348349                    }
    349350                }
     
    355356                        double speed = Double.parseDouble(accu);
    356357                        speed /= 3.6; // speed in m/s
    357                         currentwp.attr.put("speed", Double.toString(speed));
     358                        currentwp.put("speed", Double.toString(speed));
    358359                    }
    359360                }
     
    362363                accu=e[GPGSA.VDOP.position];
    363364                if(!accu.isEmpty()) {
    364                     currentwp.attr.put("vdop", Float.parseFloat(accu));
     365                    currentwp.put(GpxConstants.PT_VDOP, Float.parseFloat(accu));
    365366                }
    366367                // hdop
    367368                accu=e[GPGSA.HDOP.position];
    368369                if(!accu.isEmpty()) {
    369                     currentwp.attr.put("hdop", Float.parseFloat(accu));
     370                    currentwp.put(GpxConstants.PT_HDOP, Float.parseFloat(accu));
    370371                }
    371372                // pdop
    372373                accu=e[GPGSA.PDOP.position];
    373374                if(!accu.isEmpty()) {
    374                     currentwp.attr.put("pdop", Float.parseFloat(accu));
     375                    currentwp.put(GpxConstants.PT_PDOP, Float.parseFloat(accu));
    375376                }
    376377            }
     
    399400                }
    400401                // time: this sentence has complete time so always use it.
    401                 currentwp.attr.put("time", DateUtils.fromDate(d));
     402                currentwp.put(GpxConstants.PT_TIME, DateUtils.fromDate(d));
    402403                // speed
    403404                accu = e[GPRMC.SPEED.position];
     
    405406                    double speed = Double.parseDouble(accu);
    406407                    speed *= 0.514444444; // to m/s
    407                     currentwp.attr.put("speed", Double.toString(speed));
     408                    currentwp.put("speed", Double.toString(speed));
    408409                }
    409410                // course
     
    411412                if(!accu.isEmpty() && !currentwp.attr.containsKey("course")) {
    412413                    Double.parseDouble(accu);
    413                     currentwp.attr.put("course", accu);
     414                    currentwp.put("course", accu);
    414415                }
    415416
Note: See TracChangeset for help on using the changeset viewer.