JOSM / geojson

Allows reading GeoJSON using different projections – NOW PART OF JOSM CORE
Apache License 2.0
13 stars 10 forks source link

Add support for compressed GeoJson #18

Closed don-vip closed 6 years ago

don-vip commented 6 years ago

Currently we can't open these files by "open location" or drag and drop as there is no importer defined for compressed json/geojson: https://cadastre.data.gouv.fr/data/etalab-cadastre/2018-06-29/geojson/communes/31/31555/

As reference, the core OSM importer is defined as follows:

import org.openstreetmap.josm.actions.ExtensionFileFilter;
import org.openstreetmap.josm.io.Compression;

/**
 * File importer that reads *.osm data files. (main storage format for OSM data in JOSM)
 */
public class OsmImporter extends FileImporter {
    /**
     * The OSM file filter (*.osm and *.xml files).
     */
    public static final ExtensionFileFilter FILE_FILTER = 
        ExtensionFileFilter.newFilterWithArchiveExtensions(
            "osm,xml",
            "osm",
            tr("OSM Server Files") + " (*.osm, *.osm.gz, *.osm.bz2, *.osm.xz, *.osm.zip, *.xml)",
            ExtensionFileFilter.AddArchiveExtension.NONE,
            Arrays.asList("gz", "bz", "bz2", "xz", "zip")
        );

    /**
     * Imports OSM data from file
     * @param file file to read data from
     * @param progressMonitor handler for progress monitoring and canceling
     */
    @Override
    public void importData(File file, ProgressMonitor progressMonitor)
    throws IOException, IllegalDataException {
        try (InputStream in = Compression.getUncompressedFileInputStream(file)) {
            importData(in, file, progressMonitor);
        } catch (FileNotFoundException e) {
            Logging.error(e);
            throw new IOException(tr("File ''{0}'' does not exist.", file.getName()), e);
        }
    }
}
don-vip commented 6 years ago

@jreijn if you're interested, this should be an easy task :)

jreijn commented 6 years ago

I'll pick it up. I guess it's just a matter of supporting files that end with .json.zip, .geojson.zip, .geojson.gz?

don-vip commented 6 years ago

Yes, just that 👍 Thanks!

Edit: no there is still something to do, I create a new issue