Changeset 33671 in osm for applications/editors/josm/plugins
- Timestamp:
- 2017-09-25T21:47:56+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/.classpath
r33658 r33671 8 8 <classpathentry combineaccessrules="false" kind="src" path="/JOSM-jts"/> 9 9 <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> 10 <classpathentry combineaccessrules="false" kind="src" path="/JOSM-apache-commons"/> 10 11 <classpathentry kind="output" path="bin"/> 11 12 </classpath> -
applications/editors/josm/plugins/cadastre-fr/build.xml
r33640 r33671 15 15 <property name="plugin.link" value="https://wiki.openstreetmap.org/wiki/FR:JOSM/Fr:Plugin/Cadastre"/> 16 16 <property name="plugin.stage" value="60"/> 17 <property name="plugin.requires" value=" jts;geotools"/>17 <property name="plugin.requires" value="apache-commons;ejml;jts;geotools"/> 18 18 19 19 <!-- ** include targets that all plugins have in common ** --> … … 22 22 <property name="jts" location="${plugin.dist.dir}/jts.jar"/> 23 23 <property name="geotools" location="${plugin.dist.dir}/geotools.jar"/> 24 <property name="apache-commons" location="${plugin.dist.dir}/apache-commons.jar"/> 24 25 25 26 <!-- … … 36 37 <pathelement location="${jts}"/> 37 38 <pathelement location="${geotools}"/> 38 </classpath> 39 <pathelement location="${apache-commons}"/> 40 </classpath> 39 41 <compilerarg value="-Xlint:deprecation"/> 40 42 <compilerarg value="-Xlint:unchecked"/> -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/pci/EdigeoPciImporter.java
r33642 r33671 13 13 import org.openstreetmap.josm.data.osm.DataSet; 14 14 import org.openstreetmap.josm.gui.io.importexport.OsmImporter; 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer;16 15 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 17 16 import org.openstreetmap.josm.io.IllegalDataException; … … 24 23 25 24 static final ExtensionFileFilter EDIGEO_FILE_FILTER = new ExtensionFileFilter( 26 "thf ", "thf", tr("Cadastre Edigeo files") + " (*.thf)");25 "thf,tar.bz2", "thf", tr("Cadastre Edigeo files") + " (*.thf, *.tar.bz2)"); 27 26 28 27 protected File file; … … 38 37 public void importData(File file, ProgressMonitor progressMonitor) 39 38 throws IOException, IllegalDataException { 40 if (file != null) { 41 this.file = file; 42 } 39 this.file = file; 43 40 // Do not call super.importData because Compression.getUncompressedFileInputStream skips the first entry 44 41 try (InputStream in = new FileInputStream(file)) { … … 58 55 } 59 56 } 60 61 @Override62 protected OsmDataLayer createLayer(DataSet dataSet, File associatedFile, String layerName) {63 // FIXME: mapping pci => osm64 //DataSetUpdater.updateDataSet(dataSet, handler, associatedFile);65 return new OsmDataLayer(dataSet, layerName, associatedFile);66 }67 57 } -
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/pci/EdigeoPciReader.java
r33665 r33671 2 2 package org.openstreetmap.josm.plugins.fr.cadastre.edigeo.pci; 3 3 4 import java.io.BufferedInputStream; 4 5 import java.io.File; 6 import java.io.FileOutputStream; 5 7 import java.io.IOException; 6 8 import java.io.InputStream; 9 import java.nio.file.Files; 7 10 import java.nio.file.Path; 8 11 import java.util.Arrays; … … 12 15 import java.util.Map.Entry; 13 16 17 import org.apache.commons.compress.archivers.tar.TarArchiveEntry; 18 import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; 19 import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; 20 import org.apache.commons.compress.utils.IOUtils; 14 21 import org.openstreetmap.josm.data.osm.DataSet; 15 22 import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy; … … 20 27 import org.openstreetmap.josm.plugins.fr.cadastre.edigeo.EdigeoFileTHF; 21 28 import org.openstreetmap.josm.plugins.fr.cadastre.edigeo.EdigeoFileVEC; 29 import org.openstreetmap.josm.tools.Utils; 22 30 23 31 /** … … 180 188 181 189 DataSet parse(Path path, ProgressMonitor instance) throws IOException, ReflectiveOperationException { 182 DataSet data = new DataSet(); 183 data.setUploadPolicy(UploadPolicy.DISCOURAGED); 184 EdigeoFileTHF thf = new EdigeoFileTHF(path).read().fill(data); 185 data.setName(thf.getSupport().getBlockIdentifier()); 186 return data; 190 Path tmpDir = null; 191 Path thfPath = path; 192 try { 193 if (thfPath.toString().endsWith(".tar.bz2")) { 194 try (InputStream fin = Files.newInputStream(path); 195 BufferedInputStream in = new BufferedInputStream(fin); 196 BZip2CompressorInputStream bzIn = new BZip2CompressorInputStream(in); 197 TarArchiveInputStream tar = new TarArchiveInputStream(bzIn) 198 ) { 199 TarArchiveEntry entry; 200 tmpDir = Files.createTempDirectory(Utils.getJosmTempDir().toPath(), "cadastre"); 201 while ((entry = tar.getNextTarEntry()) != null) { 202 File file = tmpDir.resolve(entry.getName()).toFile(); 203 try (FileOutputStream out = new FileOutputStream(file)) { 204 if (IOUtils.copy(tar, out) < entry.getSize()) { 205 throw new IOException(String.format("Unable to write ''{0}'' entirely", file)); 206 } else if (file.toString().endsWith(".THF")) { 207 thfPath = file.toPath(); 208 } 209 } 210 } 211 } 212 } 213 DataSet data = new DataSet(); 214 data.setUploadPolicy(UploadPolicy.DISCOURAGED); 215 EdigeoFileTHF thf = new EdigeoFileTHF(thfPath).read().fill(data); 216 data.setName(thf.getSupport().getBlockIdentifier()); 217 return data; 218 } finally { 219 if (tmpDir != null) { 220 Utils.deleteDirectory(tmpDir.toFile()); 221 } 222 } 187 223 } 188 224
Note:
See TracChangeset
for help on using the changeset viewer.