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

Handle nodes without coordinates #143

Open
wants to merge 3 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,15 +641,17 @@ osmtogeojson = function( data, options, featureCallback ) {
role: m.role,
way: way,
nodes: way.nodes.filter(function(n) {
if (n !== undefined)
if (n !== undefined && n.lon !== undefined && n.lat !== undefined)
return true;
is_tainted = true;
if (options.verbose) console.warn('Route', rel.type+'/'+rel.id, 'tainted by a way', m.type+'/'+m.ref, 'with a missing node');
return false;
})
};
});
members = _.compact(members);
members = _.compact(members).filter(function(m) {
return m.nodes.length;
});
// construct connected linestrings
var linestrings;
linestrings = join(members);
Expand Down Expand Up @@ -762,15 +764,17 @@ osmtogeojson = function( data, options, featureCallback ) {
role: m.role || "outer",
way: way,
nodes: way.nodes.filter(function(n) {
if (n !== undefined)
if (n !== undefined && n.lon !== undefined && n.lat !== undefined)
return true;
is_tainted = true;
if (options.verbose) console.warn('Multipolygon', mp_geometry+'/'+mp_id, 'tainted by a way', m.type+'/'+m.ref, 'with a missing node');
return false;
})
};
});
members = _.compact(members);
members = _.compact(members).filter(function(m) {
return m.nodes.length;
});
// construct outer and inner rings
var outers, inners;
outers = join(members.filter(function(m) {return m.role==="outer";}));
Expand Down Expand Up @@ -903,7 +907,7 @@ osmtogeojson = function( data, options, featureCallback ) {
ways[i].hidden = false;
var coords = new Array();
for (j=0;j<ways[i].nodes.length;j++) {
if (typeof ways[i].nodes[j] == "object")
if (typeof ways[i].nodes[j] == "object" && typeof ways[i].nodes[j].lon != "undefined" && typeof ways[i].nodes[j].lat != "undefined")
coords.push([+ways[i].nodes[j].lon, +ways[i].nodes[j].lat]);
else {
if (options.verbose) console.warn('Way',ways[i].type+'/'+ways[i].id,'is tainted by an invalid node');
Expand Down
Loading