JSDOC / coding standards for Util.Bounds
git-svn-id: http://svn.openlayers.org/trunk/openlayers@95 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+68
-23
@@ -182,7 +182,7 @@ OpenLayers.LatLon.prototype = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return New OpenLayers.LatLon object with the same lat and lon values
|
* @return New OpenLayers.LatLon object with the same lat and lon values
|
||||||
* @type OpenLayers.Size
|
* @type OpenLayers.LatLon
|
||||||
*/
|
*/
|
||||||
copyOf:function() {
|
copyOf:function() {
|
||||||
return new OpenLayers.LatLon(this.lat, this.lon);
|
return new OpenLayers.LatLon(this.lat, this.lon);
|
||||||
@@ -213,7 +213,9 @@ OpenLayers.LatLon.prototype = {
|
|||||||
CLASS_NAME: "OpenLayers.LatLon"
|
CLASS_NAME: "OpenLayers.LatLon"
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/** Alternative constructor that builds a new OpenLayers.LatLon from a
|
||||||
|
* parameter string
|
||||||
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*
|
*
|
||||||
* @param {String} str Comma-separated coordinate string. (ex. "40,5")
|
* @param {String} str Comma-separated coordinate string. (ex. "40,5")
|
||||||
@@ -227,45 +229,88 @@ OpenLayers.LatLon.fromString = function(str) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class This class represents a bounding box.
|
||||||
|
* Data stored as Min and Max Latitudes and Longitudes
|
||||||
|
*/
|
||||||
OpenLayers.Bounds = Class.create();
|
OpenLayers.Bounds = Class.create();
|
||||||
OpenLayers.Bounds.prototype = {
|
OpenLayers.Bounds.prototype = {
|
||||||
initialize: function(minlat,minlon,maxlat,maxlon){
|
|
||||||
this.minlat=minlat;
|
/**
|
||||||
this.minlon=minlon;
|
* @constructor
|
||||||
this.maxlat=maxlat;
|
*
|
||||||
this.maxlon=maxlon;
|
* @param {float} minlat
|
||||||
|
* @param {float} minlon
|
||||||
|
* @param {float} maxlat
|
||||||
|
* @param {float} maxlon
|
||||||
|
*/
|
||||||
|
initialize: function(minlat, minlon, maxlat, maxlon) {
|
||||||
|
this.minlat = minlat;
|
||||||
|
this.minlon = minlon;
|
||||||
|
this.maxlat = maxlat;
|
||||||
|
this.maxlon = maxlon;
|
||||||
this.width = Math.abs(this.maxlon - this.minlon);
|
this.width = Math.abs(this.maxlon - this.minlon);
|
||||||
this.height = Math.abs(this.maxlat - this.minlat);
|
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")
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
toString:function(){
|
toString:function(){
|
||||||
return ("Min lat/lon=" + this.minlat +"/"+ this.minlon
|
return ("Min lat/lon=" + this.minlat +"/"+ this.minlon
|
||||||
+ " Max lat/lon=" + this.maxlat +"/"+ this.maxlon
|
+ " Max lat/lon=" + this.maxlat +"/"+ this.maxlon
|
||||||
+ " width:" + this.width + " height:" + this.height);
|
+ " width:" + this.width + " height:" + this.height);
|
||||||
},
|
},
|
||||||
copyOf:function(){
|
|
||||||
|
/**
|
||||||
|
* @return New OpenLayers.Bounds object with the same min/max lat/lon values
|
||||||
|
* @type OpenLayers.Bounds
|
||||||
|
*/
|
||||||
|
copyOf:function() {
|
||||||
return new OpenLayers.Bounds(this.minlat, this.minlon,
|
return new OpenLayers.Bounds(this.minlat, this.minlon,
|
||||||
this.maxlat, this.maxlon);
|
this.maxlat, this.maxlon);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Simple String representation of OpenLayers.Bounds object.
|
||||||
|
* (ex. "5,42,10,45")
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
toBBOX:function(){
|
toBBOX:function(){
|
||||||
return (this.minlon+","+this.minlat+","+this.maxlon+","+this.maxlat);
|
return (this.minlon+","+this.minlat+","+this.maxlon+","+this.maxlat);
|
||||||
},
|
},
|
||||||
contains:function(pt){
|
|
||||||
return (pt.lon >=this.minlon && pt.lon <=this.maxlon
|
|
||||||
&& pt.lat >=this.minlat && pt.lat <= this.maxlat)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether or not the passed-in coordinate is within the area
|
||||||
|
* delineated by this OpenLayers.Bounds
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
contains:function(ll) {
|
||||||
|
return ((ll.lon >= this.minlon) && (ll.lon <= this.maxlon)
|
||||||
|
&& (ll.lat >= this.minlat) && (ll.lat <= this.maxlat));
|
||||||
|
},
|
||||||
|
|
||||||
|
/** @type String */
|
||||||
|
CLASS_NAME: "OpenLayers.Bounds"
|
||||||
};
|
};
|
||||||
/** Create bounds from coordinates in a string:-180.000000,-90.000000 180.000000,90.000000
|
|
||||||
*/
|
|
||||||
OpenLayers.Bounds.fromString=function(str){
|
|
||||||
var pairs=str.split(" ");
|
|
||||||
var min=pairs[0];
|
|
||||||
var max=pairs[1];
|
|
||||||
|
|
||||||
var latlon = min.split(",");
|
/** Alternative constructor that builds a new OpenLayers.Bounds from a
|
||||||
var latlon2 = max.split(",");
|
* parameter string
|
||||||
return new OpenLayers.Bounds(latlon[1],latlon[0],latlon2[1],latlon2[0]);
|
*
|
||||||
|
* @constructor
|
||||||
|
*
|
||||||
|
* @param {String} str Comma-separated bounds string. (ex. "5,42,10,45")
|
||||||
|
*
|
||||||
|
* @returns New OpenLayers.Bounds object built from the passed-in String.
|
||||||
|
* @type OpenLayers.Bounds
|
||||||
|
*/
|
||||||
|
OpenLayers.Bounds.fromString = function(str) {
|
||||||
|
var bounds = str.split(",");
|
||||||
|
|
||||||
|
return new OpenLayers.Bounds(bounds[1],bounds[0],bounds[3],bounds[2]);
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenLayers.Box = Class.create();
|
OpenLayers.Box = Class.create();
|
||||||
|
|||||||
Reference in New Issue
Block a user