fix for #793 - split basetypes into separate files. Makes documentation better and generally just makes sense. thanks tim for patch review and cfg file help
git-svn-id: http://svn.openlayers.org/trunk/openlayers@3601 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
OpenLayers/SingleFile.js
|
||||
OpenLayers.js
|
||||
OpenLayers/BaseTypes.js
|
||||
OpenLayers/BaseTypes/Class.js
|
||||
OpenLayers/Util.js
|
||||
Rico/Corner.js
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
OpenLayers/SingleFile.js
|
||||
OpenLayers.js
|
||||
OpenLayers/BaseTypes.js
|
||||
OpenLayers/BaseTypes/Class.js
|
||||
OpenLayers/Util.js
|
||||
Rico/Corner.js
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
OpenLayers/SingleFile.js
|
||||
OpenLayers.js
|
||||
OpenLayers/BaseTypes.js
|
||||
OpenLayers/BaseTypes/Class.js
|
||||
OpenLayers/Util.js
|
||||
|
||||
[last]
|
||||
|
||||
@@ -66,6 +66,12 @@
|
||||
if(!singleFile) {
|
||||
var jsfiles = new Array(
|
||||
"OpenLayers/BaseTypes.js",
|
||||
"OpenLayers/BaseTypes/Class.js",
|
||||
"OpenLayers/BaseTypes/Bounds.js",
|
||||
"OpenLayers/BaseTypes/Element.js",
|
||||
"OpenLayers/BaseTypes/LonLat.js",
|
||||
"OpenLayers/BaseTypes/Pixel.js",
|
||||
"OpenLayers/BaseTypes/Size.js",
|
||||
"OpenLayers/Util.js",
|
||||
"OpenLayers/Console.js",
|
||||
"Rico/Corner.js",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
531
lib/OpenLayers/BaseTypes/Bounds.js
Normal file
531
lib/OpenLayers/BaseTypes/Bounds.js
Normal file
@@ -0,0 +1,531 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Bounds
|
||||
* Instances of this class represent bounding boxes. Data stored as left,
|
||||
* bottom, right, top floats
|
||||
*/
|
||||
OpenLayers.Bounds = OpenLayers.Class.create();
|
||||
OpenLayers.Bounds.prototype = {
|
||||
|
||||
/**
|
||||
* Property: left
|
||||
* {Number}
|
||||
*/
|
||||
left: 0.0,
|
||||
|
||||
/**
|
||||
* Property: bottom
|
||||
* {Number}
|
||||
*/
|
||||
bottom: 0.0,
|
||||
|
||||
/**
|
||||
* Property: right
|
||||
* {Number}
|
||||
*/
|
||||
right: 0.0,
|
||||
|
||||
/**
|
||||
* Property: top
|
||||
* {Number}
|
||||
*/
|
||||
top: 0.0,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Bounds
|
||||
* Construct a new bounds object.
|
||||
*
|
||||
* Parameters:
|
||||
* left - {Number} The left bounds of the box. Note that for width
|
||||
* calculations, this is assumed to be less than the right value.
|
||||
* bottom - {Number} The bottom bounds of the box. Note that for height
|
||||
* calculations, this is assumed to be more than the top value.
|
||||
* right - {Number} The right bounds.
|
||||
* top - {Number} The top bounds.
|
||||
*/
|
||||
initialize: function(left, bottom, right, top) {
|
||||
this.left = parseFloat(left);
|
||||
this.bottom = parseFloat(bottom);
|
||||
this.right = parseFloat(right);
|
||||
this.top = parseFloat(top);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: clone
|
||||
* Create a cloned instance of this bounds.
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.Bounds>} A fresh copy of the bounds
|
||||
*/
|
||||
clone:function() {
|
||||
return new OpenLayers.Bounds(this.left, this.bottom,
|
||||
this.right, this.top);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: equals
|
||||
* Test a two bounds for equivalence
|
||||
*
|
||||
* Parameters:
|
||||
* bounds - {<OpenLayers.Bounds>}
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} The passed-in OpenLayers.Bounds object has the same left,
|
||||
* right, top, bottom components as this. Note that if bounds
|
||||
* passed in is null, returns false.
|
||||
*/
|
||||
equals:function(bounds) {
|
||||
var equals = false;
|
||||
if (bounds != null) {
|
||||
equals = ((this.left == bounds.left) &&
|
||||
(this.right == bounds.right) &&
|
||||
(this.top == bounds.top) &&
|
||||
(this.bottom == bounds.bottom));
|
||||
}
|
||||
return equals;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: toString
|
||||
*
|
||||
* Return:
|
||||
* {String} String representation of OpenLayers.Bounds object.
|
||||
* (ex.<i>"left-bottom=(5,42) right-top=(10,45)"</i>)
|
||||
*/
|
||||
toString:function() {
|
||||
return ( "left-bottom=(" + this.left + "," + this.bottom + ")"
|
||||
+ " right-top=(" + this.right + "," + this.top + ")" );
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: toBBOX
|
||||
*
|
||||
* Parameters:
|
||||
* decimal - {Integer} How many significant digits in the bbox coords?
|
||||
* Default is 6
|
||||
*
|
||||
* Return:
|
||||
* {String} Simple String representation of OpenLayers.Bounds object.
|
||||
* (ex. <i>"5,42,10,45"</i>)
|
||||
*/
|
||||
toBBOX:function(decimal) {
|
||||
if (decimal== null) {
|
||||
decimal = 6;
|
||||
}
|
||||
var mult = Math.pow(10, decimal);
|
||||
var bbox = Math.round(this.left * mult) / mult + "," +
|
||||
Math.round(this.bottom * mult) / mult + "," +
|
||||
Math.round(this.right * mult) / mult + "," +
|
||||
Math.round(this.top * mult) / mult;
|
||||
|
||||
return bbox;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: getWidth
|
||||
*
|
||||
* Return:
|
||||
* {Float} The width of the bounds
|
||||
*/
|
||||
getWidth:function() {
|
||||
return (this.right - this.left);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: getHeight
|
||||
*
|
||||
* Return:
|
||||
* {Float} The height of the bounds
|
||||
*/
|
||||
getHeight:function() {
|
||||
return (this.top - this.bottom);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: getSize
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.Size>} An <OpenLayers.Size> which represents the size of the box
|
||||
*/
|
||||
getSize:function() {
|
||||
return new OpenLayers.Size(this.getWidth(), this.getHeight());
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: getCenterPixel
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.Pixel>} An <OpenLayers.Pixel> which represents the center
|
||||
* of the bounds
|
||||
*/
|
||||
getCenterPixel:function() {
|
||||
return new OpenLayers.Pixel( (this.left + this.right) / 2,
|
||||
(this.bottom + this.top) / 2);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: getCenterLonLat
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.LonLat>} An <OpenLayers.LonLat> which represents the center
|
||||
* of the bounds
|
||||
*/
|
||||
getCenterLonLat:function() {
|
||||
return new OpenLayers.LonLat( (this.left + this.right) / 2,
|
||||
(this.bottom + this.top) / 2);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: add
|
||||
*
|
||||
* Parameters:
|
||||
* x - {Float}
|
||||
* y - {Float}
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.Bounds>} A new <OpenLayers.Bounds> whose coordinates are
|
||||
* the same as this, but shifted by the passed-in
|
||||
* x and y values
|
||||
*/
|
||||
add:function(x, y) {
|
||||
return new OpenLayers.Bounds(this.left + x, this.bottom + y,
|
||||
this.right + x, this.top + y);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: extend
|
||||
* Extend the bounds to include the point, lonlat, or bounds specified.
|
||||
* Note: This function assumes that left<right and bottom<top.
|
||||
*
|
||||
*
|
||||
* Parameters:
|
||||
* object - {Object} Can be LonLat, Point, or Bounds
|
||||
*/
|
||||
extend:function(object) {
|
||||
var bounds = null;
|
||||
if (object) {
|
||||
switch(object.CLASS_NAME) {
|
||||
case "OpenLayers.LonLat":
|
||||
bounds = new OpenLayers.Bounds(object.lon, object.lat,
|
||||
object.lon, object.lat);
|
||||
break;
|
||||
case "OpenLayers.Geometry.Point":
|
||||
bounds = new OpenLayers.Bounds(object.x, object.y,
|
||||
object.x, object.y);
|
||||
break;
|
||||
|
||||
case "OpenLayers.Bounds":
|
||||
bounds = object;
|
||||
break;
|
||||
}
|
||||
|
||||
if (bounds) {
|
||||
this.left = (bounds.left < this.left) ? bounds.left
|
||||
: this.left;
|
||||
this.bottom = (bounds.bottom < this.bottom) ? bounds.bottom
|
||||
: this.bottom;
|
||||
this.right = (bounds.right > this.right) ? bounds.right
|
||||
: this.right;
|
||||
this.top = (bounds.top > this.top) ? bounds.top
|
||||
: this.top;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: containsLonLat
|
||||
*
|
||||
* Parameters:
|
||||
* ll - {<OpenLayers.LonLat>}
|
||||
* inclusive - {Boolean} Whether or not to include the border.
|
||||
* Default is true.
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} Whether or not the passed-in lonlat is within this bounds.
|
||||
*/
|
||||
containsLonLat:function(ll, inclusive) {
|
||||
return this.contains(ll.lon, ll.lat, inclusive);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: containsPixel
|
||||
*
|
||||
* Parameters:
|
||||
* px - {<OpenLayers.Pixel>}
|
||||
* inclusive - {Boolean} Whether or not to include the border.
|
||||
* Default is true.
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} Whether or not the passed-in pixel is within this bounds.
|
||||
*/
|
||||
containsPixel:function(px, inclusive) {
|
||||
return this.contains(px.x, px.y, inclusive);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: contains
|
||||
*
|
||||
* Parameters:
|
||||
* x - {Float}
|
||||
* y - {Float}
|
||||
* inclusive - {Boolean} Whether or not to include the border.
|
||||
* Default is true.
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} Whether or not the passed-in coordinates are within this
|
||||
* bounds.
|
||||
*/
|
||||
contains:function(x, y, inclusive) {
|
||||
|
||||
//set default
|
||||
if (inclusive == null) {
|
||||
inclusive = true;
|
||||
}
|
||||
|
||||
var contains = false;
|
||||
if (inclusive) {
|
||||
contains = ((x >= this.left) && (x <= this.right) &&
|
||||
(y >= this.bottom) && (y <= this.top));
|
||||
} else {
|
||||
contains = ((x > this.left) && (x < this.right) &&
|
||||
(y > this.bottom) && (y < this.top));
|
||||
}
|
||||
return contains;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: intersectsBounds
|
||||
*
|
||||
* Parameters:
|
||||
* bounds - {<OpenLayers.Bounds>}
|
||||
* inclusive - {<Boolean>} Whether or not to include the border.
|
||||
* Default is true.
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} Whether or not the passed-in OpenLayers.Bounds object
|
||||
* intersects this bounds. Simple math just check if either
|
||||
* contains the other, allowing for partial.
|
||||
*/
|
||||
intersectsBounds:function(bounds, inclusive) {
|
||||
|
||||
if (inclusive == null) {
|
||||
inclusive = true;
|
||||
}
|
||||
var inBottom = (bounds.bottom == this.bottom && bounds.top == this.top) ?
|
||||
true : (((bounds.bottom > this.bottom) && (bounds.bottom < this.top)) ||
|
||||
((this.bottom > bounds.bottom) && (this.bottom < bounds.top)));
|
||||
var inTop = (bounds.bottom == this.bottom && bounds.top == this.top) ?
|
||||
true : (((bounds.top > this.bottom) && (bounds.top < this.top)) ||
|
||||
((this.top > bounds.bottom) && (this.top < bounds.top)));
|
||||
var inRight = (bounds.right == this.right && bounds.left == this.left) ?
|
||||
true : (((bounds.right > this.left) && (bounds.right < this.right)) ||
|
||||
((this.right > bounds.left) && (this.right < bounds.right)));
|
||||
var inLeft = (bounds.right == this.right && bounds.left == this.left) ?
|
||||
true : (((bounds.left > this.left) && (bounds.left < this.right)) ||
|
||||
((this.left > bounds.left) && (this.left < bounds.right)));
|
||||
|
||||
return (this.containsBounds(bounds, true, inclusive) ||
|
||||
bounds.containsBounds(this, true, inclusive) ||
|
||||
((inTop || inBottom ) && (inLeft || inRight )));
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: containsBounds
|
||||
*
|
||||
* bounds - {<OpenLayers.Bounds>}
|
||||
* partial - {<Boolean>} If true, only part of passed-in
|
||||
* <OpenLayers.Bounds> needs be within this bounds.
|
||||
* If false, the entire passed-in bounds must be
|
||||
* within. Default is false
|
||||
* inclusive - {<Boolean>} Whether or not to include the border.
|
||||
* Default is true.
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} Whether or not the passed-in OpenLayers.Bounds object is
|
||||
* contained within this bounds.
|
||||
*/
|
||||
containsBounds:function(bounds, partial, inclusive) {
|
||||
|
||||
//set defaults
|
||||
if (partial == null) {
|
||||
partial = false;
|
||||
}
|
||||
if (inclusive == null) {
|
||||
inclusive = true;
|
||||
}
|
||||
|
||||
var inLeft;
|
||||
var inTop;
|
||||
var inRight;
|
||||
var inBottom;
|
||||
|
||||
if (inclusive) {
|
||||
inLeft = (bounds.left >= this.left) && (bounds.left <= this.right);
|
||||
inTop = (bounds.top >= this.bottom) && (bounds.top <= this.top);
|
||||
inRight= (bounds.right >= this.left) && (bounds.right <= this.right);
|
||||
inBottom = (bounds.bottom >= this.bottom) && (bounds.bottom <= this.top);
|
||||
} else {
|
||||
inLeft = (bounds.left > this.left) && (bounds.left < this.right);
|
||||
inTop = (bounds.top > this.bottom) && (bounds.top < this.top);
|
||||
inRight= (bounds.right > this.left) && (bounds.right < this.right);
|
||||
inBottom = (bounds.bottom > this.bottom) && (bounds.bottom < this.top);
|
||||
}
|
||||
|
||||
return (partial) ? (inTop || inBottom ) && (inLeft || inRight )
|
||||
: (inTop && inLeft && inBottom && inRight);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: determineQuadrant
|
||||
*
|
||||
* Parameters:
|
||||
* lonlat - {<OpenLayers.LonLat>}
|
||||
*
|
||||
* Return:
|
||||
* {String} The quadrant ("br" "tr" "tl" "bl") of the bounds in which
|
||||
* the coordinate lies.
|
||||
*/
|
||||
determineQuadrant: function(lonlat) {
|
||||
|
||||
var quadrant = "";
|
||||
var center = this.getCenterLonLat();
|
||||
|
||||
quadrant += (lonlat.lat < center.lat) ? "b" : "t";
|
||||
quadrant += (lonlat.lon < center.lon) ? "l" : "r";
|
||||
|
||||
return quadrant;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: wrapDateLine
|
||||
*
|
||||
* Parameters:
|
||||
* maxExtent - {<OpenLayers.Bounds>}
|
||||
* options - {Object} Some possible options are:
|
||||
* leftTolerance - {float} Allow for a margin of error
|
||||
* with the 'left' value of this
|
||||
* bound.
|
||||
* Default is 0.
|
||||
* rightTolerance - {float} Allow for a margin of error
|
||||
* with the 'right' value of
|
||||
* this bound.
|
||||
* Default is 0.
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.Bounds>} A copy of this bounds, but wrapped around the
|
||||
* "dateline" (as specified by the borders of
|
||||
* maxExtent). Note that this function only returns
|
||||
* a different bounds value if this bounds is
|
||||
* *entirely* outside of the maxExtent. If this
|
||||
* bounds straddles the dateline (is part in/part
|
||||
* out of maxExtent), the returned bounds will be
|
||||
* merely a copy of this one.
|
||||
*/
|
||||
wrapDateLine: function(maxExtent, options) {
|
||||
options = options || new Object();
|
||||
|
||||
var leftTolerance = options.leftTolerance || 0;
|
||||
var rightTolerance = options.rightTolerance || 0;
|
||||
|
||||
var newBounds = this.clone();
|
||||
|
||||
if (maxExtent) {
|
||||
|
||||
//shift right?
|
||||
while ( newBounds.left < maxExtent.left &&
|
||||
(newBounds.right - rightTolerance) <= maxExtent.left ) {
|
||||
newBounds = newBounds.add(maxExtent.getWidth(), 0);
|
||||
}
|
||||
|
||||
//shift left?
|
||||
while ( (newBounds.left + leftTolerance) >= maxExtent.right &&
|
||||
newBounds.right > maxExtent.right ) {
|
||||
newBounds = newBounds.add(-maxExtent.getWidth(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
return newBounds;
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Bounds"
|
||||
};
|
||||
|
||||
/**
|
||||
* APIFunction: fromString
|
||||
* Alternative constructor that builds a new OpenLayers.Bounds from a
|
||||
* parameter string
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String}Comma-separated bounds string. (ex. <i>"5,42,10,45"</i>)
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.Bounds>} New <OpenLayers.Bounds> object built from the
|
||||
* passed-in String.
|
||||
*/
|
||||
OpenLayers.Bounds.fromString = function(str) {
|
||||
var bounds = str.split(",");
|
||||
return OpenLayers.Bounds.fromArray(bounds);
|
||||
};
|
||||
|
||||
/**
|
||||
* APIFunction: fromArray
|
||||
* Alternative constructor that builds a new OpenLayers.Bounds
|
||||
* from an array
|
||||
*
|
||||
* Parameters:
|
||||
* bbox - {Array} Array of bounds values (ex. <i>[5,42,10,45]</i>)
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.Bounds>} New <OpenLayers.Bounds> object built from the
|
||||
* passed-in Array.
|
||||
*/
|
||||
OpenLayers.Bounds.fromArray = function(bbox) {
|
||||
return new OpenLayers.Bounds(parseFloat(bbox[0]),
|
||||
parseFloat(bbox[1]),
|
||||
parseFloat(bbox[2]),
|
||||
parseFloat(bbox[3]));
|
||||
};
|
||||
|
||||
/**
|
||||
* APIFunction: fromSize
|
||||
* Alternative constructor that builds a new OpenLayers.Bounds
|
||||
* from a size
|
||||
*
|
||||
* Parameters:
|
||||
* size - {<OpenLayers.Size>}
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.Bounds>} New <OpenLayers.Bounds> object built from the
|
||||
* passed-in size.
|
||||
*/
|
||||
OpenLayers.Bounds.fromSize = function(size) {
|
||||
return new OpenLayers.Bounds(0,
|
||||
size.h,
|
||||
size.w,
|
||||
0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function: oppositeQuadrant
|
||||
* Get the opposite quadrant for a given quadrant string.
|
||||
*
|
||||
* Parameters:
|
||||
* quadrant - {String} two character quadrant shortstring
|
||||
*
|
||||
* Return:
|
||||
* {String} The opposing quadrant ("br" "tr" "tl" "bl"). For Example, if
|
||||
* you pass in "bl" it returns "tr", if you pass in "br" it
|
||||
* returns "tl", etc.
|
||||
*/
|
||||
OpenLayers.Bounds.oppositeQuadrant = function(quadrant) {
|
||||
var opp = "";
|
||||
|
||||
opp += (quadrant.charAt(0) == 't') ? 'b' : 't';
|
||||
opp += (quadrant.charAt(1) == 'l') ? 'r' : 'l';
|
||||
|
||||
return opp;
|
||||
};
|
||||
67
lib/OpenLayers/BaseTypes/Class.js
Normal file
67
lib/OpenLayers/BaseTypes/Class.js
Normal file
@@ -0,0 +1,67 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers.Class
|
||||
* Contains functions to create OpenLayers style classes.
|
||||
*/
|
||||
OpenLayers.Class = {
|
||||
isPrototype: function () {}, // magic anonymous value
|
||||
|
||||
/**
|
||||
* APIFunction: create
|
||||
* Create an OpenLayers style class
|
||||
*
|
||||
* Return:
|
||||
* An OpenLayers class
|
||||
*/
|
||||
create: function() {
|
||||
return function() {
|
||||
if (arguments && arguments[0] != OpenLayers.Class.isPrototype)
|
||||
this.initialize.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIFunction: inherit
|
||||
* Inherit from one or more OpenLayers style classes
|
||||
*
|
||||
* Parameters:
|
||||
* class - One or more classes can be provided as arguments
|
||||
*
|
||||
* Return:
|
||||
* An object prototype
|
||||
*/
|
||||
inherit: function () {
|
||||
var superClass = arguments[0];
|
||||
var proto = new superClass(OpenLayers.Class.isPrototype);
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
if (typeof arguments[i] == "function") {
|
||||
var mixin = arguments[i];
|
||||
arguments[i] = new mixin(OpenLayers.Class.isPrototype);
|
||||
}
|
||||
OpenLayers.Util.extend(proto, arguments[i]);
|
||||
|
||||
// This is a hack for IE see
|
||||
// http://trac.openlayers.org/attachment/ticket/552
|
||||
//
|
||||
// The problem is that ie doesnt recognize toString as a property
|
||||
// so the util.extend() doesnt copy it over. we do it manually.
|
||||
//
|
||||
// to be revisited in 3.0
|
||||
//
|
||||
if((arguments[i].hasOwnProperty && arguments[i].hasOwnProperty('toString')) ||
|
||||
(!arguments[i].hasOwnProperty && arguments[i].toString)) {
|
||||
proto.toString = arguments[i].toString;
|
||||
}
|
||||
}
|
||||
return proto;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
OpenLayers.Class.inherit( OpenLayers.Layer.Grid, OpenLayers.Layer.HTTPRequest, {
|
||||
some stuff
|
||||
});
|
||||
*/
|
||||
160
lib/OpenLayers/BaseTypes/Element.js
Normal file
160
lib/OpenLayers/BaseTypes/Element.js
Normal file
@@ -0,0 +1,160 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers.Element
|
||||
*/
|
||||
OpenLayers.Element = {
|
||||
|
||||
/**
|
||||
* APIFunction: visible
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement}
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} Is the element visible?
|
||||
*/
|
||||
visible: function(element) {
|
||||
return OpenLayers.Util.getElement(element).style.display != 'none';
|
||||
},
|
||||
|
||||
/**
|
||||
* APIFunction: toggle
|
||||
* Toggle the visibility of element(s) passed in
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement} Actually user can pass any number of elements
|
||||
*/
|
||||
toggle: function() {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var element = OpenLayers.Util.getElement(arguments[i]);
|
||||
var display = OpenLayers.Element.visible(element) ? 'hide'
|
||||
: 'show';
|
||||
OpenLayers.Element[display](element);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* APIFunction: hide
|
||||
* Hide element(s) passed in
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement} Actually user can pass any number of elements
|
||||
*/
|
||||
hide: function() {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var element = OpenLayers.Util.getElement(arguments[i]);
|
||||
element.style.display = 'none';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIFunction: show
|
||||
* Show element(s) passed in
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement} Actually user can pass any number of elements
|
||||
*/
|
||||
show: function() {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var element = OpenLayers.Util.getElement(arguments[i]);
|
||||
element.style.display = '';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIFunction: remove
|
||||
* Remove the specified element from the DOM.
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement}
|
||||
*/
|
||||
remove: function(element) {
|
||||
element = OpenLayers.Util.getElement(element);
|
||||
element.parentNode.removeChild(element);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIFunction: getHeight
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement}
|
||||
*
|
||||
* Return:
|
||||
* {Integer} The offset height of the element passed in
|
||||
*/
|
||||
getHeight: function(element) {
|
||||
element = OpenLayers.Util.getElement(element);
|
||||
return element.offsetHeight;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIFunction: getDimensions
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement}
|
||||
*
|
||||
* Return:
|
||||
* {Object} Object with 'width' and 'height' properties which are the
|
||||
* dimensions of the element passed in.
|
||||
*/
|
||||
getDimensions: function(element) {
|
||||
element = OpenLayers.Util.getElement(element);
|
||||
if (OpenLayers.Element.getStyle(element, 'display') != 'none') {
|
||||
return {width: element.offsetWidth, height: element.offsetHeight};
|
||||
}
|
||||
|
||||
// All *Width and *Height properties give 0 on elements with display none,
|
||||
// so enable the element temporarily
|
||||
var els = element.style;
|
||||
var originalVisibility = els.visibility;
|
||||
var originalPosition = els.position;
|
||||
els.visibility = 'hidden';
|
||||
els.position = 'absolute';
|
||||
els.display = '';
|
||||
var originalWidth = element.clientWidth;
|
||||
var originalHeight = element.clientHeight;
|
||||
els.display = 'none';
|
||||
els.position = originalPosition;
|
||||
els.visibility = originalVisibility;
|
||||
return {width: originalWidth, height: originalHeight};
|
||||
},
|
||||
|
||||
/**
|
||||
* APIFunction: getStyle
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement}
|
||||
* style - {?}
|
||||
*
|
||||
* Return:
|
||||
* {?}
|
||||
*/
|
||||
getStyle: function(element, style) {
|
||||
element = OpenLayers.Util.getElement(element);
|
||||
var value = element.style[style.camelize()];
|
||||
if (!value) {
|
||||
if (document.defaultView &&
|
||||
document.defaultView.getComputedStyle) {
|
||||
|
||||
var css = document.defaultView.getComputedStyle(element, null);
|
||||
value = css ? css.getPropertyValue(style) : null;
|
||||
} else if (element.currentStyle) {
|
||||
value = element.currentStyle[style.camelize()];
|
||||
}
|
||||
}
|
||||
|
||||
var positions = ['left', 'top', 'right', 'bottom'];
|
||||
if (window.opera &&
|
||||
(OpenLayers.Util.indexOf(positions,style) != -1) &&
|
||||
(OpenLayers.Element.getStyle(element, 'position') == 'static')) {
|
||||
value = 'auto';
|
||||
}
|
||||
|
||||
return value == 'auto' ? null : value;
|
||||
}
|
||||
|
||||
};
|
||||
158
lib/OpenLayers/BaseTypes/LonLat.js
Normal file
158
lib/OpenLayers/BaseTypes/LonLat.js
Normal file
@@ -0,0 +1,158 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.LonLat
|
||||
* This class represents a longitude and latitude pair
|
||||
*/
|
||||
OpenLayers.LonLat = OpenLayers.Class.create();
|
||||
OpenLayers.LonLat.prototype = {
|
||||
|
||||
/**
|
||||
* APIProperty: lon
|
||||
* {Float}
|
||||
*/
|
||||
lon: 0.0,
|
||||
|
||||
/**
|
||||
* APIProperty: lat
|
||||
* {Float}
|
||||
*/
|
||||
lat: 0.0,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.LonLat
|
||||
* Create a new OpenLayers.LonLat instance
|
||||
*
|
||||
* Parameters:
|
||||
* lon - {Number} The lon coordinate
|
||||
* lat - {Number} The lat coordinate
|
||||
*/
|
||||
initialize: function(lon, lat) {
|
||||
this.lon = parseFloat(lon);
|
||||
this.lat = parseFloat(lat);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: toString
|
||||
* Return a readable string version of the lonlat
|
||||
*
|
||||
* Return:
|
||||
* {String} String representation of OpenLayers.LonLat object.
|
||||
* (ex. <i>"lon=5,lat=42"</i>)
|
||||
*/
|
||||
toString:function() {
|
||||
return ("lon=" + this.lon + ",lat=" + this.lat);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: toShortString
|
||||
*
|
||||
* Return:
|
||||
* {String} Shortened String representation of OpenLayers.LonLat object.
|
||||
* (ex. <i>"5, 42"</i>)
|
||||
*/
|
||||
toShortString:function() {
|
||||
return (this.lon + ", " + this.lat);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: clone
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.LonLat>} New OpenLayers.LonLat object with the same lon
|
||||
* and lat values
|
||||
*/
|
||||
clone:function() {
|
||||
return new OpenLayers.LonLat(this.lon, this.lat);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: add
|
||||
*
|
||||
* Parameters:
|
||||
* lon - {Float}
|
||||
* lat - {Float}
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.LonLat>} A new OpenLayers.LonLat object with the lon and
|
||||
* lat passed-in added to this's.
|
||||
*/
|
||||
add:function(lon, lat) {
|
||||
return new OpenLayers.LonLat(this.lon + lon, this.lat + lat);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: equals
|
||||
*
|
||||
* Parameters:
|
||||
* ll - {<OpenLayers.LonLat>}
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} Boolean value indicating whether the passed-in
|
||||
* <OpenLayers.LonLat> object has the same lon and lat
|
||||
* components as this.
|
||||
* Note: if ll passed in is null, returns false
|
||||
*/
|
||||
equals:function(ll) {
|
||||
var equals = false;
|
||||
if (ll != null) {
|
||||
equals = ((this.lon == ll.lon && this.lat == ll.lat) ||
|
||||
(isNaN(this.lon) && isNaN(this.lat) && isNaN(ll.lon) && isNaN(ll.lat)));
|
||||
}
|
||||
return equals;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: wrapDateLine
|
||||
*
|
||||
* Parameters:
|
||||
* maxExtent - {<OpenLayers.Bounds>}
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.LonLat>} A copy of this lonlat, but wrapped around the
|
||||
* "dateline" (as specified by the borders of
|
||||
* maxExtent)
|
||||
*/
|
||||
wrapDateLine: function(maxExtent) {
|
||||
|
||||
var newLonLat = this.clone();
|
||||
|
||||
if (maxExtent) {
|
||||
//shift right?
|
||||
while (newLonLat.lon < maxExtent.left) {
|
||||
newLonLat.lon += maxExtent.getWidth();
|
||||
}
|
||||
|
||||
//shift left?
|
||||
while (newLonLat.lon > maxExtent.right) {
|
||||
newLonLat.lon -= maxExtent.getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
return newLonLat;
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.LonLat"
|
||||
};
|
||||
|
||||
/**
|
||||
* Function: fromString
|
||||
* Alternative constructor that builds a new <OpenLayers.LonLat> from a
|
||||
* parameter string
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String} Comma-separated Lon,Lat coordinate string.
|
||||
* (ex. <i>"5,40"</i>)
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.LonLat>} New <OpenLayers.LonLat> object built from the
|
||||
* passed-in String.
|
||||
*/
|
||||
OpenLayers.LonLat.fromString = function(str) {
|
||||
var pair = str.split(",");
|
||||
return new OpenLayers.LonLat(parseFloat(pair[0]),
|
||||
parseFloat(pair[1]));
|
||||
};
|
||||
117
lib/OpenLayers/BaseTypes/Pixel.js
Normal file
117
lib/OpenLayers/BaseTypes/Pixel.js
Normal file
@@ -0,0 +1,117 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Pixel
|
||||
* This class represents a screen coordinate, in x and y coordinates
|
||||
*/
|
||||
OpenLayers.Pixel = OpenLayers.Class.create();
|
||||
OpenLayers.Pixel.prototype = {
|
||||
|
||||
/**
|
||||
* APIProperty: x
|
||||
* {Number} The x coordinate
|
||||
*/
|
||||
x: 0.0,
|
||||
|
||||
/**
|
||||
* APIProperty: y
|
||||
* {Number} The y coordinate
|
||||
*/
|
||||
y: 0.0,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Pixel
|
||||
* Create a new OpenLayers.Pixel instance
|
||||
*
|
||||
* Parameters:
|
||||
* x - {Number} The x coordinate
|
||||
* y - {Number} The y coordinate
|
||||
*
|
||||
* Return:
|
||||
* An instance of OpenLayers.Pixel
|
||||
*/
|
||||
initialize: function(x, y) {
|
||||
this.x = parseFloat(x);
|
||||
this.y = parseFloat(y);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: toString
|
||||
* Cast this object into a string
|
||||
*
|
||||
* Return:
|
||||
* {String} The string representation of Pixel. ex: "x=200.4,y=242.2"
|
||||
*/
|
||||
toString:function() {
|
||||
return ("x=" + this.x + ",y=" + this.y);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: clone
|
||||
* Return a clone of this pixel object
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.Pixel>} A clone pixel
|
||||
*/
|
||||
clone:function() {
|
||||
return new OpenLayers.Pixel(this.x, this.y);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: equals
|
||||
* Determine whether one pixel is equivalent to another
|
||||
*
|
||||
* Parameters:
|
||||
* px - {<OpenLayers.Pixel>}
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} The point passed in as parameter is equal to this. Note that
|
||||
* if px passed in is null, returns false.
|
||||
*/
|
||||
equals:function(px) {
|
||||
var equals = false;
|
||||
if (px != null) {
|
||||
equals = ((this.x == px.x && this.y == px.y) ||
|
||||
(isNaN(this.x) && isNaN(this.y) && isNaN(px.x) && isNaN(px.y)));
|
||||
}
|
||||
return equals;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: add
|
||||
*
|
||||
* Parameters:
|
||||
* x - {Integer}
|
||||
* y - {Integer}
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.Pixel>} A new Pixel with this pixel's x&y augmented by the
|
||||
* values passed in.
|
||||
*/
|
||||
add:function(x, y) {
|
||||
return new OpenLayers.Pixel(this.x + x, this.y + y);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: offset
|
||||
*
|
||||
* Parameters
|
||||
* px - {<OpenLayers.Pixel>}
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.Pixel>} A new Pixel with this pixel's x&y augmented by the
|
||||
* x&y values of the pixel passed in.
|
||||
*/
|
||||
offset:function(px) {
|
||||
var newPx = this.clone();
|
||||
if (px) {
|
||||
newPx = this.add(px.x, px.y);
|
||||
}
|
||||
return newPx;
|
||||
},
|
||||
|
||||
/** @final @type str */
|
||||
CLASS_NAME: "OpenLayers.Pixel"
|
||||
};
|
||||
86
lib/OpenLayers/BaseTypes/Size.js
Normal file
86
lib/OpenLayers/BaseTypes/Size.js
Normal file
@@ -0,0 +1,86 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Size
|
||||
* Instances of this class represent a width/height pair
|
||||
*/
|
||||
OpenLayers.Size = OpenLayers.Class.create();
|
||||
OpenLayers.Size.prototype = {
|
||||
|
||||
/**
|
||||
* APIProperty: w
|
||||
* {Number} width
|
||||
*/
|
||||
w: 0.0,
|
||||
|
||||
/**
|
||||
* APIProperty: h
|
||||
* {Number} height
|
||||
*/
|
||||
h: 0.0,
|
||||
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Size
|
||||
* Create an instance of OpenLayers.Size
|
||||
*
|
||||
* Parameters:
|
||||
* w - {Number} width
|
||||
* h - {Number} height
|
||||
*/
|
||||
initialize: function(w, h) {
|
||||
this.w = parseFloat(w);
|
||||
this.h = parseFloat(h);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: toString
|
||||
* Return the string representation of a size object
|
||||
*
|
||||
* Return:
|
||||
* {String} The string representation of OpenLayers.Size object.
|
||||
* (ex. <i>"w=55,h=66"</i>)
|
||||
*/
|
||||
toString:function() {
|
||||
return ("w=" + this.w + ",h=" + this.h);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: clone
|
||||
* Create a clone of this size object
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.Size>} A new OpenLayers.Size object with the same w and h
|
||||
* values
|
||||
*/
|
||||
clone:function() {
|
||||
return new OpenLayers.Size(this.w, this.h);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* APIMethod: equals
|
||||
* Determine where this size is equal to another
|
||||
*
|
||||
* Parameters:
|
||||
* sz - {<OpenLayers.Size>}
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} The passed in size has the same h and w properties as this one.
|
||||
* Note that if sz passed in is null, returns false.
|
||||
*
|
||||
*/
|
||||
equals:function(sz) {
|
||||
var equals = false;
|
||||
if (sz != null) {
|
||||
equals = ((this.w == sz.w && this.h == sz.h) ||
|
||||
(isNaN(this.w) && isNaN(this.h) && isNaN(sz.w) && isNaN(sz.h)));
|
||||
}
|
||||
return equals;
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Size"
|
||||
};
|
||||
Reference in New Issue
Block a user