jywarren / cartagen

Cartagen is a vector-based, client-side framework for rendering maps in native HTML 5. Maps are styled in GSS, a cascading stylesheet specification for geospatial information – a decision which leverages literacy in CSS to make map styling more accessible.
https://jywarren.github.io/cartagen/
MIT License
255 stars 27 forks source link

merge() being called in collect_ways() but merge() doesn't exist #109

Open jmullaney2003 opened 4 years ago

jmullaney2003 commented 4 years ago

Orig code:

collect_ways: function() {
    this.members.each(function(member) {
        this.nodes = member.nodes.concat(this.nodes)
        if (member.tags.size() > 0) this.tags.merge(member.tags)
    },this)
},

I'm guessing that the map-layer files I'm generating are enough different from the standard files that this bug was uncovered.

Unfortunately I don't understand the code well enough to suggest a real fix. Here's my workaround so that the code doesn't crash - I "merge" the tags:

collect_ways: function() {
    this.members.each(function(member) {
        this.nodes = member.nodes.concat(this.nodes);
        if (member.tags.size() > 0)        // if there are member.tags
        {                                  // then merge them into this.tags
            for (let member_tags_key in member.tags._object)  // for all tags found in member.tags
            {                                                 // see if the member tag needs to be copied to this.tags
                if (isUndefined(this.tags[member_tags_key]))      // if the tag from member.tags is not in this.tags
                {                                                 // then copy it to this.tags
                    this.tags[member_tags_key] = member.tags._object[member_tags_key];
                }
            }
      }
    },this)
},

Maybe I've got this all wrong and there really is a merge() method. If so, please set me right. Or please suggest a real fix for this problem. Thanks.