Ignore:
Timestamp:
2018-06-20T19:25:48+02:00 (6 years ago)
Author:
donvip
Message:

fix #josm16402 - Cannot read kml with complex ExtendedData section

Location:
applications/editors/josm/plugins/opendata
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmlReader.java

    r34089 r34331  
    3030import org.openstreetmap.josm.plugins.opendata.core.OdConstants;
    3131import org.openstreetmap.josm.plugins.opendata.core.io.ProjectionPatterns;
     32import org.openstreetmap.josm.tools.Logging;
    3233import org.openstreetmap.josm.tools.date.DateUtils;
    3334
     
    5051    public static final String KML_EXT_TRACK = "Track";
    5152    public static final String KML_EXT_COORD = "coord";
     53    public static final String KML_EXT_LANG = "lang";
    5254    // CHECKSTYLE.ON: SingleSpaceSeparator
    5355
     
    104106        Relation relation = null;
    105107        String role = "";
     108        String previousName = null;
    106109        Map<String, String> tags = new HashMap<>();
    107110        while (parser.hasNext()) {
     
    115118                    }
    116119                } else if (parser.getLocalName().equals(KML_NAME)) {
    117                     tags.put(KML_NAME, parser.getElementText());
     120                    try {
     121                        tags.put(KML_NAME, parser.getElementText());
     122                    } catch (XMLStreamException e) {
     123                        Logging.trace(e);
     124                    }
    118125                } else if (parser.getLocalName().equals(KML_SIMPLE_DATA)) {
    119126                    String key = parser.getAttributeValue(null, "name");
     
    151158                } else if (parser.getLocalName().equals(KML_WHEN)) {
    152159                    when = DateUtils.tsFromString(parser.getElementText().trim());
    153                 }
     160                } else if (parser.getLocalName().equals(KML_EXT_LANG)) {
     161                    if (KML_NAME.equals(previousName)) {
     162                        tags.put(KML_NAME, parser.getElementText());
     163                    }
     164                }
     165                previousName = parser.getLocalName();
    154166            } else if (event == XMLStreamConstants.END_ELEMENT) {
    155167                if (parser.getLocalName().equals(KML_PLACEMARK)) {
     
    158170                    list.add(node);
    159171                } else if (parser.getLocalName().equals(KML_LINE_STRING)
    160                         || parser.getLocalName().equals(KML_EXT_TRACK) 
     172                        || parser.getLocalName().equals(KML_EXT_TRACK)
    161173                        || parser.getLocalName().equals(KML_LINEAR_RING)) {
    162174                    if (way != null && wayNodes != null)
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmlReaderTest.java

    r34153 r34331  
    4141
    4242    /**
     43     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/16402">#16402</a>
     44     * @throws Exception if an error occurs during reading
     45     */
     46    @Test
     47    public void testTicket16402() throws Exception {
     48        try (InputStream is = TestUtils.getRegressionDataStream(16402, "MapsMe-new.kml")) {
     49            NonRegFunctionalTests.testGeneric("#16402", KmlReader.parseDataSet(is, null));
     50        }
     51    }
     52
     53    /**
    4354     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/12694">#12694</a>
    4455     * @throws Exception if an error occurs during reading
Note: See TracChangeset for help on using the changeset viewer.