Ticket #2545: relation-reading.patch
| File relation-reading.patch, 5.4 KB (added by , 17 years ago) |
|---|
-
src/org/openstreetmap/josm/actions/OpenFileAction.java
65 65 openAsData(file); 66 66 } catch (SAXException x) { 67 67 x.printStackTrace(); 68 JOptionPane.showMessageDialog(Main.parent, tr("Error while parsing {0}",file.getName())+": "+x.getMessage() );68 JOptionPane.showMessageDialog(Main.parent, tr("Error while parsing {0}",file.getName())+": "+x.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); 69 69 } catch (IOException x) { 70 70 x.printStackTrace(); 71 JOptionPane.showMessageDialog(Main.parent, tr("Could not read \"{0}\"",file.getName())+"\n"+x.getMessage() );71 JOptionPane.showMessageDialog(Main.parent, tr("Could not read \"{0}\"",file.getName())+"\n"+x.getMessage(),"Error", JOptionPane.ERROR_MESSAGE); 72 72 } 73 73 } 74 74 -
src/org/openstreetmap/josm/io/OsmReader.java
205 205 // ---- PARSING RELATIONS ---- 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) 216 214 throw new SAXException(tr("Found <member> element in non-relation.")); 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 if (value == null) { 236 System.out.println(tr("WARNING: no attribute \"role\" on member {0} in relation {1}, assuming empty role \"\"",Long.toString(emd.id), Long.toString(current.id))); 237 value = ""; 238 } 239 emd.relationMember.role = value; 240 223 241 if (emd.id == 0) 224 242 throw new SAXException(tr("Incomplete <member> specification with ref=0")); 225 243 … … 277 295 current.visible = Boolean.parseBoolean(visible); 278 296 } 279 297 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 298 String version = atts.getValue("version"); 288 299 if (version != null) { 289 current.version = Integer.parseInt(version); 300 try { 301 current.version = Integer.parseInt(version); 302 } catch(NumberFormatException e) { 303 throw new SAXException(tr("Illegal value for attribute \"version\" on OSM primitive with id {0}, got {1}", Long.toString(current.id), version)); 304 } 305 } else { 306 throw new SAXException(tr("Missing attribute \"version\" on OSM primitive with id {0}", Long.toString(current.id))); 290 307 } 291 version = atts.getValue("old_version");292 if (version != null) {293 current.version = Integer.parseInt(version);294 }295 308 296 309 String action = atts.getValue("action"); 297 310 if (action == null)
