Changeset 210 in josm for src/org/openstreetmap/josm
- Timestamp:
- 2007-04-04T13:21:40+02:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/OpenAction.java
r200 r210 62 62 Collection<Marker> markerData = null; 63 63 if (ExtensionFileFilter.filters[ExtensionFileFilter.GPX].acceptName(fn)) { 64 RawGpsReader r = new RawGpsReader(new FileInputStream(file)); 64 RawGpsReader r = new RawGpsReader(new FileInputStream(file), file.getAbsoluteFile().getParentFile()); 65 65 gpsData = r.trackData; 66 66 markerData = r.markerData; -
src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java
r200 r210 5 5 import java.awt.event.ActionEvent; 6 6 import java.awt.event.ActionListener; 7 import java.io.File; 7 8 import java.util.HashMap; 8 9 import java.util.LinkedList; … … 16 17 import org.openstreetmap.josm.gui.MapView; 17 18 import org.openstreetmap.josm.tools.ImageProvider; 19 20 import com.sun.org.apache.xerces.internal.util.URI; 18 21 19 22 /** … … 68 71 static { 69 72 Marker.markerProducers.add(new MarkerProducers() { 70 public Marker createMarker(LatLon ll, Map<String,String> data) { 73 public Marker createMarker(LatLon ll, Map<String,String> data, File relativePath) { 71 74 String link = data.get("link"); 75 76 // Try a relative file:// url, if the link is not in an URL-compatible form 77 if (relativePath != null && !URI.isWellFormedAddress(link)) 78 link = new File(relativePath, link).toURI().toString(); 79 72 80 if (link == null) 73 81 return new Marker(ll, data.get("name"), data.get("symbol")); … … 138 146 * @param ll lat/lon for marker 139 147 * @param data hash containing keys and values from the GPX waypoint structure 148 * @param relativePath An path to use for constructing relative URLs or 149 * <code>null</code> for no relative URLs 140 150 * @return a new Marker object 141 151 */ 142 public static Marker createMarker(LatLon ll, HashMap<String,String> data) { 152 public static Marker createMarker(LatLon ll, HashMap<String,String> data, File relativePath) { 143 153 for (MarkerProducers maker : Marker.markerProducers) { 144 Marker marker = maker.createMarker(ll, data); 154 Marker marker = maker.createMarker(ll, data, relativePath); 145 155 if (marker != null) 146 156 return marker; -
src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerProducers.java
r200 r210 1 1 package org.openstreetmap.josm.gui.layer.markerlayer; 2 2 3 import java.io.File; 3 4 import java.util.Map; 4 5 … … 20 21 * @param ll lat/lon for the marker position 21 22 * @param data A map of all tags found in the <wpt> node of the gpx file. 23 * @param relativePath An path to use for constructing relative URLs or 24 * <code>null</code> for no relative URLs 22 25 * @return A Marker object, or <code>null</code>. 23 26 */ 24 public Marker createMarker(LatLon ll, Map<String,String> data); 27 public Marker createMarker(LatLon ll, Map<String,String> data, File relativePath); 25 28 } -
src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
r204 r210 49 49 break; 50 50 // Use only track points, since the server mix everything together 51 Collection<Collection<GpsPoint>> allWays = new RawGpsReader(in).trackData; 51 Collection<Collection<GpsPoint>> allWays = new RawGpsReader(in, null).trackData; 52 52 53 53 boolean foundSomething = false; … … 70 70 if (cancel) 71 71 return null; 72 throw e;72 throw new SAXException("Illegal characters within the HTTP-header response", e); 73 73 } catch (IOException e) { 74 74 if (cancel) -
src/org/openstreetmap/josm/io/RawGpsReader.java
r200 r210 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.io.File; 5 6 import java.io.IOException; 6 7 import java.io.InputStream; … … 15 16 import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint; 16 17 import org.openstreetmap.josm.gui.layer.markerlayer.Marker; 18 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerProducers; 17 19 import org.xml.sax.Attributes; 18 20 import org.xml.sax.SAXException; … … 26 28 */ 27 29 public class RawGpsReader { 30 31 /** 32 * The relative path when constructing markers from wpt-tags. Passed to 33 * {@link MarkerProducers#createMarker(LatLon, java.util.Map, String)} 34 */ 35 private File relativeMarkerPath; 28 36 29 37 /** … … 90 98 currentTagValues.clear(); 91 99 } else if (qName.equals("wpt")) { 92 markerData.add(Marker.createMarker(currentLatLon, currentTagValues)); 100 markerData.add(Marker.createMarker(currentLatLon, currentTagValues, relativeMarkerPath)); 93 101 currentTagValues.clear(); 94 102 } else if (qName.equals("trkseg") || qName.equals("trk") || qName.equals("gpx")) { … … 107 115 } 108 116 109 110 117 /** 111 * Parse the input stream and store the result in trackData and markerData 118 * Parse the input stream and store the result in trackData and markerData 119 * 120 * @param relativeMarkerPath The directory to use as relative path for all <wpt> 121 * marker tags. Maybe <code>null</code>, in which case no relative urls are constructed for the markers. 112 122 */ 113 public RawGpsReader(InputStream source) throws SAXException, IOException { 123 public RawGpsReader(InputStream source, File relativeMarkerPath) throws SAXException, IOException { 124 this.relativeMarkerPath = relativeMarkerPath; 114 125 Parser parser = new Parser(); 115 126 parser.parse(new InputStreamReader(source, "UTF-8"));
Note:
See TracChangeset
for help on using the changeset viewer.