Ignore:
Timestamp:
2012-07-22T22:36:44+02:00 (12 years ago)
Author:
Don-vip
Message:

see #7847, see #7884 - Fix 2 NPE when dealing with nodes without coordinates + display "(none)" in history when coordinates are missing to distinguish this fact from the deleted state (and be homogenous with conflict dialog)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java

    r5287 r5356  
    4444        double precision = Main.pref.getDouble("validator.duplicatenodes.precision", 0.);
    4545
    46         private LatLon RoundCoord(Node o) {
     46        private LatLon roundCoord(LatLon coor) {
    4747            return new LatLon(
    48                     Math.round(o.getCoor().lat() / precision) * precision,
    49                     Math.round(o.getCoor().lon() / precision) * precision
     48                    Math.round(coor.lat() / precision) * precision,
     49                    Math.round(coor.lon() / precision) * precision
    5050                    );
    5151        }
     
    5454        private LatLon getLatLon(Object o) {
    5555            if (o instanceof Node) {
     56                LatLon coor = ((Node) o).getCoor();
     57                if (coor == null)
     58                    return null;
    5659                if (precision==0)
    57                     return ((Node) o).getCoor().getRoundedToOsmPrecision();
    58                 return RoundCoord((Node) o);
     60                    return coor.getRoundedToOsmPrecision();
     61                return roundCoord(coor);
    5962            } else if (o instanceof List<?>) {
     63                LatLon coor = ((List<Node>) o).get(0).getCoor();
     64                if (coor == null)
     65                    return null;
    6066                if (precision==0)
    61                     return ((List<Node>) o).get(0).getCoor().getRoundedToOsmPrecision();
    62                 return RoundCoord(((List<Node>) o).get(0));
     67                    return coor.getRoundedToOsmPrecision();
     68                return roundCoord(coor);
    6369            } else
    6470                throw new AssertionError();
     
    6773        @Override
    6874        public boolean equals(Object k, Object t) {
    69             return getLatLon(k).equals(getLatLon(t));
     75            LatLon coorK = getLatLon(k);
     76            LatLon coorT = getLatLon(t);
     77            return coorK == coorT || (coorK != null && coorT != null && coorK.equals(coorT));
    7078        }
    7179
    7280        @Override
    7381        public int getHashCode(Object k) {
    74             return getLatLon(k).hashCode();
     82            LatLon coorK = getLatLon(k);
     83            return coorK == null ? 0 : coorK.hashCode();
    7584        }
    7685    }
Note: See TracChangeset for help on using the changeset viewer.