iD.geo.edgeEqual

This commit is contained in:
John Firebaugh
2013-10-10 11:23:43 -07:00
parent 57411bd9a0
commit b69abc2359
2 changed files with 6 additions and 4 deletions
+1 -4
View File
@@ -8,10 +8,7 @@ iD.actions.AddMidpoint = function(midpoint, node) {
parents.forEach(function(way) {
for (var i = 0; i < way.nodes.length - 1; i++) {
if ((way.nodes[i] === midpoint.edge[0] &&
way.nodes[i + 1] === midpoint.edge[1]) ||
(way.nodes[i] === midpoint.edge[1] &&
way.nodes[i + 1] === midpoint.edge[0])) {
if (iD.geo.edgeEqual([way.nodes[i], way.nodes[i + 1]], midpoint.edge)) {
graph = graph.replace(graph.entity(way.id).addNode(node.id, i + 1));
// Add only one midpoint on doubled-back segments,
+5
View File
@@ -21,6 +21,11 @@ iD.geo.sphericalDistance = function(a, b) {
return 6.3710E6 * Math.sqrt((x * x) + (y * y)) * Math.PI/180;
};
iD.geo.edgeEqual = function(a, b) {
return (a[0] === b[0] && a[1] === b[1]) ||
(a[0] === b[1] && a[1] === b[0]);
};
// Choose the edge with the minimal distance from `point` to its orthogonal
// projection onto that edge, if such a projection exists, or the distance to
// the closest vertex on that edge. Returns an object with the `index` of the