From 6c849baad6ecd432bce9077a0c9f867ca4b98df7 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Sat, 18 May 2013 09:19:44 -0700 Subject: [PATCH] Revert "Cache centroid" Causes misplaced labels, suspect due to rounding artifacts. This reverts commit 5344bdea26d83ba26a095fe43c50352a4d941917. --- js/id/core/entity.js | 8 -------- js/id/svg/labels.js | 3 ++- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/js/id/core/entity.js b/js/id/core/entity.js index 013d53bca..e8181da16 100644 --- a/js/id/core/entity.js +++ b/js/id/core/entity.js @@ -108,14 +108,6 @@ iD.Entity.prototype = { }); }, - // Returns the centroid of the area, in unprojected coordinates. - centroid: function(resolver) { - return resolver.transient(this, 'centroid', function() { - return iD.Entity.areaPath.projection().invert( - iD.Entity.areaPath.centroid(this.asGeoJSON(resolver, true))); - }); - }, - hasInterestingTags: function() { return _.keys(this.tags).some(function(key) { return key != 'attribution' && diff --git a/js/id/svg/labels.js b/js/id/svg/labels.js index 25dd3d3d3..abb0a9251 100644 --- a/js/id/svg/labels.js +++ b/js/id/svg/labels.js @@ -362,7 +362,8 @@ iD.svg.Labels = function(projection, context) { } function getAreaLabel(entity, width, height) { - var centroid = projection(entity.centroid(graph)), + var path = d3.geo.path().projection(projection), + centroid = path.centroid(entity.asGeoJSON(graph, true)), extent = entity.extent(graph), entitywidth = projection(extent[1])[0] - projection(extent[0])[0], rect;