From ac8e7e16c2bd9badd8e3bd3bd302547ec74165b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 17 Sep 2014 07:37:11 +0200 Subject: [PATCH 1/3] Function circular renamed to createCircularOnSphere --- examples/tissot.js | 3 ++- src/ol/geom/polygon.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/tissot.js b/examples/tissot.js index af92b5cb32..bde3061997 100644 --- a/examples/tissot.js +++ b/examples/tissot.js @@ -63,7 +63,8 @@ var radius = 800000; var x, y; for (x = -180; x < 180; x += 30) { for (y = -90; y < 90; y += 30) { - var circle4326 = ol.geom.Polygon.circular(wgs84Sphere, [x, y], radius, 64); + var circle4326 = ol.geom.Polygon.createCircularOnSphere( + wgs84Sphere, [x, y], radius, 64); var circle3857 = circle4326.clone().transform('EPSG:4326', 'EPSG:3857'); vectorLayer4326.getSource().addFeature(new ol.Feature(circle4326)); vectorLayer3857.getSource().addFeature(new ol.Feature(circle3857)); diff --git a/src/ol/geom/polygon.js b/src/ol/geom/polygon.js index 52d55ff1fd..2532ce1b2e 100644 --- a/src/ol/geom/polygon.js +++ b/src/ol/geom/polygon.js @@ -357,7 +357,8 @@ ol.geom.Polygon.prototype.setFlatCoordinates = * @return {ol.geom.Polygon} Circle geometry. * @api stable */ -ol.geom.Polygon.circular = function(sphere, center, radius, opt_n) { +ol.geom.Polygon.createCircularOnSphere = + function(sphere, center, radius, opt_n) { var n = goog.isDef(opt_n) ? opt_n : 32; /** @type {Array.} */ var flatCoordinates = []; From 122b535393bbf88ff563590ee9950e03c54a2c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 17 Sep 2014 18:21:39 +0200 Subject: [PATCH 2/3] Better docs for ol.Sphere#offset --- src/ol/sphere/sphere.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ol/sphere/sphere.js b/src/ol/sphere/sphere.js index 96a7b68c2b..7dd37905d8 100644 --- a/src/ol/sphere/sphere.js +++ b/src/ol/sphere/sphere.js @@ -214,12 +214,13 @@ ol.Sphere.prototype.midpoint = function(c1, c2) { /** - * Returns the coordinate at the given distance and bearing from c. + * Returns the coordinate at the given distance and bearing from `c1`. * - * @param {ol.Coordinate} c1 Coordinate. - * @param {number} distance Distance. - * @param {number} bearing Bearing. - * @return {ol.Coordinate} Coordinate. + * @param {ol.Coordinate} c1 The origin point (`[lon, lat]` in degrees). + * @param {number} distance The great-circle distance between the origin + * point and the target point. + * @param {number} bearing The bearing (in radians). + * @return {ol.Coordinate} The target point. */ ol.Sphere.prototype.offset = function(c1, distance, bearing) { var lat1 = goog.math.toRadians(c1[1]); From d85d34f3dd355d13ce3419aaae7a07cf3322b7df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 17 Sep 2014 18:21:59 +0200 Subject: [PATCH 3/3] Better docs for ol.geom.Polygon#createCircularSphere --- src/ol/geolocation.js | 2 +- src/ol/geom/polygon.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index d5cf49ac84..8ccd4fb09b 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -169,7 +169,7 @@ ol.Geolocation.prototype.positionChange_ = function(position) { this.set(ol.GeolocationProperty.POSITION, projectedPosition); this.set(ol.GeolocationProperty.SPEED, goog.isNull(coords.speed) ? undefined : coords.speed); - var geometry = ol.geom.Polygon.circular( + var geometry = ol.geom.Polygon.createCircularOnSphere( ol.sphere.WGS84, this.position_, coords.accuracy); geometry.applyTransform(this.transform_); this.set(ol.GeolocationProperty.ACCURACY_GEOMETRY, geometry); diff --git a/src/ol/geom/polygon.js b/src/ol/geom/polygon.js index 2532ce1b2e..117edbc54a 100644 --- a/src/ol/geom/polygon.js +++ b/src/ol/geom/polygon.js @@ -351,10 +351,12 @@ ol.geom.Polygon.prototype.setFlatCoordinates = /** * Create an approximation of a circle on the surface of a sphere. * @param {ol.Sphere} sphere The sphere. - * @param {ol.Coordinate} center Center. - * @param {number} radius Radius. - * @param {number=} opt_n Optional number of points. Default is `32`. - * @return {ol.geom.Polygon} Circle geometry. + * @param {ol.Coordinate} center Center (`[lon, lat]` in degrees). + * @param {number} radius The great-circle distance from the center to + * the polygon vertices. + * @param {number=} opt_n Optional number of vertices for the resulting + * polygon. Default is `32`. + * @return {ol.geom.Polygon} The "circular" polygon. * @api stable */ ol.geom.Polygon.createCircularOnSphere =