Changeset 29938 in osm for applications/editors/josm/plugins/opendata/src
- Timestamp:
- 2013-09-20T22:15:29+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmzReader.java
r28000 r29938 17 17 18 18 import java.io.ByteArrayInputStream; 19 import java.io.ByteArrayOutputStream; 19 20 import java.io.IOException; 20 21 import java.io.InputStream; 22 import java.util.zip.ZipEntry; 21 23 import java.util.zip.ZipInputStream; 22 24 … … 24 26 import javax.xml.stream.XMLStreamException; 25 27 28 import org.openstreetmap.josm.Main; 26 29 import org.openstreetmap.josm.data.osm.DataSet; 27 30 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 42 45 43 46 private DataSet parseDoc(ProgressMonitor instance) throws IOException, XMLStreamException, FactoryConfigurationError { 44 long size = zis.getNextEntry().getSize(); 45 byte[] buffer = new byte[(int) size]; 46 int off = 0; 47 int count = 0; 48 while ((count = zis.read(buffer, off, (int)size)) > 0) { 49 off += count; 50 size -= count; 51 } 47 ZipEntry entry; 48 do { 49 entry = zis.getNextEntry(); 50 if (entry == null) { 51 Main.warn("No KML file found"); 52 return null; 53 } 54 } while (!entry.getName().toLowerCase().endsWith(".kml")); 55 long size = entry.getSize(); 56 byte[] buffer; 57 if (size > 0) { 58 buffer = new byte[(int) size]; 59 int off = 0; 60 int count = 0; 61 while ((count = zis.read(buffer, off, (int) size)) > 0) { 62 off += count; 63 size -= count; 64 } 65 } else { 66 ByteArrayOutputStream out = new ByteArrayOutputStream(); 67 int b; 68 do { 69 b = zis.read(); 70 if (b != -1) { 71 out.write(b); 72 } 73 } while (b != -1); 74 buffer = out.toByteArray(); 75 } 76 52 77 return KmlReader.parseDataSet(new ByteArrayInputStream(buffer), instance); 53 78 }
Note:
See TracChangeset
for help on using the changeset viewer.