Changeset 19066 in josm


Ignore:
Timestamp:
2024-04-28T11:24:57+02:00 (7 months ago)
Author:
GerdP
Message:

fix #23641: When mapping a forest inside a forest and make that inner, the inner landuse=forest tag is removed.

  • change code so the tags of inner ways which are common to the multipolygon are not removed.
  • add unit test
Location:
trunk
Files:
2 added
2 edited

Legend:

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

    r18208 r19066  
    465465            String key = entry.getKey();
    466466            String value = entry.getValue();
    467             List<OsmPrimitive> affectedWays = innerWays.stream().filter(way -> value.equals(way.get(key))).collect(Collectors.toList());
     467            List<OsmPrimitive> affectedWays;
     468            if ("area".equals(key)) {
     469                affectedWays = innerWays.stream().filter(way -> value.equals(way.get(key))).collect(Collectors.toList());
     470            } else {
     471                affectedWays = new ArrayList<>();
     472            }
    468473
    469474            if (moveTags) {
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java

    r18870 r19066  
    291291    }
    292292
     293    /**
     294     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/23641">Bug #23641</a>.
     295     * @throws Exception if an error occurs
     296     */
     297    @Test
     298    void testTicket23642() throws Exception {
     299        DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(23641, "data.osm"), null);
     300        assertEquals(0, ds.getRelations().size());
     301        Pair<SequenceCommand, Relation> cmd = CreateMultipolygonAction.createMultipolygonCommand(ds.getWays(), null);
     302        assertNotNull(cmd);
     303        cmd.a.executeCommand();
     304        assertEquals(1, ds.getRelations().size());
     305        Relation mp = ds.getRelations().iterator().next();
     306        assertTrue(mp.hasTag("landuse", "forest"));
     307        assertTrue(mp.hasTag("leaf_type", "needleleaved"));
     308        assertEquals(0, ds.getWays().stream().filter(w -> w.hasTag("leaf_type", "needleleaved")).count());
     309        assertEquals(1, ds.getWays().stream().filter(w -> w.hasTag("leaf_type", "broadleaved")).count());
     310        assertEquals(1, mp.getMembers().stream()
     311                .filter(m -> "inner".equals(m.getRole()) && m.getMember().hasTag("landuse", "forest")).count());
     312        Pair<SequenceCommand, Relation> updateCmd = CreateMultipolygonAction.createMultipolygonCommand(ds.getWays(), mp);
     313        assertNull(updateCmd);
     314    }
     315
    293316}
Note: See TracChangeset for help on using the changeset viewer.