Merge pull request #2030 from tschaub/defines

Move defines to ol namespace.
This commit is contained in:
Tim Schaub
2014-04-30 17:13:10 -06:00
31 changed files with 217 additions and 187 deletions

View File

@@ -2,76 +2,11 @@ goog.provide('ol.BrowserFeature');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.userAgent');
goog.require('ol');
goog.require('ol.dom');
goog.require('ol.webgl');
/**
* @define {boolean} Assume touch.
*/
ol.ASSUME_TOUCH = false;
/**
* @define {boolean} Whether to enable canvas.
*/
ol.ENABLE_CANVAS = true;
/**
* @define {boolean} Whether to enable DOM.
*/
ol.ENABLE_DOM = true;
/**
* @define {boolean} Whether to enable rendering of image layers.
*/
ol.ENABLE_IMAGE = true;
/**
* @define {boolean} Whether to enable rendering of tile layers.
*/
ol.ENABLE_TILE = true;
/**
* @define {boolean} Whether to enable rendering of vector layers.
*/
ol.ENABLE_VECTOR = true;
/**
* @define {boolean} Whether to enable WebGL.
*/
ol.ENABLE_WEBGL = true;
/**
* @define {boolean} Whether to support legacy IE (7-8).
*/
ol.LEGACY_IE_SUPPORT = false;
/**
* The page is loaded using HTTPS.
* @const
* @type {boolean}
*/
ol.IS_HTTPS = goog.global.location.protocol === 'https:';
/**
* Whether the current browser is legacy IE
* @const
* @type {boolean}
*/
ol.IS_LEGACY_IE = goog.userAgent.IE &&
!goog.userAgent.isVersionOrHigher('9.0') && goog.userAgent.VERSION !== '';
/**
* The ratio between physical pixels and device-independent pixels
* (dips) on the device (`window.devicePixelRatio`).

View File

@@ -11,14 +11,7 @@ goog.require('goog.color');
goog.require('goog.color.names');
goog.require('goog.math');
goog.require('goog.vec.Mat4');
/**
* @define {boolean} Enable named colors.
* Enabling named colors adds about 3KB uncompressed / 1.5KB compressed to the
* final build size.
*/
ol.color.ENABLE_NAMED_COLORS = true;
goog.require('ol');
/**
@@ -212,7 +205,7 @@ ol.color.fromString = (
ol.color.fromStringInternal_ = function(s) {
var isHex = false;
if (ol.color.ENABLE_NAMED_COLORS && goog.color.names.hasOwnProperty(s)) {
if (ol.ENABLE_NAMED_COLORS && goog.color.names.hasOwnProperty(s)) {
// goog.color.names does not have a type declaration, so add a typecast
s = /** @type {string} */ (goog.color.names[s]);
isHex = true;

View File

@@ -15,18 +15,13 @@ goog.require('goog.fx.Dragger.EventType');
goog.require('goog.math');
goog.require('goog.math.Rect');
goog.require('goog.style');
goog.require('ol');
goog.require('ol.animation');
goog.require('ol.control.Control');
goog.require('ol.css');
goog.require('ol.easing');
/**
* @define {number} Animation duration.
*/
ol.control.ZOOMSLIDER_ANIMATION_DURATION = 200;
/**
* A slider type of control for zooming.
@@ -190,7 +185,7 @@ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(browserEvent) {
goog.asserts.assert(goog.isDef(resolution));
map.beforeRender(ol.animation.zoom({
resolution: resolution,
duration: ol.control.ZOOMSLIDER_ANIMATION_DURATION,
duration: ol.ZOOMSLIDER_ANIMATION_DURATION,
easing: ol.easing.easeOut
}));
resolution = view.constrainResolution(resolution);
@@ -295,7 +290,7 @@ ol.control.ZoomSlider.prototype.handleSliderChange_ = function(e) {
goog.asserts.assert(goog.isDef(this.currentResolution_));
map.beforeRender(ol.animation.zoom({
resolution: this.currentResolution_,
duration: ol.control.ZOOMSLIDER_ANIMATION_DURATION,
duration: ol.ZOOMSLIDER_ANIMATION_DURATION,
easing: ol.easing.easeOut
}));
resolution = view.constrainResolution(this.currentResolution_);

View File

@@ -9,6 +9,7 @@ goog.require('goog.dom.TagName');
goog.require('goog.style');
goog.require('goog.userAgent');
goog.require('goog.vec.Mat4');
goog.require('ol');
/**

View File

@@ -7,18 +7,13 @@ goog.provide('ol.interaction.DragBox');
goog.require('goog.asserts');
goog.require('goog.events.Event');
goog.require('goog.functions');
goog.require('ol');
goog.require('ol.events.ConditionType');
goog.require('ol.events.condition');
goog.require('ol.interaction.Pointer');
goog.require('ol.render.Box');
/**
* @define {number} Hysterisis pixels.
*/
ol.DRAG_BOX_HYSTERESIS_PIXELS = 8;
/**
* @const
* @type {number}

View File

@@ -5,6 +5,7 @@ goog.provide('ol.interaction.DragRotateAndZoom');
goog.require('goog.asserts');
goog.require('goog.functions');
goog.require('goog.math.Vec2');
goog.require('ol');
goog.require('ol.ViewHint');
goog.require('ol.events.ConditionType');
goog.require('ol.events.condition');
@@ -12,12 +13,6 @@ goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer');
/**
* @define {number} Animation duration.
*/
ol.interaction.DRAGROTATEANDZOOM_ANIMATION_DURATION = 400;
/**
* Allows the user to zoom and rotate the map by clicking and dragging
@@ -125,7 +120,7 @@ ol.interaction.DragRotateAndZoom.prototype.handlePointerUp =
var direction = this.lastScaleDelta_ - 1;
ol.interaction.Interaction.rotate(map, view2D, view2DState.rotation);
ol.interaction.Interaction.zoom(map, view2D, view2DState.resolution,
undefined, ol.interaction.DRAGROTATEANDZOOM_ANIMATION_DURATION,
undefined, ol.DRAGROTATEANDZOOM_ANIMATION_DURATION,
direction);
this.lastScaleDelta_ = 0;
return false;

View File

@@ -1,6 +1,7 @@
goog.provide('ol.interaction.DragRotate');
goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.ViewHint');
goog.require('ol.events.ConditionType');
goog.require('ol.events.condition');
@@ -8,12 +9,6 @@ goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer');
/**
* @define {number} Animation duration.
*/
ol.interaction.DRAGROTATE_ANIMATION_DURATION = 250;
/**
* Allows the user to rotate the map by clicking and dragging on the map,
@@ -93,7 +88,7 @@ ol.interaction.DragRotate.prototype.handlePointerUp =
var view2D = view.getView2D();
var view2DState = view2D.getView2DState();
ol.interaction.Interaction.rotate(map, view2D, view2DState.rotation,
undefined, ol.interaction.DRAGROTATE_ANIMATION_DURATION);
undefined, ol.DRAGROTATE_ANIMATION_DURATION);
return false;
};

View File

@@ -1,6 +1,7 @@
goog.provide('ol.interaction.DragZoom');
goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.events.condition');
goog.require('ol.extent');
goog.require('ol.interaction.DragBox');
@@ -9,12 +10,6 @@ goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
/**
* @define {number} Animation duration.
*/
ol.interaction.DRAGZOOM_ANIMATION_DURATION = 200;
/**
* Allows the user to zoom the map by clicking and dragging on the map,
@@ -62,5 +57,5 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
var center = ol.extent.getCenter(extent);
ol.interaction.Interaction.zoom(map, view,
view.getResolutionForExtent(extent, map.getSize()),
center, ol.interaction.DRAGZOOM_ANIMATION_DURATION);
center, ol.DRAGZOOM_ANIMATION_DURATION);
};

View File

@@ -6,6 +6,7 @@ goog.require('goog.asserts');
goog.require('goog.events.KeyCodes');
goog.require('goog.events.KeyHandler.EventType');
goog.require('goog.functions');
goog.require('ol');
goog.require('ol.View2D');
goog.require('ol.coordinate');
goog.require('ol.events.ConditionType');
@@ -13,12 +14,6 @@ goog.require('ol.events.condition');
goog.require('ol.interaction.Interaction');
/**
* @define {number} Pan duration.
*/
ol.interaction.KEYBOARD_PAN_DURATION = 100;
/**
* Allows the user to pan the map using keyboard arrows.
@@ -93,7 +88,7 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
var delta = [deltaX, deltaY];
ol.coordinate.rotate(delta, view2DState.rotation);
ol.interaction.Interaction.pan(
map, view, delta, ol.interaction.KEYBOARD_PAN_DURATION);
map, view, delta, ol.KEYBOARD_PAN_DURATION);
mapBrowserEvent.preventDefault();
stopEvent = true;
}

View File

@@ -6,22 +6,11 @@ goog.require('goog.asserts');
goog.require('goog.events.MouseWheelEvent');
goog.require('goog.events.MouseWheelHandler.EventType');
goog.require('goog.math');
goog.require('ol');
goog.require('ol.Coordinate');
goog.require('ol.interaction.Interaction');
/**
* @define {number} Maximum delta.
*/
ol.interaction.MOUSEWHEELZOOM_MAXDELTA = 1;
/**
* @define {number} Timeout duration.
*/
ol.interaction.MOUSEWHEELZOOM_TIMEOUT_DURATION = 80;
/**
* Allows the user to zoom the map by scrolling the mouse wheel.
@@ -89,7 +78,7 @@ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent =
this.startTime_ = goog.now();
}
var duration = ol.interaction.MOUSEWHEELZOOM_TIMEOUT_DURATION;
var duration = ol.MOUSEWHEELZOOM_TIMEOUT_DURATION;
var timeLeft = Math.max(duration - (goog.now() - this.startTime_), 0);
goog.global.clearTimeout(this.timeoutId_);
@@ -108,7 +97,7 @@ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent =
* @param {ol.Map} map Map.
*/
ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) {
var maxDelta = ol.interaction.MOUSEWHEELZOOM_MAXDELTA;
var maxDelta = ol.MOUSEWHEELZOOM_MAXDELTA;
var delta = goog.math.clamp(this.delta_, -maxDelta, maxDelta);
// FIXME works for View2D only

View File

@@ -4,18 +4,13 @@ goog.provide('ol.interaction.PinchRotate');
goog.require('goog.asserts');
goog.require('goog.style');
goog.require('ol');
goog.require('ol.Coordinate');
goog.require('ol.ViewHint');
goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer');
/**
* @define {number} Animation duration.
*/
ol.interaction.ROTATE_ANIMATION_DURATION = 250;
/**
* Allows the user to rotate the map by twisting with two fingers
@@ -131,7 +126,7 @@ ol.interaction.PinchRotate.prototype.handlePointerUp =
var view2DState = view2D.getView2DState();
ol.interaction.Interaction.rotate(
map, view2D, view2DState.rotation, this.anchor_,
ol.interaction.ROTATE_ANIMATION_DURATION);
ol.ROTATE_ANIMATION_DURATION);
}
return false;
} else {

View File

@@ -10,6 +10,7 @@ goog.require('goog.events.BrowserEvent');
goog.require('goog.events.EventTarget');
goog.require('goog.events.EventType');
goog.require('goog.object');
goog.require('ol');
goog.require('ol.Coordinate');
goog.require('ol.MapEvent');
goog.require('ol.Pixel');

View File

@@ -1,9 +1,180 @@
goog.require('goog.userAgent');
goog.provide('ol');
/**
* @define {boolean} Assume touch.
*/
ol.ASSUME_TOUCH = false;
/**
* @define {boolean} Replace unused entries with NaNs.
*/
ol.BUFFER_REPLACE_UNUSED_ENTRIES_WITH_NANS = goog.DEBUG;
/**
* @define {number} Default maximum zoom for default tile grids.
*/
ol.DEFAULT_MAX_ZOOM = 42;
/**
* @define {number} Default high water mark.
*/
ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK = 2048;
/**
* @define {number} Default tile size.
*/
ol.DEFAULT_TILE_SIZE = 256;
/**
* @define {string} Default WMS version.
*/
ol.DEFAULT_WMS_VERSION = '1.3.0';
/**
* @define {number} Drag-rotate-zoom animation duration.
*/
ol.DRAGROTATEANDZOOM_ANIMATION_DURATION = 400;
/**
* @define {number} Drag-rotate animation duration.
*/
ol.DRAGROTATE_ANIMATION_DURATION = 250;
/**
* @define {number} Drag-zoom animation duration.
*/
ol.DRAGZOOM_ANIMATION_DURATION = 200;
/**
* @define {number} Hysterisis pixels.
*/
ol.DRAG_BOX_HYSTERESIS_PIXELS = 8;
/**
* @define {boolean} Whether to enable canvas.
*/
ol.ENABLE_CANVAS = true;
/**
* @define {boolean} Whether to enable DOM.
*/
ol.ENABLE_DOM = true;
/**
* @define {boolean} Whether to enable rendering of image layers.
*/
ol.ENABLE_IMAGE = true;
/**
* @define {boolean} Enable named colors.
* Enabling named colors adds about 3KB uncompressed / 1.5KB compressed to the
* final build size.
*/
ol.ENABLE_NAMED_COLORS = true;
/**
* @define {boolean} Enable Proj4js.
*/
ol.ENABLE_PROJ4JS = true;
/**
* @define {boolean} Whether to enable rendering of tile layers.
*/
ol.ENABLE_TILE = true;
/**
* @define {boolean} Whether to enable rendering of vector layers.
*/
ol.ENABLE_VECTOR = true;
/**
* @define {boolean} Whether to enable WebGL.
*/
ol.ENABLE_WEBGL = true;
/**
* @define {boolean} Whether to support legacy IE (7-8).
*/
ol.LEGACY_IE_SUPPORT = false;
/**
* The page is loaded using HTTPS.
* @const
* @type {boolean}
*/
ol.IS_HTTPS = goog.global.location.protocol === 'https:';
/**
* Whether the current browser is legacy IE
* @const
* @type {boolean}
*/
ol.IS_LEGACY_IE = goog.userAgent.IE &&
!goog.userAgent.isVersionOrHigher('9.0') && goog.userAgent.VERSION !== '';
/**
* @define {number} Keyboard pan duration.
*/
ol.KEYBOARD_PAN_DURATION = 100;
/**
* @define {number} Maximum mouse wheel delta.
*/
ol.MOUSEWHEELZOOM_MAXDELTA = 1;
/**
* @define {number} Mouse wheel timeout duration.
*/
ol.MOUSEWHEELZOOM_TIMEOUT_DURATION = 80;
/**
* @define {number} Rotate animation duration.
*/
ol.ROTATE_ANIMATION_DURATION = 250;
/**
* @define {number} Texture cache high water mark.
*/
ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024;
/**
* @define {number} Zoom slider animation duration.
*/
ol.ZOOMSLIDER_ANIMATION_DURATION = 200;
/**
* ol.inherits is an alias to the goog.inherits function. It is exported
* for use in non-compiled application code. See ol.exports.
* for use in non-compiled application code.
*
* FIXME: We use a new line to fake the linter. Without the new line the
* linter complains with:

View File

@@ -7,17 +7,12 @@ goog.provide('ol.proj.Units');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.object');
goog.require('ol');
goog.require('ol.Extent');
goog.require('ol.TransformFunction');
goog.require('ol.sphere.NORMAL');
/**
* @define {boolean} Enable Proj4js.
*/
ol.ENABLE_PROJ4JS = true;
/**
* Have Proj4js.
* @const

View File

@@ -6,6 +6,7 @@ goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.style');
goog.require('goog.vec.Mat4');
goog.require('ol');
goog.require('ol.css');
goog.require('ol.dom');
goog.require('ol.layer.Image');

View File

@@ -5,6 +5,7 @@ goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.functions');
goog.require('goog.style');
goog.require('ol');
goog.require('ol.css');
goog.require('ol.layer.Image');
goog.require('ol.layer.Tile');

View File

@@ -10,6 +10,7 @@ goog.require('goog.dom.TagName');
goog.require('goog.object');
goog.require('goog.style');
goog.require('goog.vec.Mat4');
goog.require('ol');
goog.require('ol.Coordinate');
goog.require('ol.Tile');
goog.require('ol.TileCoord');

View File

@@ -13,6 +13,7 @@ goog.require('goog.log.Logger');
goog.require('goog.object');
goog.require('goog.style');
goog.require('goog.webgl');
goog.require('ol');
goog.require('ol.Tile');
goog.require('ol.css');
goog.require('ol.dom');
@@ -33,12 +34,6 @@ goog.require('ol.webgl.Context');
goog.require('ol.webgl.WebGLContextEventType');
/**
* @define {number} Texture cache high water mark.
*/
ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024;
/**
* @typedef {{magFilter: number, minFilter: number, texture: WebGLTexture}}
*/

View File

@@ -4,6 +4,7 @@ goog.require('goog.Uri');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.net.Jsonp');
goog.require('ol');
goog.require('ol.Attribution');
goog.require('ol.TileRange');
goog.require('ol.TileUrlFunction');

View File

@@ -6,6 +6,7 @@ goog.require('goog.asserts');
goog.require('goog.object');
goog.require('goog.string');
goog.require('goog.uri.utils');
goog.require('ol');
goog.require('ol.Image');
goog.require('ol.extent');
goog.require('ol.proj');
@@ -150,7 +151,7 @@ ol.source.ImageWMS.prototype.getGetFeatureInfoUrl =
var baseParams = {
'SERVICE': 'WMS',
'VERSION': ol.source.wms.DEFAULT_VERSION,
'VERSION': ol.DEFAULT_WMS_VERSION,
'REQUEST': 'GetFeatureInfo',
'FORMAT': 'image/png',
'TRANSPARENT': true,
@@ -208,7 +209,7 @@ ol.source.ImageWMS.prototype.getImage =
var params = {
'SERVICE': 'WMS',
'VERSION': ol.source.wms.DEFAULT_VERSION,
'VERSION': ol.DEFAULT_WMS_VERSION,
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': true
@@ -355,6 +356,6 @@ ol.source.ImageWMS.prototype.updateParams = function(params) {
*/
ol.source.ImageWMS.prototype.updateV13_ = function() {
var version =
goog.object.get(this.params_, 'VERSION', ol.source.wms.DEFAULT_VERSION);
goog.object.get(this.params_, 'VERSION', ol.DEFAULT_WMS_VERSION);
this.v13_ = goog.string.compareVersions(version, '1.3') >= 0;
};

View File

@@ -1,6 +1,7 @@
goog.provide('ol.source.MapQuest');
goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.Attribution');
goog.require('ol.source.OSM');
goog.require('ol.source.XYZ');

View File

@@ -1,5 +1,6 @@
goog.provide('ol.source.OSM');
goog.require('ol');
goog.require('ol.Attribution');
goog.require('ol.source.XYZ');

View File

@@ -1,6 +1,7 @@
goog.provide('ol.source.Stamen');
goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.Attribution');
goog.require('ol.source.OSM');
goog.require('ol.source.XYZ');

View File

@@ -10,6 +10,7 @@ goog.require('goog.math');
goog.require('goog.object');
goog.require('goog.string');
goog.require('goog.uri.utils');
goog.require('ol');
goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction');
goog.require('ol.extent');
@@ -165,7 +166,7 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl =
var baseParams = {
'SERVICE': 'WMS',
'VERSION': ol.source.wms.DEFAULT_VERSION,
'VERSION': ol.DEFAULT_WMS_VERSION,
'REQUEST': 'GetFeatureInfo',
'FORMAT': 'image/png',
'TRANSPARENT': true,
@@ -373,7 +374,7 @@ ol.source.TileWMS.prototype.tileUrlFunction_ =
var baseParams = {
'SERVICE': 'WMS',
'VERSION': ol.source.wms.DEFAULT_VERSION,
'VERSION': ol.DEFAULT_WMS_VERSION,
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': true
@@ -405,6 +406,6 @@ ol.source.TileWMS.prototype.updateParams = function(params) {
*/
ol.source.TileWMS.prototype.updateV13_ = function() {
var version =
goog.object.get(this.params_, 'VERSION', ol.source.wms.DEFAULT_VERSION);
goog.object.get(this.params_, 'VERSION', ol.DEFAULT_WMS_VERSION);
this.v13_ = goog.string.compareVersions(version, '1.3') >= 0;
};

View File

@@ -2,12 +2,6 @@ goog.provide('ol.source.wms');
goog.provide('ol.source.wms.ServerType');
/**
* @define {string} WMS default version.
*/
ol.source.wms.DEFAULT_VERSION = '1.3.0';
/**
* @enum {string}
*/

View File

@@ -2,6 +2,7 @@ goog.provide('ol.source.Zoomify');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.ImageTile');
goog.require('ol.TileCoord');
goog.require('ol.TileState');

View File

@@ -3,6 +3,7 @@ goog.provide('ol.structs.Buffer');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.webgl');
goog.require('ol');
goog.require('ol.structs.IntegerSet');
@@ -16,12 +17,6 @@ ol.structs.BufferUsage = {
};
/**
* @define {boolean} Replace unused entries with NaNs.
*/
ol.BUFFER_REPLACE_UNUSED_ENTRIES_WITH_NANS = goog.DEBUG;
/**
* @constructor

View File

@@ -1,18 +1,13 @@
goog.provide('ol.TileCache');
goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.Tile');
goog.require('ol.TileCoord');
goog.require('ol.TileRange');
goog.require('ol.structs.LRUCache');
/**
* @define {number} Default high water mark.
*/
ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK = 2048;
/**
* @constructor

View File

@@ -2,6 +2,7 @@ goog.provide('ol.tilegrid.TileGrid');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.Coordinate');
goog.require('ol.TileCoord');
goog.require('ol.TileRange');
@@ -12,18 +13,6 @@ goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');
/**
* @define {number} Default tile size.
*/
ol.DEFAULT_TILE_SIZE = 256;
/**
* @define {number} Default maximum zoom for default tile grids.
*/
ol.DEFAULT_MAX_ZOOM = 42;
/**
* @constructor

View File

@@ -1,6 +1,7 @@
goog.provide('ol.tilegrid.XYZ');
goog.require('goog.math');
goog.require('ol');
goog.require('ol.TileCoord');
goog.require('ol.TileRange');
goog.require('ol.proj');

View File

@@ -4,6 +4,7 @@ goog.provide('ol.View2D');
goog.provide('ol.View2DProperty');
goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.CenterConstraint');
goog.require('ol.Constraints');
goog.require('ol.IView2D');