Changeset 5356 in josm


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)

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java

    r5333 r5356  
    8080            if (!n.isIncomplete() && !n.isDeleted()) {
    8181                LatLon c = n.getCoor();
    82                 BBox box = new BBox(new LatLon(c.lat() - 0.0001, c.lon() - 0.0001), new LatLon(c.lat() + 0.0001, c.lon() + 0.0001));
    83                 if (!dataSet.searchNodes(box).contains(n)) {
    84                     printError("SEARCH NODES", "%s not found using Dataset.searchNodes()", n);
     82                if (c != null) {
     83                    BBox box = new BBox(new LatLon(c.lat() - 0.0001, c.lon() - 0.0001), new LatLon(c.lat() + 0.0001, c.lon() + 0.0001));
     84                    if (!dataSet.searchNodes(box).contains(n)) {
     85                        printError("SEARCH NODES", "%s not found using Dataset.searchNodes()", n);
     86                    }
    8587                }
    8688            }
  • 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    }
  • trunk/src/org/openstreetmap/josm/gui/history/CoordinateInfoViewer.java

    r5346 r5356  
    262262            // display the coordinates
    263263            //
    264             lblLat.setText(coord != null ? coord.latToString(CoordinateFormat.DECIMAL_DEGREES) : tr("Deleted"));
    265             lblLon.setText(coord != null ? coord.lonToString(CoordinateFormat.DECIMAL_DEGREES) : tr("Deleted"));
     264            lblLat.setText(coord != null ? coord.latToString(CoordinateFormat.DECIMAL_DEGREES) : tr("(none)"));
     265            lblLon.setText(coord != null ? coord.lonToString(CoordinateFormat.DECIMAL_DEGREES) : tr("(none)"));
    266266
    267267            // update background color to reflect differences in the coordinates
     
    342342            } else {
    343343                lblDistance.setBackground(coord != oppositeCoord ? BGCOLOR_DIFFERENCE : Color.WHITE);
    344                 lblDistance.setText(tr("Deleted"));
     344                lblDistance.setText(tr("(none)"));
    345345            }
    346346        }
Note: See TracChangeset for help on using the changeset viewer.