Ticket #5760: JOSM-terracer_compare.2.patch

File JOSM-terracer_compare.2.patch, 1.3 KB (added by robome, 15 years ago)

v2 to properly address any amount and any type of whitespace

  • src/terracer/TerracerAction.java

     
    233233     *            number nodes
    234234     */
    235235    class HousenumberNodeComparator implements Comparator<Node> {
    236         private final Pattern pat = Pattern.compile("^([0-9]+)");
     236        private final Pattern pat = Pattern.compile("^(\\d+)\\s*(.*)");
    237237
    238238        /*
    239239         * (non-Javadoc)
     
    251251            Matcher mat = pat.matcher(node1String);
    252252            if (mat.find()) {
    253253                Integer node1Int = Integer.valueOf(mat.group(1));
     254                String node1Rest = mat.group(2);
    254255                mat = pat.matcher(node2String);
    255256                if (mat.find()) {
    256257                    Integer node2Int = Integer.valueOf(mat.group(1));
     258                    // If the numbers are the same, the rest has to make the decision,
     259                    // e.g. when comparing 23, 23a and 23b.
     260                    if (node1Int == node2Int)
     261                    {
     262                      String node2Rest = mat.group(2);
     263                      return node1Rest.compareTo(node2Rest);
     264                    }
    257265
    258266                    return node1Int.compareTo(node2Int);
    259267                }