Use named exports from ol/index.js

This commit is contained in:
Tim Schaub
2017-12-12 10:24:58 -07:00
parent fce644556b
commit 87295a74dd
250 changed files with 874 additions and 887 deletions

View File

@@ -1,7 +1,8 @@
/**
* @module ol/index
*/
var _ol_ = {};
import webgl from './webgl.js';
/**
@@ -12,168 +13,164 @@ var _ol_ = {};
/**
* @define {boolean} Assume touch. Default is `false`.
* @type {boolean} Assume touch. Default is `false`.
*/
_ol_.ASSUME_TOUCH = false;
export var ASSUME_TOUCH = false;
/**
* TODO: rename this to something having to do with tile grids
* see https://github.com/openlayers/openlayers/issues/2076
* @define {number} Default maximum zoom for default tile grids.
* @type {number} Default maximum zoom for default tile grids.
*/
_ol_.DEFAULT_MAX_ZOOM = 42;
export var DEFAULT_MAX_ZOOM = 42;
/**
* @define {number} Default min zoom level for the map view. Default is `0`.
* @type {number} Default min zoom level for the map view. Default is `0`.
*/
_ol_.DEFAULT_MIN_ZOOM = 0;
export var DEFAULT_MIN_ZOOM = 0;
/**
* @define {number} Default maximum allowed threshold (in pixels) for
* @type {number} Default maximum allowed threshold (in pixels) for
* reprojection triangulation. Default is `0.5`.
*/
_ol_.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD = 0.5;
export var DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD = 0.5;
/**
* @define {number} Default tile size.
* @type {number} Default tile size.
*/
_ol_.DEFAULT_TILE_SIZE = 256;
export var DEFAULT_TILE_SIZE = 256;
/**
* @define {string} Default WMS version.
* @type {string} Default WMS version.
*/
_ol_.DEFAULT_WMS_VERSION = '1.3.0';
export var DEFAULT_WMS_VERSION = '1.3.0';
/**
* @define {boolean} Enable the Canvas renderer. Default is `true`. Setting
* @type {boolean} Enable the Canvas renderer. Default is `true`. Setting
* this to false at compile time in advanced mode removes all code
* supporting the Canvas renderer from the build.
*/
_ol_.ENABLE_CANVAS = true;
export var ENABLE_CANVAS = true;
/**
* @define {boolean} Enable integration with the Proj4js library. Default is
* @type {boolean} Enable integration with the Proj4js library. Default is
* `true`.
*/
_ol_.ENABLE_PROJ4JS = true;
export var ENABLE_PROJ4JS = true;
/**
* @define {boolean} Enable automatic reprojection of raster sources. Default is
* @type {boolean} Enable automatic reprojection of raster sources. Default is
* `true`.
*/
_ol_.ENABLE_RASTER_REPROJECTION = true;
export var ENABLE_RASTER_REPROJECTION = true;
/**
* @define {boolean} Enable the WebGL renderer. Default is `true`. Setting
* @type {boolean} Enable the WebGL renderer. Default is `true`. Setting
* this to false at compile time in advanced mode removes all code
* supporting the WebGL renderer from the build.
*/
_ol_.ENABLE_WEBGL = true;
export var ENABLE_WEBGL = true;
/**
* @define {boolean} Include debuggable shader sources. Default is `true`.
* This should be set to `false` for production builds (if `ol.ENABLE_WEBGL`
* @type {boolean} Include debuggable shader sources. Default is `true`.
* This should be set to `false` for production builds (if `ENABLE_WEBGL`
* is `true`).
*/
_ol_.DEBUG_WEBGL = true;
export var DEBUG_WEBGL = true;
/**
* @define {number} The size in pixels of the first atlas image. Default is
* TODO: get rid of this or move it to AtlasManager.js
* @type {number} The size in pixels of the first atlas image. Default is
* `256`.
*/
_ol_.INITIAL_ATLAS_SIZE = 256;
export var INITIAL_ATLAS_SIZE = 256;
/**
* @define {number} The maximum size in pixels of atlas images. Default is
* `-1`, meaning it is not used (and `ol.WEBGL_MAX_TEXTURE_SIZE` is
* TODO: get rid of this or move it to AtlasManager.js
* @type {number} The maximum size in pixels of atlas images. Default is
* `-1`, meaning it is not used (and `WEBGL_MAX_TEXTURE_SIZE` is
* used instead).
*/
_ol_.MAX_ATLAS_SIZE = -1;
export var MAX_ATLAS_SIZE = -1;
/**
* @define {number} Maximum mouse wheel delta.
* TODO: move this to MouseWheelZoom.js
* @type {number} Maximum mouse wheel delta.
*/
_ol_.MOUSEWHEELZOOM_MAXDELTA = 1;
export var MOUSEWHEELZOOM_MAXDELTA = 1;
/**
* @define {number} Maximum width and/or height extent ratio that determines
* TODO: move this to OverviewMap.js
* @type {number} Maximum width and/or height extent ratio that determines
* when the overview map should be zoomed out.
*/
_ol_.OVERVIEWMAP_MAX_RATIO = 0.75;
export var OVERVIEWMAP_MAX_RATIO = 0.75;
/**
* @define {number} Minimum width and/or height extent ratio that determines
* TODO: move this to OverviewMap.js
* @type {number} Minimum width and/or height extent ratio that determines
* when the overview map should be zoomed in.
*/
_ol_.OVERVIEWMAP_MIN_RATIO = 0.1;
export var OVERVIEWMAP_MIN_RATIO = 0.1;
/**
* @define {number} Maximum number of source tiles for raster reprojection of
* a single tile.
* If too many source tiles are determined to be loaded to create a single
* reprojected tile the browser can become unresponsive or even crash.
* This can happen if the developer defines projections improperly and/or
* with unlimited extents.
* If too many tiles are required, no tiles are loaded and
* `ol.TileState.ERROR` state is set. Default is `100`.
*/
_ol_.RASTER_REPROJECTION_MAX_SOURCE_TILES = 100;
/**
* @define {number} Maximum number of subdivision steps during raster
* TODO: move this to Triangulation.js
* @type {number} Maximum number of subdivision steps during raster
* reprojection triangulation. Prevents high memory usage and large
* number of proj4 calls (for certain transformations and areas).
* At most `2*(2^this)` triangles are created for each triangulated
* extent (tile/image). Default is `10`.
*/
_ol_.RASTER_REPROJECTION_MAX_SUBDIVISION = 10;
export var RASTER_REPROJECTION_MAX_SUBDIVISION = 10;
/**
* @define {number} Maximum allowed size of triangle relative to world width.
* TODO: move this to Triangulation.js
* @type {number} Maximum allowed size of triangle relative to world width.
* When transforming corners of world extent between certain projections,
* the resulting triangulation seems to have zero error and no subdivision
* is performed.
* If the triangle width is more than this (relative to world width; 0-1),
* subdivison is forced (up to `ol.RASTER_REPROJECTION_MAX_SUBDIVISION`).
* subdivison is forced (up to `RASTER_REPROJECTION_MAX_SUBDIVISION`).
* Default is `0.25`.
*/
_ol_.RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH = 0.25;
export var RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH = 0.25;
/**
* @define {number} Tolerance for geometry simplification in device pixels.
* TODO: move this to renderer/vector.js
* @type {number} Tolerance for geometry simplification in device pixels.
*/
_ol_.SIMPLIFY_TOLERANCE = 0.5;
export var SIMPLIFY_TOLERANCE = 0.5;
/**
* @define {number} Texture cache high water mark.
* TODO: move this to webgl/Map.js
* @type {number} Texture cache high water mark.
*/
_ol_.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024;
export var WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024;
/**
* @define {string} OpenLayers version.
* @type {string} OpenLayers version.
*/
_ol_.VERSION = 'v4.6.4';
export var VERSION = 'v4.6.4';
/**
@@ -182,7 +179,7 @@ _ol_.VERSION = 'v4.6.4';
* @const
* @type {number|undefined}
*/
_ol_.WEBGL_MAX_TEXTURE_SIZE; // value is set in `ol.has`
var WEBGL_MAX_TEXTURE_SIZE; // value is set below
/**
@@ -190,7 +187,33 @@ _ol_.WEBGL_MAX_TEXTURE_SIZE; // value is set in `ol.has`
* @const
* @type {Array.<string>}
*/
_ol_.WEBGL_EXTENSIONS; // value is set in `ol.has`
var WEBGL_EXTENSIONS; // value is set below
/**
* WebGL is available.
* @type {boolean}
*/
var HAS_WEBGL = false;
if (ENABLE_WEBGL && 'WebGLRenderingContext' in window) {
try {
var canvas = /** @type {HTMLCanvasElement} */
(document.createElement('CANVAS'));
var gl = webgl.getContext(canvas, {failIfMajorPerformanceCaveat: true});
if (gl) {
HAS_WEBGL = true;
WEBGL_MAX_TEXTURE_SIZE = /** @type {number} */
(gl.getParameter(gl.MAX_TEXTURE_SIZE));
WEBGL_EXTENSIONS = gl.getSupportedExtensions();
}
} catch (e) {
// pass
}
}
export {HAS_WEBGL, WEBGL_MAX_TEXTURE_SIZE, WEBGL_EXTENSIONS};
/**
@@ -205,7 +228,7 @@ _ol_.WEBGL_EXTENSIONS; // value is set in `ol.has`
* // Call parent constructor
* ParentClass.call(this, a, b);
* }
* ol.inherits(ChildClass, ParentClass);
* inherits(ChildClass, ParentClass);
*
* var child = new ChildClass('a', 'b', 'see');
* child.foo(); // This works.
@@ -215,10 +238,10 @@ _ol_.WEBGL_EXTENSIONS; // value is set in `ol.has`
* @function
* @api
*/
_ol_.inherits = function(childCtor, parentCtor) {
export function inherits(childCtor, parentCtor) {
childCtor.prototype = Object.create(parentCtor.prototype);
childCtor.prototype.constructor = childCtor;
};
}
/**
@@ -226,9 +249,16 @@ _ol_.inherits = function(childCtor, parentCtor) {
*
* @return {undefined} Nothing.
*/
_ol_.nullFunction = function() {};
export function nullFunction() {}
/**
* Counter for getUid.
* @type {number}
* @private
*/
var uidCounter_ = 0;
/**
* Gets a unique ID for an object. This mutates the object so that further calls
* with the same object as a parameter returns the same value. Unique IDs are generated
@@ -237,16 +267,37 @@ _ol_.nullFunction = function() {};
* @param {Object} obj The object to get the unique ID for.
* @return {number} The unique ID for the object.
*/
_ol_.getUid = function(obj) {
return obj.ol_uid ||
(obj.ol_uid = ++_ol_.uidCounter_);
export function getUid(obj) {
return obj.ol_uid || (obj.ol_uid = ++uidCounter_);
}
export default {
getUid: getUid,
nullFunction: nullFunction,
inherits: inherits,
VERSION: VERSION,
ASSUME_TOUCH: ASSUME_TOUCH,
DEFAULT_MAX_ZOOM: DEFAULT_MAX_ZOOM,
DEFAULT_MIN_ZOOM: DEFAULT_MIN_ZOOM,
DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD: DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD,
DEFAULT_TILE_SIZE: DEFAULT_TILE_SIZE,
DEFAULT_WMS_VERSION: DEFAULT_WMS_VERSION,
ENABLE_CANVAS: ENABLE_CANVAS,
ENABLE_PROJ4JS: ENABLE_PROJ4JS,
ENABLE_RASTER_REPROJECTION: ENABLE_RASTER_REPROJECTION,
ENABLE_WEBGL: ENABLE_WEBGL,
DEBUG_WEBGL: DEBUG_WEBGL,
INITIAL_ATLAS_SIZE: INITIAL_ATLAS_SIZE,
MAX_ATLAS_SIZE: MAX_ATLAS_SIZE,
MOUSEWHEELZOOM_MAXDELTA: MOUSEWHEELZOOM_MAXDELTA,
OVERVIEWMAP_MAX_RATIO: OVERVIEWMAP_MAX_RATIO,
OVERVIEWMAP_MIN_RATIO: OVERVIEWMAP_MIN_RATIO,
RASTER_REPROJECTION_MAX_SUBDIVISION: RASTER_REPROJECTION_MAX_SUBDIVISION,
RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH: RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH,
SIMPLIFY_TOLERANCE: SIMPLIFY_TOLERANCE,
HAS_WEBGL: HAS_WEBGL,
WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK: WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK,
WEBGL_MAX_TEXTURE_SIZE: WEBGL_MAX_TEXTURE_SIZE,
WEBGL_EXTENSIONS: WEBGL_EXTENSIONS
};
/**
* Counter for getUid.
* @type {number}
* @private
*/
_ol_.uidCounter_ = 0;
export default _ol_;