diff --git a/examples/center.js b/examples/center.js index e1f2e029d5..7f5ca270ad 100644 --- a/examples/center.js +++ b/examples/center.js @@ -5,6 +5,7 @@ import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js'; import {OSM, Vector as VectorSource} from '../src/ol/source.js'; import {Circle as CircleStyle, Fill, Stroke, Style} from '../src/ol/style.js'; +/** @type {VectorSource} */ const source = new VectorSource({ url: 'data/geojson/switzerland.geojson', format: new GeoJSON() @@ -51,21 +52,21 @@ const zoomtoswitzerland = document.getElementById('zoomtoswitzerland'); zoomtoswitzerland.addEventListener('click', function() { const feature = source.getFeatures()[0]; - const polygon = /** @type {import("../src/ol/geom/SimpleGeometry.js").default} */ (feature.getGeometry()); + const polygon = feature.getGeometry(); view.fit(polygon, {padding: [170, 50, 30, 150]}); }, false); const zoomtolausanne = document.getElementById('zoomtolausanne'); zoomtolausanne.addEventListener('click', function() { const feature = source.getFeatures()[1]; - const point = /** @type {import("../src/ol/geom/SimpleGeometry.js").default} */ (feature.getGeometry()); + const point = feature.getGeometry(); view.fit(point, {padding: [170, 50, 30, 150], minResolution: 50}); }, false); const centerlausanne = document.getElementById('centerlausanne'); centerlausanne.addEventListener('click', function() { const feature = source.getFeatures()[1]; - const point = /** @type {import("../src/ol/geom/Point.js").default} */ (feature.getGeometry()); + const point = feature.getGeometry(); const size = map.getSize(); view.centerOn(point.getCoordinates(), size, [570, 500]); }, false); diff --git a/examples/feature-move-animation.js b/examples/feature-move-animation.js index 1d8d7bc088..5a002c5009 100644 --- a/examples/feature-move-animation.js +++ b/examples/feature-move-animation.js @@ -67,10 +67,10 @@ const routeFeature = new Feature({ type: 'route', geometry: route }); -const geoMarker = new Feature({ +const geoMarker = /** @type Feature */(new Feature({ type: 'geoMarker', geometry: new Point(routeCoords[0]) -}); +})); const startMarker = new Feature({ type: 'icon', geometry: new Point(routeCoords[0]) @@ -191,7 +191,7 @@ function stopAnimation(ended) { // if animation cancelled set the marker at the beginning const coord = ended ? routeCoords[routeLength - 1] : routeCoords[0]; - const geometry = /** @type {import("../src/ol/geom/Point").default} */ (geoMarker.getGeometry()); + const geometry = geoMarker.getGeometry(); geometry.setCoordinates(coord); //remove listener vectorLayer.un('postrender', moveFeature); diff --git a/src/ol/interaction/Draw.js b/src/ol/interaction/Draw.js index 3d28104798..201cfddde0 100644 --- a/src/ol/interaction/Draw.js +++ b/src/ol/interaction/Draw.js @@ -373,7 +373,7 @@ class Draw extends PointerInteraction { /** * Sketch point. - * @type {Feature} + * @type {Feature} * @private */ this.sketchPoint_ = null; @@ -387,7 +387,7 @@ class Draw extends PointerInteraction { /** * Sketch line. Used when drawing polygon. - * @type {Feature} + * @type {Feature} * @private */ this.sketchLine_ = null; @@ -669,7 +669,7 @@ class Draw extends PointerInteraction { this.sketchPoint_ = new Feature(new Point(coordinates)); this.updateSketchFeatures_(); } else { - const sketchPointGeom = /** @type {Point} */ (this.sketchPoint_.getGeometry()); + const sketchPointGeom = this.sketchPoint_.getGeometry(); sketchPointGeom.setCoordinates(coordinates); } } @@ -711,7 +711,7 @@ class Draw extends PointerInteraction { */ modifyDrawing_(event) { let coordinate = event.coordinate; - const geometry = /** @type {import("../geom/SimpleGeometry.js").default} */ (this.sketchFeature_.getGeometry()); + const geometry = this.sketchFeature_.getGeometry(); let coordinates, last; if (this.mode_ === Mode.POINT) { last = this.sketchCoords_; @@ -730,7 +730,7 @@ class Draw extends PointerInteraction { last[1] = coordinate[1]; this.geometryFunction_(/** @type {!LineCoordType} */ (this.sketchCoords_), geometry); if (this.sketchPoint_) { - const sketchPointGeom = /** @type {Point} */ (this.sketchPoint_.getGeometry()); + const sketchPointGeom = this.sketchPoint_.getGeometry(); sketchPointGeom.setCoordinates(coordinate); } /** @type {LineString} */ @@ -740,8 +740,8 @@ class Draw extends PointerInteraction { if (!this.sketchLine_) { this.sketchLine_ = new Feature(); } - const ring = /** @type {Polygon} */ (geometry).getLinearRing(0); - sketchLineGeom = /** @type {LineString} */ (this.sketchLine_.getGeometry()); + const ring = geometry.getLinearRing(0); + sketchLineGeom = this.sketchLine_.getGeometry(); if (!sketchLineGeom) { sketchLineGeom = new LineString(ring.getFlatCoordinates(), ring.getLayout()); this.sketchLine_.setGeometry(sketchLineGeom); @@ -751,7 +751,7 @@ class Draw extends PointerInteraction { sketchLineGeom.changed(); } } else if (this.sketchLineCoords_) { - sketchLineGeom = /** @type {LineString} */ (this.sketchLine_.getGeometry()); + sketchLineGeom = this.sketchLine_.getGeometry(); sketchLineGeom.setCoordinates(this.sketchLineCoords_); } this.updateSketchFeatures_(); @@ -764,7 +764,7 @@ class Draw extends PointerInteraction { */ addToDrawing_(event) { const coordinate = event.coordinate; - const geometry = /** @type {import("../geom/SimpleGeometry.js").default} */ (this.sketchFeature_.getGeometry()); + const geometry = this.sketchFeature_.getGeometry(); let done; let coordinates; if (this.mode_ === Mode.LINE_STRING) { @@ -808,7 +808,7 @@ class Draw extends PointerInteraction { if (!this.sketchFeature_) { return; } - const geometry = /** @type {import("../geom/SimpleGeometry.js").default} */ (this.sketchFeature_.getGeometry()); + const geometry = this.sketchFeature_.getGeometry(); let coordinates; /** @type {LineString} */ let sketchLineGeom; @@ -822,7 +822,7 @@ class Draw extends PointerInteraction { } else if (this.mode_ === Mode.POLYGON) { coordinates = /** @type {PolyCoordType} */ (this.sketchCoords_)[0]; coordinates.splice(-2, 1); - sketchLineGeom = /** @type {LineString} */ (this.sketchLine_.getGeometry()); + sketchLineGeom = this.sketchLine_.getGeometry(); sketchLineGeom.setCoordinates(coordinates); this.geometryFunction_(this.sketchCoords_, geometry); } @@ -846,7 +846,7 @@ class Draw extends PointerInteraction { return; } let coordinates = this.sketchCoords_; - const geometry = /** @type {import("../geom/SimpleGeometry.js").default} */ (sketchFeature.getGeometry()); + const geometry = sketchFeature.getGeometry(); if (this.mode_ === Mode.LINE_STRING) { // remove the redundant last point coordinates.pop(); @@ -900,12 +900,12 @@ class Draw extends PointerInteraction { * Extend an existing geometry by adding additional points. This only works * on features with `LineString` geometries, where the interaction will * extend lines by adding points to the end of the coordinates array. - * @param {!Feature} feature Feature to be extended. + * @param {!Feature} feature Feature to be extended. * @api */ extend(feature) { const geometry = feature.getGeometry(); - const lineString = /** @type {LineString} */ (geometry); + const lineString = geometry; this.sketchFeature_ = feature; this.sketchCoords_ = lineString.getCoordinates(); const last = this.sketchCoords_[this.sketchCoords_.length - 1]; diff --git a/src/ol/interaction/Extent.js b/src/ol/interaction/Extent.js index fdff413a53..02ffdf7777 100644 --- a/src/ol/interaction/Extent.js +++ b/src/ol/interaction/Extent.js @@ -126,7 +126,7 @@ class Extent extends PointerInteraction { /** * Feature for displaying the visible pointer - * @type {Feature} + * @type {Feature} * @private */ this.vertexFeature_ = null; @@ -265,7 +265,7 @@ class Extent extends PointerInteraction { this.vertexFeature_ = vertexFeature; this.vertexOverlay_.getSource().addFeature(vertexFeature); } else { - const geometry = /** @type {Point} */ (vertexFeature.getGeometry()); + const geometry = vertexFeature.getGeometry(); geometry.setCoordinates(vertex); } return vertexFeature; diff --git a/src/ol/interaction/Modify.js b/src/ol/interaction/Modify.js index 8a2382cb25..e878f5065d 100644 --- a/src/ol/interaction/Modify.js +++ b/src/ol/interaction/Modify.js @@ -660,7 +660,7 @@ class Modify extends PointerInteraction { this.vertexFeature_ = vertexFeature; this.overlay_.getSource().addFeature(vertexFeature); } else { - const geometry = /** @type {Point} */ (vertexFeature.getGeometry()); + const geometry = vertexFeature.getGeometry(); geometry.setCoordinates(coordinates); } return vertexFeature; @@ -785,7 +785,7 @@ class Modify extends PointerInteraction { const vertexFeature = this.vertexFeature_; if (vertexFeature) { const insertVertices = []; - const geometry = /** @type {Point} */ (vertexFeature.getGeometry()); + const geometry = vertexFeature.getGeometry(); const vertex = geometry.getCoordinates(); const vertexExtent = boundingExtent([vertex]); const segmentDataMatches = this.rBush_.getInExtent(vertexExtent); diff --git a/src/ol/renderer/webgl/PointsLayer.js b/src/ol/renderer/webgl/PointsLayer.js index 77b4e5f623..759c40d538 100644 --- a/src/ol/renderer/webgl/PointsLayer.js +++ b/src/ol/renderer/webgl/PointsLayer.js @@ -25,15 +25,15 @@ const VERTEX_SHADER = ` attribute vec2 a_offsets; attribute float a_opacity; attribute vec4 a_color; - + uniform mat4 u_projectionMatrix; uniform mat4 u_offsetScaleMatrix; uniform mat4 u_offsetRotateMatrix; - + varying vec2 v_texCoord; varying float v_opacity; varying vec4 v_color; - + void main(void) { mat4 offsetMatrix = u_offsetScaleMatrix; if (a_rotateWithView == 1.0) { @@ -48,13 +48,13 @@ const VERTEX_SHADER = ` const FRAGMENT_SHADER = ` precision mediump float; - + uniform sampler2D u_texture; varying vec2 v_texCoord; varying float v_opacity; varying vec4 v_color; - + void main(void) { if (v_opacity == 0.0) { discard; @@ -222,7 +222,7 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer { return 1; }; this.coordCallback_ = options.coordCallback || function(feature, index) { - const geom = /** @type {import("../../geom/Point").default} */ (feature.getGeometry()); + const geom = feature.getGeometry(); return geom.getCoordinates()[index]; }; this.opacityCallback_ = options.opacityCallback || function() { diff --git a/src/ol/source/Cluster.js b/src/ol/source/Cluster.js index e2dbcbf481..ccb01e5814 100644 --- a/src/ol/source/Cluster.js +++ b/src/ol/source/Cluster.js @@ -76,7 +76,7 @@ class Cluster extends VectorSource { * @protected */ this.geometryFunction = options.geometryFunction || function(feature) { - const geometry = /** @type {Point} */ (feature.getGeometry()); + const geometry = feature.getGeometry(); assert(geometry.getType() == GeometryType.POINT, 10); // The default `geometryFunction` can only handle `Point` geometries return geometry;