Changeset 28441 in osm


Ignore:
Timestamp:
2012-06-17T17:56:14+02:00 (12 years ago)
Author:
donvip
Message:

[josm_opendata] fix #josm7714 - KML import fails when coordinates content starts with a space character

File:
1 edited

Legend:

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

    r28191 r28441  
    132132                        list.add(way);
    133133                } else if (parser.getLocalName().equals(KML_COORDINATES)) {
    134                         String[] tab = parser.getElementText().split(" ");
     134                        String[] tab = parser.getElementText().trim().split(" ");
    135135                        for (int i = 0; i < tab.length; i ++) {
    136                                 String[] values = tab[i].split(",");
    137                                 LatLon ll = new LatLon(Double.valueOf(values[1]), Double.valueOf(values[0])).getRoundedToOsmPrecisionStrict();
    138                                 node = nodes.get(ll);
    139                                 if (node == null) {
    140                                         ds.addPrimitive(node = new Node(ll));
    141                                         nodes.put(ll, node);
    142                                         if (values.length > 2 && !values[2].equals("0")) {
    143                                                 node.put("ele", values[2]);
    144                                         }
    145                                 }
    146                                 if (way != null) {
    147                                         way.addNode(node);
     136                                String[] values = tab[i].split(",");
     137                                if (values.length >= 2) {
     138                                        LatLon ll = new LatLon(Double.valueOf(values[1]), Double.valueOf(values[0])).getRoundedToOsmPrecisionStrict();
     139                                        node = nodes.get(ll);
     140                                        if (node == null) {
     141                                                ds.addPrimitive(node = new Node(ll));
     142                                                nodes.put(ll, node);
     143                                                if (values.length > 2 && !values[2].equals("0")) {
     144                                                        node.put("ele", values[2]);
     145                                                }
     146                                        }
     147                                        if (way != null) {
     148                                                way.addNode(node);
     149                                        }
    148150                                }
    149151                        }
Note: See TracChangeset for help on using the changeset viewer.