diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 35998adf4a..5eae35affe 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -60,8 +60,10 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), { getGridBounds:function() { var topLeftTile = this.grid[0][0]; var bottomRightTile = this.grid[this.grid.length-1][this.grid[0].length-1]; - return new OpenLayers.Bounds(bottomRightTile.bounds.minlat, topLeftTile.bounds.minlon, - topLeftTile.bounds.maxlat, bottomRightTile.bounds.maxlon); + return new OpenLayers.Bounds(topLeftTile.bounds.minlon, + bottomRightTile.bounds.minlat, + bottomRightTile.bounds.maxlon, + topLeftTile.bounds.maxlat); }, _initTiles:function() { var viewSize = this.map.getSize(); @@ -98,17 +100,15 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), { tileoffsetlon = startLon; tileoffsetx = startX; do { - var tileBounds = new OpenLayers.Bounds( - tileoffsetlat, - tileoffsetlon, - tileoffsetlat+tilelat, - tileoffsetlon+tilelon - ); + var tileBounds = new OpenLayers.Bounds(tileoffsetlon, + tileoffsetlat, + tileoffsetlon+tilelon, + tileoffsetlat+tilelat); + var tile = this.addTile(tileBounds, new OpenLayers.Pixel(tileoffsetx, - tileoffsety - ) - ); + tileoffsety) + ); row.append(tile); tileoffsetlon += tilelon; diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 99f5cba666..18042517fb 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -20,7 +20,7 @@ OpenLayers.Map.prototype = { maxZoomLevel: 16, // OpenLayers.Bounds - maxExtent: new OpenLayers.Bounds(-90, -180, 90, 180), + maxExtent: new OpenLayers.Bounds(-180, -90, 180, 90), /* maxScale was determined empirically by finding the resolution of GMaps in degrees per pixel at zoom level 0. */ @@ -187,10 +187,10 @@ OpenLayers.Map.prototype = { var w_deg = size.w * res; var h_deg = size.h * res; return new OpenLayers.Bounds( - this.center.lat - h_deg / 2, this.center.lon - w_deg / 2, - this.center.lat + h_deg / 2, - this.center.lon + w_deg / 2); + this.center.lat - h_deg / 2, + this.center.lon + w_deg / 2, + this.center.lat + h_deg / 2); }, /** diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index cc8d55914a..4f3485227b 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -153,6 +153,12 @@ OpenLayers.Size.prototype = { OpenLayers.LonLat = Class.create(); OpenLayers.LonLat.prototype = { + /** @type float */ + lon: 0.0, + + /** @type float */ + lat: 0.0, + /** * @constructor * @@ -231,6 +237,8 @@ OpenLayers.LonLat.fromString = function(str) { }; + + /** * @class This class represents a bounding box. * Data stored as Min and Max Longitudes and Latitudes @@ -238,41 +246,60 @@ OpenLayers.LonLat.fromString = function(str) { OpenLayers.Bounds = Class.create(); OpenLayers.Bounds.prototype = { + /** @type float */ + minlon: 0.0, + + /** @type float */ + minlat: 0.0, + + /** @type float */ + maxlon: 0.0, + + /** @type float */ + maxlat: 0.0, + + /** @type float */ + width: 0.0, + + /** @type float */ + height: 0.0, + + /** * @constructor * - * @param {float} minlat * @param {float} minlon - * @param {float} maxlat + * @param {float} minlat * @param {float} maxlon + * @param {float} maxlat */ - initialize: function(minlat, minlon, maxlat, maxlon) { - this.minlat = minlat; + initialize: function(minlon, minlat, maxlon, maxlat) { this.minlon = minlon; - this.maxlat = maxlat; + this.minlat = minlat; this.maxlon = maxlon; + this.maxlat = maxlat; this.width = Math.abs(this.maxlon - this.minlon); this.height = Math.abs(this.maxlat - this.minlat); }, /** * @return String representation of OpenLayers.Bounds object. - * (ex. "Min lat/lon=42/5 Max lat/lon=45/10 width:5 height:3") + * (ex. "Min lon/lat=5/42 Max lon/lat=10/45 width:5 height:3") * @type String */ toString:function(){ - return ("Min lat/lon=" + this.minlat +"/"+ this.minlon - + " Max lat/lon=" + this.maxlat +"/"+ this.maxlon + return ("Min lon/lat=" + this.minlon +"/"+ this.minlat + + " Max lon/lat=" + this.maxlon +"/"+ this.maxlat + " width:" + this.width + " height:" + this.height); }, /** - * @return New OpenLayers.Bounds object with the same min/max lat/lon values + * @return New OpenLayers.Bounds object with the same min/max lon/lat values * @type OpenLayers.Bounds */ copyOf:function() { - return new OpenLayers.Bounds(this.minlat, this.minlon, - this.maxlat, this.maxlon); + return new OpenLayers.Bounds(this.minlon, this.minlat, + this.maxlon, this.maxlat); }, /** @@ -281,7 +308,8 @@ OpenLayers.Bounds.prototype = { * @type String */ toBBOX:function(){ - return (this.minlon+","+this.minlat+","+this.maxlon+","+this.maxlat); + return (this.minlon + "," + this.minlat + "," + + this.maxlon + "," + this.maxlat); }, @@ -311,8 +339,7 @@ OpenLayers.Bounds.prototype = { */ OpenLayers.Bounds.fromString = function(str) { var bounds = str.split(","); - - return new OpenLayers.Bounds(bounds[1],bounds[0],bounds[3],bounds[2]); + return new OpenLayers.Bounds(bounds[0],bounds[1],bounds[2],bounds[3]); }; OpenLayers.Box = Class.create(); diff --git a/tests/test_Bounds.html b/tests/test_Bounds.html index 425c459b8f..b7771ff781 100644 --- a/tests/test_Bounds.html +++ b/tests/test_Bounds.html @@ -7,16 +7,16 @@ t.plan( 5 ); bounds = new OpenLayers.Bounds(1,2,3,4); t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" ); - t.eq( bounds.minlon, 2, "bounds.minlon is set correctly" ); - t.eq( bounds.minlat, 1, "bounds.minlat is set correctly" ); - t.eq( bounds.maxlon, 4, "bounds.maxlon is set correctly" ); - t.eq( bounds.maxlat, 3, "bounds.maxlat is set correctly" ); + t.eq( bounds.minlon, 1, "bounds.minlon is set correctly" ); + t.eq( bounds.minlat, 2, "bounds.minlat is set correctly" ); + t.eq( bounds.maxlon, 3, "bounds.maxlon is set correctly" ); + t.eq( bounds.maxlat, 4, "bounds.maxlat is set correctly" ); } function test_02_Bounds_toBBOX(t) { t.plan( 1 ); bounds = new OpenLayers.Bounds(1,2,3,4); - t.eq( bounds.toBBOX(), "2,1,4,3", "toBBOX() returns correct value." ) + t.eq( bounds.toBBOX(), "1,2,3,4", "toBBOX() returns correct value." ) } // --> diff --git a/tests/test_Tile.html b/tests/test_Tile.html index 6623cdf96c..6dbf8ca07f 100644 --- a/tests/test_Tile.html +++ b/tests/test_Tile.html @@ -11,10 +11,10 @@ new OpenLayers.Size(5,6)); t.ok( tile instanceof OpenLayers.Tile, "new OpenLayers.Tile returns Tile object" ); t.ok( tile.bounds instanceof OpenLayers.Bounds, "tile.bounds is a Bounds object" ); - t.eq( tile.bounds.minlon, 2, "tile.bounds.minlon is set correctly"); - t.eq( tile.bounds.minlat, 1, "tile.bounds.minlat is set correctly"); - t.eq( tile.bounds.maxlon, 4, "tile.bounds.maxlon is set correctly"); - t.eq( tile.bounds.maxlat, 3, "tile.bounds.maxlat is set correctly"); + t.eq( tile.bounds.minlon, 1, "tile.bounds.minlon is set correctly"); + t.eq( tile.bounds.minlat, 2, "tile.bounds.minlat is set correctly"); + t.eq( tile.bounds.maxlon, 3, "tile.bounds.maxlon is set correctly"); + t.eq( tile.bounds.maxlat, 4, "tile.bounds.maxlat is set correctly"); t.ok( tile.size instanceof OpenLayers.Size, "tile.size is a Size object" ); t.eq( tile.size.w, 5, "tile.size.w is set correctly"); t.eq( tile.size.h, 6, "tile.size.h is set correctly"); diff --git a/tests/test_Tile_Image.html b/tests/test_Tile_Image.html index 0a0193e2c5..c74cedb303 100644 --- a/tests/test_Tile_Image.html +++ b/tests/test_Tile_Image.html @@ -11,10 +11,10 @@ new OpenLayers.Size(5,6)); t.ok( tile instanceof OpenLayers.Tile.Image, "new OpenLayers.Tile returns Tile object" ); t.ok( tile.bounds instanceof OpenLayers.Bounds, "tile.bounds is a Bounds object" ); - t.eq( tile.bounds.minlon, 2, "tile.bounds.minlon is set correctly"); - t.eq( tile.bounds.minlat, 1, "tile.bounds.minlat is set correctly"); - t.eq( tile.bounds.maxlon, 4, "tile.bounds.maxlon is set correctly"); - t.eq( tile.bounds.maxlat, 3, "tile.bounds.maxlat is set correctly"); + t.eq( tile.bounds.minlon, 1, "tile.bounds.minlon is set correctly"); + t.eq( tile.bounds.minlat, 2, "tile.bounds.minlat is set correctly"); + t.eq( tile.bounds.maxlon, 3, "tile.bounds.maxlon is set correctly"); + t.eq( tile.bounds.maxlat, 4, "tile.bounds.maxlat is set correctly"); t.ok( tile.size instanceof OpenLayers.Size, "tile.size is a Size object" ); t.eq( tile.size.w, 5, "tile.size.w is set correctly"); t.eq( tile.size.h, 6, "tile.size.h is set correctly");