LonLat.add: cast arguments to float. r=crschmidt (closes #2686)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10678 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -92,7 +92,8 @@ OpenLayers.LonLat = OpenLayers.Class({
|
|||||||
OpenLayers.Console.error(msg);
|
OpenLayers.Console.error(msg);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new OpenLayers.LonLat(this.lon + lon, this.lat + lat);
|
return new OpenLayers.LonLat(this.lon + OpenLayers.Util.toFloat(lon),
|
||||||
|
this.lat + OpenLayers.Util.toFloat(lat));
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_LonLat_add(t) {
|
function test_LonLat_add(t) {
|
||||||
t.plan( 8 );
|
t.plan(10);
|
||||||
|
|
||||||
origLL = new OpenLayers.LonLat(10,100);
|
origLL = new OpenLayers.LonLat(10,100);
|
||||||
lonlatA = origLL.clone();
|
lonlatA = origLL.clone();
|
||||||
@@ -76,6 +76,11 @@
|
|||||||
addpx = lonlatA.add(5, null);
|
addpx = lonlatA.add(5, null);
|
||||||
t.ok( lonlatA.equals(origLL), "lonlatA is not modified by erroneous add operation (null lat)");
|
t.ok( lonlatA.equals(origLL), "lonlatA is not modified by erroneous add operation (null lat)");
|
||||||
t.ok(addpx == null, "returns null on erroneous add operation (null lat)");
|
t.ok(addpx == null, "returns null on erroneous add operation (null lat)");
|
||||||
|
|
||||||
|
// string values
|
||||||
|
addpx = origLL.clone().add("5", "50");
|
||||||
|
t.eq(addpx.lon, 15, "addpx.lon is set correctly");
|
||||||
|
t.eq(addpx.lat, 150, "addpx.lat is set correctly");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_LonLat_equals(t) {
|
function test_LonLat_equals(t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user