Changeset 17131 in josm


Ignore:
Timestamp:
2020-10-09T06:59:05+02:00 (4 years ago)
Author:
GerdP
Message:

see #19822: Inconsistent behavior with GeoJSON multipolygons

  • fix another place were fillTagsFromFeature() was called after a tag was added to the OSM primitive
  • add javadoc for the rather confusing behaviour of fillTagsFromFeature()
  • add unit test
Location:
trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/GeoJSONReader.java

    r17115 r17131  
    163163        // create misc. non-geometry feature
    164164        final Relation relation = new Relation();
     165        fillTagsFromFeature(feature, relation);
    165166        relation.put(TYPE, type.toString());
    166         fillTagsFromFeature(feature, relation);
    167167        getDataSet().addPrimitive(relation);
    168168    }
     
    325325    }
    326326
     327    /**
     328     * Replace all existing tags in primitive by the values given in the GeoJSON feature.
     329     * @param feature the GeoJSON feature
     330     * @param primitive the OSM primitive
     331     */
    327332    private static void fillTagsFromFeature(final JsonObject feature, final OsmPrimitive primitive) {
    328333        if (feature != null) {
  • trunk/test/unit/org/openstreetmap/josm/io/GeoJSONReaderTest.java

    r16935 r17131  
    2525import org.openstreetmap.josm.data.osm.Node;
    2626import org.openstreetmap.josm.data.osm.OsmPrimitive;
     27import org.openstreetmap.josm.data.osm.Relation;
    2728import org.openstreetmap.josm.data.osm.Way;
    2829import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    186187                .allMatch(i -> areEqualNodes(((Way) p1).getNode(i), ((Way) p2).getNode(i)));
    187188    }
     189
     190    /**
     191     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/19822">Bug #19822</a>.
     192     * @throws Exception in case of error
     193     */
     194    @Test
     195    public void testTicket19822() throws Exception {
     196        try (InputStream in = TestUtils.getRegressionDataStream(19822, "data.geojson")) {
     197            final List<OsmPrimitive> primitives = new ArrayList<>(
     198                    new GeoJSONReader().doParseDataSet(in, null).getPrimitives(it -> true));
     199            assertTrue(primitives.stream().anyMatch(p -> p instanceof Relation && p.isMultipolygon()));
     200        }
     201    }
     202
    188203}
Note: See TracChangeset for help on using the changeset viewer.