Changeset 34089 in osm for applications/editors/josm/plugins/opendata/src
- Timestamp:
- 2018-03-18T15:24:45+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmlReader.java
r33791 r34089 100 100 long when = 0; 101 101 Way way = null; 102 List<Node> wayNodes = null; 102 103 Node node = null; 103 104 Relation relation = null; … … 131 132 if (relation != null) { 132 133 ds.addPrimitive(way = new Way()); 134 wayNodes = new ArrayList<>(); 133 135 relation.addMember(new RelationMember(role, way)); 134 136 } 135 137 } else if (parser.getLocalName().equals(KML_LINE_STRING) || parser.getLocalName().equals(KML_EXT_TRACK)) { 136 138 ds.addPrimitive(way = new Way()); 139 wayNodes = new ArrayList<>(); 137 140 list.add(way); 138 141 } else if (parser.getLocalName().equals(KML_COORDINATES)) { 139 142 String[] tab = parser.getElementText().trim().split("\\s"); 140 143 for (int i = 0; i < tab.length; i++) { 141 node = parseNode(ds, way , node, tab[i].split(","));144 node = parseNode(ds, wayNodes, node, tab[i].split(",")); 142 145 } 143 146 } else if (parser.getLocalName().equals(KML_EXT_COORD)) { 144 node = parseNode(ds, way , node, parser.getElementText().trim().split("\\s"));147 node = parseNode(ds, wayNodes, node, parser.getElementText().trim().split("\\s")); 145 148 if (node != null && when > 0) { 146 149 node.setRawTimestamp((int) when); … … 154 157 } else if (parser.getLocalName().equals(KML_POINT)) { 155 158 list.add(node); 159 } else if (parser.getLocalName().equals(KML_LINE_STRING) 160 || parser.getLocalName().equals(KML_EXT_TRACK) 161 || parser.getLocalName().equals(KML_LINEAR_RING)) { 162 if (way != null && wayNodes != null) 163 way.setNodes(wayNodes); 164 wayNodes = new ArrayList<>(); 156 165 } 157 166 } … … 164 173 } 165 174 166 private Node parseNode(DataSet ds, Way way, Node node, String[] values) {175 private Node parseNode(DataSet ds, List<Node> wayNodes, Node node, String[] values) { 167 176 if (values.length >= 2) { 168 177 LatLon ll = new LatLon(Double.valueOf(values[1]), Double.valueOf(values[0])).getRoundedToOsmPrecision(); … … 175 184 } 176 185 } 177 if (way != null) {178 way .addNode(node);186 if (wayNodes != null) { 187 wayNodes.add(node); 179 188 } 180 189 }
Note:
See TracChangeset
for help on using the changeset viewer.