Merge pull request #7826 from fredj/indent

Better code indentation and modules renaming
This commit is contained in:
Frédéric Junod
2018-02-15 09:13:22 +01:00
committed by GitHub
19 changed files with 82 additions and 157 deletions
+1 -1
View File
@@ -145,7 +145,7 @@ Collection.prototype.item = function(index) {
* @api * @api
*/ */
Collection.prototype.getLength = function() { Collection.prototype.getLength = function() {
return (/** @type {number} */ this.get(Property.LENGTH)); return /** @type {number} */ (this.get(Property.LENGTH));
}; };
+10 -30
View File
@@ -197,9 +197,7 @@ Geolocation.prototype.positionError_ = function(error) {
* @api * @api
*/ */
Geolocation.prototype.getAccuracy = function() { Geolocation.prototype.getAccuracy = function() {
return ( return /** @type {number|undefined} */ (this.get(GeolocationProperty.ACCURACY));
/** @type {number|undefined} */ this.get(GeolocationProperty.ACCURACY)
);
}; };
@@ -210,9 +208,7 @@ Geolocation.prototype.getAccuracy = function() {
* @api * @api
*/ */
Geolocation.prototype.getAccuracyGeometry = function() { Geolocation.prototype.getAccuracyGeometry = function() {
return ( return /** @type {?ol.geom.Polygon} */ (this.get(GeolocationProperty.ACCURACY_GEOMETRY) || null);
/** @type {?ol.geom.Polygon} */ this.get(GeolocationProperty.ACCURACY_GEOMETRY) || null
);
}; };
@@ -224,9 +220,7 @@ Geolocation.prototype.getAccuracyGeometry = function() {
* @api * @api
*/ */
Geolocation.prototype.getAltitude = function() { Geolocation.prototype.getAltitude = function() {
return ( return /** @type {number|undefined} */ (this.get(GeolocationProperty.ALTITUDE));
/** @type {number|undefined} */ this.get(GeolocationProperty.ALTITUDE)
);
}; };
@@ -238,9 +232,7 @@ Geolocation.prototype.getAltitude = function() {
* @api * @api
*/ */
Geolocation.prototype.getAltitudeAccuracy = function() { Geolocation.prototype.getAltitudeAccuracy = function() {
return ( return /** @type {number|undefined} */ (this.get(GeolocationProperty.ALTITUDE_ACCURACY));
/** @type {number|undefined} */ this.get(GeolocationProperty.ALTITUDE_ACCURACY)
);
}; };
@@ -253,9 +245,7 @@ Geolocation.prototype.getAltitudeAccuracy = function() {
* @api * @api
*/ */
Geolocation.prototype.getHeading = function() { Geolocation.prototype.getHeading = function() {
return ( return /** @type {number|undefined} */ (this.get(GeolocationProperty.HEADING));
/** @type {number|undefined} */ this.get(GeolocationProperty.HEADING)
);
}; };
@@ -267,9 +257,7 @@ Geolocation.prototype.getHeading = function() {
* @api * @api
*/ */
Geolocation.prototype.getPosition = function() { Geolocation.prototype.getPosition = function() {
return ( return /** @type {ol.Coordinate|undefined} */ (this.get(GeolocationProperty.POSITION));
/** @type {ol.Coordinate|undefined} */ this.get(GeolocationProperty.POSITION)
);
}; };
@@ -281,9 +269,7 @@ Geolocation.prototype.getPosition = function() {
* @api * @api
*/ */
Geolocation.prototype.getProjection = function() { Geolocation.prototype.getProjection = function() {
return ( return /** @type {ol.proj.Projection|undefined} */ (this.get(GeolocationProperty.PROJECTION));
/** @type {ol.proj.Projection|undefined} */ this.get(GeolocationProperty.PROJECTION)
);
}; };
@@ -295,9 +281,7 @@ Geolocation.prototype.getProjection = function() {
* @api * @api
*/ */
Geolocation.prototype.getSpeed = function() { Geolocation.prototype.getSpeed = function() {
return ( return /** @type {number|undefined} */ (this.get(GeolocationProperty.SPEED));
/** @type {number|undefined} */ this.get(GeolocationProperty.SPEED)
);
}; };
@@ -308,9 +292,7 @@ Geolocation.prototype.getSpeed = function() {
* @api * @api
*/ */
Geolocation.prototype.getTracking = function() { Geolocation.prototype.getTracking = function() {
return ( return /** @type {boolean} */ (this.get(GeolocationProperty.TRACKING));
/** @type {boolean} */ this.get(GeolocationProperty.TRACKING)
);
}; };
@@ -324,9 +306,7 @@ Geolocation.prototype.getTracking = function() {
* @api * @api
*/ */
Geolocation.prototype.getTrackingOptions = function() { Geolocation.prototype.getTrackingOptions = function() {
return ( return /** @type {GeolocationPositionOptions|undefined} */ (this.get(GeolocationProperty.TRACKING_OPTIONS));
/** @type {GeolocationPositionOptions|undefined} */ this.get(GeolocationProperty.TRACKING_OPTIONS)
);
}; };
+5 -5
View File
@@ -171,7 +171,7 @@ inherits(Overlay, BaseObject);
* @api * @api
*/ */
Overlay.prototype.getElement = function() { Overlay.prototype.getElement = function() {
return (/** @type {Element|undefined} */ this.get(Property.ELEMENT)); return /** @type {Element|undefined} */ (this.get(Property.ELEMENT));
}; };
@@ -192,7 +192,7 @@ Overlay.prototype.getId = function() {
* @api * @api
*/ */
Overlay.prototype.getMap = function() { Overlay.prototype.getMap = function() {
return (/** @type {ol.PluggableMap|undefined} */ this.get(Property.MAP)); return /** @type {ol.PluggableMap|undefined} */ (this.get(Property.MAP));
}; };
@@ -203,7 +203,7 @@ Overlay.prototype.getMap = function() {
* @api * @api
*/ */
Overlay.prototype.getOffset = function() { Overlay.prototype.getOffset = function() {
return (/** @type {Array.<number>} */ this.get(Property.OFFSET)); return /** @type {Array.<number>} */ (this.get(Property.OFFSET));
}; };
@@ -215,7 +215,7 @@ Overlay.prototype.getOffset = function() {
* @api * @api
*/ */
Overlay.prototype.getPosition = function() { Overlay.prototype.getPosition = function() {
return (/** @type {ol.Coordinate|undefined} */ this.get(Property.POSITION)); return /** @type {ol.Coordinate|undefined} */ (this.get(Property.POSITION));
}; };
@@ -227,7 +227,7 @@ Overlay.prototype.getPosition = function() {
* @api * @api
*/ */
Overlay.prototype.getPositioning = function() { Overlay.prototype.getPositioning = function() {
return (/** @type {ol.OverlayPositioning} */ this.get(Property.POSITIONING)); return /** @type {ol.OverlayPositioning} */ (this.get(Property.POSITIONING));
}; };
+4 -12
View File
@@ -664,9 +664,7 @@ PluggableMap.prototype.getEventPixel = function(event) {
* @api * @api
*/ */
PluggableMap.prototype.getTarget = function() { PluggableMap.prototype.getTarget = function() {
return ( return /** @type {Element|string|undefined} */ (this.get(MapProperty.TARGET));
/** @type {Element|string|undefined} */ this.get(MapProperty.TARGET)
);
}; };
@@ -762,9 +760,7 @@ PluggableMap.prototype.getInteractions = function() {
* @api * @api
*/ */
PluggableMap.prototype.getLayerGroup = function() { PluggableMap.prototype.getLayerGroup = function() {
return ( return /** @type {ol.layer.Group} */ (this.get(MapProperty.LAYERGROUP));
/** @type {ol.layer.Group} */ this.get(MapProperty.LAYERGROUP)
);
}; };
@@ -813,9 +809,7 @@ PluggableMap.prototype.getRenderer = function() {
* @api * @api
*/ */
PluggableMap.prototype.getSize = function() { PluggableMap.prototype.getSize = function() {
return ( return /** @type {ol.Size|undefined} */ (this.get(MapProperty.SIZE));
/** @type {ol.Size|undefined} */ this.get(MapProperty.SIZE)
);
}; };
@@ -827,9 +821,7 @@ PluggableMap.prototype.getSize = function() {
* @api * @api
*/ */
PluggableMap.prototype.getView = function() { PluggableMap.prototype.getView = function() {
return ( return /** @type {ol.View} */ (this.get(MapProperty.VIEW));
/** @type {ol.View} */ this.get(MapProperty.VIEW)
);
}; };
+3 -9
View File
@@ -571,9 +571,7 @@ View.prototype.constrainRotation = function(rotation, opt_delta) {
* @api * @api
*/ */
View.prototype.getCenter = function() { View.prototype.getCenter = function() {
return ( return /** @type {ol.Coordinate|undefined} */ (this.get(ViewProperty.CENTER));
/** @type {ol.Coordinate|undefined} */ this.get(ViewProperty.CENTER)
);
}; };
@@ -700,9 +698,7 @@ View.prototype.getProjection = function() {
* @api * @api
*/ */
View.prototype.getResolution = function() { View.prototype.getResolution = function() {
return ( return /** @type {number|undefined} */ (this.get(ViewProperty.RESOLUTION));
/** @type {number|undefined} */ this.get(ViewProperty.RESOLUTION)
);
}; };
@@ -763,9 +759,7 @@ View.prototype.getResolutionForValueFunction = function(opt_power) {
* @api * @api
*/ */
View.prototype.getRotation = function() { View.prototype.getRotation = function() {
return ( return /** @type {number} */ (this.get(ViewProperty.ROTATION));
/** @type {number} */ this.get(ViewProperty.ROTATION)
);
}; };
+2 -6
View File
@@ -133,9 +133,7 @@ MousePosition.prototype.handleProjectionChanged_ = function() {
* @api * @api
*/ */
MousePosition.prototype.getCoordinateFormat = function() { MousePosition.prototype.getCoordinateFormat = function() {
return ( return /** @type {ol.CoordinateFormatType|undefined} */ (this.get(COORDINATE_FORMAT));
/** @type {ol.CoordinateFormatType|undefined} */ this.get(COORDINATE_FORMAT)
);
}; };
@@ -147,9 +145,7 @@ MousePosition.prototype.getCoordinateFormat = function() {
* @api * @api
*/ */
MousePosition.prototype.getProjection = function() { MousePosition.prototype.getProjection = function() {
return ( return /** @type {ol.proj.Projection|undefined} */ (this.get(PROJECTION));
/** @type {ol.proj.Projection|undefined} */ this.get(PROJECTION)
);
}; };
+1 -3
View File
@@ -119,9 +119,7 @@ inherits(ScaleLine, Control);
* @api * @api
*/ */
ScaleLine.prototype.getUnits = function() { ScaleLine.prototype.getUnits = function() {
return ( return /** @type {ol.control.ScaleLineUnits|undefined} */ (this.get(UNITS));
/** @type {ol.control.ScaleLineUnits|undefined} */ this.get(UNITS)
);
}; };
+2 -5
View File
@@ -199,12 +199,9 @@ GMLBase.prototype.readGeometryElement = function(node, objectStack) {
context['srsName'] = node.firstElementChild.getAttribute('srsName'); context['srsName'] = node.firstElementChild.getAttribute('srsName');
context['srsDimension'] = node.firstElementChild.getAttribute('srsDimension'); context['srsDimension'] = node.firstElementChild.getAttribute('srsDimension');
/** @type {ol.geom.Geometry} */ /** @type {ol.geom.Geometry} */
const geometry = pushParseAndPop(null, const geometry = pushParseAndPop(null, this.GEOMETRY_PARSERS_, node, objectStack, this);
this.GEOMETRY_PARSERS_, node, objectStack, this);
if (geometry) { if (geometry) {
return ( return /** @type {ol.geom.Geometry} */ (transformWithOptions(geometry, false, context));
/** @type {ol.geom.Geometry} */ transformWithOptions(geometry, false, context)
);
} else { } else {
return undefined; return undefined;
} }
+1 -3
View File
@@ -796,9 +796,7 @@ WKT.prototype.readGeometry;
WKT.prototype.readGeometryFromText = function(text, opt_options) { WKT.prototype.readGeometryFromText = function(text, opt_options) {
const geometry = this.parse_(text); const geometry = this.parse_(text);
if (geometry) { if (geometry) {
return ( return /** @type {ol.geom.Geometry} */ (transformWithOptions(geometry, false, opt_options));
/** @type {ol.geom.Geometry} */ transformWithOptions(geometry, false, opt_options)
);
} else { } else {
return null; return null;
} }
+1 -1
View File
@@ -67,7 +67,7 @@ inherits(Interaction, BaseObject);
* @api * @api
*/ */
Interaction.prototype.getActive = function() { Interaction.prototype.getActive = function() {
return (/** @type {boolean} */ this.get(InteractionProperty.ACTIVE)); return /** @type {boolean} */ (this.get(InteractionProperty.ACTIVE));
}; };
+6 -18
View File
@@ -114,9 +114,7 @@ BaseLayer.prototype.getLayerStatesArray = function(opt_states) {};
* @api * @api
*/ */
BaseLayer.prototype.getExtent = function() { BaseLayer.prototype.getExtent = function() {
return ( return /** @type {ol.Extent|undefined} */ (this.get(LayerProperty.EXTENT));
/** @type {ol.Extent|undefined} */ this.get(LayerProperty.EXTENT)
);
}; };
@@ -127,9 +125,7 @@ BaseLayer.prototype.getExtent = function() {
* @api * @api
*/ */
BaseLayer.prototype.getMaxResolution = function() { BaseLayer.prototype.getMaxResolution = function() {
return ( return /** @type {number} */ (this.get(LayerProperty.MAX_RESOLUTION));
/** @type {number} */ this.get(LayerProperty.MAX_RESOLUTION)
);
}; };
@@ -140,9 +136,7 @@ BaseLayer.prototype.getMaxResolution = function() {
* @api * @api
*/ */
BaseLayer.prototype.getMinResolution = function() { BaseLayer.prototype.getMinResolution = function() {
return ( return /** @type {number} */ (this.get(LayerProperty.MIN_RESOLUTION));
/** @type {number} */ this.get(LayerProperty.MIN_RESOLUTION)
);
}; };
@@ -153,9 +147,7 @@ BaseLayer.prototype.getMinResolution = function() {
* @api * @api
*/ */
BaseLayer.prototype.getOpacity = function() { BaseLayer.prototype.getOpacity = function() {
return ( return /** @type {number} */ (this.get(LayerProperty.OPACITY));
/** @type {number} */ this.get(LayerProperty.OPACITY)
);
}; };
@@ -173,9 +165,7 @@ BaseLayer.prototype.getSourceState = function() {};
* @api * @api
*/ */
BaseLayer.prototype.getVisible = function() { BaseLayer.prototype.getVisible = function() {
return ( return /** @type {boolean} */ (this.get(LayerProperty.VISIBLE));
/** @type {boolean} */ this.get(LayerProperty.VISIBLE)
);
}; };
@@ -187,9 +177,7 @@ BaseLayer.prototype.getVisible = function() {
* @api * @api
*/ */
BaseLayer.prototype.getZIndex = function() { BaseLayer.prototype.getZIndex = function() {
return ( return /** @type {number} */ (this.get(LayerProperty.Z_INDEX));
/** @type {number} */ this.get(LayerProperty.Z_INDEX)
);
}; };
+8 -13
View File
@@ -98,10 +98,9 @@ LayerGroup.prototype.handleLayersChanged_ = function(event) {
const layers = this.getLayers(); const layers = this.getLayers();
this.layersListenerKeys_.push( this.layersListenerKeys_.push(
listen(layers, CollectionEventType.ADD, listen(layers, CollectionEventType.ADD, this.handleLayersAdd_, this),
this.handleLayersAdd_, this), listen(layers, CollectionEventType.REMOVE, this.handleLayersRemove_, this)
listen(layers, CollectionEventType.REMOVE, );
this.handleLayersRemove_, this));
for (const id in this.listenerKeys_) { for (const id in this.listenerKeys_) {
this.listenerKeys_[id].forEach(unlistenByKey); this.listenerKeys_[id].forEach(unlistenByKey);
@@ -112,10 +111,8 @@ LayerGroup.prototype.handleLayersChanged_ = function(event) {
for (let i = 0, ii = layersArray.length; i < ii; i++) { for (let i = 0, ii = layersArray.length; i < ii; i++) {
const layer = layersArray[i]; const layer = layersArray[i];
this.listenerKeys_[getUid(layer).toString()] = [ this.listenerKeys_[getUid(layer).toString()] = [
listen(layer, ObjectEventType.PROPERTYCHANGE, listen(layer, ObjectEventType.PROPERTYCHANGE, this.handleLayerChange_, this),
this.handleLayerChange_, this), listen(layer, EventType.CHANGE, this.handleLayerChange_, this)
listen(layer, EventType.CHANGE,
this.handleLayerChange_, this)
]; ];
} }
@@ -131,10 +128,8 @@ LayerGroup.prototype.handleLayersAdd_ = function(collectionEvent) {
const layer = /** @type {ol.layer.Base} */ (collectionEvent.element); const layer = /** @type {ol.layer.Base} */ (collectionEvent.element);
const key = getUid(layer).toString(); const key = getUid(layer).toString();
this.listenerKeys_[key] = [ this.listenerKeys_[key] = [
listen(layer, ObjectEventType.PROPERTYCHANGE, listen(layer, ObjectEventType.PROPERTYCHANGE, this.handleLayerChange_, this),
this.handleLayerChange_, this), listen(layer, EventType.CHANGE, this.handleLayerChange_, this)
listen(layer, EventType.CHANGE,
this.handleLayerChange_, this)
]; ];
this.changed(); this.changed();
}; };
@@ -162,7 +157,7 @@ LayerGroup.prototype.handleLayersRemove_ = function(collectionEvent) {
* @api * @api
*/ */
LayerGroup.prototype.getLayers = function() { LayerGroup.prototype.getLayers = function() {
return (/** @type {!ol.Collection.<ol.layer.Base>} */ this.get(Property.LAYERS)); return /** @type {!ol.Collection.<ol.layer.Base>} */ (this.get(Property.LAYERS));
}; };
+3 -3
View File
@@ -190,7 +190,7 @@ Heatmap.prototype.createCircle_ = function() {
* @observable * @observable
*/ */
Heatmap.prototype.getBlur = function() { Heatmap.prototype.getBlur = function() {
return (/** @type {number} */ this.get(Property.BLUR)); return /** @type {number} */ (this.get(Property.BLUR));
}; };
@@ -201,7 +201,7 @@ Heatmap.prototype.getBlur = function() {
* @observable * @observable
*/ */
Heatmap.prototype.getGradient = function() { Heatmap.prototype.getGradient = function() {
return (/** @type {Array.<string>} */ this.get(Property.GRADIENT)); return /** @type {Array.<string>} */ (this.get(Property.GRADIENT));
}; };
@@ -212,7 +212,7 @@ Heatmap.prototype.getGradient = function() {
* @observable * @observable
*/ */
Heatmap.prototype.getRadius = function() { Heatmap.prototype.getRadius = function() {
return (/** @type {number} */ this.get(Property.RADIUS)); return /** @type {number} */ (this.get(Property.RADIUS));
}; };
+8 -10
View File
@@ -178,16 +178,14 @@ Layer.prototype.setMap = function(map) {
this.mapRenderKey_ = null; this.mapRenderKey_ = null;
} }
if (map) { if (map) {
this.mapPrecomposeKey_ = listen( this.mapPrecomposeKey_ = listen(map, RenderEventType.PRECOMPOSE, function(evt) {
map, RenderEventType.PRECOMPOSE, function(evt) { const layerState = this.getLayerState();
const layerState = this.getLayerState(); layerState.managed = false;
layerState.managed = false; layerState.zIndex = Infinity;
layerState.zIndex = Infinity; evt.frameState.layerStatesArray.push(layerState);
evt.frameState.layerStatesArray.push(layerState); evt.frameState.layerStates[getUid(this)] = layerState;
evt.frameState.layerStates[getUid(this)] = layerState; }, this);
}, this); this.mapRenderKey_ = listen(this, EventType.CHANGE, map.render, map);
this.mapRenderKey_ = listen(
this, EventType.CHANGE, map.render, map);
this.changed(); this.changed();
} }
}; };
+5 -10
View File
@@ -4,7 +4,7 @@
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import LayerType from '../LayerType.js'; import LayerType from '../LayerType.js';
import Layer from '../layer/Layer.js'; import Layer from '../layer/Layer.js';
import _ol_layer_TileProperty_ from '../layer/TileProperty.js'; import TileProperty from '../layer/TileProperty.js';
import {assign} from '../obj.js'; import {assign} from '../obj.js';
/** /**
@@ -53,9 +53,7 @@ inherits(TileLayer, Layer);
* @api * @api
*/ */
TileLayer.prototype.getPreload = function() { TileLayer.prototype.getPreload = function() {
return ( return /** @type {number} */ (this.get(TileProperty.PRELOAD));
/** @type {number} */ this.get(_ol_layer_TileProperty_.PRELOAD)
);
}; };
@@ -75,7 +73,7 @@ TileLayer.prototype.getSource;
* @api * @api
*/ */
TileLayer.prototype.setPreload = function(preload) { TileLayer.prototype.setPreload = function(preload) {
this.set(_ol_layer_TileProperty_.PRELOAD, preload); this.set(TileProperty.PRELOAD, preload);
}; };
@@ -86,9 +84,7 @@ TileLayer.prototype.setPreload = function(preload) {
* @api * @api
*/ */
TileLayer.prototype.getUseInterimTilesOnError = function() { TileLayer.prototype.getUseInterimTilesOnError = function() {
return ( return /** @type {boolean} */ (this.get(TileProperty.USE_INTERIM_TILES_ON_ERROR));
/** @type {boolean} */ this.get(_ol_layer_TileProperty_.USE_INTERIM_TILES_ON_ERROR)
);
}; };
@@ -99,7 +95,6 @@ TileLayer.prototype.getUseInterimTilesOnError = function() {
* @api * @api
*/ */
TileLayer.prototype.setUseInterimTilesOnError = function(useInterimTilesOnError) { TileLayer.prototype.setUseInterimTilesOnError = function(useInterimTilesOnError) {
this.set( this.set(TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
_ol_layer_TileProperty_.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
}; };
export default TileLayer; export default TileLayer;
+3 -3
View File
@@ -4,7 +4,7 @@
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import LayerType from '../LayerType.js'; import LayerType from '../LayerType.js';
import Layer from '../layer/Layer.js'; import Layer from '../layer/Layer.js';
import _ol_layer_VectorRenderType_ from '../layer/VectorRenderType.js'; import VectorRenderType from '../layer/VectorRenderType.js';
import {assign} from '../obj.js'; import {assign} from '../obj.js';
import Style from '../style/Style.js'; import Style from '../style/Style.js';
@@ -90,7 +90,7 @@ const VectorLayer = function(opt_options) {
* @private * @private
* @type {ol.layer.VectorTileRenderType|string} * @type {ol.layer.VectorTileRenderType|string}
*/ */
this.renderMode_ = options.renderMode || _ol_layer_VectorRenderType_.VECTOR; this.renderMode_ = options.renderMode || VectorRenderType.VECTOR;
/** /**
* The layer type. * The layer type.
@@ -133,7 +133,7 @@ VectorLayer.prototype.getRenderBuffer = function() {
* order. * order.
*/ */
VectorLayer.prototype.getRenderOrder = function() { VectorLayer.prototype.getRenderOrder = function() {
return (/** @type {ol.RenderOrderFunction|null|undefined} */ this.get(Property.RENDER_ORDER)); return /** @type {ol.RenderOrderFunction|null|undefined} */ (this.get(Property.RENDER_ORDER));
}; };
+12 -17
View File
@@ -4,9 +4,9 @@
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import LayerType from '../LayerType.js'; import LayerType from '../LayerType.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import _ol_layer_TileProperty_ from '../layer/TileProperty.js'; import TileProperty from '../layer/TileProperty.js';
import VectorLayer from '../layer/Vector.js'; import VectorLayer from '../layer/Vector.js';
import _ol_layer_VectorTileRenderType_ from '../layer/VectorTileRenderType.js'; import VectorTileRenderType from '../layer/VectorTileRenderType.js';
import {assign} from '../obj.js'; import {assign} from '../obj.js';
/** /**
@@ -24,14 +24,14 @@ import {assign} from '../obj.js';
const VectorTileLayer = function(opt_options) { const VectorTileLayer = function(opt_options) {
const options = opt_options ? opt_options : {}; const options = opt_options ? opt_options : {};
let renderMode = options.renderMode || _ol_layer_VectorTileRenderType_.HYBRID; let renderMode = options.renderMode || VectorTileRenderType.HYBRID;
assert(renderMode == undefined || assert(renderMode == undefined ||
renderMode == _ol_layer_VectorTileRenderType_.IMAGE || renderMode == VectorTileRenderType.IMAGE ||
renderMode == _ol_layer_VectorTileRenderType_.HYBRID || renderMode == VectorTileRenderType.HYBRID ||
renderMode == _ol_layer_VectorTileRenderType_.VECTOR, renderMode == VectorTileRenderType.VECTOR,
28); // `renderMode` must be `'image'`, `'hybrid'` or `'vector'` 28); // `renderMode` must be `'image'`, `'hybrid'` or `'vector'`
if (options.declutter && renderMode == _ol_layer_VectorTileRenderType_.IMAGE) { if (options.declutter && renderMode == VectorTileRenderType.IMAGE) {
renderMode = _ol_layer_VectorTileRenderType_.HYBRID; renderMode = VectorTileRenderType.HYBRID;
} }
options.renderMode = renderMode; options.renderMode = renderMode;
@@ -64,9 +64,7 @@ inherits(VectorTileLayer, VectorLayer);
* @api * @api
*/ */
VectorTileLayer.prototype.getPreload = function() { VectorTileLayer.prototype.getPreload = function() {
return ( return /** @type {number} */ (this.get(TileProperty.PRELOAD));
/** @type {number} */ this.get(_ol_layer_TileProperty_.PRELOAD)
);
}; };
@@ -77,9 +75,7 @@ VectorTileLayer.prototype.getPreload = function() {
* @api * @api
*/ */
VectorTileLayer.prototype.getUseInterimTilesOnError = function() { VectorTileLayer.prototype.getUseInterimTilesOnError = function() {
return ( return /** @type {boolean} */ (this.get(TileProperty.USE_INTERIM_TILES_ON_ERROR));
/** @type {boolean} */ this.get(_ol_layer_TileProperty_.USE_INTERIM_TILES_ON_ERROR)
);
}; };
@@ -90,7 +86,7 @@ VectorTileLayer.prototype.getUseInterimTilesOnError = function() {
* @api * @api
*/ */
VectorTileLayer.prototype.setPreload = function(preload) { VectorTileLayer.prototype.setPreload = function(preload) {
this.set(_ol_layer_TileProperty_.PRELOAD, preload); this.set(TileProperty.PRELOAD, preload);
}; };
@@ -101,8 +97,7 @@ VectorTileLayer.prototype.setPreload = function(preload) {
* @api * @api
*/ */
VectorTileLayer.prototype.setUseInterimTilesOnError = function(useInterimTilesOnError) { VectorTileLayer.prototype.setUseInterimTilesOnError = function(useInterimTilesOnError) {
this.set( this.set(TileProperty.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
_ol_layer_TileProperty_.USE_INTERIM_TILES_ON_ERROR, useInterimTilesOnError);
}; };
+2 -2
View File
@@ -8,7 +8,7 @@ import LayerType from '../../LayerType.js';
import ViewHint from '../../ViewHint.js'; import ViewHint from '../../ViewHint.js';
import {equals} from '../../array.js'; import {equals} from '../../array.js';
import {getHeight, getIntersection, getWidth, isEmpty} from '../../extent.js'; import {getHeight, getIntersection, getWidth, isEmpty} from '../../extent.js';
import _ol_layer_VectorRenderType_ from '../../layer/VectorRenderType.js'; import VectorRenderType from '../../layer/VectorRenderType.js';
import {assign} from '../../obj.js'; import {assign} from '../../obj.js';
import {getLayerRendererPlugins} from '../../plugins.js'; import {getLayerRendererPlugins} from '../../plugins.js';
import RendererType from '../Type.js'; import RendererType from '../Type.js';
@@ -62,7 +62,7 @@ inherits(CanvasImageLayerRenderer, IntermediateCanvasRenderer);
CanvasImageLayerRenderer['handles'] = function(type, layer) { CanvasImageLayerRenderer['handles'] = function(type, layer) {
return type === RendererType.CANVAS && (layer.getType() === LayerType.IMAGE || return type === RendererType.CANVAS && (layer.getType() === LayerType.IMAGE ||
layer.getType() === LayerType.VECTOR && layer.getType() === LayerType.VECTOR &&
/** @type {ol.layer.Vector} */ (layer).getRenderMode() === _ol_layer_VectorRenderType_.IMAGE); /** @type {ol.layer.Vector} */ (layer).getRenderMode() === VectorRenderType.IMAGE);
}; };
+5 -6
View File
@@ -9,7 +9,7 @@ import {listen, unlisten} from '../../events.js';
import EventType from '../../events/EventType.js'; import EventType from '../../events/EventType.js';
import rbush from 'rbush'; import rbush from 'rbush';
import {buffer, containsCoordinate, equals, getIntersection, getTopLeft, intersects} from '../../extent.js'; import {buffer, containsCoordinate, equals, getIntersection, getTopLeft, intersects} from '../../extent.js';
import _ol_layer_VectorTileRenderType_ from '../../layer/VectorTileRenderType.js'; import VectorTileRenderType from '../../layer/VectorTileRenderType.js';
import {equivalent as equivalentProjection} from '../../proj.js'; import {equivalent as equivalentProjection} from '../../proj.js';
import Units from '../../proj/Units.js'; import Units from '../../proj/Units.js';
import ReplayType from '../../render/ReplayType.js'; import ReplayType from '../../render/ReplayType.js';
@@ -82,8 +82,7 @@ const CanvasVectorTileLayerRenderer = function(layer) {
this.tmpTransform_ = _ol_transform_.create(); this.tmpTransform_ = _ol_transform_.create();
// Use lower resolution for pure vector rendering. Closest resolution otherwise. // Use lower resolution for pure vector rendering. Closest resolution otherwise.
this.zDirection = this.zDirection = layer.getRenderMode() == VectorTileRenderType.VECTOR ? 1 : 0;
layer.getRenderMode() == _ol_layer_VectorTileRenderType_.VECTOR ? 1 : 0;
listen(labelCache, EventType.CLEAR, this.handleFontsChanged_, this); listen(labelCache, EventType.CLEAR, this.handleFontsChanged_, this);
@@ -132,10 +131,10 @@ CanvasVectorTileLayerRenderer.prototype.prepareFrame = function(frameState, laye
if (this.renderedLayerRevision_ != layerRevision) { if (this.renderedLayerRevision_ != layerRevision) {
this.renderedTiles.length = 0; this.renderedTiles.length = 0;
const renderMode = layer.getRenderMode(); const renderMode = layer.getRenderMode();
if (!this.context && renderMode != _ol_layer_VectorTileRenderType_.VECTOR) { if (!this.context && renderMode != VectorTileRenderType.VECTOR) {
this.context = createCanvasContext2D(); this.context = createCanvasContext2D();
} }
if (this.context && renderMode == _ol_layer_VectorTileRenderType_.VECTOR) { if (this.context && renderMode == VectorTileRenderType.VECTOR) {
this.context = null; this.context = null;
} }
} }
@@ -398,7 +397,7 @@ CanvasVectorTileLayerRenderer.prototype.postCompose = function(context, frameSta
continue; continue;
} }
const replayGroup = sourceTile.getReplayGroup(layer, tileCoord.toString()); const replayGroup = sourceTile.getReplayGroup(layer, tileCoord.toString());
if (renderMode != _ol_layer_VectorTileRenderType_.VECTOR && !replayGroup.hasReplays(replayTypes)) { if (renderMode != VectorTileRenderType.VECTOR && !replayGroup.hasReplays(replayTypes)) {
continue; continue;
} }
if (!transform) { if (!transform) {