Changeset 5356 in josm for trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java
- Timestamp:
- 2012-07-22T22:36:44+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java
r5287 r5356 44 44 double precision = Main.pref.getDouble("validator.duplicatenodes.precision", 0.); 45 45 46 private LatLon RoundCoord(Node o) {46 private LatLon roundCoord(LatLon coor) { 47 47 return new LatLon( 48 Math.round( o.getCoor().lat() / precision) * precision,49 Math.round( o.getCoor().lon() / precision) * precision48 Math.round(coor.lat() / precision) * precision, 49 Math.round(coor.lon() / precision) * precision 50 50 ); 51 51 } … … 54 54 private LatLon getLatLon(Object o) { 55 55 if (o instanceof Node) { 56 LatLon coor = ((Node) o).getCoor(); 57 if (coor == null) 58 return null; 56 59 if (precision==0) 57 return ((Node) o).getCoor().getRoundedToOsmPrecision();58 return RoundCoord((Node) o);60 return coor.getRoundedToOsmPrecision(); 61 return roundCoord(coor); 59 62 } else if (o instanceof List<?>) { 63 LatLon coor = ((List<Node>) o).get(0).getCoor(); 64 if (coor == null) 65 return null; 60 66 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); 63 69 } else 64 70 throw new AssertionError(); … … 67 73 @Override 68 74 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)); 70 78 } 71 79 72 80 @Override 73 81 public int getHashCode(Object k) { 74 return getLatLon(k).hashCode(); 82 LatLon coorK = getLatLon(k); 83 return coorK == null ? 0 : coorK.hashCode(); 75 84 } 76 85 }
Note:
See TracChangeset
for help on using the changeset viewer.