Merge pull request #197 from fredj/simple-objects

Replace LonLat instances with simple objects
This commit is contained in:
Frédéric Junod
2012-02-02 22:50:37 -08:00
5 changed files with 24 additions and 19 deletions
+6 -6
View File
@@ -359,7 +359,8 @@ OpenLayers.Bounds = OpenLayers.Class({
* APIMethod: containsLonLat * APIMethod: containsLonLat
* *
* Parameters: * Parameters:
* ll - {<OpenLayers.LonLat>} * ll - {<OpenLayers.LonLat>|Object} OpenLayers.LonLat or an
* object with a 'lon' and 'lat' properties.
* options - {Object} Optional parameters * options - {Object} Optional parameters
* *
* Acceptable options: * Acceptable options:
@@ -382,13 +383,12 @@ OpenLayers.Bounds = OpenLayers.Class({
worldBounds = options.worldBounds; worldBounds = options.worldBounds;
if (worldBounds && !contains) { if (worldBounds && !contains) {
var worldWidth = worldBounds.getWidth(); var worldWidth = worldBounds.getWidth();
ll = ll.clone();
var worldCenterX = (worldBounds.left + worldBounds.right) / 2; var worldCenterX = (worldBounds.left + worldBounds.right) / 2;
var worldsAway = Math.round((ll.lon - worldCenterX) / worldWidth); var worldsAway = Math.round((ll.lon - worldCenterX) / worldWidth);
ll.lon -= (worldsAway * worldWidth); contains = this.containsLonLat({
contains = this.containsLonLat( lon: ll.lon - worldsAway * worldWidth,
ll, {inclusive: options.inclusive} lat: ll.lat
); }, {inclusive: options.inclusive});
} }
return contains; return contains;
}, },
+10 -7
View File
@@ -628,12 +628,14 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
* translated into pixel bounds for the overview map * translated into pixel bounds for the overview map
*/ */
getRectBoundsFromMapBounds: function(lonLatBounds) { getRectBoundsFromMapBounds: function(lonLatBounds) {
var leftBottomLonLat = new OpenLayers.LonLat(lonLatBounds.left, var leftBottomPx = this.getOverviewPxFromLonLat({
lonLatBounds.bottom); lon: lonLatBounds.left,
var rightTopLonLat = new OpenLayers.LonLat(lonLatBounds.right, lat: lonLatBounds.bottom
lonLatBounds.top); });
var leftBottomPx = this.getOverviewPxFromLonLat(leftBottomLonLat); var rightTopPx = this.getOverviewPxFromLonLat({
var rightTopPx = this.getOverviewPxFromLonLat(rightTopLonLat); lon: lonLatBounds.right,
lat: lonLatBounds.top
});
var bounds = null; var bounds = null;
if (leftBottomPx && rightTopPx) { if (leftBottomPx && rightTopPx) {
bounds = new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y, bounds = new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y,
@@ -699,7 +701,8 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
* Get a pixel location from a map location * Get a pixel location from a map location
* *
* Parameters: * Parameters:
* lonlat - {<OpenLayers.LonLat>} * lonlat - {<OpenLayers.LonLat>|Object} OpenLayers.LonLat or an
* object with a 'lon' and 'lat' properties.
* *
* Returns: * Returns:
* {Object} Location which is the passed-in OpenLayers.LonLat, * {Object} Location which is the passed-in OpenLayers.LonLat,
+2 -1
View File
@@ -267,7 +267,8 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
* Determins whether the feature intersects with the specified location. * Determins whether the feature intersects with the specified location.
* *
* Parameters: * Parameters:
* lonlat - {<OpenLayers.LonLat>} * lonlat - {<OpenLayers.LonLat>|Object} OpenLayers.LonLat or an
* object with a 'lon' and 'lat' properties.
* toleranceLon - {float} Optional tolerance in Geometric Coords * toleranceLon - {float} Optional tolerance in Geometric Coords
* toleranceLat - {float} Optional tolerance in Geographic Coords * toleranceLat - {float} Optional tolerance in Geographic Coords
* *
+2 -1
View File
@@ -176,7 +176,8 @@ OpenLayers.Geometry = OpenLayers.Class({
* geometry. * geometry.
* *
* Parameters: * Parameters:
* lonlat - {<OpenLayers.LonLat>} * lonlat - {<OpenLayers.LonLat>|Object} OpenLayers.LonLat or an
* object with a 'lon' and 'lat' properties.
* toleranceLon - {float} Optional tolerance in Geometric Coords * toleranceLon - {float} Optional tolerance in Geometric Coords
* toleranceLat - {float} Optional tolerance in Geographic Coords * toleranceLat - {float} Optional tolerance in Geographic Coords
* *
+4 -4
View File
@@ -677,8 +677,10 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
* Generate parameters for the grid layout. * Generate parameters for the grid layout.
* *
* Parameters: * Parameters:
* bounds - {<OpenLayers.Bound>} * bounds - {<OpenLayers.Bound>|Object} OpenLayers.Bounds or an
* origin - {<OpenLayers.LonLat>} * object with a 'left' and 'top' properties.
* origin - {<OpenLayers.LonLat>|Object} OpenLayers.LonLat or an
* object with a 'lon' and 'lat' properties.
* resolution - {Number} * resolution - {Number}
* *
* Returns: * Returns:
@@ -686,8 +688,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
* tileoffsetlat, tileoffsetx, tileoffsety * tileoffsetlat, tileoffsetx, tileoffsety
*/ */
calculateGridLayout: function(bounds, origin, resolution) { calculateGridLayout: function(bounds, origin, resolution) {
bounds = bounds.clone();
var tilelon = resolution * this.tileSize.w; var tilelon = resolution * this.tileSize.w;
var tilelat = resolution * this.tileSize.h; var tilelat = resolution * this.tileSize.h;