Changeset 17343 in josm


Ignore:
Timestamp:
2020-11-23T21:39:48+01:00 (3 months ago)
Author:
GerdP
Message:

fix #20110: "Update multipolygon" strips natural=coastline from member ways

  • fix and unit test
Location:
trunk
Files:
2 added
2 edited

Legend:

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

    r17325 r17343  
    416416                    if (!values.containsKey(key)) { //relation values take precedence
    417417                        values.put(key, way.get(key));
    418                     } else if (!relation.hasKey(key) && !values.get(key).equals(way.get(key))) {
     418                    } else if (!values.get(key).equals(way.get(key))) {
    419419                        conflictingKeys.add(key);
    420420                    }
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java

    r17275 r17343  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNotNull;
    67import static org.junit.jupiter.api.Assertions.assertTrue;
    78
     
    1213import java.util.TreeMap;
    1314
     15import org.junit.jupiter.api.Test;
    1416import org.junit.jupiter.api.extension.RegisterExtension;
    15 import org.junit.jupiter.api.Test;
    1617import org.openstreetmap.josm.TestUtils;
    1718import org.openstreetmap.josm.command.SequenceCommand;
     
    156157
    157158    }
     159
     160    /**
     161     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/20110">Bug #20110</a>.
     162     * @throws Exception if an error occurs
     163     */
     164    @Test
     165    void testTicket20110() throws Exception {
     166        DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(20110, "data.osm"), null);
     167        assertEquals(1, ds.getRelations().size());
     168        Relation mp = ds.getRelations().iterator().next();
     169        assertEquals("wetland", mp.get("natural"));
     170        long numCoastlineWays = ds.getWays().stream().filter(w -> "coastline".equals(w.get("natural"))).count();
     171        Relation modMp = createMultipolygon(ds.getWays(), "type:way", mp, false);
     172        assertNotNull(modMp);
     173        assertEquals("wetland", modMp.get("natural"));
     174        assertEquals(numCoastlineWays, ds.getWays().stream().filter(w -> "coastline".equals(w.get("natural"))).count());
     175    }
    158176}
Note: See TracChangeset for help on using the changeset viewer.