Ignore:
Timestamp:
2009-10-04T00:37:05+02:00 (17 years ago)
Author:
stoecker
Message:

fixed #3649 - show node coordinates in history dialog

File:
1 edited

Legend:

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

    r2181 r2242  
    8080        }
    8181
     82        protected long getAttributeLong(Attributes attr, String name, long defaultValue) throws SAXException{
     83            String v = attr.getValue(name);
     84            if (v == null) {
     85                return defaultValue;
     86            }
     87            Long l = 0l;
     88            try {
     89                l = Long.parseLong(v);
     90            } catch(NumberFormatException e) {
     91                throwException(tr("Illegal value for mandatory attribute ''{0}'' of type long. Got ''{1}''.", name, v));
     92            }
     93            if (l < 0) {
     94                throwException(tr("Illegal value for mandatory attribute ''{0}'' of type long (>=0). Got ''{1}''.", name, v));
     95            }
     96            return l;
     97        }
     98
    8299        protected int getMandatoryAttributeInt(Attributes attr, String name) throws SAXException{
    83100            String v = attr.getValue(name);
     
    97114        }
    98115
     116        protected double getMandatoryAttributeDouble(Attributes attr, String name) throws SAXException{
     117            String v = attr.getValue(name);
     118            if (v == null) {
     119                throwException(tr("Missing mandatory attribute ''{0}''.", name));
     120            }
     121            double d = 0.0;
     122            try {
     123                d = Double.parseDouble(v);
     124            } catch(NumberFormatException e) {
     125                throwException(tr("Illegal value for mandatory attribute ''{0}'' of type double. Got ''{1}''.", name, v));
     126            }
     127            return d;
     128        }
     129
    99130        protected String getMandatoryAttributeString(Attributes attr, String name) throws SAXException{
    100131            String v = attr.getValue(name);
     
    102133                throwException(tr("Missing mandatory attribute ''{0}''.", name));
    103134            }
     135            return v;
     136        }
     137
     138        protected String getAttributeString(Attributes attr, String name, String defaultValue) {
     139            String v = attr.getValue(name);
     140            if (v == null)
     141                v = defaultValue;
    104142            return v;
    105143        }
     
    119157        protected  HistoryOsmPrimitive createPrimitive(Attributes atts, OsmPrimitiveType type) throws SAXException {
    120158            long id = getMandatoryAttributeLong(atts,"id");
    121             long version = getMandatoryAttributeLong(atts,"version");
    122             long changesetId = getMandatoryAttributeLong(atts,"changeset");
    123             boolean visible= getMandatoryAttributeBoolean(atts, "visible");
    124             long uid = getMandatoryAttributeLong(atts, "uid");
    125             String user = getMandatoryAttributeString(atts, "user");
     159            long version = getMandatoryAttributeLong(atts, "version");
     160            long changesetId = getMandatoryAttributeLong(atts, "changeset");
     161            boolean visible = getMandatoryAttributeBoolean(atts, "visible");
     162            long uid = getAttributeLong(atts, "uid", -1);
     163            String user = getAttributeString(atts, "user", tr("<anonymous>"));
    126164            String v = getMandatoryAttributeString(atts, "timestamp");
    127165            Date timestamp = DateUtils.fromString(v);
    128166            HistoryOsmPrimitive primitive = null;
    129167            if (type.equals(OsmPrimitiveType.NODE)) {
     168                double lat = getMandatoryAttributeDouble(atts, "lat");
     169                double lon = getMandatoryAttributeDouble(atts, "lon");
    130170                primitive = new HistoryNode(
    131                         id,version,visible,user,uid,changesetId,timestamp
     171                        id,version,visible,user,uid,changesetId,timestamp,lat,lon
    132172                );
    133173            } else if (type.equals(OsmPrimitiveType.WAY)) {
Note: See TracChangeset for help on using the changeset viewer.