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

tags = object.tags -> Pass by reference? #50

Open
bjohas opened this issue Jun 9, 2017 · 2 comments
Open

tags = object.tags -> Pass by reference? #50

bjohas opened this issue Jun 9, 2017 · 2 comments

Comments

@bjohas
Copy link

bjohas commented Jun 9, 2017

We've got a script here:
https://github.com/OSM-Utilities/JOSM-Scripts-HOT/blob/master/examples/nodeBuilding2Way.js

If you search for "pass-by-ref?", you'll see this comment:
// Does not work: If nodes[j].tags is set to null, tags also becomes null. pass-by-ref?

It appears that in "var tags = nodeBuilding[i].tags;", the element is passed by reference. If tags=null, then nodeBuilding[i].tags also becomes null.

Possibly related example here:
https://github.com/OSM-Utilities/JOSM-Scripts-HOT/blob/master/addOLC.js
(search for "pass-by-ref?").

Setting "var tags = object.tags" and later on object.tags=tags doesn't work.

Any thoughts on this?

@bjohas
Copy link
Author

bjohas commented Jun 12, 2017

I received your response by email, but it doesn't show here. It makes sense to me that nodeBuilding[i] remains linked to the object.

However, why does tags in var tags = nodeBuilding[i].tags remain linked to the object?

I saw some stage things where operating on node.lon = function ( node.lat ) ended up overwriting node.lat (see geoutils.js in our repo). Couldn't really make sense of that :(
(c.f. exports.flatten = function(dataset)... else if (latlon.lat)... in https://github.com/OSM-Utilities/JOSM-Scripts-HOT/blob/master/lib/geoutils.js)

@ghost
Copy link

ghost commented Jun 14, 2017

However, why does tags in var tags = nodeBuilding[i].tags remain linked to the object?

I deleted my previous responsive because I realized it was useless, since you were talking about the link quoted above and not about p.tags[something];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant