Ticket #19833: 19833.patch
| File 19833.patch, 1.7 KB (added by , 6 years ago) |
|---|
-
src/org/openstreetmap/josm/io/GeoJSONReader.java
10 10 import java.io.InputStreamReader; 11 11 import java.io.StringReader; 12 12 import java.nio.charset.StandardCharsets; 13 import java.util.ArrayList; 13 14 import java.util.List; 14 15 import java.util.Map; 15 16 import java.util.Objects; … … 294 295 final boolean doAutoclose; 295 296 if (size > 1) { 296 297 if (latlons.get(0).equals(latlons.get(size - 1))) { 297 // Remove last coordinate, but later add first node to the end 298 latlons.remove(size - 1); 299 doAutoclose = true; 298 doAutoclose = false; // already closed 300 299 } else { 301 300 doAutoclose = autoClose; 302 301 } … … 306 305 307 306 final Way way = new Way(); 308 307 getDataSet().addPrimitive(way); 309 way.setNodes(latlons.stream().map(this::createNode).collect(Collectors.toList()));308 final List<Node> rawNodes = latlons.stream().map(this::createNode).collect(Collectors.toList()); 310 309 if (doAutoclose) { 311 way.addNode(way.getNode(0));310 rawNodes.add(rawNodes.get(0)); 312 311 } 312 // see #19833: remove duplicated references to the same node 313 final List<Node> wayNodes = new ArrayList<>(rawNodes.size()); 314 Node last = null; 315 for (Node curr : rawNodes) { 316 if (last != curr) 317 wayNodes.add(curr); 318 last = curr; 319 } 320 way.setNodes(wayNodes); 313 321 314 322 return Optional.of(way); 315 323 }
