Ignore:
Timestamp:
2014-02-25T00:21:39+01:00 (11 years ago)
Author:
Don-vip
Message:

enable loading of .osm.zip files

Location:
trunk/src/org/openstreetmap/josm/io
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/Compression.java

    r6716 r6882  
    1313import java.net.URL;
    1414import java.util.zip.GZIPOutputStream;
     15import java.util.zip.ZipOutputStream;
    1516
    1617/**
     
    2930     * gzip compression
    3031     */
    31     GZIP;
     32    GZIP,
     33    /**
     34     * zip compression
     35     */
     36    ZIP;
    3237
    3338    /**
    3439     * Determines the compression type depending on the suffix of {@code name}.
     40     * @param name File name including extension
     41     * @return the compression type
    3542     */
    3643    public static Compression byExtension(String name) {
     
    3946                : name != null && (name.endsWith(".bz2") || name.endsWith(".bz"))
    4047                ? BZIP2
     48                : name != null && name.endsWith(".zip")
     49                ? ZIP
    4150                : NONE;
    4251    }
     
    5362            case GZIP:
    5463                return FileImporter.getGZipInputStream(in);
     64            case ZIP:
     65                return FileImporter.getZipInputStream(in);
    5566            case NONE:
    5667            default:
     
    90101            case GZIP:
    91102                return new GZIPOutputStream(out);
     103            case ZIP:
     104                return new ZipOutputStream(out);
    92105            case NONE:
    93106            default:
  • trunk/src/org/openstreetmap/josm/io/FileImporter.java

    r6830 r6882  
    1010import java.util.List;
    1111import java.util.zip.GZIPInputStream;
     12import java.util.zip.ZipEntry;
     13import java.util.zip.ZipInputStream;
    1214
    1315import javax.swing.JOptionPane;
     
    156158    }
    157159
     160    public static ZipInputStream getZipInputStream(InputStream in) throws IOException {
     161        if (in == null) {
     162            return null;
     163        }
     164        ZipInputStream zis = new ZipInputStream(in);
     165        // Positions the stream at the beginning of first entry
     166        ZipEntry ze = zis.getNextEntry();
     167        if (ze != null && Main.isDebugEnabled()) {
     168            Main.debug("Zip entry: "+ze.getName());
     169        }
     170        return zis;
     171    }
     172
    158173    /**
    159174     * Returns the enabled state of this {@code FileImporter}. When enabled, it is listed and usable in "File->Open" dialog.
  • trunk/src/org/openstreetmap/josm/io/OsmServerLocationReader.java

    r6803 r6882  
    7777
    7878    @Override
     79    public DataSet parseOsmZip(final ProgressMonitor progressMonitor) throws OsmTransferException {
     80        return doParse(new OsmParser(progressMonitor, Compression.ZIP), progressMonitor);
     81    }
     82
     83    @Override
    7984    public DataSet parseOsmChange(final ProgressMonitor progressMonitor) throws OsmTransferException {
    8085        return doParse(new OsmChangeParser(progressMonitor, Compression.NONE), progressMonitor);
  • trunk/src/org/openstreetmap/josm/io/OsmServerReader.java

    r6852 r6882  
    303303
    304304    /**
     305     * Download Zip-compressed OSM files from somewhere
     306     * @param progressMonitor The progress monitor
     307     * @return The corresponding dataset
     308     * @throws OsmTransferException if any error occurs
     309     * @since 6882
     310     */
     311    public DataSet parseOsmZip(final ProgressMonitor progressMonitor) throws OsmTransferException {
     312        return null;
     313    }
     314
     315    /**
    305316     * Returns true if this reader is adding authentication credentials to the read
    306317     * request sent to the server.
Note: See TracChangeset for help on using the changeset viewer.