Changeset 5397 in josm
- Timestamp:
- 2012-08-05T22:40:52+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/GpxExporter.java
r5396 r5397 33 33 import org.openstreetmap.josm.gui.layer.Layer; 34 34 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 35 import org.openstreetmap.josm.io.auth.CredentialsManager;36 35 import org.openstreetmap.josm.tools.CheckParameterUtil; 37 36 import org.openstreetmap.josm.tools.GBC; -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r5395 r5397 93 93 currentData.creator = atts.getValue("creator"); 94 94 version = atts.getValue("version"); 95 if (!equal(version, "1.0") && !equal(version, "1.1")) { 95 if (version != null && version.startsWith("1.0")) { 96 version = "1.0"; 97 } else if (!"1.1".equals(version)) { 98 // unknown version, assume 1.1 96 99 version = "1.1"; 97 100 } 98 System.err.println("Version: "+version);101 break; 99 102 case gpx: 100 103 if (qName.equals("metadata")) { … … 229 232 elements.pop(); 230 233 switch (currentState) { 231 case metadata: 234 case gpx: // GPX 1.0 235 case metadata: // GPX 1.1 232 236 if (qName.equals("name")) { 233 237 currentData.attr.put(GpxData.META_NAME, accumulator.toString()); … … 238 242 } else if (qName.equals("keywords")) { 239 243 currentData.attr.put(GpxData.META_KEYWORDS, accumulator.toString()); 240 } else if (qName.equals("metadata")) { 244 } else if (version.equals("1.0") && qName.equals("author")) { 245 // author is a string in 1.0, but complex element in 1.1 246 currentData.attr.put(GpxData.META_AUTHOR_NAME, accumulator.toString()); 247 } else if (version.equals("1.0") && qName.equals("email")) { 248 currentData.attr.put(GpxData.META_AUTHOR_EMAIL, accumulator.toString()); 249 } else if ((currentState == State.metadata && qName.equals("metadata")) || 250 (currentState == State.gpx && qName.equals("gpx"))) { 241 251 currentState = states.pop(); 242 252 } … … 334 344 currentState = states.pop(); 335 345 } 336 break;337 case gpx:338 currentState = states.pop();339 346 break; 340 347 default: -
trunk/src/org/openstreetmap/josm/io/GpxWriter.java
r5393 r5397 9 9 import java.io.PrintWriter; 10 10 import java.io.UnsupportedEncodingException; 11 import java.util.Arrays; 11 12 import java.util.Collection; 13 import java.util.List; 12 14 import java.util.Map; 13 15 … … 61 63 } 62 64 65 public static List<String> WPT_KEYS = Arrays.asList("ele", "time", "magvar", "geoidheight", 66 "name", "cmt", "desc", "src", GpxData.META_LINKS, "sym", "number", "type", 67 "fix", "sat", "hdop", "vdop", "pdop", "ageofdgpsdata", "dgpsid"); 63 68 @SuppressWarnings("unchecked") 64 69 private void writeAttr(Map<String, Object> attr) { 65 // FIXME this loop is evil, because it does not assure the 66 // correct element order specified by the xml schema. 67 // for now it works, but future extension could get very complex and unmaintainable 68 for (Map.Entry<String, Object> ent : attr.entrySet()) { 69 String k = ent.getKey(); 70 if (k.equals(GpxData.META_LINKS)) { 71 for (GpxLink link : (Collection<GpxLink>) ent.getValue()) { 72 gpxLink(link); 70 for (String key : WPT_KEYS) { 71 Object value = attr.get(key); 72 if (value != null) { 73 if (key.equals(GpxData.META_LINKS)) { 74 for (GpxLink link : (Collection<GpxLink>) value) { 75 gpxLink(link); 76 } 77 } else { 78 simpleTag(key, value.toString()); 73 79 } 74 } else {75 simpleTag(k, ent.getValue().toString());76 80 } 77 81 }
Note:
See TracChangeset
for help on using the changeset viewer.