From f2752eb01eb10bc8be99f9e7f32aaa6524041107 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 16:15:10 -0700 Subject: [PATCH 01/16] Common tilegrid exports --- externs/olx.js | 2 +- src/ol/View.js | 3 ++- src/ol/index.js | 16 ---------------- src/ol/source/Zoomify.js | 3 ++- src/ol/tilegrid.js | 2 +- src/ol/tilegrid/TileGrid.js | 2 +- src/ol/tilegrid/common.js | 9 +++++++++ test/spec/ol/source/zoomify.test.js | 2 +- test/spec/ol/tilegrid/tilegrid.test.js | 2 +- 9 files changed, 18 insertions(+), 23 deletions(-) create mode 100644 src/ol/tilegrid/common.js diff --git a/externs/olx.js b/externs/olx.js index 65bcf571c9..f2ecf7e07f 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -7443,7 +7443,7 @@ olx.source.ZoomifyOptions.prototype.transition; /** * Tile size. Same tile size is used for all zoom levels. Default value is - * `OpenLayers.DEFAULT_TILE_SIZE`. + * `256`. * @type {number|undefined} * @api */ diff --git a/src/ol/View.js b/src/ol/View.js index 88212a3699..9e90ae780d 100644 --- a/src/ol/View.js +++ b/src/ol/View.js @@ -1,7 +1,8 @@ /** * @module ol/View */ -import {DEFAULT_MIN_ZOOM, DEFAULT_TILE_SIZE, inherits, getUid, nullFunction} from './index.js'; +import {DEFAULT_TILE_SIZE} from './tilegrid/common.js'; +import {DEFAULT_MIN_ZOOM, inherits, getUid, nullFunction} from './index.js'; import _ol_CenterConstraint_ from './CenterConstraint.js'; import _ol_Object_ from './Object.js'; import _ol_ResolutionConstraint_ from './ResolutionConstraint.js'; diff --git a/src/ol/index.js b/src/ol/index.js index 5c04cec288..2f787fd606 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -18,14 +18,6 @@ import webgl from './webgl.js'; export var ASSUME_TOUCH = false; -/** - * TODO: rename this to something having to do with tile grids - * see https://github.com/openlayers/openlayers/issues/2076 - * @type {number} Default maximum zoom for default tile grids. - */ -export var DEFAULT_MAX_ZOOM = 42; - - /** * @type {number} Default min zoom level for the map view. Default is `0`. */ @@ -39,12 +31,6 @@ export var DEFAULT_MIN_ZOOM = 0; export var DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD = 0.5; -/** - * @type {number} Default tile size. - */ -export var DEFAULT_TILE_SIZE = 256; - - /** * @type {string} Default WMS version. */ @@ -278,10 +264,8 @@ export default { 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, diff --git a/src/ol/source/Zoomify.js b/src/ol/source/Zoomify.js index d9e1179252..807fa0fd55 100644 --- a/src/ol/source/Zoomify.js +++ b/src/ol/source/Zoomify.js @@ -1,7 +1,8 @@ /** * @module ol/source/Zoomify */ -import {DEFAULT_TILE_SIZE, inherits} from '../index.js'; +import {DEFAULT_TILE_SIZE} from '../tilegrid/common.js'; +import {inherits} from '../index.js'; import _ol_ImageTile_ from '../ImageTile.js'; import _ol_TileState_ from '../TileState.js'; import _ol_TileUrlFunction_ from '../TileUrlFunction.js'; diff --git a/src/ol/tilegrid.js b/src/ol/tilegrid.js index 30fcb5fd11..4c9e7ba0e6 100644 --- a/src/ol/tilegrid.js +++ b/src/ol/tilegrid.js @@ -1,7 +1,7 @@ /** * @module ol/tilegrid */ -import {DEFAULT_MAX_ZOOM, DEFAULT_TILE_SIZE} from './index.js'; +import {DEFAULT_MAX_ZOOM, DEFAULT_TILE_SIZE} from './tilegrid/common.js'; import _ol_size_ from './size.js'; import _ol_extent_ from './extent.js'; import _ol_extent_Corner_ from './extent/Corner.js'; diff --git a/src/ol/tilegrid/TileGrid.js b/src/ol/tilegrid/TileGrid.js index e57728e603..edab2d53de 100644 --- a/src/ol/tilegrid/TileGrid.js +++ b/src/ol/tilegrid/TileGrid.js @@ -1,7 +1,7 @@ /** * @module ol/tilegrid/TileGrid */ -import {DEFAULT_TILE_SIZE} from '../index.js'; +import {DEFAULT_TILE_SIZE} from './common.js'; import _ol_asserts_ from '../asserts.js'; import _ol_TileRange_ from '../TileRange.js'; import _ol_array_ from '../array.js'; diff --git a/src/ol/tilegrid/common.js b/src/ol/tilegrid/common.js new file mode 100644 index 0000000000..e003fba738 --- /dev/null +++ b/src/ol/tilegrid/common.js @@ -0,0 +1,9 @@ +/** + * @type {number} Default maximum zoom for default tile grids. + */ +export var DEFAULT_MAX_ZOOM = 42; + +/** + * @type {number} Default tile size. + */ +export var DEFAULT_TILE_SIZE = 256; diff --git a/test/spec/ol/source/zoomify.test.js b/test/spec/ol/source/zoomify.test.js index 3d21657ca7..a6b7d364b3 100644 --- a/test/spec/ol/source/zoomify.test.js +++ b/test/spec/ol/source/zoomify.test.js @@ -1,4 +1,4 @@ -import {DEFAULT_TILE_SIZE} from '../../../../src/ol/index.js'; +import {DEFAULT_TILE_SIZE} from '../../../../src/ol/tilegrid/common.js'; import _ol_events_ from '../../../../src/ol/events.js'; import _ol_proj_Projection_ from '../../../../src/ol/proj/Projection.js'; import _ol_source_Zoomify_ from '../../../../src/ol/source/Zoomify.js'; diff --git a/test/spec/ol/tilegrid/tilegrid.test.js b/test/spec/ol/tilegrid/tilegrid.test.js index 346c9d8b95..86a6bf3886 100644 --- a/test/spec/ol/tilegrid/tilegrid.test.js +++ b/test/spec/ol/tilegrid/tilegrid.test.js @@ -1,4 +1,4 @@ -import {DEFAULT_MAX_ZOOM, DEFAULT_TILE_SIZE} from '../../../../src/ol/index.js'; +import {DEFAULT_MAX_ZOOM, DEFAULT_TILE_SIZE} from '../../../../src/ol/tilegrid/common.js'; import _ol_TileRange_ from '../../../../src/ol/TileRange.js'; import _ol_extent_ from '../../../../src/ol/extent.js'; import _ol_proj_ from '../../../../src/ol/proj.js'; From c40d9634bb67364e7016aa370be454f4f39d6ae3 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 16:18:36 -0700 Subject: [PATCH 02/16] Move DEFAULT_MIN_ZOOM to the one place it is used --- src/ol/View.js | 9 ++++++++- src/ol/index.js | 7 ------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ol/View.js b/src/ol/View.js index 9e90ae780d..6d1bbe8eb4 100644 --- a/src/ol/View.js +++ b/src/ol/View.js @@ -2,7 +2,7 @@ * @module ol/View */ import {DEFAULT_TILE_SIZE} from './tilegrid/common.js'; -import {DEFAULT_MIN_ZOOM, inherits, getUid, nullFunction} from './index.js'; +import {inherits, getUid, nullFunction} from './index.js'; import _ol_CenterConstraint_ from './CenterConstraint.js'; import _ol_Object_ from './Object.js'; import _ol_ResolutionConstraint_ from './ResolutionConstraint.js'; @@ -22,6 +22,13 @@ import _ol_obj_ from './obj.js'; import _ol_proj_ from './proj.js'; import _ol_proj_Units_ from './proj/Units.js'; + +/** + * @type {number} Default min zoom level for the map view. + */ +var DEFAULT_MIN_ZOOM = 0; + + /** * @classdesc * An ol.View object represents a simple 2D view of the map. diff --git a/src/ol/index.js b/src/ol/index.js index 2f787fd606..ac155f5e52 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -18,12 +18,6 @@ import webgl from './webgl.js'; export var ASSUME_TOUCH = false; -/** - * @type {number} Default min zoom level for the map view. Default is `0`. - */ -export var DEFAULT_MIN_ZOOM = 0; - - /** * @type {number} Default maximum allowed threshold (in pixels) for * reprojection triangulation. Default is `0.5`. @@ -264,7 +258,6 @@ export default { inherits: inherits, VERSION: VERSION, ASSUME_TOUCH: ASSUME_TOUCH, - DEFAULT_MIN_ZOOM: DEFAULT_MIN_ZOOM, DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD: DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD, DEFAULT_WMS_VERSION: DEFAULT_WMS_VERSION, ENABLE_CANVAS: ENABLE_CANVAS, From 6afd7b47832ac7bd2b6f0c6fdfbff3ff6df66d60 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 16:24:53 -0700 Subject: [PATCH 03/16] Move things specific to the atlas manager to AtlasManager.js --- externs/olx.js | 10 +++------- src/ol/index.js | 26 -------------------------- src/ol/style/AtlasManager.js | 14 +++++++++++++- 3 files changed, 16 insertions(+), 34 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index f2ecf7e07f..f1e2320d35 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -8612,8 +8612,7 @@ olx.style.AtlasManagerOptions; /** - * The size in pixels of the first atlas image. If no value is given the - * `ol.INITIAL_ATLAS_SIZE` compile-time constant will be used. + * The size in pixels of the first atlas image. Default is `256`. * @type {number|undefined} * @api */ @@ -8621,11 +8620,8 @@ olx.style.AtlasManagerOptions.prototype.initialSize; /** - * The maximum size in pixels of atlas images. If no value is given then - * the `ol.MAX_ATLAS_SIZE` compile-time constant will be used. And if - * `ol.MAX_ATLAS_SIZE` is set to `-1` (the default) then - * `ol.WEBGL_MAX_TEXTURE_SIZE` will used if WebGL is supported. Otherwise - * 2048 is used. + * The maximum size in pixels of atlas images. Default is + * `WEBGL_MAX_TEXTURE_SIZE` or 2048 if WebGL is not supported. * @type {number|undefined} * @api */ diff --git a/src/ol/index.js b/src/ol/index.js index ac155f5e52..b434e49c42 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -5,13 +5,6 @@ import webgl from './webgl.js'; -/** - * Constants defined with the define tag cannot be changed in application - * code, but can be set at compile time. - * Some reduce the size of the build in advanced compile mode. - */ - - /** * @type {boolean} Assume touch. Default is `false`. */ @@ -69,23 +62,6 @@ export var ENABLE_WEBGL = true; export var DEBUG_WEBGL = true; -/** - * 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`. - */ -export var INITIAL_ATLAS_SIZE = 256; - - -/** - * 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). - */ -export var MAX_ATLAS_SIZE = -1; - - /** * TODO: move this to MouseWheelZoom.js * @type {number} Maximum mouse wheel delta. @@ -265,8 +241,6 @@ export default { 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, diff --git a/src/ol/style/AtlasManager.js b/src/ol/style/AtlasManager.js index 26b01aeaeb..9d67ff1a2d 100644 --- a/src/ol/style/AtlasManager.js +++ b/src/ol/style/AtlasManager.js @@ -1,9 +1,21 @@ /** * @module ol/style/AtlasManager */ -import {INITIAL_ATLAS_SIZE, MAX_ATLAS_SIZE, WEBGL_MAX_TEXTURE_SIZE, nullFunction} from '../index.js'; +import {WEBGL_MAX_TEXTURE_SIZE, nullFunction} from '../index.js'; import _ol_style_Atlas_ from '../style/Atlas.js'; + +/** + * @type {number} The size in pixels of the first atlas image. + */ +var INITIAL_ATLAS_SIZE = 256; + +/** + * @type {number} The maximum size in pixels of atlas images. + */ +var MAX_ATLAS_SIZE = -1; + + /** * Manages the creation of image atlases. * From 7725bc37bc53566aa2af3e5755c6f23d3835e0fe Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 16:27:13 -0700 Subject: [PATCH 04/16] Move WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK to the WebGL map renderer --- src/ol/index.js | 8 -------- src/ol/renderer/webgl/Map.js | 10 ++++++++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/ol/index.js b/src/ol/index.js index b434e49c42..746e7f26f0 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -116,13 +116,6 @@ export var RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH = 0.25; export var SIMPLIFY_TOLERANCE = 0.5; -/** - * TODO: move this to webgl/Map.js - * @type {number} Texture cache high water mark. - */ -export var WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024; - - /** * @type {string} OpenLayers version. */ @@ -248,7 +241,6 @@ export default { 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 }; diff --git a/src/ol/renderer/webgl/Map.js b/src/ol/renderer/webgl/Map.js index 7515e47673..642eb73d06 100644 --- a/src/ol/renderer/webgl/Map.js +++ b/src/ol/renderer/webgl/Map.js @@ -1,9 +1,8 @@ /** * @module ol/renderer/webgl/Map */ -// FIXME check against gl.getParameter(webgl.MAX_TEXTURE_SIZE) -import {WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK, inherits} from '../../index.js'; +import {inherits} from '../../index.js'; import _ol_array_ from '../../array.js'; import _ol_css_ from '../../css.js'; import _ol_dom_ from '../../dom.js'; @@ -22,6 +21,13 @@ import _ol_webgl_ from '../../webgl.js'; import _ol_webgl_Context_ from '../../webgl/Context.js'; import _ol_webgl_ContextEventType_ from '../../webgl/ContextEventType.js'; + +/** + * @type {number} Texture cache high water mark. + */ +var WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024; + + /** * @constructor * @extends {ol.renderer.Map} From 34c132a67e7dcfe9928e5863169a0c19aee240e3 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 16:29:31 -0700 Subject: [PATCH 05/16] Move MOUSEWHEELZOOM_MAXDELTA to the mouse wheel zoom interaction --- src/ol/index.js | 8 -------- src/ol/interaction/MouseWheelZoom.js | 11 +++++++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ol/index.js b/src/ol/index.js index 746e7f26f0..7fedbfe2cb 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -62,13 +62,6 @@ export var ENABLE_WEBGL = true; export var DEBUG_WEBGL = true; -/** - * TODO: move this to MouseWheelZoom.js - * @type {number} Maximum mouse wheel delta. - */ -export var MOUSEWHEELZOOM_MAXDELTA = 1; - - /** * TODO: move this to OverviewMap.js * @type {number} Maximum width and/or height extent ratio that determines @@ -234,7 +227,6 @@ export default { ENABLE_RASTER_REPROJECTION: ENABLE_RASTER_REPROJECTION, ENABLE_WEBGL: ENABLE_WEBGL, DEBUG_WEBGL: DEBUG_WEBGL, - MOUSEWHEELZOOM_MAXDELTA: MOUSEWHEELZOOM_MAXDELTA, OVERVIEWMAP_MAX_RATIO: OVERVIEWMAP_MAX_RATIO, OVERVIEWMAP_MIN_RATIO: OVERVIEWMAP_MIN_RATIO, RASTER_REPROJECTION_MAX_SUBDIVISION: RASTER_REPROJECTION_MAX_SUBDIVISION, diff --git a/src/ol/interaction/MouseWheelZoom.js b/src/ol/interaction/MouseWheelZoom.js index 16e16dc7cc..18d93663cc 100644 --- a/src/ol/interaction/MouseWheelZoom.js +++ b/src/ol/interaction/MouseWheelZoom.js @@ -1,7 +1,7 @@ /** * @module ol/interaction/MouseWheelZoom */ -import {MOUSEWHEELZOOM_MAXDELTA, inherits} from '../index.js'; +import {inherits} from '../index.js'; import _ol_ViewHint_ from '../ViewHint.js'; import _ol_easing_ from '../easing.js'; import _ol_events_EventType_ from '../events/EventType.js'; @@ -9,6 +9,13 @@ import _ol_has_ from '../has.js'; import _ol_interaction_Interaction_ from '../interaction/Interaction.js'; import _ol_math_ from '../math.js'; + +/** + * @type {number} Maximum mouse wheel delta. + */ +var MAX_DELTA = 1; + + /** * @classdesc * Allows the user to zoom the map by scrolling the mouse wheel. @@ -252,7 +259,7 @@ _ol_interaction_MouseWheelZoom_.prototype.handleWheelZoom_ = function(map) { if (view.getAnimating()) { view.cancelAnimations(); } - var maxDelta = MOUSEWHEELZOOM_MAXDELTA; + var maxDelta = MAX_DELTA; var delta = _ol_math_.clamp(this.delta_, -maxDelta, maxDelta); _ol_interaction_Interaction_.zoomByDelta(view, -delta, this.lastAnchor_, this.duration_); From 4b0dad27f564d578234f344d93854e4a6a2efb63 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 16:32:03 -0700 Subject: [PATCH 06/16] Move min and max ratios to the overview map control --- src/ol/control/OverviewMap.js | 31 +++++++++++++++++++++++-------- src/ol/index.js | 18 ------------------ 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/ol/control/OverviewMap.js b/src/ol/control/OverviewMap.js index 0fc75f9325..b3c0104fee 100644 --- a/src/ol/control/OverviewMap.js +++ b/src/ol/control/OverviewMap.js @@ -1,7 +1,7 @@ /** * @module ol/control/OverviewMap */ -import {OVERVIEWMAP_MAX_RATIO, OVERVIEWMAP_MIN_RATIO, inherits} from '../index.js'; +import {inherits} from '../index.js'; import _ol_Collection_ from '../Collection.js'; import _ol_PluggableMap_ from '../PluggableMap.js'; import _ol_MapEventType_ from '../MapEventType.js'; @@ -19,6 +19,21 @@ import _ol_events_ from '../events.js'; import _ol_events_EventType_ from '../events/EventType.js'; import _ol_extent_ from '../extent.js'; + +/** + * @type {number} Maximum width and/or height extent ratio that determines + * when the overview map should be zoomed out. + */ +var MAX_RATIO = 0.75; + + +/** + * @type {number} Minimum width and/or height extent ratio that determines + * when the overview map should be zoomed in. + */ +var MIN_RATIO = 0.1; + + /** * Create a new control with a map acting as an overview map for an other * defined map. @@ -336,10 +351,10 @@ _ol_control_OverviewMap_.prototype.validateExtent_ = function() { var ovmapWidth = ovmapSize[0]; var ovmapHeight = ovmapSize[1]; - if (boxWidth < ovmapWidth * OVERVIEWMAP_MIN_RATIO || - boxHeight < ovmapHeight * OVERVIEWMAP_MIN_RATIO || - boxWidth > ovmapWidth * OVERVIEWMAP_MAX_RATIO || - boxHeight > ovmapHeight * OVERVIEWMAP_MAX_RATIO) { + if (boxWidth < ovmapWidth * MIN_RATIO || + boxHeight < ovmapHeight * MIN_RATIO || + boxWidth > ovmapWidth * MAX_RATIO || + boxHeight > ovmapHeight * MAX_RATIO) { this.resetExtent_(); } else if (!_ol_extent_.containsExtent(ovextent, extent)) { this.recenter_(); @@ -353,7 +368,7 @@ _ol_control_OverviewMap_.prototype.validateExtent_ = function() { * @private */ _ol_control_OverviewMap_.prototype.resetExtent_ = function() { - if (OVERVIEWMAP_MAX_RATIO === 0 || OVERVIEWMAP_MIN_RATIO === 0) { + if (MAX_RATIO === 0 || MIN_RATIO === 0) { return; } @@ -371,8 +386,8 @@ _ol_control_OverviewMap_.prototype.resetExtent_ = function() { // box sizes using the min and max ratio, pick the step in the middle used // to calculate the extent from the main map to set it to the overview map, var steps = Math.log( - OVERVIEWMAP_MAX_RATIO / OVERVIEWMAP_MIN_RATIO) / Math.LN2; - var ratio = 1 / (Math.pow(2, steps / 2) * OVERVIEWMAP_MIN_RATIO); + MAX_RATIO / MIN_RATIO) / Math.LN2; + var ratio = 1 / (Math.pow(2, steps / 2) * MIN_RATIO); _ol_extent_.scaleFromCenter(extent, ratio); ovview.fit(extent); }; diff --git a/src/ol/index.js b/src/ol/index.js index 7fedbfe2cb..174b3400e1 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -62,22 +62,6 @@ export var ENABLE_WEBGL = true; export var DEBUG_WEBGL = true; -/** - * 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. - */ -export var OVERVIEWMAP_MAX_RATIO = 0.75; - - -/** - * 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. - */ -export var OVERVIEWMAP_MIN_RATIO = 0.1; - - /** * TODO: move this to Triangulation.js * @type {number} Maximum number of subdivision steps during raster @@ -227,8 +211,6 @@ export default { ENABLE_RASTER_REPROJECTION: ENABLE_RASTER_REPROJECTION, ENABLE_WEBGL: ENABLE_WEBGL, DEBUG_WEBGL: DEBUG_WEBGL, - 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, From 60f673636021b057352ef5dcc3d93dbe89281091 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 16:35:03 -0700 Subject: [PATCH 07/16] Move max subdivision and max triangle width to triangulation module --- src/ol/index.js | 26 -------------------------- src/ol/reproj/Triangulation.js | 30 ++++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/ol/index.js b/src/ol/index.js index 174b3400e1..bcc694bd72 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -62,30 +62,6 @@ export var ENABLE_WEBGL = true; export var DEBUG_WEBGL = true; -/** - * 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`. - */ -export var RASTER_REPROJECTION_MAX_SUBDIVISION = 10; - - -/** - * 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 `RASTER_REPROJECTION_MAX_SUBDIVISION`). - * Default is `0.25`. - */ -export var RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH = 0.25; - - /** * TODO: move this to renderer/vector.js * @type {number} Tolerance for geometry simplification in device pixels. @@ -211,8 +187,6 @@ export default { ENABLE_RASTER_REPROJECTION: ENABLE_RASTER_REPROJECTION, ENABLE_WEBGL: ENABLE_WEBGL, DEBUG_WEBGL: DEBUG_WEBGL, - 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_MAX_TEXTURE_SIZE: WEBGL_MAX_TEXTURE_SIZE, diff --git a/src/ol/reproj/Triangulation.js b/src/ol/reproj/Triangulation.js index d70031a88b..954153633a 100644 --- a/src/ol/reproj/Triangulation.js +++ b/src/ol/reproj/Triangulation.js @@ -1,11 +1,33 @@ /** * @module ol/reproj/Triangulation */ -import {RASTER_REPROJECTION_MAX_SUBDIVISION, RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH} from '../index.js'; import _ol_extent_ from '../extent.js'; import _ol_math_ from '../math.js'; import _ol_proj_ from '../proj.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). + */ +var MAX_SUBDIVISION = 10; + + +/** + * @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 `MAX_SUBDIVISION`). + * Default is `0.25`. + */ +var MAX_TRIANGLE_WIDTH = 0.25; + + /** * @classdesc * Class containing triangulation of the given target extent. @@ -112,7 +134,7 @@ var _ol_reproj_Triangulation_ = function(sourceProj, targetProj, targetExtent, destinationTopLeft, destinationTopRight, destinationBottomRight, destinationBottomLeft, sourceTopLeft, sourceTopRight, sourceBottomRight, sourceBottomLeft, - RASTER_REPROJECTION_MAX_SUBDIVISION); + MAX_SUBDIVISION); if (this.wrapsXInSource_) { var leftBound = Infinity; @@ -213,11 +235,11 @@ _ol_reproj_Triangulation_.prototype.addQuad_ = function(a, b, c, d, var targetCoverageX = _ol_extent_.getWidth(targetQuadExtent) / this.targetWorldWidth_; needsSubdivision |= - targetCoverageX > RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH; + targetCoverageX > MAX_TRIANGLE_WIDTH; } if (!wrapsX && this.sourceProj_.isGlobal() && sourceCoverageX) { needsSubdivision |= - sourceCoverageX > RASTER_REPROJECTION_MAX_TRIANGLE_WIDTH; + sourceCoverageX > MAX_TRIANGLE_WIDTH; } } From b8ab1ff8529f7dc9b33e33b50a25928d49237975 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 16:36:59 -0700 Subject: [PATCH 08/16] Move simplify tolerance to the vector renderer --- src/ol/index.js | 8 -------- src/ol/renderer/vector.js | 8 +++++++- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/ol/index.js b/src/ol/index.js index bcc694bd72..7fa87ad498 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -62,13 +62,6 @@ export var ENABLE_WEBGL = true; export var DEBUG_WEBGL = true; -/** - * TODO: move this to renderer/vector.js - * @type {number} Tolerance for geometry simplification in device pixels. - */ -export var SIMPLIFY_TOLERANCE = 0.5; - - /** * @type {string} OpenLayers version. */ @@ -187,7 +180,6 @@ export default { ENABLE_RASTER_REPROJECTION: ENABLE_RASTER_REPROJECTION, ENABLE_WEBGL: ENABLE_WEBGL, DEBUG_WEBGL: DEBUG_WEBGL, - SIMPLIFY_TOLERANCE: SIMPLIFY_TOLERANCE, HAS_WEBGL: HAS_WEBGL, WEBGL_MAX_TEXTURE_SIZE: WEBGL_MAX_TEXTURE_SIZE, WEBGL_EXTENSIONS: WEBGL_EXTENSIONS diff --git a/src/ol/renderer/vector.js b/src/ol/renderer/vector.js index dd9003b7dd..9d18b05175 100644 --- a/src/ol/renderer/vector.js +++ b/src/ol/renderer/vector.js @@ -1,13 +1,19 @@ /** * @module ol/renderer/vector */ -import {SIMPLIFY_TOLERANCE, getUid} from '../index.js'; +import {getUid} from '../index.js'; import _ol_ImageState_ from '../ImageState.js'; import _ol_geom_GeometryType_ from '../geom/GeometryType.js'; import _ol_render_ReplayType_ from '../render/ReplayType.js'; var _ol_renderer_vector_ = {}; +/** + * @type {number} Tolerance for geometry simplification in device pixels. + */ +var SIMPLIFY_TOLERANCE = 0.5; + + /** * @param {ol.Feature|ol.render.Feature} feature1 Feature 1. * @param {ol.Feature|ol.render.Feature} feature2 Feature 2. From 8bf00cbfb7153bedb323e5cf843ad8db066ed98b Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 17:00:30 -0700 Subject: [PATCH 09/16] Move raster reprojection error threshold to a common reproj module --- doc/tutorials/raster-reprojection.md | 2 +- src/ol/index.js | 8 -------- src/ol/reproj/Image.js | 5 +++-- src/ol/reproj/Tile.js | 5 +++-- src/ol/reproj/common.js | 5 +++++ 5 files changed, 12 insertions(+), 13 deletions(-) create mode 100644 src/ol/reproj/common.js diff --git a/doc/tutorials/raster-reprojection.md b/doc/tutorials/raster-reprojection.md index e771d50d67..3f88f3647b 100644 --- a/doc/tutorials/raster-reprojection.md +++ b/doc/tutorials/raster-reprojection.md @@ -107,7 +107,7 @@ In case you are creating a custom build of OpenLayers and do not need the reproj See [Custom builds](custom-builds.html#defines) tutorial on how to do this. ### Triangulation precision threshold -The default [triangulation error threshold](#dynamic-triangulation) in pixels is given by `DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD` (0.5 pixel). +The default [triangulation error threshold](#dynamic-triangulation) in pixels is given by `ERROR_THRESHOLD` (0.5 pixel). In case a different threshold needs to be defined for different sources, the `reprojectionErrorThreshold` option can be passed when constructing the tile image source. ###Limiting visibility of reprojected map by extent diff --git a/src/ol/index.js b/src/ol/index.js index 7fa87ad498..8ed1aced3b 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -11,13 +11,6 @@ import webgl from './webgl.js'; export var ASSUME_TOUCH = false; -/** - * @type {number} Default maximum allowed threshold (in pixels) for - * reprojection triangulation. Default is `0.5`. - */ -export var DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD = 0.5; - - /** * @type {string} Default WMS version. */ @@ -173,7 +166,6 @@ export default { inherits: inherits, VERSION: VERSION, ASSUME_TOUCH: ASSUME_TOUCH, - DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD: DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD, DEFAULT_WMS_VERSION: DEFAULT_WMS_VERSION, ENABLE_CANVAS: ENABLE_CANVAS, ENABLE_PROJ4JS: ENABLE_PROJ4JS, diff --git a/src/ol/reproj/Image.js b/src/ol/reproj/Image.js index cf843e2bdc..ec94824ce9 100644 --- a/src/ol/reproj/Image.js +++ b/src/ol/reproj/Image.js @@ -1,7 +1,8 @@ /** * @module ol/reproj/Image */ -import {DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD, inherits} from '../index.js'; +import {ERROR_THRESHOLD} from './common.js'; +import {inherits} from '../index.js'; import _ol_ImageBase_ from '../ImageBase.js'; import _ol_ImageState_ from '../ImageState.js'; import _ol_events_ from '../events.js'; @@ -48,7 +49,7 @@ var _ol_reproj_Image_ = function(sourceProj, targetProj, var sourceResolution = _ol_reproj_.calculateSourceResolution( sourceProj, targetProj, targetCenter, targetResolution); - var errorThresholdInPixels = DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD; + var errorThresholdInPixels = ERROR_THRESHOLD; /** * @private diff --git a/src/ol/reproj/Tile.js b/src/ol/reproj/Tile.js index d0e7be6530..10d5ddcdfe 100644 --- a/src/ol/reproj/Tile.js +++ b/src/ol/reproj/Tile.js @@ -1,7 +1,8 @@ /** * @module ol/reproj/Tile */ -import {DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD, inherits} from '../index.js'; +import {ERROR_THRESHOLD} from './common.js'; +import {inherits} from '../index.js'; import _ol_Tile_ from '../Tile.js'; import _ol_TileState_ from '../TileState.js'; import _ol_events_ from '../events.js'; @@ -136,7 +137,7 @@ var _ol_reproj_Tile_ = function(sourceProj, sourceTileGrid, } var errorThresholdInPixels = opt_errorThreshold !== undefined ? - opt_errorThreshold : DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD; + opt_errorThreshold : ERROR_THRESHOLD; /** * @private diff --git a/src/ol/reproj/common.js b/src/ol/reproj/common.js new file mode 100644 index 0000000000..664f13d9b7 --- /dev/null +++ b/src/ol/reproj/common.js @@ -0,0 +1,5 @@ +/** + * @type {number} Default maximum allowed threshold (in pixels) for + * reprojection triangulation. + */ +export var ERROR_THRESHOLD = 0.5; From 0a12ca690f8638f5f83ef0cbeb01a12172a9347e Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 17:08:50 -0700 Subject: [PATCH 10/16] Remove ASSUME_TOUCH --- src/ol/has.js | 4 ++-- src/ol/index.js | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/ol/has.js b/src/ol/has.js index 7428ec4c60..c529f1abf4 100644 --- a/src/ol/has.js +++ b/src/ol/has.js @@ -1,7 +1,7 @@ /** * @module ol/has */ -import {ENABLE_CANVAS, ASSUME_TOUCH, HAS_WEBGL} from './index.js'; +import {ENABLE_CANVAS, HAS_WEBGL} from './index.js'; var _ol_has_ = {}; @@ -105,7 +105,7 @@ _ol_has_.GEOLOCATION = 'geolocation' in navigator; * @type {boolean} * @api */ -_ol_has_.TOUCH = ASSUME_TOUCH || 'ontouchstart' in window; +_ol_has_.TOUCH = 'ontouchstart' in window; /** diff --git a/src/ol/index.js b/src/ol/index.js index 8ed1aced3b..8bc8c7e1e5 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -5,12 +5,6 @@ import webgl from './webgl.js'; -/** - * @type {boolean} Assume touch. Default is `false`. - */ -export var ASSUME_TOUCH = false; - - /** * @type {string} Default WMS version. */ @@ -165,7 +159,6 @@ export default { nullFunction: nullFunction, inherits: inherits, VERSION: VERSION, - ASSUME_TOUCH: ASSUME_TOUCH, DEFAULT_WMS_VERSION: DEFAULT_WMS_VERSION, ENABLE_CANVAS: ENABLE_CANVAS, ENABLE_PROJ4JS: ENABLE_PROJ4JS, From 755619fa870ab5195014c79164f04928ec39c49b Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 17:18:41 -0700 Subject: [PATCH 11/16] Remove ENABLE_CANVAS --- src/ol/Map.js | 18 ++++++++---------- src/ol/has.js | 7 +++---- src/ol/index.js | 9 --------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/ol/Map.js b/src/ol/Map.js index 5987b2f158..128a273429 100644 --- a/src/ol/Map.js +++ b/src/ol/Map.js @@ -1,7 +1,7 @@ /** * @module ol/Map */ -import {ENABLE_CANVAS, ENABLE_WEBGL, inherits} from './index.js'; +import {ENABLE_WEBGL, inherits} from './index.js'; import _ol_PluggableMap_ from './PluggableMap.js'; import _ol_PluginType_ from './PluginType.js'; import _ol_control_ from './control.js'; @@ -19,15 +19,13 @@ import _ol_renderer_webgl_TileLayer_ from './renderer/webgl/TileLayer.js'; import _ol_renderer_webgl_VectorLayer_ from './renderer/webgl/VectorLayer.js'; -if (ENABLE_CANVAS) { - _ol_plugins_.register(_ol_PluginType_.MAP_RENDERER, _ol_renderer_canvas_Map_); - _ol_plugins_.registerMultiple(_ol_PluginType_.LAYER_RENDERER, [ - _ol_renderer_canvas_ImageLayer_, - _ol_renderer_canvas_TileLayer_, - _ol_renderer_canvas_VectorLayer_, - _ol_renderer_canvas_VectorTileLayer_ - ]); -} +_ol_plugins_.register(_ol_PluginType_.MAP_RENDERER, _ol_renderer_canvas_Map_); +_ol_plugins_.registerMultiple(_ol_PluginType_.LAYER_RENDERER, [ + _ol_renderer_canvas_ImageLayer_, + _ol_renderer_canvas_TileLayer_, + _ol_renderer_canvas_VectorLayer_, + _ol_renderer_canvas_VectorTileLayer_ +]); if (ENABLE_WEBGL) { _ol_plugins_.register(_ol_PluginType_.MAP_RENDERER, _ol_renderer_webgl_Map_); diff --git a/src/ol/has.js b/src/ol/has.js index c529f1abf4..182eaea2ea 100644 --- a/src/ol/has.js +++ b/src/ol/has.js @@ -1,7 +1,7 @@ /** * @module ol/has */ -import {ENABLE_CANVAS, HAS_WEBGL} from './index.js'; +import {HAS_WEBGL} from './index.js'; var _ol_has_ = {}; @@ -51,13 +51,12 @@ _ol_has_.CANVAS_LINE_DASH = false; /** - * True if both the library and browser support Canvas. Always `false` - * if `ol.ENABLE_CANVAS` is set to `false` at compile time. + * True if the and browsers support Canvas. * @const * @type {boolean} * @api */ -_ol_has_.CANVAS = ENABLE_CANVAS && ( +_ol_has_.CANVAS = ( /** * @return {boolean} Canvas supported. */ diff --git a/src/ol/index.js b/src/ol/index.js index 8bc8c7e1e5..e5203d9a0a 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -11,14 +11,6 @@ import webgl from './webgl.js'; export var DEFAULT_WMS_VERSION = '1.3.0'; -/** - * @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. - */ -export var ENABLE_CANVAS = true; - - /** * @type {boolean} Enable integration with the Proj4js library. Default is * `true`. @@ -160,7 +152,6 @@ export default { inherits: inherits, VERSION: VERSION, DEFAULT_WMS_VERSION: DEFAULT_WMS_VERSION, - ENABLE_CANVAS: ENABLE_CANVAS, ENABLE_PROJ4JS: ENABLE_PROJ4JS, ENABLE_RASTER_REPROJECTION: ENABLE_RASTER_REPROJECTION, ENABLE_WEBGL: ENABLE_WEBGL, From 9e34c145c3f21331c92f87de895af17c9abb6c36 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 17:21:42 -0700 Subject: [PATCH 12/16] Remove ENABLE_WEBGL --- src/ol/Map.js | 17 ++++++++--------- src/ol/index.js | 14 ++------------ 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/ol/Map.js b/src/ol/Map.js index 128a273429..40b7cd33e5 100644 --- a/src/ol/Map.js +++ b/src/ol/Map.js @@ -1,7 +1,7 @@ /** * @module ol/Map */ -import {ENABLE_WEBGL, inherits} from './index.js'; +import {inherits} from './index.js'; import _ol_PluggableMap_ from './PluggableMap.js'; import _ol_PluginType_ from './PluginType.js'; import _ol_control_ from './control.js'; @@ -27,14 +27,13 @@ _ol_plugins_.registerMultiple(_ol_PluginType_.LAYER_RENDERER, [ _ol_renderer_canvas_VectorTileLayer_ ]); -if (ENABLE_WEBGL) { - _ol_plugins_.register(_ol_PluginType_.MAP_RENDERER, _ol_renderer_webgl_Map_); - _ol_plugins_.registerMultiple(_ol_PluginType_.LAYER_RENDERER, [ - _ol_renderer_webgl_ImageLayer_, - _ol_renderer_webgl_TileLayer_, - _ol_renderer_webgl_VectorLayer_ - ]); -} +// TODO: move these to new ol-webgl package +_ol_plugins_.register(_ol_PluginType_.MAP_RENDERER, _ol_renderer_webgl_Map_); +_ol_plugins_.registerMultiple(_ol_PluginType_.LAYER_RENDERER, [ + _ol_renderer_webgl_ImageLayer_, + _ol_renderer_webgl_TileLayer_, + _ol_renderer_webgl_VectorLayer_ +]); /** diff --git a/src/ol/index.js b/src/ol/index.js index e5203d9a0a..e5e1c70048 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -25,18 +25,9 @@ export var ENABLE_PROJ4JS = true; export var ENABLE_RASTER_REPROJECTION = true; -/** - * @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. - */ -export var ENABLE_WEBGL = true; - - /** * @type {boolean} Include debuggable shader sources. Default is `true`. - * This should be set to `false` for production builds (if `ENABLE_WEBGL` - * is `true`). + * This should be set to `false` for production builds. */ export var DEBUG_WEBGL = true; @@ -71,7 +62,7 @@ var WEBGL_EXTENSIONS; // value is set below var HAS_WEBGL = false; -if (ENABLE_WEBGL && 'WebGLRenderingContext' in window) { +if ('WebGLRenderingContext' in window) { try { var canvas = /** @type {HTMLCanvasElement} */ (document.createElement('CANVAS')); @@ -154,7 +145,6 @@ export default { DEFAULT_WMS_VERSION: DEFAULT_WMS_VERSION, ENABLE_PROJ4JS: ENABLE_PROJ4JS, ENABLE_RASTER_REPROJECTION: ENABLE_RASTER_REPROJECTION, - ENABLE_WEBGL: ENABLE_WEBGL, DEBUG_WEBGL: DEBUG_WEBGL, HAS_WEBGL: HAS_WEBGL, WEBGL_MAX_TEXTURE_SIZE: WEBGL_MAX_TEXTURE_SIZE, From ee5507cae860aabc26c5712f4e0fd13a41b11215 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 17:26:01 -0700 Subject: [PATCH 13/16] Remove ENABLE_PROJ4JS --- src/ol/index.js | 8 -------- src/ol/proj.js | 37 +++++++++++++++++-------------------- src/ol/proj/Projection.js | 27 ++++++++++++--------------- 3 files changed, 29 insertions(+), 43 deletions(-) diff --git a/src/ol/index.js b/src/ol/index.js index e5e1c70048..d2924a56a8 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -11,13 +11,6 @@ import webgl from './webgl.js'; export var DEFAULT_WMS_VERSION = '1.3.0'; -/** - * @type {boolean} Enable integration with the Proj4js library. Default is - * `true`. - */ -export var ENABLE_PROJ4JS = true; - - /** * @type {boolean} Enable automatic reprojection of raster sources. Default is * `true`. @@ -143,7 +136,6 @@ export default { inherits: inherits, VERSION: VERSION, DEFAULT_WMS_VERSION: DEFAULT_WMS_VERSION, - ENABLE_PROJ4JS: ENABLE_PROJ4JS, ENABLE_RASTER_REPROJECTION: ENABLE_RASTER_REPROJECTION, DEBUG_WEBGL: DEBUG_WEBGL, HAS_WEBGL: HAS_WEBGL, diff --git a/src/ol/proj.js b/src/ol/proj.js index d28c2616d1..dd5a47e98f 100644 --- a/src/ol/proj.js +++ b/src/ol/proj.js @@ -1,7 +1,6 @@ /** * @module ol/proj */ -import {ENABLE_PROJ4JS} from './index.js'; import _ol_Sphere_ from './Sphere.js'; import _ol_extent_ from './extent.js'; import _ol_math_ from './math.js'; @@ -32,23 +31,21 @@ _ol_proj_.METERS_PER_UNIT = _ol_proj_Units_.METERS_PER_UNIT; _ol_proj_.SPHERE_ = new _ol_Sphere_(_ol_Sphere_.DEFAULT_RADIUS); -if (ENABLE_PROJ4JS) { - /** - * Register proj4. If not explicitly registered, it will be assumed that - * proj4js will be loaded in the global namespace. For example in a - * browserify ES6 environment you could use: - * - * import ol from 'openlayers'; - * import proj4 from 'proj4'; - * ol.proj.setProj4(proj4); - * - * @param {Proj4} proj4 Proj4. - * @api - */ - _ol_proj_.setProj4 = function(proj4) { - _ol_proj_proj4_.set(proj4); - }; -} +/** + * Register proj4. If not explicitly registered, it will be assumed that + * proj4js will be loaded in the global namespace. For example in a + * browserify ES6 environment you could use: + * + * import ol from 'openlayers'; + * import proj4 from 'proj4'; + * ol.proj.setProj4(proj4); + * + * @param {Proj4} proj4 Proj4. + * @api + */ +_ol_proj_.setProj4 = function(proj4) { + _ol_proj_proj4_.set(proj4); +}; /** @@ -311,7 +308,7 @@ _ol_proj_.get = function(projectionLike) { } else if (typeof projectionLike === 'string') { var code = projectionLike; projection = _ol_proj_projections_.get(code); - if (ENABLE_PROJ4JS && !projection) { + if (!projection) { var proj4js = _ol_proj_proj4_.get(); if (typeof proj4js == 'function' && proj4js.defs(code) !== undefined) { @@ -380,7 +377,7 @@ _ol_proj_.getTransformFromProjections = function(sourceProjection, destinationPr var sourceCode = sourceProjection.getCode(); var destinationCode = destinationProjection.getCode(); var transform = _ol_proj_transforms_.get(sourceCode, destinationCode); - if (ENABLE_PROJ4JS && !transform) { + if (!transform) { var proj4js = _ol_proj_proj4_.get(); if (typeof proj4js == 'function') { var sourceDef = proj4js.defs(sourceCode); diff --git a/src/ol/proj/Projection.js b/src/ol/proj/Projection.js index 6a08d1a8ac..6e925544ed 100644 --- a/src/ol/proj/Projection.js +++ b/src/ol/proj/Projection.js @@ -1,7 +1,6 @@ /** * @module ol/proj/Projection */ -import {ENABLE_PROJ4JS} from '../index.js'; import _ol_proj_Units_ from '../proj/Units.js'; import _ol_proj_proj4_ from '../proj/proj4.js'; @@ -108,20 +107,18 @@ var _ol_proj_Projection_ = function(options) { this.metersPerUnit_ = options.metersPerUnit; var code = options.code; - if (ENABLE_PROJ4JS) { - var proj4js = _ol_proj_proj4_.get(); - if (typeof proj4js == 'function') { - var def = proj4js.defs(code); - if (def !== undefined) { - if (def.axis !== undefined && options.axisOrientation === undefined) { - this.axisOrientation_ = def.axis; - } - if (options.metersPerUnit === undefined) { - this.metersPerUnit_ = def.to_meter; - } - if (options.units === undefined) { - this.units_ = def.units; - } + var proj4js = _ol_proj_proj4_.get(); + if (typeof proj4js == 'function') { + var def = proj4js.defs(code); + if (def !== undefined) { + if (def.axis !== undefined && options.axisOrientation === undefined) { + this.axisOrientation_ = def.axis; + } + if (options.metersPerUnit === undefined) { + this.metersPerUnit_ = def.to_meter; + } + if (options.units === undefined) { + this.units_ = def.units; } } } From f403a069672ee247c061327caf87916c68bf5b4d Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 17:30:59 -0700 Subject: [PATCH 14/16] Move ENABLE_RASTER_REPROJECTION to a temporary place --- src/ol/index.js | 8 -------- src/ol/renderer/canvas/ImageLayer.js | 3 ++- src/ol/renderer/webgl/ImageLayer.js | 3 ++- src/ol/reproj/common.js | 7 +++++++ src/ol/source/Image.js | 3 ++- src/ol/source/TileImage.js | 3 ++- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/ol/index.js b/src/ol/index.js index d2924a56a8..04be982456 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -11,13 +11,6 @@ import webgl from './webgl.js'; export var DEFAULT_WMS_VERSION = '1.3.0'; -/** - * @type {boolean} Enable automatic reprojection of raster sources. Default is - * `true`. - */ -export var ENABLE_RASTER_REPROJECTION = true; - - /** * @type {boolean} Include debuggable shader sources. Default is `true`. * This should be set to `false` for production builds. @@ -136,7 +129,6 @@ export default { inherits: inherits, VERSION: VERSION, DEFAULT_WMS_VERSION: DEFAULT_WMS_VERSION, - ENABLE_RASTER_REPROJECTION: ENABLE_RASTER_REPROJECTION, DEBUG_WEBGL: DEBUG_WEBGL, HAS_WEBGL: HAS_WEBGL, WEBGL_MAX_TEXTURE_SIZE: WEBGL_MAX_TEXTURE_SIZE, diff --git a/src/ol/renderer/canvas/ImageLayer.js b/src/ol/renderer/canvas/ImageLayer.js index ab01e9a8a1..3e36728ef4 100644 --- a/src/ol/renderer/canvas/ImageLayer.js +++ b/src/ol/renderer/canvas/ImageLayer.js @@ -1,7 +1,8 @@ /** * @module ol/renderer/canvas/ImageLayer */ -import {ENABLE_RASTER_REPROJECTION, inherits} from '../../index.js'; +import {ENABLE_RASTER_REPROJECTION} from '../../reproj/common.js'; +import {inherits} from '../../index.js'; import _ol_ImageCanvas_ from '../../ImageCanvas.js'; import _ol_LayerType_ from '../../LayerType.js'; import _ol_ViewHint_ from '../../ViewHint.js'; diff --git a/src/ol/renderer/webgl/ImageLayer.js b/src/ol/renderer/webgl/ImageLayer.js index d67457c8c2..9b29331f77 100644 --- a/src/ol/renderer/webgl/ImageLayer.js +++ b/src/ol/renderer/webgl/ImageLayer.js @@ -1,7 +1,8 @@ /** * @module ol/renderer/webgl/ImageLayer */ -import {ENABLE_RASTER_REPROJECTION, inherits, nullFunction} from '../../index.js'; +import {ENABLE_RASTER_REPROJECTION} from '../../reproj/common.js'; +import {inherits, nullFunction} from '../../index.js'; import _ol_LayerType_ from '../../LayerType.js'; import _ol_ViewHint_ from '../../ViewHint.js'; import _ol_dom_ from '../../dom.js'; diff --git a/src/ol/reproj/common.js b/src/ol/reproj/common.js index 664f13d9b7..524358e314 100644 --- a/src/ol/reproj/common.js +++ b/src/ol/reproj/common.js @@ -3,3 +3,10 @@ * reprojection triangulation. */ export var ERROR_THRESHOLD = 0.5; + +/** + * TODO: decide if we want to expose this as a build flag or remove it + * @type {boolean} Enable automatic reprojection of raster sources. Default is + * `true`. + */ +export var ENABLE_RASTER_REPROJECTION = true; diff --git a/src/ol/source/Image.js b/src/ol/source/Image.js index 1f9dc15919..db0fb79b6e 100644 --- a/src/ol/source/Image.js +++ b/src/ol/source/Image.js @@ -1,7 +1,8 @@ /** * @module ol/source/Image */ -import {ENABLE_RASTER_REPROJECTION, inherits} from '../index.js'; +import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js'; +import {inherits} from '../index.js'; import _ol_ImageState_ from '../ImageState.js'; import _ol_array_ from '../array.js'; import _ol_events_Event_ from '../events/Event.js'; diff --git a/src/ol/source/TileImage.js b/src/ol/source/TileImage.js index 56ae68cd6d..c827ef15c0 100644 --- a/src/ol/source/TileImage.js +++ b/src/ol/source/TileImage.js @@ -1,7 +1,8 @@ /** * @module ol/source/TileImage */ -import {ENABLE_RASTER_REPROJECTION, getUid, inherits} from '../index.js'; +import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js'; +import {getUid, inherits} from '../index.js'; import _ol_ImageTile_ from '../ImageTile.js'; import _ol_TileCache_ from '../TileCache.js'; import _ol_TileState_ from '../TileState.js'; From ed5b28f366e6dd8319be9ff0757c014567531258 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 17:40:13 -0700 Subject: [PATCH 15/16] Move DEFAULT_WMS_VERSION to a common source module --- src/ol/index.js | 7 ------- src/ol/source/ImageWMS.js | 3 ++- src/ol/source/TileWMS.js | 3 ++- src/ol/source/common.js | 4 ++++ 4 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 src/ol/source/common.js diff --git a/src/ol/index.js b/src/ol/index.js index 04be982456..c82cf5a2ae 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -5,12 +5,6 @@ import webgl from './webgl.js'; -/** - * @type {string} Default WMS version. - */ -export var DEFAULT_WMS_VERSION = '1.3.0'; - - /** * @type {boolean} Include debuggable shader sources. Default is `true`. * This should be set to `false` for production builds. @@ -128,7 +122,6 @@ export default { nullFunction: nullFunction, inherits: inherits, VERSION: VERSION, - DEFAULT_WMS_VERSION: DEFAULT_WMS_VERSION, DEBUG_WEBGL: DEBUG_WEBGL, HAS_WEBGL: HAS_WEBGL, WEBGL_MAX_TEXTURE_SIZE: WEBGL_MAX_TEXTURE_SIZE, diff --git a/src/ol/source/ImageWMS.js b/src/ol/source/ImageWMS.js index 74a7d46274..98fa89fab9 100644 --- a/src/ol/source/ImageWMS.js +++ b/src/ol/source/ImageWMS.js @@ -2,7 +2,8 @@ * @module ol/source/ImageWMS */ -import {DEFAULT_WMS_VERSION, inherits} from '../index.js'; +import {DEFAULT_WMS_VERSION} from './common.js'; +import {inherits} from '../index.js'; import _ol_Image_ from '../Image.js'; import _ol_asserts_ from '../asserts.js'; import _ol_events_ from '../events.js'; diff --git a/src/ol/source/TileWMS.js b/src/ol/source/TileWMS.js index 1a63818b98..a03a4f718e 100644 --- a/src/ol/source/TileWMS.js +++ b/src/ol/source/TileWMS.js @@ -2,7 +2,8 @@ * @module ol/source/TileWMS */ -import {DEFAULT_WMS_VERSION, inherits} from '../index.js'; +import {DEFAULT_WMS_VERSION} from './common.js'; +import {inherits} from '../index.js'; import _ol_asserts_ from '../asserts.js'; import _ol_extent_ from '../extent.js'; import _ol_obj_ from '../obj.js'; diff --git a/src/ol/source/common.js b/src/ol/source/common.js new file mode 100644 index 0000000000..a20bbd8c85 --- /dev/null +++ b/src/ol/source/common.js @@ -0,0 +1,4 @@ +/** + * @type {string} Default WMS version. + */ +export var DEFAULT_WMS_VERSION = '1.3.0'; From ea6a397647b30643a5c4a6979f92d718671a32d0 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 12 Dec 2017 17:42:20 -0700 Subject: [PATCH 16/16] Add remaining TODOs --- src/ol/index.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ol/index.js b/src/ol/index.js index c82cf5a2ae..f6aced6ae8 100644 --- a/src/ol/index.js +++ b/src/ol/index.js @@ -6,6 +6,7 @@ import webgl from './webgl.js'; /** + * TODO: move to a separate ol-webgl package * @type {boolean} Include debuggable shader sources. Default is `true`. * This should be set to `false` for production builds. */ @@ -13,12 +14,7 @@ export var DEBUG_WEBGL = true; /** - * @type {string} OpenLayers version. - */ -export var VERSION = 'v4.6.4'; - - -/** + * TODO: move to a separate ol-webgl package * The maximum supported WebGL texture size in pixels. If WebGL is not * supported, the value is set to `undefined`. * @const @@ -28,6 +24,7 @@ var WEBGL_MAX_TEXTURE_SIZE; // value is set below /** + * TODO: move to a separate ol-webgl package * List of supported WebGL extensions. * @const * @type {Array.} @@ -36,6 +33,7 @@ var WEBGL_EXTENSIONS; // value is set below /** + * TODO: move to a separate ol-webgl package * WebGL is available. * @type {boolean} */ @@ -61,6 +59,12 @@ if ('WebGLRenderingContext' in window) { export {HAS_WEBGL, WEBGL_MAX_TEXTURE_SIZE, WEBGL_EXTENSIONS}; +/** + * @type {string} OpenLayers version. + */ +export var VERSION = 'v4.6.4'; + + /** * Inherit the prototype methods from one constructor into another. *