Changeset 5395 in josm for trunk


Ignore:
Timestamp:
2012-08-05T12:37:29+02:00 (12 years ago)
Author:
bastiK
Message:

gpxreader: minor refactoring, read version & creator (see #7927)

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r5108 r5395  
    3434    public File storageFile;
    3535    public boolean fromServer;
     36
     37    public String creator;
    3638
    3739    public final Collection<GpxTrack> tracks = new LinkedList<GpxTrack>();
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r5371 r5395  
    446446        int maxLineLength;
    447447        boolean lines;
    448         if (this.isLocalFile) {
     448        if (!this.data.fromServer) {
    449449            maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length.local", spec, -1);
    450450            lines = Main.pref.getBoolean("draw.rawgps.lines.local", spec, true);
  • trunk/src/org/openstreetmap/josm/io/GpxReader.java

    r4819 r5395  
    55
    66import static org.openstreetmap.josm.tools.I18n.tr;
     7import static org.openstreetmap.josm.tools.Utils.equal;
    78
    89import java.io.IOException;
     
    3738    // TODO: implement GPX 1.0 parsing
    3839
     40    private String version;
    3941    /**
    4042     * The resulting gpx data
    4143     */
    4244    public GpxData data;
    43     private enum State { init, metadata, wpt, rte, trk, ext, author, link, trkseg, copyright}
     45    private enum State { init, gpx, metadata, wpt, rte, trk, ext, author, link, trkseg, copyright}
    4446    private InputSource inputSource;
    4547
     
    8789            switch(currentState) {
    8890            case init:
     91                states.push(currentState);
     92                currentState = State.gpx;
     93                currentData.creator = atts.getValue("creator");
     94                version = atts.getValue("version");
     95                if (!equal(version, "1.0") && !equal(version, "1.1")) {
     96                    version = "1.1";
     97                }
     98                System.err.println("Version: "+version);
     99            case gpx:
    89100                if (qName.equals("metadata")) {
    90101                    states.push(currentState);
     
    110121                }
    111122                break;
     123            case metadata:
     124                if (qName.equals("author")) {
     125                    states.push(currentState);
     126                    currentState = State.author;
     127                } else if (qName.equals("extensions")) {
     128                    states.push(currentState);
     129                    currentState = State.ext;
     130                } else if (qName.equals("copyright")) {
     131                    states.push(currentState);
     132                    currentState = State.copyright;
     133                    currentData.attr.put(GpxData.META_COPYRIGHT_AUTHOR, atts.getValue("author"));
     134                } else if (qName.equals("link")) {
     135                    states.push(currentState);
     136                    currentState = State.link;
     137                    currentLink = new GpxLink(atts.getValue("href"));
     138                }
     139                break;
    112140            case author:
    113141                if (qName.equals("link")) {
     
    131159                    states.push(currentState);
    132160                    currentState = State.ext;
    133                 }
    134                 break;
    135             case metadata:
    136                 if (qName.equals("author")) {
    137                     states.push(currentState);
    138                     currentState = State.author;
    139                 } else if (qName.equals("extensions")) {
    140                     states.push(currentState);
    141                     currentState = State.ext;
    142                 } else if (qName.equals("copyright")) {
    143                     states.push(currentState);
    144                     currentState = State.copyright;
    145                     currentData.attr.put(GpxData.META_COPYRIGHT_AUTHOR, atts.getValue("author"));
    146                 } else if (qName.equals("link")) {
    147                     states.push(currentState);
    148                     currentState = State.link;
    149                     currentLink = new GpxLink(atts.getValue("href"));
    150161                }
    151162                break;
     
    323334                    currentState = states.pop();
    324335                }
     336                break;
     337            case gpx:
     338                currentState = states.pop();
    325339                break;
    326340            default:
Note: See TracChangeset for help on using the changeset viewer.