Changeset 5480 in josm for trunk/src/org


Ignore:
Timestamp:
2012-08-27T23:31:28+02:00 (12 years ago)
Author:
Don-vip
Message:

fix #8008 - validator doesn't detect duplicated closed way

File:
1 edited

Legend:

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

    r4874 r5480  
    140140    /**
    141141     * Remove uninteresting keys, like created_by to normalize the tags
     142     * @param wkeys The tags of the way, obtained by {@code Way#getKeys}
    142143     */
    143144    public void removeUninterestingKeys(Map<String, String> wkeys) {
     
    151152        List<Node> wNodes = w.getNodes();
    152153        List<LatLon> wLat = new ArrayList<LatLon>(wNodes.size());
    153         for (int i=0;i<wNodes.size();i++) {
    154             wLat.add(wNodes.get(i).getCoor());
     154        if (w.isClosed()) {
     155            // In case of a closed way, build the list of lat/lon starting from the node with the lowest id
     156            // to ensure this list will produce the same hashcode as the list obtained from another closed
     157            // way with the same nodes, in the same order, but that does not start from the same node (fix #8008)
     158            int lowestIndex = 0;
     159            long lowestNodeId = wNodes.get(0).getUniqueId();
     160            for (int i=1; i<wNodes.size(); i++) {
     161                if (wNodes.get(i).getUniqueId() < lowestNodeId) {
     162                    lowestNodeId = wNodes.get(i).getUniqueId();
     163                    lowestIndex = i;
     164                }
     165            }
     166            for (int i=lowestIndex; i<wNodes.size()-1; i++) {
     167                wLat.add(wNodes.get(i).getCoor());
     168            }
     169            for (int i=0; i<lowestIndex; i++) {
     170                wLat.add(wNodes.get(i).getCoor());
     171            }
     172            wLat.add(wNodes.get(lowestIndex).getCoor());
     173        } else {
     174            for (int i=0; i<wNodes.size(); i++) {
     175                wLat.add(wNodes.get(i).getCoor());
     176            }
    155177        }
    156178        Map<String, String> wkeys = w.getKeys();
Note: See TracChangeset for help on using the changeset viewer.