Constraint objects moved to ol namespace from ol.interaction namespace
This commit is contained in:
@@ -0,0 +1,27 @@
|
|||||||
|
goog.provide('ol.Constraints');
|
||||||
|
|
||||||
|
goog.require('ol.ResolutionConstraintType');
|
||||||
|
goog.require('ol.RotationConstraintType');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param {ol.ResolutionConstraintType} resolutionConstraint
|
||||||
|
* Resolution constraint.
|
||||||
|
* @param {ol.RotationConstraintType} rotationConstraint
|
||||||
|
* Rotation constraint.
|
||||||
|
*/
|
||||||
|
ol.Constraints = function(resolutionConstraint, rotationConstraint) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {ol.ResolutionConstraintType}
|
||||||
|
*/
|
||||||
|
this.resolution = resolutionConstraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {ol.RotationConstraintType}
|
||||||
|
*/
|
||||||
|
this.rotation = rotationConstraint;
|
||||||
|
|
||||||
|
};
|
||||||
@@ -5,6 +5,7 @@ goog.require('goog.dom.TagName');
|
|||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
|
goog.require('ol.ResolutionConstraint');
|
||||||
goog.require('ol.control.Control');
|
goog.require('ol.control.Control');
|
||||||
|
|
||||||
|
|
||||||
@@ -30,9 +31,8 @@ ol.control.Zoom = function(map, opt_resolutions) {
|
|||||||
* @type {Function}
|
* @type {Function}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.constraint_ =
|
this.constraint_ = ol.ResolutionConstraint.createSnapToResolutions(
|
||||||
ol.interaction.ResolutionConstraint.createSnapToResolutions(
|
opt_resolutions);
|
||||||
opt_resolutions);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Element}
|
* @type {Element}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
goog.provide('ol.interaction.Constraints');
|
|
||||||
|
|
||||||
goog.require('ol.interaction.CenterConstraintType');
|
|
||||||
goog.require('ol.interaction.ResolutionConstraintType');
|
|
||||||
goog.require('ol.interaction.RotationConstraintType');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {ol.interaction.ResolutionConstraintType} resolutionConstraint
|
|
||||||
* Resolution constraint.
|
|
||||||
* @param {ol.interaction.RotationConstraintType} rotationConstraint
|
|
||||||
* Rotation constraint.
|
|
||||||
*/
|
|
||||||
ol.interaction.Constraints =
|
|
||||||
function(resolutionConstraint, rotationConstraint) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {ol.interaction.ResolutionConstraintType}
|
|
||||||
*/
|
|
||||||
this.resolution = resolutionConstraint;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {ol.interaction.RotationConstraintType}
|
|
||||||
*/
|
|
||||||
this.rotation = rotationConstraint;
|
|
||||||
|
|
||||||
};
|
|
||||||
+2
-3
@@ -26,6 +26,7 @@ goog.require('goog.fx.anim.Animated');
|
|||||||
goog.require('goog.object');
|
goog.require('goog.object');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.Color');
|
goog.require('ol.Color');
|
||||||
|
goog.require('ol.Constraints');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol.Coordinate');
|
||||||
goog.require('ol.Extent');
|
goog.require('ol.Extent');
|
||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol.MapBrowserEvent');
|
||||||
@@ -34,7 +35,6 @@ goog.require('ol.Pixel');
|
|||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
goog.require('ol.Size');
|
goog.require('ol.Size');
|
||||||
goog.require('ol.TransformFunction');
|
goog.require('ol.TransformFunction');
|
||||||
goog.require('ol.interaction.Constraints');
|
|
||||||
goog.require('ol.interaction.Interaction');
|
goog.require('ol.interaction.Interaction');
|
||||||
goog.require('ol.renderer.Layer');
|
goog.require('ol.renderer.Layer');
|
||||||
|
|
||||||
@@ -139,8 +139,7 @@ ol.Map = function(container, mapOptionsLiteral, opt_viewportSizeMonitor) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* FIXME change ol.interaction.Constraints -> ol.Constraints
|
* @type {ol.Constraints}
|
||||||
* @type {ol.interaction.Constraints}
|
|
||||||
*/
|
*/
|
||||||
this.constraints_ = mapOptions.constraints;
|
this.constraints_ = mapOptions.constraints;
|
||||||
|
|
||||||
|
|||||||
+9
-11
@@ -4,17 +4,17 @@ goog.provide('ol.MapOptionsType');
|
|||||||
goog.provide('ol.RendererHint');
|
goog.provide('ol.RendererHint');
|
||||||
|
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
|
goog.require('ol.Constraints');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
|
goog.require('ol.ResolutionConstraint');
|
||||||
|
goog.require('ol.RotationConstraint');
|
||||||
goog.require('ol.interaction.AltDragRotate');
|
goog.require('ol.interaction.AltDragRotate');
|
||||||
goog.require('ol.interaction.CenterConstraint');
|
goog.require('ol.interaction.CenterConstraint');
|
||||||
goog.require('ol.interaction.Constraints');
|
|
||||||
goog.require('ol.interaction.DblClickZoom');
|
goog.require('ol.interaction.DblClickZoom');
|
||||||
goog.require('ol.interaction.DragPan');
|
goog.require('ol.interaction.DragPan');
|
||||||
goog.require('ol.interaction.KeyboardPan');
|
goog.require('ol.interaction.KeyboardPan');
|
||||||
goog.require('ol.interaction.KeyboardZoom');
|
goog.require('ol.interaction.KeyboardZoom');
|
||||||
goog.require('ol.interaction.MouseWheelZoom');
|
goog.require('ol.interaction.MouseWheelZoom');
|
||||||
goog.require('ol.interaction.ResolutionConstraint');
|
|
||||||
goog.require('ol.interaction.RotationConstraint');
|
|
||||||
goog.require('ol.interaction.ShiftDragZoom');
|
goog.require('ol.interaction.ShiftDragZoom');
|
||||||
goog.require('ol.renderer.Map');
|
goog.require('ol.renderer.Map');
|
||||||
goog.require('ol.renderer.dom');
|
goog.require('ol.renderer.dom');
|
||||||
@@ -152,7 +152,7 @@ ol.MapOptions.create = function(mapOptionsLiteral) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.interaction.Constraints}
|
* @type {ol.Constraints}
|
||||||
*/
|
*/
|
||||||
var constraints = ol.MapOptions.createConstraints_(mapOptionsLiteral);
|
var constraints = ol.MapOptions.createConstraints_(mapOptionsLiteral);
|
||||||
|
|
||||||
@@ -168,16 +168,14 @@ ol.MapOptions.create = function(mapOptionsLiteral) {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.MapOptionsLiteral} mapOptionsLiteral Map options literal.
|
* @param {ol.MapOptionsLiteral} mapOptionsLiteral Map options literal.
|
||||||
* @return {ol.interaction.Constraints} Map constraints.
|
* @return {ol.Constraints} Map constraints.
|
||||||
*/
|
*/
|
||||||
ol.MapOptions.createConstraints_ = function(mapOptionsLiteral) {
|
ol.MapOptions.createConstraints_ = function(mapOptionsLiteral) {
|
||||||
// FIXME this should be configurable
|
// FIXME this should be configurable
|
||||||
var resolutionConstraint =
|
var resolutionConstraint = ol.ResolutionConstraint.createSnapToPower(
|
||||||
ol.interaction.ResolutionConstraint.createSnapToPower(
|
Math.exp(Math.log(2) / 4), ol.Projection.EPSG_3857_HALF_SIZE / 128);
|
||||||
Math.exp(Math.log(2) / 4), ol.Projection.EPSG_3857_HALF_SIZE / 128);
|
var rotationConstraint = ol.RotationConstraint.none;
|
||||||
var rotationConstraint = ol.interaction.RotationConstraint.none;
|
return new ol.Constraints(resolutionConstraint, rotationConstraint);
|
||||||
return new ol.interaction.Constraints(
|
|
||||||
resolutionConstraint, rotationConstraint);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
goog.provide('ol.interaction.ResolutionConstraint');
|
goog.provide('ol.ResolutionConstraint');
|
||||||
goog.provide('ol.interaction.ResolutionConstraintType');
|
goog.provide('ol.ResolutionConstraintType');
|
||||||
|
|
||||||
goog.require('goog.math');
|
goog.require('goog.math');
|
||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
@@ -8,16 +8,16 @@ goog.require('ol.array');
|
|||||||
/**
|
/**
|
||||||
* @typedef {function((number|undefined), number): (number|undefined)}
|
* @typedef {function((number|undefined), number): (number|undefined)}
|
||||||
*/
|
*/
|
||||||
ol.interaction.ResolutionConstraintType;
|
ol.ResolutionConstraintType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} power Power.
|
* @param {number} power Power.
|
||||||
* @param {number} maxResolution Maximum resolution.
|
* @param {number} maxResolution Maximum resolution.
|
||||||
* @param {number=} opt_minResolution Minimum resolution.
|
* @param {number=} opt_minResolution Minimum resolution.
|
||||||
* @return {ol.interaction.ResolutionConstraintType} Zoom function.
|
* @return {ol.ResolutionConstraintType} Zoom function.
|
||||||
*/
|
*/
|
||||||
ol.interaction.ResolutionConstraint.createContinuous =
|
ol.ResolutionConstraint.createContinuous =
|
||||||
function(power, maxResolution, opt_minResolution) {
|
function(power, maxResolution, opt_minResolution) {
|
||||||
var minResolution = opt_minResolution || 0;
|
var minResolution = opt_minResolution || 0;
|
||||||
return function(resolution, delta) {
|
return function(resolution, delta) {
|
||||||
@@ -33,9 +33,9 @@ ol.interaction.ResolutionConstraint.createContinuous =
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array.<number>} resolutions Resolutions.
|
* @param {Array.<number>} resolutions Resolutions.
|
||||||
* @return {ol.interaction.ResolutionConstraintType} Zoom function.
|
* @return {ol.ResolutionConstraintType} Zoom function.
|
||||||
*/
|
*/
|
||||||
ol.interaction.ResolutionConstraint.createSnapToResolutions =
|
ol.ResolutionConstraint.createSnapToResolutions =
|
||||||
function(resolutions) {
|
function(resolutions) {
|
||||||
return function(resolution, delta) {
|
return function(resolution, delta) {
|
||||||
if (goog.isDef(resolution)) {
|
if (goog.isDef(resolution)) {
|
||||||
@@ -53,9 +53,9 @@ ol.interaction.ResolutionConstraint.createSnapToResolutions =
|
|||||||
* @param {number} power Power.
|
* @param {number} power Power.
|
||||||
* @param {number} maxResolution Maximum resolution.
|
* @param {number} maxResolution Maximum resolution.
|
||||||
* @param {number=} opt_maxLevel Maximum level.
|
* @param {number=} opt_maxLevel Maximum level.
|
||||||
* @return {ol.interaction.ResolutionConstraintType} Zoom function.
|
* @return {ol.ResolutionConstraintType} Zoom function.
|
||||||
*/
|
*/
|
||||||
ol.interaction.ResolutionConstraint.createSnapToPower =
|
ol.ResolutionConstraint.createSnapToPower =
|
||||||
function(power, maxResolution, opt_maxLevel) {
|
function(power, maxResolution, opt_maxLevel) {
|
||||||
return function(resolution, delta) {
|
return function(resolution, delta) {
|
||||||
if (goog.isDef(resolution)) {
|
if (goog.isDef(resolution)) {
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
goog.provide('ol.interaction.RotationConstraint');
|
goog.provide('ol.RotationConstraint');
|
||||||
goog.provide('ol.interaction.RotationConstraintType');
|
goog.provide('ol.RotationConstraintType');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {function((number|undefined), number): (number|undefined)}
|
* @typedef {function((number|undefined), number): (number|undefined)}
|
||||||
*/
|
*/
|
||||||
ol.interaction.RotationConstraintType;
|
ol.RotationConstraintType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,7 +13,7 @@ ol.interaction.RotationConstraintType;
|
|||||||
* @param {number} delta Delta.
|
* @param {number} delta Delta.
|
||||||
* @return {number|undefined} Rotation.
|
* @return {number|undefined} Rotation.
|
||||||
*/
|
*/
|
||||||
ol.interaction.RotationConstraint.none = function(rotation, delta) {
|
ol.RotationConstraint.none = function(rotation, delta) {
|
||||||
if (goog.isDef(rotation)) {
|
if (goog.isDef(rotation)) {
|
||||||
return rotation + delta;
|
return rotation + delta;
|
||||||
} else {
|
} else {
|
||||||
@@ -24,9 +24,9 @@ ol.interaction.RotationConstraint.none = function(rotation, delta) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} n N.
|
* @param {number} n N.
|
||||||
* @return {ol.interaction.RotationConstraintType} Rotation constraint.
|
* @return {ol.RotationConstraintType} Rotation constraint.
|
||||||
*/
|
*/
|
||||||
ol.interaction.RotationConstraint.createSnapToN = function(n) {
|
ol.RotationConstraint.createSnapToN = function(n) {
|
||||||
var theta = 2 * Math.PI / n;
|
var theta = 2 * Math.PI / n;
|
||||||
return function(rotation, delta) {
|
return function(rotation, delta) {
|
||||||
if (goog.isDef(rotation)) {
|
if (goog.isDef(rotation)) {
|
||||||
+1
-1
@@ -80,7 +80,7 @@
|
|||||||
<script type="text/javascript" src="spec/ol/rectangle.test.js"></script>
|
<script type="text/javascript" src="spec/ol/rectangle.test.js"></script>
|
||||||
<script type="text/javascript" src="spec/ol/tilerange.test.js"></script>
|
<script type="text/javascript" src="spec/ol/tilerange.test.js"></script>
|
||||||
<script type="text/javascript" src="spec/ol/tileurlfunction.test.js"></script>
|
<script type="text/javascript" src="spec/ol/tileurlfunction.test.js"></script>
|
||||||
<script type="text/javascript" src="spec/ol/interaction/resolutionconstraint.test.js"></script>
|
<script type="text/javascript" src="spec/ol/resolutionconstraint.test.js"></script>
|
||||||
<script type="text/javascript" src="spec/ol/layer/xyz.test.js"></script>
|
<script type="text/javascript" src="spec/ol/layer/xyz.test.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|||||||
+6
-6
@@ -1,4 +1,4 @@
|
|||||||
describe('ol.interaction.ResolutionConstraint', function() {
|
describe('ol.ResolutionConstraint', function() {
|
||||||
|
|
||||||
describe('SnapToResolution', function() {
|
describe('SnapToResolution', function() {
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ describe('ol.interaction.ResolutionConstraint', function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
resolutionConstraint =
|
resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToResolutions(
|
ol.ResolutionConstraint.createSnapToResolutions(
|
||||||
[1000, 500, 250, 100]);
|
[1000, 500, 250, 100]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ describe('ol.interaction.ResolutionConstraint', function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
resolutionConstraint =
|
resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToResolutions(
|
ol.ResolutionConstraint.createSnapToResolutions(
|
||||||
[1000, 500, 250, 100]);
|
[1000, 500, 250, 100]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ describe('ol.interaction.ResolutionConstraint', function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
resolutionConstraint =
|
resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToPower(2, 1024, 10);
|
ol.ResolutionConstraint.createSnapToPower(2, 1024, 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('delta 0', function() {
|
describe('delta 0', function() {
|
||||||
@@ -152,7 +152,7 @@ describe('ol.interaction.ResolutionConstraint', function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
resolutionConstraint =
|
resolutionConstraint =
|
||||||
ol.interaction.ResolutionConstraint.createSnapToPower(2, 1024, 10);
|
ol.ResolutionConstraint.createSnapToPower(2, 1024, 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('delta 0', function() {
|
describe('delta 0', function() {
|
||||||
@@ -184,4 +184,4 @@ describe('ol.interaction.ResolutionConstraint', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
goog.require('ol.interaction.ResolutionConstraint');
|
goog.require('ol.ResolutionConstraint');
|
||||||
Reference in New Issue
Block a user