Changeset 15886 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2020-02-19T09:08:57+01:00 (5 years ago)
Author:
GerdP
Message:

fix #9599: Join Overlapping Areas" creates a new way when joining 2 buildings

  • now also takes care when inner ways of multipolygons are selected together with outer ways
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r15884 r15886  
    686686
    687687        for (Way way : outerStartingWays) {
    688             List<Way> splitWays = splitWayOnNodes(way, nodes);
    689 
    690             // see #9599
    691             if (!way.isNew() && splitWays.size() > 1) {
    692                 for (Way part : splitWays) {
    693                     Node n = part.firstNode();
    694                     Way old = oldestWayMap.get(n);
    695                     if (old == null || old.getUniqueId() > way.getUniqueId()) {
    696                         oldestWayMap.put(n, way);
    697                     }
    698                 }
    699             }
    700 
     688            List<Way> splitWays = splitWayOnNodes(way, nodes, oldestWayMap);
    701689            preparedWays.addAll(markWayInsideSide(splitWays, false));
    702690        }
    703691
    704692        for (Way way : innerStartingWays) {
    705             List<Way> splitWays = splitWayOnNodes(way, nodes);
     693            List<Way> splitWays = splitWayOnNodes(way, nodes, oldestWayMap);
    706694            preparedWays.addAll(markWayInsideSide(splitWays, true));
    707695        }
     
    11261114     * @param way way to split
    11271115     * @param nodes split points
     1116     * @param oldestWayMap  nodes from old ways (modified here)
    11281117     * @return list of split ways (or original way if no splitting is done).
    11291118     */
    1130     private List<Way> splitWayOnNodes(Way way, Set<Node> nodes) {
     1119    private List<Way> splitWayOnNodes(Way way, Set<Node> nodes, Map<Node, Way> oldestWayMap) {
    11311120
    11321121        List<Way> result = new ArrayList<>();
     
    11441133                result.add(split.getOriginalWay());
    11451134                result.addAll(split.getNewWays());
     1135
     1136                // see #9599
     1137                if (!way.isNew() && result.size() > 1) {
     1138                    for (Way part : result) {
     1139                        Node n = part.firstNode();
     1140                        Way old = oldestWayMap.get(n);
     1141                        if (old == null || old.getUniqueId() > way.getUniqueId()) {
     1142                            oldestWayMap.put(n, way);
     1143                        }
     1144                    }
     1145                }
    11461146            }
    11471147        }
     
    11501150            result.add(way);
    11511151        }
    1152 
    11531152        return result;
    11541153    }
Note: See TracChangeset for help on using the changeset viewer.