Ignore:
Timestamp:
2010-01-30T20:04:10+01:00 (14 years ago)
Author:
jttt
Message:

Gpx refactoring - GpxTrack and GpxTrackSegment is now interface, implementations for specific use can be provided (currently JOSM supports immutable gpx track, livegps plugin supports append only track).

  • track length and bounds are precalculated
  • GpxLayer paints only currently visible segments
File:
1 edited

Legend:

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

    r2801 r2907  
    1111import java.util.ArrayList;
    1212import java.util.Collection;
     13import java.util.HashMap;
    1314import java.util.LinkedList;
    1415import java.util.List;
     
    2324import org.openstreetmap.josm.data.gpx.GpxLink;
    2425import org.openstreetmap.josm.data.gpx.GpxRoute;
    25 import org.openstreetmap.josm.data.gpx.GpxTrack;
     26import org.openstreetmap.josm.data.gpx.ImmutableGpxTrack;
    2627import org.openstreetmap.josm.data.gpx.WayPoint;
    2728import org.xml.sax.Attributes;
     
    4748
    4849        private GpxData currentData;
    49         private GpxTrack currentTrack;
     50        private Collection<Collection<WayPoint>> currentTrack;
     51        private Map<String, Object> currentTrackAttr;
    5052        private Collection<WayPoint> currentTrackSeg;
    5153        private GpxRoute currentRoute;
     
    100102                    states.push(currentState);
    101103                    currentState = State.trk;
    102                     currentTrack = new GpxTrack();
     104                    currentTrack = new ArrayList<Collection<WayPoint>>();
     105                    currentTrackAttr = new HashMap<String, Object>();
    103106                } else if (qName.equals("extensions")) {
    104107                    states.push(currentState);
     
    207210            case metadata: return currentData.attr;
    208211            case wpt: return currentWayPoint.attr;
    209             case trk: return currentTrack.attr;
     212            case trk: return currentTrackAttr;
    210213            default: return null;
    211214            }
     
    303306                if (qName.equals("trkseg")) {
    304307                    currentState = states.pop();
    305                     currentTrack.trackSegs.add(currentTrackSeg);
     308                    currentTrack.add(currentTrackSeg);
    306309                }
    307310                break;
     
    309312                if (qName.equals("trk")) {
    310313                    currentState = states.pop();
    311                     currentData.tracks.add(currentTrack);
     314                    currentData.tracks.add(new ImmutableGpxTrack(currentTrack, currentTrackAttr));
    312315                } else if (qName.equals("name") || qName.equals("cmt")
    313316                        || qName.equals("desc") || qName.equals("src")
    314317                        || qName.equals("type") || qName.equals("number")
    315318                        || qName.equals("url")) {
    316                     currentTrack.attr.put(qName, accumulator.toString());
     319                    currentTrackAttr.put(qName, accumulator.toString());
    317320                }
    318321                break;
Note: See TracChangeset for help on using the changeset viewer.