From 8558b6ee5cfdcba2bc40fe83c507835251d81361 Mon Sep 17 00:00:00 2001 From: fredj Date: Wed, 18 Jan 2012 10:04:45 +0100 Subject: [PATCH 1/3] Update OpenLayers.Layer.Grid.calculateGridLayout inputs type. No need to clone the passed bounds (read only access). 'bounds' can be either a Bounds instance or a simple javascript object. Same for 'origin': LonLat instance or a simple javascript object. --- lib/OpenLayers/Layer/Grid.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 0a1c2d8220..4722d64322 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -677,8 +677,10 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * Generate parameters for the grid layout. * * Parameters: - * bounds - {} - * origin - {} + * bounds - {|Object} OpenLayers.Bounds or an + * object with a 'left' and 'top' properties. + * origin - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * resolution - {Number} * * Returns: @@ -686,8 +688,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * tileoffsetlat, tileoffsetx, tileoffsety */ calculateGridLayout: function(bounds, origin, resolution) { - bounds = bounds.clone(); - var tilelon = resolution * this.tileSize.w; var tilelat = resolution * this.tileSize.h; From 657b47abb0d99a3be09c3725b1fe0e0f02c4a67b Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 16 Jan 2012 15:15:03 +0100 Subject: [PATCH 2/3] Update Control.OverviewMap.getOverviewPxFromLonLat input type 'lonlat' parameter can be either a OpenLayers.LonLat instance or a simple javascript object with a 'lon' and 'lat' properties. --- lib/OpenLayers/Control/OverviewMap.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/OpenLayers/Control/OverviewMap.js b/lib/OpenLayers/Control/OverviewMap.js index 67bba68886..29fefeb5b2 100644 --- a/lib/OpenLayers/Control/OverviewMap.js +++ b/lib/OpenLayers/Control/OverviewMap.js @@ -628,12 +628,14 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, { * translated into pixel bounds for the overview map */ getRectBoundsFromMapBounds: function(lonLatBounds) { - var leftBottomLonLat = new OpenLayers.LonLat(lonLatBounds.left, - lonLatBounds.bottom); - var rightTopLonLat = new OpenLayers.LonLat(lonLatBounds.right, - lonLatBounds.top); - var leftBottomPx = this.getOverviewPxFromLonLat(leftBottomLonLat); - var rightTopPx = this.getOverviewPxFromLonLat(rightTopLonLat); + var leftBottomPx = this.getOverviewPxFromLonLat({ + lon: lonLatBounds.left, + lat: lonLatBounds.bottom + }); + var rightTopPx = this.getOverviewPxFromLonLat({ + lon: lonLatBounds.right, + lat: lonLatBounds.top + }); var bounds = null; if (leftBottomPx && rightTopPx) { 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 * * Parameters: - * lonlat - {} + * lonlat - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * * Returns: * {Object} Location which is the passed-in OpenLayers.LonLat, From 3a69729074117739eeb33b7f14b914ccf1c53b2c Mon Sep 17 00:00:00 2001 From: fredj Date: Mon, 16 Jan 2012 14:25:15 +0100 Subject: [PATCH 3/3] Update OpenLayers.Bounds.containsLonLat input type 'll' parameter can now be either a OpenLayers.LonLat instance or a simple javascript object with a 'lon' and 'lat' properties. --- lib/OpenLayers/BaseTypes/Bounds.js | 12 ++++++------ lib/OpenLayers/Feature/Vector.js | 3 ++- lib/OpenLayers/Geometry.js | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/OpenLayers/BaseTypes/Bounds.js b/lib/OpenLayers/BaseTypes/Bounds.js index 46b992961d..5a527ca02a 100644 --- a/lib/OpenLayers/BaseTypes/Bounds.js +++ b/lib/OpenLayers/BaseTypes/Bounds.js @@ -359,7 +359,8 @@ OpenLayers.Bounds = OpenLayers.Class({ * APIMethod: containsLonLat * * Parameters: - * ll - {} + * ll - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * options - {Object} Optional parameters * * Acceptable options: @@ -382,13 +383,12 @@ OpenLayers.Bounds = OpenLayers.Class({ worldBounds = options.worldBounds; if (worldBounds && !contains) { var worldWidth = worldBounds.getWidth(); - ll = ll.clone(); var worldCenterX = (worldBounds.left + worldBounds.right) / 2; var worldsAway = Math.round((ll.lon - worldCenterX) / worldWidth); - ll.lon -= (worldsAway * worldWidth); - contains = this.containsLonLat( - ll, {inclusive: options.inclusive} - ); + contains = this.containsLonLat({ + lon: ll.lon - worldsAway * worldWidth, + lat: ll.lat + }, {inclusive: options.inclusive}); } return contains; }, diff --git a/lib/OpenLayers/Feature/Vector.js b/lib/OpenLayers/Feature/Vector.js index 75dd5ff20d..27928a2b47 100644 --- a/lib/OpenLayers/Feature/Vector.js +++ b/lib/OpenLayers/Feature/Vector.js @@ -267,7 +267,8 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, { * Determins whether the feature intersects with the specified location. * * Parameters: - * lonlat - {} + * lonlat - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * toleranceLon - {float} Optional tolerance in Geometric Coords * toleranceLat - {float} Optional tolerance in Geographic Coords * diff --git a/lib/OpenLayers/Geometry.js b/lib/OpenLayers/Geometry.js index 888f73b83e..f199e3fa35 100644 --- a/lib/OpenLayers/Geometry.js +++ b/lib/OpenLayers/Geometry.js @@ -176,7 +176,8 @@ OpenLayers.Geometry = OpenLayers.Class({ * geometry. * * Parameters: - * lonlat - {} + * lonlat - {|Object} OpenLayers.LonLat or an + * object with a 'lon' and 'lat' properties. * toleranceLon - {float} Optional tolerance in Geometric Coords * toleranceLat - {float} Optional tolerance in Geographic Coords *