From af2e46cef2d9d557cb910db1a802a246a97726d8 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 27 May 2019 13:22:55 +0200 Subject: [PATCH 1/3] Make line param optional and remove ts-ignore --- contribs/gmf/src/lidarprofile/Manager.js | 2 +- contribs/gmf/src/lidarprofile/panelComponent.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/contribs/gmf/src/lidarprofile/Manager.js b/contribs/gmf/src/lidarprofile/Manager.js index b3f14e39d17..c7affd63d84 100644 --- a/contribs/gmf/src/lidarprofile/Manager.js +++ b/contribs/gmf/src/lidarprofile/Manager.js @@ -162,7 +162,7 @@ export class LidarprofileManager { /** * Set the line for the profile - * @param {import("ol/geom/LineString.js").default} line that defines the profile + * @param {?import("ol/geom/LineString.js").default} line that defines the profile */ setLine(line) { this.line_ = line; diff --git a/contribs/gmf/src/lidarprofile/panelComponent.js b/contribs/gmf/src/lidarprofile/panelComponent.js index 6f71035cdfa..ff7364424dd 100644 --- a/contribs/gmf/src/lidarprofile/panelComponent.js +++ b/contribs/gmf/src/lidarprofile/panelComponent.js @@ -251,7 +251,6 @@ class Controller { */ clearAll() { this.line = null; - // @ts-ignore: OL issue this.profile.setLine(null); this.profile.cartoHighlight.setPosition(undefined); this.clearMeasure(); From 965c4740962966b4d65df28e4bd93ffcbca03937 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 27 May 2019 13:33:57 +0200 Subject: [PATCH 2/3] Fix coordinate type in NominatimSearchResult typedef --- src/routing/NominatimService.js | 12 ++++++------ src/routing/RoutingFeatureComponent.js | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/routing/NominatimService.js b/src/routing/NominatimService.js index 408bce56c6e..2c8e3f8d3d8 100644 --- a/src/routing/NominatimService.js +++ b/src/routing/NominatimService.js @@ -7,16 +7,16 @@ import ngeoMiscDebounce from 'ngeo/misc/debounce.js'; /** * @typedef {Object} NominatimSearchResult * @property {string} name - * @property {string} label - * @property {import("ol/coordinate.js").Coordinate} coordinate + * @property {string} [label] + * @property {Array} coordinate */ /** * @typedef {Object} NominatimSearchResponseResult * @property {string} display_name - * @property {number} lon - * @property {number} lat + * @property {string} lon + * @property {string} lat */ @@ -168,10 +168,10 @@ NominatimService.prototype.typeaheadSource_ = function(query, syncResults, async * @return {NominatimSearchResult} Parsed result */ const parse = function(result) { - return /** @type {NominatimSearchResult} */({ + return { coordinate: [result.lon, result.lat], name: result.display_name - }); + }; }; if (asyncResults) { asyncResults(resp.data.map(parse)); diff --git a/src/routing/RoutingFeatureComponent.js b/src/routing/RoutingFeatureComponent.js index e1dc4092f2b..a98c46708ba 100644 --- a/src/routing/RoutingFeatureComponent.js +++ b/src/routing/RoutingFeatureComponent.js @@ -327,7 +327,6 @@ class Controller { if (!this.feature || !this.map) { return; } - // @ts-ignore: If types are not respected const coordinate = selected.coordinate.map(parseFloat); const label = selected.label; this.setFeature_(coordinate, label); @@ -353,8 +352,8 @@ class Controller { * @param {angular.IHttpResponse} resp */ const onSuccess = (resp) => { - const lon = resp.data.lon; - const lat = resp.data.lat; + const lon = parseFloat(resp.data.lon); + const lat = parseFloat(resp.data.lat); const coordinate = [lon, lat]; const label = resp.data.display_name; this.setFeature_(coordinate, label); From 0301ac3d1f33adca3bab540bdc1a60c224054f19 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 27 May 2019 13:39:25 +0200 Subject: [PATCH 3/3] Use toDegrees and toRadians functions from OpenLayers --- src/olcs/Service.js | 15 +++++---------- src/olcs/controls3d.js | 8 +++----- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/olcs/Service.js b/src/olcs/Service.js index 331bd6de093..9c8cbaccc35 100644 --- a/src/olcs/Service.js +++ b/src/olcs/Service.js @@ -1,10 +1,9 @@ -/* global Cesium */ - import angular from 'angular'; import ngeoMiscDebounce from 'ngeo/misc/debounce.js'; import ngeoStatemanagerLocation from 'ngeo/statemanager/Location.js'; import {Permalink3dParam} from 'ngeo/olcs/constants.js'; import ngeoStatemanagerService from 'ngeo/statemanager/Service.js'; +import {toDegrees} from 'ol/math.js'; /** * @hidden @@ -112,15 +111,11 @@ export const OlcsService = class { const position = camera.positionCartographic; this.ngeoStateManager_.updateState({ [Permalink3dParam.ENABLED]: true, - // @ts-ignore: Cesium - [Permalink3dParam.LON]: Cesium.Math.toDegrees(position.longitude).toFixed(5), - // @ts-ignore: Cesium - [Permalink3dParam.LAT]: Cesium.Math.toDegrees(position.latitude).toFixed(5), + [Permalink3dParam.LON]: toDegrees(position.longitude).toFixed(5), + [Permalink3dParam.LAT]: toDegrees(position.latitude).toFixed(5), [Permalink3dParam.ELEVATION]: position.height.toFixed(0), - // @ts-ignore: Cesium - [Permalink3dParam.HEADING]: Cesium.Math.toDegrees(camera.heading).toFixed(3), - // @ts-ignore: Cesium - [Permalink3dParam.PITCH]: Cesium.Math.toDegrees(camera.pitch).toFixed(3) + [Permalink3dParam.HEADING]: toDegrees(camera.heading).toFixed(3), + [Permalink3dParam.PITCH]: toDegrees(camera.pitch).toFixed(3) }); }, 1000, true)); diff --git a/src/olcs/controls3d.js b/src/olcs/controls3d.js index 2e5af02aba7..6d71e028b26 100644 --- a/src/olcs/controls3d.js +++ b/src/olcs/controls3d.js @@ -2,6 +2,7 @@ import angular from 'angular'; import * as olEasing from 'ol/easing.js'; +import {toRadians} from 'ol/math.js'; import olcsCore from 'olcs/core.js'; @@ -205,9 +206,7 @@ const Controller = class { if (!this.ol3dm) { throw new Error('Missing ol3dm'); } - // @ts-ignore: Cesium - angle = Cesium.Math.toRadians(angle); - this.ol3dm.setHeading(angle); + this.ol3dm.setHeading(toRadians(angle)); } @@ -218,8 +217,7 @@ const Controller = class { if (!this.ol3dm) { throw new Error('Missing ol3dm'); } - // @ts-ignore: Cesium - angle = Cesium.Math.toRadians(angle); + angle = toRadians(angle); const tiltOnGlobe = this.ol3dm.getTiltOnGlobe(); if (tiltOnGlobe == undefined) { throw new Error('Missing tiltOnGlobe');