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
This commit is contained in:
@@ -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
|
* @type OpenLayers.Pixel
|
||||||
*/
|
*/
|
||||||
diff:function(ll) {
|
add:function(lon, lat) {
|
||||||
return new OpenLayers.LonLat(this.lon - ll.lon, this.lat - ll.lat);
|
return new OpenLayers.LonLat(this.lon + lon, this.lat + lat);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -38,18 +38,17 @@
|
|||||||
t.eq( lonlat.lon, 5, "changing oldLonLat.lon doesn't change lonlat.lon");
|
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 );
|
t.plan( 4 );
|
||||||
|
|
||||||
lonlatA = new OpenLayers.LonLat(10,100);
|
lonlatA = new OpenLayers.LonLat(10,100);
|
||||||
lonlatB = new OpenLayers.LonLat(15,150);
|
|
||||||
|
|
||||||
diffpx = lonlatA.diff(lonlatB);
|
addpx = lonlatA.add(5, 50);
|
||||||
t.eq( lonlatA.lon, 10, "lonlatA.lon is not modified by diff operation");
|
t.eq( lonlatA.lon, 10, "lonlatA.lon is not modified by add operation");
|
||||||
t.eq( lonlatA.lat, 100, "lonlatA.lat is not modified by diff 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( addpx.lon, 15, "addpx.lon is set correctly");
|
||||||
t.eq( diffpx.lat, -50, "diffpx.lat is set correctly");
|
t.eq( addpx.lat, 150, "addpx.lat is set correctly");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_06_LonLat_equals(t) {
|
function test_06_LonLat_equals(t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user