diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index e3ab4c064d..7b7cd98271 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -119,7 +119,7 @@ OpenLayers.Size.prototype = { * @type String */ toString:function() { - return ("w="+this.w+",h="+this.h); + return ("w=" + this.w + ",h=" + this.h); }, /** @@ -145,32 +145,89 @@ OpenLayers.Size.prototype = { CLASS_NAME: "OpenLayers.Size" }; +/** +* @class This class represents a latitude and longitude pair +*/ OpenLayers.LatLon = Class.create(); OpenLayers.LatLon.prototype = { - initialize: function(lat,lon) { - this.lat=lat; - this.lon=lon; + + /** + * @constructor + * + * @param {float} lat + * @param {float} lon + */ + initialize: function(lat, lon) { + this.lat = lat; + this.lon = lon; }, - toString:function(){ - return ("lat="+this.lat+",lon="+this.lon); + + /** + * @return String representation of OpenLayers.LatLon object. + * (ex. "lat=42,lon=5") + * @type String + */ + toString:function() { + return ("lat=" + this.lat + ",lon=" + this.lon); }, - copyOf:function(){ + + /** + * @return Shortened String representation of OpenLayers.LatLon object. + * (ex. "42,5") + * @type String + */ + toShortString:function() { + return (this.lat + ", " + this.lon); + }, + + /** + * @return New OpenLayers.LatLon object with the same lat and lon values + * @type OpenLayers.Size + */ + copyOf:function() { return new OpenLayers.LatLon(this.lat, this.lon); }, - toShortString:function(){ - return (this.lat+", "+this.lon); + + /** + * @param {OpenLayers.LatLon} ll + * + * @return a LatLon object with the difference between the two coords + * @type OpenLayers.Pixel + */ + diff:function(ll) { + return new OpenLayers.LatLon(this.lat - ll.lat, this.lon - ll.lon); }, - diff:function(pt){ // subtract pt from this - return new OpenLayers.LatLon(this.lat - pt.lat,this.lon - pt.lon); + + /** + * @param {OpenLayers.LatLon} ll + * @returns Boolean value indicating whether the passed-in OpenLayers.LatLon + * object has the same lat and lon components as this + * + * @type bool + */ + equals:function(ll) { + return ((this.lat == ll.lat) && (this.lon == ll.lon)); }, - samePT:function(pt){ - return (this.lat==pt.lat && this.lon==pt.lon); - } + + /** @type String */ + CLASS_NAME: "OpenLayers.LatLon" }; -OpenLayers.LatLon.fromString=function(str){ - var pairs=str.split(","); - return new OpenLayers.LatLon(pairs[1],pairs[0]); + +/** +* @constructor +* +* @param {String} str Comma-separated coordinate string. (ex. "40,5") +* +* @returns New OpenLayers.LatLon object built from the passed-in String. +* @type OpenLayers.LatLon +*/ +OpenLayers.LatLon.fromString = function(str) { + var pair = str.split(","); + return new OpenLayers.LatLon(pair[1], pair[0]); }; + + + OpenLayers.Bounds = Class.create(); OpenLayers.Bounds.prototype = { initialize: function(minlat,minlon,maxlat,maxlon){