Make sure all nodes have an actual loc property

- This is to make difference comparisons easier
- The only nodes that didn't have a `loc` were fake nodes we made for testing
- So this commit also fixes the `osmIntersection` code and tests.
This commit is contained in:
Bryan Housel
2019-04-03 16:15:26 -04:00
parent 561ffc402a
commit 167824a530
3 changed files with 327 additions and 326 deletions
+2 -3
View File
@@ -92,8 +92,7 @@ export function osmIntersection(graph, startVertexId, maxDistance) {
node = nodes[j];
if (node === vertex) continue; // same thing
if (vertices.indexOf(node) !== -1) continue; // seen it already
if (node.loc && startNode.loc &&
geoSphericalDistance(node.loc, startNode.loc) > maxDistance) continue; // too far from start
if (geoSphericalDistance(node.loc, startNode.loc) > maxDistance) continue; // too far from start
// a key vertex will have parents that are also roads
var hasParents = false;
@@ -485,7 +484,7 @@ export function osmIntersection(graph, startVertexId, maxDistance) {
// which nodes can we step into?
var n1 = vgraph.entity(entity.first());
var n2 = vgraph.entity(entity.last());
var dist = n1.loc && n2.loc && geoSphericalDistance(n1.loc, n2.loc);
var dist = geoSphericalDistance(n1.loc, n2.loc);
var nextNodes = [];
if (currPath.length > 1) {
+1 -2
View File
@@ -16,9 +16,8 @@ osmEntity.node = osmNode;
osmNode.prototype = Object.create(osmEntity.prototype);
Object.assign(osmNode.prototype, {
type: 'node',
loc: [NaN, NaN],
extent: function() {
return new geoExtent(this.loc);
File diff suppressed because it is too large Load Diff