From 64e7ae6eb84b65fa1c55cb0f0d7355bcacbb3839 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 10:39:52 +0100 Subject: [PATCH 01/16] Rename _ol_CollectionEventType_ to CollectionEventType --- src/ol/Collection.js | 10 +++++----- src/ol/PluggableMap.js | 14 +++++++------- src/ol/interaction/Modify.js | 6 +++--- src/ol/interaction/Select.js | 6 +++--- src/ol/interaction/Snap.js | 6 +++--- src/ol/layer/Group.js | 6 +++--- src/ol/source/Vector.js | 6 +++--- test/spec/ol/collection.test.js | 24 ++++++++++++------------ 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/ol/Collection.js b/src/ol/Collection.js index 71cb942b87..253647aa3c 100644 --- a/src/ol/Collection.js +++ b/src/ol/Collection.js @@ -3,7 +3,7 @@ */ import {inherits} from './index.js'; import AssertionError from './AssertionError.js'; -import _ol_CollectionEventType_ from './CollectionEventType.js'; +import CollectionEventType from './CollectionEventType.js'; import _ol_Object_ from './Object.js'; import Event from './events/Event.js'; @@ -158,7 +158,7 @@ _ol_Collection_.prototype.insertAt = function(index, elem) { this.array_.splice(index, 0, elem); this.updateLength_(); this.dispatchEvent( - new _ol_Collection_.Event(_ol_CollectionEventType_.ADD, elem)); + new _ol_Collection_.Event(CollectionEventType.ADD, elem)); }; @@ -219,7 +219,7 @@ _ol_Collection_.prototype.removeAt = function(index) { this.array_.splice(index, 1); this.updateLength_(); this.dispatchEvent( - new _ol_Collection_.Event(_ol_CollectionEventType_.REMOVE, prev)); + new _ol_Collection_.Event(CollectionEventType.REMOVE, prev)); return prev; }; @@ -239,9 +239,9 @@ _ol_Collection_.prototype.setAt = function(index, elem) { var prev = this.array_[index]; this.array_[index] = elem; this.dispatchEvent( - new _ol_Collection_.Event(_ol_CollectionEventType_.REMOVE, prev)); + new _ol_Collection_.Event(CollectionEventType.REMOVE, prev)); this.dispatchEvent( - new _ol_Collection_.Event(_ol_CollectionEventType_.ADD, elem)); + new _ol_Collection_.Event(CollectionEventType.ADD, elem)); } else { var j; for (j = n; j < index; ++j) { diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index 1bac396a62..32bca55aa7 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -3,7 +3,7 @@ */ import {getUid, inherits} from './index.js'; import _ol_Collection_ from './Collection.js'; -import _ol_CollectionEventType_ from './CollectionEventType.js'; +import CollectionEventType from './CollectionEventType.js'; import MapBrowserEvent from './MapBrowserEvent.js'; import MapBrowserEventHandler from './MapBrowserEventHandler.js'; import MapBrowserEventType from './MapBrowserEventType.js'; @@ -359,7 +359,7 @@ var _ol_PluggableMap_ = function(options) { control.setMap(this); }, this); - _ol_events_.listen(this.controls, _ol_CollectionEventType_.ADD, + _ol_events_.listen(this.controls, CollectionEventType.ADD, /** * @param {ol.Collection.Event} event Collection event. */ @@ -367,7 +367,7 @@ var _ol_PluggableMap_ = function(options) { event.element.setMap(this); }, this); - _ol_events_.listen(this.controls, _ol_CollectionEventType_.REMOVE, + _ol_events_.listen(this.controls, CollectionEventType.REMOVE, /** * @param {ol.Collection.Event} event Collection event. */ @@ -384,7 +384,7 @@ var _ol_PluggableMap_ = function(options) { interaction.setMap(this); }, this); - _ol_events_.listen(this.interactions, _ol_CollectionEventType_.ADD, + _ol_events_.listen(this.interactions, CollectionEventType.ADD, /** * @param {ol.Collection.Event} event Collection event. */ @@ -392,7 +392,7 @@ var _ol_PluggableMap_ = function(options) { event.element.setMap(this); }, this); - _ol_events_.listen(this.interactions, _ol_CollectionEventType_.REMOVE, + _ol_events_.listen(this.interactions, CollectionEventType.REMOVE, /** * @param {ol.Collection.Event} event Collection event. */ @@ -402,7 +402,7 @@ var _ol_PluggableMap_ = function(options) { this.overlays_.forEach(this.addOverlayInternal_, this); - _ol_events_.listen(this.overlays_, _ol_CollectionEventType_.ADD, + _ol_events_.listen(this.overlays_, CollectionEventType.ADD, /** * @param {ol.Collection.Event} event Collection event. */ @@ -410,7 +410,7 @@ var _ol_PluggableMap_ = function(options) { this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element)); }, this); - _ol_events_.listen(this.overlays_, _ol_CollectionEventType_.REMOVE, + _ol_events_.listen(this.overlays_, CollectionEventType.REMOVE, /** * @param {ol.Collection.Event} event Collection event. */ diff --git a/src/ol/interaction/Modify.js b/src/ol/interaction/Modify.js index 90ed5b3208..e9d33737e5 100644 --- a/src/ol/interaction/Modify.js +++ b/src/ol/interaction/Modify.js @@ -3,7 +3,7 @@ */ import {getUid, inherits} from '../index.js'; import _ol_Collection_ from '../Collection.js'; -import _ol_CollectionEventType_ from '../CollectionEventType.js'; +import CollectionEventType from '../CollectionEventType.js'; import _ol_Feature_ from '../Feature.js'; import MapBrowserEventType from '../MapBrowserEventType.js'; import MapBrowserPointerEvent from '../MapBrowserPointerEvent.js'; @@ -214,9 +214,9 @@ var _ol_interaction_Modify_ = function(options) { this.features_ = features; this.features_.forEach(this.addFeature_, this); - _ol_events_.listen(this.features_, _ol_CollectionEventType_.ADD, + _ol_events_.listen(this.features_, CollectionEventType.ADD, this.handleFeatureAdd_, this); - _ol_events_.listen(this.features_, _ol_CollectionEventType_.REMOVE, + _ol_events_.listen(this.features_, CollectionEventType.REMOVE, this.handleFeatureRemove_, this); /** diff --git a/src/ol/interaction/Select.js b/src/ol/interaction/Select.js index 14dc628604..5160d05a7d 100644 --- a/src/ol/interaction/Select.js +++ b/src/ol/interaction/Select.js @@ -2,7 +2,7 @@ * @module ol/interaction/Select */ import {getUid, inherits} from '../index.js'; -import _ol_CollectionEventType_ from '../CollectionEventType.js'; +import CollectionEventType from '../CollectionEventType.js'; import _ol_array_ from '../array.js'; import _ol_events_ from '../events.js'; import Event from '../events/Event.js'; @@ -135,9 +135,9 @@ var _ol_interaction_Select_ = function(opt_options) { this.featureLayerAssociation_ = {}; var features = this.featureOverlay_.getSource().getFeaturesCollection(); - _ol_events_.listen(features, _ol_CollectionEventType_.ADD, + _ol_events_.listen(features, CollectionEventType.ADD, this.addFeature_, this); - _ol_events_.listen(features, _ol_CollectionEventType_.REMOVE, + _ol_events_.listen(features, CollectionEventType.REMOVE, this.removeFeature_, this); }; diff --git a/src/ol/interaction/Snap.js b/src/ol/interaction/Snap.js index d099e62fcd..eec5ca78a5 100644 --- a/src/ol/interaction/Snap.js +++ b/src/ol/interaction/Snap.js @@ -3,7 +3,7 @@ */ import {getUid, inherits} from '../index.js'; import _ol_Collection_ from '../Collection.js'; -import _ol_CollectionEventType_ from '../CollectionEventType.js'; +import CollectionEventType from '../CollectionEventType.js'; import _ol_coordinate_ from '../coordinate.js'; import _ol_events_ from '../events.js'; import EventType from '../events/EventType.js'; @@ -309,9 +309,9 @@ _ol_interaction_Snap_.prototype.setMap = function(map) { if (map) { if (this.features_) { keys.push( - _ol_events_.listen(this.features_, _ol_CollectionEventType_.ADD, + _ol_events_.listen(this.features_, CollectionEventType.ADD, this.handleFeatureAdd_, this), - _ol_events_.listen(this.features_, _ol_CollectionEventType_.REMOVE, + _ol_events_.listen(this.features_, CollectionEventType.REMOVE, this.handleFeatureRemove_, this) ); } else if (this.source_) { diff --git a/src/ol/layer/Group.js b/src/ol/layer/Group.js index b6c30bc66f..e90ac70d02 100644 --- a/src/ol/layer/Group.js +++ b/src/ol/layer/Group.js @@ -3,7 +3,7 @@ */ import {getUid, inherits} from '../index.js'; import _ol_Collection_ from '../Collection.js'; -import _ol_CollectionEventType_ from '../CollectionEventType.js'; +import CollectionEventType from '../CollectionEventType.js'; import _ol_Object_ from '../Object.js'; import _ol_ObjectEventType_ from '../ObjectEventType.js'; import {assert} from '../asserts.js'; @@ -89,9 +89,9 @@ _ol_layer_Group_.prototype.handleLayersChanged_ = function(event) { var layers = this.getLayers(); this.layersListenerKeys_.push( - _ol_events_.listen(layers, _ol_CollectionEventType_.ADD, + _ol_events_.listen(layers, CollectionEventType.ADD, this.handleLayersAdd_, this), - _ol_events_.listen(layers, _ol_CollectionEventType_.REMOVE, + _ol_events_.listen(layers, CollectionEventType.REMOVE, this.handleLayersRemove_, this)); for (var id in this.listenerKeys_) { diff --git a/src/ol/source/Vector.js b/src/ol/source/Vector.js index e090179ce3..b524312761 100644 --- a/src/ol/source/Vector.js +++ b/src/ol/source/Vector.js @@ -4,7 +4,7 @@ import {getUid, inherits, nullFunction} from '../index.js'; import _ol_Collection_ from '../Collection.js'; -import _ol_CollectionEventType_ from '../CollectionEventType.js'; +import CollectionEventType from '../CollectionEventType.js'; import _ol_ObjectEventType_ from '../ObjectEventType.js'; import _ol_array_ from '../array.js'; import {assert} from '../asserts.js'; @@ -314,7 +314,7 @@ _ol_source_Vector_.prototype.bindFeaturesCollection_ = function(collection) { modifyingCollection = false; } }); - _ol_events_.listen(collection, _ol_CollectionEventType_.ADD, + _ol_events_.listen(collection, CollectionEventType.ADD, function(evt) { if (!modifyingCollection) { modifyingCollection = true; @@ -322,7 +322,7 @@ _ol_source_Vector_.prototype.bindFeaturesCollection_ = function(collection) { modifyingCollection = false; } }, this); - _ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, + _ol_events_.listen(collection, CollectionEventType.REMOVE, function(evt) { if (!modifyingCollection) { modifyingCollection = true; diff --git a/test/spec/ol/collection.test.js b/test/spec/ol/collection.test.js index 654bc0f0ac..54546a1f29 100644 --- a/test/spec/ol/collection.test.js +++ b/test/spec/ol/collection.test.js @@ -1,6 +1,6 @@ import _ol_events_ from '../../../src/ol/events.js'; import _ol_Collection_ from '../../../src/ol/Collection.js'; -import _ol_CollectionEventType_ from '../../../src/ol/CollectionEventType.js'; +import CollectionEventType from '../../../src/ol/CollectionEventType.js'; describe('ol.collection', function() { @@ -129,7 +129,7 @@ describe('ol.collection', function() { it('fires a remove event', function() { var collection = new _ol_Collection_([0, 1, 2]); var cb = sinon.spy(); - _ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, cb); + _ol_events_.listen(collection, CollectionEventType.REMOVE, cb); expect(collection.remove(1)).to.eql(1); expect(cb).to.be.called(); expect(cb.lastCall.args[0].element).to.eql(1); @@ -152,11 +152,11 @@ describe('ol.collection', function() { it('does dispatch events', function() { var collection = new _ol_Collection_(['a', 'b']); var added, removed; - _ol_events_.listen(collection, _ol_CollectionEventType_.ADD, function(e) { + _ol_events_.listen(collection, CollectionEventType.ADD, function(e) { added = e.element; }); _ol_events_.listen( - collection, _ol_CollectionEventType_.REMOVE, function(e) { + collection, CollectionEventType.REMOVE, function(e) { removed = e.element; }); collection.setAt(1, 1); @@ -170,7 +170,7 @@ describe('ol.collection', function() { var collection = new _ol_Collection_(['a']); var removed; _ol_events_.listen( - collection, _ol_CollectionEventType_.REMOVE, function(e) { + collection, CollectionEventType.REMOVE, function(e) { removed = e.element; }); collection.pop(); @@ -183,7 +183,7 @@ describe('ol.collection', function() { var collection = new _ol_Collection_([0, 2]); var added; _ol_events_.listen( - collection, _ol_CollectionEventType_.ADD, function(e) { + collection, CollectionEventType.ADD, function(e) { added = e.element; }); collection.insertAt(1, 1); @@ -195,7 +195,7 @@ describe('ol.collection', function() { it('triggers events properly', function() { var added = []; _ol_events_.listen( - collection, _ol_CollectionEventType_.ADD, function(e) { + collection, CollectionEventType.ADD, function(e) { added.push(e.element); }); collection.setAt(2, 0); @@ -244,7 +244,7 @@ describe('ol.collection', function() { it('triggers add when pushing', function() { var collection = new _ol_Collection_(); var elem; - _ol_events_.listen(collection, _ol_CollectionEventType_.ADD, function(e) { + _ol_events_.listen(collection, CollectionEventType.ADD, function(e) { elem = e.element; }); var length = collection.push(1); @@ -261,8 +261,8 @@ describe('ol.collection', function() { }); describe('setAt', function() { it('triggers remove', function() { - _ol_events_.listen(collection, _ol_CollectionEventType_.ADD, cb1); - _ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, cb2); + _ol_events_.listen(collection, CollectionEventType.ADD, cb1); + _ol_events_.listen(collection, CollectionEventType.REMOVE, cb2); collection.setAt(0, 2); expect(cb2.lastCall.args[0].element).to.eql(1); expect(cb1.lastCall.args[0].element).to.eql(2); @@ -270,7 +270,7 @@ describe('ol.collection', function() { }); describe('pop', function() { it('triggers remove', function() { - _ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, cb1); + _ol_events_.listen(collection, CollectionEventType.REMOVE, cb1); collection.pop(); expect(cb1.lastCall.args[0].element).to.eql(1); }); @@ -288,7 +288,7 @@ describe('ol.collection', function() { it('fires events', function() { var collection = new _ol_Collection_(); var elems = []; - _ol_events_.listen(collection, _ol_CollectionEventType_.ADD, function(e) { + _ol_events_.listen(collection, CollectionEventType.ADD, function(e) { elems.push(e.element); }); collection.extend([1, 2]); From 3e262b4c6b9d3ff3669c82d438b092b8453aa156 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 10:40:36 +0100 Subject: [PATCH 02/16] Rename _ol_MapEventType_ to MapEventType --- src/ol/Overlay.js | 4 ++-- src/ol/PluggableMap.js | 8 ++++---- src/ol/control/Control.js | 4 ++-- src/ol/control/OverviewMap.js | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ol/Overlay.js b/src/ol/Overlay.js index 8aaaae026d..46d7a12688 100644 --- a/src/ol/Overlay.js +++ b/src/ol/Overlay.js @@ -2,7 +2,7 @@ * @module ol/Overlay */ import {inherits} from './index.js'; -import _ol_MapEventType_ from './MapEventType.js'; +import MapEventType from './MapEventType.js'; import _ol_Object_ from './Object.js'; import _ol_OverlayPositioning_ from './OverlayPositioning.js'; import _ol_css_ from './css.js'; @@ -251,7 +251,7 @@ _ol_Overlay_.prototype.handleMapChanged = function() { var map = this.getMap(); if (map) { this.mapPostrenderListenerKey = _ol_events_.listen(map, - _ol_MapEventType_.POSTRENDER, this.render, this); + MapEventType.POSTRENDER, this.render, this); this.updatePixelPosition(); var container = this.stopEvent ? map.getOverlayContainerStopEvent() : map.getOverlayContainer(); diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index 32bca55aa7..1097a7040e 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -8,7 +8,7 @@ import MapBrowserEvent from './MapBrowserEvent.js'; import MapBrowserEventHandler from './MapBrowserEventHandler.js'; import MapBrowserEventType from './MapBrowserEventType.js'; import MapEvent from './MapEvent.js'; -import _ol_MapEventType_ from './MapEventType.js'; +import MapEventType from './MapEventType.js'; import _ol_MapProperty_ from './MapProperty.js'; import _ol_Object_ from './Object.js'; import _ol_ObjectEventType_ from './ObjectEventType.js'; @@ -1254,7 +1254,7 @@ _ol_PluggableMap_.prototype.renderFrame_ = function(time) { !equals(frameState.extent, this.previousExtent_)); if (moveStart) { this.dispatchEvent( - new MapEvent(_ol_MapEventType_.MOVESTART, this, previousFrameState)); + new MapEvent(MapEventType.MOVESTART, this, previousFrameState)); this.previousExtent_ = createOrUpdateEmpty(this.previousExtent_); } } @@ -1266,13 +1266,13 @@ _ol_PluggableMap_.prototype.renderFrame_ = function(time) { if (idle) { this.dispatchEvent( - new MapEvent(_ol_MapEventType_.MOVEEND, this, frameState)); + new MapEvent(MapEventType.MOVEEND, this, frameState)); clone(frameState.extent, this.previousExtent_); } } this.dispatchEvent( - new MapEvent(_ol_MapEventType_.POSTRENDER, this, frameState)); + new MapEvent(MapEventType.POSTRENDER, this, frameState)); setTimeout(this.handlePostRender.bind(this), 0); diff --git a/src/ol/control/Control.js b/src/ol/control/Control.js index 3b9b716e37..f0f12a75cc 100644 --- a/src/ol/control/Control.js +++ b/src/ol/control/Control.js @@ -2,7 +2,7 @@ * @module ol/control/Control */ import {inherits, nullFunction} from '../index.js'; -import _ol_MapEventType_ from '../MapEventType.js'; +import MapEventType from '../MapEventType.js'; import _ol_Object_ from '../Object.js'; import {removeNode} from '../dom.js'; import _ol_events_ from '../events.js'; @@ -120,7 +120,7 @@ Control.prototype.setMap = function(map) { target.appendChild(this.element); if (this.render !== nullFunction) { this.listenerKeys.push(_ol_events_.listen(map, - _ol_MapEventType_.POSTRENDER, this.render, this)); + MapEventType.POSTRENDER, this.render, this)); } map.render(); } diff --git a/src/ol/control/OverviewMap.js b/src/ol/control/OverviewMap.js index a541ca1e94..da4e179837 100644 --- a/src/ol/control/OverviewMap.js +++ b/src/ol/control/OverviewMap.js @@ -4,7 +4,7 @@ import {inherits} from '../index.js'; import _ol_Collection_ from '../Collection.js'; import _ol_PluggableMap_ from '../PluggableMap.js'; -import _ol_MapEventType_ from '../MapEventType.js'; +import MapEventType from '../MapEventType.js'; import _ol_MapProperty_ from '../MapProperty.js'; import _ol_Object_ from '../Object.js'; import _ol_ObjectEventType_ from '../ObjectEventType.js'; @@ -504,7 +504,7 @@ OverviewMap.prototype.handleToggle_ = function() { if (!this.collapsed_ && !ovmap.isRendered()) { ovmap.updateSize(); this.resetExtent_(); - _ol_events_.listenOnce(ovmap, _ol_MapEventType_.POSTRENDER, + _ol_events_.listenOnce(ovmap, MapEventType.POSTRENDER, function(event) { this.updateBox_(); }, From 0a895a2867cf5f079b5221f116300c1302248311 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 10:48:47 +0100 Subject: [PATCH 03/16] Rename _ol_ImageState_ to ImageState --- src/ol/Image.js | 14 +++++++------- src/ol/ImageCanvas.js | 13 ++++++------- src/ol/renderer/Layer.js | 14 ++++++-------- src/ol/renderer/vector.js | 11 +++++------ src/ol/reproj/Image.js | 20 +++++++++----------- src/ol/source/Image.js | 8 ++++---- src/ol/source/ImageStatic.js | 4 ++-- src/ol/style/Icon.js | 4 ++-- src/ol/style/IconImage.js | 12 ++++++------ src/ol/style/RegularShape.js | 4 ++-- 10 files changed, 49 insertions(+), 55 deletions(-) diff --git a/src/ol/Image.js b/src/ol/Image.js index 5f0e147507..86142a86fc 100644 --- a/src/ol/Image.js +++ b/src/ol/Image.js @@ -3,7 +3,7 @@ */ import {inherits} from './index.js'; import _ol_ImageBase_ from './ImageBase.js'; -import _ol_ImageState_ from './ImageState.js'; +import ImageState from './ImageState.js'; import _ol_events_ from './events.js'; import EventType from './events/EventType.js'; import {getHeight} from './extent.js'; @@ -20,7 +20,7 @@ import {getHeight} from './extent.js'; */ var _ol_Image_ = function(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction) { - _ol_ImageBase_.call(this, extent, resolution, pixelRatio, _ol_ImageState_.IDLE); + _ol_ImageBase_.call(this, extent, resolution, pixelRatio, ImageState.IDLE); /** * @private @@ -47,7 +47,7 @@ var _ol_Image_ = function(extent, resolution, pixelRatio, src, crossOrigin, imag * @protected * @type {ol.ImageState} */ - this.state = _ol_ImageState_.IDLE; + this.state = ImageState.IDLE; /** * @private @@ -75,7 +75,7 @@ _ol_Image_.prototype.getImage = function() { * @private */ _ol_Image_.prototype.handleImageError_ = function() { - this.state = _ol_ImageState_.ERROR; + this.state = ImageState.ERROR; this.unlistenImage_(); this.changed(); }; @@ -90,7 +90,7 @@ _ol_Image_.prototype.handleImageLoad_ = function() { if (this.resolution === undefined) { this.resolution = getHeight(this.extent) / this.image_.height; } - this.state = _ol_ImageState_.LOADED; + this.state = ImageState.LOADED; this.unlistenImage_(); this.changed(); }; @@ -104,8 +104,8 @@ _ol_Image_.prototype.handleImageLoad_ = function() { * @api */ _ol_Image_.prototype.load = function() { - if (this.state == _ol_ImageState_.IDLE || this.state == _ol_ImageState_.ERROR) { - this.state = _ol_ImageState_.LOADING; + if (this.state == ImageState.IDLE || this.state == ImageState.ERROR) { + this.state = ImageState.LOADING; this.changed(); this.imageListenerKeys_ = [ _ol_events_.listenOnce(this.image_, EventType.ERROR, diff --git a/src/ol/ImageCanvas.js b/src/ol/ImageCanvas.js index 16e3c74119..ba1783911b 100644 --- a/src/ol/ImageCanvas.js +++ b/src/ol/ImageCanvas.js @@ -3,7 +3,7 @@ */ import {inherits} from './index.js'; import _ol_ImageBase_ from './ImageBase.js'; -import _ol_ImageState_ from './ImageState.js'; +import ImageState from './ImageState.js'; /** * @constructor @@ -24,8 +24,7 @@ var _ol_ImageCanvas_ = function(extent, resolution, pixelRatio, canvas, opt_load */ this.loader_ = opt_loader !== undefined ? opt_loader : null; - var state = opt_loader !== undefined ? - _ol_ImageState_.IDLE : _ol_ImageState_.LOADED; + var state = opt_loader !== undefined ? ImageState.IDLE : ImageState.LOADED; _ol_ImageBase_.call(this, extent, resolution, pixelRatio, state); @@ -63,9 +62,9 @@ _ol_ImageCanvas_.prototype.getError = function() { _ol_ImageCanvas_.prototype.handleLoad_ = function(err) { if (err) { this.error_ = err; - this.state = _ol_ImageState_.ERROR; + this.state = ImageState.ERROR; } else { - this.state = _ol_ImageState_.LOADED; + this.state = ImageState.LOADED; } this.changed(); }; @@ -75,8 +74,8 @@ _ol_ImageCanvas_.prototype.handleLoad_ = function(err) { * @inheritDoc */ _ol_ImageCanvas_.prototype.load = function() { - if (this.state == _ol_ImageState_.IDLE) { - this.state = _ol_ImageState_.LOADING; + if (this.state == ImageState.IDLE) { + this.state = ImageState.LOADING; this.changed(); this.loader_(this.handleLoad_.bind(this)); } diff --git a/src/ol/renderer/Layer.js b/src/ol/renderer/Layer.js index b9f3d82cee..fde1389c4c 100644 --- a/src/ol/renderer/Layer.js +++ b/src/ol/renderer/Layer.js @@ -2,7 +2,7 @@ * @module ol/renderer/Layer */ import {getUid, inherits, nullFunction} from '../index.js'; -import _ol_ImageState_ from '../ImageState.js'; +import ImageState from '../ImageState.js'; import _ol_Observable_ from '../Observable.js'; import _ol_TileState_ from '../TileState.js'; import _ol_events_ from '../events.js'; @@ -98,7 +98,7 @@ _ol_renderer_Layer_.prototype.getLayer = function() { */ _ol_renderer_Layer_.prototype.handleImageChange_ = function(event) { var image = /** @type {ol.Image} */ (event.target); - if (image.getState() === _ol_ImageState_.LOADED) { + if (image.getState() === ImageState.LOADED) { this.renderIfReadyAndVisible(); } }; @@ -114,16 +114,14 @@ _ol_renderer_Layer_.prototype.handleImageChange_ = function(event) { */ _ol_renderer_Layer_.prototype.loadImage = function(image) { var imageState = image.getState(); - if (imageState != _ol_ImageState_.LOADED && - imageState != _ol_ImageState_.ERROR) { - _ol_events_.listen(image, EventType.CHANGE, - this.handleImageChange_, this); + if (imageState != ImageState.LOADED && imageState != ImageState.ERROR) { + _ol_events_.listen(image, EventType.CHANGE, this.handleImageChange_, this); } - if (imageState == _ol_ImageState_.IDLE) { + if (imageState == ImageState.IDLE) { image.load(); imageState = image.getState(); } - return imageState == _ol_ImageState_.LOADED; + return imageState == ImageState.LOADED; }; diff --git a/src/ol/renderer/vector.js b/src/ol/renderer/vector.js index 921b6d26c5..abe0ae7bab 100644 --- a/src/ol/renderer/vector.js +++ b/src/ol/renderer/vector.js @@ -2,7 +2,7 @@ * @module ol/renderer/vector */ import {getUid} from '../index.js'; -import _ol_ImageState_ from '../ImageState.js'; +import ImageState from '../ImageState.js'; import GeometryType from '../geom/GeometryType.js'; import _ol_render_ReplayType_ from '../render/ReplayType.js'; var _ol_renderer_vector_ = {}; @@ -88,11 +88,10 @@ _ol_renderer_vector_.renderFeature = function( imageStyle = style.getImage(); if (imageStyle) { imageState = imageStyle.getImageState(); - if (imageState == _ol_ImageState_.LOADED || - imageState == _ol_ImageState_.ERROR) { + if (imageState == ImageState.LOADED || imageState == ImageState.ERROR) { imageStyle.unlistenImageChange(listener, thisArg); } else { - if (imageState == _ol_ImageState_.IDLE) { + if (imageState == ImageState.IDLE) { imageStyle.load(); } imageState = imageStyle.getImageState(); @@ -256,7 +255,7 @@ _ol_renderer_vector_.renderMultiPolygonGeometry_ = function(replayGroup, geometr _ol_renderer_vector_.renderPointGeometry_ = function(replayGroup, geometry, style, feature) { var imageStyle = style.getImage(); if (imageStyle) { - if (imageStyle.getImageState() != _ol_ImageState_.LOADED) { + if (imageStyle.getImageState() != ImageState.LOADED) { return; } var imageReplay = replayGroup.getReplay( @@ -284,7 +283,7 @@ _ol_renderer_vector_.renderPointGeometry_ = function(replayGroup, geometry, styl _ol_renderer_vector_.renderMultiPointGeometry_ = function(replayGroup, geometry, style, feature) { var imageStyle = style.getImage(); if (imageStyle) { - if (imageStyle.getImageState() != _ol_ImageState_.LOADED) { + if (imageStyle.getImageState() != ImageState.LOADED) { return; } var imageReplay = replayGroup.getReplay( diff --git a/src/ol/reproj/Image.js b/src/ol/reproj/Image.js index 0379256a65..a764964dda 100644 --- a/src/ol/reproj/Image.js +++ b/src/ol/reproj/Image.js @@ -4,7 +4,7 @@ import {ERROR_THRESHOLD} from './common.js'; import {inherits} from '../index.js'; import _ol_ImageBase_ from '../ImageBase.js'; -import _ol_ImageState_ from '../ImageState.js'; +import ImageState from '../ImageState.js'; import _ol_events_ from '../events.js'; import EventType from '../events/EventType.js'; import {getCenter, getIntersection, getHeight, getWidth} from '../extent.js'; @@ -100,10 +100,10 @@ var _ol_reproj_Image_ = function(sourceProj, targetProj, this.sourceListenerKey_ = null; - var state = _ol_ImageState_.LOADED; + var state = ImageState.LOADED; if (this.sourceImage_) { - state = _ol_ImageState_.IDLE; + state = ImageState.IDLE; } _ol_ImageBase_.call(this, targetExtent, targetResolution, this.sourcePixelRatio_, state); @@ -116,7 +116,7 @@ inherits(_ol_reproj_Image_, _ol_ImageBase_); * @inheritDoc */ _ol_reproj_Image_.prototype.disposeInternal = function() { - if (this.state == _ol_ImageState_.LOADING) { + if (this.state == ImageState.LOADING) { this.unlistenSource_(); } _ol_ImageBase_.prototype.disposeInternal.call(this); @@ -144,7 +144,7 @@ _ol_reproj_Image_.prototype.getProjection = function() { */ _ol_reproj_Image_.prototype.reproject_ = function() { var sourceState = this.sourceImage_.getState(); - if (sourceState == _ol_ImageState_.LOADED) { + if (sourceState == ImageState.LOADED) { var width = getWidth(this.targetExtent_) / this.targetResolution_; var height = getHeight(this.targetExtent_) / this.targetResolution_; @@ -164,20 +164,18 @@ _ol_reproj_Image_.prototype.reproject_ = function() { * @inheritDoc */ _ol_reproj_Image_.prototype.load = function() { - if (this.state == _ol_ImageState_.IDLE) { - this.state = _ol_ImageState_.LOADING; + if (this.state == ImageState.IDLE) { + this.state = ImageState.LOADING; this.changed(); var sourceState = this.sourceImage_.getState(); - if (sourceState == _ol_ImageState_.LOADED || - sourceState == _ol_ImageState_.ERROR) { + if (sourceState == ImageState.LOADED || sourceState == ImageState.ERROR) { this.reproject_(); } else { this.sourceListenerKey_ = _ol_events_.listen(this.sourceImage_, EventType.CHANGE, function(e) { var sourceState = this.sourceImage_.getState(); - if (sourceState == _ol_ImageState_.LOADED || - sourceState == _ol_ImageState_.ERROR) { + if (sourceState == ImageState.LOADED || sourceState == ImageState.ERROR) { this.unlistenSource_(); this.reproject_(); } diff --git a/src/ol/source/Image.js b/src/ol/source/Image.js index 6682fd1489..7a2e76f934 100644 --- a/src/ol/source/Image.js +++ b/src/ol/source/Image.js @@ -3,7 +3,7 @@ */ import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js'; import {inherits} from '../index.js'; -import _ol_ImageState_ from '../ImageState.js'; +import ImageState from '../ImageState.js'; import _ol_array_ from '../array.js'; import Event from '../events/Event.js'; import {equals} from '../extent.js'; @@ -142,17 +142,17 @@ _ol_source_Image_.prototype.getImageInternal = function(extent, resolution, pixe _ol_source_Image_.prototype.handleImageChange = function(event) { var image = /** @type {ol.Image} */ (event.target); switch (image.getState()) { - case _ol_ImageState_.LOADING: + case ImageState.LOADING: this.dispatchEvent( new _ol_source_Image_.Event(_ol_source_Image_.EventType_.IMAGELOADSTART, image)); break; - case _ol_ImageState_.LOADED: + case ImageState.LOADED: this.dispatchEvent( new _ol_source_Image_.Event(_ol_source_Image_.EventType_.IMAGELOADEND, image)); break; - case _ol_ImageState_.ERROR: + case ImageState.ERROR: this.dispatchEvent( new _ol_source_Image_.Event(_ol_source_Image_.EventType_.IMAGELOADERROR, image)); diff --git a/src/ol/source/ImageStatic.js b/src/ol/source/ImageStatic.js index 8fc7e1a3a0..4c269736d2 100644 --- a/src/ol/source/ImageStatic.js +++ b/src/ol/source/ImageStatic.js @@ -3,7 +3,7 @@ */ import {inherits} from '../index.js'; import _ol_Image_ from '../Image.js'; -import _ol_ImageState_ from '../ImageState.js'; +import ImageState from '../ImageState.js'; import {createCanvasContext2D} from '../dom.js'; import _ol_events_ from '../events.js'; import EventType from '../events/EventType.js'; @@ -70,7 +70,7 @@ _ol_source_ImageStatic_.prototype.getImageInternal = function(extent, resolution * @inheritDoc */ _ol_source_ImageStatic_.prototype.handleImageChange = function(evt) { - if (this.image_.getState() == _ol_ImageState_.LOADED) { + if (this.image_.getState() == ImageState.LOADED) { var imageExtent = this.image_.getExtent(); var image = this.image_.getImage(); var imageWidth, imageHeight; diff --git a/src/ol/style/Icon.js b/src/ol/style/Icon.js index 68e2dfea50..7fa9099a18 100644 --- a/src/ol/style/Icon.js +++ b/src/ol/style/Icon.js @@ -2,7 +2,7 @@ * @module ol/style/Icon */ import {getUid, inherits} from '../index.js'; -import _ol_ImageState_ from '../ImageState.js'; +import ImageState from '../ImageState.js'; import {assert} from '../asserts.js'; import _ol_color_ from '../color.js'; import _ol_events_ from '../events.js'; @@ -95,7 +95,7 @@ var _ol_style_Icon_ = function(opt_options) { * @type {ol.ImageState} */ var imageState = options.src !== undefined ? - _ol_ImageState_.IDLE : _ol_ImageState_.LOADED; + ImageState.IDLE : ImageState.LOADED; /** * @private diff --git a/src/ol/style/IconImage.js b/src/ol/style/IconImage.js index be0e57f23f..ee92b98241 100644 --- a/src/ol/style/IconImage.js +++ b/src/ol/style/IconImage.js @@ -6,7 +6,7 @@ import {createCanvasContext2D} from '../dom.js'; import _ol_events_ from '../events.js'; import EventTarget from '../events/EventTarget.js'; import EventType from '../events/EventType.js'; -import _ol_ImageState_ from '../ImageState.js'; +import ImageState from '../ImageState.js'; import _ol_style_ from '../style.js'; /** @@ -83,7 +83,7 @@ var _ol_style_IconImage_ = function(image, src, size, crossOrigin, imageState, * @type {boolean} */ this.tainting_ = false; - if (this.imageState_ == _ol_ImageState_.LOADED) { + if (this.imageState_ == ImageState.LOADED) { this.determineTainting_(); } @@ -140,7 +140,7 @@ _ol_style_IconImage_.prototype.dispatchChangeEvent_ = function() { * @private */ _ol_style_IconImage_.prototype.handleImageError_ = function() { - this.imageState_ = _ol_ImageState_.ERROR; + this.imageState_ = ImageState.ERROR; this.unlistenImage_(); this.dispatchChangeEvent_(); }; @@ -150,7 +150,7 @@ _ol_style_IconImage_.prototype.handleImageError_ = function() { * @private */ _ol_style_IconImage_.prototype.handleImageLoad_ = function() { - this.imageState_ = _ol_ImageState_.LOADED; + this.imageState_ = ImageState.LOADED; if (this.size_) { this.image_.width = this.size_[0]; this.image_.height = this.size_[1]; @@ -220,8 +220,8 @@ _ol_style_IconImage_.prototype.getSrc = function() { * Load not yet loaded URI. */ _ol_style_IconImage_.prototype.load = function() { - if (this.imageState_ == _ol_ImageState_.IDLE) { - this.imageState_ = _ol_ImageState_.LOADING; + if (this.imageState_ == ImageState.IDLE) { + this.imageState_ = ImageState.LOADING; this.imageListenerKeys_ = [ _ol_events_.listenOnce(this.image_, EventType.ERROR, this.handleImageError_, this), diff --git a/src/ol/style/RegularShape.js b/src/ol/style/RegularShape.js index f1c9525dc4..c08d7066bb 100644 --- a/src/ol/style/RegularShape.js +++ b/src/ol/style/RegularShape.js @@ -5,7 +5,7 @@ import {inherits} from '../index.js'; import {asColorLike} from '../colorlike.js'; import {createCanvasContext2D} from '../dom.js'; import _ol_has_ from '../has.js'; -import _ol_ImageState_ from '../ImageState.js'; +import ImageState from '../ImageState.js'; import _ol_render_canvas_ from '../render/canvas.js'; import _ol_style_Image_ from '../style/Image.js'; @@ -228,7 +228,7 @@ _ol_style_RegularShape_.prototype.getHitDetectionImageSize = function() { * @inheritDoc */ _ol_style_RegularShape_.prototype.getImageState = function() { - return _ol_ImageState_.LOADED; + return ImageState.LOADED; }; From 424ea2213140f26268f785c7cd55ca0d5bd7ac98 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 10:53:12 +0100 Subject: [PATCH 04/16] Rename _ol_style_TextPlacement_ to TextPlacement --- src/ol/render/canvas/TextReplay.js | 4 ++-- src/ol/style/Text.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ol/render/canvas/TextReplay.js b/src/ol/render/canvas/TextReplay.js index cda2361ef5..75d2673114 100644 --- a/src/ol/render/canvas/TextReplay.js +++ b/src/ol/render/canvas/TextReplay.js @@ -12,7 +12,7 @@ import _ol_render_canvas_ from '../canvas.js'; import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js'; import _ol_render_canvas_Replay_ from '../canvas/Replay.js'; import _ol_render_replay_ from '../replay.js'; -import _ol_style_TextPlacement_ from '../../style/TextPlacement.js'; +import TextPlacement from '../../style/TextPlacement.js'; /** * @constructor @@ -176,7 +176,7 @@ _ol_render_canvas_TextReplay_.prototype.drawText = function(geometry, feature) { var stride = 2; var i, ii; - if (textState.placement === _ol_style_TextPlacement_.LINE) { + if (textState.placement === TextPlacement.LINE) { if (!intersects(this.getBufferedMaxExtent(), geometry.getExtent())) { return; } diff --git a/src/ol/style/Text.js b/src/ol/style/Text.js index 7ac9d4b4cc..d4a3aa3744 100644 --- a/src/ol/style/Text.js +++ b/src/ol/style/Text.js @@ -2,7 +2,7 @@ * @module ol/style/Text */ import _ol_style_Fill_ from '../style/Fill.js'; -import _ol_style_TextPlacement_ from '../style/TextPlacement.js'; +import TextPlacement from '../style/TextPlacement.js'; /** * @classdesc @@ -75,7 +75,7 @@ var _ol_style_Text_ = function(opt_options) { * @private * @type {ol.style.TextPlacement|string} */ - this.placement_ = options.placement !== undefined ? options.placement : _ol_style_TextPlacement_.POINT; + this.placement_ = options.placement !== undefined ? options.placement : TextPlacement.POINT; /** * @private From e4446d4cb35d1fda5917f5b20f96db17e1f1138e Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 10:56:08 +0100 Subject: [PATCH 05/16] Rename _ol_style_IconOrigin_ to IconOrigin --- src/ol/format/KML.js | 16 ++++++++-------- src/ol/style/Icon.js | 26 +++++++++++++------------- test/spec/ol/format/kml.test.js | 12 ++++++------ 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/ol/format/KML.js b/src/ol/format/KML.js index 984e5f2dce..6d94cf6ad1 100644 --- a/src/ol/format/KML.js +++ b/src/ol/format/KML.js @@ -23,7 +23,7 @@ import {get as getProjection} from '../proj.js'; import _ol_style_Fill_ from '../style/Fill.js'; import _ol_style_Icon_ from '../style/Icon.js'; import _ol_style_IconAnchorUnits_ from '../style/IconAnchorUnits.js'; -import _ol_style_IconOrigin_ from '../style/IconOrigin.js'; +import IconOrigin from '../style/IconOrigin.js'; import _ol_style_Stroke_ from '../style/Stroke.js'; import _ol_style_Style_ from '../style/Style.js'; import _ol_style_Text_ from '../style/Text.js'; @@ -201,7 +201,7 @@ KML.createStyleDefaults_ = function() { */ KML.DEFAULT_IMAGE_STYLE_ = new _ol_style_Icon_({ anchor: KML.DEFAULT_IMAGE_STYLE_ANCHOR_, - anchorOrigin: _ol_style_IconOrigin_.BOTTOM_LEFT, + anchorOrigin: IconOrigin.BOTTOM_LEFT, anchorXUnits: KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_, anchorYUnits: KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_, crossOrigin: 'anonymous', @@ -509,15 +509,15 @@ KML.readVec2_ = function(node) { var origin; if (xunits !== 'insetPixels') { if (yunits !== 'insetPixels') { - origin = _ol_style_IconOrigin_.BOTTOM_LEFT; + origin = IconOrigin.BOTTOM_LEFT; } else { - origin = _ol_style_IconOrigin_.TOP_LEFT; + origin = IconOrigin.TOP_LEFT; } } else { if (yunits !== 'insetPixels') { - origin = _ol_style_IconOrigin_.BOTTOM_RIGHT; + origin = IconOrigin.BOTTOM_RIGHT; } else { - origin = _ol_style_IconOrigin_.TOP_RIGHT; + origin = IconOrigin.TOP_RIGHT; } } return { @@ -579,7 +579,7 @@ KML.IconStyleParser_ = function(node, objectStack) { src = KML.DEFAULT_IMAGE_STYLE_SRC_; } var anchor, anchorXUnits, anchorYUnits; - var anchorOrigin = _ol_style_IconOrigin_.BOTTOM_LEFT; + var anchorOrigin = IconOrigin.BOTTOM_LEFT; var hotSpot = /** @type {ol.KMLVec2_|undefined} */ (object['hotSpot']); if (hotSpot) { @@ -640,7 +640,7 @@ KML.IconStyleParser_ = function(node, objectStack) { anchorYUnits: anchorYUnits, crossOrigin: 'anonymous', // FIXME should this be configurable? offset: offset, - offsetOrigin: _ol_style_IconOrigin_.BOTTOM_LEFT, + offsetOrigin: IconOrigin.BOTTOM_LEFT, rotation: rotation, scale: scale, size: size, diff --git a/src/ol/style/Icon.js b/src/ol/style/Icon.js index 7fa9099a18..cae2e6af34 100644 --- a/src/ol/style/Icon.js +++ b/src/ol/style/Icon.js @@ -9,7 +9,7 @@ import _ol_events_ from '../events.js'; import EventType from '../events/EventType.js'; import _ol_style_IconAnchorUnits_ from '../style/IconAnchorUnits.js'; import _ol_style_IconImage_ from '../style/IconImage.js'; -import _ol_style_IconOrigin_ from '../style/IconOrigin.js'; +import IconOrigin from '../style/IconOrigin.js'; import _ol_style_Image_ from '../style/Image.js'; /** @@ -42,7 +42,7 @@ var _ol_style_Icon_ = function(opt_options) { * @type {ol.style.IconOrigin} */ this.anchorOrigin_ = options.anchorOrigin !== undefined ? - options.anchorOrigin : _ol_style_IconOrigin_.TOP_LEFT; + options.anchorOrigin : IconOrigin.TOP_LEFT; /** * @private @@ -122,7 +122,7 @@ var _ol_style_Icon_ = function(opt_options) { * @type {ol.style.IconOrigin} */ this.offsetOrigin_ = options.offsetOrigin !== undefined ? - options.offsetOrigin : _ol_style_IconOrigin_.TOP_LEFT; + options.offsetOrigin : IconOrigin.TOP_LEFT; /** * @private @@ -226,19 +226,19 @@ _ol_style_Icon_.prototype.getAnchor = function() { } } - if (this.anchorOrigin_ != _ol_style_IconOrigin_.TOP_LEFT) { + if (this.anchorOrigin_ != IconOrigin.TOP_LEFT) { if (!size) { return null; } if (anchor === this.anchor_) { anchor = this.anchor_.slice(); } - if (this.anchorOrigin_ == _ol_style_IconOrigin_.TOP_RIGHT || - this.anchorOrigin_ == _ol_style_IconOrigin_.BOTTOM_RIGHT) { + if (this.anchorOrigin_ == IconOrigin.TOP_RIGHT || + this.anchorOrigin_ == IconOrigin.BOTTOM_RIGHT) { anchor[0] = -anchor[0] + size[0]; } - if (this.anchorOrigin_ == _ol_style_IconOrigin_.BOTTOM_LEFT || - this.anchorOrigin_ == _ol_style_IconOrigin_.BOTTOM_RIGHT) { + if (this.anchorOrigin_ == IconOrigin.BOTTOM_LEFT || + this.anchorOrigin_ == IconOrigin.BOTTOM_RIGHT) { anchor[1] = -anchor[1] + size[1]; } } @@ -311,19 +311,19 @@ _ol_style_Icon_.prototype.getOrigin = function() { } var offset = this.offset_; - if (this.offsetOrigin_ != _ol_style_IconOrigin_.TOP_LEFT) { + if (this.offsetOrigin_ != IconOrigin.TOP_LEFT) { var size = this.getSize(); var iconImageSize = this.iconImage_.getSize(); if (!size || !iconImageSize) { return null; } offset = offset.slice(); - if (this.offsetOrigin_ == _ol_style_IconOrigin_.TOP_RIGHT || - this.offsetOrigin_ == _ol_style_IconOrigin_.BOTTOM_RIGHT) { + if (this.offsetOrigin_ == IconOrigin.TOP_RIGHT || + this.offsetOrigin_ == IconOrigin.BOTTOM_RIGHT) { offset[0] = iconImageSize[0] - size[0] - offset[0]; } - if (this.offsetOrigin_ == _ol_style_IconOrigin_.BOTTOM_LEFT || - this.offsetOrigin_ == _ol_style_IconOrigin_.BOTTOM_RIGHT) { + if (this.offsetOrigin_ == IconOrigin.BOTTOM_LEFT || + this.offsetOrigin_ == IconOrigin.BOTTOM_RIGHT) { offset[1] = iconImageSize[1] - size[1] - offset[1]; } } diff --git a/test/spec/ol/format/kml.test.js b/test/spec/ol/format/kml.test.js index b9a48642d9..2209435f0e 100644 --- a/test/spec/ol/format/kml.test.js +++ b/test/spec/ol/format/kml.test.js @@ -17,7 +17,7 @@ import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js'; import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; import _ol_style_Icon_ from '../../../../src/ol/style/Icon.js'; import _ol_style_IconAnchorUnits_ from '../../../../src/ol/style/IconAnchorUnits.js'; -import _ol_style_IconOrigin_ from '../../../../src/ol/style/IconOrigin.js'; +import IconOrigin from '../../../../src/ol/style/IconOrigin.js'; import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; import _ol_style_Text_ from '../../../../src/ol/style/Text.js'; @@ -1843,7 +1843,7 @@ describe('ol.format.KML', function() { if (f.getId() == 1) { expect(imageStyle.anchor_[0]).to.be(0.5); expect(imageStyle.anchor_[1]).to.be(0.5); - expect(imageStyle.anchorOrigin_).to.be(_ol_style_IconOrigin_.BOTTOM_LEFT); + expect(imageStyle.anchorOrigin_).to.be(IconOrigin.BOTTOM_LEFT); expect(imageStyle.anchorXUnits_).to.be(_ol_style_IconAnchorUnits_.FRACTION); expect(imageStyle.anchorYUnits_).to.be(_ol_style_IconAnchorUnits_.FRACTION); } else { @@ -1852,16 +1852,16 @@ describe('ol.format.KML', function() { expect(imageStyle.anchorXUnits_).to.be(_ol_style_IconAnchorUnits_.PIXELS); expect(imageStyle.anchorYUnits_).to.be(_ol_style_IconAnchorUnits_.PIXELS); if (f.getId() == 2) { - expect(imageStyle.anchorOrigin_).to.be(_ol_style_IconOrigin_.BOTTOM_LEFT); + expect(imageStyle.anchorOrigin_).to.be(IconOrigin.BOTTOM_LEFT); } if (f.getId() == 3) { - expect(imageStyle.anchorOrigin_).to.be(_ol_style_IconOrigin_.BOTTOM_RIGHT); + expect(imageStyle.anchorOrigin_).to.be(IconOrigin.BOTTOM_RIGHT); } if (f.getId() == 4) { - expect(imageStyle.anchorOrigin_).to.be(_ol_style_IconOrigin_.TOP_LEFT); + expect(imageStyle.anchorOrigin_).to.be(IconOrigin.TOP_LEFT); } if (f.getId() == 5) { - expect(imageStyle.anchorOrigin_).to.be(_ol_style_IconOrigin_.TOP_RIGHT); + expect(imageStyle.anchorOrigin_).to.be(IconOrigin.TOP_RIGHT); } } expect(imageStyle.getRotation()).to.eql(0); From bbd8a3f6aea1b38069f1c523777c4b22f056147e Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 10:58:16 +0100 Subject: [PATCH 06/16] Rename _ol_style_IconAnchorUnits_ to IconAnchorUnits --- src/ol/format/KML.js | 22 ++++++++++------------ src/ol/style/Icon.js | 14 +++++++------- test/spec/ol/format/kml.test.js | 10 +++++----- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/ol/format/KML.js b/src/ol/format/KML.js index 6d94cf6ad1..81b1d5f985 100644 --- a/src/ol/format/KML.js +++ b/src/ol/format/KML.js @@ -22,7 +22,7 @@ import _ol_math_ from '../math.js'; import {get as getProjection} from '../proj.js'; import _ol_style_Fill_ from '../style/Fill.js'; import _ol_style_Icon_ from '../style/Icon.js'; -import _ol_style_IconAnchorUnits_ from '../style/IconAnchorUnits.js'; +import IconAnchorUnits from '../style/IconAnchorUnits.js'; import IconOrigin from '../style/IconOrigin.js'; import _ol_style_Stroke_ from '../style/Stroke.js'; import _ol_style_Style_ from '../style/Style.js'; @@ -161,16 +161,14 @@ KML.createStyleDefaults_ = function() { * @type {ol.style.IconAnchorUnits} * @private */ - KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_ = - _ol_style_IconAnchorUnits_.PIXELS; + KML.DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS_ = IconAnchorUnits.PIXELS; /** * @const * @type {ol.style.IconAnchorUnits} * @private */ - KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_ = - _ol_style_IconAnchorUnits_.PIXELS; + KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_ = IconAnchorUnits.PIXELS; /** * @const @@ -280,9 +278,9 @@ KML.createStyleDefaults_ = function() { * @private */ KML.ICON_ANCHOR_UNITS_MAP_ = { - 'fraction': _ol_style_IconAnchorUnits_.FRACTION, - 'pixels': _ol_style_IconAnchorUnits_.PIXELS, - 'insetPixels': _ol_style_IconAnchorUnits_.PIXELS + 'fraction': IconAnchorUnits.FRACTION, + 'pixels': IconAnchorUnits.PIXELS, + 'insetPixels': IconAnchorUnits.PIXELS }; @@ -593,8 +591,8 @@ KML.IconStyleParser_ = function(node, objectStack) { anchorYUnits = KML.DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS_; } else if (/^http:\/\/maps\.(?:google|gstatic)\.com\//.test(src)) { anchor = [0.5, 0]; - anchorXUnits = _ol_style_IconAnchorUnits_.FRACTION; - anchorYUnits = _ol_style_IconAnchorUnits_.FRACTION; + anchorXUnits = IconAnchorUnits.FRACTION; + anchorYUnits = IconAnchorUnits.FRACTION; } var offset; @@ -2279,9 +2277,9 @@ KML.writeIconStyle_ = function(node, style, objectStack) { if (anchor && (anchor[0] !== size[0] / 2 || anchor[1] !== size[1] / 2)) { var /** @type {ol.KMLVec2_} */ hotSpot = { x: anchor[0], - xunits: _ol_style_IconAnchorUnits_.PIXELS, + xunits: IconAnchorUnits.PIXELS, y: size[1] - anchor[1], - yunits: _ol_style_IconAnchorUnits_.PIXELS + yunits: IconAnchorUnits.PIXELS }; properties['hotSpot'] = hotSpot; } diff --git a/src/ol/style/Icon.js b/src/ol/style/Icon.js index cae2e6af34..ed99ebf37a 100644 --- a/src/ol/style/Icon.js +++ b/src/ol/style/Icon.js @@ -7,7 +7,7 @@ import {assert} from '../asserts.js'; import _ol_color_ from '../color.js'; import _ol_events_ from '../events.js'; import EventType from '../events/EventType.js'; -import _ol_style_IconAnchorUnits_ from '../style/IconAnchorUnits.js'; +import IconAnchorUnits from '../style/IconAnchorUnits.js'; import _ol_style_IconImage_ from '../style/IconImage.js'; import IconOrigin from '../style/IconOrigin.js'; import _ol_style_Image_ from '../style/Image.js'; @@ -49,14 +49,14 @@ var _ol_style_Icon_ = function(opt_options) { * @type {ol.style.IconAnchorUnits} */ this.anchorXUnits_ = options.anchorXUnits !== undefined ? - options.anchorXUnits : _ol_style_IconAnchorUnits_.FRACTION; + options.anchorXUnits : IconAnchorUnits.FRACTION; /** * @private * @type {ol.style.IconAnchorUnits} */ this.anchorYUnits_ = options.anchorYUnits !== undefined ? - options.anchorYUnits : _ol_style_IconAnchorUnits_.FRACTION; + options.anchorYUnits : IconAnchorUnits.FRACTION; /** * @private @@ -212,16 +212,16 @@ _ol_style_Icon_.prototype.getAnchor = function() { } var anchor = this.anchor_; var size = this.getSize(); - if (this.anchorXUnits_ == _ol_style_IconAnchorUnits_.FRACTION || - this.anchorYUnits_ == _ol_style_IconAnchorUnits_.FRACTION) { + if (this.anchorXUnits_ == IconAnchorUnits.FRACTION || + this.anchorYUnits_ == IconAnchorUnits.FRACTION) { if (!size) { return null; } anchor = this.anchor_.slice(); - if (this.anchorXUnits_ == _ol_style_IconAnchorUnits_.FRACTION) { + if (this.anchorXUnits_ == IconAnchorUnits.FRACTION) { anchor[0] *= size[0]; } - if (this.anchorYUnits_ == _ol_style_IconAnchorUnits_.FRACTION) { + if (this.anchorYUnits_ == IconAnchorUnits.FRACTION) { anchor[1] *= size[1]; } } diff --git a/test/spec/ol/format/kml.test.js b/test/spec/ol/format/kml.test.js index 2209435f0e..7a30ac2cfd 100644 --- a/test/spec/ol/format/kml.test.js +++ b/test/spec/ol/format/kml.test.js @@ -16,7 +16,7 @@ import {remove as removeTransform} from '../../../../src/ol/proj/transforms.js'; import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js'; import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; import _ol_style_Icon_ from '../../../../src/ol/style/Icon.js'; -import _ol_style_IconAnchorUnits_ from '../../../../src/ol/style/IconAnchorUnits.js'; +import IconAnchorUnits from '../../../../src/ol/style/IconAnchorUnits.js'; import IconOrigin from '../../../../src/ol/style/IconOrigin.js'; import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js'; import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; @@ -1844,13 +1844,13 @@ describe('ol.format.KML', function() { expect(imageStyle.anchor_[0]).to.be(0.5); expect(imageStyle.anchor_[1]).to.be(0.5); expect(imageStyle.anchorOrigin_).to.be(IconOrigin.BOTTOM_LEFT); - expect(imageStyle.anchorXUnits_).to.be(_ol_style_IconAnchorUnits_.FRACTION); - expect(imageStyle.anchorYUnits_).to.be(_ol_style_IconAnchorUnits_.FRACTION); + expect(imageStyle.anchorXUnits_).to.be(IconAnchorUnits.FRACTION); + expect(imageStyle.anchorYUnits_).to.be(IconAnchorUnits.FRACTION); } else { expect(imageStyle.anchor_[0]).to.be(5); expect(imageStyle.anchor_[1]).to.be(5); - expect(imageStyle.anchorXUnits_).to.be(_ol_style_IconAnchorUnits_.PIXELS); - expect(imageStyle.anchorYUnits_).to.be(_ol_style_IconAnchorUnits_.PIXELS); + expect(imageStyle.anchorXUnits_).to.be(IconAnchorUnits.PIXELS); + expect(imageStyle.anchorYUnits_).to.be(IconAnchorUnits.PIXELS); if (f.getId() == 2) { expect(imageStyle.anchorOrigin_).to.be(IconOrigin.BOTTOM_LEFT); } From 7fd957c2e51811393b6a1d3a246639b2450f10b5 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 11:08:05 +0100 Subject: [PATCH 07/16] Rename _ol_style_IconImageCache_ to IconImageCache --- src/ol/style.js | 4 ++-- src/ol/style/IconImageCache.js | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ol/style.js b/src/ol/style.js index 744ffc2474..b9bc21cd64 100644 --- a/src/ol/style.js +++ b/src/ol/style.js @@ -1,12 +1,12 @@ /** * @module ol/style */ -import _ol_style_IconImageCache_ from './style/IconImageCache.js'; +import IconImageCache from './style/IconImageCache.js'; var _ol_style_ = {}; /** * The {@link ol.style.IconImageCache} for {@link ol.style.Icon} images. * @api */ -_ol_style_.iconImageCache = new _ol_style_IconImageCache_(); +_ol_style_.iconImageCache = new IconImageCache(); export default _ol_style_; diff --git a/src/ol/style/IconImageCache.js b/src/ol/style/IconImageCache.js index 14935640f4..c7c773664a 100644 --- a/src/ol/style/IconImageCache.js +++ b/src/ol/style/IconImageCache.js @@ -7,7 +7,7 @@ import _ol_color_ from '../color.js'; * Singleton class. Available through {@link ol.style.iconImageCache}. * @constructor */ -var _ol_style_IconImageCache_ = function() { +var IconImageCache = function() { /** * @type {Object.} @@ -35,16 +35,16 @@ var _ol_style_IconImageCache_ = function() { * @param {ol.Color} color Color. * @return {string} Cache key. */ -_ol_style_IconImageCache_.getKey = function(src, crossOrigin, color) { +function getKey(src, crossOrigin, color) { var colorString = color ? _ol_color_.asString(color) : 'null'; return crossOrigin + ':' + src + ':' + colorString; -}; +} /** * FIXME empty description for jsdoc */ -_ol_style_IconImageCache_.prototype.clear = function() { +IconImageCache.prototype.clear = function() { this.cache_ = {}; this.cacheSize_ = 0; }; @@ -53,7 +53,7 @@ _ol_style_IconImageCache_.prototype.clear = function() { /** * FIXME empty description for jsdoc */ -_ol_style_IconImageCache_.prototype.expire = function() { +IconImageCache.prototype.expire = function() { if (this.cacheSize_ > this.maxCacheSize_) { var i = 0; var key, iconImage; @@ -74,8 +74,8 @@ _ol_style_IconImageCache_.prototype.expire = function() { * @param {ol.Color} color Color. * @return {ol.style.IconImage} Icon image. */ -_ol_style_IconImageCache_.prototype.get = function(src, crossOrigin, color) { - var key = _ol_style_IconImageCache_.getKey(src, crossOrigin, color); +IconImageCache.prototype.get = function(src, crossOrigin, color) { + var key = getKey(src, crossOrigin, color); return key in this.cache_ ? this.cache_[key] : null; }; @@ -86,8 +86,8 @@ _ol_style_IconImageCache_.prototype.get = function(src, crossOrigin, color) { * @param {ol.Color} color Color. * @param {ol.style.IconImage} iconImage Icon image. */ -_ol_style_IconImageCache_.prototype.set = function(src, crossOrigin, color, iconImage) { - var key = _ol_style_IconImageCache_.getKey(src, crossOrigin, color); +IconImageCache.prototype.set = function(src, crossOrigin, color, iconImage) { + var key = getKey(src, crossOrigin, color); this.cache_[key] = iconImage; ++this.cacheSize_; }; @@ -100,8 +100,8 @@ _ol_style_IconImageCache_.prototype.set = function(src, crossOrigin, color, icon * @param {number} maxCacheSize Cache max size. * @api */ -_ol_style_IconImageCache_.prototype.setSize = function(maxCacheSize) { +IconImageCache.prototype.setSize = function(maxCacheSize) { this.maxCacheSize_ = maxCacheSize; this.expire(); }; -export default _ol_style_IconImageCache_; +export default IconImageCache; From e23d0bf907d41ca552fb2ae2b1d08d7a5e905ed9 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 12:33:21 +0100 Subject: [PATCH 08/16] Rename _ol_ObjectEventType_ to ObjectEventType --- src/ol/Object.js | 4 ++-- src/ol/PluggableMap.js | 6 +++--- src/ol/control/OverviewMap.js | 4 ++-- src/ol/layer/Group.js | 6 +++--- src/ol/source/Vector.js | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ol/Object.js b/src/ol/Object.js index 29bf981ac1..10f8fe0ea6 100644 --- a/src/ol/Object.js +++ b/src/ol/Object.js @@ -2,7 +2,7 @@ * @module ol/Object */ import {getUid, inherits} from './index.js'; -import _ol_ObjectEventType_ from './ObjectEventType.js'; +import ObjectEventType from './ObjectEventType.js'; import _ol_Observable_ from './Observable.js'; import Event from './events/Event.js'; import _ol_obj_ from './obj.js'; @@ -136,7 +136,7 @@ _ol_Object_.prototype.notify = function(key, oldValue) { var eventType; eventType = _ol_Object_.getChangeEventType(key); this.dispatchEvent(new _ol_Object_.Event(eventType, key, oldValue)); - eventType = _ol_ObjectEventType_.PROPERTYCHANGE; + eventType = ObjectEventType.PROPERTYCHANGE; this.dispatchEvent(new _ol_Object_.Event(eventType, key, oldValue)); }; diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index 1097a7040e..3d0c5490f5 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -11,7 +11,7 @@ import MapEvent from './MapEvent.js'; import MapEventType from './MapEventType.js'; import _ol_MapProperty_ from './MapProperty.js'; import _ol_Object_ from './Object.js'; -import _ol_ObjectEventType_ from './ObjectEventType.js'; +import ObjectEventType from './ObjectEventType.js'; import TileQueue from './TileQueue.js'; import _ol_View_ from './View.js'; import _ol_ViewHint_ from './ViewHint.js'; @@ -1072,7 +1072,7 @@ _ol_PluggableMap_.prototype.handleViewChanged_ = function() { if (view) { this.viewport_.setAttribute('data-view', getUid(view)); this.viewPropertyListenerKey_ = _ol_events_.listen( - view, _ol_ObjectEventType_.PROPERTYCHANGE, + view, ObjectEventType.PROPERTYCHANGE, this.handleViewPropertyChanged_, this); this.viewChangeListenerKey_ = _ol_events_.listen( view, EventType.CHANGE, @@ -1094,7 +1094,7 @@ _ol_PluggableMap_.prototype.handleLayerGroupChanged_ = function() { if (layerGroup) { this.layerGroupPropertyListenerKeys_ = [ _ol_events_.listen( - layerGroup, _ol_ObjectEventType_.PROPERTYCHANGE, + layerGroup, ObjectEventType.PROPERTYCHANGE, this.render, this), _ol_events_.listen( layerGroup, EventType.CHANGE, diff --git a/src/ol/control/OverviewMap.js b/src/ol/control/OverviewMap.js index da4e179837..ae2849f239 100644 --- a/src/ol/control/OverviewMap.js +++ b/src/ol/control/OverviewMap.js @@ -7,7 +7,7 @@ import _ol_PluggableMap_ from '../PluggableMap.js'; import MapEventType from '../MapEventType.js'; import _ol_MapProperty_ from '../MapProperty.js'; import _ol_Object_ from '../Object.js'; -import _ol_ObjectEventType_ from '../ObjectEventType.js'; +import ObjectEventType from '../ObjectEventType.js'; import _ol_Overlay_ from '../Overlay.js'; import _ol_OverlayPositioning_ from '../OverlayPositioning.js'; import _ol_ViewProperty_ from '../ViewProperty.js'; @@ -227,7 +227,7 @@ OverviewMap.prototype.setMap = function(map) { if (map) { this.ovmap_.setTarget(this.ovmapDiv_); this.listenerKeys.push(_ol_events_.listen( - map, _ol_ObjectEventType_.PROPERTYCHANGE, + map, ObjectEventType.PROPERTYCHANGE, this.handleMapPropertyChange_, this)); // TODO: to really support map switching, this would need to be reworked diff --git a/src/ol/layer/Group.js b/src/ol/layer/Group.js index e90ac70d02..a907766427 100644 --- a/src/ol/layer/Group.js +++ b/src/ol/layer/Group.js @@ -5,7 +5,7 @@ import {getUid, inherits} from '../index.js'; import _ol_Collection_ from '../Collection.js'; import CollectionEventType from '../CollectionEventType.js'; import _ol_Object_ from '../Object.js'; -import _ol_ObjectEventType_ from '../ObjectEventType.js'; +import ObjectEventType from '../ObjectEventType.js'; import {assert} from '../asserts.js'; import _ol_events_ from '../events.js'; import EventType from '../events/EventType.js'; @@ -104,7 +104,7 @@ _ol_layer_Group_.prototype.handleLayersChanged_ = function(event) { for (i = 0, ii = layersArray.length; i < ii; i++) { layer = layersArray[i]; this.listenerKeys_[getUid(layer).toString()] = [ - _ol_events_.listen(layer, _ol_ObjectEventType_.PROPERTYCHANGE, + _ol_events_.listen(layer, ObjectEventType.PROPERTYCHANGE, this.handleLayerChange_, this), _ol_events_.listen(layer, EventType.CHANGE, this.handleLayerChange_, this) @@ -123,7 +123,7 @@ _ol_layer_Group_.prototype.handleLayersAdd_ = function(collectionEvent) { var layer = /** @type {ol.layer.Base} */ (collectionEvent.element); var key = getUid(layer).toString(); this.listenerKeys_[key] = [ - _ol_events_.listen(layer, _ol_ObjectEventType_.PROPERTYCHANGE, + _ol_events_.listen(layer, ObjectEventType.PROPERTYCHANGE, this.handleLayerChange_, this), _ol_events_.listen(layer, EventType.CHANGE, this.handleLayerChange_, this) diff --git a/src/ol/source/Vector.js b/src/ol/source/Vector.js index b524312761..849670b350 100644 --- a/src/ol/source/Vector.js +++ b/src/ol/source/Vector.js @@ -5,7 +5,7 @@ import {getUid, inherits, nullFunction} from '../index.js'; import _ol_Collection_ from '../Collection.js'; import CollectionEventType from '../CollectionEventType.js'; -import _ol_ObjectEventType_ from '../ObjectEventType.js'; +import ObjectEventType from '../ObjectEventType.js'; import _ol_array_ from '../array.js'; import {assert} from '../asserts.js'; import _ol_events_ from '../events.js'; @@ -205,7 +205,7 @@ _ol_source_Vector_.prototype.setupChangeEvents_ = function(featureKey, feature) this.featureChangeKeys_[featureKey] = [ _ol_events_.listen(feature, EventType.CHANGE, this.handleFeatureChange_, this), - _ol_events_.listen(feature, _ol_ObjectEventType_.PROPERTYCHANGE, + _ol_events_.listen(feature, ObjectEventType.PROPERTYCHANGE, this.handleFeatureChange_, this) ]; }; From b1b9edb43d68a94f652d8376264135e75e4f454a Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 12:34:31 +0100 Subject: [PATCH 09/16] Rename _ol_OverlayPositioning_ to OverlayPositioning --- src/ol/Overlay.js | 28 ++++++++++++++-------------- src/ol/control/OverviewMap.js | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ol/Overlay.js b/src/ol/Overlay.js index 46d7a12688..f5c128f794 100644 --- a/src/ol/Overlay.js +++ b/src/ol/Overlay.js @@ -4,7 +4,7 @@ import {inherits} from './index.js'; import MapEventType from './MapEventType.js'; import _ol_Object_ from './Object.js'; -import _ol_OverlayPositioning_ from './OverlayPositioning.js'; +import OverlayPositioning from './OverlayPositioning.js'; import _ol_css_ from './css.js'; import {removeNode, removeChildren, outerWidth, outerHeight} from './dom.js'; import _ol_events_ from './events.js'; @@ -139,7 +139,7 @@ var _ol_Overlay_ = function(options) { this.setPositioning(options.positioning !== undefined ? /** @type {ol.OverlayPositioning} */ (options.positioning) : - _ol_OverlayPositioning_.TOP_LEFT); + OverlayPositioning.TOP_LEFT); if (options.position !== undefined) { this.setPosition(options.position); @@ -481,9 +481,9 @@ _ol_Overlay_.prototype.updateRenderedPosition = function(pixel, mapSize) { var offsetX = offset[0]; var offsetY = offset[1]; - if (positioning == _ol_OverlayPositioning_.BOTTOM_RIGHT || - positioning == _ol_OverlayPositioning_.CENTER_RIGHT || - positioning == _ol_OverlayPositioning_.TOP_RIGHT) { + if (positioning == OverlayPositioning.BOTTOM_RIGHT || + positioning == OverlayPositioning.CENTER_RIGHT || + positioning == OverlayPositioning.TOP_RIGHT) { if (this.rendered.left_ !== '') { this.rendered.left_ = style.left = ''; } @@ -495,9 +495,9 @@ _ol_Overlay_.prototype.updateRenderedPosition = function(pixel, mapSize) { if (this.rendered.right_ !== '') { this.rendered.right_ = style.right = ''; } - if (positioning == _ol_OverlayPositioning_.BOTTOM_CENTER || - positioning == _ol_OverlayPositioning_.CENTER_CENTER || - positioning == _ol_OverlayPositioning_.TOP_CENTER) { + if (positioning == OverlayPositioning.BOTTOM_CENTER || + positioning == OverlayPositioning.CENTER_CENTER || + positioning == OverlayPositioning.TOP_CENTER) { offsetX -= this.element.offsetWidth / 2; } var left = Math.round(pixel[0] + offsetX) + 'px'; @@ -505,9 +505,9 @@ _ol_Overlay_.prototype.updateRenderedPosition = function(pixel, mapSize) { this.rendered.left_ = style.left = left; } } - if (positioning == _ol_OverlayPositioning_.BOTTOM_LEFT || - positioning == _ol_OverlayPositioning_.BOTTOM_CENTER || - positioning == _ol_OverlayPositioning_.BOTTOM_RIGHT) { + if (positioning == OverlayPositioning.BOTTOM_LEFT || + positioning == OverlayPositioning.BOTTOM_CENTER || + positioning == OverlayPositioning.BOTTOM_RIGHT) { if (this.rendered.top_ !== '') { this.rendered.top_ = style.top = ''; } @@ -519,9 +519,9 @@ _ol_Overlay_.prototype.updateRenderedPosition = function(pixel, mapSize) { if (this.rendered.bottom_ !== '') { this.rendered.bottom_ = style.bottom = ''; } - if (positioning == _ol_OverlayPositioning_.CENTER_LEFT || - positioning == _ol_OverlayPositioning_.CENTER_CENTER || - positioning == _ol_OverlayPositioning_.CENTER_RIGHT) { + if (positioning == OverlayPositioning.CENTER_LEFT || + positioning == OverlayPositioning.CENTER_CENTER || + positioning == OverlayPositioning.CENTER_RIGHT) { offsetY -= this.element.offsetHeight / 2; } var top = Math.round(pixel[1] + offsetY) + 'px'; diff --git a/src/ol/control/OverviewMap.js b/src/ol/control/OverviewMap.js index ae2849f239..0a23cbf08b 100644 --- a/src/ol/control/OverviewMap.js +++ b/src/ol/control/OverviewMap.js @@ -9,7 +9,7 @@ import _ol_MapProperty_ from '../MapProperty.js'; import _ol_Object_ from '../Object.js'; import ObjectEventType from '../ObjectEventType.js'; import _ol_Overlay_ from '../Overlay.js'; -import _ol_OverlayPositioning_ from '../OverlayPositioning.js'; +import OverlayPositioning from '../OverlayPositioning.js'; import _ol_ViewProperty_ from '../ViewProperty.js'; import Control from '../control/Control.js'; import _ol_coordinate_ from '../coordinate.js'; @@ -142,7 +142,7 @@ var OverviewMap = function(opt_options) { */ this.boxOverlay_ = new _ol_Overlay_({ position: [0, 0], - positioning: _ol_OverlayPositioning_.BOTTOM_LEFT, + positioning: OverlayPositioning.BOTTOM_LEFT, element: box }); this.ovmap_.addOverlay(this.boxOverlay_); From 8cae7abb3eb8d27c81eafbae1f1c5dcf6189da9c Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 12:40:13 +0100 Subject: [PATCH 10/16] Rename _ol_Overlay_.Property to Property --- src/ol/Overlay.js | 68 +++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/src/ol/Overlay.js b/src/ol/Overlay.js index f5c128f794..fc2011af20 100644 --- a/src/ol/Overlay.js +++ b/src/ol/Overlay.js @@ -10,6 +10,20 @@ import {removeNode, removeChildren, outerWidth, outerHeight} from './dom.js'; import _ol_events_ from './events.js'; import {containsExtent} from './extent.js'; + +/** + * @enum {string} + * @protected + */ +var Property = { + ELEMENT: 'element', + MAP: 'map', + OFFSET: 'offset', + POSITION: 'position', + POSITIONING: 'positioning' +}; + + /** * @classdesc * An element to be displayed over the map and attached to a single map @@ -112,23 +126,23 @@ var _ol_Overlay_ = function(options) { this.mapPostrenderListenerKey = null; _ol_events_.listen( - this, _ol_Object_.getChangeEventType(_ol_Overlay_.Property.ELEMENT), + this, _ol_Object_.getChangeEventType(Property.ELEMENT), this.handleElementChanged, this); _ol_events_.listen( - this, _ol_Object_.getChangeEventType(_ol_Overlay_.Property.MAP), + this, _ol_Object_.getChangeEventType(Property.MAP), this.handleMapChanged, this); _ol_events_.listen( - this, _ol_Object_.getChangeEventType(_ol_Overlay_.Property.OFFSET), + this, _ol_Object_.getChangeEventType(Property.OFFSET), this.handleOffsetChanged, this); _ol_events_.listen( - this, _ol_Object_.getChangeEventType(_ol_Overlay_.Property.POSITION), + this, _ol_Object_.getChangeEventType(Property.POSITION), this.handlePositionChanged, this); _ol_events_.listen( - this, _ol_Object_.getChangeEventType(_ol_Overlay_.Property.POSITIONING), + this, _ol_Object_.getChangeEventType(Property.POSITIONING), this.handlePositioningChanged, this); if (options.element !== undefined) { @@ -157,9 +171,7 @@ inherits(_ol_Overlay_, _ol_Object_); * @api */ _ol_Overlay_.prototype.getElement = function() { - return ( - /** @type {Element|undefined} */ this.get(_ol_Overlay_.Property.ELEMENT) - ); + return (/** @type {Element|undefined} */ this.get(Property.ELEMENT)); }; @@ -180,9 +192,7 @@ _ol_Overlay_.prototype.getId = function() { * @api */ _ol_Overlay_.prototype.getMap = function() { - return ( - /** @type {ol.PluggableMap|undefined} */ this.get(_ol_Overlay_.Property.MAP) - ); + return (/** @type {ol.PluggableMap|undefined} */ this.get(Property.MAP)); }; @@ -193,9 +203,7 @@ _ol_Overlay_.prototype.getMap = function() { * @api */ _ol_Overlay_.prototype.getOffset = function() { - return ( - /** @type {Array.} */ this.get(_ol_Overlay_.Property.OFFSET) - ); + return (/** @type {Array.} */ this.get(Property.OFFSET)); }; @@ -207,9 +215,7 @@ _ol_Overlay_.prototype.getOffset = function() { * @api */ _ol_Overlay_.prototype.getPosition = function() { - return ( - /** @type {ol.Coordinate|undefined} */ this.get(_ol_Overlay_.Property.POSITION) - ); + return (/** @type {ol.Coordinate|undefined} */ this.get(Property.POSITION)); }; @@ -221,9 +227,7 @@ _ol_Overlay_.prototype.getPosition = function() { * @api */ _ol_Overlay_.prototype.getPositioning = function() { - return ( - /** @type {ol.OverlayPositioning} */ this.get(_ol_Overlay_.Property.POSITIONING) - ); + return (/** @type {ol.OverlayPositioning} */ this.get(Property.POSITIONING)); }; @@ -285,7 +289,7 @@ _ol_Overlay_.prototype.handleOffsetChanged = function() { */ _ol_Overlay_.prototype.handlePositionChanged = function() { this.updatePixelPosition(); - if (this.get(_ol_Overlay_.Property.POSITION) && this.autoPan) { + if (this.get(Property.POSITION) && this.autoPan) { this.panIntoView(); } }; @@ -306,7 +310,7 @@ _ol_Overlay_.prototype.handlePositioningChanged = function() { * @api */ _ol_Overlay_.prototype.setElement = function(element) { - this.set(_ol_Overlay_.Property.ELEMENT, element); + this.set(Property.ELEMENT, element); }; @@ -317,7 +321,7 @@ _ol_Overlay_.prototype.setElement = function(element) { * @api */ _ol_Overlay_.prototype.setMap = function(map) { - this.set(_ol_Overlay_.Property.MAP, map); + this.set(Property.MAP, map); }; @@ -328,7 +332,7 @@ _ol_Overlay_.prototype.setMap = function(map) { * @api */ _ol_Overlay_.prototype.setOffset = function(offset) { - this.set(_ol_Overlay_.Property.OFFSET, offset); + this.set(Property.OFFSET, offset); }; @@ -341,7 +345,7 @@ _ol_Overlay_.prototype.setOffset = function(offset) { * @api */ _ol_Overlay_.prototype.setPosition = function(position) { - this.set(_ol_Overlay_.Property.POSITION, position); + this.set(Property.POSITION, position); }; @@ -431,7 +435,7 @@ _ol_Overlay_.prototype.getRect = function(element, size) { * @api */ _ol_Overlay_.prototype.setPositioning = function(positioning) { - this.set(_ol_Overlay_.Property.POSITIONING, positioning); + this.set(Property.POSITIONING, positioning); }; @@ -541,16 +545,4 @@ _ol_Overlay_.prototype.getOptions = function() { return this.options; }; - -/** - * @enum {string} - * @protected - */ -_ol_Overlay_.Property = { - ELEMENT: 'element', - MAP: 'map', - OFFSET: 'offset', - POSITION: 'position', - POSITIONING: 'positioning' -}; export default _ol_Overlay_; From db69f0ae44bd0d2970618dad5a5391c576586068 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 12:41:31 +0100 Subject: [PATCH 11/16] Rename _ol_Overlay_ to Overlay --- src/ol/Overlay.js | 52 +++++++++++++++++------------------ src/ol/control/OverviewMap.js | 4 +-- test/spec/ol/map.test.js | 8 +++--- test/spec/ol/overlay.test.js | 16 +++++------ 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/ol/Overlay.js b/src/ol/Overlay.js index fc2011af20..674664f25d 100644 --- a/src/ol/Overlay.js +++ b/src/ol/Overlay.js @@ -45,7 +45,7 @@ var Property = { * @param {olx.OverlayOptions} options Overlay options. * @api */ -var _ol_Overlay_ = function(options) { +var Overlay = function(options) { _ol_Object_.call(this); @@ -161,7 +161,7 @@ var _ol_Overlay_ = function(options) { }; -inherits(_ol_Overlay_, _ol_Object_); +inherits(Overlay, _ol_Object_); /** @@ -170,7 +170,7 @@ inherits(_ol_Overlay_, _ol_Object_); * @observable * @api */ -_ol_Overlay_.prototype.getElement = function() { +Overlay.prototype.getElement = function() { return (/** @type {Element|undefined} */ this.get(Property.ELEMENT)); }; @@ -180,7 +180,7 @@ _ol_Overlay_.prototype.getElement = function() { * @return {number|string|undefined} Id. * @api */ -_ol_Overlay_.prototype.getId = function() { +Overlay.prototype.getId = function() { return this.id; }; @@ -191,7 +191,7 @@ _ol_Overlay_.prototype.getId = function() { * @observable * @api */ -_ol_Overlay_.prototype.getMap = function() { +Overlay.prototype.getMap = function() { return (/** @type {ol.PluggableMap|undefined} */ this.get(Property.MAP)); }; @@ -202,7 +202,7 @@ _ol_Overlay_.prototype.getMap = function() { * @observable * @api */ -_ol_Overlay_.prototype.getOffset = function() { +Overlay.prototype.getOffset = function() { return (/** @type {Array.} */ this.get(Property.OFFSET)); }; @@ -214,7 +214,7 @@ _ol_Overlay_.prototype.getOffset = function() { * @observable * @api */ -_ol_Overlay_.prototype.getPosition = function() { +Overlay.prototype.getPosition = function() { return (/** @type {ol.Coordinate|undefined} */ this.get(Property.POSITION)); }; @@ -226,7 +226,7 @@ _ol_Overlay_.prototype.getPosition = function() { * @observable * @api */ -_ol_Overlay_.prototype.getPositioning = function() { +Overlay.prototype.getPositioning = function() { return (/** @type {ol.OverlayPositioning} */ this.get(Property.POSITIONING)); }; @@ -234,7 +234,7 @@ _ol_Overlay_.prototype.getPositioning = function() { /** * @protected */ -_ol_Overlay_.prototype.handleElementChanged = function() { +Overlay.prototype.handleElementChanged = function() { removeChildren(this.element); var element = this.getElement(); if (element) { @@ -246,7 +246,7 @@ _ol_Overlay_.prototype.handleElementChanged = function() { /** * @protected */ -_ol_Overlay_.prototype.handleMapChanged = function() { +Overlay.prototype.handleMapChanged = function() { if (this.mapPostrenderListenerKey) { removeNode(this.element); _ol_events_.unlistenByKey(this.mapPostrenderListenerKey); @@ -271,7 +271,7 @@ _ol_Overlay_.prototype.handleMapChanged = function() { /** * @protected */ -_ol_Overlay_.prototype.render = function() { +Overlay.prototype.render = function() { this.updatePixelPosition(); }; @@ -279,7 +279,7 @@ _ol_Overlay_.prototype.render = function() { /** * @protected */ -_ol_Overlay_.prototype.handleOffsetChanged = function() { +Overlay.prototype.handleOffsetChanged = function() { this.updatePixelPosition(); }; @@ -287,7 +287,7 @@ _ol_Overlay_.prototype.handleOffsetChanged = function() { /** * @protected */ -_ol_Overlay_.prototype.handlePositionChanged = function() { +Overlay.prototype.handlePositionChanged = function() { this.updatePixelPosition(); if (this.get(Property.POSITION) && this.autoPan) { this.panIntoView(); @@ -298,7 +298,7 @@ _ol_Overlay_.prototype.handlePositionChanged = function() { /** * @protected */ -_ol_Overlay_.prototype.handlePositioningChanged = function() { +Overlay.prototype.handlePositioningChanged = function() { this.updatePixelPosition(); }; @@ -309,7 +309,7 @@ _ol_Overlay_.prototype.handlePositioningChanged = function() { * @observable * @api */ -_ol_Overlay_.prototype.setElement = function(element) { +Overlay.prototype.setElement = function(element) { this.set(Property.ELEMENT, element); }; @@ -320,7 +320,7 @@ _ol_Overlay_.prototype.setElement = function(element) { * @observable * @api */ -_ol_Overlay_.prototype.setMap = function(map) { +Overlay.prototype.setMap = function(map) { this.set(Property.MAP, map); }; @@ -331,7 +331,7 @@ _ol_Overlay_.prototype.setMap = function(map) { * @observable * @api */ -_ol_Overlay_.prototype.setOffset = function(offset) { +Overlay.prototype.setOffset = function(offset) { this.set(Property.OFFSET, offset); }; @@ -344,7 +344,7 @@ _ol_Overlay_.prototype.setOffset = function(offset) { * @observable * @api */ -_ol_Overlay_.prototype.setPosition = function(position) { +Overlay.prototype.setPosition = function(position) { this.set(Property.POSITION, position); }; @@ -354,7 +354,7 @@ _ol_Overlay_.prototype.setPosition = function(position) { * (if necessary). * @protected */ -_ol_Overlay_.prototype.panIntoView = function() { +Overlay.prototype.panIntoView = function() { var map = this.getMap(); if (!map || !map.getTargetElement()) { @@ -414,7 +414,7 @@ _ol_Overlay_.prototype.panIntoView = function() { * @return {ol.Extent} The extent. * @protected */ -_ol_Overlay_.prototype.getRect = function(element, size) { +Overlay.prototype.getRect = function(element, size) { var box = element.getBoundingClientRect(); var offsetX = box.left + window.pageXOffset; var offsetY = box.top + window.pageYOffset; @@ -434,7 +434,7 @@ _ol_Overlay_.prototype.getRect = function(element, size) { * @observable * @api */ -_ol_Overlay_.prototype.setPositioning = function(positioning) { +Overlay.prototype.setPositioning = function(positioning) { this.set(Property.POSITIONING, positioning); }; @@ -444,7 +444,7 @@ _ol_Overlay_.prototype.setPositioning = function(positioning) { * @param {boolean} visible Element visibility. * @protected */ -_ol_Overlay_.prototype.setVisible = function(visible) { +Overlay.prototype.setVisible = function(visible) { if (this.rendered.visible !== visible) { this.element.style.display = visible ? '' : 'none'; this.rendered.visible = visible; @@ -456,7 +456,7 @@ _ol_Overlay_.prototype.setVisible = function(visible) { * Update pixel position. * @protected */ -_ol_Overlay_.prototype.updatePixelPosition = function() { +Overlay.prototype.updatePixelPosition = function() { var map = this.getMap(); var position = this.getPosition(); if (!map || !map.isRendered() || !position) { @@ -475,7 +475,7 @@ _ol_Overlay_.prototype.updatePixelPosition = function() { * @param {ol.Size|undefined} mapSize The map size. * @protected */ -_ol_Overlay_.prototype.updateRenderedPosition = function(pixel, mapSize) { +Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { var style = this.element.style; var offset = this.getOffset(); @@ -541,8 +541,8 @@ _ol_Overlay_.prototype.updateRenderedPosition = function(pixel, mapSize) { * @public * @return {olx.OverlayOptions} overlay options */ -_ol_Overlay_.prototype.getOptions = function() { +Overlay.prototype.getOptions = function() { return this.options; }; -export default _ol_Overlay_; +export default Overlay; diff --git a/src/ol/control/OverviewMap.js b/src/ol/control/OverviewMap.js index 0a23cbf08b..0ef3be298b 100644 --- a/src/ol/control/OverviewMap.js +++ b/src/ol/control/OverviewMap.js @@ -8,7 +8,7 @@ import MapEventType from '../MapEventType.js'; import _ol_MapProperty_ from '../MapProperty.js'; import _ol_Object_ from '../Object.js'; import ObjectEventType from '../ObjectEventType.js'; -import _ol_Overlay_ from '../Overlay.js'; +import Overlay from '../Overlay.js'; import OverlayPositioning from '../OverlayPositioning.js'; import _ol_ViewProperty_ from '../ViewProperty.js'; import Control from '../control/Control.js'; @@ -140,7 +140,7 @@ var OverviewMap = function(opt_options) { * @type {ol.Overlay} * @private */ - this.boxOverlay_ = new _ol_Overlay_({ + this.boxOverlay_ = new Overlay({ position: [0, 0], positioning: OverlayPositioning.BOTTOM_LEFT, element: box diff --git a/test/spec/ol/map.test.js b/test/spec/ol/map.test.js index fade1f14ac..d86c39e844 100644 --- a/test/spec/ol/map.test.js +++ b/test/spec/ol/map.test.js @@ -1,7 +1,7 @@ import _ol_Feature_ from '../../../src/ol/Feature.js'; import _ol_Map_ from '../../../src/ol/Map.js'; import MapEvent from '../../../src/ol/MapEvent.js'; -import _ol_Overlay_ from '../../../src/ol/Overlay.js'; +import Overlay from '../../../src/ol/Overlay.js'; import _ol_View_ from '../../../src/ol/View.js'; import Point from '../../../src/ol/geom/Point.js'; import _ol_has_ from '../../../src/ol/has.js'; @@ -610,7 +610,7 @@ describe('ol.Map', function() { }); it('returns an overlay by id', function() { - overlay = new _ol_Overlay_({ + overlay = new Overlay({ id: 'foo', element: overlay_target, position: [0, 0] @@ -620,7 +620,7 @@ describe('ol.Map', function() { }); it('returns null when no overlay is found', function() { - overlay = new _ol_Overlay_({ + overlay = new Overlay({ id: 'foo', element: overlay_target, position: [0, 0] @@ -630,7 +630,7 @@ describe('ol.Map', function() { }); it('returns null after removing overlay', function() { - overlay = new _ol_Overlay_({ + overlay = new Overlay({ id: 'foo', element: overlay_target, position: [0, 0] diff --git a/test/spec/ol/overlay.test.js b/test/spec/ol/overlay.test.js index ec25b13555..7adf87f578 100644 --- a/test/spec/ol/overlay.test.js +++ b/test/spec/ol/overlay.test.js @@ -1,5 +1,5 @@ import _ol_Map_ from '../../../src/ol/Map.js'; -import _ol_Overlay_ from '../../../src/ol/Overlay.js'; +import Overlay from '../../../src/ol/Overlay.js'; import _ol_View_ from '../../../src/ol/View.js'; @@ -38,13 +38,13 @@ describe('ol.Overlay', function() { describe('constructor', function() { it('can be constructed with minimal arguments', function() { - var instance = new _ol_Overlay_({}); - expect(instance).to.be.an(_ol_Overlay_); + var instance = new Overlay({}); + expect(instance).to.be.an(Overlay); }); it('can be constructed with className', function() { - var instance = new _ol_Overlay_({className: 'my-class'}); - expect(instance).to.be.an(_ol_Overlay_); + var instance = new Overlay({className: 'my-class'}); + expect(instance).to.be.an(Overlay); expect(instance.element.className).to.be('my-class'); }); @@ -61,14 +61,14 @@ describe('ol.Overlay', function() { }); it('returns the overlay identifier', function() { - overlay = new _ol_Overlay_({ + overlay = new Overlay({ element: target, position: [0, 0] }); map.addOverlay(overlay); expect(overlay.getId()).to.be(undefined); map.removeOverlay(overlay); - overlay = new _ol_Overlay_({ + overlay = new Overlay({ id: 'foo', element: target, position: [0, 0] @@ -90,7 +90,7 @@ describe('ol.Overlay', function() { }); it('changes the CSS display value', function() { - overlay = new _ol_Overlay_({ + overlay = new Overlay({ element: target, position: [0, 0] }); From b35d464cc8eeb2085936266ab813e0a815834ed0 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 12:47:35 +0100 Subject: [PATCH 12/16] Rename _ol_layer_Heatmap_.Property_ to Property --- src/ol/layer/Heatmap.js | 46 +++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/ol/layer/Heatmap.js b/src/ol/layer/Heatmap.js index a4ee0d844e..54c7b54a54 100644 --- a/src/ol/layer/Heatmap.js +++ b/src/ol/layer/Heatmap.js @@ -12,6 +12,18 @@ import _ol_render_EventType_ from '../render/EventType.js'; import _ol_style_Icon_ from '../style/Icon.js'; import _ol_style_Style_ from '../style/Style.js'; + +/** + * @enum {string} + * @private + */ +var Property = { + BLUR: 'blur', + GRADIENT: 'gradient', + RADIUS: 'radius' +}; + + /** * @classdesc * Layer for rendering vector data as a heatmap. @@ -62,7 +74,7 @@ var _ol_layer_Heatmap_ = function(opt_options) { this.styleCache_ = null; _ol_events_.listen(this, - _ol_Object_.getChangeEventType(_ol_layer_Heatmap_.Property_.GRADIENT), + _ol_Object_.getChangeEventType(Property.GRADIENT), this.handleGradientChanged_, this); this.setGradient(options.gradient ? @@ -73,10 +85,10 @@ var _ol_layer_Heatmap_ = function(opt_options) { this.setRadius(options.radius !== undefined ? options.radius : 8); _ol_events_.listen(this, - _ol_Object_.getChangeEventType(_ol_layer_Heatmap_.Property_.BLUR), + _ol_Object_.getChangeEventType(Property.BLUR), this.handleStyleChanged_, this); _ol_events_.listen(this, - _ol_Object_.getChangeEventType(_ol_layer_Heatmap_.Property_.RADIUS), + _ol_Object_.getChangeEventType(Property.RADIUS), this.handleStyleChanged_, this); this.handleStyleChanged_(); @@ -179,9 +191,7 @@ _ol_layer_Heatmap_.prototype.createCircle_ = function() { * @observable */ _ol_layer_Heatmap_.prototype.getBlur = function() { - return ( - /** @type {number} */ this.get(_ol_layer_Heatmap_.Property_.BLUR) - ); + return (/** @type {number} */ this.get(Property.BLUR)); }; @@ -192,9 +202,7 @@ _ol_layer_Heatmap_.prototype.getBlur = function() { * @observable */ _ol_layer_Heatmap_.prototype.getGradient = function() { - return ( - /** @type {Array.} */ this.get(_ol_layer_Heatmap_.Property_.GRADIENT) - ); + return (/** @type {Array.} */ this.get(Property.GRADIENT)); }; @@ -205,9 +213,7 @@ _ol_layer_Heatmap_.prototype.getGradient = function() { * @observable */ _ol_layer_Heatmap_.prototype.getRadius = function() { - return ( - /** @type {number} */ this.get(_ol_layer_Heatmap_.Property_.RADIUS) - ); + return (/** @type {number} */ this.get(Property.RADIUS)); }; @@ -258,7 +264,7 @@ _ol_layer_Heatmap_.prototype.handleRender_ = function(event) { * @observable */ _ol_layer_Heatmap_.prototype.setBlur = function(blur) { - this.set(_ol_layer_Heatmap_.Property_.BLUR, blur); + this.set(Property.BLUR, blur); }; @@ -269,7 +275,7 @@ _ol_layer_Heatmap_.prototype.setBlur = function(blur) { * @observable */ _ol_layer_Heatmap_.prototype.setGradient = function(colors) { - this.set(_ol_layer_Heatmap_.Property_.GRADIENT, colors); + this.set(Property.GRADIENT, colors); }; @@ -280,17 +286,7 @@ _ol_layer_Heatmap_.prototype.setGradient = function(colors) { * @observable */ _ol_layer_Heatmap_.prototype.setRadius = function(radius) { - this.set(_ol_layer_Heatmap_.Property_.RADIUS, radius); + this.set(Property.RADIUS, radius); }; - -/** - * @enum {string} - * @private - */ -_ol_layer_Heatmap_.Property_ = { - BLUR: 'blur', - GRADIENT: 'gradient', - RADIUS: 'radius' -}; export default _ol_layer_Heatmap_; From d35b4b8be4da4509d314fdf81547f47454ea5abe Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 12:52:07 +0100 Subject: [PATCH 13/16] Rename _ol_layer_Heatmap_ to Heatmap --- examples/heatmap-earthquakes.js | 4 +-- src/ol/layer/Heatmap.js | 47 +++++++++++++++--------------- test/spec/ol/layer/heatmap.test.js | 6 ++-- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/examples/heatmap-earthquakes.js b/examples/heatmap-earthquakes.js index 8439a59ae7..d3851061fb 100644 --- a/examples/heatmap-earthquakes.js +++ b/examples/heatmap-earthquakes.js @@ -1,7 +1,7 @@ import _ol_Map_ from '../src/ol/Map.js'; import _ol_View_ from '../src/ol/View.js'; import KML from '../src/ol/format/KML.js'; -import _ol_layer_Heatmap_ from '../src/ol/layer/Heatmap.js'; +import HeatmapLayer from '../src/ol/layer/Heatmap.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; import _ol_source_Stamen_ from '../src/ol/source/Stamen.js'; import _ol_source_Vector_ from '../src/ol/source/Vector.js'; @@ -9,7 +9,7 @@ import _ol_source_Vector_ from '../src/ol/source/Vector.js'; var blur = document.getElementById('blur'); var radius = document.getElementById('radius'); -var vector = new _ol_layer_Heatmap_({ +var vector = new HeatmapLayer({ source: new _ol_source_Vector_({ url: 'data/kml/2012_Earthquakes_Mag5.kml', format: new KML({ diff --git a/src/ol/layer/Heatmap.js b/src/ol/layer/Heatmap.js index 54c7b54a54..c211796eb6 100644 --- a/src/ol/layer/Heatmap.js +++ b/src/ol/layer/Heatmap.js @@ -24,6 +24,13 @@ var Property = { }; +/** + * @const + * @type {Array.} + */ +var DEFAULT_GRADIENT = ['#00f', '#0ff', '#0f0', '#ff0', '#f00']; + + /** * @classdesc * Layer for rendering vector data as a heatmap. @@ -37,7 +44,7 @@ var Property = { * @param {olx.layer.HeatmapOptions=} opt_options Options. * @api */ -var _ol_layer_Heatmap_ = function(opt_options) { +var Heatmap = function(opt_options) { var options = opt_options ? opt_options : {}; var baseOptions = _ol_obj_.assign({}, options); @@ -77,8 +84,7 @@ var _ol_layer_Heatmap_ = function(opt_options) { _ol_Object_.getChangeEventType(Property.GRADIENT), this.handleGradientChanged_, this); - this.setGradient(options.gradient ? - options.gradient : _ol_layer_Heatmap_.DEFAULT_GRADIENT); + this.setGradient(options.gradient ? options.gradient : DEFAULT_GRADIENT); this.setBlur(options.blur !== undefined ? options.blur : 15); @@ -130,14 +136,7 @@ var _ol_layer_Heatmap_ = function(opt_options) { _ol_events_.listen(this, _ol_render_EventType_.RENDER, this.handleRender_, this); }; -inherits(_ol_layer_Heatmap_, _ol_layer_Vector_); - - -/** - * @const - * @type {Array.} - */ -_ol_layer_Heatmap_.DEFAULT_GRADIENT = ['#00f', '#0ff', '#0f0', '#ff0', '#f00']; +inherits(Heatmap, _ol_layer_Vector_); /** @@ -145,7 +144,7 @@ _ol_layer_Heatmap_.DEFAULT_GRADIENT = ['#00f', '#0ff', '#0f0', '#ff0', '#f00']; * @return {Uint8ClampedArray} An array. * @private */ -_ol_layer_Heatmap_.createGradient_ = function(colors) { +var createGradient = function(colors) { var width = 1; var height = 256; var context = createCanvasContext2D(width, height); @@ -167,7 +166,7 @@ _ol_layer_Heatmap_.createGradient_ = function(colors) { * @return {string} Data URL for a circle. * @private */ -_ol_layer_Heatmap_.prototype.createCircle_ = function() { +Heatmap.prototype.createCircle_ = function() { var radius = this.getRadius(); var blur = this.getBlur(); var halfSize = radius + blur + 1; @@ -190,7 +189,7 @@ _ol_layer_Heatmap_.prototype.createCircle_ = function() { * @api * @observable */ -_ol_layer_Heatmap_.prototype.getBlur = function() { +Heatmap.prototype.getBlur = function() { return (/** @type {number} */ this.get(Property.BLUR)); }; @@ -201,7 +200,7 @@ _ol_layer_Heatmap_.prototype.getBlur = function() { * @api * @observable */ -_ol_layer_Heatmap_.prototype.getGradient = function() { +Heatmap.prototype.getGradient = function() { return (/** @type {Array.} */ this.get(Property.GRADIENT)); }; @@ -212,7 +211,7 @@ _ol_layer_Heatmap_.prototype.getGradient = function() { * @api * @observable */ -_ol_layer_Heatmap_.prototype.getRadius = function() { +Heatmap.prototype.getRadius = function() { return (/** @type {number} */ this.get(Property.RADIUS)); }; @@ -220,15 +219,15 @@ _ol_layer_Heatmap_.prototype.getRadius = function() { /** * @private */ -_ol_layer_Heatmap_.prototype.handleGradientChanged_ = function() { - this.gradient_ = _ol_layer_Heatmap_.createGradient_(this.getGradient()); +Heatmap.prototype.handleGradientChanged_ = function() { + this.gradient_ = createGradient(this.getGradient()); }; /** * @private */ -_ol_layer_Heatmap_.prototype.handleStyleChanged_ = function() { +Heatmap.prototype.handleStyleChanged_ = function() { this.circleImage_ = this.createCircle_(); this.styleCache_ = new Array(256); this.changed(); @@ -239,7 +238,7 @@ _ol_layer_Heatmap_.prototype.handleStyleChanged_ = function() { * @param {ol.render.Event} event Post compose event * @private */ -_ol_layer_Heatmap_.prototype.handleRender_ = function(event) { +Heatmap.prototype.handleRender_ = function(event) { var context = event.context; var canvas = context.canvas; var image = context.getImageData(0, 0, canvas.width, canvas.height); @@ -263,7 +262,7 @@ _ol_layer_Heatmap_.prototype.handleRender_ = function(event) { * @api * @observable */ -_ol_layer_Heatmap_.prototype.setBlur = function(blur) { +Heatmap.prototype.setBlur = function(blur) { this.set(Property.BLUR, blur); }; @@ -274,7 +273,7 @@ _ol_layer_Heatmap_.prototype.setBlur = function(blur) { * @api * @observable */ -_ol_layer_Heatmap_.prototype.setGradient = function(colors) { +Heatmap.prototype.setGradient = function(colors) { this.set(Property.GRADIENT, colors); }; @@ -285,8 +284,8 @@ _ol_layer_Heatmap_.prototype.setGradient = function(colors) { * @api * @observable */ -_ol_layer_Heatmap_.prototype.setRadius = function(radius) { +Heatmap.prototype.setRadius = function(radius) { this.set(Property.RADIUS, radius); }; -export default _ol_layer_Heatmap_; +export default Heatmap; diff --git a/test/spec/ol/layer/heatmap.test.js b/test/spec/ol/layer/heatmap.test.js index b25fd33044..95cc852fec 100644 --- a/test/spec/ol/layer/heatmap.test.js +++ b/test/spec/ol/layer/heatmap.test.js @@ -1,4 +1,4 @@ -import _ol_layer_Heatmap_ from '../../../../src/ol/layer/Heatmap.js'; +import HeatmapLayer from '../../../../src/ol/layer/Heatmap.js'; describe('ol.layer.Heatmap', function() { @@ -6,8 +6,8 @@ describe('ol.layer.Heatmap', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var instance = new _ol_layer_Heatmap_(); - expect(instance).to.be.an(_ol_layer_Heatmap_); + var instance = new HeatmapLayer(); + expect(instance).to.be.an(HeatmapLayer); }); }); From ae7fb85ef0324eefb77c9caa7c937dc1a74ebd23 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 13:36:19 +0100 Subject: [PATCH 14/16] Rename _ol_layer_Vector_.Property_ to Property --- src/ol/layer/Vector.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/ol/layer/Vector.js b/src/ol/layer/Vector.js index 8df28ea20a..1a8b03b55d 100644 --- a/src/ol/layer/Vector.js +++ b/src/ol/layer/Vector.js @@ -8,6 +8,16 @@ import _ol_layer_VectorRenderType_ from '../layer/VectorRenderType.js'; import _ol_obj_ from '../obj.js'; import _ol_style_Style_ from '../style/Style.js'; + +/** + * @enum {string} + * @private + */ +var Property = { + RENDER_ORDER: 'renderOrder' +}; + + /** * @classdesc * Vector data that is rendered client-side. @@ -123,9 +133,7 @@ _ol_layer_Vector_.prototype.getRenderBuffer = function() { * order. */ _ol_layer_Vector_.prototype.getRenderOrder = function() { - return ( - /** @type {ol.RenderOrderFunction|null|undefined} */ this.get(_ol_layer_Vector_.Property_.RENDER_ORDER) - ); + return (/** @type {ol.RenderOrderFunction|null|undefined} */ this.get(Property.RENDER_ORDER)); }; @@ -183,7 +191,7 @@ _ol_layer_Vector_.prototype.getUpdateWhileInteracting = function() { * Render order. */ _ol_layer_Vector_.prototype.setRenderOrder = function(renderOrder) { - this.set(_ol_layer_Vector_.Property_.RENDER_ORDER, renderOrder); + this.set(Property.RENDER_ORDER, renderOrder); }; @@ -214,11 +222,4 @@ _ol_layer_Vector_.prototype.getRenderMode = function() { }; -/** - * @enum {string} - * @private - */ -_ol_layer_Vector_.Property_ = { - RENDER_ORDER: 'renderOrder' -}; export default _ol_layer_Vector_; From b56fa824469f896534b22529f588d201a13db4ae Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 13:38:15 +0100 Subject: [PATCH 15/16] Rename _ol_Collection_.Property_ to Property --- src/ol/Collection.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/ol/Collection.js b/src/ol/Collection.js index 253647aa3c..d784c12e6f 100644 --- a/src/ol/Collection.js +++ b/src/ol/Collection.js @@ -8,6 +8,16 @@ import _ol_Object_ from './Object.js'; import Event from './events/Event.js'; + +/** + * @enum {string} + * @private + */ +var Property = { + LENGTH: 'length' +}; + + /** * @typedef {{unique: (boolean|undefined)}} */ @@ -139,9 +149,7 @@ _ol_Collection_.prototype.item = function(index) { * @api */ _ol_Collection_.prototype.getLength = function() { - return ( - /** @type {number} */ this.get(_ol_Collection_.Property_.LENGTH) - ); + return (/** @type {number} */ this.get(Property.LENGTH)); }; @@ -256,7 +264,7 @@ _ol_Collection_.prototype.setAt = function(index, elem) { * @private */ _ol_Collection_.prototype.updateLength_ = function() { - this.set(_ol_Collection_.Property_.LENGTH, this.array_.length); + this.set(Property.LENGTH, this.array_.length); }; @@ -273,16 +281,6 @@ _ol_Collection_.prototype.assertUnique_ = function(elem, opt_except) { } }; - -/** - * @enum {string} - * @private - */ -_ol_Collection_.Property_ = { - LENGTH: 'length' -}; - - /** * @classdesc * Events emitted by {@link ol.Collection} instances are instances of this From 904f197c0640319cfb1779506cd72cfa40f08cec Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 18 Dec 2017 13:39:35 +0100 Subject: [PATCH 16/16] Rename _ol_layer_Group_.Property_ to Property --- src/ol/Collection.js | 1 - src/ol/layer/Group.js | 26 +++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/ol/Collection.js b/src/ol/Collection.js index d784c12e6f..a0a1d9ae95 100644 --- a/src/ol/Collection.js +++ b/src/ol/Collection.js @@ -8,7 +8,6 @@ import _ol_Object_ from './Object.js'; import Event from './events/Event.js'; - /** * @enum {string} * @private diff --git a/src/ol/layer/Group.js b/src/ol/layer/Group.js index a907766427..112bbed2ce 100644 --- a/src/ol/layer/Group.js +++ b/src/ol/layer/Group.js @@ -14,6 +14,16 @@ import _ol_layer_Base_ from '../layer/Base.js'; import _ol_obj_ from '../obj.js'; import _ol_source_State_ from '../source/State.js'; + +/** + * @enum {string} + * @private + */ +var Property = { + LAYERS: 'layers' +}; + + /** * @classdesc * A {@link ol.Collection} of layers that are handled together. @@ -49,7 +59,7 @@ var _ol_layer_Group_ = function(opt_options) { this.listenerKeys_ = {}; _ol_events_.listen(this, - _ol_Object_.getChangeEventType(_ol_layer_Group_.Property_.LAYERS), + _ol_Object_.getChangeEventType(Property.LAYERS), this.handleLayersChanged_, this); if (layers) { @@ -154,10 +164,7 @@ _ol_layer_Group_.prototype.handleLayersRemove_ = function(collectionEvent) { * @api */ _ol_layer_Group_.prototype.getLayers = function() { - return ( - /** @type {!ol.Collection.} */ this.get( - _ol_layer_Group_.Property_.LAYERS) - ); + return (/** @type {!ol.Collection.} */ this.get(Property.LAYERS)); }; @@ -170,7 +177,7 @@ _ol_layer_Group_.prototype.getLayers = function() { * @api */ _ol_layer_Group_.prototype.setLayers = function(layers) { - this.set(_ol_layer_Group_.Property_.LAYERS, layers); + this.set(Property.LAYERS, layers); }; @@ -228,11 +235,4 @@ _ol_layer_Group_.prototype.getSourceState = function() { return _ol_source_State_.READY; }; -/** - * @enum {string} - * @private - */ -_ol_layer_Group_.Property_ = { - LAYERS: 'layers' -}; export default _ol_layer_Group_;