From 935133755e12ed765a74bdc5f5bf2806edabf29c Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sat, 16 Dec 2017 08:06:48 +0100 Subject: [PATCH 1/4] Rename _ol_Kinetic_ to Kinetic --- src/ol/Kinetic.js | 15 ++++++++------- src/ol/interaction.js | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/ol/Kinetic.js b/src/ol/Kinetic.js index 449c522b20..500d10c234 100644 --- a/src/ol/Kinetic.js +++ b/src/ol/Kinetic.js @@ -1,6 +1,7 @@ /** * @module ol/Kinetic */ + /** * @classdesc * Implementation of inertial deceleration for map movement. @@ -13,7 +14,7 @@ * @struct * @api */ -var _ol_Kinetic_ = function(decay, minVelocity, delay) { +var Kinetic = function(decay, minVelocity, delay) { /** * @private @@ -56,7 +57,7 @@ var _ol_Kinetic_ = function(decay, minVelocity, delay) { /** * FIXME empty description for jsdoc */ -_ol_Kinetic_.prototype.begin = function() { +Kinetic.prototype.begin = function() { this.points_.length = 0; this.angle_ = 0; this.initialVelocity_ = 0; @@ -67,7 +68,7 @@ _ol_Kinetic_.prototype.begin = function() { * @param {number} x X. * @param {number} y Y. */ -_ol_Kinetic_.prototype.update = function(x, y) { +Kinetic.prototype.update = function(x, y) { this.points_.push(x, y, Date.now()); }; @@ -75,7 +76,7 @@ _ol_Kinetic_.prototype.update = function(x, y) { /** * @return {boolean} Whether we should do kinetic animation. */ -_ol_Kinetic_.prototype.end = function() { +Kinetic.prototype.end = function() { if (this.points_.length < 6) { // at least 2 points are required (i.e. there must be at least 6 elements // in the array) @@ -114,7 +115,7 @@ _ol_Kinetic_.prototype.end = function() { /** * @return {number} Total distance travelled (pixels). */ -_ol_Kinetic_.prototype.getDistance = function() { +Kinetic.prototype.getDistance = function() { return (this.minVelocity_ - this.initialVelocity_) / this.decay_; }; @@ -122,7 +123,7 @@ _ol_Kinetic_.prototype.getDistance = function() { /** * @return {number} Angle of the kinetic panning animation (radians). */ -_ol_Kinetic_.prototype.getAngle = function() { +Kinetic.prototype.getAngle = function() { return this.angle_; }; -export default _ol_Kinetic_; +export default Kinetic; diff --git a/src/ol/interaction.js b/src/ol/interaction.js index d6d12730cf..5cfe6956b3 100644 --- a/src/ol/interaction.js +++ b/src/ol/interaction.js @@ -2,7 +2,7 @@ * @module ol/interaction */ import _ol_Collection_ from './Collection.js'; -import _ol_Kinetic_ from './Kinetic.js'; +import Kinetic from './Kinetic.js'; import DoubleClickZoom from './interaction/DoubleClickZoom.js'; import DragPan from './interaction/DragPan.js'; import DragRotate from './interaction/DragRotate.js'; @@ -44,7 +44,7 @@ _ol_interaction_.defaults = function(opt_options) { var interactions = new _ol_Collection_(); - var kinetic = new _ol_Kinetic_(-0.005, 0.05, 100); + var kinetic = new Kinetic(-0.005, 0.05, 100); var altShiftDragRotate = options.altShiftDragRotate !== undefined ? options.altShiftDragRotate : true; From bf6a18dfc4b2299cab48c1ea1e759d539ff30785 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sat, 16 Dec 2017 08:11:54 +0100 Subject: [PATCH 2/4] Rename _ol_Graticule_ to Graticule --- examples/graticule.js | 4 +- examples/sphere-mollweide.js | 4 +- src/ol/Graticule.js | 79 +++++++++++++++++----------------- test/spec/ol/graticule.test.js | 10 ++--- 4 files changed, 48 insertions(+), 49 deletions(-) diff --git a/examples/graticule.js b/examples/graticule.js index 44d39420f1..357a2c2243 100644 --- a/examples/graticule.js +++ b/examples/graticule.js @@ -1,4 +1,4 @@ -import _ol_Graticule_ from '../src/ol/Graticule.js'; +import Graticule from '../src/ol/Graticule.js'; import _ol_Map_ from '../src/ol/Map.js'; import _ol_View_ from '../src/ol/View.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; @@ -23,7 +23,7 @@ var map = new _ol_Map_({ }); // Create the graticule component -var graticule = new _ol_Graticule_({ +var graticule = new Graticule({ // the style to use for the lines, optional. strokeStyle: new _ol_style_Stroke_({ color: 'rgba(255,120,0,0.9)', diff --git a/examples/sphere-mollweide.js b/examples/sphere-mollweide.js index 08552b07fc..13cb008b6c 100644 --- a/examples/sphere-mollweide.js +++ b/examples/sphere-mollweide.js @@ -1,4 +1,4 @@ -import _ol_Graticule_ from '../src/ol/Graticule.js'; +import Graticule from '../src/ol/Graticule.js'; import _ol_Map_ from '../src/ol/Map.js'; import _ol_View_ from '../src/ol/View.js'; import _ol_format_GeoJSON_ from '../src/ol/format/GeoJSON.js'; @@ -41,6 +41,6 @@ var map = new _ol_Map_({ }) }); -new _ol_Graticule_({ +new Graticule({ map: map }); diff --git a/src/ol/Graticule.js b/src/ol/Graticule.js index 524a21d13a..68b330e634 100644 --- a/src/ol/Graticule.js +++ b/src/ol/Graticule.js @@ -15,6 +15,25 @@ import _ol_style_Stroke_ from './style/Stroke.js'; import _ol_style_Text_ from './style/Text.js'; +/** + * @type {ol.style.Stroke} + * @private + * @const + */ +var DEFAULT_STROKE_STYLE = new _ol_style_Stroke_({ + color: 'rgba(0,0,0,0.2)' +}); + +/** + * TODO can be configurable + * @type {Array.} + * @private + */ +var INTERVALS = [ + 90, 45, 30, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, 0.01, 0.005, 0.002, 0.001 +]; + + /** * @typedef {{map: (ol.PluggableMap|undefined), * maxLines: (number|undefined), @@ -100,7 +119,7 @@ export var GraticuleOptions; * of the viewport. * @api */ -var _ol_Graticule_ = function(opt_options) { +var Graticule = function(opt_options) { var options = opt_options || {}; /** @@ -192,8 +211,7 @@ var _ol_Graticule_ = function(opt_options) { * @type {ol.style.Stroke} * @private */ - this.strokeStyle_ = options.strokeStyle !== undefined ? - options.strokeStyle : _ol_Graticule_.DEFAULT_STROKE_STYLE_; + this.strokeStyle_ = options.strokeStyle !== undefined ? options.strokeStyle : DEFAULT_STROKE_STYLE; /** * @type {ol.TransformFunction|undefined} @@ -302,25 +320,6 @@ var _ol_Graticule_ = function(opt_options) { }; -/** - * @type {ol.style.Stroke} - * @private - * @const - */ -_ol_Graticule_.DEFAULT_STROKE_STYLE_ = new _ol_style_Stroke_({ - color: 'rgba(0,0,0,0.2)' -}); - - -/** - * TODO can be configurable - * @type {Array.} - * @private - */ -_ol_Graticule_.intervals_ = [90, 45, 30, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, - 0.01, 0.005, 0.002, 0.001]; - - /** * @param {number} lon Longitude. * @param {number} minLat Minimal latitude. @@ -331,7 +330,7 @@ _ol_Graticule_.intervals_ = [90, 45, 30, 20, 10, 5, 2, 1, 0.5, 0.2, 0.1, 0.05, * @return {number} Index. * @private */ -_ol_Graticule_.prototype.addMeridian_ = function(lon, minLat, maxLat, squaredTolerance, extent, index) { +Graticule.prototype.addMeridian_ = function(lon, minLat, maxLat, squaredTolerance, extent, index) { var lineString = this.getMeridian_(lon, minLat, maxLat, squaredTolerance, index); if (intersects(lineString.getExtent(), extent)) { @@ -354,7 +353,7 @@ _ol_Graticule_.prototype.addMeridian_ = function(lon, minLat, maxLat, squaredTol * @return {ol.geom.Point} Meridian point. * @private */ -_ol_Graticule_.prototype.getMeridianPoint_ = function(lineString, extent, index) { +Graticule.prototype.getMeridianPoint_ = function(lineString, extent, index) { var flatCoordinates = lineString.getFlatCoordinates(); var clampedBottom = Math.max(extent[1], flatCoordinates[1]); var clampedTop = Math.min(extent[3], flatCoordinates[flatCoordinates.length - 1]); @@ -379,7 +378,7 @@ _ol_Graticule_.prototype.getMeridianPoint_ = function(lineString, extent, index) * @return {number} Index. * @private */ -_ol_Graticule_.prototype.addParallel_ = function(lat, minLon, maxLon, squaredTolerance, extent, index) { +Graticule.prototype.addParallel_ = function(lat, minLon, maxLon, squaredTolerance, extent, index) { var lineString = this.getParallel_(lat, minLon, maxLon, squaredTolerance, index); if (intersects(lineString.getExtent(), extent)) { @@ -403,7 +402,7 @@ _ol_Graticule_.prototype.addParallel_ = function(lat, minLon, maxLon, squaredTol * @return {ol.geom.Point} Parallel point. * @private */ -_ol_Graticule_.prototype.getParallelPoint_ = function(lineString, extent, index) { +Graticule.prototype.getParallelPoint_ = function(lineString, extent, index) { var flatCoordinates = lineString.getFlatCoordinates(); var clampedLeft = Math.max(extent[0], flatCoordinates[0]); var clampedRight = Math.min(extent[2], flatCoordinates[flatCoordinates.length - 2]); @@ -425,7 +424,7 @@ _ol_Graticule_.prototype.getParallelPoint_ = function(lineString, extent, index) * @param {number} squaredTolerance Squared tolerance. * @private */ -_ol_Graticule_.prototype.createGraticule_ = function(extent, center, resolution, squaredTolerance) { +Graticule.prototype.createGraticule_ = function(extent, center, resolution, squaredTolerance) { var interval = this.getInterval_(resolution); if (interval == -1) { @@ -519,7 +518,7 @@ _ol_Graticule_.prototype.createGraticule_ = function(extent, center, resolution, * @return {number} The interval in degrees. * @private */ -_ol_Graticule_.prototype.getInterval_ = function(resolution) { +Graticule.prototype.getInterval_ = function(resolution) { var centerLon = this.projectionCenterLonLat_[0]; var centerLat = this.projectionCenterLonLat_[1]; var interval = -1; @@ -529,8 +528,8 @@ _ol_Graticule_.prototype.getInterval_ = function(resolution) { var p1 = []; /** @type {Array.} **/ var p2 = []; - for (i = 0, ii = _ol_Graticule_.intervals_.length; i < ii; ++i) { - delta = _ol_Graticule_.intervals_[i] / 2; + for (i = 0, ii = INTERVALS.length; i < ii; ++i) { + delta = INTERVALS[i] / 2; p1[0] = centerLon - delta; p1[1] = centerLat - delta; p2[0] = centerLon + delta; @@ -541,7 +540,7 @@ _ol_Graticule_.prototype.getInterval_ = function(resolution) { if (dist <= target) { break; } - interval = _ol_Graticule_.intervals_[i]; + interval = INTERVALS[i]; } return interval; }; @@ -552,7 +551,7 @@ _ol_Graticule_.prototype.getInterval_ = function(resolution) { * @return {ol.PluggableMap} The map. * @api */ -_ol_Graticule_.prototype.getMap = function() { +Graticule.prototype.getMap = function() { return this.map_; }; @@ -566,7 +565,7 @@ _ol_Graticule_.prototype.getMap = function() { * @param {number} index Index. * @private */ -_ol_Graticule_.prototype.getMeridian_ = function(lon, minLat, maxLat, +Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat, squaredTolerance, index) { var flatCoordinates = _ol_geom_flat_geodesic_.meridian(lon, minLat, maxLat, this.projection_, squaredTolerance); @@ -582,7 +581,7 @@ _ol_Graticule_.prototype.getMeridian_ = function(lon, minLat, maxLat, * @return {Array.} The meridians. * @api */ -_ol_Graticule_.prototype.getMeridians = function() { +Graticule.prototype.getMeridians = function() { return this.meridians_; }; @@ -596,7 +595,7 @@ _ol_Graticule_.prototype.getMeridians = function() { * @param {number} index Index. * @private */ -_ol_Graticule_.prototype.getParallel_ = function(lat, minLon, maxLon, +Graticule.prototype.getParallel_ = function(lat, minLon, maxLon, squaredTolerance, index) { var flatCoordinates = _ol_geom_flat_geodesic_.parallel(lat, minLon, maxLon, this.projection_, squaredTolerance); @@ -612,7 +611,7 @@ _ol_Graticule_.prototype.getParallel_ = function(lat, minLon, maxLon, * @return {Array.} The parallels. * @api */ -_ol_Graticule_.prototype.getParallels = function() { +Graticule.prototype.getParallels = function() { return this.parallels_; }; @@ -621,7 +620,7 @@ _ol_Graticule_.prototype.getParallels = function() { * @param {ol.render.Event} e Event. * @private */ -_ol_Graticule_.prototype.handlePostCompose_ = function(e) { +Graticule.prototype.handlePostCompose_ = function(e) { var vectorContext = e.vectorContext; var frameState = e.frameState; var extent = frameState.extent; @@ -677,7 +676,7 @@ _ol_Graticule_.prototype.handlePostCompose_ = function(e) { * @param {ol.proj.Projection} projection Projection. * @private */ -_ol_Graticule_.prototype.updateProjectionInfo_ = function(projection) { +Graticule.prototype.updateProjectionInfo_ = function(projection) { var epsg4326Projection = getProjection('EPSG:4326'); var extent = projection.getExtent(); @@ -722,7 +721,7 @@ _ol_Graticule_.prototype.updateProjectionInfo_ = function(projection) { * @param {ol.PluggableMap} map Map. * @api */ -_ol_Graticule_.prototype.setMap = function(map) { +Graticule.prototype.setMap = function(map) { if (this.map_) { this.map_.un(_ol_render_EventType_.POSTCOMPOSE, this.handlePostCompose_, this); @@ -735,4 +734,4 @@ _ol_Graticule_.prototype.setMap = function(map) { } this.map_ = map; }; -export default _ol_Graticule_; +export default Graticule; diff --git a/test/spec/ol/graticule.test.js b/test/spec/ol/graticule.test.js index c50e873439..ff8d6a7a1e 100644 --- a/test/spec/ol/graticule.test.js +++ b/test/spec/ol/graticule.test.js @@ -1,4 +1,4 @@ -import _ol_Graticule_ from '../../../src/ol/Graticule.js'; +import Graticule from '../../../src/ol/Graticule.js'; import _ol_Map_ from '../../../src/ol/Map.js'; import {get as getProjection} from '../../../src/ol/proj.js'; import _ol_style_Stroke_ from '../../../src/ol/style/Stroke.js'; @@ -8,7 +8,7 @@ describe('ol.Graticule', function() { var graticule; function createGraticule() { - graticule = new _ol_Graticule_({ + graticule = new Graticule({ map: new _ol_Map_({}) }); } @@ -30,7 +30,7 @@ describe('ol.Graticule', function() { }); it('creates a graticule with labels', function() { - graticule = new _ol_Graticule_({ + graticule = new Graticule({ map: new _ol_Map_({}), showLabels: true }); @@ -62,7 +62,7 @@ describe('ol.Graticule', function() { var customStrokeStyle = new _ol_style_Stroke_({ color: 'rebeccapurple' }); - var styledGraticule = new _ol_Graticule_({ + var styledGraticule = new Graticule({ map: new _ol_Map_({}), strokeStyle: customStrokeStyle }); @@ -75,7 +75,7 @@ describe('ol.Graticule', function() { it('can be configured with label options', function() { var latLabelStyle = new _ol_style_Text_(); var lonLabelStyle = new _ol_style_Text_(); - graticule = new _ol_Graticule_({ + graticule = new Graticule({ map: new _ol_Map_({}), showLabels: true, lonLabelFormatter: function(lon) { From e3bf72f90ebaf5885cdd6357ba0419911f70b3f9 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sat, 16 Dec 2017 08:15:59 +0100 Subject: [PATCH 3/4] Rename _ol_Geolocation_ to Geolocation --- examples/geolocation-orientation.js | 4 +-- examples/geolocation.js | 4 +-- examples/mobile-full-screen.js | 4 +-- src/ol/Geolocation.js | 42 ++++++++++++++--------------- test/spec/ol/geolocation.test.js | 6 ++--- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/examples/geolocation-orientation.js b/examples/geolocation-orientation.js index 126584239f..e16e27d849 100644 --- a/examples/geolocation-orientation.js +++ b/examples/geolocation-orientation.js @@ -1,4 +1,4 @@ -import _ol_Geolocation_ from '../src/ol/Geolocation.js'; +import Geolocation from '../src/ol/Geolocation.js'; import _ol_Map_ from '../src/ol/Map.js'; import _ol_Overlay_ from '../src/ol/Overlay.js'; import _ol_View_ from '../src/ol/View.js'; @@ -46,7 +46,7 @@ var positions = new LineString([], /** @type {ol.geom.GeometryLayout} */ ('XYZM')); // Geolocation Control -var geolocation = new _ol_Geolocation_({ +var geolocation = new Geolocation({ projection: view.getProjection(), trackingOptions: { maximumAge: 10000, diff --git a/examples/geolocation.js b/examples/geolocation.js index 55575be11c..a08c074da7 100644 --- a/examples/geolocation.js +++ b/examples/geolocation.js @@ -1,5 +1,5 @@ import _ol_Feature_ from '../src/ol/Feature.js'; -import _ol_Geolocation_ from '../src/ol/Geolocation.js'; +import Geolocation from '../src/ol/Geolocation.js'; import _ol_Map_ from '../src/ol/Map.js'; import _ol_View_ from '../src/ol/View.js'; import _ol_control_ from '../src/ol/control.js'; @@ -33,7 +33,7 @@ var map = new _ol_Map_({ view: view }); -var geolocation = new _ol_Geolocation_({ +var geolocation = new Geolocation({ projection: view.getProjection() }); diff --git a/examples/mobile-full-screen.js b/examples/mobile-full-screen.js index 1726704860..26e56ae028 100644 --- a/examples/mobile-full-screen.js +++ b/examples/mobile-full-screen.js @@ -1,4 +1,4 @@ -import _ol_Geolocation_ from '../src/ol/Geolocation.js'; +import Geolocation from '../src/ol/Geolocation.js'; import _ol_Map_ from '../src/ol/Map.js'; import _ol_View_ from '../src/ol/View.js'; import _ol_layer_Tile_ from '../src/ol/layer/Tile.js'; @@ -23,7 +23,7 @@ var map = new _ol_Map_({ view: view }); -var geolocation = new _ol_Geolocation_({ +var geolocation = new Geolocation({ projection: view.getProjection(), tracking: true }); diff --git a/src/ol/Geolocation.js b/src/ol/Geolocation.js index b3a793273e..870b0a1c5b 100644 --- a/src/ol/Geolocation.js +++ b/src/ol/Geolocation.js @@ -55,7 +55,7 @@ export var GeolocationOptions; * is reported in. * @api */ -var _ol_Geolocation_ = function(opt_options) { +var Geolocation = function(opt_options) { _ol_Object_.call(this); @@ -104,13 +104,13 @@ var _ol_Geolocation_ = function(opt_options) { }; -inherits(_ol_Geolocation_, _ol_Object_); +inherits(Geolocation, _ol_Object_); /** * @inheritDoc */ -_ol_Geolocation_.prototype.disposeInternal = function() { +Geolocation.prototype.disposeInternal = function() { this.setTracking(false); _ol_Object_.prototype.disposeInternal.call(this); }; @@ -119,7 +119,7 @@ _ol_Geolocation_.prototype.disposeInternal = function() { /** * @private */ -_ol_Geolocation_.prototype.handleProjectionChanged_ = function() { +Geolocation.prototype.handleProjectionChanged_ = function() { var projection = this.getProjection(); if (projection) { this.transform_ = getTransformFromProjections( @@ -135,7 +135,7 @@ _ol_Geolocation_.prototype.handleProjectionChanged_ = function() { /** * @private */ -_ol_Geolocation_.prototype.handleTrackingChanged_ = function() { +Geolocation.prototype.handleTrackingChanged_ = function() { if (_ol_has_.GEOLOCATION) { var tracking = this.getTracking(); if (tracking && this.watchId_ === undefined) { @@ -155,7 +155,7 @@ _ol_Geolocation_.prototype.handleTrackingChanged_ = function() { * @private * @param {GeolocationPosition} position position event. */ -_ol_Geolocation_.prototype.positionChange_ = function(position) { +Geolocation.prototype.positionChange_ = function(position) { var coords = position.coords; this.set(_ol_GeolocationProperty_.ACCURACY, coords.accuracy); this.set(_ol_GeolocationProperty_.ALTITUDE, @@ -192,7 +192,7 @@ _ol_Geolocation_.prototype.positionChange_ = function(position) { * @private * @param {GeolocationPositionError} error error object. */ -_ol_Geolocation_.prototype.positionError_ = function(error) { +Geolocation.prototype.positionError_ = function(error) { error.type = EventType.ERROR; this.setTracking(false); this.dispatchEvent(/** @type {{type: string, target: undefined}} */ (error)); @@ -206,7 +206,7 @@ _ol_Geolocation_.prototype.positionError_ = function(error) { * @observable * @api */ -_ol_Geolocation_.prototype.getAccuracy = function() { +Geolocation.prototype.getAccuracy = function() { return ( /** @type {number|undefined} */ this.get(_ol_GeolocationProperty_.ACCURACY) ); @@ -219,7 +219,7 @@ _ol_Geolocation_.prototype.getAccuracy = function() { * @observable * @api */ -_ol_Geolocation_.prototype.getAccuracyGeometry = function() { +Geolocation.prototype.getAccuracyGeometry = function() { return ( /** @type {?ol.geom.Polygon} */ this.get(_ol_GeolocationProperty_.ACCURACY_GEOMETRY) || null ); @@ -233,7 +233,7 @@ _ol_Geolocation_.prototype.getAccuracyGeometry = function() { * @observable * @api */ -_ol_Geolocation_.prototype.getAltitude = function() { +Geolocation.prototype.getAltitude = function() { return ( /** @type {number|undefined} */ this.get(_ol_GeolocationProperty_.ALTITUDE) ); @@ -247,7 +247,7 @@ _ol_Geolocation_.prototype.getAltitude = function() { * @observable * @api */ -_ol_Geolocation_.prototype.getAltitudeAccuracy = function() { +Geolocation.prototype.getAltitudeAccuracy = function() { return ( /** @type {number|undefined} */ this.get(_ol_GeolocationProperty_.ALTITUDE_ACCURACY) ); @@ -260,7 +260,7 @@ _ol_Geolocation_.prototype.getAltitudeAccuracy = function() { * @observable * @api */ -_ol_Geolocation_.prototype.getHeading = function() { +Geolocation.prototype.getHeading = function() { return ( /** @type {number|undefined} */ this.get(_ol_GeolocationProperty_.HEADING) ); @@ -274,7 +274,7 @@ _ol_Geolocation_.prototype.getHeading = function() { * @observable * @api */ -_ol_Geolocation_.prototype.getPosition = function() { +Geolocation.prototype.getPosition = function() { return ( /** @type {ol.Coordinate|undefined} */ this.get(_ol_GeolocationProperty_.POSITION) ); @@ -288,7 +288,7 @@ _ol_Geolocation_.prototype.getPosition = function() { * @observable * @api */ -_ol_Geolocation_.prototype.getProjection = function() { +Geolocation.prototype.getProjection = function() { return ( /** @type {ol.proj.Projection|undefined} */ this.get(_ol_GeolocationProperty_.PROJECTION) ); @@ -302,7 +302,7 @@ _ol_Geolocation_.prototype.getProjection = function() { * @observable * @api */ -_ol_Geolocation_.prototype.getSpeed = function() { +Geolocation.prototype.getSpeed = function() { return ( /** @type {number|undefined} */ this.get(_ol_GeolocationProperty_.SPEED) ); @@ -315,7 +315,7 @@ _ol_Geolocation_.prototype.getSpeed = function() { * @observable * @api */ -_ol_Geolocation_.prototype.getTracking = function() { +Geolocation.prototype.getTracking = function() { return ( /** @type {boolean} */ this.get(_ol_GeolocationProperty_.TRACKING) ); @@ -331,7 +331,7 @@ _ol_Geolocation_.prototype.getTracking = function() { * @observable * @api */ -_ol_Geolocation_.prototype.getTrackingOptions = function() { +Geolocation.prototype.getTrackingOptions = function() { return ( /** @type {GeolocationPositionOptions|undefined} */ this.get(_ol_GeolocationProperty_.TRACKING_OPTIONS) ); @@ -345,7 +345,7 @@ _ol_Geolocation_.prototype.getTrackingOptions = function() { * @observable * @api */ -_ol_Geolocation_.prototype.setProjection = function(projection) { +Geolocation.prototype.setProjection = function(projection) { this.set(_ol_GeolocationProperty_.PROJECTION, getProjection(projection)); }; @@ -356,7 +356,7 @@ _ol_Geolocation_.prototype.setProjection = function(projection) { * @observable * @api */ -_ol_Geolocation_.prototype.setTracking = function(tracking) { +Geolocation.prototype.setTracking = function(tracking) { this.set(_ol_GeolocationProperty_.TRACKING, tracking); }; @@ -370,7 +370,7 @@ _ol_Geolocation_.prototype.setTracking = function(tracking) { * @observable * @api */ -_ol_Geolocation_.prototype.setTrackingOptions = function(options) { +Geolocation.prototype.setTrackingOptions = function(options) { this.set(_ol_GeolocationProperty_.TRACKING_OPTIONS, options); }; -export default _ol_Geolocation_; +export default Geolocation; diff --git a/test/spec/ol/geolocation.test.js b/test/spec/ol/geolocation.test.js index ed993aa388..6507c36ad9 100644 --- a/test/spec/ol/geolocation.test.js +++ b/test/spec/ol/geolocation.test.js @@ -1,4 +1,4 @@ -import _ol_Geolocation_ from '../../../src/ol/Geolocation.js'; +import Geolocation from '../../../src/ol/Geolocation.js'; describe('ol.Geolocation', function() { @@ -6,8 +6,8 @@ describe('ol.Geolocation', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var instance = new _ol_Geolocation_(); - expect(instance).to.be.an(_ol_Geolocation_); + var instance = new Geolocation(); + expect(instance).to.be.an(Geolocation); }); }); From 3f3e412d10f367da41f11ab01c597beda04ca880 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sat, 16 Dec 2017 08:25:23 +0100 Subject: [PATCH 4/4] Rename _ol_AssertionError_ to AssertionError --- src/ol/AssertionError.js | 6 +++--- src/ol/Collection.js | 4 ++-- src/ol/asserts.js | 4 ++-- test/spec/ol/assertionerror.test.js | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ol/AssertionError.js b/src/ol/AssertionError.js index 95418f2112..6b1bcc4ac3 100644 --- a/src/ol/AssertionError.js +++ b/src/ol/AssertionError.js @@ -12,7 +12,7 @@ import {VERSION, inherits} from './index.js'; * @implements {oli.AssertionError} * @param {number} code Error code. */ -var _ol_AssertionError_ = function(code) { +var AssertionError = function(code) { var path = VERSION ? VERSION.split('-')[0] : 'latest'; @@ -36,6 +36,6 @@ var _ol_AssertionError_ = function(code) { }; -inherits(_ol_AssertionError_, Error); +inherits(AssertionError, Error); -export default _ol_AssertionError_; +export default AssertionError; diff --git a/src/ol/Collection.js b/src/ol/Collection.js index 35598754a0..71cb942b87 100644 --- a/src/ol/Collection.js +++ b/src/ol/Collection.js @@ -2,7 +2,7 @@ * @module ol/Collection */ import {inherits} from './index.js'; -import _ol_AssertionError_ from './AssertionError.js'; +import AssertionError from './AssertionError.js'; import _ol_CollectionEventType_ from './CollectionEventType.js'; import _ol_Object_ from './Object.js'; import Event from './events/Event.js'; @@ -268,7 +268,7 @@ _ol_Collection_.prototype.updateLength_ = function() { _ol_Collection_.prototype.assertUnique_ = function(elem, opt_except) { for (var i = 0, ii = this.array_.length; i < ii; ++i) { if (this.array_[i] === elem && i !== opt_except) { - throw new _ol_AssertionError_(58); + throw new AssertionError(58); } } }; diff --git a/src/ol/asserts.js b/src/ol/asserts.js index e284c80901..626f95d744 100644 --- a/src/ol/asserts.js +++ b/src/ol/asserts.js @@ -1,7 +1,7 @@ /** * @module ol/asserts */ -import _ol_AssertionError_ from './AssertionError.js'; +import AssertionError from './AssertionError.js'; var _ol_asserts_ = {}; @@ -11,7 +11,7 @@ var _ol_asserts_ = {}; */ _ol_asserts_.assert = function(assertion, errorCode) { if (!assertion) { - throw new _ol_AssertionError_(errorCode); + throw new AssertionError(errorCode); } }; export default _ol_asserts_; diff --git a/test/spec/ol/assertionerror.test.js b/test/spec/ol/assertionerror.test.js index 70a7d9c14b..03999ebe16 100644 --- a/test/spec/ol/assertionerror.test.js +++ b/test/spec/ol/assertionerror.test.js @@ -1,25 +1,25 @@ import {VERSION} from '../../../src/ol/index.js'; -import _ol_AssertionError_ from '../../../src/ol/AssertionError.js'; +import AssertionError from '../../../src/ol/AssertionError.js'; describe('ol.AssertionError', function() { it('generates an error', function() { - var error = new _ol_AssertionError_(42); + var error = new AssertionError(42); expect(error).to.be.an(Error); }); it('generates a message with a versioned url', function() { - var error = new _ol_AssertionError_(42); + var error = new AssertionError(42); var path = VERSION ? VERSION.split('-')[0] : 'latest'; expect(error.message).to.be('Assertion failed. See https://openlayers.org/en/' + path + '/doc/errors/#42 for details.'); }); it('has an error code', function() { - var error = new _ol_AssertionError_(42); + var error = new AssertionError(42); expect(error.code).to.be(42); }); it('has a name', function() { - var error = new _ol_AssertionError_(42); + var error = new AssertionError(42); expect(error.name).to.be('AssertionError'); }); });