- Timestamp:
- 2010-01-30T20:04:10+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r2795 r2907 63 63 public boolean hasTrackPoints() { 64 64 for (GpxTrack trk : tracks) { 65 for ( Collection<WayPoint> trkseg : trk.trackSegs) {66 if (!trkseg. isEmpty())65 for (GpxTrackSegment trkseg : trk.getSegments()) { 66 if (!trkseg.getWayPoints().isEmpty()) 67 67 return true; 68 68 } … … 103 103 } 104 104 for (GpxTrack trk : tracks) { 105 for (Collection<WayPoint> trkseg : trk.trackSegs) { 106 for (WayPoint wpt : trkseg) { 107 if (bounds == null) { 108 bounds = new Bounds(wpt.getCoor()); 109 } else { 110 bounds.extend(wpt.getCoor()); 111 } 105 Bounds trkBounds = trk.getBounds(); 106 if (trkBounds != null) { 107 if (bounds == null) { 108 bounds = new Bounds(trkBounds); 109 } else { 110 bounds.extend(trkBounds); 112 111 } 113 112 } -
trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java
r2247 r2907 5 5 6 6 import java.util.Collection; 7 import java.util. concurrent.ConcurrentLinkedQueue;7 import java.util.Map; 8 8 9 public class GpxTrack extends WithAttributes { 10 public final Collection<Collection<WayPoint>> trackSegs 11 = new ConcurrentLinkedQueue<Collection<WayPoint>>(); 9 import org.openstreetmap.josm.data.Bounds; 12 10 13 /**14 * calculates the length of the track15 */16 public double length(){17 double result = 0.0; // in meters18 WayPoint last = null;19 11 20 for (Collection<WayPoint> trkseg : trackSegs) { 21 for (WayPoint tpt : trkseg) { 22 if(last != null){ 23 Double d = last.getCoor().greatCircleDistance(tpt.getCoor()); 24 if(!d.isNaN() && !d.isInfinite()) { 25 result += d; 26 } 27 } 28 last = tpt; 29 } 30 last = null; // restart for each track segment 31 } 32 return result; 33 } 12 /** 13 * Read-only gpx track. Implementations doesn't have to be immutable, but should always be thread safe. 14 * 15 */ 16 17 public interface GpxTrack { 18 19 Collection<GpxTrackSegment> getSegments(); 20 Map<String, Object> getAttributes(); 21 Bounds getBounds(); 22 double length(); 23 34 24 } -
trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java
r2874 r2907 10 10 import org.openstreetmap.josm.data.coor.EastNorth; 11 11 import org.openstreetmap.josm.data.coor.LatLon; 12 import org.openstreetmap.josm.tools.DateUtils;13 12 import org.openstreetmap.josm.tools.PrimaryDateParser; 14 13 … … 20 19 public int dir; 21 20 22 private CachedLatLon coor;21 private final CachedLatLon coor; 23 22 24 23 public final LatLon getCoor() { -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r2867 r2907 53 53 import org.openstreetmap.josm.data.gpx.GpxData; 54 54 import org.openstreetmap.josm.data.gpx.GpxTrack; 55 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 55 56 import org.openstreetmap.josm.data.gpx.WayPoint; 56 57 import org.openstreetmap.josm.data.osm.DataSet; … … 197 198 GpxData namedTrackPoints = new GpxData(); 198 199 for (GpxTrack track : data.tracks) { 199 for ( Collection<WayPoint> seg : track.trackSegs) {200 for (WayPoint point : seg )200 for (GpxTrackSegment seg : track.getSegments()) { 201 for (WayPoint point : seg.getWayPoints()) 201 202 if (point.attr.containsKey("name") || point.attr.containsKey("desc")) { 202 203 namedTrackPoints.waypoints.add(point); … … 385 386 386 387 info.append("<tr><td>"); 387 if (trk. attr.containsKey("name")) {388 info.append(trk. attr.get("name"));388 if (trk.getAttributes().containsKey("name")) { 389 info.append(trk.getAttributes().get("name")); 389 390 } 390 391 info.append("</td><td>"); 391 if (trk. attr.containsKey("desc")) {392 info.append(" ").append(trk. attr.get("desc"));392 if (trk.getAttributes().containsKey("desc")) { 393 info.append(" ").append(trk.getAttributes().get("desc")); 393 394 } 394 395 info.append("</td><td>"); 395 396 396 for ( Collection<WayPoint> seg : trk.trackSegs) {397 for (WayPoint pnt : seg ) {397 for (GpxTrackSegment seg : trk.getSegments()) { 398 for (WayPoint pnt : seg.getWayPoints()) { 398 399 if (latest == null) { 399 400 latest = earliest = pnt; … … 429 430 info.append(new DecimalFormat("#0.00").format(trk.length() / 1000) + "km"); 430 431 info.append("</td><td>"); 431 if (trk. attr.containsKey("url")) {432 info.append(trk. attr.get("url"));432 if (trk.getAttributes().containsKey("url")) { 433 info.append(trk.getAttributes().get("url")); 433 434 } 434 435 info.append("</td></tr>"); … … 552 553 WayPoint oldWp = null; 553 554 for (GpxTrack trk : data.tracks) { 554 for ( Collection<WayPoint> segment : trk.trackSegs) {555 for (GpxTrackSegment segment : trk.getSegments()) { 555 556 if (!forceLines) { // don't draw lines between segments, unless forced to 556 557 oldWp = null; 557 558 } 558 for (WayPoint trkPnt : segment ) {559 for (WayPoint trkPnt : segment.getWayPoints()) { 559 560 LatLon c = trkPnt.getCoor(); 560 561 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { … … 609 610 } 610 611 612 List<Collection<WayPoint>> visibleSegments = new ArrayList<Collection<WayPoint>>(); 613 for (GpxTrack trk: data.tracks) { 614 for (GpxTrackSegment trkSeg: trk.getSegments()) { 615 if (trkSeg.getBounds().asRect().intersects(box.asRect())) { 616 visibleSegments.add(trkSeg.getWayPoints()); 617 } 618 } 619 } 620 611 621 /**************************************************************** 612 622 ********** STEP 3a - DRAW LINES ******************************** … … 614 624 if (lines) { 615 625 Point old = null; 616 for (GpxTrack trk : data.tracks) { 617 for (Collection<WayPoint> segment : trk.trackSegs) { 618 for (WayPoint trkPnt : segment) { 619 LatLon c = trkPnt.getCoor(); 620 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 621 continue; 622 } 623 Point screen = mv.getPoint(trkPnt.getEastNorth()); 624 if (trkPnt.drawLine) { 625 // skip points that are on the same screenposition 626 if (old != null && ((old.x != screen.x) || (old.y != screen.y))) { 627 g.setColor(trkPnt.customColoring); 628 g.drawLine(old.x, old.y, screen.x, screen.y); 629 } 630 } 631 old = screen; 632 } // end for trkpnt 633 } // end for segment 634 } // end for trk 626 for (Collection<WayPoint> segment : visibleSegments) { 627 for (WayPoint trkPnt : segment) { 628 LatLon c = trkPnt.getCoor(); 629 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 630 continue; 631 } 632 Point screen = mv.getPoint(trkPnt.getEastNorth()); 633 if (trkPnt.drawLine) { 634 // skip points that are on the same screenposition 635 if (old != null && ((old.x != screen.x) || (old.y != screen.y))) { 636 g.setColor(trkPnt.customColoring); 637 g.drawLine(old.x, old.y, screen.x, screen.y); 638 } 639 } 640 old = screen; 641 } // end for trkpnt 642 } // end for segment 635 643 } // end if lines 636 644 … … 641 649 Point old = null; 642 650 Point oldA = null; // last arrow painted 643 for (GpxTrack trk : data.tracks) { 644 for (Collection<WayPoint> segment : trk.trackSegs) { 645 for (WayPoint trkPnt : segment) { 646 LatLon c = trkPnt.getCoor(); 647 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 648 continue; 649 } 650 if (trkPnt.drawLine) { 651 Point screen = mv.getPoint(trkPnt.getEastNorth()); 652 // skip points that are on the same screenposition 653 if (old != null 654 && (oldA == null || screen.x < oldA.x - delta || screen.x > oldA.x + delta 655 || screen.y < oldA.y - delta || screen.y > oldA.y + delta)) { 656 g.setColor(trkPnt.customColoring); 657 double t = Math.atan2(screen.y - old.y, screen.x - old.x) + Math.PI; 658 g.drawLine(screen.x, screen.y, (int) (screen.x + 10 * Math.cos(t - PHI)), 659 (int) (screen.y + 10 * Math.sin(t - PHI))); 660 g.drawLine(screen.x, screen.y, (int) (screen.x + 10 * Math.cos(t + PHI)), 661 (int) (screen.y + 10 * Math.sin(t + PHI))); 662 oldA = screen; 663 } 664 old = screen; 665 } 666 } // end for trkpnt 667 } // end for segment 668 } // end for trk 651 for (Collection<WayPoint> segment : visibleSegments) { 652 for (WayPoint trkPnt : segment) { 653 LatLon c = trkPnt.getCoor(); 654 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 655 continue; 656 } 657 if (trkPnt.drawLine) { 658 Point screen = mv.getPoint(trkPnt.getEastNorth()); 659 // skip points that are on the same screenposition 660 if (old != null 661 && (oldA == null || screen.x < oldA.x - delta || screen.x > oldA.x + delta 662 || screen.y < oldA.y - delta || screen.y > oldA.y + delta)) { 663 g.setColor(trkPnt.customColoring); 664 double t = Math.atan2(screen.y - old.y, screen.x - old.x) + Math.PI; 665 g.drawLine(screen.x, screen.y, (int) (screen.x + 10 * Math.cos(t - PHI)), 666 (int) (screen.y + 10 * Math.sin(t - PHI))); 667 g.drawLine(screen.x, screen.y, (int) (screen.x + 10 * Math.cos(t + PHI)), 668 (int) (screen.y + 10 * Math.sin(t + PHI))); 669 oldA = screen; 670 } 671 old = screen; 672 } 673 } // end for trkpnt 674 } // end for segment 669 675 } // end if lines 670 676 … … 675 681 Point old = null; 676 682 Point oldA = null; // last arrow painted 677 for (GpxTrack trk : data.tracks) { 678 for (Collection<WayPoint> segment : trk.trackSegs) { 679 for (WayPoint trkPnt : segment) { 680 LatLon c = trkPnt.getCoor(); 681 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 682 continue; 683 } 684 if (trkPnt.drawLine) { 685 Point screen = mv.getPoint(trkPnt.getEastNorth()); 686 // skip points that are on the same screenposition 687 if (old != null 688 && (oldA == null || screen.x < oldA.x - delta || screen.x > oldA.x + delta 689 || screen.y < oldA.y - delta || screen.y > oldA.y + delta)) { 690 g.setColor(trkPnt.customColoring); 691 g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][0], screen.y 692 + dir[trkPnt.dir][1]); 693 g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][2], screen.y 694 + dir[trkPnt.dir][3]); 695 oldA = screen; 696 } 697 old = screen; 698 } 699 } // end for trkpnt 700 } // end for segment 701 } // end for trk 683 for (Collection<WayPoint> segment : visibleSegments) { 684 for (WayPoint trkPnt : segment) { 685 LatLon c = trkPnt.getCoor(); 686 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 687 continue; 688 } 689 if (trkPnt.drawLine) { 690 Point screen = mv.getPoint(trkPnt.getEastNorth()); 691 // skip points that are on the same screenposition 692 if (old != null 693 && (oldA == null || screen.x < oldA.x - delta || screen.x > oldA.x + delta 694 || screen.y < oldA.y - delta || screen.y > oldA.y + delta)) { 695 g.setColor(trkPnt.customColoring); 696 g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][0], screen.y 697 + dir[trkPnt.dir][1]); 698 g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][2], screen.y 699 + dir[trkPnt.dir][3]); 700 oldA = screen; 701 } 702 old = screen; 703 } 704 } // end for trkpnt 705 } // end for segment 702 706 } // end if lines 703 707 … … 707 711 if (large || hdopcircle) { 708 712 g.setColor(neutralColor); 709 for (GpxTrack trk : data.tracks) { 710 for (Collection<WayPoint> segment : trk.trackSegs) { 711 for (WayPoint trkPnt : segment) { 712 LatLon c = trkPnt.getCoor(); 713 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 714 continue; 715 } 716 Point screen = mv.getPoint(trkPnt.getEastNorth()); 717 g.setColor(trkPnt.customColoring); 718 if (hdopcircle && trkPnt.attr.get("hdop") != null) { 719 // hdop value 720 float hdop = ((Float)trkPnt.attr.get("hdop")).floatValue(); 721 if (hdop < 0) { 722 hdop = 0; 723 } 724 // hdop pixels 725 int hdopp = mv.getPoint(new LatLon(trkPnt.getCoor().lat(), trkPnt.getCoor().lon() + 2*6*hdop*360/40000000)).x - screen.x; 726 g.drawArc(screen.x-hdopp/2, screen.y-hdopp/2, hdopp, hdopp, 0, 360); 727 } 728 if (large) { 729 g.fillRect(screen.x-1, screen.y-1, 3, 3); 730 } 731 } // end for trkpnt 732 } // end for segment 733 } // end for trk 713 for (Collection<WayPoint> segment : visibleSegments) { 714 for (WayPoint trkPnt : segment) { 715 LatLon c = trkPnt.getCoor(); 716 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 717 continue; 718 } 719 Point screen = mv.getPoint(trkPnt.getEastNorth()); 720 g.setColor(trkPnt.customColoring); 721 if (hdopcircle && trkPnt.attr.get("hdop") != null) { 722 // hdop value 723 float hdop = ((Float)trkPnt.attr.get("hdop")).floatValue(); 724 if (hdop < 0) { 725 hdop = 0; 726 } 727 // hdop pixels 728 int hdopp = mv.getPoint(new LatLon(trkPnt.getCoor().lat(), trkPnt.getCoor().lon() + 2*6*hdop*360/40000000)).x - screen.x; 729 g.drawArc(screen.x-hdopp/2, screen.y-hdopp/2, hdopp, hdopp, 0, 360); 730 } 731 if (large) { 732 g.fillRect(screen.x-1, screen.y-1, 3, 3); 733 } 734 } // end for trkpnt 735 } // end for segment 734 736 } // end if large || hdopcircle 735 737 … … 739 741 if (!large && lines) { 740 742 g.setColor(neutralColor); 741 for (GpxTrack trk : data.tracks) { 742 for (Collection<WayPoint> segment : trk.trackSegs) { 743 for (WayPoint trkPnt : segment) { 744 LatLon c = trkPnt.getCoor(); 745 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 746 continue; 747 } 748 if (!trkPnt.drawLine) { 749 Point screen = mv.getPoint(trkPnt.getEastNorth()); 750 g.drawRect(screen.x, screen.y, 0, 0); 751 } 752 } // end for trkpnt 753 } // end for segment 754 } // end for trk 743 for (Collection<WayPoint> segment : visibleSegments) { 744 for (WayPoint trkPnt : segment) { 745 LatLon c = trkPnt.getCoor(); 746 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 747 continue; 748 } 749 if (!trkPnt.drawLine) { 750 Point screen = mv.getPoint(trkPnt.getEastNorth()); 751 g.drawRect(screen.x, screen.y, 0, 0); 752 } 753 } // end for trkpnt 754 } // end for segment 755 755 } // end if large 756 756 … … 760 760 if (!large && !lines) { 761 761 g.setColor(neutralColor); 762 for (GpxTrack trk : data.tracks) { 763 for (Collection<WayPoint> segment : trk.trackSegs) { 764 for (WayPoint trkPnt : segment) { 765 LatLon c = trkPnt.getCoor(); 766 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 767 continue; 768 } 769 Point screen = mv.getPoint(trkPnt.getEastNorth()); 770 g.setColor(trkPnt.customColoring); 771 g.drawRect(screen.x, screen.y, 0, 0); 772 } // end for trkpnt 773 } // end for segment 774 } // end for trk 762 for (Collection<WayPoint> segment : visibleSegments) { 763 for (WayPoint trkPnt : segment) { 764 LatLon c = trkPnt.getCoor(); 765 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 766 continue; 767 } 768 Point screen = mv.getPoint(trkPnt.getEastNorth()); 769 g.setColor(trkPnt.customColoring); 770 g.drawRect(screen.x, screen.y, 0, 0); 771 } // end for trkpnt 772 } // end for segment 775 773 } // end if large 776 774 … … 802 800 DataSet ds = new DataSet(); 803 801 for (GpxTrack trk : data.tracks) { 804 for ( Collection<WayPoint> segment : trk.trackSegs) {802 for (GpxTrackSegment segment : trk.getSegments()) { 805 803 List<Node> nodes = new ArrayList<Node>(); 806 for (WayPoint p : segment ) {804 for (WayPoint p : segment.getWayPoints()) { 807 805 Node n = new Node(p.getCoor()); 808 806 String timestr = p.getString("time"); … … 887 885 888 886 for (GpxTrack trk : data.tracks) { 889 for ( Collection<WayPoint> segment : trk.trackSegs) {890 for (WayPoint p : segment ) {887 for (GpxTrackSegment segment : trk.getSegments()) { 888 for (WayPoint p : segment.getWayPoints()) { 891 889 latsum += p.getCoor().lat(); 892 890 latcnt++; … … 920 918 LatLon previous = null; 921 919 for (GpxTrack trk : data.tracks) { 922 for ( Collection<WayPoint> segment : trk.trackSegs) {923 for (WayPoint p : segment ) {920 for (GpxTrackSegment segment : trk.getSegments()) { 921 for (WayPoint p : segment.getWayPoints()) { 924 922 LatLon c = p.getCoor(); 925 923 if (previous == null || c.greatCircleDistance(previous) > buffer_dist) { … … 1047 1045 if (data.tracks != null && !data.tracks.isEmpty()) { 1048 1046 for (GpxTrack track : data.tracks) { 1049 if (track.trackSegs == null) { 1050 continue; 1051 } 1052 for (Collection<WayPoint> seg : track.trackSegs) { 1053 for (WayPoint w : seg) { 1047 for (GpxTrackSegment seg : track.getSegments()) { 1048 for (WayPoint w : seg.getWayPoints()) { 1054 1049 firstTime = w.time; 1055 1050 break; … … 1111 1106 && !data.tracks.isEmpty()) { 1112 1107 for (GpxTrack track : data.tracks) { 1113 if (track.trackSegs == null) { 1114 continue; 1115 } 1116 for (Collection<WayPoint> seg : track.trackSegs) { 1117 for (WayPoint w : seg) { 1108 for (GpxTrackSegment seg : track.getSegments()) { 1109 for (WayPoint w : seg.getWayPoints()) { 1118 1110 if (w.attr.containsKey("name") || w.attr.containsKey("desc")) { 1119 1111 waypoints.add(w); … … 1137 1129 1138 1130 for (GpxTrack track : data.tracks) { 1139 if (track.trackSegs == null) { 1140 continue; 1141 } 1142 for (Collection<WayPoint> seg : track.trackSegs) { 1143 for (WayPoint w : seg) { 1131 for (GpxTrackSegment seg : track.getSegments()) { 1132 for (WayPoint w : seg.getWayPoints()) { 1144 1133 if (startTime < w.time) { 1145 1134 w2 = w; … … 1177 1166 boolean gotOne = false; 1178 1167 for (GpxTrack track : data.tracks) { 1179 if (track.trackSegs == null) { 1180 continue; 1181 } 1182 for (Collection<WayPoint> seg : track.trackSegs) { 1183 for (WayPoint w : seg) { 1168 for (GpxTrackSegment seg : track.getSegments()) { 1169 for (WayPoint w : seg.getWayPoints()) { 1184 1170 WayPoint wStart = new WayPoint(w.getCoor()); 1185 1171 wStart.attr.put("name", "start"); … … 1290 1276 return null; 1291 1277 for (GpxTrack track : data.tracks) { 1292 if (track.trackSegs == null) { 1293 continue; 1294 } 1295 for (Collection<WayPoint> seg : track.trackSegs) { 1278 for (GpxTrackSegment seg : track.getSegments()) { 1296 1279 WayPoint R = null; 1297 for (WayPoint S : seg ) {1280 for (WayPoint S : seg.getWayPoints()) { 1298 1281 EastNorth c = S.getEastNorth(); 1299 1282 if (R == null) { -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r2671 r2907 23 23 import java.util.ArrayList; 24 24 import java.util.Collection; 25 import java.util.HashMap; 25 26 import java.util.HashSet; 26 27 import java.util.Iterator; 27 28 import java.util.LinkedList; 29 import java.util.Map; 28 30 import java.util.Set; 29 31 … … 47 49 import org.openstreetmap.josm.data.coor.LatLon; 48 50 import org.openstreetmap.josm.data.gpx.GpxData; 49 import org.openstreetmap.josm.data.gpx. GpxTrack;51 import org.openstreetmap.josm.data.gpx.ImmutableGpxTrack; 50 52 import org.openstreetmap.josm.data.gpx.WayPoint; 51 53 import org.openstreetmap.josm.data.osm.DataSet; … … 573 575 continue; 574 576 } 575 GpxTrack trk = new GpxTrack();576 gpxData.tracks.add(trk);577 Collection<Collection<WayPoint>> trk = new ArrayList<Collection<WayPoint>>(); 578 Map<String, Object> trkAttr = new HashMap<String, Object>(); 577 579 578 580 if (w.get("name") != null) { 579 trk .attr.put("name", w.get("name"));581 trkAttr.put("name", w.get("name")); 580 582 } 581 583 … … 588 590 if (trkseg == null) { 589 591 trkseg = new ArrayList<WayPoint>(); 590 trk. trackSegs.add(trkseg);592 trk.add(trkseg); 591 593 } 592 594 if (!n.isTagged()) { … … 600 602 trkseg.add(wpt); 601 603 } 604 605 gpxData.tracks.add(new ImmutableGpxTrack(trk, trkAttr)); 602 606 } 603 607 -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r2850 r2907 66 66 import org.openstreetmap.josm.data.gpx.GpxData; 67 67 import org.openstreetmap.josm.data.gpx.GpxTrack; 68 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 68 69 import org.openstreetmap.josm.data.gpx.WayPoint; 69 70 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; … … 959 960 // Finds first GPX point 960 961 outer: for (GpxTrack trk : gpx.tracks) { 961 for ( Collection<WayPoint> segment : trk.trackSegs) {962 for (WayPoint curWp : segment ) {962 for (GpxTrackSegment segment : trk.getSegments()) { 963 for (WayPoint curWp : segment.getWayPoints()) { 963 964 String curDateWpStr = (String) curWp.attr.get("time"); 964 965 if (curDateWpStr == null) { … … 1087 1088 1088 1089 for (GpxTrack trk : selectedGpx.tracks) { 1089 for ( Collection<WayPoint> segment : trk.trackSegs) {1090 for (GpxTrackSegment segment : trk.getSegments()) { 1090 1091 1091 1092 long prevDateWp = 0; 1092 1093 WayPoint prevWp = null; 1093 1094 1094 for (WayPoint curWp : segment ) {1095 for (WayPoint curWp : segment.getWayPoints()) { 1095 1096 1096 1097 String curDateWpStr = (String) curWp.attr.get("time"); -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
r2017 r2907 12 12 import java.awt.event.MouseAdapter; 13 13 import java.awt.event.MouseEvent; 14 import java.util.Collection;15 import java.util.Iterator;16 14 17 15 import javax.swing.JOptionPane; … … 24 22 import org.openstreetmap.josm.data.coor.LatLon; 25 23 import org.openstreetmap.josm.data.gpx.GpxTrack; 24 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 26 25 import org.openstreetmap.josm.data.gpx.WayPoint; 27 26 import org.openstreetmap.josm.gui.MapView; … … 311 310 312 311 for (GpxTrack track : trackLayer.data.tracks) { 313 for (Collection<WayPoint> trackseg : track.trackSegs) { 314 for (Iterator<WayPoint> it = trackseg.iterator(); it.hasNext();) { 315 WayPoint w = it.next(); 312 for (GpxTrackSegment trackseg : track.getSegments()) { 313 for (WayPoint w: trackseg.getWayPoints()) { 316 314 if (audioTime < w.time) { 317 315 w2 = w; -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r2801 r2907 11 11 import java.util.ArrayList; 12 12 import java.util.Collection; 13 import java.util.HashMap; 13 14 import java.util.LinkedList; 14 15 import java.util.List; … … 23 24 import org.openstreetmap.josm.data.gpx.GpxLink; 24 25 import org.openstreetmap.josm.data.gpx.GpxRoute; 25 import org.openstreetmap.josm.data.gpx. GpxTrack;26 import org.openstreetmap.josm.data.gpx.ImmutableGpxTrack; 26 27 import org.openstreetmap.josm.data.gpx.WayPoint; 27 28 import org.xml.sax.Attributes; … … 47 48 48 49 private GpxData currentData; 49 private GpxTrack currentTrack; 50 private Collection<Collection<WayPoint>> currentTrack; 51 private Map<String, Object> currentTrackAttr; 50 52 private Collection<WayPoint> currentTrackSeg; 51 53 private GpxRoute currentRoute; … … 100 102 states.push(currentState); 101 103 currentState = State.trk; 102 currentTrack = new GpxTrack(); 104 currentTrack = new ArrayList<Collection<WayPoint>>(); 105 currentTrackAttr = new HashMap<String, Object>(); 103 106 } else if (qName.equals("extensions")) { 104 107 states.push(currentState); … … 207 210 case metadata: return currentData.attr; 208 211 case wpt: return currentWayPoint.attr; 209 case trk: return currentTrack .attr;212 case trk: return currentTrackAttr; 210 213 default: return null; 211 214 } … … 303 306 if (qName.equals("trkseg")) { 304 307 currentState = states.pop(); 305 currentTrack. trackSegs.add(currentTrackSeg);308 currentTrack.add(currentTrackSeg); 306 309 } 307 310 break; … … 309 312 if (qName.equals("trk")) { 310 313 currentState = states.pop(); 311 currentData.tracks.add( currentTrack);314 currentData.tracks.add(new ImmutableGpxTrack(currentTrack, currentTrackAttr)); 312 315 } else if (qName.equals("name") || qName.equals("cmt") 313 316 || qName.equals("desc") || qName.equals("src") 314 317 || qName.equals("type") || qName.equals("number") 315 318 || qName.equals("url")) { 316 currentTrack .attr.put(qName, accumulator.toString());319 currentTrackAttr.put(qName, accumulator.toString()); 317 320 } 318 321 break; -
trunk/src/org/openstreetmap/josm/io/GpxWriter.java
r2620 r2907 18 18 import org.openstreetmap.josm.data.gpx.GpxRoute; 19 19 import org.openstreetmap.josm.data.gpx.GpxTrack; 20 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 20 21 import org.openstreetmap.josm.data.gpx.WayPoint; 21 22 … … 161 162 for (GpxTrack trk : data.tracks) { 162 163 open("trk"); 163 writeAttr(trk. attr);164 for ( Collection<WayPoint> seg : trk.trackSegs) {164 writeAttr(trk.getAttributes()); 165 for (GpxTrackSegment seg : trk.getSegments()) { 165 166 openln("trkseg"); 166 for (WayPoint pnt : seg ) {167 for (WayPoint pnt : seg.getWayPoints()) { 167 168 wayPoint(pnt, TRACK_POINT); 168 169 } -
trunk/src/org/openstreetmap/josm/io/NmeaReader.java
r2676 r2907 12 12 import java.util.ArrayList; 13 13 import java.util.Collection; 14 import java.util.Collections; 14 15 import java.util.Date; 15 16 16 17 import org.openstreetmap.josm.data.coor.LatLon; 17 18 import org.openstreetmap.josm.data.gpx.GpxData; 18 import org.openstreetmap.josm.data.gpx. GpxTrack;19 import org.openstreetmap.josm.data.gpx.ImmutableGpxTrack; 19 20 import org.openstreetmap.josm.data.gpx.WayPoint; 20 21 import org.openstreetmap.josm.tools.DateUtils; … … 173 174 // create the data tree 174 175 data = new GpxData(); 175 GpxTrack currentTrack = new GpxTrack(); 176 data.tracks.add(currentTrack); 176 Collection<Collection<WayPoint>> currentTrack = new ArrayList<Collection<WayPoint>>(); 177 177 178 178 try { … … 207 207 } 208 208 rd.close(); 209 currentTrack.trackSegs.add(ps.waypoints); 209 currentTrack.add(ps.waypoints); 210 data.tracks.add(new ImmutableGpxTrack(currentTrack, Collections.<String, Object>emptyMap())); 210 211 data.recalculateBounds(); 211 212 -
trunk/src/org/openstreetmap/josm/tools/CopyList.java
r2741 r2907 49 49 } 50 50 51 p rivateCopyList(E[] array, int size) {51 public CopyList(E[] array, int size) { 52 52 this.array = array; 53 53 this.size = size;
Note:
See TracChangeset
for help on using the changeset viewer.