Merge pull request #2727 from elemoine/createcircular

Rename ol.geom.Polygon#circular to createCircularOnSphere
This commit is contained in:
Éric Lemoine
2014-09-19 11:13:54 +02:00
4 changed files with 17 additions and 12 deletions
+2 -1
View File
@@ -63,7 +63,8 @@ var radius = 800000;
var x, y; var x, y;
for (x = -180; x < 180; x += 30) { for (x = -180; x < 180; x += 30) {
for (y = -90; y < 90; y += 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'); var circle3857 = circle4326.clone().transform('EPSG:4326', 'EPSG:3857');
vectorLayer4326.getSource().addFeature(new ol.Feature(circle4326)); vectorLayer4326.getSource().addFeature(new ol.Feature(circle4326));
vectorLayer3857.getSource().addFeature(new ol.Feature(circle3857)); vectorLayer3857.getSource().addFeature(new ol.Feature(circle3857));
+1 -1
View File
@@ -169,7 +169,7 @@ ol.Geolocation.prototype.positionChange_ = function(position) {
this.set(ol.GeolocationProperty.POSITION, projectedPosition); this.set(ol.GeolocationProperty.POSITION, projectedPosition);
this.set(ol.GeolocationProperty.SPEED, this.set(ol.GeolocationProperty.SPEED,
goog.isNull(coords.speed) ? undefined : coords.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); ol.sphere.WGS84, this.position_, coords.accuracy);
geometry.applyTransform(this.transform_); geometry.applyTransform(this.transform_);
this.set(ol.GeolocationProperty.ACCURACY_GEOMETRY, geometry); this.set(ol.GeolocationProperty.ACCURACY_GEOMETRY, geometry);
+8 -5
View File
@@ -351,13 +351,16 @@ ol.geom.Polygon.prototype.setFlatCoordinates =
/** /**
* Create an approximation of a circle on the surface of a sphere. * Create an approximation of a circle on the surface of a sphere.
* @param {ol.Sphere} sphere The sphere. * @param {ol.Sphere} sphere The sphere.
* @param {ol.Coordinate} center Center. * @param {ol.Coordinate} center Center (`[lon, lat]` in degrees).
* @param {number} radius Radius. * @param {number} radius The great-circle distance from the center to
* @param {number=} opt_n Optional number of points. Default is `32`. * the polygon vertices.
* @return {ol.geom.Polygon} Circle geometry. * @param {number=} opt_n Optional number of vertices for the resulting
* polygon. Default is `32`.
* @return {ol.geom.Polygon} The "circular" polygon.
* @api stable * @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; var n = goog.isDef(opt_n) ? opt_n : 32;
/** @type {Array.<number>} */ /** @type {Array.<number>} */
var flatCoordinates = []; var flatCoordinates = [];
+6 -5
View File
@@ -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 {ol.Coordinate} c1 The origin point (`[lon, lat]` in degrees).
* @param {number} distance Distance. * @param {number} distance The great-circle distance between the origin
* @param {number} bearing Bearing. * point and the target point.
* @return {ol.Coordinate} Coordinate. * @param {number} bearing The bearing (in radians).
* @return {ol.Coordinate} The target point.
*/ */
ol.Sphere.prototype.offset = function(c1, distance, bearing) { ol.Sphere.prototype.offset = function(c1, distance, bearing) {
var lat1 = goog.math.toRadians(c1[1]); var lat1 = goog.math.toRadians(c1[1]);