Changeset 2382 in josm


Ignore:
Timestamp:
2009-11-02T09:40:17+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

    r2377 r2382  
    169169        private String generator;
    170170
    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         }
    183171
    184172        @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
     
    227215                current.latlon = new LatLon(getDouble(atts, "lat"), getDouble(atts, "lon"));
    228216                readCommon(atts, current);
    229                 fixLegacyVersion(atts);
    230217                Node n = current.createNode();
    231218                externalIdMap.put("n"+current.id, n);
     
    233220                current = new OsmPrimitiveData();
    234221                readCommon(atts, current);
    235                 fixLegacyVersion(atts);
    236222                Way w = current.createWay();
    237223                externalIdMap.put("w"+current.id, w);
     
    262248                current = new OsmPrimitiveData();
    263249                readCommon(atts, current);
    264                 fixLegacyVersion(atts);
    265250                Relation r = current.createRelation();
    266251                externalIdMap.put("r"+current.id, r );
     
    387372                if (current.id > 0 && ds.version != null && ds.version.equals("0.6")) {
    388373                    throwException(tr("Missing attribute ''version'' on OSM primitive with ID {0}.", Long.toString(current.id)));
     374                } else if (current.id > 0 && ds.version != null && ds.version.equals("0.5")) {
     375                    // default version in 0.5 files for existing primitives
     376                    System.out.println(tr("WARNING: Normalizing value of attribute ''version'' of element {0} to {2}, API version is ''{3}''. Got {1}.", current.id, current.version, 1, "0.5"));
     377                    current.version= 1;
     378                } else if (current.id <= 0 && ds.version != null && ds.version.equals("0.5")) {
     379                    // default version in 0.5 files for new primitives
     380                    System.out.println(tr("WARNING: Normalizing value of attribute ''version'' of element {0} to {2}, API version is ''{3}''. Got {1}.", current.id, current.version, 0, "0.5"));
     381                    current.version= 0;
    389382                }
    390383            }
Note: See TracChangeset for help on using the changeset viewer.