Changeset 5268 in osm for applications/editors/josm/plugins
- Timestamp:
- 2007-11-01T08:48:01+01:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/openvisible/src/at/dallermassl/josm/plugin/openvisible/OpenVisibleAction.java
r5138 r5268 30 30 import org.openstreetmap.josm.gui.MapView; 31 31 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 32 import org.openstreetmap.josm.gui.layer.RawGpsLayer; 33 import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint; 34 import org.openstreetmap.josm.gui.layer.markerlayer.Marker; 32 import org.openstreetmap.josm.gui.layer.GpxLayer; 35 33 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 34 import org.openstreetmap.josm.io.GpxReader; 36 35 import org.openstreetmap.josm.io.OsmReader; 37 import org.openstreetmap.josm.io.RawCsvReader;38 import org.openstreetmap.josm.io.RawGpsReader;39 36 import org.xml.sax.SAXException; 40 37 … … 86 83 openAsData(file); 87 84 } else if(file.getName().endsWith("gpx")) { 88 openFileAs RawGps(file);85 openFileAsGpx(file); 89 86 } 90 87 … … 113 110 } 114 111 115 private void openFileAs RawGps(File file) throws SAXException, IOException, FileNotFoundException {112 private void openFileAsGpx(File file) throws SAXException, IOException, FileNotFoundException { 116 113 String fn = file.getName(); 117 Collection<Collection<GpsPoint>> gpsData = null;118 Collection<Marker> markerData = null;119 114 if (ExtensionFileFilter.filters[ExtensionFileFilter.GPX].acceptName(fn)) { 120 RawGpsReader r = null;121 if (file.getName().endsWith(".gpx.gz")) 122 r = new RawGpsReader(new GZIPInputStream(new FileInputStream(file)), file.getAbsoluteFile().getParentFile());123 else124 r = new RawGpsReader(new FileInputStream(file), file.getAbsoluteFile().getParentFile());125 gpsData = r.trackData;126 markerData = r.markerData;127 } else if (ExtensionFileFilter.filters[ExtensionFileFilter.CSV].acceptName(fn)) {128 gpsData = new LinkedList<Collection<GpsPoint>>();129 gpsData.add(new RawCsvReader(new FileReader(file)).parse()); 130 } else 115 GpxReader r = null; 116 if (file.getName().endsWith(".gpx.gz")) { 117 r = new GpxReader(new GZIPInputStream(new FileInputStream(file)), file.getAbsoluteFile().getParentFile()); 118 } else{ 119 r = new GpxReader(new FileInputStream(file), file.getAbsoluteFile().getParentFile()); 120 } 121 r.data.storageFile = file; 122 Main.main.addLayer(new GpxLayer(r.data, fn)); 123 Main.main.addLayer(new MarkerLayer(r.data, tr("Markers from {0}", fn), file)); 124 125 } else { 131 126 throw new IllegalStateException(); 132 if (gpsData != null && !gpsData.isEmpty()) 133 Main.main.addLayer(new RawGpsLayer(false, gpsData, tr("Tracks from {0}", file.getName()), file)); 134 if (markerData != null && !markerData.isEmpty()) 135 Main.main.addLayer(new MarkerLayer(markerData, tr ("Markers from {0}", file.getName()), file)); 127 } 136 128 } 137 138 139 129 }
Note:
See TracChangeset
for help on using the changeset viewer.