From 893966dfae6e9f2e376e08eccbf6b4474de56cd7 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 19 Dec 2012 22:23:45 +0100 Subject: [PATCH 1/3] 'm' and 'Meters' in OpenLayers.INCHES_PER_UNIT are not the same OpenLayers.INCHES_PER_UNIT.m should equal OpenLayers.INCHES_PER_UNIT.Meters, just like OpenLayers.INCHES_PER_UNIT.km should equal OpenLayers.Inches_PER_UNIT.Kilometers. This confusion probably comes from mixing International inches with US Survey inches when compiling the unit conversion list (1 meter is 39.37007874 International inches, but 39.37 US Survey inches. It may not be obvious, but 'inches'/'Inch' in OpenLayers means US Survey inch, and 'IInch' means International inch). This change also fixes offsets caused by incorrect resolution calculations in OpenLayers.Format.WMTSCapabilities. --- lib/OpenLayers/Util.js | 4 ++-- tests/Util.html | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index f4948edc37..a8c4a5de42 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -962,8 +962,8 @@ OpenLayers.INCHES_PER_UNIT = { 'inches': 1.0, 'ft': 12.0, 'mi': 63360.0, - 'm': 39.3701, - 'km': 39370.1, + 'm': 39.37, + 'km': 39370, 'dd': 4374754, 'yd': 36 }; diff --git a/tests/Util.html b/tests/Util.html index 4a7507e451..3972d68d84 100644 --- a/tests/Util.html +++ b/tests/Util.html @@ -706,6 +706,12 @@ t.ok(OpenLayers.String.startsWith(id, "chicken"), "OpenLayers.Util.createUniqueID starts id correctly"); } + + function test_units(t) { + t.plan(2); + t.eq(OpenLayers.INCHES_PER_UNIT.m, OpenLayers.INCHES_PER_UNIT.Meter, 'Same inches per m and Meters'); + t.eq(OpenLayers.INCHES_PER_UNIT.km, OpenLayers.INCHES_PER_UNIT.Kilometer, 'Same inches per km and Kilometers'); + } function test_Util_normalizeScale(t) { t.plan(2); @@ -728,7 +734,7 @@ var scale = 1/150000000; var resolution = OpenLayers.Util.getResolutionFromScale(scale, 'm'); - t.eq(resolution.toFixed(6), "52916.638092", "Calculated correct resolution for " + scale); + t.eq(resolution.toFixed(6), "52916.772500", "Calculated correct resolution for " + scale); scale = 150000000; resolution = OpenLayers.Util.getResolutionFromScale(scale); From f5d7f794c9c9d7a3a41b774c910f4f5f0573771e Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 19 Dec 2012 23:13:11 +0100 Subject: [PATCH 2/3] Some tweaks to make tests pass again --- tests/Format/WMSCapabilities/v1_1_1.html | 4 ++-- tests/Layer.html | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Format/WMSCapabilities/v1_1_1.html b/tests/Format/WMSCapabilities/v1_1_1.html index 0d044e480c..e3b0863624 100644 --- a/tests/Format/WMSCapabilities/v1_1_1.html +++ b/tests/Format/WMSCapabilities/v1_1_1.html @@ -340,7 +340,7 @@ // needed for the minScale/maxScale test, see below var dpi = OpenLayers.DOTS_PER_INCH; - OpenLayers.DOTS_PER_INCH = 90.71; + OpenLayers.DOTS_PER_INCH = 90.710230403857; var xml = document.getElementById("ogcsample").firstChild.nodeValue; var doc = new OpenLayers.Format.XML().read(xml); @@ -377,7 +377,7 @@ - corresponds to (RESOLUTION keyword in MAP file has value of 90.71): + corresponds to (RESOLUTION keyword in MAP file has value of 90.710230403857): MAXSCALE 250000 MINSCALE 1000 diff --git a/tests/Layer.html b/tests/Layer.html index 22935f7e3a..85f22aae6a 100644 --- a/tests/Layer.html +++ b/tests/Layer.html @@ -315,7 +315,7 @@ for (var i=0; i Date: Thu, 20 Dec 2012 16:30:58 +0100 Subject: [PATCH 3/3] Fixing tests properly, as suggested by @sbrunner --- tests/Layer.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Layer.html b/tests/Layer.html index 85f22aae6a..1c3db10577 100644 --- a/tests/Layer.html +++ b/tests/Layer.html @@ -315,7 +315,7 @@ for (var i=0; i