Changeset 2377 in josm


Ignore:
Timestamp:
2009-11-01T19:34:42+01:00 (14 years ago)
Author:
Gubaer
Message:

fixed #3443: Illegal value for attribute 'version' when loading OSM file

File:
1 edited

Legend:

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

    r2291 r2377  
    168168        private OsmPrimitiveData current;
    169169        private String generator;
     170
     171        protected void fixLegacyVersion(Attributes atts) throws SAXException {
     172            if (ds.version.equals("0.6") && atts.getValue("version") == null) {
     173                throwException(
     174                        tr("Mandatory attribute ''version'' missing for object with id {0}.", current.id)
     175                );
     176            } else if (ds.version.equals("0.5") && atts.getValue("version") == null) {
     177                // legacy mode. 0.5 data might not have version attribute. Init with
     178                // default value 1
     179                //
     180                current.version = 1;
     181            }
     182        }
    170183
    171184        @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
     
    214227                current.latlon = new LatLon(getDouble(atts, "lat"), getDouble(atts, "lon"));
    215228                readCommon(atts, current);
     229                fixLegacyVersion(atts);
    216230                Node n = current.createNode();
    217231                externalIdMap.put("n"+current.id, n);
     
    219233                current = new OsmPrimitiveData();
    220234                readCommon(atts, current);
     235                fixLegacyVersion(atts);
    221236                Way w = current.createWay();
    222237                externalIdMap.put("w"+current.id, w);
     
    247262                current = new OsmPrimitiveData();
    248263                readCommon(atts, current);
     264                fixLegacyVersion(atts);
    249265                Relation r = current.createRelation();
    250266                externalIdMap.put("r"+current.id, r );
Note: See TracChangeset for help on using the changeset viewer.