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

Escape throws an error when drawing area with only one point #5941

Closed
quincylvania opened this issue Feb 23, 2019 · 10 comments
Closed

Escape throws an error when drawing area with only one point #5941

quincylvania opened this issue Feb 23, 2019 · 10 comments
Assignees
Labels
bug A bug - let's fix this!
Milestone

Comments

@quincylvania
Copy link
Collaborator

[Error] TypeError: undefined is not an object (evaluating 'entity.id')
	isInvalidGeometry (iD.js:60348)
	checkGeometry (iD.js:60313)
	finish (iD.js:60522)
	call (iD.js:786)
	ret (iD.js:30157)
	testBindings (iD.js:28419)
	bubble (iD.js:28477)
	(anonymous function) (iD.js:1527)

Possibly related: #5911

@quincylvania quincylvania added the bug A bug - let's fix this! label Feb 23, 2019
@maxgrossman maxgrossman self-assigned this Feb 23, 2019
@maxgrossman
Copy link
Collaborator

hmmm... seems to be a scenario where graph.childNodes does not return all nodes in the way...

image

Is there reason why we could not just use the parent's node property? I will keep digging into childNodes function too

@jguthrie100
Copy link
Contributor

jguthrie100 commented Feb 23, 2019

I think those are changes I made some time last year to check if an area self intersects.

It probably just needs an if() statement to avoid the instance when there is only 1 node (i.e. nodes.length-2 resolves to -1 and hence entity gets set to undefined)

Just a bit busy atm, but can have a look at it later

@jguthrie100
Copy link
Contributor

#4860

@jguthrie100
Copy link
Contributor

@maxgrossman what happens if you inspect the node immediately after graph.getChildNodes(parent) is called?

All the nodes should probably be there in that case, but in your screenshot, nodes.splice() has already been called, which will remove a node.

@jguthrie100
Copy link
Contributor

@quincylvania Out of interest, graph.childNodes(way) might actually be slightly dangerous, in that modifying a variable that was set to graph.childNodes(way) will change the underlying childNodes value.

image

Presumeably, the underlying childNodes data should always remain constant, regardless of what the user does with any assigned variables, unless its meant to be like this?

@bhousel
Copy link
Member

bhousel commented Feb 28, 2019

Presumeably, the underlying childNodes data should always remain constant, regardless of what the user does with any assigned variables, unless its meant to be like this?

Yes you should always _clone() the result of childNodes if you intend to modify it.

@jguthrie100
Copy link
Contributor

Is it worth forcing it through in the childNodes method and _clone-ing it before returning?

@bhousel
Copy link
Member

bhousel commented Feb 28, 2019

Is it worth forcing it through in the childNodes method and _clone-ing it before returning?

I don't understand what you're asking.

@jguthrie100
Copy link
Contributor

As in:

if (this._childNodes[entity.id]) return this._childNodes[entity.id];

return this._childNodes[entity.id] could be return _clone(this._childNodes[entity.id])

@bhousel
Copy link
Member

bhousel commented Feb 28, 2019

return this._childNodes[entity.id] could be return _clone(this._childNodes[entity.id])

It's extremely hot code, so I'd rather not introduce an extra _clone when it's usually not needed.

bhousel added a commit that referenced this issue Mar 6, 2019
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