Changeset 14761 in josm for trunk/src


Ignore:
Timestamp:
2019-02-05T10:53:02+01:00 (6 years ago)
Author:
GerdP
Message:

fix #13195
1) BoundingBoxDownloader: Reduce number of gpx api calls: If a call returned less than 5000 points there is no need to request another page. This improves all routines which download raw GPX data from the server.
2) GpxImporter: Create a new GpxLayer even if the area contains no GPX data. This allows to keep track of the already downloaded boundaries. Without this change the continuosDownload will try agaian and again to download data from this area because the GpxLayer will not contain the information that the corresponding bbox was already downloaded.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java

    r13927 r14761  
    1616import org.openstreetmap.josm.data.Bounds.ParseMethod;
    1717import org.openstreetmap.josm.data.ProjectionBounds;
    18 import org.openstreetmap.josm.data.ViewportData;
    1918import org.openstreetmap.josm.data.gpx.GpxData;
    2019import org.openstreetmap.josm.gui.MainApplication;
    21 import org.openstreetmap.josm.gui.MapFrame;
    2220import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    2321import org.openstreetmap.josm.gui.io.importexport.GpxImporter;
     
    161159                mergeLayer.mergeFrom(layer);
    162160                mergeLayer.invalidate();
    163                 MapFrame map = MainApplication.getMap();
    164                 if (map != null && zoomAfterDownload && layer instanceof GpxLayer) {
    165                     map.mapView.scheduleZoomTo(new ViewportData(layer.getViewProjectionBounds()));
    166                 }
    167161                return mergeLayer;
    168162            }
  • trunk/src/org/openstreetmap/josm/gui/io/importexport/GpxImporter.java

    r12854 r14761  
    145145        GpxLayer gpxLayer = null;
    146146        MarkerLayer markerLayer = null;
    147         if (data.hasRoutePoints() || data.hasTrackPoints()) {
    148             gpxLayer = new GpxLayer(data, gpxLayerName, data.storageFile != null);
    149         }
     147        gpxLayer = new GpxLayer(data, gpxLayerName, data.storageFile != null);
    150148        if (Config.getPref().getBoolean("marker.makeautomarkers", true) && !data.waypoints.isEmpty()) {
    151149            markerLayer = new MarkerLayer(data, markerLayerName, data.storageFile, gpxLayer);
  • trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    r12620 r14761  
    5151        boolean done = false;
    5252        GpxData result = null;
     53        final int pointsPerPage = 5000; // see https://wiki.openstreetmap.org/wiki/API_v0.6#GPS_traces
    5354        String url = "trackpoints?bbox="+b.getMinLon()+','+b.getMinLat()+','+b.getMaxLon()+','+b.getMaxLat()+"&page=";
    5455        for (int i = 0; !done && !isCanceled(); ++i) {
    55             progressMonitor.subTask(tr("Downloading points {0} to {1}...", i * 5000, (i + 1) * 5000));
     56            progressMonitor.subTask(tr("Downloading points {0} to {1}...", i * pointsPerPage, (i + 1) * pointsPerPage));
    5657            try (InputStream in = getInputStream(url+i, progressMonitor.createSubTaskMonitor(1, true))) {
    5758                if (in == null) {
     
    6566                    result = currentGpx;
    6667                } else if (currentGpx.hasTrackPoints()) {
     68                    long count = currentGpx.getTrackPoints().count();
     69                    Logging.debug("got {0} gpx points", count);
     70                    if (count < pointsPerPage)
     71                        done = true;
    6772                    result.mergeFrom(currentGpx);
    6873                } else {
Note: See TracChangeset for help on using the changeset viewer.