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:
Frédéric Junod
2010-08-23 11:50:56 +00:00
parent 19af3bb8e7
commit a6319b2974
2 changed files with 8 additions and 2 deletions

View File

@@ -92,7 +92,8 @@ OpenLayers.LonLat = OpenLayers.Class({
OpenLayers.Console.error(msg);
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));
},
/**

View File

@@ -52,7 +52,7 @@
}
function test_LonLat_add(t) {
t.plan( 8 );
t.plan(10);
origLL = new OpenLayers.LonLat(10,100);
lonlatA = origLL.clone();
@@ -76,6 +76,11 @@
addpx = lonlatA.add(5, null);
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)");
// 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) {