From 233a638e3eed6a37a6410d1ac03628d18f6b2903 Mon Sep 17 00:00:00 2001 From: euzuro Date: Thu, 18 May 2006 05:31:17 +0000 Subject: [PATCH] change diff to add in OpenLayers.LonLat. Even though it is not used, it is probably better to have all these Util objects be consistent. See [129] git-svn-id: http://svn.openlayers.org/trunk/openlayers@131 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Util.js | 10 ++++++---- tests/test_LonLat.html | 13 ++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index eeeaf5fcf8..8ee49d7adf 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -175,13 +175,15 @@ OpenLayers.LonLat.prototype = { }, /** - * @param {OpenLayers.LonLat} ll + * @param {float} lon + * @param {float} lat * - * @return OpenLayers.LonLat object with difference between the two coords + * @return A new OpenLayers.LonLat object with the lon and lat passed-in + * added to this's. * @type OpenLayers.Pixel */ - diff:function(ll) { - return new OpenLayers.LonLat(this.lon - ll.lon, this.lat - ll.lat); + add:function(lon, lat) { + return new OpenLayers.LonLat(this.lon + lon, this.lat + lat); }, /** diff --git a/tests/test_LonLat.html b/tests/test_LonLat.html index 396decdbf4..5f8017789c 100644 --- a/tests/test_LonLat.html +++ b/tests/test_LonLat.html @@ -38,18 +38,17 @@ t.eq( lonlat.lon, 5, "changing oldLonLat.lon doesn't change lonlat.lon"); } - function test_04_LonLat_diff(t) { + function test_04_LonLat_add(t) { t.plan( 4 ); lonlatA = new OpenLayers.LonLat(10,100); - lonlatB = new OpenLayers.LonLat(15,150); - diffpx = lonlatA.diff(lonlatB); - t.eq( lonlatA.lon, 10, "lonlatA.lon is not modified by diff operation"); - t.eq( lonlatA.lat, 100, "lonlatA.lat is not modified by diff operation"); + addpx = lonlatA.add(5, 50); + t.eq( lonlatA.lon, 10, "lonlatA.lon is not modified by add operation"); + t.eq( lonlatA.lat, 100, "lonlatA.lat is not modified by add operation"); - t.eq( diffpx.lon, -5, "diffpx.lon is set correctly"); - t.eq( diffpx.lat, -50, "diffpx.lat is set correctly"); + t.eq( addpx.lon, 15, "addpx.lon is set correctly"); + t.eq( addpx.lat, 150, "addpx.lat is set correctly"); } function test_06_LonLat_equals(t) {