Changeset 210 in josm for src/org/openstreetmap/josm/io


Ignore:
Timestamp:
2007-04-04T13:21:40+02:00 (18 years ago)
Author:
imi
Message:
  • added the possibility for <wpt> tags in GPX files to construct markers from relative file:// urls
  • fixed NPE when illegal characters in HTTP response from the server (fix for the fix)
Location:
src/org/openstreetmap/josm/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    r204 r210  
    4949                                break;
    5050                        // 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;
    5252
    5353                        boolean foundSomething = false;
     
    7070                if (cancel)
    7171                        return null;
    72                 throw e;
     72                throw new SAXException("Illegal characters within the HTTP-header response", e);
    7373        } catch (IOException e) {
    7474                if (cancel)
  • src/org/openstreetmap/josm/io/RawGpsReader.java

    r200 r210  
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
     5import java.io.File;
    56import java.io.IOException;
    67import java.io.InputStream;
     
    1516import org.openstreetmap.josm.gui.layer.RawGpsLayer.GpsPoint;
    1617import org.openstreetmap.josm.gui.layer.markerlayer.Marker;
     18import org.openstreetmap.josm.gui.layer.markerlayer.MarkerProducers;
    1719import org.xml.sax.Attributes;
    1820import org.xml.sax.SAXException;
     
    2628 */
    2729public 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;
    2836
    2937        /**
     
    9098                                currentTagValues.clear();
    9199                        } else if (qName.equals("wpt")) {
    92                                 markerData.add(Marker.createMarker(currentLatLon, currentTagValues));
     100                                markerData.add(Marker.createMarker(currentLatLon, currentTagValues, relativeMarkerPath));
    93101                                currentTagValues.clear();
    94102                        } else if (qName.equals("trkseg") || qName.equals("trk") || qName.equals("gpx")) {
     
    107115        }
    108116
    109 
    110117        /**
    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 &lt;wpt&gt;
     121         *    marker tags. Maybe <code>null</code>, in which case no relative urls are constructed for the markers.
    112122         */
    113         public RawGpsReader(InputStream source) throws SAXException, IOException {
     123        public RawGpsReader(InputStream source, File relativeMarkerPath) throws SAXException, IOException {
     124                this.relativeMarkerPath = relativeMarkerPath;
    114125                Parser parser = new Parser();
    115126                parser.parse(new InputStreamReader(source, "UTF-8"));
Note: See TracChangeset for help on using the changeset viewer.