Changed constructor for bounds to take minlon, minlat, maxlon, maxlat as its arguments. changed all related usage and comments

git-svn-id: http://svn.openlayers.org/trunk/openlayers@104 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-05-17 16:50:12 +00:00
parent fe360c91e5
commit ff2e3017f9
6 changed files with 69 additions and 42 deletions

View File

@@ -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;

View File

@@ -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);
},
/**

View File

@@ -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();