diff --git a/index.js b/index.js index 0164459..a1f04cc 100644 --- a/index.js +++ b/index.js @@ -641,7 +641,7 @@ 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'); @@ -649,7 +649,9 @@ osmtogeojson = function( data, options, featureCallback ) { }) }; }); - members = _.compact(members); + members = _.compact(members).filter(function(m) { + return m.nodes.length; + }); // construct connected linestrings var linestrings; linestrings = join(members); @@ -762,7 +764,7 @@ 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'); @@ -770,7 +772,9 @@ osmtogeojson = function( data, options, featureCallback ) { }) }; }); - 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";})); @@ -903,7 +907,7 @@ osmtogeojson = function( data, options, featureCallback ) { ways[i].hidden = false; var coords = new Array(); for (j=0;j(+t.version||0)?e:t:F.merge(e,t)}e("osm-polygon-features").forEach(function(e){var t,n;"all"===e.polygon?r[e.key]=!0:(t="whitelist"===e.polygon?"included_values":"excluded_values",n={},e.values.forEach(function(e){n[e]=!0}),r[e.key]={},r[e.key][t]=n)});function P(e){function t(e){return e[e.length-1]}function n(e,t){return void 0!==e&&void 0!==t&&e.id===t.id}for(var r,o,i,a,u,s,l=[];e.length;)for(r=e.pop().nodes.slice(),l.push(r);e.length&&!n(r[0],t(r));){for(o=r[0],i=t(r),a=0;ar!=c>r&&n<(l-u)*(r-s)/(c-s)+u;if(f)o=!o}return o}(t[n],e))return!0;return!1}(t(a[n]),e))return n}t=(t=t.members.filter(function(e){return"way"===e.type})).map(function(t){var e=y[t.ref];if(void 0!==e&&void 0!==e.nodes)return{id:t.ref,role:t.role||"outer",way:e,nodes:e.nodes.filter(function(e){return void 0!==e||(n=!0,N.verbose&&console.warn("Multipolygon",r+"/"+o,"tainted by a way",t.type+"/"+t.ref,"with a missing node"),!1)})};N.verbose&&console.warn("Multipolygon",r+"/"+o,"tainted by a missing or incomplete way",t.type+"/"+t.ref),n=!0});for(var a=P((t=F.compact(t)).filter(function(e){return"outer"===e.role})),u=P(t.filter(function(e){return"inner"===e.role})),s=a.map(function(e){return[e]}),l=0;l=Math.abs(u)?n-s+u:u-s+n,n=s}0<=n+r!=!!t&&e.reverse()}t.exports=function e(t,n){var r,o=t&&t.type;if("FeatureCollection"===o)for(r=0;r(+t.version||0)?e:t:F.merge(e,t)}e("osm-polygon-features").forEach(function(e){var t,n;"all"===e.polygon?r[e.key]=!0:(t="whitelist"===e.polygon?"included_values":"excluded_values",n={},e.values.forEach(function(e){n[e]=!0}),r[e.key]={},r[e.key][t]=n)});function P(e){function t(e){return e[e.length-1]}function n(e,t){return void 0!==e&&void 0!==t&&e.id===t.id}for(var r,o,i,a,u,s,l=[];e.length;)for(r=e.pop().nodes.slice(),l.push(r);e.length&&!n(r[0],t(r));){for(o=r[0],i=t(r),a=0;ar!=c>r&&n<(l-u)*(r-s)/(c-s)+u;if(f)o=!o}return o}(t[n],e))return!0;return!1}(t(a[n]),e))return n}t=(t=t.members.filter(function(e){return"way"===e.type})).map(function(t){var e=y[t.ref];if(void 0!==e&&void 0!==e.nodes)return{id:t.ref,role:t.role||"outer",way:e,nodes:e.nodes.filter(function(e){return void 0!==e&&void 0!==e.lon&&void 0!==e.lat||(n=!0,N.verbose&&console.warn("Multipolygon",r+"/"+o,"tainted by a way",t.type+"/"+t.ref,"with a missing node"),!1)})};N.verbose&&console.warn("Multipolygon",r+"/"+o,"tainted by a missing or incomplete way",t.type+"/"+t.ref),n=!0});for(var a=P((t=F.compact(t).filter(function(e){return e.nodes.length})).filter(function(e){return"outer"===e.role})),u=P(t.filter(function(e){return"inner"===e.role})),s=a.map(function(e){return[e]}),l=0;l=Math.abs(u)?n-s+u:u-s+n,n=s}0<=n+r!=!!t&&e.reverse()}t.exports=function e(t,n){var r,o=t&&t.type;if("FeatureCollection"===o)for(r=0;r