From 8b3677967d700b3d75ceb910469d4920d9a44999 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 14 Oct 2014 13:45:23 -0600 Subject: [PATCH 1/2] Use getMetersPerUnit --- src/ol/proj/proj.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index 46be6ddc95..0f0f00b166 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -252,7 +252,8 @@ ol.proj.Projection.prototype.setWorldExtent = function(worldExtent) { * @return {number} Point resolution. */ ol.proj.Projection.prototype.getPointResolution = function(resolution, point) { - if (this.getUnits() == ol.proj.Units.DEGREES) { + var units = this.getUnits(); + if (units == ol.proj.Units.DEGREES) { return resolution; } else { // Estimate point resolution by transforming the center pixel to EPSG:4326, @@ -272,10 +273,9 @@ ol.proj.Projection.prototype.getPointResolution = function(resolution, point) { var height = ol.sphere.NORMAL.haversineDistance( vertices.slice(4, 6), vertices.slice(6, 8)); var pointResolution = (width + height) / 2; - if (this.getUnits() == ol.proj.Units.FEET) { - // The radius of the normal sphere is defined in meters, so we must - // convert back to feet. - pointResolution /= 0.3048; + var metersPerUnit = this.getMetersPerUnit(); + if (goog.isDef(metersPerUnit)) { + pointResolution /= metersPerUnit; } return pointResolution; } From 081f3689b172ee073192676d6e7cead1db6f3578 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 14 Oct 2014 13:58:19 -0600 Subject: [PATCH 2/2] Quarter the number of test cases to avoid timeout --- test/spec/ol/proj/proj.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/ol/proj/proj.test.js b/test/spec/ol/proj/proj.test.js index 07efbcca59..6dcbbebf34 100644 --- a/test/spec/ol/proj/proj.test.js +++ b/test/spec/ol/proj/proj.test.js @@ -175,8 +175,8 @@ describe('ol.proj', function() { var epsg3857Projection = ol.proj.get('EPSG:3857'); var googleProjection = ol.proj.get('GOOGLE'); var point, x, y; - for (x = -20; x <= 20; ++x) { - for (y = -20; y <= 20; ++y) { + for (x = -20; x <= 20; x += 2) { + for (y = -20; y <= 20; y += 2) { point = [1000000 * x, 1000000 * y]; expect(googleProjection.getPointResolution(1, point)).to.roughlyEqual( epsg3857Projection.getPointResolution(1, point), 1e-1);