Merge pull request #3176 from fredj/undefined-rotation

Disallowed undefined rotation value
This commit is contained in:
Frédéric Junod
2015-01-27 17:11:26 +01:00
2 changed files with 22 additions and 4 deletions
+4 -4
View File
@@ -351,12 +351,12 @@ ol.View.prototype.getResolutionForValueFunction = function(opt_power) {
/** /**
* @return {number|undefined} The rotation of the view. * @return {number} The rotation of the view.
* @observable * @observable
* @api stable * @api stable
*/ */
ol.View.prototype.getRotation = function() { ol.View.prototype.getRotation = function() {
return /** @type {number|undefined} */ (this.get(ol.ViewProperty.ROTATION)); return /** @type {number} */ (this.get(ol.ViewProperty.ROTATION));
}; };
goog.exportProperty( goog.exportProperty(
ol.View.prototype, ol.View.prototype,
@@ -402,7 +402,7 @@ ol.View.prototype.getState = function() {
center: center.slice(), center: center.slice(),
projection: goog.isDef(projection) ? projection : null, projection: goog.isDef(projection) ? projection : null,
resolution: resolution, resolution: resolution,
rotation: goog.isDef(rotation) ? rotation : 0 rotation: rotation
}); });
}; };
@@ -626,7 +626,7 @@ goog.exportProperty(
/** /**
* Set the rotation for this view. * Set the rotation for this view.
* @param {number|undefined} rotation The rotation of the view. * @param {number} rotation The rotation of the view.
* @observable * @observable
* @api stable * @api stable
*/ */
+18
View File
@@ -1,6 +1,24 @@
goog.provide('ol.test.View'); goog.provide('ol.test.View');
describe('ol.View', function() { describe('ol.View', function() {
describe('constructor (defaults)', function() {
var view;
beforeEach(function() {
view = new ol.View();
});
it('creates an instance', function() {
expect(view).to.be.a(ol.View);
});
it('provides default rotation', function() {
expect(view.getRotation()).to.be(0);
});
});
describe('create constraints', function() { describe('create constraints', function() {
describe('create resolution constraint', function() { describe('create resolution constraint', function() {