- Timestamp:
- 2020-08-10T23:19:05+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
r16643 r16864 22 22 import org.openstreetmap.josm.gui.io.importexport.GpxImporter.GpxImporterData; 23 23 import org.openstreetmap.josm.gui.layer.GpxLayer; 24 import org.openstreetmap.josm.gui.layer.GpxRouteLayer; 24 25 import org.openstreetmap.josm.gui.layer.Layer; 25 26 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; … … 144 145 addOrMergeLayer(gpxLayer, findGpxMergeLayer()); 145 146 addOrMergeLayer(layers.getMarkerLayer(), findMarkerMergeLayer(gpxLayer)); 147 addOrMergeLayer(layers.getGpxRouteLayer(), findGpxRouteMergeLayer(gpxLayer)); 146 148 147 149 layers.getPostLayerTask().run(); … … 190 192 } 191 193 194 private GpxRouteLayer findGpxRouteMergeLayer(GpxLayer fromLayer) { 195 return MainApplication.getLayerManager().getLayersOfType(GpxRouteLayer.class).stream() 196 .filter(l -> fromLayer != null && l.fromLayer == fromLayer) 197 .findFirst().orElse(null); 198 } 199 192 200 @Override 193 201 protected void cancel() { -
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r16862 r16864 905 905 private int idxTracks; 906 906 private Iterator<IGpxTrackSegment> itTrackSegments; 907 private final Iterator<GpxRoute> itRoutes;908 907 909 908 private Line next; … … 921 920 itTracks = data.tracks.iterator(); 922 921 idxTracks = -1; 923 itRoutes = data.routes.iterator();924 922 this.trackVisibility = trackVisibility; 925 923 next = getNext(); … … 961 959 itTracks = null; 962 960 } 963 }964 if (itRoutes.hasNext()) {965 return new Line(itRoutes.next());966 961 } 967 962 return null; -
trunk/src/org/openstreetmap/josm/gui/io/importexport/GpxImporter.java
r16625 r16864 15 15 import org.openstreetmap.josm.gui.Notification; 16 16 import org.openstreetmap.josm.gui.layer.GpxLayer; 17 import org.openstreetmap.josm.gui.layer.GpxRouteLayer; 17 18 import org.openstreetmap.josm.gui.layer.ImageryLayer; 18 19 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 41 42 private final GpxLayer gpxLayer; 42 43 /** 44 * The imported GPX route layer. May be null if no marker. 45 */ 46 private final GpxRouteLayer gpxRouteLayer; 47 /** 43 48 * The imported marker layer. May be null if no marker. 44 49 */ … … 55 60 * @param postLayerTask The task to run after GPX and/or marker layer has been added to MapView. 56 61 */ 57 public GpxImporterData(GpxLayer gpxLayer, MarkerLayer markerLayer, Runnable postLayerTask) {62 public GpxImporterData(GpxLayer gpxLayer, GpxRouteLayer gpxRouteLayer, MarkerLayer markerLayer, Runnable postLayerTask) { 58 63 this.gpxLayer = gpxLayer; 64 this.gpxRouteLayer = gpxRouteLayer; 59 65 this.markerLayer = markerLayer; 60 66 this.postLayerTask = postLayerTask; … … 67 73 public GpxLayer getGpxLayer() { 68 74 return gpxLayer; 75 } 76 77 /** 78 * Returns the imported GPX route layer. May be null if no GPX data. 79 * @return the imported GPX route layer. May be null if no GPX data. 80 */ 81 public GpxRouteLayer getGpxRouteLayer() { 82 return gpxRouteLayer; 69 83 } 70 84 … … 128 142 MainApplication.getLayerManager().addLayer(data.markerLayer); 129 143 } 144 if (data.gpxRouteLayer != null) { 145 MainApplication.getLayerManager().addLayer(data.gpxRouteLayer); 146 } 130 147 if (data.gpxLayer != null) { 131 148 MainApplication.getLayerManager().addLayer(data.gpxLayer); … … 147 164 final String gpxLayerName, String markerLayerName) { 148 165 MarkerLayer markerLayer = null; 166 GpxRouteLayer gpxRouteLayer = null; 149 167 GpxLayer gpxLayer = new GpxLayer(data, gpxLayerName, data.storageFile != null); 150 168 if (Config.getPref().getBoolean("marker.makeautomarkers", true) && !data.waypoints.isEmpty()) { … … 155 173 gpxLayer.setLinkedMarkerLayer(markerLayer); 156 174 } 175 } 176 if (Config.getPref().getBoolean("gpx.makeautoroutes", true)) { 177 gpxRouteLayer = new GpxRouteLayer(tr("Routes from {0}", gpxLayerName), gpxLayer); 157 178 } 158 179 … … 182 203 } 183 204 }; 184 return new GpxImporterData(gpxLayer, markerLayer, postLayerTask);205 return new GpxImporterData(gpxLayer, gpxRouteLayer, markerLayer, postLayerTask); 185 206 } 186 207 -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
r16643 r16864 370 370 371 371 ensureTrackVisibilityLength(); 372 for (Line segment : data.getLinesIterable(layer.trackVisibility)) {372 for (Line segment : getLinesIterable(layer.trackVisibility)) { 373 373 374 374 for (WayPoint pt : segment) { … … 396 396 } 397 397 398 protected Iterable<Line> getLinesIterable(final boolean[] trackVisibility) { 399 return data.getLinesIterable(trackVisibility); 400 } 401 398 402 /** ensures the trackVisibility array has the correct length without losing data. 399 403 * TODO: Make this nicer by syncing the trackVisibility automatically. … … 508 512 if (colored == ColorMode.VELOCITY) { 509 513 final List<Double> velocities = new ArrayList<>(); 510 for (Line segment : data.getLinesIterable(null)) {514 for (Line segment : getLinesIterable(null)) { 511 515 if (!forceLines) { 512 516 oldWp = null; … … 533 537 } 534 538 } else if (colored == ColorMode.HDOP) { 535 for (Line segment : data.getLinesIterable(null)) {539 for (Line segment : getLinesIterable(null)) { 536 540 for (WayPoint trkPnt : segment) { 537 541 Object val = trkPnt.get(GpxConstants.PT_HDOP); … … 573 577 574 578 // Now the colors for all the points will be assigned 575 for (Line segment : data.getLinesIterable(null)) {579 for (Line segment : getLinesIterable(null)) { 576 580 if (!forceLines) { // don't draw lines between segments, unless forced to 577 581 oldWp = null;
Note:
See TracChangeset
for help on using the changeset viewer.