Changeset 15887 in josm for trunk/src


Ignore:
Timestamp:
2020-02-19T11:01:46+01:00 (5 years ago)
Author:
GerdP
Message:

fix #9599: Join Overlapping Areas" creates a new way when joining 2 buildings
Have to call keepOlder() earlier and keepOlder() must return the original way, not the copy, as the copy will not be part of the dataset.

File:
1 edited

Legend:

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

    r15886 r15887  
    699699        List<AssembledPolygon> boundaries = findBoundaryPolygons(preparedWays, discardedWays);
    700700
     701        //  see #9599
     702        if (discardedWays.stream().anyMatch(w -> !w.isNew())) {
     703            for (int i = 0; i < boundaries.size(); i++) {
     704                AssembledPolygon ring = boundaries.get(i);
     705                for (int k = 0; k < ring.ways.size(); k++) {
     706                    WayInPolygon ringWay = ring.ways.get(k);
     707                    Way older = keepOlder(ringWay.way, oldestWayMap, discardedWays);
     708
     709                    if (ringWay.way != older) {
     710                        WayInPolygon repl = new WayInPolygon(older, ringWay.insideToTheRight);
     711                        ring.ways.set(k, repl);
     712                    }
     713                }
     714            }
     715            commitCommands(marktr("Keep older versions"));
     716        }
     717
    701718        //find polygons
    702719        List<AssembledMultipolygon> preparedPolygons = findPolygons(boundaries);
     
    731748
    732749        commitCommands(marktr("Delete relations"));
    733 
    734         // see #9599: result should contain original way(s) where possible
    735         if (discardedWays.stream().anyMatch(w -> !w.isNew())) {
    736             for (int i = 0; i < polygons.size(); i++) {
    737                 Multipolygon mp = polygons.get(i);
    738                 for (int k = 0; k < mp.getInnerWays().size(); k++) {
    739                     Way inner = mp.getInnerWays().get(k);
    740                     Way older = keepOlder(inner, oldestWayMap, discardedWays);
    741                     if (inner != older) {
    742                         mp.getInnerWays().set(k, older);
    743                     }
    744                 }
    745                 Way older = keepOlder(mp.outerWay, oldestWayMap, discardedWays);
    746                 if (older != mp.outerWay) {
    747                     Multipolygon mpNew = new Multipolygon(older);
    748                     mpNew.innerWays.addAll(mp.getInnerWays());
    749                     polygons.set(i, mpNew);
    750                 }
    751             }
    752             commitCommands(marktr("Keep older versions"));
    753         }
    754750
    755751        // Delete the discarded inner ways
     
    795791            copy.setNodes(way.getNodes());
    796792            cmds.add(new ChangeCommand(oldest, copy));
    797             return copy;
     793            return oldest;
    798794        }
    799795        return way;
Note: See TracChangeset for help on using the changeset viewer.