Changeset 1523 in josm for trunk/src/org/openstreetmap/josm/io/OsmReader.java
- Timestamp:
- 2009-04-06T20:18:48+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r1499 r1523 8 8 import java.io.InputStreamReader; 9 9 import java.util.ArrayList; 10 import java.util.Arrays;11 10 import java.util.Collection; 12 11 import java.util.HashMap; 13 import java.util.HashSet;14 12 import java.util.LinkedList; 15 13 import java.util.Map; … … 130 128 private Map<OsmPrimitiveData, Collection<RelationMemberData>> relations = new HashMap<OsmPrimitiveData, Collection<RelationMemberData>>(); 131 129 132 /**133 * List of protocol versions that will be accepted on reading134 */135 private HashSet<String> allowedVersions = new HashSet<String>();136 137 130 private class Parser extends DefaultHandler { 138 131 /** … … 164 157 if (atts == null) 165 158 throw new SAXException(tr("Unknown version")); 166 if (!allowedVersions.contains(atts.getValue("version"))) 167 throw new SAXException(tr("Unknown version")+": "+atts.getValue("version")); 159 String v = atts.getValue("version"); 160 if (v == null) 161 throw new SAXException(tr("Version number missing from OSM data")); 162 if (!(v.equals("0.5") || v.equals("0.6"))) 163 throw new SAXException(tr("Unknown version: {0}", v)); 168 164 // save generator attribute for later use when creating DataSource objects 169 165 generator = atts.getValue("generator"); 170 171 172 } else if (qName.equals("bound")) { 173 // old style bounds. 174 // TODO: remove this around 1st October 2008. 175 // - this is a bit of a hack; since we still write out old style bound objects, 176 // we don't want to load them both. so when writing, we add a "note" tag the our 177 // old-style bound, and when reading, ignore those with a "note". 178 String note = atts.getValue("note"); 179 if (note == null) { 180 System.out.println("Notice: old style <bound> element detected; support for these will be dropped in a future release."); 181 String bbox = atts.getValue("box"); 182 String origin = atts.getValue("origin"); 183 if (origin == null) origin = ""; 184 if (bbox != null) { 185 String[] b = bbox.split(","); 186 Bounds bounds = new Bounds(); 187 if (b.length == 4) 188 bounds = new Bounds( 189 new LatLon(Double.parseDouble(b[0]),Double.parseDouble(b[1])), 190 new LatLon(Double.parseDouble(b[2]),Double.parseDouble(b[3]))); 191 DataSource src = new DataSource(bounds, origin); 192 ds.dataSources.add(src); 193 } 194 } 166 ds.version = v; 167 195 168 } else if (qName.equals("bounds")) { 196 169 // new style bounds. … … 277 250 return Double.parseDouble(atts.getValue(value)); 278 251 } 279 }280 281 /**282 * Constructor initializes list of allowed protocol versions.283 */284 public OsmReader() {285 // first add the main server version286 allowedVersions.add(Main.pref.get("osm-server.version", "0.5"));287 // now also add all compatible versions288 String[] additionalVersions =289 Main.pref.get("osm-server.additional-versions", "").split("/,/");290 if (additionalVersions.length == 1 && additionalVersions[0].length() == 0)291 additionalVersions = new String[] {};292 allowedVersions.addAll(Arrays.asList(additionalVersions));293 252 } 294 253 … … 491 450 osm.references = ref == null ? new DataSet() : ref; 492 451 493 494 452 currSource = source; 495 453
Note:
See TracChangeset
for help on using the changeset viewer.