[OpenLayers-Commits] r2344 - in sandbox/vector-2.4/lib/OpenLayers: . Geometry
commits at openlayers.org
commits at openlayers.org
Mon Mar 5 15:35:19 EST 2007
Author: euzuro
Date: 2007-03-05 15:35:18 -0500 (Mon, 05 Mar 2007)
New Revision: 2344
Modified:
sandbox/vector-2.4/lib/OpenLayers/Geometry.js
sandbox/vector-2.4/lib/OpenLayers/Geometry/Curve.js
Log:
update Geometry's setBounds function to accept lonlats, geometry.points, and bounds, then make other updates accordingly
Modified: sandbox/vector-2.4/lib/OpenLayers/Geometry/Curve.js
===================================================================
--- sandbox/vector-2.4/lib/OpenLayers/Geometry/Curve.js 2007-03-05 20:33:50 UTC (rev 2343)
+++ sandbox/vector-2.4/lib/OpenLayers/Geometry/Curve.js 2007-03-05 20:35:18 UTC (rev 2344)
@@ -98,8 +98,7 @@
} else {
this.path.push(point);
}
- var bounds = new OpenLayers.Bounds(point.lon, point.lat, point.lon, point.lat);
- this.extendBounds(bounds);
+ this.extendBounds(point);
}
},
Modified: sandbox/vector-2.4/lib/OpenLayers/Geometry.js
===================================================================
--- sandbox/vector-2.4/lib/OpenLayers/Geometry.js 2007-03-05 20:33:50 UTC (rev 2343)
+++ sandbox/vector-2.4/lib/OpenLayers/Geometry.js 2007-03-05 20:35:18 UTC (rev 2344)
@@ -40,23 +40,39 @@
/**
* Set the bounds for this Geometry.
*
- * @param {OpenLayers.Bounds} bounds
+ * @param {OpenLayers.LonLat|OpenLayers.Geometry.Point|OpenLayers.Bounds} object
*/
- setBounds: function(bounds) {
- this.bounds = bounds;
+ setBounds: function(object) {
+ var bounds = null;
+ if (object) {
+ switch(object.CLASS_NAME) {
+ case "OpenLayers.Geometry.Point":
+ case "OpenLayers.LonLat":
+ bounds = new OpenLayers.Bounds(object.lon, object.lat,
+ object.lon, object.lat);
+ break;
+
+ case "OpenLayers.Bounds":
+ bounds = object;
+ break;
+ }
+ }
+ if (bounds) {
+ this.bounds = bounds;
+ }
},
/**
- * Extend the existing bounds to include the new bounds. If existing
- * bounds=null, then set a new Bounds.
+ * Extend the existing bounds to include the new lonlat, point, or bounds.
+ * If geometry's bounds is not yet set, then set a new Bounds.
*
- * @param {Object} bounds
+ * @param {OpenLayers.LonLat|OpenLayers.Geometry.Point|OpenLayers.Bounds} object
*/
- extendBounds: function(bounds){
+ extendBounds: function(object){
if (!this.bounds) {
- this.setBounds(bounds);
+ this.setBounds(object);
} else {
- this.bounds.extend(bounds);
+ this.bounds.extend(object);
}
},
More information about the Commits
mailing list