Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iD sometimes creates ways with duplicated nodes (way lenght = 0) #3211

Closed
naoliv opened this issue Jun 30, 2016 · 7 comments
Closed

iD sometimes creates ways with duplicated nodes (way lenght = 0) #3211

naoliv opened this issue Jun 30, 2016 · 7 comments
Labels
bug A bug - let's fix this!

Comments

@naoliv
Copy link

naoliv commented Jun 30, 2016

While fixing some geometries I found that sometimes people editing with iD are creating ways with duplicated nodes (ie, the initial and final nodes are the same)

For example, https://www.openstreetmap.org/api/0.6/way/427739762

<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="CGImap 0.4.3 (6182 thorn-05.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
 <way id="427739762" visible="true" version="1" changeset="40334708" timestamp="2016-06-28T04:06:07Z" user="AjBelnuovo" uid="1799626">
  <nd ref="1840070954"/>
  <nd ref="1840070954"/>
  <tag k="highway" v="residential"/>
  <tag k="name" v="Rua Hermes Salgado Vasconcelos"/>
 </way>
</osm>

Is it possible to avoid this, please?

@pnorman
Copy link
Contributor

pnorman commented Jun 30, 2016

While fixing some geometries I found that sometimes people editing with iD are creating ways with duplicated nodes (ie, the initial and final nodes are the same)

What you describe is not an error by itself or necessarily a duplicated node, circular ways must have the same initial and final nodes.

This particular case is an error because it's a two node ways where both nodes are the same.

@bhousel
Copy link
Member

bhousel commented Jun 30, 2016

^ That does give me a clue though.. Maybe it's a circular way that got simplified down to just its start/end point. I feel like I saw this recently in another recent issue.

@naoliv
Copy link
Author

naoliv commented Jun 30, 2016

Sure, my description was incomplete, sorry.
What I was trying to say is "iD is creating highways with only 2 nodes, and they (initial and final) are the same".

@bhousel bhousel added the bug A bug - let's fix this! label Nov 1, 2016
@slhh
Copy link
Contributor

slhh commented Dec 13, 2016

The needle replacement in way.js will be a source of duplicated nodes if it is called for a way containing replacement as one of the neighbors of needle.

replaceNode: function(needle, replacement) {
    if (this.nodes.indexOf(needle) < 0)
        return this;
    var nodes = this.nodes.slice();
    for (var i = 0; i < nodes.length; i++) {
        if (nodes[i] === needle) {
            nodes[i] = replacement;
        }
    }
    return this.update({nodes: nodes});
},

I'm not sure if this can really happen. I will make a pull request to prevent this if desired.

@bhousel
Copy link
Member

bhousel commented Dec 13, 2016

I'm not sure if this can really happen. I will make a pull request to prevent this if desired.

Can you add a failing test for this to test/spec/osm/way.js?

@slhh
Copy link
Contributor

slhh commented Dec 14, 2016

The functions updateNode and addNode do have the same potential issue. The issue might be prevented from occuring by the calling code, but I think such basic functions should be more robust.

@bhousel I have a set of aditional tests and new implementations ready, but there is one existing test left.
For addNode there is a test for negativ Index counting from the end. Do we really want to have this behavior? It might simply be in the tests because it is the current behavior due to the splice function.

@bhousel
Copy link
Member

bhousel commented Feb 3, 2017

Closing, because I think this was fixed in #3676 and #3750
Please open a new issue if you see it in any version after iD 2.1

@bhousel bhousel closed this as completed Feb 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug - let's fix this!
Projects
None yet
Development

No branches or pull requests

4 participants