Changeset 16311 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-04-15T22:40:32+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/GeoJSONReader.java
r15865 r16311 24 24 import org.openstreetmap.josm.data.coor.EastNorth; 25 25 import org.openstreetmap.josm.data.coor.LatLon; 26 import org.openstreetmap.josm.data.osm.BBox; 26 27 import org.openstreetmap.josm.data.osm.DataSet; 27 28 import org.openstreetmap.josm.data.osm.Node; … … 267 268 268 269 private Node createNode(final LatLon latlon) { 270 final List<Node> existingNodes = getDataSet().searchNodes(new BBox(latlon, latlon)); 271 if (!existingNodes.isEmpty()) { 272 // reuse existing node, avoid multiple nodes on top of each other 273 return existingNodes.get(0); 274 } 269 275 final Node node = new Node(latlon); 270 276 getDataSet().addPrimitive(node); … … 277 283 } 278 284 279 final List<LatLon> latlons = coordinates.stream().map( 280 coordinate -> getLatLon(coordinate.asJsonArray())).collect(Collectors.toList()); 285 final List<LatLon> latlons = coordinates.stream() 286 .map(coordinate -> getLatLon(coordinate.asJsonArray())) 287 .collect(Collectors.toList()); 281 288 282 289 final int size = latlons.size(); … … 295 302 296 303 final Way way = new Way(); 297 way.setNodes(latlons.stream().map(Node::new).collect(Collectors.toList())); 304 getDataSet().addPrimitive(way); 305 way.setNodes(latlons.stream().map(this::createNode).collect(Collectors.toList())); 298 306 if (doAutoclose) { 299 307 way.addNode(way.getNode(0)); 300 308 } 301 302 way.getNodes().stream().distinct().forEach(it -> getDataSet().addPrimitive(it));303 getDataSet().addPrimitive(way);304 309 305 310 return Optional.of(way);
Note:
See TracChangeset
for help on using the changeset viewer.