From 00e354511e6878aa34ebda568390013891d52995 Mon Sep 17 00:00:00 2001 From: euzuro Date: Thu, 7 Sep 2006 02:31:37 +0000 Subject: [PATCH] make sure passed in values are floats... if they are strings, parse them. just in case. add test for this git-svn-id: http://svn.openlayers.org/trunk/openlayers@1412 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/BaseTypes.js | 4 ++-- tests/test_LonLat.html | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/BaseTypes.js b/lib/OpenLayers/BaseTypes.js index 5e06a464b5..0ee6c75eb5 100644 --- a/lib/OpenLayers/BaseTypes.js +++ b/lib/OpenLayers/BaseTypes.js @@ -193,8 +193,8 @@ OpenLayers.LonLat.prototype = { * @param {float} lat */ initialize: function(lon, lat) { - this.lon = lon; - this.lat = lat; + this.lon = parseFloat(lon); + this.lat = parseFloat(lat); }, /** diff --git a/tests/test_LonLat.html b/tests/test_LonLat.html index f79bee5abe..29ff3f0de8 100644 --- a/tests/test_LonLat.html +++ b/tests/test_LonLat.html @@ -6,12 +6,19 @@ var lonlat; function test_01_LonLat_constructor (t) { - t.plan( 4 ); + t.plan( 8 ); lonlat = new OpenLayers.LonLat(6, 5); t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" ); t.eq( lonlat.CLASS_NAME, "OpenLayers.LonLat", "lonlat.CLASS_NAME is set correctly"); t.eq( lonlat.lon, 6, "lonlat.lon is set correctly"); t.eq( lonlat.lat, 5, "lonlat.lat is set correctly"); + + lonlat = new OpenLayers.LonLat("6", "5"); + t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" ); + t.eq( lonlat.CLASS_NAME, "OpenLayers.LonLat", "lonlat.CLASS_NAME is set correctly"); + t.eq( lonlat.lon, 6, "lonlat.lon is set correctly"); + t.eq( lonlat.lat, 5, "lonlat.lat is set correctly"); + } function test_02_LonLat_toString(t) {