Remove unneeded type cast

This commit is contained in:
Frederic Junod
2019-01-28 15:33:57 +01:00
parent 5318d52036
commit 0b53a3229b
10 changed files with 24 additions and 24 deletions
+2 -2
View File
@@ -891,7 +891,7 @@ class Draw extends PointerInteraction {
this.sketchFeature_ = null; this.sketchFeature_ = null;
this.sketchPoint_ = null; this.sketchPoint_ = null;
this.sketchLine_ = null; this.sketchLine_ = null;
/** @type {VectorSource} */ (this.overlay_.getSource()).clear(true); this.overlay_.getSource().clear(true);
} }
return sketchFeature; return sketchFeature;
} }
@@ -930,7 +930,7 @@ class Draw extends PointerInteraction {
if (this.sketchPoint_) { if (this.sketchPoint_) {
sketchFeatures.push(this.sketchPoint_); sketchFeatures.push(this.sketchPoint_);
} }
const overlaySource = /** @type {VectorSource} */ (this.overlay_.getSource()); const overlaySource = this.overlay_.getSource();
overlaySource.clear(true); overlaySource.clear(true);
overlaySource.addFeatures(sketchFeatures); overlaySource.addFeatures(sketchFeatures);
} }
+2 -2
View File
@@ -242,7 +242,7 @@ class ExtentInteraction extends PointerInteraction {
extentFeature = new Feature(polygonFromExtent(extent)); extentFeature = new Feature(polygonFromExtent(extent));
} }
this.extentFeature_ = extentFeature; this.extentFeature_ = extentFeature;
/** @type {VectorSource} */ (this.extentOverlay_.getSource()).addFeature(extentFeature); this.extentOverlay_.getSource().addFeature(extentFeature);
} else { } else {
if (!extent) { if (!extent) {
extentFeature.setGeometry(undefined); extentFeature.setGeometry(undefined);
@@ -263,7 +263,7 @@ class ExtentInteraction extends PointerInteraction {
if (!vertexFeature) { if (!vertexFeature) {
vertexFeature = new Feature(new Point(vertex)); vertexFeature = new Feature(new Point(vertex));
this.vertexFeature_ = vertexFeature; this.vertexFeature_ = vertexFeature;
/** @type {VectorSource} */ (this.vertexOverlay_.getSource()).addFeature(vertexFeature); this.vertexOverlay_.getSource().addFeature(vertexFeature);
} else { } else {
const geometry = /** @type {Point} */ (vertexFeature.getGeometry()); const geometry = /** @type {Point} */ (vertexFeature.getGeometry());
geometry.setCoordinates(vertex); geometry.setCoordinates(vertex);
+5 -5
View File
@@ -368,7 +368,7 @@ class Modify extends PointerInteraction {
// Remove the vertex feature if the collection of canditate features // Remove the vertex feature if the collection of canditate features
// is empty. // is empty.
if (this.vertexFeature_ && this.features_.getLength() === 0) { if (this.vertexFeature_ && this.features_.getLength() === 0) {
/** @type {VectorSource} */ (this.overlay_.getSource()).removeFeature(this.vertexFeature_); this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null; this.vertexFeature_ = null;
} }
unlisten(feature, EventType.CHANGE, unlisten(feature, EventType.CHANGE,
@@ -407,7 +407,7 @@ class Modify extends PointerInteraction {
*/ */
setActive(active) { setActive(active) {
if (this.vertexFeature_ && !active) { if (this.vertexFeature_ && !active) {
/** @type {VectorSource} */ (this.overlay_.getSource()).removeFeature(this.vertexFeature_); this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null; this.vertexFeature_ = null;
} }
super.setActive(active); super.setActive(active);
@@ -658,7 +658,7 @@ class Modify extends PointerInteraction {
if (!vertexFeature) { if (!vertexFeature) {
vertexFeature = new Feature(new Point(coordinates)); vertexFeature = new Feature(new Point(coordinates));
this.vertexFeature_ = vertexFeature; this.vertexFeature_ = vertexFeature;
/** @type {VectorSource} */ (this.overlay_.getSource()).addFeature(vertexFeature); this.overlay_.getSource().addFeature(vertexFeature);
} else { } else {
const geometry = /** @type {Point} */ (vertexFeature.getGeometry()); const geometry = /** @type {Point} */ (vertexFeature.getGeometry());
geometry.setCoordinates(coordinates); geometry.setCoordinates(coordinates);
@@ -944,7 +944,7 @@ class Modify extends PointerInteraction {
} }
} }
if (this.vertexFeature_) { if (this.vertexFeature_) {
/** @type {VectorSource} */ (this.overlay_.getSource()).removeFeature(this.vertexFeature_); this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null; this.vertexFeature_ = null;
} }
} }
@@ -1139,7 +1139,7 @@ class Modify extends PointerInteraction {
} }
this.updateSegmentIndices_(geometry, index, segmentData.depth, -1); this.updateSegmentIndices_(geometry, index, segmentData.depth, -1);
if (this.vertexFeature_) { if (this.vertexFeature_) {
/** @type {VectorSource} */ (this.overlay_.getSource()).removeFeature(this.vertexFeature_); this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null; this.vertexFeature_ = null;
} }
dragSegments.length = 0; dragSegments.length = 0;
+1 -1
View File
@@ -275,7 +275,7 @@ class Select extends Interaction {
* @api * @api
*/ */
getFeatures() { getFeatures() {
return /** @type {VectorSource} */ (this.featureOverlay_.getSource()).getFeaturesCollection(); return this.featureOverlay_.getSource().getFeaturesCollection();
} }
/** /**
+1 -1
View File
@@ -437,7 +437,7 @@ class Graticule extends VectorLayer {
* @param {import("../proj/Projection.js").default} projection Projection * @param {import("../proj/Projection.js").default} projection Projection
*/ */
loaderFunction(extent, resolution, projection) { loaderFunction(extent, resolution, projection) {
const source = /** @type {import("../source/Vector.js").default} */ (this.getSource()); const source = this.getSource();
// only consider the intersection between our own extent & the requested one // only consider the intersection between our own extent & the requested one
const layerExtent = this.getExtent() || [-Infinity, -Infinity, Infinity, Infinity]; const layerExtent = this.getExtent() || [-Infinity, -Infinity, Infinity, Infinity];
+1 -1
View File
@@ -44,7 +44,7 @@ class CanvasImageLayerRenderer extends CanvasLayerRenderer {
const viewResolution = viewState.resolution; const viewResolution = viewState.resolution;
const imageLayer = /** @type {import("../../layer/Image.js").default} */ (this.getLayer()); const imageLayer = /** @type {import("../../layer/Image.js").default} */ (this.getLayer());
const imageSource = /** @type {import("../../source/Image.js").default} */ (imageLayer.getSource()); const imageSource = imageLayer.getSource();
const hints = frameState.viewHints; const hints = frameState.viewHints;
+3 -3
View File
@@ -88,7 +88,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
*/ */
getTile(z, x, y, pixelRatio, projection) { getTile(z, x, y, pixelRatio, projection) {
const tileLayer = /** @type {import("../../layer/Tile.js").default} */ (this.getLayer()); const tileLayer = /** @type {import("../../layer/Tile.js").default} */ (this.getLayer());
const tileSource = /** @type {import("../../source/Tile.js").default} */ (tileLayer.getSource()); const tileSource = tileLayer.getSource();
let tile = tileSource.getTile(z, x, y, pixelRatio, projection); let tile = tileSource.getTile(z, x, y, pixelRatio, projection);
if (tile.getState() == TileState.ERROR) { if (tile.getState() == TileState.ERROR) {
if (!tileLayer.getUseInterimTilesOnError()) { if (!tileLayer.getUseInterimTilesOnError()) {
@@ -130,7 +130,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
const pixelRatio = frameState.pixelRatio; const pixelRatio = frameState.pixelRatio;
const tileLayer = /** @type {import("../../layer/Tile.js").default} */ (this.getLayer()); const tileLayer = /** @type {import("../../layer/Tile.js").default} */ (this.getLayer());
const tileSource = /** @type {import("../../source/Tile.js").default} */ (tileLayer.getSource()); const tileSource = tileLayer.getSource();
const sourceRevision = tileSource.getRevision(); const sourceRevision = tileSource.getRevision();
const tileGrid = tileSource.getTileGridForProjection(projection); const tileGrid = tileSource.getTileGridForProjection(projection);
const z = tileGrid.getZForResolution(viewResolution, this.zDirection); const z = tileGrid.getZForResolution(viewResolution, this.zDirection);
@@ -334,7 +334,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
const uid = getUid(this); const uid = getUid(this);
const alpha = transition ? tile.getAlpha(uid, frameState.time) : 1; const alpha = transition ? tile.getAlpha(uid, frameState.time) : 1;
const tileLayer = /** @type {import("../../layer/Tile.js").default} */ (this.getLayer()); const tileLayer = /** @type {import("../../layer/Tile.js").default} */ (this.getLayer());
const tileSource = /** @type {import("../../source/Tile.js").default} */ (tileLayer.getSource()); const tileSource = tileLayer.getSource();
if (alpha === 1 && !tileSource.getOpaque(frameState.viewState.projection)) { if (alpha === 1 && !tileSource.getOpaque(frameState.viewState.projection)) {
this.context.clearRect(x, y, w, h); this.context.clearRect(x, y, w, h);
} }
+2 -2
View File
@@ -129,7 +129,7 @@ class CanvasVectorLayerRenderer extends CanvasLayerRenderer {
const projection = viewState.projection; const projection = viewState.projection;
const rotation = viewState.rotation; const rotation = viewState.rotation;
const projectionExtent = projection.getExtent(); const projectionExtent = projection.getExtent();
const vectorSource = /** @type {import("../../source/Vector.js").default} */ (this.getLayer().getSource()); const vectorSource = this.getLayer().getSource();
// clipped rendering if layer extent is set // clipped rendering if layer extent is set
const clipExtent = layerState.extent; const clipExtent = layerState.extent;
@@ -239,7 +239,7 @@ class CanvasVectorLayerRenderer extends CanvasLayerRenderer {
*/ */
prepareFrame(frameState, layerState) { prepareFrame(frameState, layerState) {
const vectorLayer = /** @type {import("../../layer/Vector.js").default} */ (this.getLayer()); const vectorLayer = /** @type {import("../../layer/Vector.js").default} */ (this.getLayer());
const vectorSource = /** @type {import("../../source/Vector.js").default} */ (vectorLayer.getSource()); const vectorSource = vectorLayer.getSource();
const animating = frameState.viewHints[ViewHint.ANIMATING]; const animating = frameState.viewHints[ViewHint.ANIMATING];
const interacting = frameState.viewHints[ViewHint.INTERACTING]; const interacting = frameState.viewHints[ViewHint.INTERACTING];
+6 -6
View File
@@ -229,7 +229,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
* @private * @private
*/ */
updateExecutorGroup_(tile, pixelRatio, projection) { updateExecutorGroup_(tile, pixelRatio, projection) {
const layer = /** @type {import("../../layer/Vector.js").default} */ (this.getLayer()); const layer = /** @type {import("../../layer/VectorTile.js").default} */ (this.getLayer());
const revision = layer.getRevision(); const revision = layer.getRevision();
const renderOrder = /** @type {import("../../render.js").OrderFunction} */ (layer.getRenderOrder()) || null; const renderOrder = /** @type {import("../../render.js").OrderFunction} */ (layer.getRenderOrder()) || null;
@@ -239,7 +239,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
return; return;
} }
const source = /** @type {import("../../source/VectorTile.js").default} */ (layer.getSource()); const source = layer.getSource();
const sourceTileGrid = source.getTileGrid(); const sourceTileGrid = source.getTileGrid();
const tileGrid = source.getTileGridForProjection(projection); const tileGrid = source.getTileGridForProjection(projection);
const zoom = tile.tileCoord[0]; const zoom = tile.tileCoord[0];
@@ -334,7 +334,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
const rotation = frameState.viewState.rotation; const rotation = frameState.viewState.rotation;
hitTolerance = hitTolerance == undefined ? 0 : hitTolerance; hitTolerance = hitTolerance == undefined ? 0 : hitTolerance;
const layer = this.getLayer(); const layer = this.getLayer();
const source = /** @type {import("../../source/VectorTile").default} */ (layer.getSource()); const source = layer.getSource();
const tileGrid = source.getTileGridForProjection(frameState.viewState.projection); const tileGrid = source.getTileGridForProjection(frameState.viewState.projection);
/** @type {!Object<string, boolean>} */ /** @type {!Object<string, boolean>} */
const features = {}; const features = {};
@@ -378,7 +378,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
*/ */
getReplayTransform_(tile, frameState) { getReplayTransform_(tile, frameState) {
const layer = this.getLayer(); const layer = this.getLayer();
const source = /** @type {import("../../source/VectorTile.js").default} */ (layer.getSource()); const source = layer.getSource();
const tileGrid = source.getTileGrid(); const tileGrid = source.getTileGrid();
const tileCoord = tile.tileCoord; const tileCoord = tile.tileCoord;
const tileResolution = tileGrid.getResolution(tileCoord[0]); const tileResolution = tileGrid.getResolution(tileCoord[0]);
@@ -435,7 +435,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
const context = this.overlayContext_; const context = this.overlayContext_;
const declutterReplays = layer.getDeclutter() ? {} : null; const declutterReplays = layer.getDeclutter() ? {} : null;
const source = /** @type {import("../../source/VectorTile.js").default} */ (layer.getSource()); const source = layer.getSource();
const replayTypes = VECTOR_REPLAYS[renderMode]; const replayTypes = VECTOR_REPLAYS[renderMode];
const pixelRatio = frameState.pixelRatio; const pixelRatio = frameState.pixelRatio;
const rotation = frameState.viewState.rotation; const rotation = frameState.viewState.rotation;
@@ -608,7 +608,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
replayState.renderedTileZ = tile.sourceZ; replayState.renderedTileZ = tile.sourceZ;
const tileCoord = tile.wrappedTileCoord; const tileCoord = tile.wrappedTileCoord;
const z = tileCoord[0]; const z = tileCoord[0];
const source = /** @type {import("../../source/VectorTile.js").default} */ (layer.getSource()); const source = layer.getSource();
const tileGrid = source.getTileGridForProjection(projection); const tileGrid = source.getTileGridForProjection(projection);
const resolution = tileGrid.getResolution(z); const resolution = tileGrid.getResolution(z);
const context = tile.getContext(layer); const context = tile.getContext(layer);
+1 -1
View File
@@ -264,7 +264,7 @@ class WebGLPointsLayerRenderer extends LayerRenderer {
*/ */
prepareFrame(frameState) { prepareFrame(frameState) {
const vectorLayer = /** @type {import("../../layer/Vector.js").default} */ (this.getLayer()); const vectorLayer = /** @type {import("../../layer/Vector.js").default} */ (this.getLayer());
const vectorSource = /** @type {import("../../source/Vector.js").default} */ (vectorLayer.getSource()); const vectorSource = vectorLayer.getSource();
const stride = 12; const stride = 12;