Changeset 12136 in josm


Ignore:
Timestamp:
2017-05-13T14:43:25+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #14788 - add robustness against invalid coordinates in .osm files

File:
1 edited

Legend:

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

    r12087 r12136  
    220220        LatLon ll = null;
    221221        if (lat != null && lon != null) {
    222             ll = new LatLon(Double.parseDouble(lat), Double.parseDouble(lon));
    223             nd.setCoor(ll);
     222            try {
     223                ll = new LatLon(Double.parseDouble(lat), Double.parseDouble(lon));
     224                nd.setCoor(ll);
     225            } catch (NumberFormatException e) {
     226                Main.trace(e);
     227            }
    224228        }
    225229        readCommon(nd);
    226         if (ll != null && !ll.isValid()) {
     230        if (lat != null && lon != null && (ll == null || !ll.isValid())) {
    227231            throwException(tr("Illegal value for attributes ''lat'', ''lon'' on node with ID {0}. Got ''{1}'', ''{2}''.",
    228232                    Long.toString(nd.getId()), lat, lon));
Note: See TracChangeset for help on using the changeset viewer.