From 7403b9b9e89f152b3e048099bdda6eee28502ae0 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Tue, 16 Apr 2013 19:08:52 -0400 Subject: [PATCH] Fix maxspeed unit detection Centroid calculations were failing for two node ways. It just uses the middle node now. --- js/id/ui/preset/maxspeed.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/id/ui/preset/maxspeed.js b/js/id/ui/preset/maxspeed.js index 39977e051..0decb72d6 100644 --- a/js/id/ui/preset/maxspeed.js +++ b/js/id/ui/preset/maxspeed.js @@ -19,11 +19,11 @@ iD.ui.preset.maxspeed = function(field, context) { .call(combobox); var childNodes = context.graph().childNodes(context.entity(entity.id)), - centroid = d3.geom.polygon(_.pluck(childNodes, 'loc')).centroid(); + loc = childNodes[~~(childNodes.length/2)].loc; imperial = _.any(iD.data.imperial.features, function(f) { return _.any(f.geometry.coordinates, function(d) { - return iD.geo.pointInPolygon(centroid, d[0]); + return iD.geo.pointInPolygon(loc, d[0]); }); });