Ignore:
Timestamp:
2018-01-21T23:28:56+01:00 (23 months ago)
Author:
Don-vip
Message:

fix #15816 - full XZ support

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

Legend:

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

    r13350 r13352  
    103103                org.openstreetmap.josm.gui.io.importexport.OsmGzipExporter.class,
    104104                org.openstreetmap.josm.gui.io.importexport.OsmBzip2Exporter.class,
     105                org.openstreetmap.josm.gui.io.importexport.OsmXzExporter.class,
    105106                org.openstreetmap.josm.gui.io.importexport.GeoJSONExporter.class,
    106107                org.openstreetmap.josm.gui.io.importexport.WMSLayerExporter.class,
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTask.java

    r12679 r13352  
    2727import org.openstreetmap.josm.io.BoundingBoxDownloader;
    2828import org.openstreetmap.josm.io.BoundingBoxDownloader.MoreNotesException;
     29import org.openstreetmap.josm.io.Compression;
    2930import org.openstreetmap.josm.io.OsmApi;
    3031import org.openstreetmap.josm.io.OsmServerLocationReader;
     
    4748    /** Property defining number of days a bug needs to be closed to no longer be downloaded */
    4849    public static final IntegerProperty DAYS_CLOSED = new IntegerProperty("osm.notes.daysClosed", 7);
     50
     51    private static final String PATTERN_COMPRESS = "https?://.*/(.*\\.osn.(gz|xz|bz2?|zip))";
    4952
    5053    private DownloadTask downloadTask;
     
    7174    @Override
    7275    public Future<?> loadUrl(boolean newLayer, String url, ProgressMonitor progressMonitor) {
    73         if (url.endsWith(".bz2")) {
    74             downloadTask = new DownloadBzip2RawUrlTask(new OsmServerLocationReader(url), progressMonitor);
     76        if (url.matches(PATTERN_COMPRESS)) {
     77            downloadTask = new DownloadCompressedRawUrlTask(new OsmServerLocationReader(url), progressMonitor, Compression.byExtension(url));
    7578        } else {
    7679            downloadTask = new DownloadRawUrlTask(new OsmServerLocationReader(url), progressMonitor);
     
    210213    }
    211214
    212     class DownloadBzip2RawUrlTask extends DownloadTask {
    213 
    214         DownloadBzip2RawUrlTask(OsmServerReader reader, ProgressMonitor progressMonitor) {
     215    class DownloadCompressedRawUrlTask extends DownloadTask {
     216
     217        private final Compression compression;
     218
     219        DownloadCompressedRawUrlTask(OsmServerReader reader, ProgressMonitor progressMonitor, Compression compression) {
    215220            super(reader, progressMonitor);
     221            this.compression = compression;
    216222        }
    217223
     
    223229            ProgressMonitor subMonitor = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false);
    224230            try {
    225                 notesData = reader.parseRawNotesBzip2(subMonitor);
     231                notesData = reader.parseRawNotes(subMonitor, compression);
    226232            } catch (OsmTransferException e) {
    227233                if (isCanceled())
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmChangeCompressedTask.java

    r12634 r13352  
    99import org.openstreetmap.josm.gui.MainApplication;
    1010import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     11import org.openstreetmap.josm.io.Compression;
    1112import org.openstreetmap.josm.io.OsmServerLocationReader;
    1213import org.openstreetmap.josm.io.OsmTransferException;
    1314
    1415/**
    15  * Task allowing to download compressed OSM-Change files (gzip and bzip2)
     16 * Task allowing to download compressed OSM-Change files (gzip, xz and bzip2)
    1617 * @since 5361
    1718 */
    1819public class DownloadOsmChangeCompressedTask extends DownloadOsmChangeTask {
    1920
     21    private static final String PATTERN_COMPRESS = "https?://.*/(.*\\.osc.(gz|xz|bz2?|zip))";
     22
    2023    @Override
    2124    public String[] getPatterns() {
    22         return new String[]{"https?://.*/.*\\.osc.(gz|bz2?)"};
     25        return new String[]{PATTERN_COMPRESS};
    2326    }
    2427
     
    4043            protected DataSet parseDataSet() throws OsmTransferException {
    4144                ProgressMonitor subTaskMonitor = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false);
    42                 if (url.matches("https?://.*/.*\\.osc.bz2?")) {
    43                     return reader.parseOsmChangeBzip2(subTaskMonitor);
    44                 } else {
    45                     return reader.parseOsmChangeGzip(subTaskMonitor);
    46                 }
     45                return reader.parseOsmChange(subTaskMonitor, Compression.byExtension(url));
    4746            }
    4847        };
    4948        currentBounds = null;
    50         // Extract .osc.gz/bz/bz2 filename from URL to set the new layer name
    51         extractOsmFilename("https?://.*/(.*\\.osc.(gz|bz2?))", url);
     49        // Extract .osc.gz/xz/bz/bz2/zip filename from URL to set the new layer name
     50        extractOsmFilename(PATTERN_COMPRESS, url);
    5251        return MainApplication.worker.submit(downloadTask);
    5352    }
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmCompressedTask.java

    r12634 r13352  
    1010import org.openstreetmap.josm.gui.MainApplication;
    1111import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     12import org.openstreetmap.josm.io.Compression;
    1213import org.openstreetmap.josm.io.OsmServerLocationReader;
    1314import org.openstreetmap.josm.io.OsmTransferException;
    1415
    1516/**
    16  * Task allowing to download compressed OSM files (gzip and bzip2)
     17 * Task allowing to download compressed OSM files (gzip, xz and bzip2)
    1718 * @since 5317
    1819 */
    1920public class DownloadOsmCompressedTask extends DownloadOsmTask {
    2021
    21     private static final String PATTERN_COMPRESS = "https?://.*/.*\\.osm.(gz|bz2?|zip)";
     22    private static final String PATTERN_COMPRESS = "https?://.*/(.*\\.osm\\.(gz|xz|bz2?|zip))";
    2223
    2324    @Override
     
    3233
    3334    @Override
    34     public Future<?> download(boolean newLayer, Bounds downloadArea,
    35             ProgressMonitor progressMonitor) {
     35    public Future<?> download(boolean newLayer, Bounds downloadArea, ProgressMonitor progressMonitor) {
    3636        return null;
    3737    }
     
    4949            protected DataSet parseDataSet() throws OsmTransferException {
    5050                ProgressMonitor subTaskMonitor = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false);
    51                 if (url.matches("https?://.*/.*\\.osm.bz2?")) {
    52                     return reader.parseOsmBzip2(subTaskMonitor);
    53                 } else if (url.matches("https?://.*/.*\\.osm.gz")) {
    54                     return reader.parseOsmGzip(subTaskMonitor);
    55                 } else {
    56                     return reader.parseOsmZip(subTaskMonitor);
    57                 }
     51                return reader.parseOsm(subTaskMonitor, Compression.byExtension(url));
    5852            }
    5953        };
    6054        currentBounds = null;
    6155        // Extract .osm.gz/bz/bz2/zip filename from URL to set the new layer name
    62         extractOsmFilename("https?://.*/(.*\\.osm.(gz|bz2?|zip))", url);
     56        extractOsmFilename(PATTERN_COMPRESS, url);
    6357        return MainApplication.worker.submit(downloadTask);
    6458    }
Note: See TracChangeset for help on using the changeset viewer.