Changeset 1604 in josm for trunk/src/org/openstreetmap/josm/io/OsmReader.java
- Timestamp:
- 2009-05-19T19:05:10+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r1523 r1604 206 206 207 207 } else if (qName.equals("relation")) { 208 // relationsN++;209 208 current = new OsmPrimitiveData(); 210 209 readCommon(atts, current); 211 210 relations.put((OsmPrimitiveData)current, new LinkedList<RelationMemberData>()); 212 211 } else if (qName.equals("member")) { 213 // membersN++;214 212 Collection<RelationMemberData> list = relations.get(current); 215 213 if (list == null) … … 217 215 RelationMemberData emd = new RelationMemberData(); 218 216 emd.relationMember = new RelationMember(); 219 emd.id = getLong(atts, "ref"); 220 emd.type=atts.getValue("type"); 221 emd.relationMember.role = atts.getValue("role"); 222 217 String value = atts.getValue("ref"); 218 if (value == null) { 219 throw new SAXException(tr("Missing attribute \"ref\" on member in relation {0}",current.id)); 220 } 221 try { 222 emd.id = Long.parseLong(value); 223 } catch(NumberFormatException e) { 224 throw new SAXException(tr("Illegal value for attribute \"ref\" on member in relation {0}, got {1}", Long.toString(current.id),value)); 225 } 226 value = atts.getValue("type"); 227 if (value == null) { 228 throw new SAXException(tr("Missing attribute \"type\" on member {0} in relation {1}", Long.toString(emd.id), Long.toString(current.id))); 229 } 230 if (! (value.equals("way") || value.equals("node") || value.equals("relation"))) { 231 throw new SAXException(tr("Unexpected \"type\" on member {0} in relation {1}, got {2}.", Long.toString(emd.id), Long.toString(current.id), value)); 232 } 233 emd.type= value; 234 value = atts.getValue("role"); 235 emd.relationMember.role = value; 236 223 237 if (emd.id == 0) 224 238 throw new SAXException(tr("Incomplete <member> specification with ref=0")); … … 271 285 current.user = User.get(user); 272 286 } 287 288 // uid attribute added in 0.6 API 289 String uid = atts.getValue("uid"); 290 if (uid != null) { 291 if (current.user != null) { 292 current.user.uid = uid; 293 } 294 } 273 295 274 296 // visible attribute added in 0.4 API … … 278 300 } 279 301 280 // oldversion attribute added in 0.6 API281 282 // Note there is an asymmetry here: the server will send283 // the version as "version" the client sends it as284 // "oldversion". So we take both since which we receive will285 // depend on reading from a file or reading from the server286 287 302 String version = atts.getValue("version"); 303 current.version = 0; 288 304 if (version != null) { 289 current.version = Integer.parseInt(version); 290 } 291 version = atts.getValue("old_version"); 292 if (version != null) { 293 current.version = Integer.parseInt(version); 305 try { 306 current.version = Integer.parseInt(version); 307 } catch(NumberFormatException e) { 308 throw new SAXException(tr("Illegal value for attribute \"version\" on OSM primitive with id {0}, got {1}", Long.toString(current.id), version)); 309 } 310 } else { 311 // version expected for OSM primitives with an id assigned by the server (id > 0), since API 0.6 312 // 313 if (current.id > 0 && ds.version != null && ds.version.equals("0.6")) { 314 throw new SAXException(tr("Missing attribute \"version\" on OSM primitive with id {0}", Long.toString(current.id))); 315 } 294 316 } 295 317
Note:
See TracChangeset
for help on using the changeset viewer.