From b1cc0c1b9dd6df83569b6d2b6a26386cf76b185c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 9 Feb 2012 16:58:36 +0100 Subject: [PATCH 1/3] make OpenLayers.js auto-load Spherical.js --- lib/OpenLayers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 3ffa1b6a84..78b35da424 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -348,7 +348,8 @@ "OpenLayers/Symbolizer/Text.js", "OpenLayers/Symbolizer/Raster.js", "OpenLayers/Lang.js", - "OpenLayers/Lang/en.js" + "OpenLayers/Lang/en.js", + "OpenLayers/Spherical.js" ]; // etc. } From 4cc1bf18993486d0bde9a6849994b639c064bd20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 9 Feb 2012 16:59:02 +0100 Subject: [PATCH 2/3] better docs for the Spherical namespace --- lib/OpenLayers/Spherical.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/OpenLayers/Spherical.js b/lib/OpenLayers/Spherical.js index ed64c844f8..b19edc8939 100644 --- a/lib/OpenLayers/Spherical.js +++ b/lib/OpenLayers/Spherical.js @@ -3,29 +3,32 @@ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the * full text of the license. */ -/** - * @see http://www.movable-type.co.uk/scripts/latlong.html - * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#spherical - */ - - /** * Namespace: Spherical + * The OpenLayers.Spherical namespace includes utility functions for + * calculations on the basis of a spherical earth (ignoring ellipsoidal + * effects), which is accurate enough for most purposes. + * + * Relevant links: + * * http://www.movable-type.co.uk/scripts/latlong.html + * * http://code.google.com/apis/maps/documentation/javascript/reference.html#spherical */ + OpenLayers.Spherical = OpenLayers.Spherical || {}; - OpenLayers.Spherical.DEFAULT_RADIUS = 6378137; - /** * APIFunction: computeDistanceBetween * Computes the distance between two LonLats. * * Parameters: - * from - {} - * to - {} - * radius - {Float} + * from - {} or {Object} Starting point. A LonLat or + * a JavaScript litteral with lon lat properties. + * to - {} or {Object} Ending point. A LonLat or a + * JavaScript litteral with lon lat properties. + * radius - {Float} The radius. Optional. Defaults to the earth's + * radius, i.e. 6378137 meters. * * Returns: * {Float} The distance in meters. @@ -45,8 +48,10 @@ OpenLayers.Spherical.computeDistanceBetween = function(from, to, radius) { * Computes the heading from one LonLat to another LonLat. * * Parameters: - * from - {} - * to - {} + * from - {} or {Object} Starting point. A LonLat or + * a JavaScript litteral with lon lat properties. + * to - {} or {Object} Ending point. A LonLat or a + * JavaScript litteral with lon lat properties. * * Returns: * {Float} The heading in degrees. From 50629f3e50793233419c25cf4695751621151d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 9 Feb 2012 16:59:20 +0100 Subject: [PATCH 3/3] add Spherical to the API doc menu --- doc_config/Menu.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc_config/Menu.txt b/doc_config/Menu.txt index 7d685cb73c..1a941749ae 100644 --- a/doc_config/Menu.txt +++ b/doc_config/Menu.txt @@ -458,6 +458,7 @@ Group: OpenLayers { File: Tween (no auto-title, OpenLayers/Tween.js) File: Util (no auto-title, OpenLayers/Util.js) + File: Spherical (no auto-title, OpenLayers/Spherical.js) File: Deprecated (no auto-title, deprecated.js) } # Group: OpenLayers