Ignore:
Timestamp:
2014-02-02T23:23:27+01:00 (6 years ago)
Author:
simon04
Message:

fix #9660 - Allow to download compressed GPX tracks from osm.org/trace/ using "Download location"

This works by inspecting the filename in the Content-Disposition HTTP header.

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
2 edited

Legend:

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

    r6643 r6803  
    184184            // TODO: handle multiple suitable tasks ?
    185185            try {
    186                 future = tasks.iterator().next().loadUrl(new_layer, url, monitor);
     186                task = tasks.iterator().next();
     187                future = task.loadUrl(new_layer, url, monitor);
    187188            } catch (IllegalArgumentException e) {
    188189                Main.error(e);
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java

    r6380 r6803  
    5959    public Future<?> download(boolean newLayer, Bounds downloadArea, ProgressMonitor progressMonitor) {
    6060        downloadTask = new DownloadTask(newLayer,
    61                 new BoundingBoxDownloader(downloadArea), progressMonitor, false);
     61                new BoundingBoxDownloader(downloadArea), progressMonitor);
    6262        // We need submit instead of execute so we can wait for it to finish and get the error
    6363        // message if necessary. If no one calls getErrorMessage() it just behaves like execute.
     
    7070        if (url.matches(PATTERN_TRACE_ID) || url.matches(PATTERN_EXTERNAL_GPX_SCRIPT) || url.matches(PATTERN_EXTERNAL_GPX_FILE)) {
    7171            downloadTask = new DownloadTask(newLayer,
    72                     new OsmServerLocationReader(url), progressMonitor, url.matches(PATTERN_TRACE_ID));
     72                    new OsmServerLocationReader(url), progressMonitor);
    7373            // Extract .gpx filename from URL to set the new layer name
    7474            Matcher matcher = Pattern.compile(PATTERN_EXTERNAL_GPX_FILE).matcher(url);
     
    9999        private GpxData rawData;
    100100        private final boolean newLayer;
    101         private final boolean compressed;
    102 
    103         public DownloadTask(boolean newLayer, OsmServerReader reader, ProgressMonitor progressMonitor, boolean compressed) {
     101
     102        public DownloadTask(boolean newLayer, OsmServerReader reader, ProgressMonitor progressMonitor) {
    104103            super(tr("Downloading GPS data"));
    105104            this.reader = reader;
    106105            this.newLayer = newLayer;
    107             this.compressed = compressed;
    108106        }
    109107
     
    113111                    return;
    114112                ProgressMonitor subMonitor = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false);
    115                 if (compressed) {
    116                     rawData = reader.parseRawGpsBzip2(subMonitor);
    117                 } else {
    118                     rawData = reader.parseRawGps(subMonitor);
    119                 }
     113                rawData = reader.parseRawGps(subMonitor);
    120114            } catch(Exception e) {
    121115                if (isCanceled())
Note: See TracChangeset for help on using the changeset viewer.