diff --git a/buildtools/webpack.commons.js b/buildtools/webpack.commons.js index 692eef8d6920..3a6bfbaaddff 100644 --- a/buildtools/webpack.commons.js +++ b/buildtools/webpack.commons.js @@ -181,7 +181,6 @@ module.exports = function (config) { babelrc: false, comments: false, presets: [babelPresetEnv], - plugins: [require.resolve('babel-plugin-angularjs-annotate')], }, }, }; diff --git a/contribs/gmf/apps/appmodule.js b/contribs/gmf/apps/appmodule.js index 5ab7d89984bd..6bbc93814e67 100644 --- a/contribs/gmf/apps/appmodule.js +++ b/contribs/gmf/apps/appmodule.js @@ -34,7 +34,6 @@ import AngularServices from 'ngeo/services'; * @hidden */ const appModule = angular.module('app', []); - appModule.config([ '$compileProvider', /** @@ -49,11 +48,12 @@ appModule.config([ ]); /** - * @ngInject */ -appModule.run(($injector) => { - //AngularServices.auth = $injector.get('gmfAuthenticationService'); - //AngularServices.notification = $injector.get('ngeoNotification'); -}); - +appModule.run([ + '$injector', + ($injector) => { + //AngularServices.auth = $injector.get('gmfAuthenticationService'); + //AngularServices.notification = $injector.get('ngeoNotification'); + }, +]); export default appModule; diff --git a/contribs/gmf/apps/desktop/Controller.js b/contribs/gmf/apps/desktop/Controller.js index acd64f0f7589..0ce075231bec 100644 --- a/contribs/gmf/apps/desktop/Controller.js +++ b/contribs/gmf/apps/desktop/Controller.js @@ -28,7 +28,6 @@ import './sass/desktop.scss'; import './sass/vars_desktop.scss'; - import angular from 'angular'; import {isEventUsingCtrlKey} from 'ngeo/utils'; import gmfControllersAbstractDesktopController, { @@ -55,19 +54,18 @@ class Controller extends AbstractDesktopController { * @hidden */ const appModule = angular.module('Appdesktop', [appBase.name, gmfControllersAbstractDesktopController.name]); - appModule.value('gmfContextualdatacontentTemplateUrl', 'gmf/contextualdata'); appModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/contextualdata', require('./contextualdata.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/contextualdata', require('./contextualdata.html')); + }, + ], ); - appModule.controller('DesktopController', Controller); - export default appModule; diff --git a/contribs/gmf/apps/desktop_alt/Controller.js b/contribs/gmf/apps/desktop_alt/Controller.js index 0b1c4fab26d3..90317c715d4a 100644 --- a/contribs/gmf/apps/desktop_alt/Controller.js +++ b/contribs/gmf/apps/desktop_alt/Controller.js @@ -28,7 +28,6 @@ import './sass/desktop_alt.scss'; import './sass/vars_desktop_alt.scss'; - import angular from 'angular'; import gmfControllersAbstractDesktopController, { AbstractDesktopController, @@ -49,11 +48,9 @@ class Controller extends AbstractDesktopController { /** * @param {angular.IScope} $scope Scope. * @param {angular.auto.IInjectorService} $injector Main injector. - * @ngInject */ constructor($scope, $injector) { super($scope, $injector); - if (this.dimensions.FLOOR == undefined) { this.dimensions.FLOOR = '*'; } @@ -62,16 +59,12 @@ class Controller extends AbstractDesktopController { * @type {boolean} */ this.drawLidarprofilePanelActive = false; - const drawLidarprofilePanelActive = new ngeoMiscToolActivate(this, 'drawLidarprofilePanelActive'); this.ngeoToolActivateMgr.registerTool('mapTools', drawLidarprofilePanelActive, false); - const $timeout = $injector.get('$timeout'); - panels.getActiveToolPanel().subscribe({ next: (panel) => { this.drawLidarprofilePanelActive = panel === 'lidar'; - $timeout(() => {}); // this triggered on DOM click, we call $timeout to force Angular digest }, }); @@ -82,7 +75,7 @@ class Controller extends AbstractDesktopController { */ onKeydown(event) {} } - +Controller.$inject = ['$scope', '$injector']; /** * @hidden */ @@ -95,7 +88,5 @@ const appModule = angular.module('Appdesktop_alt', [ ngeoStreetviewModule.name, ngeoStatemanagerWfsPermalink.name, ]); - appModule.controller('AlternativeDesktopController', Controller); - export default appModule; diff --git a/contribs/gmf/apps/oeedit/Controller.js b/contribs/gmf/apps/oeedit/Controller.js index 4f60efb996ba..21a92d8d2275 100644 --- a/contribs/gmf/apps/oeedit/Controller.js +++ b/contribs/gmf/apps/oeedit/Controller.js @@ -28,7 +28,6 @@ import './sass/vars_oeedit.scss'; import './sass/oeedit.scss'; - import angular from 'angular'; import gmfControllersAbstractDesktopController, { AbstractDesktopController, @@ -48,7 +47,6 @@ class Controller extends AbstractDesktopController { * @param {angular.IScope} $scope Scope. * @param {angular.auto.IInjectorService} $injector Main injector. * @param {angular.ITimeoutService} $timeout Angular timeout service. - * @ngInject */ constructor($scope, $injector, $timeout) { super($scope, $injector); @@ -64,12 +62,9 @@ class Controller extends AbstractDesktopController { * @type {import('ngeo/misc/ToolActivateMgr').ToolActivateMgr} */ const ngeoToolActivateMgr = $injector.get('ngeoToolActivateMgr'); - ngeoToolActivateMgr.unregisterGroup('mapTools'); - const oeEditToolActivate = new ngeoMiscToolActivate(this, 'oeEditActive'); ngeoToolActivateMgr.registerTool('mapTools', oeEditToolActivate, true); - const queryToolActivate = new ngeoMiscToolActivate(this, 'queryActive'); ngeoToolActivateMgr.registerTool('mapTools', queryToolActivate, false); @@ -114,7 +109,6 @@ class Controller extends AbstractDesktopController { * @type {import('gmf/theme/Themes').ThemesService} gmfObjectEditingManager The gmf theme service */ const gmfThemes = $injector.get('gmfThemes'); - gmfThemes.getThemesObject().then((themes) => { if (themes) { // Add layer vector after @@ -143,7 +137,6 @@ class Controller extends AbstractDesktopController { * @type {?import('ol/Feature').default} */ this.oeFeature = null; - gmfObjectEditingManager.getFeature().then((feature) => { this.oeFeature = feature; if (feature) { @@ -152,7 +145,7 @@ class Controller extends AbstractDesktopController { }); } } - +Controller.$inject = ['$scope', '$injector', '$timeout']; /** * @hidden */ @@ -161,26 +154,24 @@ const appModule = angular.module('Appoeedit', [ gmfControllersAbstractDesktopController.name, gmfObjecteditingModule.name, ]); - appModule.value('gmfContextualdatacontentTemplateUrl', 'gmf/contextualdata'); appModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/contextualdata', require('./contextualdata.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/contextualdata', require('./contextualdata.html')); + }, + ], ); - appModule.value( 'gmfPermalinkOptions', - /** @type {import('gmf/options').gmfPermalinkOptions} */ ({ + /** @type {import('gmf/options').gmfPermalinkOptions} */ { pointRecenterZoom: 10, - }), + }, ); - appModule.controller('OEEditController', Controller); - export default appModule; diff --git a/contribs/gmf/examples/backgroundlayerselector.js b/contribs/gmf/examples/backgroundlayerselector.js index 51fd4a410cae..6b6ccdfe3c90 100644 --- a/contribs/gmf/examples/backgroundlayerselector.js +++ b/contribs/gmf/examples/backgroundlayerselector.js @@ -1,3 +1,4 @@ +MainController.$inject = ['gmfThemes']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,9 +23,7 @@ import angular from 'angular'; import './backgroundlayerselector.css'; import gmfBackgroundlayerselectorModule from 'gmf/backgroundlayerselector/module'; - import gmfMapComponent from 'gmf/map/component'; - import gmfThemeThemes from 'gmf/theme/Themes'; import EPSG2056 from 'ngeo/proj/EPSG_2056'; import olMap from 'ol/Map'; @@ -47,7 +46,6 @@ const myModule = angular.module('gmfapp', [ /** * @param {import('gmf/theme/Themes').ThemesService} gmfThemes Themes service. * @class - * @ngInject */ function MainController(gmfThemes) { gmfThemes.loadThemes(); @@ -65,8 +63,6 @@ function MainController(gmfThemes) { }), }); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/contextualdata.js b/contribs/gmf/examples/contextualdata.js index b96c05eae761..8d34b341a088 100644 --- a/contribs/gmf/examples/contextualdata.js +++ b/contribs/gmf/examples/contextualdata.js @@ -22,7 +22,6 @@ import angular from 'angular'; import './contextualdata.css'; import gmfContextualdataModule from 'gmf/contextualdata/module'; - import gmfMapComponent from 'gmf/map/component'; import ngeoMiscFilters from 'ngeo/misc/filters'; import ngeoMapModule from 'ngeo/map/module'; @@ -45,12 +44,10 @@ const myModule = angular.module('gmfapp', [ ngeoMiscFilters.name, ngeoMapModule.name, ]); - myModule.value('gmfContextualdatacontentTemplateUrl', 'partials/contextualdata.html'); /** * @class - * @ngInject */ function MainController() { /** @@ -83,12 +80,9 @@ MainController.prototype.onRasterData = function (coordinate, data) { elelvation_diff: data.srtm - data.aster, }; }; - myModule.controller('MainController', MainController); myModule.constant('gmfContextualDataOptions', { projections: ['EPSG:2056', 'EPSG:21781', 'EPSG:4326'], }); - options(myModule); - export default MainController; diff --git a/contribs/gmf/examples/datepicker.js b/contribs/gmf/examples/datepicker.js index f8f2fc189140..ae7053fa9e6f 100644 --- a/contribs/gmf/examples/datepicker.js +++ b/contribs/gmf/examples/datepicker.js @@ -1,3 +1,4 @@ +MainController.$inject = ['ngeoWMSTime']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,7 +23,6 @@ import angular from 'angular'; import './datepicker.css'; import ngeoMiscDatepickerComponent from 'ngeo/misc/datepickerComponent'; - import ngeoMiscWMSTime from 'ngeo/misc/WMSTime'; import {TimePropertyWidgetEnum, TimePropertyResolutionEnum, TimePropertyModeEnum} from 'ngeo/datasource/OGC'; import options from './options'; @@ -40,7 +40,6 @@ const myModule = angular.module('gmfapp', [ /** * @class * @param {import('ngeo/misc/WMSTime').WMSTime} ngeoWMSTime wmstime service. - * @ngInject */ function MainController(ngeoWMSTime) { /** @@ -64,11 +63,11 @@ function MainController(ngeoWMSTime) { * @type {import('ngeo/datasource/OGC').TimeProperty} */ this.wmsTimeValueMode = { - widget: /** @type {TimePropertyWidgetEnum} */ ('datepicker'), + widget: /** @type {TimePropertyWidgetEnum} */ 'datepicker', maxValue: '2015-12-31T00:00:00Z', minValue: '2014-01-01T00:00:00Z', - resolution: /** @type {TimePropertyResolutionEnum}*/ ('month'), - mode: /** @type {TimePropertyModeEnum} */ ('value'), + resolution: /** @type {TimePropertyResolutionEnum}*/ 'month', + mode: /** @type {TimePropertyModeEnum} */ 'value', interval: [0, 1, 0, 0], }; @@ -98,8 +97,6 @@ function MainController(ngeoWMSTime) { this.rangeValue = this.ngeoWMSTime_.formatWMSTimeParam(this.wmsTimeRangeMode, date); }; } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/displayquerygrid.js b/contribs/gmf/examples/displayquerygrid.js index e619e4146d80..6c532112257a 100644 --- a/contribs/gmf/examples/displayquerygrid.js +++ b/contribs/gmf/examples/displayquerygrid.js @@ -1,3 +1,5 @@ +MainController.$inject = ['gmfThemes', 'gmfDataSourcesManager', 'gmfThemeManager', 'defaultTheme']; +QueryresultController.$inject = ['ngeoQueryResult']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -23,15 +25,10 @@ import angular from 'angular'; import './displayquerygrid.css'; import './gmf-hidden.inc.css'; import gmfDatasourceManager from 'gmf/datasource/Manager'; - import gmfLayertreeComponent from 'gmf/layertree/component'; - import gmfMapComponent from 'gmf/map/component'; - import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; - import gmfQueryGridComponent from 'gmf/query/gridComponent'; - import gmfThemeManager from 'gmf/theme/Manager'; import gmfThemeThemes from 'gmf/theme/Themes'; import ngeoGridModule from 'ngeo/grid/module'; @@ -58,7 +55,8 @@ const myModule = angular.module('gmfapp', [ gmfThemeManager.name, gmfThemeThemes.name, ngeoGridModule.name, - ngeoMapModule.name, // for ngeo.map.FeatureOverlay, perhaps remove me + ngeoMapModule.name, + // for ngeo.map.FeatureOverlay, perhaps remove me ngeoMiscBtnComponent.name, ngeoQueryComponent.name, ]); @@ -75,7 +73,6 @@ const queryresultComponent = { // @ts-ignore: webpack template: require('./partials/queryresult.html'), }; - myModule.component('gmfappQueryresult', queryresultComponent); /** @@ -83,7 +80,6 @@ myModule.component('gmfappQueryresult', queryresultComponent); * * @param {import('ngeo/query/MapQuerent').QueryResult} ngeoQueryResult Query service. * @class - * @ngInject */ function QueryresultController(ngeoQueryResult) { /** @@ -91,7 +87,6 @@ function QueryresultController(ngeoQueryResult) { */ this.result = ngeoQueryResult; } - myModule.controller('gmfappQueryresultController', QueryresultController); /** @@ -101,7 +96,6 @@ myModule.controller('gmfappQueryresultController', QueryresultController); * data sources manager service. * @param {import('gmf/theme/Manager').ThemeManagerService} gmfThemeManager gmf Theme Manager service. * @param {string} defaultTheme The default theme. - * @ngInject */ function MainController(gmfThemes, gmfDataSourcesManager, gmfThemeManager, defaultTheme) { gmfThemes.loadThemes(); @@ -148,7 +142,6 @@ function MainController(gmfThemes, gmfDataSourcesManager, gmfThemeManager, defau * @type {import('gmf/themes').GmfTheme} The selected theme. */ this.selectedTheme = null; - this.updateTheme = function () { gmfThemeManager.addTheme(this.selectedTheme); }; @@ -157,7 +150,6 @@ function MainController(gmfThemes, gmfDataSourcesManager, gmfThemeManager, defau * @type {boolean} */ this.queryGridActive = true; - gmfThemes.getThemesObject().then((themes) => { if (themes) { this.themes = themes; @@ -171,23 +163,29 @@ function MainController(gmfThemes, gmfDataSourcesManager, gmfThemeManager, defau }); } }); - ngeoMapFeatureOverlayMgr.init(this.map); } - myModule.controller('MainController', MainController); - myModule.constant('gmfDisplayQueryGridOptions', { featuresStyle: { - fill: {color: [255, 170, 0, 0.6]}, + fill: { + color: [255, 170, 0, 0.6], + }, circle: { - fill: {color: [255, 170, 0, 0.6]}, + fill: { + color: [255, 170, 0, 0.6], + }, radius: 5, - stroke: {color: [255, 170, 0, 1], width: 2}, + stroke: { + color: [255, 170, 0, 1], + width: 2, + }, + }, + stroke: { + color: [255, 170, 0, 1], + width: 2, }, - stroke: {color: [255, 170, 0, 1], width: 2}, }, }); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/displayquerywindow.js b/contribs/gmf/examples/displayquerywindow.js index 1397e0044c23..2f45c5618585 100644 --- a/contribs/gmf/examples/displayquerywindow.js +++ b/contribs/gmf/examples/displayquerywindow.js @@ -1,3 +1,5 @@ +MainController.$inject = ['gmfThemes', 'gmfDataSourcesManager', 'gmfThemeManager', 'defaultTheme']; +QueryresultController.$inject = ['ngeoQueryResult']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -23,15 +25,10 @@ import angular from 'angular'; import './displayquerywindow.css'; import './gmf-hidden.inc.css'; import gmfDatasourceManager from 'gmf/datasource/Manager'; - import gmfLayertreeComponent from 'gmf/layertree/component'; - import gmfMapComponent from 'gmf/map/component'; - import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; - import gmfQueryWindowComponent from 'gmf/query/windowComponent'; - import gmfThemeManager from 'gmf/theme/Manager'; import gmfThemeThemes from 'gmf/theme/Themes'; import ngeoMiscBtnComponent from 'ngeo/misc/btnComponent'; @@ -56,7 +53,8 @@ const myModule = angular.module('gmfapp', [ gmfQueryWindowComponent.name, gmfThemeManager.name, gmfThemeThemes.name, - ngeoMapModule.name, // for ngeo.map.FeatureOverlay, perhaps remove me + ngeoMapModule.name, + // for ngeo.map.FeatureOverlay, perhaps remove me ngeoMiscBtnComponent.name, ngeoQueryComponent.name, ]); @@ -73,7 +71,6 @@ const queryresultComponent = { // @ts-ignore: webpack template: require('./partials/queryresult.html'), }; - myModule.component('appQueryresult', queryresultComponent); /** @@ -81,7 +78,6 @@ myModule.component('appQueryresult', queryresultComponent); * * @param {import('ngeo/query/MapQuerent').QueryResult} ngeoQueryResult Query service. * @class - * @ngInject */ function QueryresultController(ngeoQueryResult) { /** @@ -89,7 +85,6 @@ function QueryresultController(ngeoQueryResult) { */ this.result = ngeoQueryResult; } - myModule.controller('AppQueryresultController', QueryresultController); /** @@ -99,7 +94,6 @@ myModule.controller('AppQueryresultController', QueryresultController); * data sources manager service. * @param {import('gmf/theme/Manager').ThemeManagerService} gmfThemeManager gmf Theme Manager service. * @param {string} defaultTheme The default theme. - * @ngInject */ function MainController(gmfThemes, gmfDataSourcesManager, gmfThemeManager, defaultTheme) { gmfThemes.loadThemes(); @@ -146,11 +140,9 @@ function MainController(gmfThemes, gmfDataSourcesManager, gmfThemeManager, defau * @type {import('gmf/themes').GmfTheme} The selected theme. */ this.selectedTheme = null; - this.updateTheme = function () { gmfThemeManager.addTheme(this.selectedTheme); }; - gmfThemes.getThemesObject().then((themes) => { if (themes) { this.themes = themes; @@ -164,23 +156,29 @@ function MainController(gmfThemes, gmfDataSourcesManager, gmfThemeManager, defau }); } }); - ngeoMapFeatureOverlayMgr.init(this.map); } - myModule.controller('MainController', MainController); - myModule.constant('gmfDisplayQueryWindowOptions', { featuresStyle: { - fill: {color: [255, 170, 0, 0.6]}, - stroke: {color: [255, 170, 0, 1], width: 2}, + fill: { + color: [255, 170, 0, 0.6], + }, + stroke: { + color: [255, 170, 0, 1], + width: 2, + }, circle: { radius: 5, - fill: {color: [255, 170, 0, 0.6]}, - stroke: {color: [255, 170, 0, 1], width: 2}, + fill: { + color: [255, 170, 0, 0.6], + }, + stroke: { + color: [255, 170, 0, 1], + width: 2, + }, }, }, }); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/drawfeature.js b/contribs/gmf/examples/drawfeature.js index 3dcf89913eda..b29075d0297b 100644 --- a/contribs/gmf/examples/drawfeature.js +++ b/contribs/gmf/examples/drawfeature.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$scope', 'ngeoFeatureHelper', 'ngeoFeatures', 'ngeoToolActivateMgr']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -24,7 +25,6 @@ import './drawfeature.css'; import 'bootstrap/js/src/tooltip'; import gmfMapComponent from 'gmf/map/component'; import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; - import gmfDrawingModule from 'gmf/drawing/module'; import ngeoFormatFeatureProperties from 'ngeo/format/FeatureProperties'; import ngeoMapModule from 'ngeo/map/module'; @@ -45,7 +45,8 @@ const myModule = angular.module('gmfapp', [ 'gettext', gmfDrawingModule.name, gmfMapComponent.name, - ngeoMapModule.name, // for ngeo.map.FeatureOverlay, perhaps remove me + ngeoMapModule.name, + // for ngeo.map.FeatureOverlay, perhaps remove me ngeoMiscFeatureHelper.name, ngeoMiscToolActivateMgr.name, ]); @@ -58,21 +59,17 @@ const myModule = angular.module('gmfapp', [ * @param {import('ngeo/misc/ToolActivateMgr').ToolActivateMgr} ngeoToolActivateMgr Ngeo ToolActivate * manager service. * @class - * @ngInject */ function MainController($scope, ngeoFeatureHelper, ngeoFeatures, ngeoToolActivateMgr) { /** * @type {angular.IScope} */ this.scope_ = $scope; - const view = new olView({ center: [0, 0], zoom: 3, }); - ngeoFeatureHelper.setProjection(view.getProjection()); - const featureOverlay = ngeoMapFeatureOverlayMgr.getFeatureOverlay(); featureOverlay.setFeatures(ngeoFeatures); @@ -92,7 +89,6 @@ function MainController($scope, ngeoFeatureHelper, ngeoFeatures, ngeoToolActivat * @type {boolean} */ this.drawFeatureActive = true; - const drawFeatureToolActivate = new ngeoMiscToolActivate(this, 'drawFeatureActive'); ngeoToolActivateMgr.registerTool('mapTools', drawFeatureToolActivate, true); @@ -100,34 +96,30 @@ function MainController($scope, ngeoFeatureHelper, ngeoFeatures, ngeoToolActivat * @type {boolean} */ this.pointerMoveActive = false; - const pointerMoveToolActivate = new ngeoMiscToolActivate(this, 'pointerMoveActive'); ngeoToolActivateMgr.registerTool('mapTools', pointerMoveToolActivate, false); - $scope.$watch( () => this.pointerMoveActive, (newVal) => { if (newVal) { this.map.on( - /** @type {import('ol/Observable').EventTypes} */ ('pointermove'), - /** @type {function(?): ?} */ ( - /** - * @param {import('ol/MapBrowserEvent').default} evt - */ (evt) => { - this.handleMapPointerMove_(evt); - } - ), + /** @type {import('ol/Observable').EventTypes} */ 'pointermove', + /** @type {function(?): ?} */ + /** + * @param {import('ol/MapBrowserEvent').default} evt + */ (evt) => { + this.handleMapPointerMove_(evt); + }, ); } else { this.map.un( - /** @type {import('ol/Observable').EventTypes} */ ('pointermove'), - /** @type {function(?): ?} */ ( - /** - * @param {import('ol/MapBrowserEvent').default} evt - */ (evt) => { - this.handleMapPointerMove_(evt); - } - ), + /** @type {import('ol/Observable').EventTypes} */ 'pointermove', + /** @type {function(?): ?} */ + /** + * @param {import('ol/MapBrowserEvent').default} evt + */ (evt) => { + this.handleMapPointerMove_(evt); + }, ); $('#pointermove-feature').html(''); } @@ -146,15 +138,10 @@ function MainController($scope, ngeoFeatureHelper, ngeoFeatures, ngeoToolActivat */ MainController.prototype.handleMapPointerMove_ = function (evt) { const pixel = evt.pixel; - const feature = this.map.forEachFeatureAtPixel(pixel, (feature) => feature); - $('#pointermove-feature').html(feature ? feature.get(ngeoFormatFeatureProperties.NAME) : 'None'); - this.scope_.$apply(); }; - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/elevation.js b/contribs/gmf/examples/elevation.js index f4ebb004c07b..3f34bb9e2ef4 100644 --- a/contribs/gmf/examples/elevation.js +++ b/contribs/gmf/examples/elevation.js @@ -22,7 +22,6 @@ import angular from 'angular'; import './elevation.css'; import gmfMapComponent from 'gmf/map/component'; - import gmfRasterModule from 'gmf/raster/module'; import EPSG2056 from 'ngeo/proj/EPSG_2056'; import ngeoMapModule from 'ngeo/map/module'; @@ -45,7 +44,6 @@ const myModule = angular.module('gmfapp', [ /** * @class - * @ngInject */ function MainController() { /** @@ -65,12 +63,9 @@ function MainController() { }), }); } - myModule.controller('MainController', MainController); - myModule.constant('gmfElevationOptions', { layers: ['aster', 'srtm'], }); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/featurestyle.js b/contribs/gmf/examples/featurestyle.js index fe41dc52300b..31e84163cf7c 100644 --- a/contribs/gmf/examples/featurestyle.js +++ b/contribs/gmf/examples/featurestyle.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$scope', 'ngeoFeatureHelper']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,9 +23,7 @@ import angular from 'angular'; import './featurestyle.css'; import gmfDrawingFeatureStyleComponent from 'gmf/drawing/featureStyleComponent'; - import gmfMapComponent from 'gmf/map/component'; - import ngeoFormatFeatureProperties from 'ngeo/format/FeatureProperties'; import ngeoMiscFeatureHelper from 'ngeo/misc/FeatureHelper'; import ngeoMapModule from 'ngeo/map/module'; @@ -60,7 +59,6 @@ const myModule = angular.module('gmfapp', [ * @class * @param {angular.IScope} $scope Angular scope. * @param {import('ngeo/misc/FeatureHelper').FeatureHelper} ngeoFeatureHelper Gmf feature helper service. - * @ngInject */ function MainController($scope, ngeoFeatureHelper) { /** @@ -169,12 +167,10 @@ function MainController($scope, ngeoFeatureHelper) { circleProperties[ngeoFormatFeatureProperties.OPACITY] = '0.5'; circleProperties[ngeoFormatFeatureProperties.STROKE] = '2'; features.push(new olFeature(circleProperties)); - const view = new olView({ center: [-8174482, 6288627], zoom: 6, }); - ngeoFeatureHelper.setProjection(view.getProjection()); // set style @@ -216,14 +212,12 @@ function MainController($scope, ngeoFeatureHelper) { */ MainController.prototype.handleMapSingleClick_ = function (evt) { const pixel = evt.pixel; - - const feature = /** @type {olFeature} */ ( - this.map.forEachFeatureAtPixel(pixel, (feature) => feature) - ); + const feature = + /** @type {olFeature} */ + this.map.forEachFeatureAtPixel(pixel, (feature) => feature); if (this.selectedFeature) { this.featureHelper_.setStyle(this.selectedFeature); } - if (feature) { if (this.selectedFeature !== feature) { this.selectedFeature = feature; @@ -232,11 +226,8 @@ MainController.prototype.handleMapSingleClick_ = function (evt) { } else { this.selectedFeature = null; } - this.scope_.$apply(); }; - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/importdatasource.js b/contribs/gmf/examples/importdatasource.js index 27345f47107b..32aa52d6a695 100644 --- a/contribs/gmf/examples/importdatasource.js +++ b/contribs/gmf/examples/importdatasource.js @@ -24,19 +24,14 @@ import angular from 'angular'; import './importdatasource.css'; import 'bootstrap/js/src/tooltip'; import gmfDatasourceManager from 'gmf/datasource/Manager'; - import gmfImportImportdatasourceComponent from 'gmf/import/importdatasourceComponent'; import gmfLayertreeComponent from 'gmf/layertree/component'; import gmfLayertreeTreeManager from 'gmf/layertree/TreeManager'; - import gmfMapComponent from 'gmf/map/component'; - import gmfThemeThemes from 'gmf/theme/Themes'; import ngeoDatasourceDataSources from 'ngeo/datasource/DataSources'; - import ngeoQueryComponent from 'ngeo/query/component'; import ngeoMapModule from 'ngeo/map/module'; - import EPSG2056 from 'ngeo/proj/EPSG_2056'; import olMap from 'ol/Map'; import olView from 'ol/View'; @@ -73,7 +68,6 @@ class MainController { * @param {import('gmf/layertree/TreeManager').LayertreeTreeManager} gmfTreeManager gmf Tree Manager * service. * @param {import('ngeo/datasource/DataSources').DataSource} ngeoDataSources Ngeo data sources service. - * @ngInject */ constructor($scope, gmfDataSourcesManager, gmfThemes, gmfTreeManager, ngeoDataSources) { /** @@ -81,7 +75,6 @@ class MainController { * @private */ this.scope_ = $scope; - gmfThemes.loadThemes(); /** @@ -108,7 +101,6 @@ class MainController { // Init the datasources with our map. gmfDataSourcesManager.setDatasourceMap(this.map); - gmfThemes.getThemesObject().then((themes) => { if (themes) { // Set 'Filters' theme, i.e. the one with id 175 @@ -133,10 +125,14 @@ class MainController { }); } } - +MainController.$inject = [ + '$scope', + 'gmfDataSourcesManager', + 'gmfThemes', + 'gmfTreeManager', + 'ngeoDataSources', +]; myModule.controller('MainController', MainController); - myModule.constant('defaultTheme', 'Filters'); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/layertree.js b/contribs/gmf/examples/layertree.js index 008006934165..f205ad1dc6a5 100644 --- a/contribs/gmf/examples/layertree.js +++ b/contribs/gmf/examples/layertree.js @@ -1,3 +1,4 @@ +MainController.$inject = ['gmfTreeManager', 'gmfThemes', 'gmfThemeManager', 'ngeoLocation']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,12 +23,9 @@ import angular from 'angular'; import './layertree.css'; import gmfDisclaimerModule from 'gmf/disclaimer/module'; - import gmfLayertreeComponent from 'gmf/layertree/component'; import gmfLayertreeTreeManager from 'gmf/layertree/TreeManager'; - import gmfMapComponent from 'gmf/map/component'; - import gmfThemeManager from 'gmf/theme/Manager'; import gmfThemeThemes from 'gmf/theme/Themes'; import EPSG2056 from 'ngeo/proj/EPSG_2056'; @@ -64,7 +62,6 @@ const myModule = angular.module('gmfapp', [ * @param {import('gmf/theme/Themes').ThemesService} gmfThemes The gmf themes service. * @param {import('gmf/theme/Manager').ThemeManagerService} gmfThemeManager gmf Theme Manager service. * @param {import('ngeo/statemanager/Location').StatemanagerLocation} ngeoLocation ngeo location service. - * @ngInject */ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation) { gmfThemes.loadThemes(); @@ -163,7 +160,6 @@ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation } return this.gmfTreeManager.root.children; }; - gmfThemes.getThemesObject().then((themes) => { if (themes) { this.themes = themes; @@ -178,10 +174,10 @@ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation }); }); flatNodes.forEach((node) => { - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (node); + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ node; // Get an array of all layers if (groupNode.children === undefined) { - this.layers.push(/** @type {import('gmf/themes').GmfLayer} */ (node)); + this.layers.push(/** @type {import('gmf/themes').GmfLayer} */ node); } }); } @@ -197,7 +193,7 @@ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation */ this.getDistinctFlatNodes_ = function (node, nodes) { let i; - const children = /** @type {import('gmf/themes').GmfGroup} */ (node).children; + const children = /** @type {import('gmf/themes').GmfGroup} */ node.children; if (children !== undefined) { for (i = 0; i < children.length; i++) { this.getDistinctFlatNodes_(children[i], nodes); @@ -216,8 +212,6 @@ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation } }; } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/layertreeadd.js b/contribs/gmf/examples/layertreeadd.js index 4880e106f773..bb672ebdd7ec 100644 --- a/contribs/gmf/examples/layertreeadd.js +++ b/contribs/gmf/examples/layertreeadd.js @@ -1,3 +1,4 @@ +MainController.$inject = ['gmfTreeManager', 'gmfThemes', 'gmfThemeManager', 'ngeoLocation']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,14 +23,10 @@ import angular from 'angular'; import './layertreeadd.css'; import gmfDisclaimerModule from 'gmf/disclaimer/module'; - import gmfLayertreeComponent from 'gmf/layertree/component'; import gmfLayertreeTreeManager from 'gmf/layertree/TreeManager'; - import gmfMapComponent from 'gmf/map/component'; - import gmfThemeThemes from 'gmf/theme/Themes'; - import gmfThemeManager from 'gmf/theme/Manager'; import EPSG2056 from 'ngeo/proj/EPSG_2056'; import ngeoStatemanagerLocation from 'ngeo/statemanager/Location'; @@ -63,7 +60,6 @@ const myModule = angular.module('gmfapp', [ * @param {import('gmf/theme/Themes').ThemesService} gmfThemes The gmf themes service. * @param {import('gmf/theme/Manager').ThemeManagerService} gmfThemeManager gmf Tree Manager service. * @param {import('ngeo/statemanager/Location').StatemanagerLocation} ngeoLocation ngeo location service. - * @ngInject */ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation) { gmfThemes.loadThemes(); @@ -162,7 +158,6 @@ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation } return this.gmfTreeManager.root.children; }; - gmfThemes.getThemesObject().then((themes) => { if (themes) { this.themes = themes; @@ -177,10 +172,10 @@ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation }); }); flatNodes.forEach((node) => { - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (node); + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ node; // Get an array of all layers if (groupNode.children === undefined) { - this.layers.push(/** @type {import('gmf/themes').GmfLayer} */ (node)); + this.layers.push(/** @type {import('gmf/themes').GmfLayer} */ node); } }); } @@ -196,7 +191,7 @@ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation */ this.getDistinctFlatNodes_ = function (node, nodes) { let i; - const children = /** @type {import('gmf/themes').GmfGroup} */ (node).children; + const children = /** @type {import('gmf/themes').GmfGroup} */ node.children; if (children !== undefined) { for (i = 0; i < children.length; i++) { this.getDistinctFlatNodes_(children[i], nodes); @@ -214,8 +209,6 @@ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation } }; } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/mobilemeasure.js b/contribs/gmf/examples/mobilemeasure.js index 893b2ad78753..2401a9df9fc6 100644 --- a/contribs/gmf/examples/mobilemeasure.js +++ b/contribs/gmf/examples/mobilemeasure.js @@ -1,3 +1,4 @@ +MainController.$inject = ['gmfPermalink']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,9 +23,7 @@ import angular from 'angular'; import './mobilemeasure.css'; import gmfMapComponent from 'gmf/map/component'; - import gmfPermalinkPermalink from 'gmf/permalink/Permalink'; - import gmfMobileMeasureAreaComponent from 'gmf/mobile/measure/areaComponent'; import gmfMobileMeasureLengthComponent from 'gmf/mobile/measure/lengthComponent'; import gmfMobileMeasurePointComponent from 'gmf/mobile/measure/pointComponent'; @@ -56,7 +55,6 @@ const myModule = angular.module('gmfapp', [ /** * @param {import('gmf/permalink/Permalink').PermalinkService} gmfPermalink The gmf permalink service. * @class - * @ngInject */ function MainController(gmfPermalink) { const center = gmfPermalink.getMapCenter() || [537635, 152640]; @@ -78,7 +76,6 @@ function MainController(gmfPermalink) { zoom: zoom, }), }); - this.map.addControl( new olControlScaleLine({ // See: https://www.w3.org/TR/CSS21/syndata.html#length-units @@ -101,9 +98,7 @@ function MainController(gmfPermalink) { */ this.measurePointActive = false; } - myModule.controller('MainController', MainController); - const sketchStyle = { fill: { color: 'rgba(255, 255, 255, 0.2)', @@ -129,8 +124,15 @@ myModule.constant('gmfMobileMeasurePointOptions', { decimals: 2, format: '{x}, {y}', rasterLayers: [ - {name: 'aster', unit: 'm', decimals: 2}, - {name: 'srtm', unit: 'm'}, + { + name: 'aster', + unit: 'm', + decimals: 2, + }, + { + name: 'srtm', + unit: 'm', + }, ], }); myModule.constant('gmfMobileMeasureLengthOptions', { @@ -140,5 +142,4 @@ myModule.constant('gmfMobileMeasureAreaOptions', { sketchStyle: sketchStyle, }); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/mouseposition.js b/contribs/gmf/examples/mouseposition.js index 3dacc87935fa..393f1f645d94 100644 --- a/contribs/gmf/examples/mouseposition.js +++ b/contribs/gmf/examples/mouseposition.js @@ -23,7 +23,6 @@ import './mouseposition.css'; import angular from 'angular'; import gmfMapModule from 'gmf/map/module'; import gmfMapComponent from 'gmf/map/component'; - import EPSG2056 from 'ngeo/proj/EPSG_2056'; import EPSG21781 from 'ngeo/proj/EPSG_21781'; import olMap from 'ol/Map'; @@ -40,7 +39,6 @@ const myModule = angular.module('gmfapp', ['gettext', gmfMapModule.name, gmfMapC /** * @class - * @ngInject */ function MainController() { /** @@ -58,9 +56,7 @@ function MainController() { }), }); } - myModule.controller('MainController', MainController); - myModule.constant('gmfMousePositionOptions', { projections: [ { @@ -81,5 +77,4 @@ myModule.constant('gmfMousePositionOptions', { ], }); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/objectediting.js b/contribs/gmf/examples/objectediting.js index 18a7e4197b30..48cd79ebfa57 100644 --- a/contribs/gmf/examples/objectediting.js +++ b/contribs/gmf/examples/objectediting.js @@ -1,3 +1,4 @@ +MainController.$inject = ['gmfObjectEditingManager', 'gmfThemes', 'gmfTreeManager', 'ngeoToolActivateMgr']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,13 +23,9 @@ import angular from 'angular'; import './objectediting.css'; import gmfLayertreeComponent from 'gmf/layertree/component'; - import gmfLayertreeTreeManager from 'gmf/layertree/TreeManager'; - import gmfMapComponent from 'gmf/map/component'; - import gmfObjecteditingComponent from 'gmf/objectediting/component'; - import gmfObjecteditingManager from 'gmf/objectediting/Manager'; import gmfThemeThemes from 'gmf/theme/Themes'; import ngeoMiscToolActivate from 'ngeo/misc/ToolActivate'; @@ -70,16 +67,13 @@ const myModule = angular.module('gmfapp', [ * @param {import('ngeo/misc/ToolActivateMgr').ToolActivateMgr} ngeoToolActivateMgr Ngeo ToolActivate * manager service. * @class - * @ngInject */ function MainController(gmfObjectEditingManager, gmfThemes, gmfTreeManager, ngeoToolActivateMgr) { /** * @type {import('gmf/layertree/TreeManager').LayertreeTreeManager} */ this.gmfTreeManager_ = gmfTreeManager; - gmfThemes.loadThemes(); - const projection = olProj.get(EPSG2056); projection.setExtent([485869.5728, 76443.1884, 837076.5648, 299941.7864]); @@ -128,7 +122,6 @@ function MainController(gmfObjectEditingManager, gmfThemes, gmfTreeManager, ngeo zoom: 2, }), }); - gmfThemes.getThemesObject().then((themes) => { if (themes) { // Add layer vector after @@ -151,7 +144,6 @@ function MainController(gmfObjectEditingManager, gmfThemes, gmfTreeManager, ngeo * @type {boolean} */ this.objectEditingActive = true; - const objectEditingToolActivate = new ngeoMiscToolActivate(this, 'objectEditingActive'); ngeoToolActivateMgr.registerTool('mapTools', objectEditingToolActivate, true); @@ -159,7 +151,6 @@ function MainController(gmfObjectEditingManager, gmfThemes, gmfTreeManager, ngeo * @type {boolean} */ this.dummyActive = false; - const dummyToolActivate = new ngeoMiscToolActivate(this, 'dummyActive'); ngeoToolActivateMgr.registerTool('mapTools', dummyToolActivate, false); @@ -167,7 +158,6 @@ function MainController(gmfObjectEditingManager, gmfThemes, gmfTreeManager, ngeo * @type {?import('ol/Feature').default} */ this.objectEditingFeature = null; - gmfObjectEditingManager.getFeature().then((feature) => { this.objectEditingFeature = feature; if (feature) { @@ -175,10 +165,7 @@ function MainController(gmfObjectEditingManager, gmfThemes, gmfTreeManager, ngeo } }); } - myModule.controller('MainController', MainController); - myModule.constant('defaultTheme', 'ObjectEditing'); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/objecteditinghub.js b/contribs/gmf/examples/objecteditinghub.js index bc1b548dcf6b..88164a0ac4ae 100644 --- a/contribs/gmf/examples/objecteditinghub.js +++ b/contribs/gmf/examples/objecteditinghub.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$http', '$q', '$scope', 'gmfThemes', 'gmfXSDAttributes']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -21,7 +22,6 @@ import angular from 'angular'; import './objecteditinghub.css'; - import gmfEditingXSDAttributes from 'gmf/editing/XSDAttributes'; import gmfObjecteditingManager, {ObjecteditingParam} from 'gmf/objectediting/Manager'; import gmfThemeThemes from 'gmf/theme/Themes'; @@ -48,7 +48,6 @@ const myModule = angular.module('gmfapp', [ * @param {import('gmf/editing/XSDAttributes').EditingXSDAttributeService} gmfXSDAttributes * The gmf XSDAttributes service. * @class - * @ngInject */ function MainController($http, $q, $scope, gmfThemes, gmfXSDAttributes) { /** @@ -139,12 +138,10 @@ function MainController($http, $q, $scope, gmfThemes, gmfXSDAttributes) { * @type {string|undefined} */ this.selectedGeomType = undefined; - $scope.$watch( () => this.selectedGmfLayerNode, (newVal, oldVal) => { this.selectedFeature = null; - if (newVal) { this.getFeatures_(newVal).then(this.handleGetFeatures_.bind(this, newVal)); this.getGeometryType_(newVal).then(this.handleGetGeometryType_.bind(this, newVal)); @@ -156,18 +153,14 @@ function MainController($http, $q, $scope, gmfThemes, gmfXSDAttributes) { * @type {string} */ this.themeName = 'ObjectEditing'; - this.gmfThemes_.loadThemes(); - this.gmfThemes_.getOgcServersObject().then((ogcServers) => { // (1) Set OGC servers this.gmfServers_ = ogcServers; - this.gmfThemes_.getThemesObject().then((themes) => { if (!themes) { return; } - let i, ii; // (2) Find OE theme @@ -179,7 +172,6 @@ function MainController($http, $q, $scope, gmfThemes, gmfXSDAttributes) { break; } } - if (!theme) { return; } @@ -206,7 +198,7 @@ function MainController($http, $q, $scope, gmfThemes, gmfXSDAttributes) { for (i = 0, ii = groupNode.children.length; i < ii; i++) { if (groupNode.children[i].metadata.identifierAttributeField) { gmfLayerNodes.push( - /** @type {import('gmf/themes').GmfLayerWMS} */ (/** @type {any} */ (groupNode.children[i])), + /** @type {import('gmf/themes').GmfLayerWMS} */ /** @type {any} */ groupNode.children[i], ); } } @@ -229,7 +221,6 @@ MainController.prototype.runEditor = function () { if (!this.selectedFeature) { throw new Error('Missing selectedFeature'); } - const geomType = this.selectedGeomType; const feature = this.selectedFeature; const layer = this.selectedGmfLayerNode.id; @@ -246,7 +237,6 @@ MainController.prototype.runEditor = function () { params[ObjecteditingParam.LAYER] = layer; params[ObjecteditingParam.THEME] = this.themeName; params[ObjecteditingParam.PROPERTY] = property; - const url = MainController.appendParams(this.selectedUrl.url, params); window.open(url); }; @@ -257,15 +247,12 @@ MainController.prototype.runEditor = function () { */ MainController.prototype.getFeatures_ = function (gmfLayerNode) { this.getFeaturesDeferred_ = this.q_.defer(); - const features = this.getFeaturesFromCache_(gmfLayerNode); - if (features) { this.getFeaturesDeferred_.resolve(); } else { this.issueGetFeatures_(gmfLayerNode); } - return this.getFeaturesDeferred_.promise; }; @@ -276,23 +263,20 @@ MainController.prototype.issueGetFeatures_ = function (gmfLayerNode) { if (!this.gmfServer_) { throw new Error('Missing gmfServer'); } - const id = gmfLayerNode.id; - const url = MainController.appendParams(this.gmfServer_.urlWfs, { 'SERVICE': 'WFS', 'REQUEST': 'GetFeature', 'VERSION': '1.1.0', 'TYPENAME': gmfLayerNode.layers, }); - this.http_.get(url).then((response) => { if (!this.getFeaturesDeferred_) { throw new Error('Missing getFeaturesDeferred'); } - const features = /** @type {import('ol/Feature').default[]} */ ( - new olFormatWFS().readFeatures(response.data) - ); + const features = + /** @type {import('ol/Feature').default[]} */ + new olFormatWFS().readFeatures(response.data); this.featuresCache_[id] = features; this.getFeaturesDeferred_.resolve(); }); @@ -302,9 +286,9 @@ MainController.prototype.issueGetFeatures_ = function (gmfLayerNode) { * @param {import('gmf/themes').GmfLayerWMS} gmfLayerNode Layer node. */ MainController.prototype.handleGetFeatures_ = function (gmfLayerNode) { - this.features = /** @type {import('ol/Feature').default[]} */ ( - this.getFeaturesFromCache_(gmfLayerNode) - ); + this.features = + /** @type {import('ol/Feature').default[]} */ + this.getFeaturesFromCache_(gmfLayerNode); this.selectedFeature = this.features[0]; }; @@ -324,15 +308,12 @@ MainController.prototype.getFeaturesFromCache_ = function (gmfLayerNode) { */ MainController.prototype.getGeometryType_ = function (gmfLayerNode) { this.getGeometryTypeDeferred_ = this.q_.defer(); - const geomType = this.getGeometryTypeFromCache_(gmfLayerNode); - if (geomType) { this.getGeometryTypeDeferred_.resolve(); } else { this.issueGetAttributesRequest_(gmfLayerNode); } - return this.getGeometryTypeDeferred_.promise; }; @@ -402,8 +383,6 @@ MainController.appendParams = function (uri, params) { uri = uri.includes('?') ? `${uri}&` : `${uri}?`; return uri + qs; }; - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/permalink.js b/contribs/gmf/examples/permalink.js index d06670ad8a8d..562649f366c7 100644 --- a/contribs/gmf/examples/permalink.js +++ b/contribs/gmf/examples/permalink.js @@ -23,7 +23,6 @@ import './permalink.css'; import angular from 'angular'; import gmfMapModule from 'gmf/map/module'; import gmfMapComponent from 'gmf/map/component'; - import EPSG2056 from 'ngeo/proj/EPSG_2056'; import olMap from 'ol/Map'; import olView from 'ol/View'; @@ -39,7 +38,6 @@ const myModule = angular.module('gmfapp', ['gettext', gmfMapModule.name, gmfMapC /** * @class - * @ngInject */ function MainController() { /** @@ -59,8 +57,6 @@ function MainController() { }), }); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/print.js b/contribs/gmf/examples/print.js index 97d753de71f1..4de443ae0883 100644 --- a/contribs/gmf/examples/print.js +++ b/contribs/gmf/examples/print.js @@ -1,3 +1,4 @@ +MainController.$inject = ['gmfThemes']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -23,13 +24,9 @@ import angular from 'angular'; import './print.css'; import './gmf-hidden.inc.css'; import gmfLayertreeComponent from 'gmf/layertree/component'; - import gmfMapComponent from 'gmf/map/component'; - import gmfPrintComponent from 'gmf/print/component'; - import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; - import gmfThemeThemes from 'gmf/theme/Themes'; import ngeoMapModule from 'ngeo/map/module'; import EPSG2056 from 'ngeo/proj/EPSG_2056'; @@ -55,7 +52,6 @@ const myModule = angular.module('gmfapp', [ /** * @class * @param {import('gmf/theme/Themes').ThemesService} gmfThemes The gmf themes service. - * @ngInject */ function MainController(gmfThemes) { gmfThemes.loadThemes(); @@ -86,19 +82,15 @@ function MainController(gmfThemes) { * @type {import('gmf/themes').GmfTheme|undefined} */ this.treeSource = undefined; - gmfThemes.getThemesObject().then((themes) => { if (themes) { this.themes = themes; this.treeSource = themes[3]; } }); - ngeoMapFeatureOverlayMgr.init(this.map); } - myModule.controller('MainController', MainController); - myModule.constant('gmfPrintOptions', { fieldsValues: { comments: 'Default comments example', @@ -106,5 +98,4 @@ myModule.constant('gmfPrintOptions', { }, }); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/profile.js b/contribs/gmf/examples/profile.js index a7d2fa1e6630..f64e86510739 100644 --- a/contribs/gmf/examples/profile.js +++ b/contribs/gmf/examples/profile.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$scope']; // The MIT License (MIT) // // Copyright (c) 2014-2024 Camptocamp SA @@ -22,11 +23,8 @@ import angular from 'angular'; import './profile.css'; import gmfPermalinkPermalink from 'gmf/permalink/Permalink'; - import gmfMapComponent from 'gmf/map/component'; - import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; - import gmfProfileModule from 'gmf/profile/module'; import ngeoMapModule from 'ngeo/map/module'; import EPSG2056 from 'ngeo/proj/EPSG_2056'; @@ -55,7 +53,6 @@ const myModule = angular.module('gmfapp', [ /** * @param {angular.IScope} $scope Angular scope. * @class - * @ngInject */ function MainController($scope) { /** @@ -79,7 +76,6 @@ function MainController($scope) { zoom: 3, }), }); - const lineStyle = new olStyleStyle({ stroke: new olStyleStroke({ color: '#ffcc33', @@ -91,7 +87,6 @@ function MainController($scope) { * @type {import('ol/Collection').default>} */ const features = new olCollection(); - const overlay = ngeoMapFeatureOverlayMgr.getFeatureOverlay(); overlay.setFeatures(features); overlay.setStyle(lineStyle); @@ -108,7 +103,6 @@ function MainController($scope) { type: 'LineString', features: features, }); - this.drawLine.setActive(false); this.map.addInteraction(this.drawLine); @@ -123,33 +117,27 @@ function MainController($scope) { this.drawLine.setActive(true); } }; - this.clear_ = function () { features.clear(); // For the draw overlay. this.profileLine = null; // To reset the profile. }; - - this.drawLine.on(/** @type {import('ol/Observable').EventTypes} */ ('drawstart'), () => { + this.drawLine.on(/** @type {import('ol/Observable').EventTypes} */ 'drawstart', () => { this.clear_(); }); - this.drawLine.on( - /** @type {import('ol/Observable').EventTypes} */ ('drawend'), - /** @type {function(?): ?} */ ( - /** - * @param {import('lib/ol.interaction.Draw').DrawEvent} e - */ - (e) => { - // Update the profile with the new geometry - this.profileLine = /** @type {?import('ol/geom/LineString').default} */ (e.feature.getGeometry()); - $scope.$digest(); - } - ), + /** @type {import('ol/Observable').EventTypes} */ 'drawend', + /** @type {function(?): ?} */ + /** + * @param {import('lib/ol.interaction.Draw').DrawEvent} e + */ + (e) => { + // Update the profile with the new geometry + this.profileLine = /** @type {?import('ol/geom/LineString').default} */ e.feature.getGeometry(); + $scope.$digest(); + }, ); } - myModule.controller('MainController', MainController); - myModule.constant('ngeoProfileOptions', { styleDefs: 'svg {background-color: #D3E5D7};', linesConfiguration: { @@ -162,5 +150,4 @@ myModule.constant('ngeoProfileOptions', { }, }); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/search.js b/contribs/gmf/examples/search.js index 7e4fce820487..bac3ce435878 100644 --- a/contribs/gmf/examples/search.js +++ b/contribs/gmf/examples/search.js @@ -1,3 +1,4 @@ +MainController.$inject = ['gmfThemes']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -22,9 +23,7 @@ import angular from 'angular'; import './search.css'; import gmfMapComponent from 'gmf/map/component'; - import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; - import gmfSearchModule from 'gmf/search/module'; import gmfThemeThemes from 'gmf/theme/Themes'; import ngeoMessageNotification from 'ngeo/message/Notification'; @@ -52,11 +51,9 @@ const myModule = angular.module('gmfapp', [ /** * @param {import('gmf/theme/Themes').ThemesService} gmfThemes Themes service. * @class - * @ngInject */ function MainController(gmfThemes) { gmfThemes.loadThemes(); - ngeoMapFeatureOverlayMgr.init(this.map); /** @@ -97,9 +94,7 @@ function MainController(gmfThemes) { }); }; } - myModule.controller('MainController', MainController); - myModule.constant('gmfSearchGroups', []); myModule.constant('gmfSearchOptions', { colorChooser: true, @@ -107,13 +102,23 @@ myModule.constant('gmfSearchOptions', { placeholder: 'Search for « Laus » for example…', styles: { osm: { - fill: {color: [255, 255, 255, 0.6]}, + fill: { + color: [255, 255, 255, 0.6], + }, circle: { - fill: {color: [255, 255, 255, 0.6]}, + fill: { + color: [255, 255, 255, 0.6], + }, radius: 5, - stroke: {color: [255, 0, 0, 1], width: 2}, + stroke: { + color: [255, 0, 0, 1], + width: 2, + }, + }, + stroke: { + color: [255, 0, 0, 1], + width: 2, }, - stroke: {color: [255, 0, 0, 1], width: 2}, }, }, datasources: [ @@ -123,15 +128,14 @@ myModule.constant('gmfSearchOptions', { groupActions: [], labelKey: 'label', projection: EPSG2056, - bloodhoundOptions: /** @type {Bloodhound.BloodhoundOptions} */ ({ + bloodhoundOptions: /** @type {Bloodhound.BloodhoundOptions} */ { remote: { rateLimitWait: 250, }, - }), + }, url: SEARCH, }, ], }); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/share.js b/contribs/gmf/examples/share.js index fb01a34a78e9..9f158790f398 100644 --- a/contribs/gmf/examples/share.js +++ b/contribs/gmf/examples/share.js @@ -22,7 +22,6 @@ import angular from 'angular'; import './share.css'; import gmfPermalinkShareComponent from 'gmf/permalink/shareComponent'; - import ngeoMessageModalComponent from 'ngeo/message/modalComponent'; import options from './options'; @@ -38,7 +37,6 @@ const myModule = angular.module('gmfapp', [ /** * @class - * @ngInject */ function MainController() { /** @@ -55,8 +53,6 @@ function MainController() { */ this.modalShareShown = false; } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/simple.js b/contribs/gmf/examples/simple.js index 3d46af3bde91..abd8600799be 100644 --- a/contribs/gmf/examples/simple.js +++ b/contribs/gmf/examples/simple.js @@ -23,7 +23,6 @@ import './simple.css'; import angular from 'angular'; import gmfMapComponent from 'gmf/map/component'; import ngeoMapModule from 'ngeo/map/module'; - import olMap from 'ol/Map'; import olView from 'ol/View'; import olLayerTile from 'ol/layer/WebGLTile'; @@ -38,7 +37,6 @@ const myModule = angular.module('gmfapp', ['gettext', gmfMapComponent.name, ngeo /** * @class - * @ngInject */ function MainController() { /** @@ -56,8 +54,6 @@ function MainController() { }), }); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/themeselector.js b/contribs/gmf/examples/themeselector.js index 716463092c83..43da56513dff 100644 --- a/contribs/gmf/examples/themeselector.js +++ b/contribs/gmf/examples/themeselector.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$http', 'gmfThemes', 'gmfThemeManager']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,7 +23,6 @@ import angular from 'angular'; import './themeselector.css'; import gmfThemeModule from 'gmf/theme/module'; - import gmfLayertreeTreeManager from 'gmf/layertree/TreeManager'; import options from './options'; @@ -34,7 +34,6 @@ const myModule = angular.module('gmfapp', ['gettext', gmfLayertreeTreeManager.na * @param {angular.IHttpService} $http Angular's $http service. * @param {import('gmf/theme/Themes').ThemesService} gmfThemes Themes service. * @param {import('gmf/theme/Manager').ThemeManagerService} gmfThemeManager gmf Tree Manager service. - * @ngInject */ function MainController($http, gmfThemes, gmfThemeManager) { /** @@ -49,11 +48,8 @@ function MainController($http, gmfThemes, gmfThemeManager) { * @type {import('gmf/theme/Manager').ThemeManagerService} */ this.manager = gmfThemeManager; - gmfThemes.loadThemes(); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/timeslider.js b/contribs/gmf/examples/timeslider.js index a2b4f204a5a6..ab1edf7633d5 100644 --- a/contribs/gmf/examples/timeslider.js +++ b/contribs/gmf/examples/timeslider.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$scope', 'ngeoWMSTime']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,7 +23,6 @@ import './timeslider.css'; import angular from 'angular'; import gmfLayertreeTimeSliderComponent from 'gmf/layertree/timeSliderComponent'; - import ngeoMiscWMSTime from 'ngeo/misc/WMSTime'; import {TimePropertyWidgetEnum, TimePropertyResolutionEnum, TimePropertyModeEnum} from 'ngeo/datasource/OGC'; import options from './options'; @@ -38,7 +38,6 @@ const myModule = angular.module('gmfapp', [ * @class * @param {angular.IScope} $scope Angular scope. * @param {import('ngeo/misc/WMSTime').WMSTime} ngeoWMSTime wmstime service. - * @ngInject */ function MainController($scope, ngeoWMSTime) { /** @@ -98,8 +97,6 @@ function MainController($scope, ngeoWMSTime) { $scope.$digest(); }; } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/wfspermalink.js b/contribs/gmf/examples/wfspermalink.js index 87007b7f6523..61a3b72a7854 100644 --- a/contribs/gmf/examples/wfspermalink.js +++ b/contribs/gmf/examples/wfspermalink.js @@ -23,10 +23,8 @@ import angular from 'angular'; import './wfspermalink.css'; import gmfMapModule from 'gmf/map/module'; import gmfMapComponent from 'gmf/map/component'; - import gmfQueryWindowComponent from 'gmf/query/windowComponent'; import ngeoStatemanagerWfsPermalink from 'ngeo/statemanager/WfsPermalink'; - import EPSG2056 from 'ngeo/proj/EPSG_2056'; import olMap from 'ol/Map'; import olView from 'ol/View'; @@ -45,7 +43,6 @@ const myModule = angular.module('gmfapp', [ /** * @class - * @ngInject */ function MainController() { /** @@ -65,20 +62,27 @@ function MainController() { }), }); } - myModule.controller('MainController', MainController); - myModule.constant('gmfDisplayQueryWindowOptions', { featuresStyle: { - fill: {color: [255, 170, 0, 0.6]}, - stroke: {color: [255, 170, 0, 1], width: 2}, + fill: { + color: [255, 170, 0, 0.6], + }, + stroke: { + color: [255, 170, 0, 1], + width: 2, + }, circle: { radius: 5, - fill: {color: [255, 170, 0, 0.6]}, - stroke: {color: [255, 170, 0, 1], width: 2}, + fill: { + color: [255, 170, 0, 0.6], + }, + stroke: { + color: [255, 170, 0, 1], + width: 2, + }, }, }, }); options(myModule); - export default myModule; diff --git a/contribs/gmf/examples/xsdattributes.js b/contribs/gmf/examples/xsdattributes.js index 4f197c8033ff..80166c48cc2c 100644 --- a/contribs/gmf/examples/xsdattributes.js +++ b/contribs/gmf/examples/xsdattributes.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$timeout', 'gmfThemes', 'gmfXSDAttributes']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,7 +23,6 @@ import angular from 'angular'; import './xsdattributes.css'; import gmfThemeThemes from 'gmf/theme/Themes'; - import gmfEditingXSDAttributes from 'gmf/editing/XSDAttributes'; import ngeoEditingAttributesComponent from 'ngeo/editing/attributesComponent'; import {getGeometryAttribute} from 'ngeo/format/XSDAttribute'; @@ -44,7 +44,6 @@ const myModule = angular.module('gmfapp', [ * @param {import('gmf/editing/XSDAttributes').EditingXSDAttributeService} gmfXSDAttributes * The gmf XSDAttributes service. * @class - * @ngInject */ function MainController($timeout, gmfThemes, gmfXSDAttributes) { /** @@ -75,9 +74,7 @@ function MainController($timeout, gmfThemes, gmfXSDAttributes) { // TMP - The list of layer names to use. We'll keep this until we can use // those that are editable. const layerNames = ['line', 'point', 'polygon']; - gmfThemes.loadThemes(); - gmfThemes.getThemesObject().then((themes) => { if (!themes) { return; @@ -91,10 +88,10 @@ function MainController($timeout, gmfThemes, gmfXSDAttributes) { }); }); flatNodes.forEach((node) => { - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (node); + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ node; // Get an array of all layers if (groupNode.children === undefined && layerNames.includes(node.name)) { - this.layers.push(/** @type {import('gmf/themes').GmfLayer} */ (node)); + this.layers.push(/** @type {import('gmf/themes').GmfLayer} */ node); } }); }); @@ -150,7 +147,7 @@ MainController.prototype.getGeomType = function () { */ MainController.prototype.getDistinctFlatNodes_ = function (node, nodes) { let i; - const children = /** @type {import('gmf/themes').GmfGroup} */ (node).children; + const children = /** @type {import('gmf/themes').GmfGroup} */ node.children; if (children !== undefined) { for (i = 0; i < children.length; i++) { this.getDistinctFlatNodes_(children[i], nodes); @@ -168,8 +165,6 @@ MainController.prototype.getDistinctFlatNodes_ = function (node, nodes) { nodes.push(node); } }; - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/docs/guidelines.md b/docs/guidelines.md index f3fc412c9cd4..478ac6120547 100644 --- a/docs/guidelines.md +++ b/docs/guidelines.md @@ -232,7 +232,6 @@ module.run( * @param {!angular.IAttributes} $attrs Attributes. * @param {!function(!JQuery, !angular.IAttributes): string} gmfDisplayquerywindowTemplateUrl Template function. * @return {string} Template URL. - * @ngInject * @hidden */ function gmfDisplayquerywindowTemplateUrl($element, $attrs, ngeoModuleComponentTemplateUrl) { @@ -465,7 +464,6 @@ For example: * * * @htmlAttribute {import("ol/Map.js").default} ngeo-misc-map The map. - * @ngInject * @ngdoc component * @ngname ngeoControl */ diff --git a/examples/animation.js b/examples/animation.js index 3fc5fa536af0..6295c57acc7f 100644 --- a/examples/animation.js +++ b/examples/animation.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$timeout']; // The MIT License (MIT) // // Copyright (c) 2014-2024 Camptocamp SA @@ -45,7 +46,6 @@ const mapComponent = { }, template: '', }; - myModule.component('appMap', mapComponent); /** @@ -53,7 +53,6 @@ myModule.component('appMap', mapComponent); * * @param {angular.ITimeoutService} $timeout Angular timeout service. * @class - * @ngInject * @private * @hidden */ @@ -87,8 +86,6 @@ function MainController($timeout) { this.open = true; }, 0); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/asitvd.js b/examples/asitvd.js index 4f6697440ce6..e5a66be10742 100644 --- a/examples/asitvd.js +++ b/examples/asitvd.js @@ -22,7 +22,6 @@ import angular from 'angular'; import ngeoSourceAsitVD from 'ngeo/source/AsitVD'; import EPSG2056 from 'ngeo/proj/EPSG_2056'; - import olMap from 'ol/Map'; import olView from 'ol/View'; import olLayerTile from 'ol/layer/WebGLTile'; @@ -34,7 +33,6 @@ const myModule = angular.module('app', ['gettext', gmfMapComponent.name]); /** * @class - * @ngInject */ function MainController() { /** @@ -56,8 +54,6 @@ function MainController() { }), }); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/attributes.js b/examples/attributes.js index 604572e3473b..62f227bd0418 100644 --- a/examples/attributes.js +++ b/examples/attributes.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$http', '$timeout', '$scope']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -21,9 +22,7 @@ import angular from 'angular'; import ngeoFormatXSDAttribute from 'ngeo/format/XSDAttribute'; - import ngeoEditingAttributesComponent from 'ngeo/editing/attributesComponent'; - import olFeature from 'ol/Feature'; import ngeoMapModule from 'ngeo/map/module'; @@ -34,7 +33,6 @@ const myModule = angular.module('app', ['gettext', ngeoMapModule.name, ngeoEditi * @param {angular.IHttpService} $http Angular http service. * @param {angular.ITimeoutService} $timeout Angular timeout service. * @param {angular.IScope} $scope Scope. - * @ngInject * @class */ function MainController($http, $timeout, $scope) { @@ -60,7 +58,6 @@ function MainController($http, $timeout, $scope) { 'name': 'A feature', 'kind': 'house', }); - $http.get('data/xsdattributes.xml').then(this.handleXSDAttributeGet_.bind(this)); // @@ -70,7 +67,6 @@ function MainController($http, $timeout, $scope) { * @type {string} */ this.log = ''; - $scope.$watch( () => this.feature.get('name'), (newValue, oldValue) => { @@ -79,7 +75,6 @@ function MainController($http, $timeout, $scope) { } }, ); - $scope.$watch( () => this.feature.get('kind'), (newValue, oldValue) => { @@ -115,7 +110,5 @@ MainController.prototype.updateName = function () { MainController.prototype.appendLog = function (newMessage) { this.log = `${newMessage}\n${this.log}`; }; - myModule.controller('MainController', MainController); - export default myModule; diff --git a/examples/backgroundlayer.js b/examples/backgroundlayer.js index 5cf32a18c912..d8661e064176 100644 --- a/examples/backgroundlayer.js +++ b/examples/backgroundlayer.js @@ -1,3 +1,5 @@ +MainController.$inject = ['$scope']; +BackgroundlayerController.$inject = ['$http', 'ngeoBackgroundLayerMgr']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -23,7 +25,6 @@ import './backgroundlayer.css'; import angular from 'angular'; import ngeoSourceAsitVD from 'ngeo/source/AsitVD'; import {MAPSERVER_PROXY} from './url'; - import EPSG2056 from 'ngeo/proj/EPSG_2056'; import olMap from 'ol/Map'; import olView from 'ol/View'; @@ -37,16 +38,17 @@ import options from './options'; /** @type {angular.IModule} **/ const myModule = angular.module('app', ['gettext', gmfMapComponent.name]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('partials/backgroundlayer', require('./partials/backgroundlayer.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('partials/backgroundlayer', require('./partials/backgroundlayer.html')); + }, + ], ); /** @@ -69,7 +71,6 @@ const backgroundlayerComponent = { templateUrl: 'partials/backgroundlayer', controller: 'AppBackgroundlayerController', }; - myModule.component('appBackgroundlayer', backgroundlayerComponent); /** @@ -77,7 +78,6 @@ myModule.component('appBackgroundlayer', backgroundlayerComponent); * @param {angular.IHttpService} $http Angular http service. * @param {import('ngeo/map/BackgroundLayerMgr').MapBackgroundLayerManager} ngeoBackgroundLayerMgr * Background layer manager. - * @ngInject */ function BackgroundlayerController($http, ngeoBackgroundLayerMgr) { /** @@ -94,7 +94,6 @@ function BackgroundlayerController($http, ngeoBackgroundLayerMgr) { * @type {import('gmf/themes').GmfLayer} */ this.bgLayer = null; - $http.get('data/backgroundlayers.json').then((resp) => { this.bgLayers = resp.data; if (!this.bgLayers) { @@ -136,19 +135,18 @@ BackgroundlayerController.prototype.getLayer_ = function (layerName) { layer.set('label', 'blank'); return layer; } - const source = new ngeoSourceAsitVD({ layer: layerName, }); - return new olLayerTile({source}); + return new olLayerTile({ + source, + }); }; - myModule.controller('AppBackgroundlayerController', BackgroundlayerController); /** * @class * @param {angular.IScope} $scope Controller scope. - * @ngInject */ function MainController($scope) { /** @@ -162,10 +160,11 @@ function MainController($scope) { zoom: 3, }), }); - const source = new olSourceImageWMS({ url: MAPSERVER_PROXY, - params: {'LAYERS': 'default'}, + params: { + 'LAYERS': 'default', + }, serverType: 'mapserver', }); /** @@ -176,12 +175,9 @@ function MainController($scope) { const overlay = new olLayerImage({ source, }); - this.map.addLayer(overlay); } - myModule.controller('MainController', MainController); myModule.constant('ngeoTilesPreloadingLimit', 0); options(myModule); - export default myModule; diff --git a/examples/backgroundlayerdropdown.js b/examples/backgroundlayerdropdown.js index 4b35553cfccf..92366f885adf 100644 --- a/examples/backgroundlayerdropdown.js +++ b/examples/backgroundlayerdropdown.js @@ -1,3 +1,5 @@ +MainController.$inject = ['$scope']; +BackgroundlayerController.$inject = ['$http', 'ngeoBackgroundLayerMgr']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -23,7 +25,6 @@ import './backgroundlayerdropdown.css'; import angular from 'angular'; import ngeoSourceAsitVD from 'ngeo/source/AsitVD'; import {MAPSERVER_PROXY} from './url'; - import EPSG2056 from 'ngeo/proj/EPSG_2056'; import olMap from 'ol/Map'; import olView from 'ol/View'; @@ -37,19 +38,20 @@ import options from './options'; /** @type {angular.IModule} **/ const myModule = angular.module('app', ['gettext', gmfMapComponent.name]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - $templateCache.put( - 'partials/backgroundlayerdropdown', - // @ts-ignore: webpack - require('./partials/backgroundlayerdropdown.html'), - ); - }, + [ + '$templateCache', + ($templateCache) => { + $templateCache.put( + 'partials/backgroundlayerdropdown', + // @ts-ignore: webpack + require('./partials/backgroundlayerdropdown.html'), + ); + }, + ], ); /** @@ -67,7 +69,6 @@ const backgroundlayerComponent = { templateUrl: 'partials/backgroundlayerdropdown', controller: 'AppBackgroundlayerController', }; - myModule.component('appBackgroundlayer', backgroundlayerComponent); /** @@ -75,7 +76,6 @@ myModule.component('appBackgroundlayer', backgroundlayerComponent); * @param {angular.IHttpService} $http Angular http service. * @param {import('ngeo/map/BackgroundLayerMgr').MapBackgroundLayerManager} ngeoBackgroundLayerMgr * Background layer manager. - * @ngInject */ function BackgroundlayerController($http, ngeoBackgroundLayerMgr) { $http.get('data/backgroundlayers.json').then((resp) => { @@ -122,19 +122,18 @@ BackgroundlayerController.prototype.createLayer_ = function (layerName) { layer.set('label', 'blank'); return layer; } - const source = new ngeoSourceAsitVD({ layer: layerName, }); - return new olLayerTile({source}); + return new olLayerTile({ + source, + }); }; - myModule.controller('AppBackgroundlayerController', BackgroundlayerController); /** * @class * @param {angular.IScope} $scope Controller scope. - * @ngInject */ function MainController($scope) { /** @@ -149,10 +148,11 @@ function MainController($scope) { }), }); this.map = map; - const source = new olSourceImageWMS({ url: MAPSERVER_PROXY, - params: {'LAYERS': 'default'}, + params: { + 'LAYERS': 'default', + }, serverType: 'mapserver', }); /** @@ -163,14 +163,9 @@ function MainController($scope) { const overlay = new olLayerImage({ source, }); - map.addLayer(overlay); } - myModule.controller('MainController', MainController); - myModule.constant('ngeoTilesPreloadingLimit', 0); - options(myModule); - export default myModule; diff --git a/examples/colorpicker.js b/examples/colorpicker.js index f8e0e281f6fa..c5b4d4576623 100644 --- a/examples/colorpicker.js +++ b/examples/colorpicker.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$scope']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -36,12 +37,10 @@ const colorpickerComponent = { template: '
', controller: 'AppColorpickerController', }; - myModule.component('appColorpicker', colorpickerComponent); /** * @class - * @ngInject */ function ColorPickerController() { /** @@ -55,13 +54,11 @@ function ColorPickerController() { ['#ffffff', '#f7f7f7', '#c3c3c3', '#000000'], ]; } - myModule.controller('AppColorpickerController', ColorPickerController); /** * @class * @param {angular.IScope} $scope Controller scope. - * @ngInject */ function MainController($scope) { /** @@ -71,7 +68,5 @@ function MainController($scope) { */ this.color = 'red'; } - myModule.controller('MainController', MainController); - export default myModule; diff --git a/examples/control.js b/examples/control.js index 55e6a52f22fa..d640f3d54902 100644 --- a/examples/control.js +++ b/examples/control.js @@ -22,9 +22,7 @@ import angular from 'angular'; import gmfMapComponent from 'gmf/map/component'; import options from './options'; - import ngeoMiscControlComponent from 'ngeo/misc/controlComponent'; - import olMap from 'ol/Map'; import olView from 'ol/View'; import olControlMousePosition from 'ol/control/MousePosition'; @@ -36,7 +34,6 @@ const myModule = angular.module('app', ['gettext', gmfMapComponent.name, ngeoMis /** * @class - * @ngInject */ function MainController() { /** @@ -61,8 +58,6 @@ function MainController() { className: 'mouse-position', }); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/createfeature.js b/examples/createfeature.js index 4a2c3898b071..a2eac254fdab 100644 --- a/examples/createfeature.js +++ b/examples/createfeature.js @@ -1,3 +1,4 @@ +MainController.$inject = ['ngeoToolActivateMgr']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,11 +23,8 @@ import './createfeature.css'; import angular from 'angular'; import ngeoEditingCreatefeatureComponent from 'ngeo/editing/createfeatureComponent'; - import ngeoGeometryType from 'ngeo/GeometryType'; - import ngeoMiscBtnComponent from 'ngeo/misc/btnComponent'; - import ngeoMiscToolActivate from 'ngeo/misc/ToolActivate'; import ngeoMiscToolActivateMgr from 'ngeo/misc/ToolActivateMgr'; import olCollection from 'ol/Collection'; @@ -52,7 +50,6 @@ const myModule = angular.module('app', [ * @param {import('ngeo/misc/ToolActivateMgr').ToolActivateMgr} ngeoToolActivateMgr Ngeo ToolActivate * manager service. * @class - * @ngInject */ function MainController(ngeoToolActivateMgr) { /** @@ -74,7 +71,6 @@ function MainController(ngeoToolActivateMgr) { * @type {string} */ this.polygonGeomType = ngeoGeometryType.POLYGON; - const vector = new olLayerVector({ source: new olSourceVector({ wrapX: false, @@ -102,7 +98,6 @@ function MainController(ngeoToolActivateMgr) { * @type {boolean} */ this.createPointActive = false; - const createPointToolActivate = new ngeoMiscToolActivate(this, 'createPointActive'); ngeoToolActivateMgr.registerTool('mapTools', createPointToolActivate, false); @@ -110,7 +105,6 @@ function MainController(ngeoToolActivateMgr) { * @type {boolean} */ this.createLineStringActive = false; - const createLineStringToolActivate = new ngeoMiscToolActivate(this, 'createLineStringActive'); ngeoToolActivateMgr.registerTool('mapTools', createLineStringToolActivate, false); @@ -118,7 +112,6 @@ function MainController(ngeoToolActivateMgr) { * @type {boolean} */ this.createPolygonActive = false; - const createPolygonToolActivate = new ngeoMiscToolActivate(this, 'createPolygonActive'); ngeoToolActivateMgr.registerTool('mapTools', createPolygonToolActivate, false); @@ -126,12 +119,9 @@ function MainController(ngeoToolActivateMgr) { * @type {boolean} */ this.dummyActive = true; - const dummyToolActivate = new ngeoMiscToolActivate(this, 'dummyActive'); ngeoToolActivateMgr.registerTool('mapTools', dummyToolActivate, true); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/datepicker.js b/examples/datepicker.js index 6503596d348e..f80b6153d379 100644 --- a/examples/datepicker.js +++ b/examples/datepicker.js @@ -1,3 +1,4 @@ +MainController.$inject = ['ngeoTime']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,7 +23,6 @@ import './datepicker.css'; import angular from 'angular'; import ngeoMiscDatepickerComponent from 'ngeo/misc/datepickerComponent'; - import ngeoMiscTime from 'ngeo/misc/Time'; import {TimePropertyWidgetEnum, TimePropertyModeEnum} from 'ngeo/datasource/OGC'; @@ -32,7 +32,6 @@ const myModule = angular.module('app', ['gettext', ngeoMiscDatepickerComponent.n /** * @class * @param {import('ngeo/misc/Time').default} ngeoTime time service. - * @ngInject */ function MainController(ngeoTime) { /** @@ -86,7 +85,5 @@ function MainController(ngeoTime) { this.rangeValue = date; }; } - myModule.controller('MainController', MainController); - export default myModule; diff --git a/examples/datetimepicker.js b/examples/datetimepicker.js index 6c61d8dc9fde..a3cc6ee575cf 100644 --- a/examples/datetimepicker.js +++ b/examples/datetimepicker.js @@ -28,7 +28,6 @@ const myModule = angular.module('app', ['gettext', ngeoMiscDatetimepickerCompone /** * @class - * @ngInject */ function MainController() { /** @@ -46,7 +45,5 @@ function MainController() { */ this.datetime = '2018-01-01 12:00:00'; } - myModule.controller('MainController', MainController); - export default myModule; diff --git a/examples/disclaimer.js b/examples/disclaimer.js index 7c9fcd5eadf2..50a4ef07c870 100644 --- a/examples/disclaimer.js +++ b/examples/disclaimer.js @@ -1,3 +1,4 @@ +MainController.$inject = ['ngeoDisclaimer']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -23,7 +24,6 @@ import './disclaimer.css'; import 'bootstrap/js/src/tooltip'; import angular from 'angular'; import ngeoMessageDisclaimer from 'ngeo/message/Disclaimer'; - import {MessageType} from 'ngeo/message/Message'; import olMap from 'ol/Map'; import olView from 'ol/View'; @@ -38,7 +38,6 @@ const myModule = angular.module('app', ['gettext', gmfMapComponent.name, ngeoMes /** * @param {import('ngeo/message/Disclaimer').MessageDisclaimerService} ngeoDisclaimer Ngeo disclaimer * service. - * @ngInject * @class */ function MainController(ngeoDisclaimer) { @@ -145,22 +144,18 @@ MainController.prototype.closeAll = function () { msg: this.successMsg_, type: MessageType.SUCCESS, }); - this.disclaimer.close({ msg: this.infoMsg_, type: MessageType.INFORMATION, }); - this.disclaimer.close({ msg: this.warningMsg_, type: MessageType.WARNING, }); - this.disclaimer.close({ msg: this.errorMsg_, type: MessageType.ERROR, }); - this.inMapMsgs_.forEach((message) => { this.disclaimer.close({ msg: message, @@ -168,8 +163,6 @@ MainController.prototype.closeAll = function () { }); }); }; - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/displaywindow.js b/examples/displaywindow.js index 3d4674123354..3db9cadbdc82 100644 --- a/examples/displaywindow.js +++ b/examples/displaywindow.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$scope']; // The MIT License (MIT) // // Copyright (c) 2018-2024 Camptocamp SA @@ -28,7 +29,6 @@ const myModule = angular.module('app', [ngeoMessageDisplaywindowComponent.name]) /** * @param {angular.IScope} $scope Scope. - * @ngInject * @class */ function MainController($scope) { @@ -79,7 +79,6 @@ function MainController($scope) { * @type {boolean} */ this.window4IsOpen = false; - const element = document.getElementById('window4Template'); if (!element) { throw new Error('Missing element'); @@ -99,7 +98,5 @@ function MainController($scope) { */ this.windowScope = $scope; } - myModule.controller('MainController', MainController); - export default myModule; diff --git a/examples/drawfeature.js b/examples/drawfeature.js index 9e5326162bba..45e78a5cb6fc 100644 --- a/examples/drawfeature.js +++ b/examples/drawfeature.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$scope', 'ngeoFeatures', 'ngeoToolActivateMgr']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,7 +23,6 @@ import './drawfeature.css'; import angular from 'angular'; import ngeoDrawModule from 'ngeo/draw/module'; - import gmfMapComponent from 'gmf/map/component'; import options from './options'; import ngeoMiscToolActivate from 'ngeo/misc/ToolActivate'; @@ -48,7 +48,6 @@ const myModule = angular.module('app', [ * of features. * @param {import('ngeo/misc/ToolActivateMgr').ToolActivateMgr} ngeoToolActivateMgr Ngeo ToolActivate * manager service. - * @ngInject * @class */ function MainController($scope, ngeoFeatures, ngeoToolActivateMgr) { @@ -56,7 +55,6 @@ function MainController($scope, ngeoFeatures, ngeoToolActivateMgr) { * @type {angular.IScope} */ this.scope_ = $scope; - const vector = new olLayerVector({ source: new olSourceVector({ wrapX: false, @@ -84,7 +82,6 @@ function MainController($scope, ngeoFeatures, ngeoToolActivateMgr) { * @type {boolean} */ this.drawActive = false; - const drawToolActivate = new ngeoMiscToolActivate(this, 'drawActive'); ngeoToolActivateMgr.registerTool('mapTools', drawToolActivate, false); @@ -92,12 +89,9 @@ function MainController($scope, ngeoFeatures, ngeoToolActivateMgr) { * @type {boolean} */ this.dummyActive = true; - const dummyToolActivate = new ngeoMiscToolActivate(this, 'dummyActive'); ngeoToolActivateMgr.registerTool('mapTools', dummyToolActivate, true); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/elevationProfile.js b/examples/elevationProfile.js index c19c78897d6d..d94b26eb0751 100644 --- a/examples/elevationProfile.js +++ b/examples/elevationProfile.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$http', '$scope']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -23,7 +24,6 @@ import './elevationProfile.css'; import angular from 'angular'; import EPSG2056 from 'ngeo/proj/EPSG_2056'; import {MAPSERVER_PROXY} from './url'; - import olFeature from 'ol/Feature'; import olMap from 'ol/Map'; import olView from 'ol/View'; @@ -70,14 +70,12 @@ const typedFunctionsFactory = function (key, opt_childKey) { * @class * @param {angular.IHttpService} $http The $http angular service. * @param {angular.IScope} $scope The $scope angular service. - * @ngInject */ function MainController($http, $scope) { /** * @type {angular.IScope} */ this.scope_ = $scope; - const source = new olSourceVector(); const source2 = new olSourceImageWMS({ url: MAPSERVER_PROXY, @@ -105,17 +103,13 @@ function MainController($http, $scope) { projection: EPSG2056, }), }); - const map = this.map; - const vectorLayer = new olLayerVector({ source: new olSourceVector(), }); - this.snappedPoint_ = new olFeature(); - /** @type {olSourceVector} */ (vectorLayer.getSource()).addFeature( - this.snappedPoint_, - ); + /** @type {olSourceVector} */ + vectorLayer.getSource().addFeature(this.snappedPoint_); // Use vectorLayer.setMap(map) rather than map.addLayer(vectorLayer). This // makes the vector layer "unmanaged", meaning that it is always on top. @@ -125,19 +119,27 @@ function MainController($http, $scope) { * @type {Object[]} */ this.profilePoisData = [ - {sort: 1, dist: 1000, title: 'First POI', id: 12345}, - {sort: 2, dist: 3000, title: 'Second POI', id: 12346}, + { + sort: 1, + dist: 1000, + title: 'First POI', + id: 12345, + }, + { + sort: 2, + dist: 3000, + title: 'Second POI', + id: 12346, + }, ]; /** * @type {Object|undefined} */ this.profileData = undefined; - $http.get('data/profile.json').then((resp) => { const data = resp.data.profile; this.profileData = data; - let i; const len = data.length; const lineString = new olGeomLineString([], 'XYM'); @@ -146,33 +148,31 @@ function MainController($http, $scope) { lineString.appendCoordinate([p.x, p.y, p.dist]); } source.addFeature(new olFeature(lineString)); - const size = this.map.getSize(); if (size === undefined) { throw new Error('Missing size'); } - map.getView().fit(source.getExtent(), {size}); + map.getView().fit(source.getExtent(), { + size, + }); }); - map.on( - /** @type {import('ol/Observable').EventTypes} */ ('pointermove'), - /** @type {function(?): ?} */ ( - /** - * @param {import('ol/MapBrowserEvent').default} evt - */ (evt) => { - if (evt.dragging) { - return; - } - const coordinate = map.getEventCoordinate(evt.originalEvent); - const geometry = source.getFeatures()[0].getGeometry(); - if (!geometry) { - throw new Error('Missing geometry'); - } - this.snapToGeometry(coordinate, geometry); + /** @type {import('ol/Observable').EventTypes} */ 'pointermove', + /** @type {function(?): ?} */ + /** + * @param {import('ol/MapBrowserEvent').default} evt + */ (evt) => { + if (evt.dragging) { + return; + } + const coordinate = map.getEventCoordinate(evt.originalEvent); + const geometry = source.getFeatures()[0].getGeometry(); + if (!geometry) { + throw new Error('Missing geometry'); } - ), + this.snapToGeometry(coordinate, geometry); + }, ); - const distanceExtractor = typedFunctionsFactory('dist'); /** @type {function(Object): number} */ @@ -216,7 +216,6 @@ function MainController($http, $scope) { // @ts-ignore this.snappedPoint_.setGeometry(new olGeomPoint([point.x, point.y])); }; - const outCallback = () => { this.point = null; this.snappedPoint_.setGeometry(undefined); @@ -261,7 +260,6 @@ MainController.prototype.snapToGeometry = function (coordinate, geometry) { throw new Error('Missing resolution'); } const pixelDist = dist / resolution; - if (pixelDist < 8) { this.profileHighlight = closestPoint[2]; } else { @@ -269,9 +267,7 @@ MainController.prototype.snapToGeometry = function (coordinate, geometry) { } this.scope_.$apply(); }; - myModule.controller('MainController', MainController); - myModule.constant('ngeoProfileOptions', { linesConfiguration: { 'line1': { @@ -280,7 +276,5 @@ myModule.constant('ngeoProfileOptions', { }, }, }); - options(myModule); - export default myModule; diff --git a/examples/error.js b/examples/error.js index dccc1c1b61c2..c4c21ae41473 100644 --- a/examples/error.js +++ b/examples/error.js @@ -21,7 +21,6 @@ import angular from 'angular'; import olMap from 'ol/Map'; - import olView from 'ol/View'; import olLayerTile from 'ol/layer/WebGLTile'; import olSourceOSM from 'ol/source/OSM'; @@ -33,7 +32,6 @@ const myModule = angular.module('app', ['gettext', gmfMapComponent.name]); /** * @class - * @ngInject */ function MainController() { /** @@ -51,8 +49,6 @@ function MainController() { }), }); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/googlestreetview.js b/examples/googlestreetview.js index 7a28585ff25c..959c7d364870 100644 --- a/examples/googlestreetview.js +++ b/examples/googlestreetview.js @@ -1,3 +1,4 @@ +MainController.$inject = ['ngeoToolActivateMgr']; // The MIT License (MIT) // // Copyright (c) 2017-2024 Camptocamp SA @@ -22,7 +23,6 @@ import './googlestreetview.css'; import angular from 'angular'; import olMap from 'ol/Map'; - import olView from 'ol/View'; import olLayerTile from 'ol/layer/WebGLTile'; import olSourceOSM from 'ol/source/OSM'; @@ -49,7 +49,6 @@ const myModule = angular.module('app', [ * @param {import('ngeo/misc/ToolActivateMgr').ToolActivateMgr} ngeoToolActivateMgr * Ngeo ToolActivate manager service. * @class - * @ngInject */ function MainController(ngeoToolActivateMgr) { /** @@ -62,10 +61,15 @@ function MainController(ngeoToolActivateMgr) { */ this.style = new olStyleStyle({ text: new olStyleText({ - fill: new olStyleFill({color: '#279B61'}), + fill: new olStyleFill({ + color: '#279B61', + }), font: '900 30px "Font Awesome 5 Free"', offsetY: -15, - stroke: new olStyleStroke({color: '#ffffff', width: 3}), + stroke: new olStyleStroke({ + color: '#ffffff', + width: 3, + }), text: '\uf041', }), }); @@ -84,14 +88,12 @@ function MainController(ngeoToolActivateMgr) { zoom: 17, }), }); - ngeoMapFeatureOverlayMgr.init(this.map); /** * @type {boolean} */ this.googleStreetViewActive = true; - const googleStreetViewToolActivate = new ngeoMiscToolActivate(this, 'googleStreetViewActive'); ngeoToolActivateMgr.registerTool('mapTools', googleStreetViewToolActivate, true); @@ -99,17 +101,12 @@ function MainController(ngeoToolActivateMgr) { * @type {boolean} */ this.dummyActive = false; - const dummyToolActivate = new ngeoMiscToolActivate(this, 'dummyActive'); ngeoToolActivateMgr.registerTool('mapTools', dummyToolActivate, false); } - myModule.controller('MainController', MainController); - myModule.constant('ngeoGoogleStreetviewOptions', { 'viewer': 'google', }); - options(myModule); - export default myModule; diff --git a/examples/grid.js b/examples/grid.js index 16bf4777d896..d09306058a53 100644 --- a/examples/grid.js +++ b/examples/grid.js @@ -29,7 +29,6 @@ const myModule = angular.module('app', ['gettext', ngeoGridModule.name]); /** * @class - * @ngInject */ function MainController() { const data = [ @@ -70,16 +69,26 @@ function MainController() { 'timestamp': '2010-11-17T22:56:26Z', }, ]; - - const columnDefs = [{name: 'name'}, {name: 'display_name'}, {name: 'timestamp'}, {name: 'type'}]; + const columnDefs = [ + { + name: 'name', + }, + { + name: 'display_name', + }, + { + name: 'timestamp', + }, + { + name: 'type', + }, + ]; /** * @type {import('ngeo/grid/Config').default} */ this.gridConfig = new ngeoGridConfig(data, columnDefs); } - myModule.controller('MainController', MainController); myModule.constant('ngeoStringToHtmlReplacements', []); - export default myModule; diff --git a/examples/importfeatures.js b/examples/importfeatures.js index 08bf166a3426..7ba36d5af9fe 100644 --- a/examples/importfeatures.js +++ b/examples/importfeatures.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$scope']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -22,9 +23,7 @@ import angular from 'angular'; import gmfMapComponent from 'gmf/map/component'; import options from './options'; - import ngeoMiscFilereaderComponent from 'ngeo/misc/filereaderComponent'; - import olMap from 'ol/Map'; import olView from 'ol/View'; import * as olExtent from 'ol/extent'; @@ -40,7 +39,6 @@ const myModule = angular.module('app', ['gettext', gmfMapComponent.name, ngeoMis /** * @class * @param {angular.IScope} $scope Scope. - * @ngInject */ function MainController($scope) { /** @@ -80,7 +78,6 @@ function MainController($scope) { * @type {string} */ this.fileContent = ''; - $scope.$watch(() => this.fileContent, this.importKml_.bind(this)); } @@ -90,21 +87,21 @@ function MainController($scope) { MainController.prototype.importKml_ = function (kml) { const map = this.map; const vectorSource = this.vectorSource_; - const features = /** @type {import('ol/Feature').default[]} */ ( + const features = + /** @type {import('ol/Feature').default[]} */ this.kmlFormat_.readFeatures(kml, { featureProjection: 'EPSG:3857', - }) - ); + }); vectorSource.clear(true); vectorSource.addFeatures(features); const extent = vectorSource.getExtent(); const mapSize = map.getSize(); if (mapSize && !olExtent.isEmpty(extent)) { - map.getView().fit(extent, {size: mapSize}); + map.getView().fit(extent, { + size: mapSize, + }); } }; - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/interactionbtngroup.js b/examples/interactionbtngroup.js index 99a998ef9c8b..e9a5cfbbbd54 100644 --- a/examples/interactionbtngroup.js +++ b/examples/interactionbtngroup.js @@ -23,10 +23,8 @@ import './interactionbtngroup.css'; import angular from 'angular'; import gmfMapComponent from 'gmf/map/component'; import options from './options'; - import ngeoMiscBtnComponent from 'ngeo/misc/btnComponent'; import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; - import {interactionDecoration} from 'ngeo/misc/decorate'; import olCollection from 'ol/Collection'; import olMap from 'ol/Map'; @@ -44,7 +42,6 @@ const myModule = angular.module('app', ['gettext', gmfMapComponent.name, ngeoMis /** * @class - * @ngInject */ function MainController() { /** @@ -54,7 +51,6 @@ function MainController() { * @type {import('ol/Collection').default>} */ const features = new olCollection(); - const overlay = ngeoMapFeatureOverlayMgr.getFeatureOverlay(); overlay.setFeatures(features); overlay.setStyle( @@ -89,7 +85,6 @@ function MainController() { zoom: 4, }), }); - const map = this.map; // initialize the feature overlay manager with the map @@ -99,14 +94,12 @@ function MainController() { * @type {import('ol/interaction/Draw').default} */ this.drawPolygon = new olInteractionDraw( - /** @type {import('ol/interaction/Draw').Options} */ ({ + /** @type {import('ol/interaction/Draw').Options} */ { type: 'Polygon', features: features, - }), + }, ); - const drawPolygon = this.drawPolygon; - drawPolygon.setActive(false); interactionDecoration(drawPolygon); map.addInteraction(drawPolygon); @@ -115,12 +108,11 @@ function MainController() { * @type {import('ol/interaction/Draw').default} */ this.drawPoint = new olInteractionDraw( - /** @type {import('ol/interaction/Draw').Options} */ ({ + /** @type {import('ol/interaction/Draw').Options} */ { type: 'Point', features: features, - }), + }, ); - const drawPoint = this.drawPoint; drawPoint.setActive(false); interactionDecoration(drawPoint); @@ -130,19 +122,16 @@ function MainController() { * @type {import('ol/interaction/Draw').default} */ this.drawLine = new olInteractionDraw( - /** @type {import('ol/interaction/Draw').Options} */ ({ + /** @type {import('ol/interaction/Draw').Options} */ { type: 'LineString', features: features, - }), + }, ); - const drawLine = this.drawLine; drawLine.setActive(false); interactionDecoration(drawLine); map.addInteraction(drawLine); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/layerorder.js b/examples/layerorder.js index 98420cd6bfcc..dc8f1ed1d52f 100644 --- a/examples/layerorder.js +++ b/examples/layerorder.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$scope']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -23,9 +24,7 @@ import './layerorder.css'; import angular from 'angular'; import gmfMapComponent from 'gmf/map/component'; import options from './options'; - import ngeoMiscSortableComponent from 'ngeo/misc/sortableComponent'; - import ngeoMiscSyncArrays from 'ngeo/misc/syncArrays'; import ngeoSourceAsitVD from 'ngeo/source/AsitVD'; import EPSG2056 from 'ngeo/proj/EPSG_2056'; @@ -42,7 +41,6 @@ const myModule = angular.module('app', ['gettext', gmfMapComponent.name, ngeoMis /** * @param {angular.IScope} $scope Scope. * @class - * @ngInject */ function MainController($scope) { const asitvd = new olLayerTile({ @@ -51,7 +49,6 @@ function MainController($scope) { }), }); asitvd.set('name', 'asitvd'); - const boundaries = new olLayerImage({ source: new olSourceWMS({ url: MAPSERVER_PROXY, @@ -63,7 +60,6 @@ function MainController($scope) { }), }); boundaries.set('name', 'Boundaries'); - const waterBodies = new olLayerImage({ source: new olSourceWMS({ url: MAPSERVER_PROXY, @@ -75,7 +71,6 @@ function MainController($scope) { }), }); waterBodies.set('name', 'Water bodies'); - const cities = new olLayerImage({ source: new olSourceWMS({ url: MAPSERVER_PROXY, @@ -100,9 +95,7 @@ function MainController($scope) { zoom: 9, }), }); - const map = this.map; - this.roads_ = new olLayerImage({ source: new olSourceWMS({ url: MAPSERVER_PROXY, @@ -120,9 +113,7 @@ function MainController($scope) { * @constant */ this.selectedLayers = []; - const selectedLayers = this.selectedLayers; - ngeoMiscSyncArrays(map.getLayers().getArray(), selectedLayers, true, $scope, layerFilter); // watch any change on layers array to refresh the map @@ -163,8 +154,6 @@ MainController.prototype.toggleRoadsLayer = function (val) { } } }; - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/locationsearch.js b/examples/locationsearch.js index ac374bc9ed10..c5882f035fed 100644 --- a/examples/locationsearch.js +++ b/examples/locationsearch.js @@ -1,3 +1,4 @@ +SearchController.$inject = ['ngeoCreateLocationSearchBloodhound']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -21,7 +22,6 @@ import './locationsearch.css'; import angular from 'angular'; - import gmfMapComponent from 'gmf/map/component'; import options from './options'; import ngeoSearchModule from 'ngeo/search/module'; @@ -48,21 +48,18 @@ const locationSearchComponent = { 'ngeo-search-datasets="$ctrl.datasets" ' + 'ngeo-search-listeners="$ctrl.listeners">', }; - appmodule.component('appLocationSearch', locationSearchComponent); /** * @class * @param {import('ngeo/search/createLocationSearchBloodhound').createLocationSearchBloodhoundFunction} ngeoCreateLocationSearchBloodhound * Bloodhound service. - * @ngInject */ function SearchController(ngeoCreateLocationSearchBloodhound) { /** * @type {?import('ol/Map').default} */ this.map = null; - const limit = 10; /** @type {Bloodhound[]>} */ const bloodhoundEngine = this.createAndInitBloodhound_(ngeoCreateLocationSearchBloodhound, limit); @@ -70,11 +67,11 @@ function SearchController(ngeoCreateLocationSearchBloodhound) { /** * @type {Twitter.Typeahead.Options} */ - this.options = /** @type {Twitter.Typeahead.Options} */ ({ + this.options = /** @type {Twitter.Typeahead.Options} */ { highlight: true, hint: undefined, minLength: undefined, - }); + }; /** * @type {Twitter.Typeahead.Dataset>[]} @@ -105,9 +102,9 @@ function SearchController(ngeoCreateLocationSearchBloodhound) { if (!this.map) { throw new Error('Missing map'); } - const feature = /** @type {import('ol/Feature').default} */ ( - suggestion - ); + const feature = + /** @type {import('ol/Feature').default} */ + suggestion; /** * @type {import('ol/extent').Extent} */ @@ -117,7 +114,10 @@ function SearchController(ngeoCreateLocationSearchBloodhound) { throw new Error('issing size'); } const maxZoom = 16; - this.map.getView().fit(bbox, {size, maxZoom}); + this.map.getView().fit(bbox, { + size, + maxZoom, + }); }, }; } @@ -147,12 +147,10 @@ SearchController.prototype.createAndInitBloodhound_ = function (ngeoCreateLocati bloodhound.initialize(); return bloodhound; }; - appmodule.controller('AppSearchController', SearchController); /** * @class - * @ngInject */ function MainController() { /** @@ -170,8 +168,6 @@ function MainController() { }), }); } - appmodule.controller('MainController', MainController); options(appmodule); - export default module; diff --git a/examples/mapfishprint.js b/examples/mapfishprint.js index d8f18ea72ca4..219e02230b0f 100644 --- a/examples/mapfishprint.js +++ b/examples/mapfishprint.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$timeout', 'ngeoCreatePrint', 'ngeoPrintUtils']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -22,7 +23,6 @@ import angular from 'angular'; import {MAPSERVER_PROXY, PRINT_PROXY} from './url'; import EPSG2056 from 'ngeo/proj/EPSG_2056'; - import ngeoPrintService from 'ngeo/print/Service'; import ngeoPrintUtils from 'ngeo/print/Utils'; import MaskLayer from 'ngeo/print/Mask'; @@ -80,7 +80,6 @@ const PRINT_PAPER_SIZE_ = [555, 675]; * @param {angular.ITimeoutService} $timeout Angular timeout service. * @param {import('ngeo/print/Service').CreatePrint} ngeoCreatePrint The ngeo Create Print function. * @param {import('ngeo/print/Utils').PrintUtils} ngeoPrintUtils The ngeo PrintUtils service. - * @ngInject * @hidden */ function MainController($timeout, ngeoCreatePrint, ngeoPrintUtils) { @@ -137,9 +136,7 @@ function MainController($timeout, ngeoCreatePrint, ngeoPrintUtils) { * @type {import('ngeo/print/Utils').PrintUtils} */ this.printUtils_ = ngeoPrintUtils; - this.maskLayer_ = new MaskLayer(); - this.maskLayer_.getSize = () => PRINT_PAPER_SIZE_; this.maskLayer_.getScale = (frameState) => { const mapSize = frameState.size; @@ -158,7 +155,6 @@ function MainController($timeout, ngeoCreatePrint, ngeoPrintUtils) { */ MainController.prototype.print = function () { const map = this.map; - const mapSize = map.getSize(); const viewResolution = map.getView().getResolution(); @@ -167,21 +163,17 @@ MainController.prototype.print = function () { mapSize !== undefined && viewResolution !== undefined ? this.printUtils_.getOptimalScale(mapSize, viewResolution, PRINT_PAPER_SIZE_, PRINT_SCALES_) : PRINT_SCALES_[0]; - const rotation = map.getView().getRotation(); const dpi = PRINT_DPI_; const format = PRINT_FORMAT_; const layout = PRINT_LAYOUT_; - this.printState = 'Printing...'; - const spec = this.print_.createSpec(map, scale, rotation, dpi, layout, format, { 'datasource': [], 'debug': 0, 'comments': 'My comments', 'title': 'My print', }); - this.print_ .createReport(spec) .then(this.handleCreateReportSuccess_.bind(this), this.handleCreateReportError_.bind(this)); @@ -243,10 +235,7 @@ MainController.prototype.handleGetStatusSuccess_ = function (ref, resp) { MainController.prototype.handleGetStatusError_ = function (resp) { this.printState = 'Print error'; }; - appmodule.controller('MainController', MainController); - appmodule.constant('ngeoTilesPreloadingLimit', 0); options(appmodule); - export default module; diff --git a/examples/mapillarystreetview.js b/examples/mapillarystreetview.js index 2d112d792b38..0445263bfb82 100644 --- a/examples/mapillarystreetview.js +++ b/examples/mapillarystreetview.js @@ -1,3 +1,4 @@ +MainController.$inject = ['ngeoToolActivateMgr']; // The MIT License (MIT) // // Copyright (c) 2021-2024 Camptocamp SA @@ -22,7 +23,6 @@ import './mapillarystreetview.css'; import angular from 'angular'; import olMap from 'ol/Map'; - import olView from 'ol/View'; import olLayerTile from 'ol/layer/WebGLTile'; import olSourceOSM from 'ol/source/OSM'; @@ -49,7 +49,6 @@ const myModule = angular.module('app', [ * @param {import('ngeo/misc/ToolActivateMgr').ToolActivateMgr} ngeoToolActivateMgr * Ngeo ToolActivate manager service. * @class - * @ngInject */ function MainController(ngeoToolActivateMgr) { /** @@ -57,10 +56,15 @@ function MainController(ngeoToolActivateMgr) { */ this.style = new olStyleStyle({ text: new olStyleText({ - fill: new olStyleFill({color: '#279B61'}), + fill: new olStyleFill({ + color: '#279B61', + }), font: '900 30px "Font Awesome 5 Free"', offsetY: -15, - stroke: new olStyleStroke({color: '#ffffff', width: 3}), + stroke: new olStyleStroke({ + color: '#ffffff', + width: 3, + }), text: '\uf041', //map-marker }), }); @@ -79,14 +83,12 @@ function MainController(ngeoToolActivateMgr) { zoom: 17, }), }); - ngeoMapFeatureOverlayMgr.init(this.map); /** * @type {boolean} */ this.streetViewActive = true; - const streetViewToolActivate = new ngeoMiscToolActivate(this, 'streetViewActive'); ngeoToolActivateMgr.registerTool('mapTools', streetViewToolActivate, true); @@ -94,18 +96,14 @@ function MainController(ngeoToolActivateMgr) { * @type {boolean} */ this.dummyActive = false; - const dummyToolActivate = new ngeoMiscToolActivate(this, 'dummyActive'); ngeoToolActivateMgr.registerTool('mapTools', dummyToolActivate, false); } - myModule.controller('MainController', MainController); - myModule.constant('ngeoStreetviewOptions', { viewer: 'mapillary', key: 'd1dNaFk4aDVoVVlZd0dEZG95Wm84QTpkYmRkOGQyMWRkMThiM2E2', bufferSize: 10, // value in pixels }); options(myModule); - export default myModule; diff --git a/examples/mapswipe.js b/examples/mapswipe.js index 2bdd2a16b14b..3d7373fb0bad 100644 --- a/examples/mapswipe.js +++ b/examples/mapswipe.js @@ -34,7 +34,6 @@ const myModule = angular.module('app', ['gettext', gmfMapComponent.name, ngeoMap /** * @class - * @ngInject */ function MainController() { const openStreetMapLayer = new olLayerTile({ @@ -62,14 +61,11 @@ function MainController() { zoom: 15, }), }); - this.gmfLayerBeingSwipe = { layer: this.openSeaMapLayer, swipeValue: 0.5, }; } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/mask.js b/examples/mask.js index dccc1c1b61c2..c4c21ae41473 100644 --- a/examples/mask.js +++ b/examples/mask.js @@ -21,7 +21,6 @@ import angular from 'angular'; import olMap from 'ol/Map'; - import olView from 'ol/View'; import olLayerTile from 'ol/layer/WebGLTile'; import olSourceOSM from 'ol/source/OSM'; @@ -33,7 +32,6 @@ const myModule = angular.module('app', ['gettext', gmfMapComponent.name]); /** * @class - * @ngInject */ function MainController() { /** @@ -51,8 +49,6 @@ function MainController() { }), }); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/measure.js b/examples/measure.js index 428fe7e57e34..7877b373a77e 100644 --- a/examples/measure.js +++ b/examples/measure.js @@ -1,3 +1,4 @@ +MeasuretoolsController.$inject = ['$scope', '$compile', '$sce', '$filter', 'gettextCatalog']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -22,14 +23,11 @@ import './measure.css'; import angular from 'angular'; import ngeoInteractionMeasureArea from 'ngeo/interaction/MeasureArea'; - import ngeoInteractionMeasureAzimut from 'ngeo/interaction/MeasureAzimut'; import ngeoInteractionMeasureLength from 'ngeo/interaction/MeasureLength'; import gmfMapComponent from 'gmf/map/component'; import options from './options'; - import ngeoMiscBtnComponent from 'ngeo/misc/btnComponent'; - import {interactionDecoration} from 'ngeo/misc/decorate'; import ngeoMiscFilters from 'ngeo/misc/filters'; import olMap from 'ol/Map'; @@ -52,16 +50,17 @@ const myModule = angular.module('app', [ ngeoMiscFilters.name, 'ngSanitize', ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('partials/measuretools', require('./partials/measuretools.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('partials/measuretools', require('./partials/measuretools.html')); + }, + ], ); /** @@ -79,7 +78,6 @@ const measuretoolsComponent = { controller: 'AppMeasuretoolsController', templateUrl: 'partials/measuretools', }; - myModule.component('appMeasuretools', measuretoolsComponent); /** @@ -89,7 +87,6 @@ myModule.component('appMeasuretools', measuretoolsComponent); * @param {angular.IFilterService} $filter Angular filter service. * @param {angular.gettext.gettextCatalog} gettextCatalog Gettext catalog. * @class - * @ngInject */ function MeasuretoolsController($scope, $compile, $sce, $filter, gettextCatalog) { /** @@ -175,7 +172,6 @@ function MeasuretoolsController($scope, $compile, $sce, $filter, gettextCatalog) this.measureAzimutContinueMsg = measureAzimutContinueMsgs[newVal]; }, ); - const style = new olStyleStyle({ fill: new olStyleFill({ color: 'rgba(255, 255, 255, 0.2)', @@ -204,7 +200,6 @@ function MeasuretoolsController($scope, $compile, $sce, $filter, gettextCatalog) startMsg: measureStartMsg[0], continueMsg: measureLengthContinueMsg[0], }); - this.measureLength.setActive(false); interactionDecoration(this.measureLength); @@ -216,7 +211,6 @@ function MeasuretoolsController($scope, $compile, $sce, $filter, gettextCatalog) startMsg: measureStartMsg[0], continueMsg: measureAreaContinueMsg[0], }); - this.measureArea.setActive(false); interactionDecoration(this.measureArea); @@ -228,7 +222,6 @@ function MeasuretoolsController($scope, $compile, $sce, $filter, gettextCatalog) startMsg: measureStartMsg[0], continueMsg: measureAzimutContinueMsg[0], }); - this.measureAzimut.setActive(false); interactionDecoration(this.measureAzimut); @@ -236,23 +229,20 @@ function MeasuretoolsController($scope, $compile, $sce, $filter, gettextCatalog) // tooltip. This can be useful to display the elevation offset from the // 2 points of an azimut measurement. this.measureAzimut.on( - /** @type {import('ol/Observable').EventTypes} */ ('measureend'), - /** @type {function(?): ?} */ ( - /** - * @param {import('ol/MapBrowserEvent').default} evt - */ (evt) => { - const target = evt.target; - if (target instanceof Measure) { - const el = target.getTooltipElement(); - el.innerHTML += '
Additional info'; - } + /** @type {import('ol/Observable').EventTypes} */ 'measureend', + /** @type {function(?): ?} */ + /** + * @param {import('ol/MapBrowserEvent').default} evt + */ (evt) => { + const target = evt.target; + if (target instanceof Measure) { + const el = target.getTooltipElement(); + el.innerHTML += '
Additional info'; } - ), + }, ); } - myModule.controller('AppMeasuretoolsController', MeasuretoolsController); - MeasuretoolsController.prototype.$onInit = function () { if (!this.map) { throw new Error('Missing map'); @@ -264,7 +254,6 @@ MeasuretoolsController.prototype.$onInit = function () { /** * @class - * @ngInject */ function MainController() { /** @@ -286,7 +275,6 @@ function MainController() { zoom: 15, }), }); - this.map.addControl( new olControlScaleLine({ // See: https://www.w3.org/TR/CSS21/syndata.html#length-units @@ -294,8 +282,6 @@ function MainController() { }), ); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/mobilegeolocation.js b/examples/mobilegeolocation.js index 65eec586b550..e31495154ff8 100644 --- a/examples/mobilegeolocation.js +++ b/examples/mobilegeolocation.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$scope']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -22,7 +23,6 @@ import './mobilegeolocation.css'; import angular from 'angular'; import olMap from 'ol/Map'; - import olView from 'ol/View'; import olLayerTile from 'ol/layer/WebGLTile'; import olSourceOSM from 'ol/source/OSM'; @@ -37,7 +37,6 @@ const appmodule = angular.module('app', ['gettext', ngeoGeolocation.name, gmfMap /** * @param {angular.IScope} $scope Scope. * @class - * @ngInject */ function MainController($scope) { /** @@ -54,28 +53,33 @@ function MainController($scope) { zoom: 4, }), }); - ngeoMapFeatureOverlayMgr.init(this.map); } - appmodule.controller('MainController', MainController); - appmodule.constant('ngeoGeolocationOptions', { positionFeatureStyle: { circle: { radius: 6, - fill: {color: 'rgba(230, 100, 100, 1)'}, - stroke: {color: 'rgba(230, 40, 40, 1)', width: 2}, + fill: { + color: 'rgba(230, 100, 100, 1)', + }, + stroke: { + color: 'rgba(230, 40, 40, 1)', + width: 2, + }, }, }, accuracyFeatureStyle: { - fill: {color: 'rgba(100, 100, 230, 0.3)'}, - stroke: {color: 'rgba(40, 40, 230, 1)', width: 2}, + fill: { + color: 'rgba(100, 100, 230, 0.3)', + }, + stroke: { + color: 'rgba(40, 40, 230, 1)', + width: 2, + }, }, zoom: 17, autoRotate: true, }); - options(appmodule); - export default appmodule; diff --git a/examples/modal.js b/examples/modal.js index d1d1052d4d6e..f916b2680c4b 100644 --- a/examples/modal.js +++ b/examples/modal.js @@ -27,7 +27,6 @@ const myModule = angular.module('app', ['gettext', ngeoMessageModalComponent.nam /** * @class - * @ngInject */ function MainController() { /** @@ -35,7 +34,5 @@ function MainController() { */ this.modalShown = false; } - myModule.controller('MainController', MainController); - export default myModule; diff --git a/examples/modifycircle.js b/examples/modifycircle.js index bfa6defae7f1..087c80e24c2d 100644 --- a/examples/modifycircle.js +++ b/examples/modifycircle.js @@ -21,7 +21,6 @@ import angular from 'angular'; import ngeoFormatFeatureProperties from 'ngeo/format/FeatureProperties'; - import ngeoInteractionModifyCircle from 'ngeo/interaction/ModifyCircle'; import olMap from 'ol/Map'; import olView from 'ol/View'; @@ -41,7 +40,6 @@ const appmodule = angular.module('app', ['gettext', gmfMapComponent.name]); /** * @class - * @ngInject */ function MainController() { /** @@ -58,16 +56,13 @@ function MainController() { zoom: 4, }), }); - const map = this.map; - const circle = new olGeomCircle([-10691093, 4966327], 465000); /** * @type {import('ol/Collection').default>} */ this.features = new olCollection(); - const circleFeature = new olFeature({ geometry: fromCircle(circle), color: '#000000', @@ -75,10 +70,8 @@ function MainController() { opacity: '0.5', stroke: '2', }); - circleFeature.set(ngeoFormatFeatureProperties.IS_CIRCLE, true); this.features.push(circleFeature); - const vectorSource = new olSourceVector({ features: this.features, }); @@ -94,17 +87,14 @@ function MainController() { * @type {import('ngeo/interaction/ModifyCircle').default} */ this.interaction = new ngeoInteractionModifyCircle( - /** @type {import('ol/interaction/Modify').Options} */ ({ + /** @type {import('ol/interaction/Modify').Options} */ { features: this.features, - }), + }, ); - const interaction = this.interaction; interaction.setActive(true); map.addInteraction(interaction); } - appmodule.controller('MainController', MainController); options(appmodule); - export default module; diff --git a/examples/modifyrectangle.js b/examples/modifyrectangle.js index a6d17b4a7ac0..40062befdd27 100644 --- a/examples/modifyrectangle.js +++ b/examples/modifyrectangle.js @@ -21,7 +21,6 @@ import angular from 'angular'; import ngeoInteractionModifyRectangle from 'ngeo/interaction/ModifyRectangle'; - import olMap from 'ol/Map'; import olView from 'ol/View'; import olLayerTile from 'ol/layer/WebGLTile'; @@ -43,7 +42,6 @@ const appmodule = angular.module('app', ['gettext', gmfMapComponent.name]); /** * @class - * @ngInject */ function MainController() { /** @@ -60,9 +58,7 @@ function MainController() { zoom: 4, }), }); - const map = this.map; - const rectangle = new olGeomPolygon([ [ [-9e6, 4e6], @@ -76,7 +72,6 @@ function MainController() { * @type {import('ol/Collection').default>} */ this.features = new olCollection(); - this.features.push( new olFeature({ geometry: rectangle, @@ -107,7 +102,6 @@ function MainController() { }), }), ]; - styles.Point = [ new olStyleStyle({ image: new olStyleCircle({ @@ -124,7 +118,6 @@ function MainController() { }), ]; styles.GeometryCollection = styles.Polygon.concat(styles.Point); - return ( /** * @param {olFeature|import('ol/render/Feature').default} feature @@ -139,7 +132,6 @@ function MainController() { } ); })(); - const vectorSource = new olSourceVector({ features: this.features, }); @@ -155,18 +147,15 @@ function MainController() { * @type {import('ngeo/interaction/ModifyRectangle').default} */ this.interaction = new ngeoInteractionModifyRectangle( - /** @type {import('ol/interaction/Modify').Options} */ ({ + /** @type {import('ol/interaction/Modify').Options} */ { features: this.features, style: style, - }), + }, ); - const interaction = this.interaction; map.addInteraction(interaction); interaction.setActive(true); } - appmodule.controller('MainController', MainController); options(appmodule); - export default module; diff --git a/examples/notification.js b/examples/notification.js index 795467109da7..dccf2bda483a 100644 --- a/examples/notification.js +++ b/examples/notification.js @@ -23,14 +23,12 @@ import './notification.css'; import 'bootstrap/js/src/tooltip'; import angular from 'angular'; import {MessageType} from 'ngeo/message/Message'; - import ngeoMessageNotification from 'ngeo/message/Notification'; /** @type {angular.IModule} **/ const myModule = angular.module('app', ['gettext']); /** - * @ngInject * @class */ function MainController() { @@ -70,23 +68,18 @@ MainController.prototype.notifyMulti = function () { }, ]); }; - MainController.prototype.success = function (msg) { ngeoMessageNotification.success(msg); }; - MainController.prototype.warn = function (msg) { ngeoMessageNotification.warn(msg); }; - MainController.prototype.info = function (msg) { ngeoMessageNotification.info(msg); }; - MainController.prototype.error = function (msg) { ngeoMessageNotification.error(msg); }; - MainController.prototype.clear = function () { ngeoMessageNotification.clear(); }; @@ -113,7 +106,5 @@ MainController.prototype.notifyQuick = function () { type: MessageType.SUCCESS, }); }; - myModule.controller('MainController', MainController); - export default myModule; diff --git a/examples/permalink.js b/examples/permalink.js index 0022af75f571..09afbb75f40e 100644 --- a/examples/permalink.js +++ b/examples/permalink.js @@ -1,3 +1,5 @@ +DrawComponentController.$inject = ['$scope', 'ngeoLocation']; +MapComponentController.$inject = ['ngeoLocation', 'ngeoDebounce']; // The MIT License (MIT) // // Copyright (c) 2014-2024 Camptocamp SA @@ -61,7 +63,6 @@ const mapComponent = { }, template: '', }; - myModule.component('appMap', mapComponent); /** @@ -69,7 +70,6 @@ myModule.component('appMap', mapComponent); * @param {import('ngeo/misc/debounce').miscDebounce} ngeoDebounce * ngeo Debounce factory. * @class - * @ngInject */ function MapComponentController(ngeoLocation, ngeoDebounce) { /** @@ -87,54 +87,46 @@ function MapComponentController(ngeoLocation, ngeoDebounce) { */ this.ngeoDebounce_ = ngeoDebounce; } - myModule.controller('AppMapController', MapComponentController); - MapComponentController.prototype.$onInit = function () { if (!this.map) { throw new Error('Missing map'); } const view = this.map.getView(); - const zoom_ = this.ngeoLocation_.getParam('z'); const zoom = zoom_ !== undefined ? +zoom_ : 4; - const x = this.ngeoLocation_.getParam('x'); const y = this.ngeoLocation_.getParam('y'); const center = x !== undefined && y !== undefined ? [+x, +y] : [0, 0]; - view.setCenter(center); view.setZoom(zoom); - this.ngeoLocation_.updateParams({ 'z': `${zoom}`, 'x': `${Math.round(center[0])}`, 'y': `${Math.round(center[1])}`, }); - view.on( - /** @type {import('ol/Observable').EventTypes} */ ('propertychange'), - /** @type {function(?): ?} */ ( - this.ngeoDebounce_( - /** - * @param {import('ol/events/Event').default} e Object event. - */ - // @ts-ignore - (e) => { - const center = view.getCenter(); - if (!center) { - throw new Error('Missing center'); - } - const params = { - 'z': `${view.getZoom()}`, - 'x': `${Math.round(center[0])}`, - 'y': `${Math.round(center[1])}`, - }; - this.ngeoLocation_.updateParams(params); - }, - 300, - /* invokeApply */ true, - ) + /** @type {import('ol/Observable').EventTypes} */ 'propertychange', + /** @type {function(?): ?} */ + this.ngeoDebounce_( + /** + * @param {import('ol/events/Event').default} e Object event. + */ + // @ts-ignore + (e) => { + const center = view.getCenter(); + if (!center) { + throw new Error('Missing center'); + } + const params = { + 'z': `${view.getZoom()}`, + 'x': `${Math.round(center[0])}`, + 'y': `${Math.round(center[1])}`, + }; + this.ngeoLocation_.updateParams(params); + }, + 300, + /* invokeApply */ true, ), ); }; @@ -156,14 +148,12 @@ const drawComponent = { '
' + '', }; - myModule.component('appDraw', drawComponent); /** * @param {angular.IScope} $scope Scope. * @param {import('ngeo/statemanager/Location').StatemanagerLocation} ngeoLocation ngeo Location service. * @class - * @ngInject */ function DrawComponentController($scope, ngeoLocation) { /** @@ -196,7 +186,6 @@ function DrawComponentController($scope, ngeoLocation) { */ this.interaction = null; } - DrawComponentController.prototype.$onInit = function () { if (!this.map) { throw new Error('Missing map'); @@ -208,66 +197,61 @@ DrawComponentController.prototype.$onInit = function () { * @type {olSourceVector} */ const vectorSource = this.layer.getSource(); - this.interaction = new olInteractionDraw({ type: 'LineString', source: vectorSource, }); - this.interaction.setActive(false); this.map.addInteraction(this.interaction); interactionDecoration(this.interaction); - this.interaction.on( - /** @type {import('ol/Observable').EventTypes} */ ('drawend'), - /** @type {function(?): ?} */ ( - /** - * @param {import('ol/MapBrowserEvent').default} e - */ (e) => { - // @ts-ignore - e.feature.set('id', ++this.featureSeq_); - } - ), + /** @type {import('ol/Observable').EventTypes} */ 'drawend', + /** @type {function(?): ?} */ + /** + * @param {import('ol/MapBrowserEvent').default} e + */ (e) => { + // @ts-ignore + e.feature.set('id', ++this.featureSeq_); + }, ); // Deal with the encoding and decoding of features in the URL. const fhFormat = new ngeoFormatFeatureHash(); - vectorSource.on( - /** @type {import('ol/Observable').EventTypes} */ ('addfeature'), - /** @type {function(?): ?} */ ( - /** - * @param {import('ol/MapBrowserEvent').default} e - */ (e) => { - // @ts-ignore - const feature = e.feature; - feature.setStyle( - new olStyleStyle({ - stroke: new olStyleStroke({ - color: [255, 0, 0, 1], - width: 2, - }), + /** @type {import('ol/Observable').EventTypes} */ 'addfeature', + /** @type {function(?): ?} */ + /** + * @param {import('ol/MapBrowserEvent').default} e + */ (e) => { + // @ts-ignore + const feature = e.feature; + feature.setStyle( + new olStyleStyle({ + stroke: new olStyleStroke({ + color: [255, 0, 0, 1], + width: 2, }), - ); - const features = vectorSource.getFeatures(); - const encodedFeatures = fhFormat.writeFeatures(features); - if (typeof encodedFeatures == 'string') { - this.scope_.$applyAsync(() => { - this.ngeoLocation_.updateParams({'features': encodedFeatures}); + }), + ); + const features = vectorSource.getFeatures(); + const encodedFeatures = fhFormat.writeFeatures(features); + if (typeof encodedFeatures == 'string') { + this.scope_.$applyAsync(() => { + this.ngeoLocation_.updateParams({ + 'features': encodedFeatures, }); - } else { - console.error(`Unsupported type: ${typeof encodedFeatures}`); - } + }); + } else { + console.error(`Unsupported type: ${typeof encodedFeatures}`); } - ), + }, ); - const encodedFeatures = this.ngeoLocation_.getParam('features'); if (encodedFeatures !== undefined) { - const features = /** @type {import('ol/Feature').default[]} */ ( - fhFormat.readFeatures(encodedFeatures) - ); + const features = + /** @type {import('ol/Feature').default[]} */ + fhFormat.readFeatures(encodedFeatures); this.featureSeq_ = features.length; vectorSource.addFeatures(features); } @@ -288,7 +272,6 @@ DrawComponentController.prototype.clearLayer = function () { this.featureSeq_ = 0; this.ngeoLocation_.deleteParam('features'); }; - myModule.controller('AppDrawController', DrawComponentController); /** @@ -305,7 +288,6 @@ function MainController() { }), ], }); - const vectorSource = new olSourceVector(); /** @@ -319,8 +301,6 @@ function MainController() { // makes the vector layer "unmanaged", meaning that it is always on top. this.vectorLayer.setMap(this.map); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/popupservice.js b/examples/popupservice.js index ae5d44744976..6f56d0b57593 100644 --- a/examples/popupservice.js +++ b/examples/popupservice.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$sce', 'ngeoCreatePopup']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -30,7 +31,6 @@ const myModule = angular.module('app', ['gettext', ngeoMessagePopup.name]); /** * @param {angular.ISCEService} $sce Angular sce service. * @param {import('ngeo/message/Popup').PopupFactory} ngeoCreatePopup Popup service. - * @ngInject * @class */ function MainController($sce, ngeoCreatePopup) { @@ -130,7 +130,5 @@ MainController.prototype.openPopupWithUrl = function () { width: '400px', }); }; - myModule.controller('MainController', MainController); - export default myModule; diff --git a/examples/query.js b/examples/query.js index cc7826b1daa4..25acb12f8ed5 100644 --- a/examples/query.js +++ b/examples/query.js @@ -1,3 +1,5 @@ +MainController.$inject = ['ngeoDataSources', 'ngeoToolActivateMgr', 'ngeoQueryModeSelector']; +QueryresultController.$inject = ['ngeoQueryResult']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -24,20 +26,16 @@ import {MAPSERVER_PROXY, MAPSERVER_WFS_FEATURE_NS} from './url'; import './base.css'; import './query.css'; import EPSG2056 from 'ngeo/proj/EPSG_2056'; - import ngeoDatasourceDataSources from 'ngeo/datasource/DataSources'; import gmfDatasourceOGC from 'gmf/datasource/OGC'; import gmfMapComponent from 'gmf/map/component'; import options from './options'; - import ngeoMiscBtnComponent from 'ngeo/misc/btnComponent'; - import ngeoMiscToolActivate from 'ngeo/misc/ToolActivate'; import ngeoMiscToolActivateMgr from 'ngeo/misc/ToolActivateMgr'; import ngeoQueryComponent from 'ngeo/query/component'; import ngeoQueryPanelComponent from 'ngeo/query/panelComponent'; import ngeoQueryModule from 'ngeo/query/module'; - import olMap from 'ol/Map'; import olView from 'ol/View'; import olLayerImage from 'ol/layer/Image'; @@ -56,18 +54,18 @@ const myModule = angular.module('app', [ ngeoQueryPanelComponent.name, ngeoQueryModule.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('partials/queryresult', require('./partials/queryresult.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('partials/queryresult', require('./partials/queryresult.html')); + }, + ], ); - myModule.value('ngeoQueryOptions', { 'cursorHover': true, 'limit': 20, @@ -82,13 +80,11 @@ const queryresultComponent = { controller: 'AppQueryresultController', templateUrl: 'partials/queryresult', }; - myModule.component('appQueryresult', queryresultComponent); /** * @param {import('ngeo/query/MapQuerent').QueryResult} ngeoQueryResult The ngeo query service. * @class - * @ngInject */ function QueryresultController(ngeoQueryResult) { /** @@ -96,7 +92,6 @@ function QueryresultController(ngeoQueryResult) { */ this.result = ngeoQueryResult; } - myModule.controller('AppQueryresultController', QueryresultController); /** @@ -105,7 +100,6 @@ myModule.controller('AppQueryresultController', QueryresultController); * manager. * @param {import('ngeo/query/ModeSelector').QueryModeSelector} ngeoQueryModeSelector The ngeo QueryModeSelector service * @class - * @ngInject */ function MainController(ngeoDataSources, ngeoToolActivateMgr, ngeoQueryModeSelector) { /** @@ -127,18 +121,20 @@ function MainController(ngeoDataSources, ngeoToolActivateMgr, ngeoQueryModeSelec * @type {import('ngeo/query/ModeSelector').QueryModeSelector} */ this.ngeoQueryModeSelector = ngeoQueryModeSelector; - const source1 = new olSourceImageWMS({ url: MAPSERVER_PROXY, - params: {'LAYERS': 'bus_stop'}, + params: { + 'LAYERS': 'bus_stop', + }, }); const busStopLayer = new olLayerImage({ source: source1, }); - const source2 = new olSourceImageWMS({ url: MAPSERVER_PROXY, - params: {'LAYERS': 'information'}, + params: { + 'LAYERS': 'information', + }, }); const informationLayer = new olLayerImage({ source: source2, @@ -162,9 +158,7 @@ function MainController(ngeoDataSources, ngeoToolActivateMgr, ngeoQueryModeSelec zoom: 4, }), }); - ngeoDataSources.map = this.map; - ngeoDataSources.collection.push( new gmfDatasourceOGC({ id: 1, @@ -187,7 +181,6 @@ function MainController(ngeoDataSources, ngeoToolActivateMgr, ngeoQueryModeSelec ], }), ); - ngeoDataSources.collection.push( new gmfDatasourceOGC({ id: 2, @@ -210,10 +203,8 @@ function MainController(ngeoDataSources, ngeoToolActivateMgr, ngeoQueryModeSelec ], }), ); - const queryToolActivate = new ngeoMiscToolActivate(this, 'queryActive'); ngeoToolActivateMgr.registerTool('mapTools', queryToolActivate); - const dummyToolActivate = new ngeoMiscToolActivate(this, 'dummyActive'); ngeoToolActivateMgr.registerTool('mapTools', dummyToolActivate, true); } @@ -229,12 +220,10 @@ MainController.prototype.getSetQueryActive = function (val) { return this.queryActive; } }; - myModule.controller('MainController', MainController); myModule.constant('ngeoMeasurePrecision', 0); myModule.constant('ngeoMeasureDecimals', 0); myModule.constant('ngeoMeasureSpherical', false); myModule.constant('ngeoPointfilter', null); options(myModule); - export default myModule; diff --git a/examples/recenter.js b/examples/recenter.js index 7665f21c6f67..12891705d26e 100644 --- a/examples/recenter.js +++ b/examples/recenter.js @@ -21,7 +21,6 @@ import angular from 'angular'; import olMap from 'ol/Map'; - import olView from 'ol/View'; import olLayerTile from 'ol/layer/WebGLTile'; import olSourceOSM from 'ol/source/OSM'; @@ -33,7 +32,6 @@ const appmodule = angular.module('app', ['gettext', gmfMapComponent.name]); /** * @class - * @ngInject */ function MainController() { /** @@ -51,8 +49,6 @@ function MainController() { }), }); } - appmodule.controller('MainController', MainController); options(appmodule); - export default module; diff --git a/examples/rotate.js b/examples/rotate.js index e0ff4ecf44b1..84a30d531431 100644 --- a/examples/rotate.js +++ b/examples/rotate.js @@ -21,7 +21,6 @@ import angular from 'angular'; import ngeoInteractionRotate from 'ngeo/interaction/Rotate'; - import olCollection from 'ol/Collection'; import olFeature from 'ol/Feature'; import olMap from 'ol/Map'; @@ -47,7 +46,6 @@ const appmodule = angular.module('app', ['ngeo']); /** * @class - * @ngInject */ function MainController() { /** @@ -64,9 +62,7 @@ function MainController() { zoom: 4, }), }); - const map = this.map; - const polygon = new olGeomPolygon([ [ [-9e6, 4e6], @@ -80,13 +76,11 @@ function MainController() { * @type {import('ol/Collection').default>} */ this.features = new olCollection(); - this.features.push( new olFeature({ geometry: polygon, }), ); - const vectorSource = new olSourceVector({ features: this.features, }); @@ -131,9 +125,7 @@ function MainController() { }), }), }); - styles.GeometryCollection = styles.Polygon.concat(styles.Point); - return ( /** * @param {olFeature|import('ol/render/Feature').default} feature @@ -153,33 +145,28 @@ function MainController() { * @type {import('ngeo/interaction/Rotate').default} */ this.interaction = new ngeoInteractionRotate( - /** @type {import('ol/interaction/Modify').Options} */ ({ + /** @type {import('ol/interaction/Modify').Options} */ { features: this.features, layers: [vectorLayer], style: style, - }), + }, ); - const interaction = this.interaction; interaction.setActive(false); map.addInteraction(interaction); - map.on( - /** @type {import('ol/Observable').EventTypes} */ ('singleclick'), - /** @type {function(?): ?} */ ( - /** - * @param {import('ol/MapBrowserEvent').default} evt - */ (evt) => { - const feature = this.map.forEachFeatureAtPixel(evt.pixel, (feature) => feature); - if (feature) { - this.interaction.setActive(true); - } + /** @type {import('ol/Observable').EventTypes} */ 'singleclick', + /** @type {function(?): ?} */ + /** + * @param {import('ol/MapBrowserEvent').default} evt + */ (evt) => { + const feature = this.map.forEachFeatureAtPixel(evt.pixel, (feature) => feature); + if (feature) { + this.interaction.setActive(true); } - ), + }, ); } - appmodule.controller('MainController', MainController); options(appmodule); - export default myModule; diff --git a/examples/routing.js b/examples/routing.js index e9a27068fdd3..71cf51536725 100644 --- a/examples/routing.js +++ b/examples/routing.js @@ -26,7 +26,6 @@ import './routing.css'; import 'ol/ol.css'; import 'bootstrap/dist/css/bootstrap.css'; import '@fortawesome/fontawesome-free/css/fontawesome.min.css'; - import angular from 'angular'; import gmfMapComponent from 'gmf/map/component'; import options from './options'; @@ -43,7 +42,6 @@ const myModule = angular.module('app', ['gettext', gmfMapComponent.name, ngeoRou * The application's main directive. * * @class - * @ngInject */ function MainController() { /** @@ -66,11 +64,9 @@ function MainController() { */ this.routingPanelActive = true; } - myModule.controller('MainController', MainController); myModule.constant('ngeoRoutingOptions', {}); myModule.constant('ngeoNominatimUrl', 'https://nominatim.openstreetmap.org/'); myModule.constant('ngeoNominatimSearchDefaultParams', {}); options(myModule); - export default myModule; diff --git a/examples/scaleselector.js b/examples/scaleselector.js index 0fb2155f3a0d..57e6644a333a 100644 --- a/examples/scaleselector.js +++ b/examples/scaleselector.js @@ -1,3 +1,4 @@ +MainController.$inject = ['$scope']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -22,7 +23,6 @@ import './scaleselector.css'; import angular from 'angular'; import ngeoScaleSelector from 'ngeo/map/scaleselector'; - import olMap from 'ol/Map'; import olView from 'ol/View'; import olLayerTile from 'ol/layer/WebGLTile'; @@ -36,7 +36,6 @@ const myModule = angular.module('app', ['gettext', ngeoScaleSelector.name, gmfMa /** * @class * @param {angular.IScope} $scope Controller scope. - * @ngInject */ function MainController($scope) { /** @@ -55,12 +54,10 @@ function MainController($scope) { }), }); } - myModule.controller('MainController', MainController); myModule.constant('ngeoScaleSelectorOptions', { values: [600000000, 300000000, 150000000, 70000000, 40000000], dropup: true, }); options(myModule); - export default myModule; diff --git a/examples/search.js b/examples/search.js index a4f19f927f4f..7313ba2e2608 100644 --- a/examples/search.js +++ b/examples/search.js @@ -1,3 +1,4 @@ +SearchController.$inject = ['$element', '$rootScope', '$compile', 'ngeoSearchCreateGeoJSONBloodhound']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -22,7 +23,6 @@ import angular from 'angular'; import {SEARCH} from './url'; import './search.css'; - import gmfMapComponent from 'gmf/map/component'; import options from './options'; import {proj as EPSG2056} from 'ngeo/proj/EPSG_2056'; @@ -53,7 +53,6 @@ const searchComponent = { 'ngeo-search-datasets="$ctrl.datasets" ' + 'ngeo-search-listeners="$ctrl.listeners">', }; - myModule.component('appSearch', searchComponent); /** @@ -63,7 +62,6 @@ myModule.component('appSearch', searchComponent); * @param {angular.ICompileService} $compile Angular compile service. * @param {Function} ngeoSearchCreateGeoJSONBloodhound * The ngeo create GeoJSON Bloodhound service. - * @ngInject */ function SearchController($element, $rootScope, $compile, ngeoSearchCreateGeoJSONBloodhound) { /** @@ -87,11 +85,11 @@ function SearchController($element, $rootScope, $compile, ngeoSearchCreateGeoJSO /** * @type {Twitter.Typeahead.Options} */ - this.options = /** @type {Twitter.Typeahead.Options} */ ({ + this.options = /** @type {Twitter.Typeahead.Options} */ { highlight: true, hint: undefined, minLength: undefined, - }); + }; /** * @type {Twitter.Typeahead.Dataset>[]} @@ -100,17 +98,17 @@ function SearchController($element, $rootScope, $compile, ngeoSearchCreateGeoJSO { source: bloodhoundEngine.ttAdapter(), display: (suggestion) => { - const feature = /** @type {import('ol/Feature').default} */ ( - suggestion - ); + const feature = + /** @type {import('ol/Feature').default} */ + suggestion; return feature.get('label'); }, templates: { header: () => '
Addresses
', suggestion: (suggestion) => { - const feature = /** @type {import('ol/Feature').default} */ ( - suggestion - ); + const feature = + /** @type {import('ol/Feature').default} */ + suggestion; // A scope for the ng-click on the suggestion's « i » button. const scope = $rootScope.$new(true); @@ -121,7 +119,6 @@ function SearchController($element, $rootScope, $compile, ngeoSearchCreateGeoJSO window.alert(feature.get('label')); event.stopPropagation(); }; - const html = `

${feature.get('label')}

`; return $compile(html)(scope).html(); }, @@ -137,9 +134,9 @@ function SearchController($element, $rootScope, $compile, ngeoSearchCreateGeoJSO if (!this.map) { throw new Error('Missing map'); } - const feature = /** @type {import('ol/Feature').default} */ ( - suggestion - ); + const feature = + /** @type {import('ol/Feature').default} */ + suggestion; const featureGeometry = feature.getGeometry(); if (!(featureGeometry instanceof SimpleGeometry)) { throw new Error('Missing Wrong geometry type'); @@ -200,12 +197,10 @@ SearchController.prototype.createAndInitBloodhound_ = function (ngeoSearchCreate bloodhound.initialize(); return bloodhound; }; - myModule.controller('AppSearchController', SearchController); /** * @class - * @ngInject */ function MainController() { /** @@ -223,8 +218,6 @@ function MainController() { }), }); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/simple.js b/examples/simple.js index dccc1c1b61c2..c4c21ae41473 100644 --- a/examples/simple.js +++ b/examples/simple.js @@ -21,7 +21,6 @@ import angular from 'angular'; import olMap from 'ol/Map'; - import olView from 'ol/View'; import olLayerTile from 'ol/layer/WebGLTile'; import olSourceOSM from 'ol/source/OSM'; @@ -33,7 +32,6 @@ const myModule = angular.module('app', ['gettext', gmfMapComponent.name]); /** * @class - * @ngInject */ function MainController() { /** @@ -51,8 +49,6 @@ function MainController() { }), }); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/examples/svg.js b/examples/svg.js index 2c609c714ea2..6bd24509b9fb 100644 --- a/examples/svg.js +++ b/examples/svg.js @@ -22,7 +22,6 @@ import angular from 'angular'; import './svg.css'; import EPSG2056 from 'ngeo/proj/EPSG_2056'; - import Map from 'ol/Map'; import View from 'ol/View'; import LayerVector from 'ol/layer/Vector'; @@ -31,7 +30,6 @@ import Feature from 'ol/Feature'; import Point from 'ol/geom/Point'; import Style from 'ol/style/Style'; import Icon from 'ol/style/Icon'; - import gmfMapComponent from 'gmf/map/component'; import options from './options'; @@ -40,7 +38,6 @@ const appmodule = angular.module('app', ['gettext', gmfMapComponent.name]); /** * @class - * @ngInject * @hidden */ function MainController() { @@ -59,7 +56,6 @@ function MainController() { }), ]); source.addFeature(feature1); - const feature2 = new Feature({ geometry: new Point([2600000, 1200000]), }); @@ -74,7 +70,6 @@ function MainController() { }), ]); source.addFeature(feature2); - const feature3 = new Feature({ geometry: new Point([2601000, 1200000]), }); @@ -89,7 +84,6 @@ function MainController() { }), ]); source.addFeature(feature3); - this.map = new Map({ layers: [ new LayerVector({ @@ -104,8 +98,6 @@ function MainController() { }), }); } - appmodule.controller('MainController', MainController); options(appmodule); - export default appmodule; diff --git a/examples/toolActivate.js b/examples/toolActivate.js index 6b450541d9df..ac61c8e0f4b2 100644 --- a/examples/toolActivate.js +++ b/examples/toolActivate.js @@ -1,3 +1,4 @@ +MainController.$inject = ['ngeoToolActivateMgr']; // The MIT License (MIT) // // Copyright (c) 2014-2024 Camptocamp SA @@ -22,10 +23,8 @@ import angular from 'angular'; import gmfMapComponent from 'gmf/map/component'; import options from './options'; - import ngeoMiscBtnComponent from 'ngeo/misc/btnComponent'; import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; - import {interactionDecoration} from 'ngeo/misc/decorate'; import ngeoMiscToolActivate from 'ngeo/misc/ToolActivate'; import ngeoMiscToolActivateMgr from 'ngeo/misc/ToolActivateMgr'; @@ -52,7 +51,6 @@ const myModule = angular.module('app', [ /** * @param {import('ngeo/misc/ToolActivateMgr').ToolActivateMgr} ngeoToolActivateMgr ToolActivate manager. * @class - * @ngInject */ function MainController(ngeoToolActivateMgr) { /** @@ -69,7 +67,6 @@ function MainController(ngeoToolActivateMgr) { zoom: 4, }), }); - const map = this.map; // initialize the feature overlay manager with the map @@ -82,7 +79,6 @@ function MainController(ngeoToolActivateMgr) { * @type {import('ol/Collection').default>} */ const features = new olCollection(); - const overlay = ngeoMapFeatureOverlayMgr.getFeatureOverlay(); overlay.setFeatures(features); overlay.setStyle( @@ -110,20 +106,18 @@ function MainController(ngeoToolActivateMgr) { throw new Error('Missing content'); } this.map.on( - /** @type {import('ol/Observable').EventTypes} */ ('singleclick'), - /** @type {function(?): ?} */ ( - /** - * @param {import('ol/MapBrowserEvent').default} evt - */ - (evt) => { - if (this.mapClickIsEnabled) { - const c = olCoordinate.toStringXY(evt.coordinate); - content.innerHTML = `

You clicked here: ${c}

`; - } + /** @type {import('ol/Observable').EventTypes} */ 'singleclick', + /** @type {function(?): ?} */ + /** + * @param {import('ol/MapBrowserEvent').default} evt + */ + (evt) => { + if (this.mapClickIsEnabled) { + const c = olCoordinate.toStringXY(evt.coordinate); + content.innerHTML = `

You clicked here: ${c}

`; } - ), + }, ); - const mapClickTool = new ngeoMiscToolActivate(this, 'mapClickIsEnabled'); ngeoToolActivateMgr.registerTool('mapTools', mapClickTool, true); @@ -132,15 +126,14 @@ function MainController(ngeoToolActivateMgr) { * @type {import('ol/interaction/Draw').default} */ this.drawPoint = new olInteractionDraw( - /** @type {import('ol/interaction/Draw').Options} */ ({ + /** @type {import('ol/interaction/Draw').Options} */ { type: 'Point', features: features, - }), + }, ); this.drawPoint.setActive(false); interactionDecoration(this.drawPoint); map.addInteraction(this.drawPoint); - const drawPointTool = new ngeoMiscToolActivate(this.drawPoint, 'active'); ngeoToolActivateMgr.registerTool('mapTools', drawPointTool); @@ -149,15 +142,14 @@ function MainController(ngeoToolActivateMgr) { * @type {import('ol/interaction/Draw').default} */ this.drawLine = new olInteractionDraw( - /** @type {import('ol/interaction/Draw').Options} */ ({ + /** @type {import('ol/interaction/Draw').Options} */ { type: 'LineString', features: features, - }), + }, ); this.drawLine.setActive(false); interactionDecoration(this.drawLine); map.addInteraction(this.drawLine); - const drawLineTool = new ngeoMiscToolActivate(this.drawLine, 'active'); ngeoToolActivateMgr.registerTool('mapTools', drawLineTool); @@ -166,20 +158,17 @@ function MainController(ngeoToolActivateMgr) { * @type {import('ol/interaction/Draw').default} */ this.drawPolygon = new olInteractionDraw( - /** @type {import('ol/interaction/Draw').Options} */ ({ + /** @type {import('ol/interaction/Draw').Options} */ { type: 'Polygon', features: features, - }), + }, ); this.drawPolygon.setActive(false); interactionDecoration(this.drawPolygon); map.addInteraction(this.drawPolygon); - const drawPolygonTool = new ngeoMiscToolActivate(this.drawPolygon, 'active'); ngeoToolActivateMgr.registerTool('mapTools', drawPolygonTool); } - myModule.controller('MainController', MainController); options(myModule); - export default myModule; diff --git a/package.json b/package.json index f8ad212e062a..a5d4a12c308f 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,6 @@ "angular-ui-date": "1.1.1", "angular-ui-slider": "0.4.0", "babel-loader": "8.3.0", - "babel-plugin-angularjs-annotate": "0.10.0", "bootstrap": "4.6.2", "cheerio": "1.0.0-rc.12", "chokidar": "3.6.0", diff --git a/src/backgroundlayerselector/component.js b/src/backgroundlayerselector/component.js index 04d33e5662f7..0d31867a4e3b 100644 --- a/src/backgroundlayerselector/component.js +++ b/src/backgroundlayerselector/component.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$scope', 'ngeoBackgroundLayerMgr', 'gmfThemes', 'gmfBackgroundLayerSelectorOptions']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -33,7 +34,6 @@ const myModule = angular.module('gmfBackgroundlayerselector', [ gmfThemeThemes.name, ngeoMapBackgroundLayerMgr.name, ]); - myModule.value( 'gmfBackgroundlayerselectorTemplateUrl', /** @@ -46,16 +46,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'gmf/backgroundlayerselector'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/backgroundlayerselector', require('./component.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/backgroundlayerselector', require('./component.html')); + }, + ], ); /** @@ -64,10 +65,14 @@ myModule.run( * @param {function(JQuery, angular.IAttributes): string} gmfBackgroundlayerselectorTemplateUrl * Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfBackgroundlayerselectorTemplateUrl.$inject = [ + '$element', + '$attrs', + 'gmfBackgroundlayerselectorTemplateUrl', +]; function gmfBackgroundlayerselectorTemplateUrl($element, $attrs, gmfBackgroundlayerselectorTemplateUrl) { return gmfBackgroundlayerselectorTemplateUrl($element, $attrs); } @@ -104,7 +109,6 @@ const backgroundlayerselectorComponent = { }, templateUrl: gmfBackgroundlayerselectorTemplateUrl, }; - myModule.component('gmfBackgroundlayerselector', backgroundlayerselectorComponent); /** @@ -115,7 +119,6 @@ myModule.component('gmfBackgroundlayerselector', backgroundlayerselectorComponen * Background layer manager. * @param {import('gmf/theme/Themes').ThemesService} gmfThemes Themes service. * @param {import('gmf/options').gmfBackgroundLayerSelectorOptions} gmfBackgroundLayerSelectorOptions The options - * @ngInject * @ngdoc controller * @ngname GmfBackgroundlayerselectorController */ @@ -161,14 +164,12 @@ export function Controller($scope, ngeoBackgroundLayerMgr, gmfThemes, gmfBackgro * @type {import('ol/events').EventsKey[]} */ this.listenerKeys_ = []; - this.listenerKeys_.push(listen(gmfThemes, 'change', this.handleThemesChange_, this)); /** * @type {import('ngeo/map/BackgroundLayerMgr').MapBackgroundLayerManager} */ this.backgroundLayerMgr_ = ngeoBackgroundLayerMgr; - this.listenerKeys_.push( listen( this.backgroundLayerMgr_, @@ -177,11 +178,10 @@ export function Controller($scope, ngeoBackgroundLayerMgr, gmfThemes, gmfBackgro (event) => { this.bgLayer = /** @type {import('ngeo/map/BackgroundLayerMgr').BackgroundEvent} */ - (event).detail.current; + event.detail.current; }, ), ); - $scope.$on('$destroy', this.handleDestroy_.bind(this)); } @@ -198,7 +198,6 @@ Controller.prototype.$onInit = function () { Controller.prototype.handleThemesChange_ = function () { this.gmfThemes_.getBgLayers().then((layers) => { this.bgLayers = layers; - if (this.options.opacityLayer !== undefined) { const opacityLayer = layers.find((layer) => layer.get('label') === this.options.opacityLayer); if (opacityLayer !== undefined) { @@ -266,12 +265,9 @@ Controller.prototype.setOpacityBgLayer = function (layer) { } this.backgroundLayerMgr_.setOpacityBgLayer(this.map, layer); }; - Controller.prototype.handleDestroy_ = function () { this.listenerKeys_.forEach(unlistenByKey); this.listenerKeys_.length = 0; }; - myModule.controller('GmfBackgroundlayerselectorController', Controller); - export default myModule; diff --git a/src/contextualdata/component.js b/src/contextualdata/component.js index 9640d2fa4415..a89487694030 100644 --- a/src/contextualdata/component.js +++ b/src/contextualdata/component.js @@ -1,3 +1,12 @@ +contextualDataComponentContent.$inject = ['gmfContextualdatacontentTemplateUrl']; +ContextualdataController.$inject = [ + '$compile', + '$timeout', + '$scope', + 'gmfRaster', + 'gmfContextualDataOptions', + 'ngeoAutoProjection', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -92,7 +101,6 @@ function contextualDataComponent() { }, }; } - myModule.directive('gmfContextualdata', contextualDataComponent); /** @@ -106,7 +114,6 @@ myModule.directive('gmfContextualdata', contextualDataComponent); * @class * @hidden * @ngdoc controller - * @ngInject */ export function ContextualdataController( $compile, @@ -180,10 +187,9 @@ export function ContextualdataController( * @type {import('ngeo/misc/AutoProjection').AutoProjectionService} */ this.ngeoAutoProjection = ngeoAutoProjection; - document.body.addEventListener('mousedown', (event) => { const element = this.overlay_.getElement(); - const target = /** @type {Node} */ (event.target); + const target = /** @type {Node} */ event.target; // don't close if the user click the popup itself. this allows the text to be copied. if (!element.contains(target)) { this.$scope_.$apply(() => { @@ -201,12 +207,10 @@ ContextualdataController.prototype.init = function () { this.options.projections === undefined ? [this.map.getView().getProjection()] : this.ngeoAutoProjection.getProjectionList(this.options.projections); - this.preparePopover_(); if (!this.map) { throw new Error('Missing map'); } - const mapDiv = this.map.getTargetElement(); if (!mapDiv) { throw new Error('Missing mapDiv'); @@ -217,8 +221,7 @@ ContextualdataController.prototype.init = function () { mapDiv.addEventListener('touchstart', this.handleMapTouchStart_.bind(this)); mapDiv.addEventListener('touchmove', this.handleMapTouchEnd_.bind(this)); mapDiv.addEventListener('touchend', this.handleMapTouchEnd_.bind(this)); - - this.map.on(/** @type {import('ol/Observable').EventTypes} */ ('pointerdown'), () => { + this.map.on(/** @type {import('ol/Observable').EventTypes} */ 'pointerdown', () => { this.$scope_.$apply(() => { this.hidePopover(); }); @@ -236,7 +239,6 @@ ContextualdataController.prototype.handleMapTouchStart_ = function (event) { }, 500); } }; - ContextualdataController.prototype.handleMapTouchEnd_ = function () { if (this.longPressTimeout_) { clearTimeout(this.longPressTimeout_); @@ -279,7 +281,6 @@ ContextualdataController.prototype.setContent_ = function (coordinate) { } const scope = this.$scope_.$new(true); this.$compile_(this.content_)(scope); - const mapProjection = this.map.getView().getProjection().getCode(); this.projections.forEach((proj) => { const ref = proj.getCode().replace('EPSG:', '').replace(':', '_'); @@ -291,7 +292,6 @@ ContextualdataController.prototype.setContent_ = function (coordinate) { // @ts-ignore: scope ... scope[`coord_${ref}_northern`] = coord[1]; }); - this.gmfRaster_.getRaster(coordinate, this.gmfContextualDataOptions_.rasterParams).then( (resp) => { Object.assign(scope, resp); @@ -304,12 +304,10 @@ ContextualdataController.prototype.setContent_ = function (coordinate) { }, ); }; - ContextualdataController.prototype.preparePopover_ = function () { if (!this.map) { throw new Error('Missing map'); } - const container = document.createElement('DIV'); container.classList.add('popover'); container.classList.add('bs-popover-bottom'); @@ -322,7 +320,6 @@ ContextualdataController.prototype.preparePopover_ = function () { this.content_.setAttribute('gmf-contextualdatacontent', ''); this.content_.classList.add('popover-body'); container.appendChild(this.content_); - this.overlay_ = new olOverlay({ element: container, stopEvent: true, @@ -334,7 +331,6 @@ ContextualdataController.prototype.preparePopover_ = function () { }); this.map.addOverlay(this.overlay_); }; - ContextualdataController.prototype.showPopover = function () { if (!this.overlay_) { throw new Error('Missing overlay'); @@ -346,7 +342,6 @@ ContextualdataController.prototype.showPopover = function () { element.style.display = 'block'; this.displayed = true; }; - ContextualdataController.prototype.hidePopover = function () { if (!this.overlay_) { throw new Error('Missing overlay'); @@ -358,7 +353,6 @@ ContextualdataController.prototype.hidePopover = function () { element.style.display = 'none'; this.displayed = false; }; - myModule.controller('GmfContextualdataController', ContextualdataController); /** @@ -386,7 +380,6 @@ myModule.controller('GmfContextualdataController', ContextualdataController); * * @param {string} gmfContextualdatacontentTemplateUrl URL to template. * @returns {angular.IDirective} The Directive Definition Object. - * @ngInject * @ngdoc directive * @ngname gmfContextualdatacontent */ @@ -397,7 +390,5 @@ function contextualDataComponentContent(gmfContextualdatacontentTemplateUrl) { templateUrl: gmfContextualdatacontentTemplateUrl, }; } - myModule.directive('gmfContextualdatacontent', contextualDataComponentContent); - export default myModule; diff --git a/src/controllers/AbstractAPIController.js b/src/controllers/AbstractAPIController.js index 0805176de2f0..ab07b9f32b6b 100644 --- a/src/controllers/AbstractAPIController.js +++ b/src/controllers/AbstractAPIController.js @@ -35,13 +35,12 @@ export class AbstractAPIController extends AbstractAppController { /** * @param {angular.IScope} $scope Scope. * @param {angular.auto.IInjectorService} $injector Main injector. - * @ngInject */ constructor($scope, $injector) { super($scope, $injector, false); } } - +AbstractAPIController.$inject = ['$scope', '$injector']; /** * @type {angular.IModule} * @hidden @@ -50,7 +49,5 @@ const myModule = angular.module('GmfAbstractAPIControllerModule', [ gmfControllersAbstractAppController.name, ngeoMapResizemap.name, ]); - myModule.controller('AbstractAPIController', AbstractAPIController); - export default myModule; diff --git a/src/controllers/AbstractAppController.js b/src/controllers/AbstractAppController.js index d3329177a62c..3553dd1a694f 100644 --- a/src/controllers/AbstractAppController.js +++ b/src/controllers/AbstractAppController.js @@ -1,3 +1,4 @@ +AbstractAppController.$inject = ['$scope', '$injector', 'mobile']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -58,10 +59,8 @@ import olControlRotate from 'ol/control/Rotate'; import {defaults as interactionsDefaults} from 'ol/interaction'; import olInteractionDragPan from 'ol/interaction/DragPan'; import {noModifierKeys} from 'ol/events/condition'; - import gmfAuthenticationService from 'ngeo/auth/service'; import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; - import storeMap from 'gmfapi/store/map'; import user, {UserState, loginMessageRequired} from 'gmfapi/store/user'; @@ -79,14 +78,12 @@ import user, {UserState, loginMessageRequired} from 'gmfapi/store/user'; * @param {boolean} [mobile] Is mobile. * @class * @ngdoc controller - * @ngInject */ export function AbstractAppController($scope, $injector, mobile) { createProjections($injector.get('gmfProjectionsOptions')); /** @type {import('gmf/options').gmfOptions} */ this.options = $injector.get('gmfOptions'); - if (this.options.cssVars) { const cssVars = calculateCssVars(this.options.cssVars); const style = document.documentElement.style; @@ -94,11 +91,8 @@ export function AbstractAppController($scope, $injector, mobile) { style.setProperty(`--${cssVar}`, cssVars[cssVar]); } } - const scaleline = document.getElementById('scaleline'); - const view = new olView(this.options.view); - const constraints = view.getConstraints(); const centerConstraint = constraints.center; /** @@ -128,11 +122,9 @@ export function AbstractAppController($scope, $injector, mobile) { fixedModulo((newCenter[0] - wmtsTopLeft[1]) / resolution - size[0] / 2 + 0.5, 1) - 0.5; const correctionY = fixedModulo((wmtsTopLeft[0] - newCenter[1]) / resolution - size[1] / 2 + 0.5, 1) - 0.5; - newCenter[0] -= correctionX * resolution; newCenter[1] += correctionY * resolution; } - return newCenter; }; @@ -144,7 +136,6 @@ export function AbstractAppController($scope, $injector, mobile) { view.setCenter(view.getCenter()); } }; - const map = new olMap( Object.assign( { @@ -198,7 +189,6 @@ export function AbstractAppController($scope, $injector, mobile) { view.setViewportSize(size); } }; - if (!mobile) { map.addInteraction( new olInteractionDragPan({ @@ -206,7 +196,6 @@ export function AbstractAppController($scope, $injector, mobile) { }), ); } - storeMap.setMap(map); // Needed cypress e2e tests @@ -332,11 +321,9 @@ export function AbstractAppController($scope, $injector, mobile) { } }.bind(this), }; - $scope.$on('authenticationrequired', (event, args) => { this.loginRedirectUrl = args.url; this.loginActive = true; - const unbind = $scope.$watch( () => this.loginActive, () => { @@ -347,7 +334,6 @@ export function AbstractAppController($scope, $injector, mobile) { }, ); }); - this.hasPrivateLayers = false; user.getLoginMessage().subscribe({ next: (loginMessage) => { @@ -364,7 +350,6 @@ export function AbstractAppController($scope, $injector, mobile) { return; } const roleId = gmfAuthenticationService.getRolesIds().join(','); - const functionalities = this.gmfUser.functionalities; // Enable filter tool in toolbar @@ -389,7 +374,6 @@ export function AbstractAppController($scope, $injector, mobile) { // Reload themes and background layer when login status changes. this.gmfThemes.loadThemes(roleId); - if (user.getState() !== UserState.READY) { const themeName = this.permalink_.defaultThemeNameFromFunctionalities(); this.gmfThemeManager.updateCurrentTheme(themeName, previousThemeName, true, this.hasPrivateLayers); @@ -439,7 +423,6 @@ export function AbstractAppController($scope, $injector, mobile) { gmfDataSourcesManager.setDatasourceMap(this.map); // Give the dimensions to the gmfDataSourcesManager gmfDataSourcesManager.setDimensions(this.dimensions); - if ($injector.has('gmfDefaultDimensions')) { // Set defaults const defaultDimensions = $injector.get('gmfDefaultDimensions'); @@ -462,7 +445,6 @@ export function AbstractAppController($scope, $injector, mobile) { this.backgroundLayerMgr_.updateDimensions(this.map, this.dimensions); }, ); - this.backgroundLayerMgr_.on('change', () => { this.backgroundLayerMgr_.updateDimensions(this.map, this.dimensions); }); @@ -524,7 +506,6 @@ export function AbstractAppController($scope, $injector, mobile) { * @type {angular.gettext.gettextCatalog} */ this.gettextCatalog = $injector.get('gettextCatalog'); - this.initLanguage(); /** @@ -546,10 +527,8 @@ export function AbstractAppController($scope, $injector, mobile) { * @type {import('ngeo/misc/ToolActivateMgr').ToolActivateMgr} */ const ngeoToolActivateMgr = $injector.get('ngeoToolActivateMgr'); - const queryToolActivate = new ngeoMiscToolActivate(this, 'queryActive'); ngeoToolActivateMgr.registerTool(this.mapToolsGroup, queryToolActivate, true); - $scope.$root.$on(ThemeEventType.THEME_NAME_SET, (event, name) => { this.gmfThemes.getThemeObject(name).then((theme) => { this.setDefaultBackground_(theme); @@ -565,7 +544,6 @@ export function AbstractAppController($scope, $injector, mobile) { const openPopup_ = (title, opt_width, opt_height, opt_apply) => { this.displaywindowTitle = title; this.displaywindowOpen = true; - if (opt_width) { this.displaywindowWidth = `${opt_width}px`; } @@ -627,7 +605,6 @@ export function AbstractAppController($scope, $injector, mobile) { * @type {number|undefined} */ this.resizeTransition; - const cgxp = window.cgxp || {}; // @ts-ignore: We do want to define a new property on `window`. window.cgxp = cgxp; @@ -680,7 +657,6 @@ export function AbstractAppController($scope, $injector, mobile) { * @type {?string} */ this.displaywindowWidth = '50vw'; - if ($injector.has('sentryOptions')) { const options = $injector.get('sentryOptions'); if (options.dsn) { @@ -749,10 +725,8 @@ AbstractAppController.prototype.initLanguage = function () { }); }, ); - const browserLanguage = getBrowserLanguage(Object.keys(this.langUrls)); - const urlLanguage = /** @type {string|undefined} */ (this.stateManager.getInitialStringValue('lang')); - + const urlLanguage = /** @type {string|undefined} */ this.stateManager.getInitialStringValue('lang'); if (urlLanguage !== undefined && urlLanguage in this.langUrls) { this.switchLanguage(urlLanguage); return; @@ -779,22 +753,18 @@ AbstractAppController.prototype.setDefaultBackground_ = function (theme) { if (!gmfBackgroundlayerStatus.touchedByUser) { layer = this.permalink_.getBackgroundLayer(layers); } - if (!layer && this.gmfUser.functionalities) { // get the background from the user settings layer = getLayerByLabels(layers, this.gmfUser.functionalities.default_basemap); } - if (!layer && theme) { // get the background from the theme layer = getLayerByLabels(layers, theme.functionalities.default_basemap); } - if (!layer) { // fallback to the layers list, use the second one because the first is the blank layer. layer = layers[layers.length > 1 ? 1 : 0]; } - if (!layer) { throw new Error('Missing layer'); } @@ -857,11 +827,8 @@ const myModule = angular.module('GmfAbstractAppControllerModule', [ ngeoGeolocation.name, gmfMapComponent.name, ]); - myModule.controller('AbstractController', AbstractAppController); - myModule.value('ngeoExportFeatureFormats', [FeatureFormatType.KML, FeatureFormatType.GPX]); - myModule.config([ 'tmhDynamicLocaleProvider', 'angularLocaleScript', @@ -875,7 +842,5 @@ myModule.config([ tmhDynamicLocaleProvider.localeLocationPattern(angularLocaleScript); }, ]); - bootstrap(myModule); - export default myModule; diff --git a/src/controllers/AbstractDesktopController.js b/src/controllers/AbstractDesktopController.js index 4916ff395d41..62047f4c851f 100644 --- a/src/controllers/AbstractDesktopController.js +++ b/src/controllers/AbstractDesktopController.js @@ -49,11 +49,9 @@ import olStyleFill from 'ol/style/Fill'; import olStyleStroke from 'ol/style/Stroke'; import olStyleStyle from 'ol/style/Style'; import olStyleText from 'ol/style/Text'; - import 'gmfapi/index'; import panels from 'gmfapi/store/panels'; import user from 'gmfapi/store/user'; - import 'gmf/controllers/vars_desktop.scss'; import 'gmf/controllers/desktop.scss'; @@ -67,7 +65,6 @@ export class AbstractDesktopController extends AbstractAPIController { /** * @param {angular.IScope} $scope Scope. * @param {angular.auto.IInjectorService} $injector Main injector. - * @ngInject */ constructor($scope, $injector) { super($scope, $injector); @@ -166,9 +163,7 @@ export class AbstractDesktopController extends AbstractAPIController { * @type {boolean} */ this.routingPanelActive = false; - const $timeout = $injector.get('$timeout'); - panels.getActiveToolPanel().subscribe({ next: (panel) => { this.printPanelActive = panel === 'print'; @@ -178,7 +173,6 @@ export class AbstractDesktopController extends AbstractAPIController { this.editFeatureActivate = panel === 'edit'; this.googleStreetViewActive = panel === 'googlestreetview'; this.mapillaryStreetViewActive = panel === 'mapillary'; - $timeout(() => {}); // this triggered on DOM click, we call $timeout to force Angular digest if (panel === null || !panel.includes('auth')) { @@ -186,7 +180,6 @@ export class AbstractDesktopController extends AbstractAPIController { } }, }); - user.getLoginMessage().subscribe({ next: (message) => { if (message) { @@ -209,7 +202,6 @@ export class AbstractDesktopController extends AbstractAPIController { this.printActive = newVal; }, ); - $scope.$watch( () => this.googleStreetViewActive || this.mapillaryStreetViewActive, (newVal) => { @@ -229,10 +221,15 @@ export class AbstractDesktopController extends AbstractAPIController { */ this.streetViewStyle = new olStyleStyle({ text: new olStyleText({ - fill: new olStyleFill({color: '#279B61'}), + fill: new olStyleFill({ + color: '#279B61', + }), font: '900 30px "Font Awesome 5 Free"', offsetY: -15, - stroke: new olStyleStroke({color: '#ffffff', width: 3}), + stroke: new olStyleStroke({ + color: '#ffffff', + width: 3, + }), text: '\uf041', }), }); @@ -241,23 +238,20 @@ export class AbstractDesktopController extends AbstractAPIController { * @type {boolean} */ this.importDataSourceActive = false; - const body = $('body'); - if ($injector.has('gmfQueryGrid')) { this.queryGrid = $injector.get('gmfQueryGrid'); } // initialize tooltips body.tooltip( - /** @type {Bootstrap.TooltipOption} */ ({ + /** @type {Bootstrap.TooltipOption} */ { container: 'body', trigger: 'hover', selector: '[data-toggle="tooltip"]', - // Avoid error in config type checking with IE11 sanitizeFn: $injector.get('$sanitize'), - }), + }, ); // deactivate tooltips on touch device @@ -265,7 +259,6 @@ export class AbstractDesktopController extends AbstractAPIController { body.tooltip('dispose'); body.off('touchstart.detectTouch'); }); - const ngeoFeatureHelper = $injector.get('ngeoFeatureHelper'); /** @@ -300,28 +293,20 @@ export class AbstractDesktopController extends AbstractAPIController { * @type {import('gmf/datasource/LayerBeingSwipe').LayerBeingSwipe} */ this.gmfLayerBeingSwipe = $injector.get('gmfLayerBeingSwipe'); - const editFeatureActivate = new ngeoMiscToolActivate(this, 'editFeatureActive'); this.ngeoToolActivateMgr.registerTool('mapTools', editFeatureActivate, false); - const googleStreetViewActivate = new ngeoMiscToolActivate(this, 'googleStreetViewActive'); this.ngeoToolActivateMgr.registerTool('mapTools', googleStreetViewActivate, false); - const mapillaryStreetViewActivate = new ngeoMiscToolActivate(this, 'mapillaryStreetViewActive'); this.ngeoToolActivateMgr.registerTool('mapTools', mapillaryStreetViewActivate, false); - const contextdataActivate = new ngeoMiscToolActivate(this, 'contextdataActive'); this.ngeoToolActivateMgr.registerTool('mapTools', contextdataActivate, false); - const drawFeatureActivate = new ngeoMiscToolActivate(this, 'drawFeatureActive'); this.ngeoToolActivateMgr.registerTool('mapTools', drawFeatureActivate, false); - const drawProfilePanelActivate = new ngeoMiscToolActivate(this, 'drawProfilePanelActive'); this.ngeoToolActivateMgr.registerTool('mapTools', drawProfilePanelActivate, false); - const printPanelActivate = new ngeoMiscToolActivate(this, 'printPanelActive'); this.ngeoToolActivateMgr.registerTool('mapTools', printPanelActivate, false); - const routingPanelActive = new ngeoMiscToolActivate(this, 'routingPanelActive'); this.ngeoToolActivateMgr.registerTool('mapTools', routingPanelActive, false); @@ -430,7 +415,6 @@ export class AbstractDesktopController extends AbstractAPIController { 'class': `fa fa-angle-double-right ${dataPanelCls}-expand-btn`, }), ); - $scope.$watch( () => this.dataPanelActive, (newVal) => { @@ -469,7 +453,6 @@ export class AbstractDesktopController extends AbstractAPIController { const showRightPanelResize = (active) => { this.$toolsPanel_.resizable(active ? 'enable' : 'disable'); }; - $scope.$watch( () => this.toolsActive, (newVal) => { @@ -620,6 +603,7 @@ export class AbstractDesktopController extends AbstractAPIController { return maxWidth; } } +AbstractDesktopController.$inject = ['$scope', '$injector']; /** * @type {angular.IModule} * @hidden @@ -642,9 +626,6 @@ const myModule = angular.module('GmfAbstractDesktopControllerModule', [ ngeoMapswipeModule.name, ngeoQueryPanelComponent.name, ]); - myModule.controller('AbstractDesktopController', AbstractDesktopController); - myModule.value('ngeoSnappingSource', new olSourceVector()); - export default myModule; diff --git a/src/controllers/AbstractMobileController.js b/src/controllers/AbstractMobileController.js index 98caf4508093..684fd7eeff00 100644 --- a/src/controllers/AbstractMobileController.js +++ b/src/controllers/AbstractMobileController.js @@ -28,7 +28,6 @@ import gmfMobileNavigationModule from 'gmf/mobile/navigation/module'; import gmfQueryWindowComponent from 'gmf/query/windowComponent'; import ngeoMiscToolActivate from 'ngeo/misc/ToolActivate'; import user from 'gmfapi/store/user'; - import 'gmf/controllers/vars_mobile.scss'; import 'gmf/controllers/mobile.scss'; @@ -42,7 +41,6 @@ export class AbstractMobileController extends AbstractAppController { /** * @param {angular.IScope} $scope Scope. * @param {angular.auto.IInjectorService} $injector Main injector. - * @ngInject */ constructor($scope, $injector) { super($scope, $injector, true); @@ -99,16 +97,12 @@ export class AbstractMobileController extends AbstractAppController { * @type {import('ngeo/misc/ToolActivateMgr').ToolActivateMgr} */ const ngeoToolActivateMgr = $injector.get('ngeoToolActivateMgr'); - const measureAreaActivate = new ngeoMiscToolActivate(this, 'measureAreaActive'); ngeoToolActivateMgr.registerTool('mapTools', measureAreaActivate, false); - const measurePointActivate = new ngeoMiscToolActivate(this, 'measurePointActive'); ngeoToolActivateMgr.registerTool('mapTools', measurePointActivate, false); - const measureLengthActivate = new ngeoMiscToolActivate(this, 'measureLengthActive'); ngeoToolActivateMgr.registerTool('mapTools', measureLengthActivate, false); - Object.assign(this.searchListeners, { open: () => { this.searchOverlayVisible = true; @@ -117,7 +111,6 @@ export class AbstractMobileController extends AbstractAppController { this.searchOverlayVisible = false; }, }); - this.manageResize = true; this.resizeTransition = 500; @@ -130,7 +123,6 @@ export class AbstractMobileController extends AbstractAppController { } }, ); - user.getLoginMessage().subscribe({ next: (message) => { if (message) { @@ -184,14 +176,14 @@ export class AbstractMobileController extends AbstractAppController { const navElements = document.getElementsByClassName('gmf-mobile-nav-button'); // eslint-disable-next-line @typescript-eslint/prefer-for-of for (let i = 0; i < navElements.length; i++) { - const element = /** @type {HTMLElement} */ (navElements[i]); + const element = /** @type {HTMLElement} */ navElements[i]; if (element.dataset && element.dataset.target === target) { element.click(); } } } } - +AbstractMobileController.$inject = ['$scope', '$injector']; /** * @type {angular.IModule} * @hidden @@ -202,9 +194,6 @@ const myModule = angular.module('GmfAbstractMobileControllerModule', [ gmfMobileNavigationModule.name, gmfQueryWindowComponent.name, ]); - myModule.controller('AbstractMobileController', AbstractMobileController); - myModule.value('isMobile', true); - export default myModule; diff --git a/src/datasource/DataSources.js b/src/datasource/DataSources.js index 655ac90f3818..efaaf25c4bbf 100644 --- a/src/datasource/DataSources.js +++ b/src/datasource/DataSources.js @@ -42,7 +42,6 @@ export class DataSource { * * @ngdoc service * @ngname ngeoDataSources - * @ngInject */ constructor() { /** @@ -62,7 +61,6 @@ export class DataSource { * @private */ this.listenerKeys_ = []; - listen(this.collection_, 'add', this.handleDataSourcesAdd_, this); } @@ -75,18 +73,14 @@ export class DataSource { if (this.map_ === map) { return; } - if (this.map_) { this.unbindMap_(this.map_); } - this.map_ = map; - if (map) { this.bindMap_(map); } } - get collection() { return this.collection_; } @@ -164,14 +158,11 @@ export class DataSource { if (!dataSource.supportsDynamicInRange) { return; } - const maxResolution = dataSource.maxResolution; const minResolution = dataSource.minResolution; - const inMinRange = minResolution === null || minResolution === undefined || resolution >= minResolution; const inMaxRange = maxResolution === null || maxResolution === undefined || resolution <= maxResolution; const inRange = inMinRange && inMaxRange; - dataSource.inRange = inRange; } @@ -195,7 +186,7 @@ export class DataSource { } } } - +DataSource.$inject = []; /** * @type {angular.IModule} * @hidden @@ -203,5 +194,4 @@ export class DataSource { const myModule = angular.module('ngeoDataSources', []); // DataSources with the DataSources type. myModule.service('ngeoDataSources', DataSource); - export default myModule; diff --git a/src/datasource/ExternalDataSourcesManager.js b/src/datasource/ExternalDataSourcesManager.js index 6a60db4f27e6..0a76fe14ec79 100644 --- a/src/datasource/ExternalDataSourcesManager.js +++ b/src/datasource/ExternalDataSourcesManager.js @@ -66,7 +66,6 @@ export class ExternalDatSourcesManager { * @param {import('ngeo/datasource/DataSources').DataSource} ngeoDataSources Ngeo data sources service. * @param {import('ngeo/misc/File').FileService} ngeoFile Ngeo file. * @param {import('ngeo/map/LayerHelper').LayerHelper} ngeoLayerHelper Ngeo layer helper service. - * @ngInject * @ngdoc service * @ngname gmfExternalDataSourcesManager */ @@ -187,7 +186,6 @@ export class ExternalDatSourcesManager { * @private */ this.wmtsCache_ = {}; - listen(this.dataSources_, 'remove', this.handleDataSourcesRemove_, this); } @@ -350,13 +348,10 @@ export class ExternalDatSourcesManager { createAndAddDataSourceFromWMSCapability(layer, capabilities, url) { const id = getId(layer); const service = capabilities.Service; - const req = capabilities.Capability.Request; const dcpType = req.GetMap.DCPType.find((type) => type.hasOwnProperty('HTTP')); const getMapUrl = dcpType !== undefined ? dcpType.HTTP.Get.OnlineResource : url; - const originalUrl = url || getMapUrl; - let dataSource; // (1) Get data source from cache if it exists, otherwise create it @@ -401,9 +396,11 @@ export class ExternalDatSourcesManager { if (wmsInfoFormat) { options.wmsInfoFormat = wmsInfoFormat; } - - const legend = {'title': layer.Title, 'url': originalUrl, 'name': layer.Name}; - + const legend = { + 'title': layer.Title, + 'url': originalUrl, + 'name': layer.Name, + }; dataSource = new gmfExternalDatasourceOGC(options, legend); // Keep a reference to the external data source in the cache @@ -565,7 +562,6 @@ export class ExternalDatSourcesManager { */ getFileDataSource_(file) { const defer = this.q_.defer(); - if (this.files_[file.name]) { defer.resolve(this.files_[file.name]); } else { @@ -579,20 +575,17 @@ export class ExternalDatSourcesManager { const readOptions = { featureProjection: this.map_.getView().getProjection(), }; - if (ngeoFile.isKml(content)) { - features = /** @type {import('ol/Feature').default[]} */ ( - new olFormatKML().readFeatures(content, readOptions) - ); + features = + /** @type {import('ol/Feature').default[]} */ + new olFormatKML().readFeatures(content, readOptions); } else if (ngeoFile.isGpx(content)) { - features = /** @type {import('ol/Feature').default[]} */ ( - new olFormatGPX().readFeatures(content, readOptions) - ); + features = + /** @type {import('ol/Feature').default[]} */ + new olFormatGPX().readFeatures(content, readOptions); } - if (features) { const id = getId(file); - const dataSource = new ngeoDatasourceFile({ features: new olCollection(features), id: id, @@ -603,14 +596,12 @@ export class ExternalDatSourcesManager { // Keep a reference if both caches this.files_[file.name] = dataSource; this.extDataSources_[id] = dataSource; - defer.resolve(dataSource); } else { defer.reject(); } }); } - return defer.promise; } @@ -677,7 +668,6 @@ export class ExternalDatSourcesManager { if (!dataSource.wmsUrl) { throw new Error('Missing dataSource.wmsUrl'); } - const wmsGroup = this.getWMSGroup(dataSource.wmsUrl); if (wmsGroup && wmsGroup.dataSources.includes(dataSource)) { // Remove from group @@ -696,7 +686,6 @@ export class ExternalDatSourcesManager { if (!dataSource.wmtsUrl) { throw new Error('Missing dataSource.wmsUrl'); } - const wmtsGroup = this.getWMTSGroup(dataSource.wmtsUrl); if (wmtsGroup && wmtsGroup.dataSources.includes(dataSource)) { // Remove from group @@ -745,7 +734,16 @@ export class ExternalDatSourcesManager { } } } - +ExternalDatSourcesManager.$inject = [ + 'gettextCatalog', + '$injector', + '$q', + '$rootScope', + 'gmfDatasourceFileGroup', + 'ngeoDataSources', + 'ngeoFile', + 'ngeoLayerHelper', +]; /** * Get the data source id from a WMS or WMTS Capability Layer object, or * from a File object. @@ -775,5 +773,4 @@ const myModule = angular.module('gmfExternalDataSourcesManager', [ ngeoDatasourceDataSources.name, ]); myModule.service('gmfExternalDataSourcesManager', ExternalDatSourcesManager); - export default myModule; diff --git a/src/datasource/Helper.js b/src/datasource/Helper.js index 64304ef149a8..25bbc66715c5 100644 --- a/src/datasource/Helper.js +++ b/src/datasource/Helper.js @@ -45,7 +45,6 @@ export class DatasourceHelper { * @ngname ngeoDataSourcesHelper * @param {import('gmf/editing/EnumerateAttribute').EditingEnumerateAttributeService} gmfEnumerateAttribute * The Gmf enumerate attribute service. - * @ngInject */ constructor($q, ngeoDataSources, ngeoQuerent, gmfEnumerateAttribute) { // === Injected properties === @@ -120,7 +119,6 @@ export class DatasourceHelper { */ getDataSourceAttributes(dataSource) { const getDataSourceAttributesDefer = this.q_.defer(); - if (dataSource.attributes) { getDataSourceAttributesDefer.resolve(dataSource.attributes); } else { @@ -142,7 +140,7 @@ export class DatasourceHelper { // was returned. Just to be sure, let's do a bunch of assertions. const ogcLayerName = dataSource.getWFSLayerNames()[0]; console.assert(typeof ogcLayerName == 'string', 'The data source should have only one ogcLayer.'); - const featureType = /** @type {Object} */ (/** @type {unknown} */ (featureType_)); + const featureType = /** @type {Object} */ /** @type {unknown} */ featureType_; for (const element of featureType.element) { if (element.name === ogcLayerName) { for (const type of featureType.complexType) { @@ -152,7 +150,6 @@ export class DatasourceHelper { // Set the attributes in the data source dataSource.setAttributes(attributes); - getDataSourceAttributesDefer.resolve(attributes); break; } @@ -162,7 +159,6 @@ export class DatasourceHelper { }); } } - return getDataSourceAttributesDefer.promise; } @@ -230,14 +226,12 @@ export class DatasourceHelper { */ createDataSourceAttributesFromOGCAttributes_(dataSource) { let attributes = null; - const formatWFSAttribute = new ngeoFormatWFSAttribute(); const ogcAttributes = dataSource.ogcAttributesWFS; if (ogcAttributes) { attributes = []; for (const name in ogcAttributes) { const ogcAttribute = ogcAttributes[name]; - const alias = ogcAttribute.alias; const required = ogcAttribute.minOccurs != '0'; const type = ogcAttribute.type; @@ -257,11 +251,9 @@ export class DatasourceHelper { if (!ngeoAttributeSetGeometryType(attribute, `gml:${type}`)) { formatWFSAttribute.setAttributeType(attribute, type.toLowerCase()); } - attributes.push(attribute); } } - return attributes; } @@ -305,11 +297,10 @@ export class DatasourceHelper { prepareFiltrableDataSourceDefer.resolve(dataSource); } }); - return prepareFiltrableDataSourceDefer.promise; } } - +DatasourceHelper.$inject = ['$q', 'ngeoDataSources', 'ngeoQuerent', 'gmfEnumerateAttribute']; /** * @type {angular.IModule} * @hidden @@ -320,5 +311,4 @@ const myModule = angular.module('gmfDataSourcesHelper', [ gmfEditingEnumerateAttribute.name, ]); myModule.service('gmfDataSourcesHelper', DatasourceHelper); - export default myModule; diff --git a/src/datasource/Manager.js b/src/datasource/Manager.js index 374ef70ce2cc..efc05dbc8c7f 100644 --- a/src/datasource/Manager.js +++ b/src/datasource/Manager.js @@ -25,12 +25,9 @@ import gmfDatasourceWFSAliases from 'gmf/datasource/WFSAliases'; import gmfLayertreeSyncLayertreeMap, {getLayer} from 'gmf/layertree/SyncLayertreeMap'; import gmfLayertreeTreeManager from 'gmf/layertree/TreeManager'; import gmfThemeThemes, {ThemeNodeType} from 'gmf/theme/Themes'; - import {ServerType, WFSOutputFormat, Type} from 'ngeo/datasource/OGC'; import ngeoDatasourceDataSources from 'ngeo/datasource/DataSources'; - import ngeoFilterRuleHelper from 'ngeo/filter/RuleHelper'; - import ngeoMapBackgroundLayerMgr from 'ngeo/map/BackgroundLayerMgr'; import ngeoMapLayerHelper from 'ngeo/map/LayerHelper'; import ngeoMiscWMSTime from 'ngeo/misc/WMSTime'; @@ -92,7 +89,6 @@ export class DatasourceManager { * @param {import('ngeo/misc/WMSTime').WMSTime} ngeoWMSTime wms time service. * @param {import('gmf/datasource/WFSAliases').DatasourceWFSAlias} gmfWFSAliases Gmf WFS aliases * service. - * @ngInject * @ngdoc service * @ngname gmfDataSourcesManager */ @@ -277,9 +273,7 @@ export class DatasourceManager { if (this.dimensionsWatcherUnregister) { this.dimensionsWatcherUnregister(); } - this.dimensions_ = dimensions; - this.dimensionsWatcherUnregister = this.rootScope_.$watch( () => this.dimensions_, this.handleDimensionsChange_.bind(this), @@ -304,7 +298,6 @@ export class DatasourceManager { * @type {string[]} */ const layerIds = []; - const dataSources = this.dataSources_.getArray(); for (const dataSource of dataSources) { if (dataSource instanceof GmfDatasourceOGC && dataSource.dimensionsFiltersConfig) { @@ -323,7 +316,6 @@ export class DatasourceManager { } } } - layers.forEach(this.updateLayerFilter_.bind(this)); } @@ -352,7 +344,6 @@ export class DatasourceManager { } } }); - const promiseBgLayers = this.gmfThemes_.getBackgroundLayersObject().then((backgroundLayers) => { // Create a DataSource for each background layer for (const backgroundLayer of backgroundLayers) { @@ -403,10 +394,10 @@ export class DatasourceManager { * @param {import('ngeo/layertree/Controller').LayertreeController} treeCtrl */ const visitor = (treeCtrl) => { - const node = /** @type {import('gmf/themes').GmfGroup|!import('gmf/themes').GmfLayer} */ ( - treeCtrl.node - ); - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (node); + const node = + /** @type {import('gmf/themes').GmfGroup|!import('gmf/themes').GmfLayer} */ + treeCtrl.node; + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ node; const children = groupNode.children; if (!children) { newTreeCtrls.push(treeCtrl); @@ -475,7 +466,7 @@ export class DatasourceManager { * @hidden */ createDataSource_(firstLevelGroup, node, ogcServers) { - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (node); + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ node; const children = groupNode.children; // Group node (node that has children). Loop in the children @@ -489,7 +480,7 @@ export class DatasourceManager { } // From there on, the node is a layer node. - const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ (node); + const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ node; // Skip layer node if a data source with the same id exists const id = Number(olUtilGetUid(gmfLayer)); @@ -518,7 +509,6 @@ export class DatasourceManager { let ogcServer; /** @type {string} */ let ogcServerName; - if (ogcType === ThemeNodeType.WMTS || ogcType === ThemeNodeType.VECTOR_TILES) { // Manage WMTS / Vector tiles maxResolution = meta.maxQueryResolution !== undefined ? meta.maxQueryResolution : meta.maxResolution; @@ -549,10 +539,9 @@ export class DatasourceManager { ogcServer = ogcServers[meta.ogcServer]; } } - if (ogcType === ThemeNodeType.WMTS) { // Manage WMTS - const gmfLayerWMTS = /** @type {import('gmf/themes').GmfLayerWMTS} */ (/** @type {any} */ (gmfLayer)); + const gmfLayerWMTS = /** @type {import('gmf/themes').GmfLayerWMTS} */ /** @type {any} */ gmfLayer; // Common options for WMTS wmtsLayer = gmfLayerWMTS.layer; @@ -562,7 +551,7 @@ export class DatasourceManager { ogcImageType = gmfLayerWMTS.imageType; } else if (ogcType === ThemeNodeType.WMS) { // Manage WMS - const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ (/** @type {any} */ (gmfLayer)); + const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ /** @type {any} */ gmfLayer; // Common options for WMS maxResolution = gmfLayerWMS.maxResolutionHint; @@ -588,7 +577,6 @@ export class DatasourceManager { // filtrable. const queryLayers = meta.queryLayers ? meta.queryLayers.split(',') : null; - wmsLayers = gmfLayerWMS.layers.split(',').map((childLayer) => { /** @type {import('ngeo/datasource/OGC').WMSLayer} */ const item = { @@ -634,7 +622,6 @@ export class DatasourceManager { const wmsIsSingleTile = ogcServer ? ogcServer.isSingleTile : undefined; const wfsUrl = ogcServer && ogcServer.wfsSupport ? ogcServer.urlWfs : undefined; const wmsUrl = ogcServer ? ogcServer.url : undefined; - let wfsOutputFormat = WFSOutputFormat.GML3; // qgis server only supports GML2 output if (ogcServerType === ServerType.QGISSERVER) { @@ -650,13 +637,11 @@ export class DatasourceManager { // Dimensions const dimensions = this.dimensions_; const dimensionsConfig = node.dimensions || (firstLevelGroup === null ? {} : firstLevelGroup.dimensions); - const dimensionsFiltersConfig = gmfLayer.dimensionsFilters; // Time values (lower or lower/upper) let timeLowerValue; let timeUpperValue; - if (timeProperty) { const timeValues = this.ngeoWMSTime_.getOptions(timeProperty).values; if (Array.isArray(timeValues)) { @@ -782,12 +767,10 @@ export class DatasourceManager { throw new Error('Missing dataSource'); } treeCtrl.setDataSource(dataSource); - const stateWatcherUnregister = this.rootScope_.$watch( () => treeCtrl.getState(), this.handleTreeCtrlStateChange_.bind(this, treeCtrl), ); - const filterRulesWatcherUnregister = this.rootScope_.$watch( () => { const hasFilters = dataSource.filterRules !== null; @@ -806,17 +789,14 @@ export class DatasourceManager { () => dataSource.timeLowerValue, this.handleDataSourceTimeValueChange_.bind(this, dataSource), ); - if (dataSource.timeProperty.mode === 'range') { timeUpperValueWatcherUnregister = this.rootScope_.$watch( () => dataSource.timeUpperValue, this.handleDataSourceTimeValueChange_.bind(this, dataSource), ); } - wmsLayer = getLayer(treeCtrl); } - this.treeCtrlCache_[id] = { filterRulesWatcherUnregister, stateWatcherUnregister, @@ -825,9 +805,7 @@ export class DatasourceManager { treeCtrl, wmsLayer, }; - this.dataSources_.push(dataSource); - this.gmfWFSAliases_.describe(dataSource); } @@ -958,20 +936,17 @@ export class DatasourceManager { if (!(source instanceof olSourceImageWMS || source instanceof olSourceTileWMS)) { return; } - const params = source.getParams(); const layersParam = params.LAYERS; const layersList = layersParam.split(','); if (!layersList.length) { throw new Error('Missing layersList'); } - const filterParam = 'FILTER'; const filterParamValues = []; let hasFilter = false; for (const wmsLayerName of layersList) { let filterParamValue = '()'; - const dataSources = this.dataSources_.getArray(); for (const dataSource of dataSources) { const dsLayer = this.getDataSourceLayer_(dataSource); @@ -981,9 +956,9 @@ export class DatasourceManager { if (!(dataSource instanceof GmfDatasourceOGC)) { throw new Error('Wrong dataSource type'); } - const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ ( - /** @type {any} */ (dataSource.gmfLayer) - ); + const gmfLayerWMS = + /** @type {import('gmf/themes').GmfLayerWMS} */ + /** @type {any} */ dataSource.gmfLayer; if ( olUtilGetUid(dsLayer) == olUtilGetUid(layer) && layer.get('querySourceIds').includes(String(dataSource.id)) && @@ -996,7 +971,6 @@ export class DatasourceManager { } const treeCtrl = item.treeCtrl; const projCode = treeCtrl.map.getView().getProjection().getCode(); - if (!(dataSource instanceof GmfDatasourceOGC)) { throw new Error('Wrong datasource'); } @@ -1013,10 +987,8 @@ export class DatasourceManager { } } } - filterParamValues.push(filterParamValue); } - source.updateParams({ [filterParam]: hasFilter ? filterParamValues.join('') : null, }); @@ -1041,7 +1013,6 @@ export class DatasourceManager { if (dataSource.filtrable !== true || dataSource.ogcType !== Type.WMS) { return; } - const layer = this.getDataSourceLayer_(dataSource); if (layer === undefined) { return; @@ -1068,7 +1039,6 @@ export class DatasourceManager { } const wmsLayer = item.wmsLayer; const wmsSource = wmsLayer.getSource(); - const timeProperty = dataSource.timeProperty; let timeParam; const range = dataSource.timeRangeValue; @@ -1104,7 +1074,7 @@ export class DatasourceManager { * @hidden */ handleNgeoBackgroundLayerChange_(evt) { - const event = /** @type {import('ngeo/map/BackgroundLayerMgr').BackgroundEvent} */ (evt); + const event = /** @type {import('ngeo/map/BackgroundLayerMgr').BackgroundEvent} */ evt; const previousBackgroundLayer = event.detail.previous; const currentBackgroundLayer = event.detail.current; const cache = this.dataSourcesCache_; @@ -1138,7 +1108,20 @@ export class DatasourceManager { } } } - +DatasourceManager.$inject = [ + '$q', + '$rootScope', + '$timeout', + '$injector', + 'gmfThemes', + 'gmfTreeManager', + 'ngeoBackgroundLayerMgr', + 'ngeoDataSources', + 'ngeoLayerHelper', + 'ngeoRuleHelper', + 'ngeoWMSTime', + 'gmfWFSAliases', +]; /** * @type {angular.IModule} * @hidden @@ -1155,5 +1138,4 @@ const myModule = angular.module('gmfDataSourcesManager', [ ngeoMiscWMSTime.name, ]); myModule.service('gmfDataSourcesManager', DatasourceManager); - export default myModule; diff --git a/src/datasource/WFSAliases.js b/src/datasource/WFSAliases.js index faf0e496fffd..b01d1f387b33 100644 --- a/src/datasource/WFSAliases.js +++ b/src/datasource/WFSAliases.js @@ -35,7 +35,6 @@ export class DatasourceWFSAlias { * source helper service. * @ngdoc service * @ngname gmfWFSAliases - * @ngInject */ constructor(gmfDataSourcesHelper) { // === Injected properties === @@ -64,12 +63,11 @@ export class DatasourceWFSAlias { } } } - +DatasourceWFSAlias.$inject = ['gmfDataSourcesHelper']; /** * @type {angular.IModule} * @hidden */ const myModule = angular.module('gmfDatasourceWFSAliases', [gmfDatasourceHelper.name]); myModule.service('gmfWFSAliases', DatasourceWFSAlias); - export default myModule; diff --git a/src/disclaimer/component.js b/src/disclaimer/component.js index f3268242636d..b09abe3e5eb3 100644 --- a/src/disclaimer/component.js +++ b/src/disclaimer/component.js @@ -1,3 +1,14 @@ +DisclaimerController.$inject = [ + '$element', + '$sce', + '$timeout', + '$rootScope', + 'gettextCatalog', + 'ngeoDisclaimer', + 'ngeoEventHelper', + 'ngeoLayerHelper', + 'gmfDisclaimerOptions', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -30,7 +41,6 @@ import {MessageType} from 'ngeo/message/Message'; import ngeoMessageDisclaimer from 'ngeo/message/Disclaimer'; import ngeoMiscEventHelper from 'ngeo/misc/EventHelper'; import {CollectionEvent} from 'ol/Collection'; - import 'angular-sanitize'; /** @@ -73,7 +83,6 @@ const myModule = angular.module('gmfDisclaimer', [ * @param {import('ngeo/misc/EventHelper').EventHelper} ngeoEventHelper Ngeo Event Helper. * @param {import('ngeo/map/LayerHelper').LayerHelper} ngeoLayerHelper Ngeo Layer Helper. * @param {import('gmf/options').gmfDisclaimerOptions} gmfDisclaimerOptions The options. - * @ngInject * @class * @ngdoc controller * @ngname GmfDisclaimerController @@ -171,10 +180,8 @@ DisclaimerController.prototype.$onInit = function () { if (!this.map) { throw new Error('Missing map'); } - this.dataLayerGroup_ = this.ngeoLayerHelper_.getGroupFromMap(this.map, DATALAYERGROUP_NAME); this.registerLayer_(this.dataLayerGroup_); - this.rootScope_.$on('ngeo-pre-empty-layertree', () => { for (const layer of this.map.getAllLayers()) { this.closeAll_(layer); @@ -206,7 +213,6 @@ DisclaimerController.prototype.handleLayersRemove_ = function (evt) { if (!(layer instanceof olLayerBase)) { throw new Error('Wrong layer type'); } - this.unregisterLayer_(layer); } }; @@ -216,7 +222,6 @@ DisclaimerController.prototype.handleLayersRemove_ = function (evt) { */ DisclaimerController.prototype.registerLayer_ = function (layer) { const layerUid = olUtilGetUid(layer); - if (layer instanceof olLayerGroup) { // (1) Listen to added/removed layers to this group this.eventHelper_.addListenerKey(layerUid, listen(layer.getLayers(), 'add', this.handleLayersAdd_, this)); @@ -237,7 +242,6 @@ DisclaimerController.prototype.registerLayer_ = function (layer) { } else { this.closeAll_(layer); } - this.rootScope_.$on('ngeo-disclaimer-state', () => { if (layer.getVisible() && this.map.getAllLayers().includes(layer)) { this.update_(layer); @@ -257,7 +261,6 @@ DisclaimerController.prototype.registerLayer_ = function (layer) { */ DisclaimerController.prototype.unregisterLayer_ = function (layer) { const layerUid = olUtilGetUid(layer); - if (layer instanceof olLayerGroup) { // (1) Clear event listeners this.eventHelper_.clearListenerKey(layerUid); @@ -269,7 +272,6 @@ DisclaimerController.prototype.unregisterLayer_ = function (layer) { this.closeAll_(layer); } }; - DisclaimerController.prototype.$onDestroy = function () { if (!this.dataLayerGroup_) { throw new Error('Missing dataLayerGroup'); @@ -346,9 +348,9 @@ DisclaimerController.prototype.update_ = function (layer) { console.assert(Object.keys(disclaimers).length === 1); this.showAll_(layer); } else { - const layerWMS = /** @type {import('ol/layer/Layer').default} */ ( - layer - ); + const layerWMS = + /** @type {import('ol/layer/Layer').default} */ + layer; const sourceWMS = layerWMS.getSource(); if (sourceWMS.getParams) { const layers = sourceWMS.getParams()['LAYERS']; @@ -441,7 +443,5 @@ const disclaimerComponent = { 'msg': '=?gmfDisclaimerExternalMsg', }, }; - myModule.component('gmfDisclaimer', disclaimerComponent); - export default myModule; diff --git a/src/draw/Controller.js b/src/draw/Controller.js index dab0295c7dc1..ce57be2b8ecb 100644 --- a/src/draw/Controller.js +++ b/src/draw/Controller.js @@ -20,9 +20,7 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - import ngeoDrawFeatures from 'ngeo/draw/features'; - import ngeoFormatFeatureProperties from 'ngeo/format/FeatureProperties'; import ngeoGeometryType from 'ngeo/GeometryType'; import ngeoMiscBtnComponent from 'ngeo/misc/btnComponent'; @@ -41,7 +39,6 @@ export class DrawController { * service. * @param {import('ol/Collection').default>} ngeoFeatures Collection of * features. - * @ngInject */ constructor($scope, gettextCatalog, ngeoFeatureHelper, ngeoFeatures) { /** @@ -188,15 +185,10 @@ export class DrawController { const event = evt.detail ? evt.detail : evt; const sketch = event.feature; console.assert(sketch); - const azimut = sketch.get('azimut'); - const features = this.features || this.ngeoFeatures_; - const feature = new olFeature(sketch.getGeometry()); - const prop = ngeoFormatFeatureProperties; - switch (type) { case ngeoGeometryType.CIRCLE: feature.set(prop.IS_CIRCLE, true); @@ -229,7 +221,6 @@ export class DrawController { */ const color = type !== ngeoGeometryType.TEXT ? '#DB4436' : '#000000'; feature.set(prop.COLOR, color); - feature.set(prop.ANGLE, 0); feature.set(prop.OPACITY, 0.2); feature.set(prop.SHOW_MEASURE, this.showMeasure ? true : false); @@ -244,7 +235,7 @@ export class DrawController { features.push(feature); } } - +DrawController.$inject = ['$scope', 'gettextCatalog', 'ngeoFeatureHelper', 'ngeoFeatures']; /** * @type {angular.IModule} * @hidden @@ -255,5 +246,4 @@ const myModule = angular.module('ngeoDrawfeatureController', [ ngeoMiscFeatureHelper.name, ]); myModule.controller('ngeoDrawfeatureController', DrawController); - export default myModule; diff --git a/src/draw/component.js b/src/draw/component.js index 61d5e73e3a29..1193125f3e80 100644 --- a/src/draw/component.js +++ b/src/draw/component.js @@ -20,7 +20,6 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - import ngeoDrawController from 'ngeo/draw/Controller'; import ngeoDrawPoint from 'ngeo/draw/point'; import ngeoDrawRectangle from 'ngeo/draw/rectangle'; @@ -116,7 +115,6 @@ const myModule = angular.module('ngeoDrawfeature', [ * property. Used to find those draw interactions later on from the * map, using the property set. * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoDrawfeature */ @@ -133,7 +131,5 @@ function drawComponent() { }, }; } - myModule.directive('ngeoDrawfeature', drawComponent); - export default myModule; diff --git a/src/draw/point.js b/src/draw/point.js index 2dd2f3e81600..2cb695e324bd 100644 --- a/src/draw/point.js +++ b/src/draw/point.js @@ -32,7 +32,6 @@ const myModule = angular.module('ngeoDrawpoint', []); /** * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoDrawpoint */ @@ -50,18 +49,14 @@ function drawPointComponent() { if (!drawFeatureCtrl) { throw new Error('Missing drawFeatureCtrl'); } - const drawPoint = new olInteractionDraw({ type: 'Point', }); - if (drawFeatureCtrl.uid) { drawPoint.set('ngeo-interaction-draw-uid', `${drawFeatureCtrl.uid}-point`); } - drawFeatureCtrl.registerInteraction(drawPoint); drawFeatureCtrl.drawPoint = drawPoint; - listen( drawPoint, 'drawend', @@ -72,7 +67,5 @@ function drawPointComponent() { }, }; } - myModule.directive('ngeoDrawpoint', drawPointComponent); - export default myModule; diff --git a/src/draw/rectangle.js b/src/draw/rectangle.js index 87649f9a85b0..ac5f7ba281bb 100644 --- a/src/draw/rectangle.js +++ b/src/draw/rectangle.js @@ -33,7 +33,6 @@ const myModule = angular.module('ngeoDrawrectangle', []); /** * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoDrawrectangle */ @@ -51,7 +50,6 @@ function drawRectangleComponent() { if (!drawFeatureCtrl) { throw new Error('Missing drawFeatureCtrl'); } - const drawRectangle = new olInteractionDraw({ type: 'LineString', geometryFunction: (coordinates, geometry) => { @@ -71,14 +69,11 @@ function drawRectangleComponent() { }, maxPoints: 2, }); - if (drawFeatureCtrl.uid) { drawRectangle.set('ngeo-interaction-draw-uid', `${drawFeatureCtrl.uid}-rectangle`); } - drawFeatureCtrl.registerInteraction(drawRectangle); drawFeatureCtrl.drawRectangle = drawRectangle; - listen( drawRectangle, 'drawend', @@ -89,7 +84,5 @@ function drawRectangleComponent() { }, }; } - myModule.directive('ngeoDrawrectangle', drawRectangleComponent); - export default myModule; diff --git a/src/draw/text.js b/src/draw/text.js index 8ed284674024..b31a2ef6568a 100644 --- a/src/draw/text.js +++ b/src/draw/text.js @@ -32,7 +32,6 @@ const myModule = angular.module('ngeoDrawtext', []); /** * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoDrawtext */ @@ -50,18 +49,14 @@ function drawTextComponent() { if (!drawFeatureCtrl) { throw new Error('Missing drawFeatureCtrl'); } - const drawText = new olInteractionDraw({ type: 'Point', }); - if (drawFeatureCtrl.uid) { drawText.set('ngeo-interaction-draw-uid', `${drawFeatureCtrl.uid}-text`); } - drawFeatureCtrl.registerInteraction(drawText); drawFeatureCtrl.drawText = drawText; - listen( drawText, 'drawend', @@ -72,7 +67,5 @@ function drawTextComponent() { }, }; } - myModule.directive('ngeoDrawtext', drawTextComponent); - export default myModule; diff --git a/src/drawing/drawFeatureComponent.js b/src/drawing/drawFeatureComponent.js index 4979d57a93d6..f6611b3d84bb 100644 --- a/src/drawing/drawFeatureComponent.js +++ b/src/drawing/drawFeatureComponent.js @@ -1,3 +1,12 @@ +Controller.$inject = [ + '$scope', + '$timeout', + 'gettextCatalog', + 'gmfSnapping', + 'ngeoFeatureHelper', + 'ngeoFeatures', + 'ngeoToolActivateMgr', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,16 +31,11 @@ import angular from 'angular'; import gmfDrawingDrawFeatureOptionsComponent from 'gmf/drawing/drawFeatureOptionsComponent'; import gmfDrawingFeatureStyleComponent from 'gmf/drawing/featureStyleComponent'; - import ngeoGeometryType from 'ngeo/GeometryType'; import ngeoMenu from 'ngeo/Menu'; - import ngeoEditingExportfeaturesComponent from 'ngeo/editing/exportfeaturesComponent'; - import ngeoMiscBtnComponent from 'ngeo/misc/btnComponent'; - import ngeoDrawComponent from 'ngeo/draw/component'; - import ngeoFormatFeatureProperties from 'ngeo/format/FeatureProperties'; import ngeoInteractionModify from 'ngeo/interaction/Modify'; import ngeoInteractionRotate from 'ngeo/interaction/Rotate'; @@ -49,7 +53,6 @@ import olStyleText from 'ol/style/Text'; import {CollectionEvent} from 'ol/Collection'; import MapBrowserEvent from 'ol/MapBrowserEvent'; import Feature from 'ol/Feature'; - import 'bootstrap/js/src/dropdown'; /** @@ -65,16 +68,17 @@ const myModule = angular.module('GmfDrawFeatureComponent', [ ngeoMiscFeatureHelper.name, ngeoMiscToolActivateMgr.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/drawing/drawFeatureComponent', require('./drawFeatureComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/drawing/drawFeatureComponent', require('./drawFeatureComponent.html')); + }, + ], ); /** @@ -91,7 +95,6 @@ myModule.run( * active or not. * @htmlAttribute {import('ol/Map').default} gmf-drawfeature-map The map. * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname gmfDrawfeature */ @@ -107,7 +110,6 @@ function drawinfDrawFeatureComponent() { templateUrl: 'gmf/drawing/drawFeatureComponent', }; } - myModule.directive('gmfDrawfeature', drawinfDrawFeatureComponent); /** @@ -122,7 +124,6 @@ myModule.directive('gmfDrawfeature', drawinfDrawFeatureComponent); * manager service. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname GmfDrawfeatureController */ @@ -277,7 +278,6 @@ export function Controller( }), }); this.interactions_.push(this.rotate_); - this.initializeInteractions_(); /** @@ -313,9 +313,7 @@ export function Controller( * @type {boolean} */ this.listSelectionInProgress_ = false; - $scope.$watch(() => this.active, this.handleActiveChange_.bind(this)); - $scope.$watch( () => this.drawActive, (active) => { @@ -324,7 +322,6 @@ export function Controller( } }, ); - $scope.$watch( () => this.selectedFeature, (newFeature, previousFeature) => { @@ -350,14 +347,12 @@ export function Controller( } }, ); - $scope.$watch(() => this.mapSelectActive, this.handleMapSelectActiveChange_.bind(this)); /** * @type {string} */ this.nameProperty = ngeoFormatFeatureProperties.NAME; - this.gettextCatalog_ = gettextCatalog; // --- Draw Interactions --- @@ -402,7 +397,6 @@ Controller.prototype.$onInit = function () { if (!this.map) { throw new Error('Missing map'); } - this.mainListenerKeys_.push( listen(this.map.getInteractions(), 'add', this.handleMapInteractionsAdd_, this), ); @@ -480,7 +474,6 @@ Controller.prototype.handleActiveChange_ = function (active) { const drawUid = ['draw-', olUtilGetUid(this)].join('-'); const otherUid = ['other-', olUtilGetUid(this)].join('-'); const toolMgr = this.ngeoToolActivateMgr_; - if (active) { // when activated @@ -488,15 +481,12 @@ Controller.prototype.handleActiveChange_ = function (active) { keys.push(listen(this.features, 'remove', this.handleFeaturesRemove_, this)); keys.push(listen(this.translate_, 'translateend', this.handleTranslateEnd_, this)); keys.push(listen(this.rotate_, 'rotateend', this.handleRotateEnd_, this)); - toolMgr.registerTool(drawUid, this.drawToolActivate, false); toolMgr.registerTool(drawUid, this.mapSelectToolActivate, true); - toolMgr.registerTool(otherUid, this.drawToolActivate, false); toolMgr.registerTool(otherUid, this.modifyToolActivate, true); toolMgr.registerTool(otherUid, this.translateToolActivate, false); toolMgr.registerTool(otherUid, this.rotateToolActivate, false); - this.mapSelectActive = true; this.modify_.setActive(true); } else { @@ -504,20 +494,16 @@ Controller.prototype.handleActiveChange_ = function (active) { keys.forEach(unlistenByKey); keys.length = 0; - toolMgr.unregisterTool(drawUid, this.drawToolActivate); toolMgr.unregisterTool(drawUid, this.mapSelectToolActivate); - toolMgr.unregisterTool(otherUid, this.drawToolActivate); toolMgr.unregisterTool(otherUid, this.modifyToolActivate); toolMgr.unregisterTool(otherUid, this.translateToolActivate); toolMgr.unregisterTool(otherUid, this.rotateToolActivate); - this.drawActive = false; this.modify_.setActive(false); this.mapSelectActive = false; this.selectedFeature = null; - this.closeMenu_(); } }; @@ -570,7 +556,7 @@ Controller.prototype.handleFeaturesAdd_ = function (evt) { if (evt instanceof CollectionEvent) { // timeout to prevent double-click to zoom the map this.timeout_(() => { - this.selectedFeature = /** @type {Feature} */ (evt.element); + this.selectedFeature = /** @type {Feature} */ evt.element; this.drawActive = false; this.scope_.$apply(); }); @@ -593,12 +579,10 @@ Controller.prototype.handleMapSelectActiveChange_ = function (active) { if (!this.map) { throw new Error('Missing map'); } - const mapDiv = this.map.getViewport(); if (!mapDiv) { throw new Error('Missing mapDiv'); } - if (active) { this.mapListenerKeys_.push(listen(this.map, 'click', this.handleMapClick_, this)); this.mapListenerKeys_.push(listen(mapDiv, 'contextmenu', this.handleMapContextMenu_, this)); @@ -619,7 +603,6 @@ Controller.prototype.handleMapClick_ = function (evt) { throw new Error('Missing map'); } const pixel = evt.pixel; - let feature = this.map.forEachFeatureAtPixel( pixel, (feature) => { @@ -636,16 +619,13 @@ Controller.prototype.handleMapClick_ = function (evt) { layerFilter: undefined, }, ); - feature = feature ? feature : null; // do not do any further action if feature is null or already selected if (feature === this.selectedFeature) { return; } - this.selectedFeature = feature; - this.scope_.$apply(); } }; @@ -680,8 +660,8 @@ Controller.prototype.handleMapContextMenu_ = function (evt) { const gettextCatalog = this.gettextCatalog_; const pixel = this.map.getEventPixel(evt); const coordinate = this.map.getCoordinateFromPixel(pixel); - - let feature = /** @type {?import('ol/Feature').default} */ ( + let feature = + /** @type {?import('ol/Feature').default} */ this.map.forEachFeatureAtPixel( pixel, (feature) => { @@ -697,9 +677,7 @@ Controller.prototype.handleMapContextMenu_ = function (evt) { hitTolerance: 7, layerFilter: undefined, }, - ) - ); - + ); feature = feature ? feature : null; // show contextual menu when clicking on certain types of features @@ -735,7 +713,6 @@ Controller.prototype.handleMapContextMenu_ = function (evt) { ]); } } - actions = actions.concat([ { cls: 'fa fa-trash', @@ -743,11 +720,9 @@ Controller.prototype.handleMapContextMenu_ = function (evt) { name: 'delete', }, ]); - this.menu_ = new ngeoMenu({ actions, }); - this.menuListenerKey_ = listen( this.menu_, 'actionclick', @@ -755,9 +730,7 @@ Controller.prototype.handleMapContextMenu_ = function (evt) { this, ); this.map.addOverlay(this.menu_); - this.menu_.open(coordinate); - evt.preventDefault(); evt.stopPropagation(); } @@ -766,11 +739,8 @@ Controller.prototype.handleMapContextMenu_ = function (evt) { if (feature === this.selectedFeature) { return; } - this.modify_.setActive(true); - this.selectedFeature = feature; - this.scope_.$apply(); } }; @@ -781,11 +751,10 @@ Controller.prototype.handleMapContextMenu_ = function (evt) { * @param {Event|import('ol/events/Event').default} evt Event. */ Controller.prototype.handleMenuActionClick_ = function (vertexInfo, evt) { - const action = /** @type {import('ngeo/filter/ruleComponent').MenuEvent} */ (evt).detail.action; + const action = /** @type {import('ngeo/filter/ruleComponent').MenuEvent} */ evt.detail.action; if (!this.selectedFeature) { throw new Error('Missing selectedFeature'); } - switch (action) { case 'delete': if (!this.selectedFeature) { @@ -839,34 +808,31 @@ Controller.prototype.handleMapInteractionsAdd_ = function (evt) { // If the added interaction is a draw one registered with a unique // id, bind it to the according property. - const interaction = /** @type {import('ol/interaction/Interaction').default} */ (evt.element); + const interaction = /** @type {import('ol/interaction/Interaction').default} */ evt.element; const drawFeatureUid = interaction.get('ngeo-interaction-draw-uid'); - switch (drawFeatureUid) { case `${this.ngeoDrawFeatureUid}-point`: - this.drawPoint = /** @type {import('ol/interaction/Draw').default} */ (interaction); + this.drawPoint = /** @type {import('ol/interaction/Draw').default} */ interaction; break; case `${this.ngeoDrawFeatureUid}-length`: - this.measureLength = /** @type {import('ngeo/interaction/MeasureLength').default} */ (interaction); + this.measureLength = /** @type {import('ngeo/interaction/MeasureLength').default} */ interaction; this.measureLength.spherical = this.featureHelper_.spherical; break; case `${this.ngeoDrawFeatureUid}-area`: - this.measureArea = /** @type {import('ngeo/interaction/MeasureArea').default} */ (interaction); + this.measureArea = /** @type {import('ngeo/interaction/MeasureArea').default} */ interaction; break; case `${this.ngeoDrawFeatureUid}-azimut`: - this.measureAzimut = /** @type {import('ngeo/interaction/MeasureAzimut').default} */ (interaction); + this.measureAzimut = /** @type {import('ngeo/interaction/MeasureAzimut').default} */ interaction; break; case `${this.ngeoDrawFeatureUid}-rectangle`: - this.drawRectangle = /** @type {import('ol/interaction/Draw').default} */ (interaction); + this.drawRectangle = /** @type {import('ol/interaction/Draw').default} */ interaction; break; case `${this.ngeoDrawFeatureUid}-text`: - this.drawText = /** @type {import('ol/interaction/Draw').default} */ (interaction); + this.drawText = /** @type {import('ol/interaction/Draw').default} */ interaction; break; default: break; } }; - myModule.controller('GmfDrawfeatureController', Controller); - export default myModule; diff --git a/src/drawing/drawFeatureOptionsComponent.js b/src/drawing/drawFeatureOptionsComponent.js index 0a2864d63a88..c23736e98dc3 100644 --- a/src/drawing/drawFeatureOptionsComponent.js +++ b/src/drawing/drawFeatureOptionsComponent.js @@ -20,7 +20,6 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - import {listen as olEventsListen} from 'ol/events'; import OLFeature from 'ol/Feature'; import OLGeomCircle from 'ol/geom/Circle'; @@ -33,7 +32,6 @@ import OLInteractionPointer from 'ol/interaction/Pointer'; import OLInteractionSnap from 'ol/interaction/Snap'; import OLMapBrowserEvent from 'ol/MapBrowserEvent'; import OLSourceVector from 'ol/source/Vector'; - import {unlistenByKeys as ngeoEventsUnlistenByKeys} from 'ngeo/events'; /** @@ -41,19 +39,20 @@ import {unlistenByKeys as ngeoEventsUnlistenByKeys} from 'ngeo/events'; * @hidden */ const myModule = angular.module('GmfDrawFeatureOptionsComponent', []); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - $templateCache.put( - 'gmf/drawing/drawFeatureOptionsComponent', - // @ts-ignore: webpack - require('./drawFeatureOptionsComponent.html'), - ); - }, + [ + '$templateCache', + ($templateCache) => { + $templateCache.put( + 'gmf/drawing/drawFeatureOptionsComponent', + // @ts-ignore: webpack + require('./drawFeatureOptionsComponent.html'), + ); + }, + ], ); /** @@ -62,7 +61,6 @@ myModule.run( export class DrawFeatureOptionsController { /** * @param {angular.IScope} $scope Scope. - * @ngInject * @ngdoc controller * @ngname GmfDrawFeatureOptionsController */ @@ -232,21 +230,17 @@ export class DrawFeatureOptionsController { drawInteraction = this.drawRectangle; requiresHeight = true; } - if (drawInteraction instanceof OLInteractionDraw) { - this.drawInteraction_ = /** @type {OLInteractionDraw} */ (drawInteraction); + this.drawInteraction_ = /** @type {OLInteractionDraw} */ drawInteraction; } else { throw new Error('No draw interaction given to DrawFeatureOptions component'); } - this.map.addInteraction(this.snapInteraction_); - this.listenerKeys_.push( olEventsListen(drawInteraction, 'drawstart', this.handleDrawInteractionDrawStart_, this), olEventsListen(this.map, 'singleclick', this.handleMapSingleClick_, this), olEventsListen(this.map, 'dblclick', this.handleMapDoubleClick_, this), ); - if (requiresHeight) { this.scope_.$watch( () => { @@ -291,9 +285,7 @@ export class DrawFeatureOptionsController { if (!this.drawInteraction_) { return; } - ngeoEventsUnlistenByKeys(this.listenerKeys_); - this.map.removeInteraction(this.snapInteraction_); this.snapSource_.clear(); } @@ -310,9 +302,7 @@ export class DrawFeatureOptionsController { // evt.detail.feature - ngeo.interaction.DrawAzimut // @ts-ignore: webpack const feature = evt.feature || evt.detail.feature; - this.feature_ = feature; - const geometry = feature.getGeometry(); this.listenerKeys_.push(olEventsListen(geometry, 'change', this.handleFeatureGeometryChange_, this)); } @@ -324,7 +314,6 @@ export class DrawFeatureOptionsController { */ handleFeatureGeometryChange_() { let adjust = false; - if (this.measureLength) { // Length, i.e. LineString const lineStringGeometry = this.feature_.getGeometry(); @@ -382,9 +371,7 @@ export class DrawFeatureOptionsController { const lengthMeters = lengthUnits === 'm' ? length : length * 1000; const heightMeters = opt_height && opt_heightUnits ? (opt_heightUnits === 'm' ? opt_height : opt_height * 1000) : null; - let snapGeometry; - if (this.measureLength) { // Length, i.e. LineString const lineStringGeometry = this.feature_.getGeometry(); @@ -430,7 +417,6 @@ export class DrawFeatureOptionsController { ]); } } - if (snapGeometry) { this.snapFeature_.setGeometry(snapGeometry); } @@ -456,7 +442,6 @@ export class DrawFeatureOptionsController { this.shouldStopDrawing_ = true; } } - return OLInteractionPointer.prototype.handleEvent.call(this.snapInteraction_, evt); } @@ -471,7 +456,6 @@ export class DrawFeatureOptionsController { if (!(evt instanceof OLMapBrowserEvent)) { return; } - this.shouldStopDrawing_ = false; } @@ -493,14 +477,13 @@ export class DrawFeatureOptionsController { if (!(evt instanceof OLMapBrowserEvent)) { return; } - if (this.shouldStopDrawing_) { this.drawInteraction_.removeLastPoint(); this.drawInteraction_.finishDrawing(); } } } - +DrawFeatureOptionsController.$inject = ['$scope']; myModule.component('gmfDrawfeatureoptions', { bindings: { 'map': '<', @@ -513,5 +496,4 @@ myModule.component('gmfDrawfeatureoptions', { controller: DrawFeatureOptionsController, templateUrl: 'gmf/drawing/drawFeatureOptionsComponent', }); - export default myModule; diff --git a/src/drawing/featureStyleComponent.js b/src/drawing/featureStyleComponent.js index 68bfb2e9a278..7a6bf335f791 100644 --- a/src/drawing/featureStyleComponent.js +++ b/src/drawing/featureStyleComponent.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$scope', 'ngeoFeatureHelper']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -23,9 +24,7 @@ import angular from 'angular'; import {getUid as olUtilGetUid} from 'ol/util'; import {listen, unlistenByKey} from 'ol/events'; import ngeoFormatFeatureProperties from 'ngeo/format/FeatureProperties'; - import ngeoMiscColorpickerComponent from 'ngeo/misc/colorpickerComponent'; - import ngeoMiscFeatureHelper, {ArrowDirections, ArrowPositions} from 'ngeo/misc/FeatureHelper'; /** @@ -36,16 +35,17 @@ const myModule = angular.module('gmfDrawingFeatureStyle', [ ngeoMiscColorpickerComponent.name, ngeoMiscFeatureHelper.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/drawing/featureStyleComponent', require('./featureStyleComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/drawing/featureStyleComponent', require('./featureStyleComponent.html')); + }, + ], ); /** @@ -59,7 +59,6 @@ myModule.run( * * @htmlAttribute {import('ol/Feature').default} gmf-featurestyle-feature The feature. * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname gmfFeaturestyle */ @@ -73,7 +72,6 @@ function drawingDrawFeatureComponent() { templateUrl: 'gmf/drawing/featureStyleComponent', }; } - myModule.directive('gmfFeaturestyle', drawingDrawFeatureComponent); /** @@ -81,7 +79,6 @@ myModule.directive('gmfFeaturestyle', drawingDrawFeatureComponent); * @param {import('ngeo/misc/FeatureHelper').FeatureHelper} ngeoFeatureHelper Gmf feature helper service. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname GmfFeaturestyleController */ @@ -136,7 +133,6 @@ export function Controller($scope, ngeoFeatureHelper) { * @enum {string} */ this.arrowPositions = ArrowPositions; - $scope.$watch(() => this.color, this.handleColorSet_.bind(this)); /** @@ -150,7 +146,6 @@ export function Controller($scope, ngeoFeatureHelper) { * @type {string|undefined} */ this.type; - $scope.$watch(() => this.feature, this.handleFeatureSet_.bind(this)); } @@ -162,7 +157,6 @@ export function Controller($scope, ngeoFeatureHelper) { */ Controller.prototype.handleFeatureSet_ = function (newFeature, previousFeature) { const keys = this.featureListenerKeys_; - if (previousFeature) { keys.forEach(unlistenByKey); keys.length = 0; @@ -171,7 +165,6 @@ Controller.prototype.handleFeatureSet_ = function (newFeature, previousFeature) this.measure = undefined; this.label = undefined; } - if (newFeature) { [ ngeoFormatFeatureProperties.ANGLE, @@ -187,14 +180,11 @@ Controller.prototype.handleFeatureSet_ = function (newFeature, previousFeature) ].forEach((propName) => { keys.push(listen(newFeature, `change:${propName}`, this.handleFeatureChange_, this)); }); - const geometry = newFeature.getGeometry(); if (!geometry) { throw new Error('Missing geometry'); } - keys.push(listen(geometry, 'change', this.handleGeometryChange_, this)); - this.type = this.featureHelper_.getType(newFeature); this.color = this.featureHelper_.getColorProperty(newFeature); this.measure = this.featureHelper_.getMeasure(newFeature); @@ -218,7 +208,7 @@ Controller.prototype.handleColorSet_ = function (newColor) { * @returns {number} The angle of the feature. */ Controller.prototype.getSetAngle = function (value) { - return /** @type {number} */ (this.getSetProperty_(ngeoFormatFeatureProperties.ANGLE, value)); + return /** @type {number} */ this.getSetProperty_(ngeoFormatFeatureProperties.ANGLE, value); }; /** @@ -226,7 +216,7 @@ Controller.prototype.getSetAngle = function (value) { * @returns {string} The name of the feature. */ Controller.prototype.getSetName = function (value) { - return /** @type {string} */ (this.getSetProperty_(ngeoFormatFeatureProperties.NAME, value)); + return /** @type {string} */ this.getSetProperty_(ngeoFormatFeatureProperties.NAME, value); }; /** @@ -235,7 +225,7 @@ Controller.prototype.getSetName = function (value) { * @returns {boolean} Whether to show the labels or not. */ Controller.prototype.getSetShowLabel = function (value) { - return /** @type {boolean} */ (this.getSetProperty_(ngeoFormatFeatureProperties.SHOW_LABEL, value)); + return /** @type {boolean} */ this.getSetProperty_(ngeoFormatFeatureProperties.SHOW_LABEL, value); }; /** @@ -243,7 +233,7 @@ Controller.prototype.getSetShowLabel = function (value) { * @returns {number} The stroke of the feature. */ Controller.prototype.getSetOpacity = function (value) { - return /** @type {number} */ (this.getSetProperty_(ngeoFormatFeatureProperties.OPACITY, value)); + return /** @type {number} */ this.getSetProperty_(ngeoFormatFeatureProperties.OPACITY, value); }; /** @@ -252,7 +242,7 @@ Controller.prototype.getSetOpacity = function (value) { * @returns {boolean} Whether to show the measurements or not. */ Controller.prototype.getSetShowMeasure = function (value) { - return /** @type {boolean} */ (this.getSetProperty_(ngeoFormatFeatureProperties.SHOW_MEASURE, value)); + return /** @type {boolean} */ this.getSetProperty_(ngeoFormatFeatureProperties.SHOW_MEASURE, value); }; /** @@ -260,7 +250,7 @@ Controller.prototype.getSetShowMeasure = function (value) { * @returns {number} The size of the feature. */ Controller.prototype.getSetSize = function (value) { - return /** @type {number} */ (this.getSetProperty_(ngeoFormatFeatureProperties.SIZE, value)); + return /** @type {number} */ this.getSetProperty_(ngeoFormatFeatureProperties.SIZE, value); }; /** @@ -268,7 +258,7 @@ Controller.prototype.getSetSize = function (value) { * @returns {number} The stroke of the feature. */ Controller.prototype.getSetStroke = function (value) { - return /** @type {number} */ (this.getSetProperty_(ngeoFormatFeatureProperties.STROKE, value)); + return /** @type {number} */ this.getSetProperty_(ngeoFormatFeatureProperties.STROKE, value); }; /** @@ -276,7 +266,7 @@ Controller.prototype.getSetStroke = function (value) { * @returns {number} The arrow-direction of the feature. */ Controller.prototype.getSetArrowDirection = function (value) { - return /** @type {number} */ (this.getSetProperty_(ngeoFormatFeatureProperties.ARROW_DIRECTION, value)); + return /** @type {number} */ this.getSetProperty_(ngeoFormatFeatureProperties.ARROW_DIRECTION, value); }; /** @@ -284,7 +274,7 @@ Controller.prototype.getSetArrowDirection = function (value) { * @returns {number} The arrow-position of the feature. */ Controller.prototype.getSetArrowPosition = function (value) { - return /** @type {number} */ (this.getSetProperty_(ngeoFormatFeatureProperties.ARROW_POSITION, value)); + return /** @type {number} */ this.getSetProperty_(ngeoFormatFeatureProperties.ARROW_POSITION, value); }; /** @@ -300,34 +290,26 @@ Controller.prototype.getSetProperty_ = function (key, value) { if (value !== undefined) { this.feature.set(key, value); } - return /** @type {boolean|number|string} */ (this.feature.get(key)); + return /** @type {boolean|number|string} */ this.feature.get(key); }; - Controller.prototype.handleFeatureChange_ = function () { const feature = this.feature; - if (!feature) { return; } - this.featureHelper_.setStyle(feature, true); }; - Controller.prototype.handleGeometryChange_ = function () { if (!this.feature) { throw new Error('Missing feature'); } this.measure = this.featureHelper_.getMeasure(this.feature); - const showMeasure = this.featureHelper_.getShowMeasureProperty(this.feature); const showArrow = this.featureHelper_.getShowArrowsProperty(this.feature); if (showMeasure || showArrow) { this.handleFeatureChange_(); } - this.scope_.$apply(); }; - myModule.controller('GmfFeaturestyleController', Controller); - export default myModule; diff --git a/src/dropfile/component.js b/src/dropfile/component.js index ece0a27e569d..c9c997abdf8d 100644 --- a/src/dropfile/component.js +++ b/src/dropfile/component.js @@ -35,7 +35,6 @@ import ngeoMessageNotification from 'ngeo/message/Notification'; * On drop the file is added to the external datasources if it is valid * Otherwise an alert message is shown * - * @ngInject * @param {import('gmf/datasource/ExternalDataSourcesManager').ExternalDatSourcesManager} gmfExternalDataSourcesManager The manager of external datasources. * @param {angular.gettext.gettextCatalog} gettextCatalog Gettext catalog. * @returns {angular.IDirective} The Directive Definition Object. @@ -54,12 +53,12 @@ const fileDrop = function (gmfExternalDataSourcesManager, gettextCatalog) { element.bind('dragover', processDrag_); element.bind('dragenter', processDrag_); element.bind('dragleave', processDrag_); - element.bind('drop', processDrop_.bind(this, element, gmfExternalDataSourcesManager, gettextCatalog)); }, }; }; - +fileDrop.$inject = ['gmfExternalDataSourcesManager', 'gettextCatalog']; +fileDrop.$inject = ['gmfExternalDataSourcesManager', 'gettextCatalog']; /** * Function to display and hide the 'drop-zone' element, which covers the element */ @@ -70,7 +69,6 @@ function processDrag_() { } if (event.type === 'dragenter' || event.type === 'dragleave') { const dropZone = document.getElementById('drop-zone'); - if (event.type === 'dragenter') { dropZone.classList.remove('drop-zone-off'); dropZone.classList.add('drop-zone'); @@ -112,7 +110,6 @@ function processDrop_(element, gmfExternalDataSourcesManager, gettextCatalog, ev if (!success) { const div = document.createElement('DIV'); div.id = 'file-alert'; - const alertElements = document.getElementsByClassName('gmf-app-map-messages'); if (alertElements && alertElements.length > 0) { div.classList.add('gmf-file-alert-contained'); @@ -128,7 +125,6 @@ function processDrop_(element, gmfExternalDataSourcesManager, gettextCatalog, ev target: document.querySelector('#file-alert'), delay: delay, }); - setTimeout(function () { const el = document.getElementById('file-alert'); el.remove(); @@ -142,7 +138,5 @@ function processDrop_(element, gmfExternalDataSourcesManager, gettextCatalog, ev * @hidden */ const myModule = angular.module('gmfFileDropZone', [gmfExternalDataSourcesManager.name]); - myModule.directive('gmfFileDropZone', fileDrop); - export default myModule; diff --git a/src/editing/EditFeature.js b/src/editing/EditFeature.js index e757990729a6..7ffe7649d923 100644 --- a/src/editing/EditFeature.js +++ b/src/editing/EditFeature.js @@ -1,3 +1,4 @@ +EditingEditFeature.$inject = ['$http', 'gmfLayersUrl']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -40,7 +41,6 @@ import {appendParams as olUriAppendParams} from 'ol/uri'; * @class * @param {angular.IHttpService} $http Angular http service. * @param {string} gmfLayersUrl URL to the GeoMapFish layers service. - * @ngInject * @hidden */ export function EditingEditFeature($http, gmfLayersUrl) { @@ -71,14 +71,10 @@ EditingEditFeature.prototype.getFeaturesInExtent = function (layerIds, extent) { const url = olUriAppendParams(`${this.baseUrl_}/${layerIds.join(',')}`, { 'bbox': extent.join(','), }); - return this.http_ - .get(url) - .then( - (response) => - /** @type {import('ol/Feature').default[]} */ ( - new olFormatGeoJSON().readFeatures(response.data) - ), - ); + return this.http_.get(url).then((response) => + /** @type {import('ol/Feature').default[]} */ + new olFormatGeoJSON().readFeatures(response.data), + ); }; /** @@ -98,24 +94,16 @@ EditingEditFeature.prototype.getFeaturesWithComparisonFilters = function (layerI const properties = []; /** @type {Object} */ const params = {}; - for (const filter of filters) { params[`${filter.property}__${filter.operator}`] = filter.value; properties.push(filter.property); } - params.queryable = properties.join(','); - const url = olUriAppendParams(`${this.baseUrl_}/${layerIds.join(',')}`, params); - - return this.http_ - .get(url) - .then( - (response) => - /** @type {import('ol/Feature').default[]} */ ( - new olFormatGeoJSON().readFeatures(response.data) - ), - ); + return this.http_.get(url).then((response) => + /** @type {import('ol/Feature').default[]} */ + new olFormatGeoJSON().readFeatures(response.data), + ); }; /** @@ -127,7 +115,9 @@ EditingEditFeature.prototype.insertFeatures = function (layerId, features) { const url = `${this.baseUrl_}/${layerId}`; const geoJSON = new olFormatGeoJSON().writeFeatures(features); return this.http_.post(url, geoJSON, { - headers: {'Content-Type': 'application/geo+json'}, + headers: { + 'Content-Type': 'application/geo+json', + }, withCredentials: true, }); }; @@ -141,7 +131,9 @@ EditingEditFeature.prototype.updateFeature = function (layerId, feature) { const url = `${this.baseUrl_}/${layerId.toString()}/${feature.getId()}`; const geoJSON = new olFormatGeoJSON().writeFeature(feature); return this.http_.put(url, geoJSON, { - headers: {'Content-Type': 'application/geo+json'}, + headers: { + 'Content-Type': 'application/geo+json', + }, withCredentials: true, }); }; @@ -164,5 +156,4 @@ EditingEditFeature.prototype.deleteFeature = function (layerId, feature) { */ const myModule = angular.module('gmfEditFeature', []); myModule.service('gmfEditFeature', EditingEditFeature); - export default myModule; diff --git a/src/editing/EnumerateAttribute.js b/src/editing/EnumerateAttribute.js index 7725a09bb0bf..51238c3f6517 100644 --- a/src/editing/EnumerateAttribute.js +++ b/src/editing/EnumerateAttribute.js @@ -31,7 +31,6 @@ export class EditingEnumerateAttributeService { * * @param {angular.IHttpService} $http Angular $http service. * @param {string} gmfLayersUrl URL to the GeoMapFish layers service. - * @ngInject * @ngdoc service * @ngname gmfEnumerateAttribute */ @@ -72,12 +71,11 @@ export class EditingEnumerateAttributeService { return this.promises_[promiseId]; } } - +EditingEnumerateAttributeService.$inject = ['$http', 'gmfLayersUrl']; /** * @type {angular.IModule} * @hidden */ const myModule = angular.module('gmfEnumerateAttribute', []); myModule.service('gmfEnumerateAttribute', EditingEnumerateAttributeService); - export default myModule; diff --git a/src/editing/Snapping.js b/src/editing/Snapping.js index dfe2dc1576b9..57b4b577743e 100644 --- a/src/editing/Snapping.js +++ b/src/editing/Snapping.js @@ -1,3 +1,16 @@ +EditingSnappingService.$inject = [ + '$http', + '$q', + '$rootScope', + '$injector', + '$timeout', + 'gmfDatasourceFileGroup', + 'gmfSnappingConfig', + 'gmfThemes', + 'gmfTreeManager', + 'ngeoFeatures', + 'gmfSnappingOptions', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -31,7 +44,6 @@ import {listen, unlistenByKey} from 'ol/events'; import olCollection, {CollectionEvent} from 'ol/Collection'; import olFormatWFS from 'ol/format/WFS'; import olInteractionSnap from 'ol/interaction/Snap'; - export class CustomSnap extends olInteractionSnap { /** * @param {import('ol/interaction/Snap').Options} options @@ -74,7 +86,6 @@ export class CustomSnap extends olInteractionSnap { * @param {import('ol/Collection').default>} ngeoFeatures Collection * of features. * @param {import('gmf/options.js').gmfSnappingOptions} gmfSnappingOptions The options. - * @ngInject * @ngdoc service * @ngname gmfSnapping */ @@ -264,7 +275,6 @@ EditingSnappingService.prototype.ensureSnapInteractionsOnTop = function () { */ EditingSnappingService.prototype.setMap = function (map) { const keys = this.listenerKeys_; - if (this.map_) { if (!this.treeCtrlsUnregister_) { throw new Error('Missing treeCtrlsUnregister'); @@ -275,9 +285,7 @@ EditingSnappingService.prototype.setMap = function (map) { keys.length = 0; this.map_.removeInteraction(this.ngeoFeaturesSnapInteraction_); } - this.map_ = map; - if (map) { // (1) Listen to the layer tree nodes changes to manage the WMS // (WFS) layers that support being snapped on. @@ -301,7 +309,6 @@ EditingSnappingService.prototype.setMap = function (map) { }, 0); }, ); - keys.push( // (2) Listen when the themes change to reobtain the OGC servers listen(this.gmfThemes_, 'change', this.handleThemesChange_, this), @@ -354,27 +361,25 @@ EditingSnappingService.prototype.handleThemesChange_ = function () { */ EditingSnappingService.prototype.registerTreeCtrl_ = function (treeCtrl) { // Skip any Layertree controller that has a node that is not a leaf - let node = /** @type {import('gmf/themes').GmfGroup|import('gmf/themes').GmfLayer} */ (treeCtrl.node); - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (node); + let node = /** @type {import('gmf/themes').GmfGroup|import('gmf/themes').GmfLayer} */ treeCtrl.node; + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ node; if (groupNode.children) { return; } // If treeCtrl is snappable and supports WFS, listen to its state change. // When it becomes visible, it's added to the list of snappable tree ctrls. - node = /** @type {import('gmf/themes').GmfLayer} */ (treeCtrl.node); + node = /** @type {import('gmf/themes').GmfLayer} */ treeCtrl.node; const snappingConfig = getSnappingConfig(node); const maxFeatures = this.gmfSnappingOptions_.maxFeatures || 50; if (snappingConfig) { const wfsConfig = this.getWFSConfig_(treeCtrl); if (wfsConfig) { const uid = olUtilGetUid(treeCtrl); - const stateWatcherUnregister = this.rootScope_.$watch( () => this.isSnappingActiveForTreeCtrl_(treeCtrl), this.handleTreeCtrlStateChange_.bind(this, treeCtrl), ); - const ogcServer = this.getOGCServer_(treeCtrl); if (!ogcServer) { throw new Error('Missing ogcServer'); @@ -421,19 +426,18 @@ EditingSnappingService.prototype.unregisterAllTreeCtrl_ = function () { * @returns {?import('gmf/themes').GmfOgcServer} The OGC server. */ EditingSnappingService.prototype.getOGCServer_ = function (treeCtrl) { - const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ (treeCtrl.node); + const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ treeCtrl.node; if (gmfLayer.type !== ThemeNodeType.WMS) { return null; } - const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ (/** @type {any} */ (gmfLayer)); - + const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ /** @type {any} */ gmfLayer; let ogcServerName; - const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.parent.node); + const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.parent.node; if (gmfGroup.mixed) { ogcServerName = gmfLayerWMS.ogcServer; } else { const firstTreeCtrl = getFirstParentTree(treeCtrl); - const firstNode = /** @type {import('gmf/themes').GmfGroup} */ (firstTreeCtrl.node); + const firstNode = /** @type {import('gmf/themes').GmfGroup} */ firstTreeCtrl.node; ogcServerName = firstNode.ogcServer; } if (!ogcServerName) { @@ -466,15 +470,13 @@ EditingSnappingService.prototype.getWFSConfig_ = function (treeCtrl) { if (this.ogcServers_ === null) { return null; } - - const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ (treeCtrl.node); + const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ treeCtrl.node; // (2) if (gmfLayer.type !== ThemeNodeType.WMS) { return null; } - - const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ (/** @type {any} */ (gmfLayer)); + const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ /** @type {any} */ gmfLayer; // (3) const featureTypes = []; @@ -499,7 +501,6 @@ EditingSnappingService.prototype.getWFSConfig_ = function (treeCtrl) { if (!urlWfs) { throw new Error('Missing urlWfs'); } - return { featureTypes: featureTypes.join(','), url: urlWfs, @@ -522,7 +523,7 @@ EditingSnappingService.prototype.isSnappingActiveForTreeCtrl_ = function (treeCt } return treeCtrl.properties.snapping; } - const node = /** @type {import('gmf/themes').GmfLayer} */ (treeCtrl.node); + const node = /** @type {import('gmf/themes').GmfLayer} */ treeCtrl.node; const config = getSnappingConfig(node); return config !== null && config.activated; }; @@ -534,7 +535,6 @@ EditingSnappingService.prototype.isSnappingActiveForTreeCtrl_ = function (treeCt EditingSnappingService.prototype.handleTreeCtrlStateChange_ = function (treeCtrl, newVal) { const uid = olUtilGetUid(treeCtrl); const item = this.cache_[uid]; - newVal ? this.activateItem_(item) : this.deactivateItem_(item); }; @@ -553,18 +553,14 @@ EditingSnappingService.prototype.activateItem_ = function (item) { if (item.active) { return; } - const map = this.map_; - const interaction = new CustomSnap({ edge: item.snappingConfig.edge, features: item.features, pixelTolerance: item.snappingConfig.tolerance, vertex: item.snappingConfig.vertex, }); - map.addInteraction(interaction); - item.interaction = interaction; item.active = true; @@ -587,15 +583,12 @@ EditingSnappingService.prototype.deactivateItem_ = function (item) { if (!item.active) { return; } - const map = this.map_; - const interaction = item.interaction; if (!interaction) { throw new Error('Missing interaction'); } map.removeInteraction(interaction); - item.interaction = null; item.features.clear(); @@ -604,11 +597,9 @@ EditingSnappingService.prototype.deactivateItem_ = function (item) { item.requestDeferred.resolve(); item.requestDeferred = null; } - item.active = false; this.refreshSnappingSource_(); }; - EditingSnappingService.prototype.loadAllItems_ = function () { this.mapViewChangePromise_ = null; let item; @@ -643,19 +634,15 @@ EditingSnappingService.prototype.loadItemFeatures_ = function (item) { if (item.requestDeferred) { item.requestDeferred.resolve(); } - const map = this.map_; - const view = map.getView(); const size = map.getSize(); if (!size) { throw new Error('Missing size'); } - const extent = view.calculateExtent(size); const projCode = view.getProjection().getCode(); const featureTypes = item.wfsConfig.featureTypes.split(','); - const getFeatureOptions = { srsName: projCode, featureNS: item.featureNS, @@ -666,17 +653,16 @@ EditingSnappingService.prototype.loadItemFeatures_ = function (item) { geometryName: DEFAULT_GEOMETRY_NAME, maxFeatures: item.maxFeatures, }; - const wfsFormat = new olFormatWFS(); const xmlSerializer = new XMLSerializer(); const featureRequestXml = wfsFormat.writeGetFeature(getFeatureOptions); const featureRequest = xmlSerializer.serializeToString(featureRequestXml); const url = item.wfsConfig.url; - item.requestDeferred = this.q_.defer(); - this.http_ - .post(url, featureRequest, {timeout: item.requestDeferred.promise}) + .post(url, featureRequest, { + timeout: item.requestDeferred.promise, + }) .then((response) => { // (1) Unset requestDeferred item.requestDeferred = null; @@ -686,9 +672,8 @@ EditingSnappingService.prototype.loadItemFeatures_ = function (item) { // (3) Read features from request response and add them to the item const readFeatures = - /** @type {import('ol/Feature.js').default[]} */ ( - new olFormatWFS().readFeatures(response.data) - ); + /** @type {import('ol/Feature.js').default[]} */ + new olFormatWFS().readFeatures(response.data); if (readFeatures) { item.features.extend(readFeatures); this.refreshSnappingSource_(); @@ -713,7 +698,6 @@ EditingSnappingService.prototype.handleMapMoveEnd_ = function () { } this.mapViewChangePromise_ = this.timeout_(this.loadAllItems_.bind(this), 400); }; - EditingSnappingService.prototype.refreshSnappingSource_ = function () { if (this.ngeoSnappingSource_ === undefined) { return; @@ -740,7 +724,6 @@ EditingSnappingService.prototype.handleFileGroupDataSourcesCollectionAdd_ = func if (!(evt instanceof CollectionEvent)) { return; } - const fileDataSource = evt.element; if (!(fileDataSource instanceof ngeoDatasourceFile)) { return; @@ -765,7 +748,6 @@ EditingSnappingService.prototype.handleFileGroupDataSourcesCollectionAdd_ = func }, this.handleFileDataSourceVisibleChange_.bind(this, fileDataSource), ); - const uid = olUtilGetUid(fileDataSource); // (3) Create and add the cache item @@ -791,17 +773,14 @@ EditingSnappingService.prototype.handleFileGroupDataSourcesCollectionRemove_ = f if (!(evt instanceof CollectionEvent)) { return; } - const fileDataSource = evt.element; if (!(fileDataSource instanceof ngeoDatasourceFile)) { return; } - const uid = olUtilGetUid(fileDataSource); if (!this.cacheFileDataSource_[uid]) { return; } - const item = this.cacheFileDataSource_[uid]; const map = this.map_; @@ -834,10 +813,8 @@ EditingSnappingService.prototype.handleFileDataSourceVisibleChange_ = function ( if (item.active === visible) { return; } - item.active = visible; const map = this.map_; - if (visible) { map.addInteraction(item.interaction); } else { @@ -895,5 +872,4 @@ const myModule = angular.module('gmfSnapping', [ ngeoLayertreeController.name, ]); myModule.service('gmfSnapping', EditingSnappingService); - export default myModule; diff --git a/src/editing/XSDAttributes.js b/src/editing/XSDAttributes.js index 051523d7625e..5c782b64c1de 100644 --- a/src/editing/XSDAttributes.js +++ b/src/editing/XSDAttributes.js @@ -1,3 +1,4 @@ +EditingXSDAttributeService.$inject = ['$http', 'gmfLayersUrl']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -29,7 +30,6 @@ import ngeoFormatXSDAttribute from 'ngeo/format/XSDAttribute'; * @class * @param {angular.IHttpService} $http Angular http service. * @param {string} gmfLayersUrl URL to the GeoMapFish layers service. - * @ngInject * @hidden */ export function EditingXSDAttributeService($http, gmfLayersUrl) { @@ -67,5 +67,4 @@ EditingXSDAttributeService.prototype.getAttributes = function (id) { */ const myModule = angular.module('gmfXSDAttributes', []); myModule.service('gmfXSDAttributes', EditingXSDAttributeService); - export default myModule; diff --git a/src/editing/attributesComponent.js b/src/editing/attributesComponent.js index edee0fba3492..c4d4dff85efe 100644 --- a/src/editing/attributesComponent.js +++ b/src/editing/attributesComponent.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$scope', 'ngeoEventHelper']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -35,18 +36,18 @@ const myModule = angular.module('ngeoAttributes', [ ngeoMiscDatetimepickerComponent.name, ngeoMiscEventHelper.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/editing/attributescomponent', require('./attributescomponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/editing/attributescomponent', require('./attributescomponent.html')); + }, + ], ); - myModule.value( 'ngeoAttributesTemplateUrl', /** @@ -63,10 +64,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} ngeoAttributesTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +ngeoAttributesTemplateUrl.$inject = ['$attrs', 'ngeoAttributesTemplateUrl']; function ngeoAttributesTemplateUrl($attrs, ngeoAttributesTemplateUrl) { return ngeoAttributesTemplateUrl($attrs); } @@ -101,7 +102,6 @@ const editingAttributeComponent = { }, templateUrl: ngeoAttributesTemplateUrl, }; - myModule.component('ngeoAttributes', editingAttributeComponent); /** @@ -109,7 +109,6 @@ myModule.component('ngeoAttributes', editingAttributeComponent); * @param {import('ngeo/misc/EventHelper').EventHelper} ngeoEventHelper Ngeo event helper service * @class * @hidden - * @ngInject * @ngdoc controller * @ngname ngeoAttributesController */ @@ -182,7 +181,6 @@ Controller.prototype.$onInit = function () { this.attributes.forEach((attribute) => { this.sanitize_(attribute); }); - this.ngeoEventHelper_.addListenerKey( uid, listen(this.feature, 'propertychange', this.handleFeaturePropertyChange_, this), @@ -251,7 +249,5 @@ Controller.prototype.handleFeaturePropertyChange_ = function (evt) { this.scope_.$apply(); } }; - myModule.controller('ngeoAttributesController', Controller); - export default myModule; diff --git a/src/editing/createfeatureComponent.js b/src/editing/createfeatureComponent.js index 8ff0ea9aa021..7b4f72d7d765 100644 --- a/src/editing/createfeatureComponent.js +++ b/src/editing/createfeatureComponent.js @@ -1,3 +1,13 @@ +Controller.$inject = [ + 'gettextCatalog', + '$compile', + '$filter', + '$injector', + '$scope', + '$timeout', + 'ngeoEventHelper', + 'ngeoSnappingTolerance', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -88,7 +98,6 @@ function editingCreateFeatureComponent() { }, }; } - myModule.directive('ngeoCreatefeature', editingCreateFeatureComponent); /** @@ -102,7 +111,6 @@ myModule.directive('ngeoCreatefeature', editingCreateFeatureComponent); * @param {import('ngeo/options').ngeoSnappingTolerance} ngeoSnappingTolerance The tolerance. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname ngeoCreatefeatureController */ @@ -228,32 +236,27 @@ Controller.prototype.$onInit = function () { if (this.injector_.has('ngeoSnappingSource')) { options.source = this.injector_.get('ngeoSnappingSource'); } - interaction = new ngeoInteractionMeasureLength(this.filter_('ngeoUnitPrefix'), gettextCatalog, options); } else if (this.geomType === ngeoGeometryType.POLYGON || this.geomType === ngeoGeometryType.MULTI_POLYGON) { const helpMsg = gettextCatalog.getString('Click to start drawing area'); const contMsg = gettextCatalog.getString( 'Click to continue drawing
' + 'Double-click or click starting point to finish', ); - interaction = new ngeoInteractionMeasureArea(this.filter_('ngeoUnitPrefix'), gettextCatalog, { style: new olStyleStyle(), startMsg: this.compile_(`
${helpMsg}
`)(this.scope_)[0], continueMsg: this.compile_(`
${contMsg}
`)(this.scope_)[0], }); } - if (!interaction) { throw new Error('Missing interaction'); } if (!this.map) { throw new Error('Missing map'); } - interaction.setActive(this.active); this.interaction_ = interaction; this.map.addInteraction(interaction); - const uid = olUtilGetUid(this); if (interaction instanceof olInteractionDraw) { this.ngeoEventHelper_.addListenerKey( @@ -261,7 +264,7 @@ Controller.prototype.$onInit = function () { listen( interaction, 'drawend', - /** @type {import('ol/events').ListenerFunction } */ (this.handleDrawEnd_), + /** @type {import('ol/events').ListenerFunction } */ this.handleDrawEnd_, this, ), ); @@ -274,7 +277,7 @@ Controller.prototype.$onInit = function () { listen( interaction, 'measureend', - /** @type {import('ol/events').ListenerFunction } */ (this.handleDrawEnd_), + /** @type {import('ol/events').ListenerFunction } */ this.handleDrawEnd_, this, ), ); @@ -329,6 +332,5 @@ Controller.prototype.$onDestroy = function () { this.map.removeInteraction(this.interaction_); }, 0); }; - myModule.controller('ngeoCreatefeatureController', Controller); export default myModule; diff --git a/src/editing/createregularpolygonfromclickComponent.js b/src/editing/createregularpolygonfromclickComponent.js index 7ec51d9da7e1..e6daefcc5622 100644 --- a/src/editing/createregularpolygonfromclickComponent.js +++ b/src/editing/createregularpolygonfromclickComponent.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$scope']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -88,14 +89,12 @@ function editingCreateRegularPolygonFromClickComponent() { }, }; } - myModule.directive('ngeoCreateregularpolygonfromclick', editingCreateRegularPolygonFromClickComponent); /** * @param {angular.IScope} $scope Scope. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname ngeoCreateregularpolygonfromclickController */ @@ -106,7 +105,6 @@ export function Controller($scope) { * @type {boolean} */ this.active = false; - $scope.$watch( () => this.active, (newVal) => { @@ -153,7 +151,6 @@ export function Controller($scope) { * @type {?import('ol/events').EventsKey} */ this.interactionListenerKey_ = null; - $scope.$on('$destroy', this.handleDestroy_.bind(this)); } @@ -173,14 +170,12 @@ Controller.prototype.$onInit = function () { } this.interaction_ = new ngeoInteractionDrawRegularPolygonFromClick(options); this.interaction_.setActive(this.active); - this.interactionListenerKey_ = listen( this.interaction_, 'drawend', - /** @type {import('ol/events').ListenerFunction} */ (this.handleDrawEnd_), + /** @type {import('ol/events').ListenerFunction} */ this.handleDrawEnd_, this, ); - this.map.addInteraction(this.interaction_); }; @@ -215,7 +210,5 @@ Controller.prototype.handleDestroy_ = function () { this.interaction_.setActive(false); this.map.removeInteraction(this.interaction_); }; - myModule.controller('ngeoCreateregularpolygonfromclickController', Controller); - export default myModule; diff --git a/src/editing/editFeatureComponent.js b/src/editing/editFeatureComponent.js index a173fad7bfd8..ba22931e0045 100644 --- a/src/editing/editFeatureComponent.js +++ b/src/editing/editFeatureComponent.js @@ -1,3 +1,18 @@ +Controller.$inject = [ + '$element', + '$q', + '$scope', + '$timeout', + 'gettextCatalog', + 'gmfEditFeature', + 'gmfSnapping', + 'gmfXSDAttributes', + 'ngeoEventHelper', + 'ngeoFeatureHelper', + 'ngeoLayerHelper', + 'ngeoToolActivateMgr', + 'gmfEditFeatureOptions', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -21,19 +36,14 @@ import angular from 'angular'; import gmfEditingEditFeature from 'gmf/editing/EditFeature'; - import gmfEditingSnapping from 'gmf/editing/Snapping'; - import gmfEditingXSDAttributes from 'gmf/editing/XSDAttributes'; import {getLayer as syncLayertreeMapGetLayer} from 'gmf/layertree/SyncLayertreeMap'; import DateFormatter from 'ngeo/misc/php-date-formatter'; import 'jquery-datetimepicker/jquery.datetimepicker'; import 'jquery-datetimepicker/jquery.datetimepicker.css'; - import ngeoEditingAttributesComponent from 'ngeo/editing/attributesComponent'; - import ngeoEditingCreatefeatureComponent from 'ngeo/editing/createfeatureComponent'; - import {deleteCondition} from 'ngeo/utils'; import {getGeometryAttribute} from 'ngeo/format/XSDAttribute'; import ngeoGeometryType from 'ngeo/GeometryType'; @@ -42,18 +52,13 @@ import ngeoInteractionTranslate from 'ngeo/interaction/Translate'; import ngeoMapLayerHelper from 'ngeo/map/LayerHelper'; import ngeoMenu from 'ngeo/Menu'; import ngeoMenuMulti from 'gmf/menu/MenuMultiFeature'; - import ngeoMessageModalComponent from 'ngeo/message/modalComponent'; - import ngeoMiscBtnComponent from 'ngeo/misc/btnComponent'; - import {interactionDecoration as ngeoMiscDecorateInteraction} from 'ngeo/misc/decorate'; import ngeoMiscEventHelper from 'ngeo/misc/EventHelper'; import ngeoMiscFeatureHelper from 'ngeo/misc/FeatureHelper'; import ngeoMiscToolActivate from 'ngeo/misc/ToolActivate'; - import ngeoMiscToolActivateMgr from 'ngeo/misc/ToolActivateMgr'; - import {getUid as olUtilGetUid} from 'ol/util'; import olCollection from 'ol/Collection'; import {listen, unlistenByKey} from 'ol/events'; @@ -133,16 +138,17 @@ const myModule = angular.module('GmfEditingFeatureComponent', [ ngeoMiscFeatureHelper.name, ngeoMiscToolActivateMgr.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/editing/editFeatureComponent', require('./editFeatureComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/editing/editFeatureComponent', require('./editFeatureComponent.html')); + }, + ], ); /** @@ -206,7 +212,6 @@ function editingEditFeatureComponent() { templateUrl: 'gmf/editing/editFeatureComponent', }; } - myModule.directive('gmfEditfeature', editingEditFeatureComponent); /** @@ -227,7 +232,6 @@ myModule.directive('gmfEditfeature', editingEditFeatureComponent); * @param {import('gmf/options').gmfEditFeatureOptions} gmfEditFeatureOptions The options. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname GmfEditfeatureController */ @@ -415,7 +419,6 @@ export function Controller( * @type {?olFeature} */ this.feature = null; - this.scope_.$watch(() => this.feature, this.handleFeatureChange_.bind(this)); /** @@ -586,7 +589,6 @@ Controller.prototype.$onInit = function () { }); this.highlightVectorLayer_.setMap(this.map); this.hightlightedFeatures_ = this.highlightVectorLayer_.getSource().getFeaturesCollection(); - const lang = this.gettextCatalog_.getCurrentLanguage(); // @ts-ignore: $.datetimepicker is available, as it is imported @@ -599,7 +601,7 @@ Controller.prototype.$onInit = function () { if (!this.editableTreeCtrl) { throw new Error('Missing editableTreeCtrl'); } - this.editableNode_ = /** @type {import('gmf/themes').GmfLayer} */ (this.editableTreeCtrl.node); + this.editableNode_ = /** @type {import('gmf/themes').GmfLayer} */ this.editableTreeCtrl.node; if (!this.vectorLayer) { throw new Error('Missing vectorLayer'); } @@ -623,7 +625,6 @@ Controller.prototype.$onInit = function () { style: this.ngeoFeatureHelper_.getVertexStyle(false), }); this.interactions_.push(this.modify_); - this.rotate_ = new ngeoInteractionRotate({ features: this.features, style: new olStyleStyle({ @@ -637,7 +638,6 @@ Controller.prototype.$onInit = function () { }), }); this.interactions_.push(this.rotate_); - this.translate_ = new ngeoInteractionTranslate({ features: this.features, style: new olStyleStyle({ @@ -651,9 +651,7 @@ Controller.prototype.$onInit = function () { }), }); this.interactions_.push(this.translate_); - this.initializeInteractions_(); - this.modifyToolActivate = new ngeoMiscToolActivate(this.modify_, 'active'); this.rotateToolActivate = new ngeoMiscToolActivate(this.rotate_, 'active'); this.translateToolActivate = new ngeoMiscToolActivate(this.translate_, 'active'); @@ -671,14 +669,10 @@ Controller.prototype.$onInit = function () { } }, ); - this.scope_.$on('$destroy', this.handleDestroy_.bind(this)); - const uid = olUtilGetUid(this); this.ngeoEventHelper_.addListenerKey(uid, listen(this.features, 'add', this.handleFeatureAdd_, this)); - this.scope_.$watch(() => this.mapSelectActive, this.handleMapSelectActiveChange_.bind(this)); - this.scope_.$watch( () => this.state, (newValue, oldValue) => { @@ -708,7 +702,6 @@ Controller.prototype.$onInit = function () { } }, ); - this.scope_.$watch( () => this.unsavedModificationsModalShown, (newValue, oldValue) => { @@ -739,11 +732,9 @@ Controller.prototype.save = function () { if (!this.editableNode_) { throw new Error('Missing editableNode'); } - const feature = this.feature.clone(); feature.setId(this.feature.getId()); const id = this.featureId; - this.pending = true; // Correct datetime on save @@ -765,7 +756,6 @@ Controller.prototype.save = function () { feature.set(attribute.name, dateFormatter.formatDate(formattedValue, jsonFormat)); } }); - const promise = id ? this.gmfEditFeature_.updateFeature(this.editableNode_.id, feature) : this.gmfEditFeature_.insertFeatures(this.editableNode_.id, [feature]); @@ -833,7 +823,6 @@ Controller.prototype.checkForModifications_ = function (scopeApply) { } else { this.confirmDeferred_.resolve(); } - return this.confirmDeferred_.promise; }; @@ -1019,12 +1008,10 @@ Controller.prototype.toggle_ = function (active) { if (!this.editableTreeCtrl) { throw new Error('Missing editableTreeCtrl'); } - const keys = this.listenerKeys_; const createUid = ['create-', olUtilGetUid(this)].join('-'); const otherUid = ['other-', olUtilGetUid(this)].join('-'); const toolMgr = this.ngeoToolActivateMgr_; - if (active) { if (!this.translate_) { throw new Error('Missing translate'); @@ -1040,10 +1027,8 @@ Controller.prototype.toggle_ = function (active) { keys.push(listen(this.menuVertex_, 'actionclick', this.handleMenuVertexActionClick_, this)); keys.push(listen(this.translate_, 'translateend', this.handleTranslateEnd_, this)); keys.push(listen(this.rotate_, 'rotateend', this.handleRotateEnd_, this)); - toolMgr.registerTool(createUid, this.createToolActivate, false); toolMgr.registerTool(createUid, this.mapSelectToolActivate, true); - toolMgr.registerTool(otherUid, this.createToolActivate, false); toolMgr.registerTool(otherUid, this.modifyToolActivate, true); toolMgr.registerTool(otherUid, this.translateToolActivate, false); @@ -1054,19 +1039,15 @@ Controller.prototype.toggle_ = function (active) { keys.forEach(unlistenByKey); keys.length = 0; - toolMgr.unregisterTool(createUid, this.createToolActivate); toolMgr.unregisterTool(createUid, this.mapSelectToolActivate); - toolMgr.unregisterTool(otherUid, this.createToolActivate); toolMgr.unregisterTool(otherUid, this.modifyToolActivate); toolMgr.unregisterTool(otherUid, this.translateToolActivate); toolMgr.unregisterTool(otherUid, this.rotateToolActivate); - this.createActive = false; this.cancel(); } - this.modify_.setActive(active); this.mapSelectActive = active; this.editableTreeCtrl.properties.editing = active; @@ -1081,12 +1062,10 @@ Controller.prototype.handleMapSelectActiveChange_ = function (active) { if (!this.map) { throw new Error('Missing map'); } - const mapDiv = this.map.getViewport(); if (!mapDiv) { throw new Error('Missing mapDiv'); } - if (active) { this.mapListenerKeys_.push( listen(this.map, 'click', this.handleMapClick_, this), @@ -1143,7 +1122,6 @@ Controller.prototype.handleMapClick_ = function (evt) { layerFilter: undefined, }, ); - if (feature) { return; } @@ -1157,7 +1135,6 @@ Controller.prototype.handleMapClick_ = function (evt) { if (!this.editableNode_) { throw new Error('Missing editableNode'); } - const map = this.map; const view = map.getView(); const resolution = view.getResolution(); @@ -1191,7 +1168,6 @@ Controller.prototype.handleMapContextMenu_ = function (evt) { } const pixel = this.map.getEventPixel(evt); const coordinate = this.map.getCoordinateFromPixel(pixel); - let feature = this.map.forEachFeatureAtPixel( pixel, (feature) => { @@ -1212,9 +1188,7 @@ Controller.prototype.handleMapContextMenu_ = function (evt) { layerFilter: undefined, }, ); - feature = feature ? feature : null; - this.menu_.close(); this.menuVertex_.close(); this.vertexInfo_ = null; @@ -1240,7 +1214,6 @@ Controller.prototype.handleMapContextMenu_ = function (evt) { this.menu_.open(coordinate); } } - evt.preventDefault(); evt.stopPropagation(); } @@ -1261,12 +1234,10 @@ Controller.prototype.setFeature_ = function (feature) { */ Controller.prototype.handleGetFeatures_ = function (coordinate, features) { this.pending = false; - this.timeout_(() => { if (!this.features) { throw new Error('Missing features'); } - if (features.length === 1) { this.setFeature_(features[0]); } else if (features.length > 1) { @@ -1298,7 +1269,6 @@ Controller.prototype.openFeatureMenu_ = function (coordinate, features) { }; actions.push(choice); }); - this.menuMultiple_ = new ngeoMenuMulti({ actions, }); @@ -1321,7 +1291,6 @@ Controller.prototype.openFeatureMenu_ = function (coordinate, features) { this.menuMultipleListenerKeys_.push( listen(this.menuMultiple_, 'actionclick', this.handleMenuMultipleActionClick_.bind(this, features), this), ); - this.map.addOverlay(this.menuMultiple_); if (features[0].getGeometry().getType() === 'MultiPoint') { const resolution = this.map.getView().getResolution(); @@ -1379,7 +1348,6 @@ Controller.prototype.handleFeatureChange_ = function (newFeature, oldFeature) { this.geomListenerKeys_.forEach(unlistenByKey); this.unregisterInteractions_(); } - if (newFeature) { this.featureId = newFeature.getId(); geom = newFeature.getGeometry(); @@ -1388,7 +1356,6 @@ Controller.prototype.handleFeatureChange_ = function (newFeature, oldFeature) { listen(geom, 'change', this.handleFeatureGeometryChange_, this), ); this.registerInteractions_(); - this.gmfSnapping_.ensureSnapInteractionsOnTop(); // The `ui-date` triggers an unwanted change, i.e. it converts the text @@ -1405,11 +1372,9 @@ Controller.prototype.handleFeatureChange_ = function (newFeature, oldFeature) { this.featureId = undefined; } }; - Controller.prototype.handleFeaturePropertyChange_ = function () { this.dirty = true; }; - Controller.prototype.handleFeatureGeometryChange_ = function () { this.dirty = true; this.scope_.$apply(); @@ -1419,8 +1384,7 @@ Controller.prototype.handleFeatureGeometryChange_ = function () { * @param {Event|import('ol/events/Event').default} evt Event. */ Controller.prototype.handleMenuActionClick_ = function (evt) { - const action = /** @type {import('ngeo/filter/ruleComponent').MenuEvent} */ (evt).detail.action; - + const action = /** @type {import('ngeo/filter/ruleComponent').MenuEvent} */ evt.detail.action; switch (action) { case 'move': if (!this.translate_) { @@ -1445,8 +1409,7 @@ Controller.prototype.handleMenuActionClick_ = function (evt) { * @param {Event|import('ol/events/Event').default} evt Event. */ Controller.prototype.handleMenuVertexActionClick_ = function (evt) { - const action = /** @type {import('ngeo/filter/ruleComponent').MenuEvent} */ (evt).detail.action; - + const action = /** @type {import('ngeo/filter/ruleComponent').MenuEvent} */ evt.detail.action; switch (action) { case 'delete': if (!this.feature) { @@ -1486,7 +1449,6 @@ Controller.prototype.handleRotateEnd_ = function (evt) { this.rotate_.setActive(false); this.scope_.$apply(); }; - Controller.prototype.handleDestroy_ = function () { if (!this.features) { throw new Error('Missing features'); @@ -1509,7 +1471,7 @@ Controller.prototype.handleDestroy_ = function () { * @param {Event|import('ol/events/Event').default} evt Event. */ Controller.prototype.handleMenuMultipleActionClick_ = function (features, evt) { - const action = /** @type {import('ngeo/filter/ruleComponent').MenuEvent} */ (evt).detail.action; + const action = /** @type {import('ngeo/filter/ruleComponent').MenuEvent} */ evt.detail.action; const feature = Object.values(features).filter((feature) => feature.getId() === action); this.setFeature_(feature[0]); this.hightlightedFeatures_.clear(); @@ -1522,7 +1484,7 @@ Controller.prototype.handleMenuMultipleActionClick_ = function (features, evt) { * @param {Event|import('ol/events/Event').default} evt Event. */ Controller.prototype.handleMultiMenuActionMouseEnter_ = function (features, evt) { - const action = /** @type {import('ngeo/filter/ruleComponent').MenuEvent} */ (evt).detail.action; + const action = /** @type {import('ngeo/filter/ruleComponent').MenuEvent} */ evt.detail.action; const feature = Object.values(features).filter((feature) => feature.getId() === action); this.hightlightedFeatures_.push(feature[0]); }; @@ -1533,7 +1495,5 @@ Controller.prototype.handleMultiMenuActionMouseEnter_ = function (features, evt) Controller.prototype.handleMultiMenuActionMouseOut_ = function () { this.hightlightedFeatures_.clear(); }; - myModule.controller('GmfEditfeatureController', Controller); - export default myModule; diff --git a/src/editing/editFeatureSelectorComponent.js b/src/editing/editFeatureSelectorComponent.js index 89ff8e042f02..cf6e1ded5c02 100644 --- a/src/editing/editFeatureSelectorComponent.js +++ b/src/editing/editFeatureSelectorComponent.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$scope', '$timeout', 'gmfThemes', 'gmfTreeManager']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -20,9 +21,7 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - import gmfEditingEditFeatureComponent, {EditingState} from 'gmf/editing/editFeatureComponent'; - import gmfLayertreeTreeManager from 'gmf/layertree/TreeManager'; import gmfThemeThemes from 'gmf/theme/Themes'; @@ -35,19 +34,20 @@ const myModule = angular.module('GmfEditingFeatureSelectorComponent', [ gmfLayertreeTreeManager.name, gmfThemeThemes.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - $templateCache.put( - 'gmf/editing/editFeatureSelectorComponent', - // @ts-ignore: webpack - require('./editFeatureSelectorComponent.html'), - ); - }, + [ + '$templateCache', + ($templateCache) => { + $templateCache.put( + 'gmf/editing/editFeatureSelectorComponent', + // @ts-ignore: webpack + require('./editFeatureSelectorComponent.html'), + ); + }, + ], ); /** @@ -89,7 +89,6 @@ function editingEditFeatureComponent() { templateUrl: 'gmf/editing/editFeatureSelectorComponent', }; } - myModule.directive('gmfEditfeatureselector', editingEditFeatureComponent); /** @@ -100,7 +99,6 @@ myModule.directive('gmfEditfeatureselector', editingEditFeatureComponent); * service. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname GmfEditfeatureselectorController */ @@ -111,7 +109,6 @@ export function Controller($scope, $timeout, gmfThemes, gmfTreeManager) { * @type {boolean} */ this.active = this.active === true; - $scope.$watch(() => this.active, this.handleActiveChange_.bind(this)); /** @@ -156,11 +153,10 @@ export function Controller($scope, $timeout, gmfThemes, gmfTreeManager) { this.$timeout_(() => { if (value) { const editables = this.editableTreeCtrls; - editables.length = 0; if (this.gmfTreeManager_.rootCtrl) { this.gmfTreeManager_.rootCtrl.traverseDepthFirst((treeCtrl) => { - const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ (treeCtrl.node); + const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ treeCtrl.node; if (gmfLayer.editable) { editables.push(treeCtrl); } @@ -203,7 +199,6 @@ export function Controller($scope, $timeout, gmfThemes, gmfTreeManager) { * @type {?import('ngeo/layertree/Controller').LayertreeController} */ this.selectedEditableTreeCtrl = null; - $scope.$watch( () => this.selectedEditableTreeCtrl, (newValue, oldValue) => { @@ -222,7 +217,6 @@ export function Controller($scope, $timeout, gmfThemes, gmfTreeManager) { * @type {string} */ this.state = EditingState.IDLE; - $scope.$watch( () => this.state, (newValue, oldValue) => { @@ -234,7 +228,6 @@ export function Controller($scope, $timeout, gmfThemes, gmfTreeManager) { } }, ); - $scope.$on('$destroy', this.handleDestroy_.bind(this)); } @@ -270,11 +263,8 @@ Controller.prototype.handleActiveChange_ = function (active) { } } }; - Controller.prototype.handleDestroy_ = function () { this.treeCtrlsWatcherUnregister_(); }; - myModule.controller('GmfEditfeatureselectorController', Controller); - export default myModule; diff --git a/src/editing/exportfeaturesComponent.js b/src/editing/exportfeaturesComponent.js index 62eaf1152af6..74fee78c3fd7 100644 --- a/src/editing/exportfeaturesComponent.js +++ b/src/editing/exportfeaturesComponent.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$element', '$injector', '$scope', 'ngeoFeatureHelper']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -49,7 +50,6 @@ const myModule = angular.module('ngeoExportfeatures', [ngeoMiscFeatureHelper.nam * @htmlAttribute {import('ol/Collection').default>} * ngeo-exportfeatures-features The features to export * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoExportfeatures */ @@ -62,7 +62,6 @@ function editingExportFeaturesComponent() { }, }; } - myModule.directive('ngeoExportfeatures', editingExportFeaturesComponent); /** @@ -72,7 +71,6 @@ myModule.directive('ngeoExportfeatures', editingExportFeaturesComponent); * @param {import('ngeo/misc/FeatureHelper').FeatureHelper} ngeoFeatureHelper Ngeo feature helper service. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname ngeoExportfeaturesController */ @@ -86,7 +84,6 @@ export function Controller($element, $injector, $scope, ngeoFeatureHelper) { * @type {JQuery} */ this.element_ = $element; - const uid = olUtilGetUid(this); const id = ['ngeo-exportfeature', uid].join('-'); @@ -125,9 +122,7 @@ export function Controller($element, $injector, $scope, ngeoFeatureHelper) { 'class': 'dropdown-menu', 'aria-labelledby': id, }).appendTo($element.parent()[0]); - this.menu_ = $menu; - formats.forEach((format) => { const item = $('', { 'href': '#', @@ -144,9 +139,7 @@ export function Controller($element, $injector, $scope, ngeoFeatureHelper) { * @type {string[]} */ this.formats_ = formats; - $element.on(['click', id].join('.'), this.handleElementClick_.bind(this)); - $scope.$on('$destroy', this.handleDestroy_.bind(this)); } @@ -164,9 +157,7 @@ Controller.prototype.handleElementClick_ = function () { if (!this.features) { throw new Error('Missing features'); } - const features = this.features.getArray(); - if (this.formats_.length === 1) { this.featureHelper_.export(features, this.formats_[0]); } else if (features.length === 1) { @@ -215,9 +206,7 @@ Controller.prototype.handleMenuItemClick_ = function (format, event) { */ Controller.prototype.handleDestroy_ = function () { const id = this.id_; - this.element_.off(['click', id].join('.')); - if (this.menu_) { this.menu_.remove(); this.items_.forEach(($item) => { @@ -227,7 +216,5 @@ Controller.prototype.handleDestroy_ = function () { this.menu_ = null; } }; - myModule.controller('ngeoExportfeaturesController', Controller); - export default myModule; diff --git a/src/filter/RuleHelper.js b/src/filter/RuleHelper.js index 6a1468e250eb..d3c84223d706 100644 --- a/src/filter/RuleHelper.js +++ b/src/filter/RuleHelper.js @@ -36,7 +36,6 @@ import ngeoRuleSelect from 'ngeo/rule/Select'; import ngeoRuleText from 'ngeo/rule/Text'; import {writeFilter} from 'ol/format/WFS'; import * as olFormatFilter from 'ol/format/filter'; - import moment from 'moment'; /** @@ -80,7 +79,6 @@ export class RuleHelper { * @param {import('ngeo/misc/WMSTime').WMSTime} ngeoWMSTime wms time service. * @ngdoc service * @ngname ngeoRuleHelper - * @ngInject */ constructor(gettextCatalog, ngeoFeatureHelper, ngeoWMSTime) { /** @@ -221,7 +219,6 @@ export class RuleHelper { } break; } - return rule; } @@ -260,15 +257,15 @@ export class RuleHelper { case ngeoFormatAttributeType.SELECT: // Compatibility with filters saved before version 2.6 if (options.expression) { - const expression = /** @type {string} */ (options.expression); + const expression = /** @type {string} */ options.expression; options.literal = expression.split(','); } - const selectOptions = /** @type {import('ngeo/rule/Select').SelectOptions} */ (options); + const selectOptions = /** @type {import('ngeo/rule/Select').SelectOptions} */ options; console.assert(selectOptions.choices); rule = new ngeoRuleSelect(selectOptions); break; default: - rule = new ngeoRuleText(/** @type {import('ngeo/rule/Text').TextOptions} */ (options)); + rule = new ngeoRuleText(/** @type {import('ngeo/rule/Text').TextOptions} */ options); break; } return rule; @@ -304,7 +301,6 @@ export class RuleHelper { if (rule.upperBoundary !== null) { options.upperBoundary = rule.upperBoundary; } - let clone; if (rule instanceof ngeoRuleDate) { clone = new ngeoRuleDate(options); @@ -312,16 +308,15 @@ export class RuleHelper { clone = new ngeoRuleGeometry(options); clone.feature.setProperties(this.ngeoFeatureHelper_.getNonSpatialProperties(rule.feature)); } else if (rule instanceof ngeoRuleSelect) { - const opt = /** @type {import('ngeo/rule/Select').SelectOptions} */ (options); + const opt = /** @type {import('ngeo/rule/Select').SelectOptions} */ options; opt.choices = rule.choices.slice(0); clone = new ngeoRuleSelect(opt); } else if (rule instanceof ngeoRuleText) { - const opt = /** @type {import('ngeo/rule/Text').TextOptions} */ (options); + const opt = /** @type {import('ngeo/rule/Text').TextOptions} */ options; clone = new ngeoRuleText(opt); } else { clone = new ngeoRuleRule(options); } - return clone; } @@ -338,19 +333,15 @@ export class RuleHelper { if (destRule.literal !== sourceRule.literal) { destRule.literal = sourceRule.literal; } - if (destRule.lowerBoundary !== sourceRule.lowerBoundary) { destRule.lowerBoundary = sourceRule.lowerBoundary; } - if (destRule.operator !== sourceRule.operator) { destRule.operator = sourceRule.operator; } - if (destRule.upperBoundary !== sourceRule.upperBoundary) { destRule.upperBoundary = sourceRule.upperBoundary; } - if (sourceRule instanceof ngeoRuleGeometry && destRule instanceof ngeoRuleGeometry) { this.ngeoFeatureHelper_.clearNonSpatialProperties(destRule.feature); destRule.feature.setProperties(this.ngeoFeatureHelper_.getNonSpatialProperties(sourceRule.feature)); @@ -381,27 +372,21 @@ export class RuleHelper { propertyName: rule.propertyName, type: rule.type, }; - if (rule.literal !== null) { obj.literal = rule.literal; } - if (rule.lowerBoundary !== null) { obj.lowerBoundary = rule.lowerBoundary; } - if (rule.operator !== null) { obj.operator = rule.operator; } - if (rule.operators !== null) { obj.operators = rule.operators.slice(0); } - if (rule.upperBoundary !== null) { obj.upperBoundary = rule.upperBoundary; } - if (rule instanceof ngeoRuleGeometry) { /** * @type {import('ngeo/rule/Geometry').GeometryOptions} @@ -409,12 +394,10 @@ export class RuleHelper { const opt = obj; opt.featureProperties = this.ngeoFeatureHelper_.getNonSpatialProperties(rule.feature); } - if (rule instanceof ngeoRuleSelect) { - const opt = /** @type {import('ngeo/rule/Select').SelectOptions} */ (obj); + const opt = /** @type {import('ngeo/rule/Select').SelectOptions} */ obj; opt.choices = rule.choices; } - return obj; } @@ -428,13 +411,11 @@ export class RuleHelper { createFilter(options) { const dataSource = options.dataSource; let mainFilter = null; - if (options.filter) { mainFilter = options.filter; } else { const rules = options.filterRules || dataSource.filterRules; const conditions = []; - if (rules && rules.length) { for (const rule of rules) { const filter = this.createFilterFromRule_(rule, dataSource, options.srsName); @@ -443,7 +424,6 @@ export class RuleHelper { } } } - const condition = dataSource.filterCondition; if (conditions.length === 1) { mainFilter = conditions[0]; @@ -458,17 +438,14 @@ export class RuleHelper { mainFilter = olFormatFilter.not(mainFilter); } } - if (options.incTime) { const timeFilter = this.createTimeFilterFromDataSource_(dataSource); mainFilter = this.joinFilters(mainFilter, timeFilter); } - if (options.incDimensions) { const dimensionsFilter = this.createDimensionsFilterFromDataSource_(dataSource); mainFilter = this.joinFilters(mainFilter, dimensionsFilter); } - return mainFilter; } @@ -525,35 +502,28 @@ export class RuleHelper { */ createFilterFromRule_(rule, dataSource, opt_srsName) { let filter = null; - const value = rule.value; if (!value) { return null; } - - const literal = /** @type {import('ngeo/rule/Rule').RuleOptions} */ (value).literal; - const lowerBoundary = /** @type {import('ngeo/rule/Rule').RuleOptions} */ (value).lowerBoundary; + const literal = /** @type {import('ngeo/rule/Rule').RuleOptions} */ value.literal; + const lowerBoundary = /** @type {import('ngeo/rule/Rule').RuleOptions} */ value.lowerBoundary; const operator = value.operator; const propertyName = value.propertyName; - const upperBoundary = /** @type {import('ngeo/rule/Rule').RuleOptions} */ (value).upperBoundary; - + const upperBoundary = /** @type {import('ngeo/rule/Rule').RuleOptions} */ value.upperBoundary; const rot = RuleOperatorType; const rsot = RuleSpatialOperatorType; const rtot = RuleTemporalOperatorType; - const spatialTypes = [rsot.CONTAINS, rsot.INTERSECTS, rsot.WITHIN]; - const numericTypes = [ rot.GREATER_THAN, rot.GREATER_THAN_OR_EQUAL_TO, rot.LESSER_THAN, rot.LESSER_THAN_OR_EQUAL_TO, ]; - if (rule instanceof ngeoRuleDate) { let beginValue; let endValue; - if (operator === rtot.DURING) { beginValue = moment(lowerBoundary).format('YYYY-MM-DD'); endValue = moment(upperBoundary).format('YYYY-MM-DD'); @@ -622,7 +592,7 @@ export class RuleHelper { } else if (operator === rot.BETWEEN) { filter = olFormatFilter.between(propertyName, lowerBoundary, upperBoundary); } else if (operator === rot.EQUAL_TO) { - filter = olFormatFilter.equalTo(propertyName, /** @type {?number|string} */ (literal)); + filter = olFormatFilter.equalTo(propertyName, /** @type {?number|string} */ literal); } else if (operator === rot.LIKE) { const stringLiteral = String(literal).replace(/!/g, '!!').replace(/\./g, '!.').replace(/\*/g, '!*'); filter = olFormatFilter.like( @@ -634,9 +604,8 @@ export class RuleHelper { false /* matchCase */, ); } else if (operator === rot.NOT_EQUAL_TO) { - filter = olFormatFilter.notEqualTo(propertyName, /** @type {?number|string} */ (literal)); + filter = olFormatFilter.notEqualTo(propertyName, /** @type {?number|string} */ literal); } - return filter; } @@ -652,7 +621,6 @@ export class RuleHelper { createDimensionsFilterFromDataSource_(dataSource) { const config = dataSource.dimensionsFiltersConfig || {}; const dimensions = dataSource.dimensions; - const conditions = []; for (const key in config) { let value = config[key].value; @@ -688,14 +656,12 @@ export class RuleHelper { const range = dataSource.timeRangeValue; const timeProperty = dataSource.timeProperty; const name = dataSource.timeAttributeName; - if (range && timeProperty && name) { if (range.end !== undefined) { // Case 1: the range has both 'start' and 'end' values. Use them to // create a During filter. const values = this.ngeoWMSTime_.formatWMSTimeParam(timeProperty, range).split('/'); - filter = olFormatFilter.during(name, values[0], values[1]); } else { // Case 2: we only have a 'start' value. We need to calculate the 'end' @@ -704,7 +670,6 @@ export class RuleHelper { const resolution = timeProperty.resolution || 'seconds'; const value = this.ngeoWMSTime_.formatWMSTimeParam(timeProperty, range); let momentEnd; - switch (resolution) { case 'year': momentEnd = moment(value).add(1, 'years').subtract(1, 'seconds'); @@ -720,7 +685,6 @@ export class RuleHelper { // This would require a TContains filter, which neither OpenLayers // and MapServer support. Skip... } - if (momentEnd) { const startValue = moment(value).utc().format('YYYY-MM-DD HH:mm:ss'); const endValue = momentEnd.utc().format('YYYY-MM-DD HH:mm:ss'); @@ -728,16 +692,14 @@ export class RuleHelper { } } } - return filter; } } - +RuleHelper.$inject = ['gettextCatalog', 'ngeoFeatureHelper', 'ngeoWMSTime']; /** * @type {angular.IModule} * @hidden */ const myModule = angular.module('ngeoRuleHelper', [ngeoMiscFeatureHelper.name, ngeoMiscWMSTime.name]); myModule.service('ngeoRuleHelper', RuleHelper); - export default myModule; diff --git a/src/filter/component.js b/src/filter/component.js index 032e509cb519..1faf33383535 100644 --- a/src/filter/component.js +++ b/src/filter/component.js @@ -22,11 +22,8 @@ import angular from 'angular'; import ngeoQueryMapQuerent from 'ngeo/query/MapQuerent'; import ngeoFilterCondition from 'ngeo/filter/Condition'; - import ngeoFilterRuleComponent from 'ngeo/filter/ruleComponent'; - import ngeoFilterRuleHelper from 'ngeo/filter/RuleHelper'; - import ngeoFormatAttributeType from 'ngeo/format/AttributeType'; import ngeoRuleGeometry from 'ngeo/rule/Geometry'; import {getUid as olUtilGetUid} from 'ol/util'; @@ -49,18 +46,18 @@ const myModule = angular.module('ngeoFilter', [ ngeoFilterRuleComponent.name, ngeoQueryMapQuerent.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/filter', require('./component.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/filter', require('./component.html')); + }, + ], ); - myModule.value( 'ngeoFilterTemplateUrl', /** @@ -77,14 +74,13 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} ngeoFilterTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +ngeoFilterTemplateUrl.$inject = ['$attrs', 'ngeoFilterTemplateUrl']; function ngeoFilterTemplateUrl($attrs, ngeoFilterTemplateUrl) { return ngeoFilterTemplateUrl($attrs); } - myModule.component('ngeoFilter', { bindings: { 'aRuleIsActive': '=', @@ -112,7 +108,6 @@ export class FilterController { * @param {angular.ITimeoutService} $timeout Angular timeout service. * @param {import('ngeo/query/MapQuerent').MapQuerent} ngeoMapQuerent The ngeo map querent service. * @param {import('ngeo/filter/RuleHelper').RuleHelper} ngeoRuleHelper Ngeo rule helper service. - * @ngInject * @ngdoc controller * @ngname NgeoFilterController */ @@ -242,9 +237,7 @@ export class FilterController { if (!this.datasource) { throw new Error('Missing datasource'); } - this.scope_.$watch(() => this.aRuleIsActive, this.handleARuleIsActiveChange_.bind(this)); - this.scope_.$watch( () => this.datasource.filterRules, () => { @@ -358,7 +351,6 @@ export class FilterController { if (!filterRules.length) { return; } - const dataSource = this.datasource; const limit = 1000; const map = this.map; @@ -371,7 +363,6 @@ export class FilterController { if (!filter) { throw new Error('Missing filter'); } - this.ngeoMapQuerent_.issue({ dataSources: [dataSource], filter: filter, @@ -458,7 +449,6 @@ export class FilterController { () => rule.active, this.handleRuleActiveChange_.bind(this), ); - if (rule instanceof ngeoRuleGeometry) { this.featureOverlay.addFeature(rule.feature); } @@ -476,7 +466,6 @@ export class FilterController { console.assert(unlistener); unlistener(); delete this.ruleUnlisteners_[uid]; - if (rule instanceof ngeoRuleGeometry) { this.featureOverlay.removeFeature(rule.feature); } @@ -529,7 +518,6 @@ export class FilterController { } } } - +FilterController.$inject = ['gettextCatalog', '$scope', '$timeout', 'ngeoMapQuerent', 'ngeoRuleHelper']; myModule.controller('ngeoFilterController', FilterController); - export default myModule; diff --git a/src/filter/ruleComponent.js b/src/filter/ruleComponent.js index de7cc35acb51..ae7427e2849d 100644 --- a/src/filter/ruleComponent.js +++ b/src/filter/ruleComponent.js @@ -22,17 +22,13 @@ import angular from 'angular'; import ngeoMenu from 'ngeo/Menu'; import ngeoDrawComponent from 'ngeo/draw/component'; - import ngeoFilterRuleHelper from 'ngeo/filter/RuleHelper'; - import ngeoFormatAttributeType from 'ngeo/format/AttributeType'; import ngeoGeometryType from 'ngeo/GeometryType'; import ngeoInteractionModify from 'ngeo/interaction/Modify'; import ngeoInteractionRotate from 'ngeo/interaction/Rotate'; import ngeoInteractionTranslate from 'ngeo/interaction/Translate'; - import ngeoMiscDatepickerComponent from 'ngeo/misc/datepickerComponent'; - import {interactionDecoration as ngeoMiscDecorateInteraction} from 'ngeo/misc/decorate'; import ngeoMiscFeatureHelper from 'ngeo/misc/FeatureHelper'; import ngeoMiscToolActivate from 'ngeo/misc/ToolActivate'; @@ -69,18 +65,18 @@ const myModule = angular.module('ngeoRule', [ ngeoMiscFeatureHelper.name, ngeoMiscToolActivateMgr.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/filter/rulecomponent', require('./rulecomponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/filter/rulecomponent', require('./rulecomponent.html')); + }, + ], ); - myModule.value( 'ngeoRuleTemplateUrl', /** @@ -97,10 +93,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} ngeoRuleTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +ngeoRuleTemplateUrl.$inject = ['$attrs', 'ngeoRuleTemplateUrl']; function ngeoRuleTemplateUrl($attrs, ngeoRuleTemplateUrl) { return ngeoRuleTemplateUrl($attrs); } @@ -118,7 +114,6 @@ export class RuleController { * @param {import('ngeo/filter/RuleHelper').RuleHelper} ngeoRuleHelper Ngeo rule helper service. * @param {import('ngeo/misc/ToolActivateMgr').ToolActivateMgr} ngeoToolActivateMgr Ngeo ToolActivate * manager service. - * @ngInject * @ngdoc controller * @ngname NgeoRuleController */ @@ -195,7 +190,6 @@ export class RuleController { * @type {?import('ngeo/rule/Rule').default} */ this.clone = null; - const operatorType = RuleOperatorType; const spatialOperatorType = RuleSpatialOperatorType; const temporalOperatorType = RuleTemporalOperatorType; @@ -362,7 +356,6 @@ export class RuleController { * @private */ this.listenerKeys_ = []; - this.initializeInteractions_(); /** @@ -403,11 +396,8 @@ export class RuleController { throw new Error('Missing rule'); } this.clone = this.ngeoRuleHelper_.cloneRule(this.rule); - this.toolActivate_ = new ngeoMiscToolActivate(this.rule, 'active'); - this.ngeoToolActivateMgr_.registerTool(this.toolGroup, this.toolActivate_); - this.scope_.$watch(() => { if (!this.rule) { throw new Error('Missing rule'); @@ -436,7 +426,7 @@ export class RuleController { if (!this.clone) { throw new Error('Missing clone'); } - const literal = /** @type {string|number} */ (this.clone.literal); + const literal = /** @type {string|number} */ this.clone.literal; return literal; }, /** @@ -667,7 +657,7 @@ export class RuleController { throw new Error('Missing clone'); } const rule = this.clone; - const choices = rule.literal ? /** @type {string[]} */ (rule.literal) : []; + const choices = rule.literal ? /** @type {string[]} */ rule.literal : []; const idx = choices.indexOf(choice); if (idx > -1) { choices.splice(idx, 1); @@ -705,12 +695,10 @@ export class RuleController { */ createDate_(opt_timeDelta) { const date = new Date(); - if (opt_timeDelta !== undefined) { const time = date.getTime() - opt_timeDelta; date.setTime(time); } - return date.toISOString(); } @@ -750,7 +738,6 @@ export class RuleController { if (!this.featureOverlay) { throw new Error('Missing featureOverlay'); } - if ( !(this.rule instanceof ngeoRuleGeometry) || !(this.clone instanceof ngeoRuleGeometry) || @@ -758,17 +745,13 @@ export class RuleController { ) { return; } - const keys = this.listenerKeys_; const uid = ['ngeo-rule-', olUtilGetUid(this)].join('-'); const toolMgr = this.ngeoToolActivateMgr_; - const ruleFeature = this.rule.feature; const cloneFeature = this.clone.feature; - const mapDiv = this.map.getViewport(); console.assert(mapDiv); - if (active) { keys.push( listen(this.drawnFeatures, 'add', this.handleFeaturesAdd_, this), @@ -776,19 +759,14 @@ export class RuleController { listen(this.translate_, 'translateend', this.handleTranslateEnd_, this), listen(this.rotate_, 'rotateend', this.handleRotateEnd_, this), ); - this.featureOverlay.removeFeature(ruleFeature); this.featureOverlay.addFeature(cloneFeature); - this.registerInteractions_(); - toolMgr.registerTool(uid, this.drawToolActivate, false); toolMgr.registerTool(uid, this.modifyToolActivate, true); toolMgr.registerTool(uid, this.rotateToolActivate, false); toolMgr.registerTool(uid, this.translateToolActivate, false); - this.modify_.setActive(true); - if (cloneFeature.getGeometry()) { this.ngeoFeatureHelper_.setStyle(cloneFeature, true); } @@ -796,23 +774,17 @@ export class RuleController { cloneFeature.setStyle(null); keys.forEach(unlistenByKey); keys.length = 0; - this.drawActive = false; - toolMgr.unregisterTool(uid, this.drawToolActivate); toolMgr.unregisterTool(uid, this.modifyToolActivate); toolMgr.unregisterTool(uid, this.rotateToolActivate); toolMgr.unregisterTool(uid, this.translateToolActivate); - this.modify_.setActive(false); - this.unregisterInteractions_(); - if (this.selectedFeatures.getLength()) { this.featureOverlay.removeFeature(cloneFeature); } this.featureOverlay.addFeature(ruleFeature); - this.selectedFeatures.clear(); } } @@ -882,7 +854,6 @@ export class RuleController { this.ngeoFeatureHelper_.clearNonSpatialProperties(feature); feature.setProperties(properties); this.ngeoFeatureHelper_.setStyle(feature, true); - this.scope_.$apply(); } }); @@ -917,7 +888,6 @@ export class RuleController { // (2) Get feature at pixel const pixel = this.map.getEventPixel(evt); const coordinate = this.map.getCoordinateFromPixel(pixel); - const feature = this.map.forEachFeatureAtPixel(pixel, (feature) => { /** @type {?Feature} */ let ret = null; @@ -939,7 +909,6 @@ export class RuleController { if (feature) { const type = this.ngeoFeatureHelper_.getType(feature); const gettextCatalog = this.gettextCatalog_; - if ( type == ngeoGeometryType.CIRCLE || type == ngeoGeometryType.LINE_STRING || @@ -964,21 +933,16 @@ export class RuleController { }); } } - if (actions.length) { // (4) Create and show menu this.menu_ = new ngeoMenu({ actions, }); - this.listenerKeys_.push(listen(this.menu_, 'actionclick', this.handleMenuActionClick_, this)); this.map.addOverlay(this.menu_); - this.menu_.open(coordinate); - evt.preventDefault(); evt.stopPropagation(); - this.scope_.$apply(); } } @@ -1005,8 +969,7 @@ export class RuleController { * @private */ handleMenuActionClick_(evt) { - const action = /** @type {MenuEvent} */ (evt).detail.action; - + const action = /** @type {MenuEvent} */ evt.detail.action; switch (action) { case 'move': this.translate_.setActive(true); @@ -1040,7 +1003,14 @@ export class RuleController { this.scope_.$apply(); } } - +RuleController.$inject = [ + 'gettextCatalog', + '$scope', + '$timeout', + 'ngeoFeatureHelper', + 'ngeoRuleHelper', + 'ngeoToolActivateMgr', +]; /** * The rule component is bound to a `import('ngeo/rule/Rule').default` object and shows UI * components to be able to edit its properties, such as: operator, literal, @@ -1059,5 +1029,4 @@ myModule.component('ngeoRule', { controller: RuleController, templateUrl: ngeoRuleTemplateUrl, }); - export default myModule; diff --git a/src/filters/SavedFilters.js b/src/filters/SavedFilters.js index 8195662ff45c..b263aba411af 100644 --- a/src/filters/SavedFilters.js +++ b/src/filters/SavedFilters.js @@ -40,7 +40,6 @@ export class SavedFilter { * Otherwise, they are kept in this service for the duration of the visit. * * @param {angular.IScope} $rootScope Angular rootScope. - * @ngInject * @ngdoc service * @ngname gmfSavedFilters */ @@ -79,7 +78,6 @@ export class SavedFilter { * @private */ this.useLocalStorage_ = true; - try { if ('localStorage' in window) { window.localStorage['test'] = ''; @@ -97,14 +95,12 @@ export class SavedFilter { * @private */ this.items_ = []; - this.rootScope_.$watchCollection( () => this.items, () => { this.rePopulateCurrentDataSourceItems_(); }, ); - if (this.useLocalStorage_) { this.loadItemsFromLocalStorage_(); } @@ -166,7 +162,6 @@ export class SavedFilter { break; } } - return idx; } @@ -227,13 +222,12 @@ export class SavedFilter { } } } - +SavedFilter.$inject = ['$rootScope']; /** * @type {angular.IModule} * @hidden */ const myModule = angular.module('gmfSavedFilters', []); - myModule.service('gmfSavedFilters', SavedFilter); /** @@ -278,5 +272,4 @@ SavedFilterItem.prototype.directedRules; * @type {string} */ SavedFilterItem.prototype.name; - export default myModule; diff --git a/src/filters/filterselectorComponent.js b/src/filters/filterselectorComponent.js index 5c3555e4a99e..5f780ac6c251 100644 --- a/src/filters/filterselectorComponent.js +++ b/src/filters/filterselectorComponent.js @@ -21,28 +21,19 @@ import angular from 'angular'; import {CollectionEvent} from 'ol/Collection'; - import gmfDatasourceDataSourceBeingFiltered from 'gmf/datasource/DataSourceBeingFiltered'; - import gmfDatasourceHelper from 'gmf/datasource/Helper'; - import GmfDatasourceOGC from 'gmf/datasource/OGC'; import gmfFiltersSavedFilters from 'gmf/filters/SavedFilters'; - import ngeoMessageModalComponent from 'ngeo/message/modalComponent'; - import ngeoMessageNotification from 'ngeo/message/Notification'; import {MessageType} from 'ngeo/message/Message'; - import ngeoFilterRuleHelper from 'ngeo/filter/RuleHelper'; - import ngeoFilterComponent from 'ngeo/filter/component'; import {listen, unlistenByKey} from 'ol/events'; import {remove as removeFromArray} from 'ol/array'; import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; - import 'bootstrap/js/src/dropdown'; - import panels from 'gmfapi/store/panels'; import user from 'gmfapi/store/user'; @@ -58,18 +49,18 @@ const myModule = angular.module('gmfFilterselector', [ ngeoFilterComponent.name, gmfFiltersSavedFilters.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/filters/filterselectorcomponent', require('./filterselectorcomponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/filters/filterselectorcomponent', require('./filterselectorcomponent.html')); + }, + ], ); - myModule.value( 'gmfFilterselectorTemplateUrl', /** @@ -86,10 +77,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} gmfFilterselectorTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfFilterselectorTemplateUrl.$inject = ['$attrs', 'gmfFilterselectorTemplateUrl']; function gmfFilterselectorTemplateUrl($attrs, gmfFilterselectorTemplateUrl) { return gmfFilterselectorTemplateUrl($attrs); } @@ -120,7 +111,6 @@ export class FilterSelectorController { * sources helper service. * @param {import('gmf/filters/SavedFilters').SavedFilter} gmfSavedFilters Gmf saved filters service. * @param {import('ngeo/filter/RuleHelper').RuleHelper} ngeoRuleHelper Ngeo rule helper service. - * @ngInject * @ngdoc controller * @ngname GmfFilterselectorController */ @@ -172,7 +162,6 @@ export class FilterSelectorController { * @type {import('gmf/datasource/DataSourceBeingFiltered').DataSourceBeingFiltered} */ this.gmfDataSourceBeingFiltered = gmfDataSourceBeingFiltered; - $scope.$watch( () => this.gmfDataSourceBeingFiltered.dataSource, this.handleSelectedDataSourceChange_.bind(this), @@ -210,7 +199,6 @@ export class FilterSelectorController { * @private */ this.subscriptions_ = []; - this.subscriptions_.push( user.getProperties().subscribe({ next: (value) => { @@ -264,9 +252,8 @@ export class FilterSelectorController { * @private */ this.gmfDataSources_ = - /** @type {import('ol/Collection').default} */ ( - gmfDataSourcesHelper.collection - ); + /** @type {import('ol/Collection').default} */ + gmfDataSourcesHelper.collection; /** * @type {import('ol/events').EventsKey[]} @@ -315,7 +302,6 @@ export class FilterSelectorController { * @type {boolean} */ this.enableDataSourceRegistration_ = false; - $scope.$watch( () => this.enableDataSourceRegistration_, this.handleEnableDataSourceRegistrationChange_.bind(this), @@ -378,7 +364,6 @@ export class FilterSelectorController { */ handleEnableDataSourceRegistrationChange_(register) { const keys = this.listenerKeys_; - if (register) { // Listen to data sources being added/removed keys.push( @@ -446,10 +431,8 @@ export class FilterSelectorController { if (dataSource.filtrable === null) { dataSource.filtrable = this.isDataSourceFiltrable_(dataSource); } - if (dataSource.filtrable) { this.filtrableDataSources.push(dataSource); - if ( this.defaultFiltrableDataSourceName_ !== undefined && dataSource.name === this.defaultFiltrableDataSourceName_ @@ -470,7 +453,6 @@ export class FilterSelectorController { unregisterDataSource_(dataSource) { if (dataSource.filtrable) { removeFromArray(this.filtrableDataSources, dataSource); - if (this.gmfDataSourceBeingFiltered.dataSource === dataSource) { this.gmfDataSourceBeingFiltered.dataSource = null; } @@ -530,21 +512,16 @@ export class FilterSelectorController { // (4) The ogcLayer must be queryable msgs.push(gettext.getString('The wfsLayer within the data source must be queryable.')); } - filtrable = !msgs.length; // Notify if the name is in list of filtrable layer node names but // there are missing requirements. if (notify && !filtrable) { - const p1 = gettext.getString( - `The following data source is marked as being filtrable, - but is missing some requirements: `, - ); + const p1 = gettext.getString(`The following data source is marked as being filtrable, + but is missing some requirements: `); const p2 = `${dataSource.name} (${dataSource.id}).`; - const p3 = gettext.getString( - `Please, contact your administrator about this. - Here are the reasons: `, - ); + const p3 = gettext.getString(`Please, contact your administrator about this. + Here are the reasons: `); msgs.unshift(`${p1} ${p2} ${p3}`); console.warn(msgs.join(' ')); ngeoMessageNotification.notify({ @@ -555,7 +532,6 @@ export class FilterSelectorController { } else { filtrable = false; } - return filtrable; } @@ -576,13 +552,14 @@ export class FilterSelectorController { if (!dataSource) { return; } - panels.openToolPanel('filter', {state: true}); + panels.openToolPanel('filter', { + state: true, + }); // A data source has been selected. Make sure the component is active. if (!this.active) { this.active = true; } - this.gmfDataSourcesHelper_.prepareFiltrableDataSource(dataSource).then((dataSource) => { // Data source is ready. Get any existing rules or create new ones from the attributes let item = this.getRuleCacheItem_(dataSource); @@ -606,7 +583,6 @@ export class FilterSelectorController { } } } - this.customRules = item.customRules; this.directedRules = item.directedRules; this.readyDataSource = dataSource; @@ -648,30 +624,26 @@ export class FilterSelectorController { if (!this.readyDataSource) { throw new Error('Missing readyDataSource'); } - const name = this.saveFilterName; const dataSource = this.readyDataSource; const dataSourceId = dataSource.id; const alreadyExist = this.gmfSavedFilters.indexOfItem(name, dataSourceId) !== -1; const condition = dataSource.filterCondition; - - const msg = this.gettextCatalog_.getString( - `A filter with the same name already exists. - Do you want to overwrite it?`, - ); + const msg = this.gettextCatalog_.getString(`A filter with the same name already exists. + Do you want to overwrite it?`); if (!alreadyExist || confirm(msg)) { // (1) Serialize the existing custom and directed rules const customRules = this.customRules ? this.ngeoRuleHelper_.serializeRules(this.customRules) : []; const directedRules = this.directedRules ? this.ngeoRuleHelper_.serializeRules(this.directedRules) : []; // (2) Ask the service to save it - const item = /** @type {import('gmf/filters/SavedFilters').SavedFilterItem} */ ({ + const item = /** @type {import('gmf/filters/SavedFilters').SavedFilterItem} */ { condition, customRules, dataSourceId, directedRules, name, - }); + }; this.gmfSavedFilters.save(item); // (3) Close popup, which resets the name @@ -694,7 +666,6 @@ export class FilterSelectorController { // (1) Reset current rules this.customRules = null; this.directedRules = null; - const customRules = this.ngeoRuleHelper_.createRules(filterItem.customRules); const directedRules = this.ngeoRuleHelper_.createRules(filterItem.directedRules); @@ -735,7 +706,15 @@ export class FilterSelectorController { this.gmfSavedFilters.remove(item); } } - +FilterSelectorController.$inject = [ + '$scope', + '$timeout', + 'gettextCatalog', + 'gmfDataSourceBeingFiltered', + 'gmfDataSourcesHelper', + 'gmfSavedFilters', + 'ngeoRuleHelper', +]; /** * @typedef {Object} RuleCache */ @@ -756,5 +735,4 @@ myModule.component('gmfFilterselector', { controller: FilterSelectorController, templateUrl: gmfFilterselectorTemplateUrl, }); - export default myModule; diff --git a/src/floor/floorselectorComponent.js b/src/floor/floorselectorComponent.js index 70a721504d3a..321f35a98c39 100644 --- a/src/floor/floorselectorComponent.js +++ b/src/floor/floorselectorComponent.js @@ -26,18 +26,18 @@ import angular from 'angular'; * @hidden */ const myModule = angular.module('gmfFloorSelector', []); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/floor/floorselectorcomponent', require('./floorselectorcomponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/floor/floorselectorcomponent', require('./floorselectorcomponent.html')); + }, + ], ); - myModule.value( 'gmfFloorselectorTemplateUrl', /** @@ -54,10 +54,10 @@ myModule.value( * @param {!angular.IAttributes} $attrs Attributes. * @param {!function(!angular.IAttributes): string} gmfFloorselectorTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfFloorselectorTemplateUrl.$inject = ['$attrs', 'gmfFloorselectorTemplateUrl']; function gmfFloorselectorTemplateUrl($attrs, gmfFloorselectorTemplateUrl) { return gmfFloorselectorTemplateUrl($attrs); } @@ -70,7 +70,6 @@ export class Controller { * @param {angular.IScope} $scope Angular scope. * @param {JQuery} $element Element. * @param {import('gmf/options').gmfFloors} gmfFloors Floor dimension values and labels. - * @ngInject * @ngdoc controller * @ngname GmfFilterselectorController */ @@ -106,11 +105,9 @@ export class Controller { * @private */ this.upperBound_; - this.scope = $scope; this.element = $element; } - $postLink() { this.scope.$watch( () => { @@ -120,7 +117,6 @@ export class Controller { this.valueChanged_(); }, ); - this.element[0].addEventListener('wheel', (event) => { this.scope.$apply(() => { const delta = event.deltaY > 0 ? -1 : 1; @@ -146,23 +142,19 @@ export class Controller { }, ); console.assert(this.currentIndex > -1); - const buttonGroup = this.element.find('.btn-group-floors'); - const buttonUp = this.element.find('.btn-floor-up'); const buttonUpOuterHeight = buttonUp.outerHeight(true); if (buttonUpOuterHeight === undefined) { throw new Error('Missing buttonUp.outerHeight'); } const maxTop = buttonUp.position().top + buttonUpOuterHeight; - const buttonDown = this.element.find('.btn-floor-down'); const buttonGroupOuterHeight = buttonGroup.outerHeight(true); if (buttonGroupOuterHeight === undefined) { throw new Error('Missing buttonGroup.outerHeight'); } const minTop = buttonDown.position().top - buttonGroupOuterHeight; - const currentButton = this.element.find(`.btn-floor:nth(${this.currentIndex})`); const innerHeight = this.element.innerHeight(); if (innerHeight === undefined) { @@ -188,7 +180,7 @@ export class Controller { } } } - +Controller.$inject = ['$scope', '$element', 'gmfFloors']; /** * Provide a floor selector component. * Note that it is not limited to floors, but allows selecting a dimension value @@ -219,7 +211,5 @@ const floorSelectorComponent = { controller: Controller, templateUrl: gmfFloorselectorTemplateUrl, }; - myModule.component('gmfFloorselector', floorSelectorComponent); - export default myModule; diff --git a/src/geolocation/component.js b/src/geolocation/component.js index 53b960973d7a..b922c8abef1a 100644 --- a/src/geolocation/component.js +++ b/src/geolocation/component.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$scope', '$element', 'gettextCatalog', 'ngeoGeolocationOptions']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -63,7 +64,6 @@ const GeolocationEventType = { * @htmlAttribute {import('ol/Map').default} ngeo-geolocation-map The map. * @htmlAttribute {GeolocationDirectiveOptions} ngeo-geolocation-options The options. * @returns {angular.IDirective} The Directive Definition Object. - * @ngInject * @ngdoc directive * @ngname ngeoGeolocation */ @@ -78,7 +78,6 @@ function geolocationComponent() { bindToController: true, }; } - myModule.directive('ngeoGeolocation', geolocationComponent); /** @@ -88,13 +87,11 @@ myModule.directive('ngeoGeolocation', geolocationComponent); * @param {JQuery} $element Element. * @param {angular.gettext.gettextCatalog} gettextCatalog Gettext service. * @param {import('ngeo/options').ngeoGeolocationOptions} ngeoGeolocationOptions The options. - * @ngInject * @ngdoc controller * @ngname ngeoGeolocationController */ export function Controller($scope, $element, gettextCatalog, ngeoGeolocationOptions) { this.options = ngeoGeolocationOptions; - $element.on('click', this.toggleTracking.bind(this)); /** @@ -137,11 +134,10 @@ Controller.prototype.$onInit = function () { */ this.geolocation_ = new olGeolocation({ projection: this.map.getView().getProjection(), - trackingOptions: /** @type {PositionOptions} */ ({ + trackingOptions: /** @type {PositionOptions} */ { enableHighAccuracy: true, - }), + }, }); - if (this.options.autoRotate) { this.autoRotateListener(); } @@ -152,45 +148,46 @@ Controller.prototype.$onInit = function () { // handle geolocation error. this.geolocation_.on( 'error', - /** @type {function(?): ?} */ ( - /** - * @param {GeolocationPositionError} error - */ - (error) => { - this.untrack_(); - let msg; - switch (error.code) { - case 1: - msg = gettextCatalog.getString('User denied the request for Geolocation.'); - break; - case 2: - msg = gettextCatalog.getString('Location information is unavailable.'); - break; - case 3: - msg = gettextCatalog.getString('The request to get user location timed out.'); - break; - default: - msg = gettextCatalog.getString('Geolocation: An unknown error occurred.'); - break; - } - ngeoMessageNotification.error(msg); - this.$scope_.$emit(GeolocationEventType.ERROR, error); + /** @type {function(?): ?} */ + /** + * @param {GeolocationPositionError} error + */ + (error) => { + this.untrack_(); + let msg; + switch (error.code) { + case 1: + msg = gettextCatalog.getString('User denied the request for Geolocation.'); + break; + case 2: + msg = gettextCatalog.getString('Location information is unavailable.'); + break; + case 3: + msg = gettextCatalog.getString('The request to get user location timed out.'); + break; + default: + msg = gettextCatalog.getString('Geolocation: An unknown error occurred.'); + break; } - ), + ngeoMessageNotification.error(msg); + this.$scope_.$emit(GeolocationEventType.ERROR, error); + }, ); /** * @type {olFeature} */ - this.positionFeature_ = new olFeature({name: 'GeolocationPositionFeature'}); - + this.positionFeature_ = new olFeature({ + name: 'GeolocationPositionFeature', + }); this.positionFeature_.setStyle(buildStyle(this.options.positionFeatureStyle)); /** * @type {olFeature} */ - this.accuracyFeature_ = new olFeature({name: 'GeolocationAccuracyFeature'}); - + this.accuracyFeature_ = new olFeature({ + name: 'GeolocationAccuracyFeature', + }); this.accuracyFeature_.setStyle(buildStyle(this.options.accuracyFeatureStyle)); /** @@ -207,7 +204,6 @@ Controller.prototype.$onInit = function () { * @type {boolean} */ this.viewChangedByMe_ = false; - listen( this.geolocation_, 'change:accuracyGeometry', @@ -221,7 +217,6 @@ Controller.prototype.$onInit = function () { this.setPosition_(); }, ); - listen( this.geolocation_, 'change:position', @@ -230,12 +225,9 @@ Controller.prototype.$onInit = function () { this.setPosition_(); }, ); - const view = this.map.getView(); - listen(view, 'change:center', this.handleViewChange_, this); listen(view, 'change:resolution', this.handleViewChange_, this); - if (this.options.atLoadingTime && this.loading !== undefined) { this.$scope_.$watch( () => this.loading, @@ -280,21 +272,18 @@ Controller.prototype.toggleTracking = function () { this.track_(); } }; - Controller.prototype.track_ = function () { this.featureOverlay_.addFeature(this.positionFeature_); this.featureOverlay_.addFeature(this.accuracyFeature_); this.follow_ = true; this.geolocation_.setTracking(true); }; - Controller.prototype.untrack_ = function () { this.featureOverlay_.clear(); this.follow_ = false; this.geolocation_.setTracking(false); ngeoMessageNotification.clear(); }; - Controller.prototype.setPosition_ = function () { const view = this.map.getView(); const position = this.geolocation_.getPosition(); @@ -302,10 +291,8 @@ Controller.prototype.setPosition_ = function () { throw new Error('Missing position'); } const point = new olGeomPoint(position); - this.positionFeature_.setGeometry(point); const accuracy = this.accuracyFeature_.getGeometry(); - if (this.follow_) { this.viewChangedByMe_ = true; if (this.options.zoom || this.options.zoom === 0) { @@ -316,7 +303,9 @@ Controller.prototype.setPosition_ = function () { if (size === undefined) { throw new Error('Missing size'); } - view.fit(accuracy, {size}); + view.fit(accuracy, { + size, + }); } this.viewChangedByMe_ = false; } @@ -390,7 +379,5 @@ Controller.prototype.handleRotate_ = function (eventAlpha, currentAlpha) { } return currentAlpha; }; - myModule.controller('ngeoGeolocationController', Controller); - export default myModule; diff --git a/src/grid/component.js b/src/grid/component.js index 8505681d2966..e7756b850a2b 100644 --- a/src/grid/component.js +++ b/src/grid/component.js @@ -1,3 +1,4 @@ +GridController.$inject = ['$scope']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -23,7 +24,6 @@ import angular from 'angular'; import {isPlatformModifierKeyOnly, isShiftKeyOnly} from 'ngeo/utils'; import ngeoMiscFilters from 'ngeo/misc/filters'; import {getRowUid} from 'ngeo/grid/Config'; - import 'floatthead'; import 'angular-float-thead'; import 'ngeo/sass/font.scss'; @@ -33,18 +33,18 @@ import 'ngeo/sass/font.scss'; * @hidden */ const myModule = angular.module('ngeoGrid', [ngeoMiscFilters.name, 'floatThead']); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/grid', require('./component.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/grid', require('./component.html')); + }, + ], ); - myModule.value( 'ngeoGridTemplateUrl', /** @@ -61,10 +61,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} ngeoGridTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +ngeoGridTemplateUrl.$inject = ['$attrs', 'ngeoGridTemplateUrl']; function ngeoGridTemplateUrl($attrs, ngeoGridTemplateUrl) { return ngeoGridTemplateUrl($attrs); } @@ -92,7 +92,6 @@ const gridComponent = { }, templateUrl: ngeoGridTemplateUrl, }; - myModule.component('ngeoGrid', gridComponent); /** @@ -100,7 +99,6 @@ myModule.component('ngeoGrid', gridComponent); * @class * @private * @hidden - * @ngInject * @ngdoc controller * @ngname ngeoGridController */ @@ -175,7 +173,6 @@ GridController.prototype.sort = function (columnName) { } this.sortAscending = this.sortedBy === columnName ? !this.sortAscending : true; this.sortedBy = columnName; - const asc = this.sortAscending ? 1 : -1; this.configuration.data.sort((attributes1, attributes2) => { if (!attributes1[columnName]) { @@ -197,7 +194,6 @@ GridController.prototype.sort = function (columnName) { GridController.prototype.clickRow = function (attributes, event) { const shiftKey = isShiftKeyOnly(event); const platformModifierKey = isPlatformModifierKeyOnly(event); - this.clickRow_(attributes, shiftKey, platformModifierKey); }; @@ -210,7 +206,6 @@ GridController.prototype.clickRow_ = function (attributes, shiftKey, platformMod if (!this.configuration) { throw new Error('Missing configuration'); } - if (shiftKey && !platformModifierKey) { this.selectRange_(attributes); } else if (!shiftKey && platformModifierKey) { @@ -238,7 +233,6 @@ GridController.prototype.selectRange_ = function (attributes) { } const targetUid = getRowUid(attributes); const data = this.configuration.data; - if (this.configuration.isRowSelected(attributes)) { return; } @@ -250,14 +244,12 @@ GridController.prototype.selectRange_ = function (attributes) { for (let i = 0; i < data.length; i++) { const currentRow = data[i]; const currentUid = getRowUid(currentRow); - if (targetUid === currentUid) { posClickedRow = i; } else if (this.configuration.isRowSelected(currentRow)) { posSelectedRows.push(i); } } - if (posSelectedRows.length == 0) { // if no other row is selected, select the clicked one and stop this.configuration.selectRow(attributes); @@ -279,7 +271,6 @@ GridController.prototype.selectRange_ = function (attributes) { // then select all rows between the clicked one and the closest const rangeStart = posClickedRow < posClosestRow ? posClickedRow : posClosestRow; const rangeEnd = posClickedRow > posClosestRow ? posClickedRow : posClosestRow; - for (let l = rangeStart; l <= rangeEnd; l++) { this.configuration.selectRow(data[l]); } @@ -294,12 +285,9 @@ GridController.prototype.selectRange_ = function (attributes) { GridController.prototype.preventTextSelection = function (event) { const shiftKey = isShiftKeyOnly(event); const platformModifierKey = isPlatformModifierKeyOnly(event); - if (shiftKey || platformModifierKey) { event.preventDefault(); } }; - myModule.controller('ngeoGridController', GridController); - export default myModule; diff --git a/src/header/component.js b/src/header/component.js index 3d1ca74b6e1b..9bb117e3a7a4 100644 --- a/src/header/component.js +++ b/src/header/component.js @@ -26,18 +26,18 @@ import angular from 'angular'; * @hidden */ const myModule = angular.module('gmfHeader', []); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/header/component', require('./component.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/header/component', require('./component.html')); + }, + ], ); - myModule.value( 'gmfHeaderTemplateUrl', /** @@ -57,10 +57,10 @@ myModule.value( * @param {function(JQuery, angular.IAttributes): string} gmfHeaderTemplateUrl * Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfHeaderTemplateUrl.$inject = ['$element', '$attrs', 'gmfHeaderTemplateUrl']; function gmfHeaderTemplateUrl($element, $attrs, gmfHeaderTemplateUrl) { return gmfHeaderTemplateUrl($element, $attrs); } @@ -76,7 +76,5 @@ function gmfHeaderTemplateUrl($element, $attrs, gmfHeaderTemplateUrl) { const headerComponent = { templateUrl: gmfHeaderTemplateUrl, }; - myModule.component('gmfHeader', headerComponent); - export default myModule; diff --git a/src/import/importdatasourceComponent.js b/src/import/importdatasourceComponent.js index 17046cfc8f31..ceef94a0419b 100644 --- a/src/import/importdatasourceComponent.js +++ b/src/import/importdatasourceComponent.js @@ -22,13 +22,9 @@ /* global Bloodhound */ import angular from 'angular'; - import gmfDatasourceExternalDataSourcesManager from 'gmf/datasource/ExternalDataSourcesManager'; - import gmfImportWmsCapabilityLayertreeComponent from 'gmf/import/wmsCapabilityLayertreeComponent'; - import gmfImportWmtsCapabilityLayertreeComponent from 'gmf/import/wmtsCapabilityLayertreeComponent'; - import ngeoQueryQuerent from 'ngeo/query/Querent'; import {guessServiceTypeByUrl, Type} from 'ngeo/datasource/OGC'; @@ -42,18 +38,18 @@ const myModule = angular.module('gmfImportdatasource', [ gmfImportWmtsCapabilityLayertreeComponent.name, ngeoQueryQuerent.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/import/importdatasourceComponent', require('./importdatasourceComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/import/importdatasourceComponent', require('./importdatasourceComponent.html')); + }, + ], ); - myModule.value( 'gmfImportdatasourceTemplateUrl', /** @@ -70,10 +66,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} gmfImportdatasourceTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfImportdatasourceTemplateUrl.$inject = ['$attrs', 'gmfImportdatasourceTemplateUrl']; function gmfImportdatasourceTemplateUrl($attrs, gmfImportdatasourceTemplateUrl) { return gmfImportdatasourceTemplateUrl($attrs); } @@ -101,7 +97,6 @@ export class Controller { * @param {import('ngeo/query/Querent').Querent} ngeoQuerent Ngeo querent service. * @param {import('gmf/options').gmfExternalOGCServers} gmfExternalOGCServers The options. * @param {angular.gettext.gettextCatalog} gettextCatalog The gettextCatalog service. - * @ngInject * @ngdoc controller * @ngname GmfImportdatasourceController */ @@ -199,7 +194,6 @@ export class Controller { * @type {string[]} */ this.modes = [Mode.LOCAL, Mode.ONLINE]; - gettextCatalog.getString('Local'); gettextCatalog.getString('Online'); @@ -212,9 +206,7 @@ export class Controller { * @type {import('ngeo/misc/filters').unitPrefix} * @private */ - this.unitPrefixFormat_ = /** @type {import('ngeo/misc/filters').unitPrefix} */ ( - $filter('ngeoUnitPrefix') - ); + this.unitPrefixFormat_ = /** @type {import('ngeo/misc/filters').unitPrefix} */ $filter('ngeoUnitPrefix'); /** * Current WMS Capabilities that were connected. @@ -243,7 +235,6 @@ export class Controller { /** @type {import('gmf/options').gmfExternalOGCServers} */ const servers = gmfExternalOGCServers; - if (servers) { this.serversEngine_ = new Bloodhound({ datumTokenizer: (datum) => { @@ -256,16 +247,14 @@ export class Controller { // Register input[type=file] onchange event, use HTML5 File api this.fileInput_.on('change', () => { - const fileInput = /** @type {HTMLInputElement} */ (this.fileInput_[0]); + const fileInput = /** @type {HTMLInputElement} */ this.fileInput_[0]; const files = fileInput.files; this.file = files && files[0] ? files[0] : null; - if (this.file) { this.hasError = false; // update the label $(fileInput).next('.custom-file-label').html(this.fileNameAndSize); } - this.scope_.$apply(); }); } @@ -275,7 +264,6 @@ export class Controller { */ $onInit() { this.gmfExternalDataSourcesManager_.map = this.map; - if (this.serversEngine_) { /** * @param {string} query Query string. @@ -338,7 +326,6 @@ export class Controller { } const url = this.url; const serviceType = guessServiceTypeByUrl(url); - this.isLoading = true; this.startWorking_(); if (serviceType === Type.WMS) { @@ -401,13 +388,11 @@ export class Controller { return ''; } let nameAndSize = ''; - const file = this.file; if (file !== undefined) { const fileSize = this.unitPrefixFormat_(file.size, 'o'); nameAndSize = `${file.name}, ${fileSize}`; } - return nameAndSize; } @@ -441,7 +426,6 @@ export class Controller { layer._visible = visible; layer._searchMatch = null; layer._expanded = false; - if (!this.searchText) { layer._visible = true; } else { @@ -507,7 +491,16 @@ export class Controller { } } } - +Controller.$inject = [ + '$element', + '$filter', + '$scope', + '$timeout', + 'gmfExternalDataSourcesManager', + 'ngeoQuerent', + 'gmfExternalOGCServers', + 'gettextCatalog', +]; myModule.component('gmfImportdatasource', { bindings: { 'map': '<', @@ -515,5 +508,4 @@ myModule.component('gmfImportdatasource', { controller: Controller, templateUrl: gmfImportdatasourceTemplateUrl, }); - export default myModule; diff --git a/src/import/wmsCapabilityLayertreeComponent.js b/src/import/wmsCapabilityLayertreeComponent.js index f681cf94dfa4..18c1c7c72dc2 100644 --- a/src/import/wmsCapabilityLayertreeComponent.js +++ b/src/import/wmsCapabilityLayertreeComponent.js @@ -20,13 +20,9 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - import gmfDatasourceExternalDataSourcesManager from 'gmf/datasource/ExternalDataSourcesManager'; - import ngeoMessagePopup from 'ngeo/message/Popup'; - import {getUid as olUtilGetUid} from 'ol/util'; - import 'bootstrap/js/src/collapse'; /** @@ -37,21 +33,21 @@ const myModule = angular.module('gmfWmscapabilitylayertreenode', [ gmfDatasourceExternalDataSourcesManager.name, ngeoMessagePopup.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - $templateCache.put( - 'gmf/import/wmsCapabilityLayertreeComponent', - // @ts-ignore: webpack - require('./wmsCapabilityLayertreeComponent.html'), - ); - }, + [ + '$templateCache', + ($templateCache) => { + $templateCache.put( + 'gmf/import/wmsCapabilityLayertreeComponent', + // @ts-ignore: webpack + require('./wmsCapabilityLayertreeComponent.html'), + ); + }, + ], ); - myModule.value( 'gmfWmscapabilitylayertreenodeTemplateUrl', /** @@ -69,10 +65,10 @@ myModule.value( * @param {function(angular.IAttributes): string} gmfWmscapabilitylayertreenodeTemplateUrl Template * function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfWmscapabilitylayertreenodeTemplateUrl.$inject = ['$attrs', 'gmfWmscapabilitylayertreenodeTemplateUrl']; function gmfWmscapabilitylayertreenodeTemplateUrl($attrs, gmfWmscapabilitylayertreenodeTemplateUrl) { return gmfWmscapabilitylayertreenodeTemplateUrl($attrs); } @@ -84,7 +80,6 @@ export class Controller { /** * @param {import('gmf/datasource/ExternalDataSourcesManager').ExternalDatSourcesManager} gmfExternalDataSourcesManager * GMF service responsible of managing external data sources. - * @ngInject * @ngdoc controller * @ngname GmfWmscapabilitylayertreenodeController */ @@ -141,7 +136,7 @@ export class Controller { return olUtilGetUid(layer); } } - +Controller.$inject = ['gmfExternalDataSourcesManager']; myModule.component('gmfWmscapabilitylayertreenode', { bindings: { 'capabilities': '<', @@ -151,5 +146,4 @@ myModule.component('gmfWmscapabilitylayertreenode', { controller: Controller, templateUrl: gmfWmscapabilitylayertreenodeTemplateUrl, }); - export default myModule; diff --git a/src/import/wmtsCapabilityLayertreeComponent.js b/src/import/wmtsCapabilityLayertreeComponent.js index b7f4c2a6a132..2fb3101f0d08 100644 --- a/src/import/wmtsCapabilityLayertreeComponent.js +++ b/src/import/wmtsCapabilityLayertreeComponent.js @@ -20,11 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - import gmfDatasourceExternalDataSourcesManager from 'gmf/datasource/ExternalDataSourcesManager'; - import ngeoMessagePopup from 'ngeo/message/Popup'; - import {getUid as olUtilGetUid} from 'ol/util'; /** @@ -35,21 +32,21 @@ const myModule = angular.module('gmfWmtscapabilitylayertree', [ gmfDatasourceExternalDataSourcesManager.name, ngeoMessagePopup.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - $templateCache.put( - 'ngeo/import/wmtsCapabilityLayertreeComponent', - // @ts-ignore: webpack - require('./wmtsCapabilityLayertreeComponent.html'), - ); - }, + [ + '$templateCache', + ($templateCache) => { + $templateCache.put( + 'ngeo/import/wmtsCapabilityLayertreeComponent', + // @ts-ignore: webpack + require('./wmtsCapabilityLayertreeComponent.html'), + ); + }, + ], ); - myModule.value( 'gmfWmtscapabilitylayertreTemplateUrl', /** @@ -66,10 +63,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} gmfWmtscapabilitylayertreTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfWmtscapabilitylayertreTemplateUrl.$inject = ['$attrs', 'gmfWmtscapabilitylayertreTemplateUrl']; function gmfWmtscapabilitylayertreTemplateUrl($attrs, gmfWmtscapabilitylayertreTemplateUrl) { return gmfWmtscapabilitylayertreTemplateUrl($attrs); } @@ -81,7 +78,6 @@ export class Controller { /** * @param {import('gmf/datasource/ExternalDataSourcesManager').ExternalDatSourcesManager} gmfExternalDataSourcesManager * GMF service responsible of managing external data sources. - * @ngInject * @ngdoc controller * @ngname GmfWmtscapabilitylayertreeController */ @@ -138,7 +134,7 @@ export class Controller { return olUtilGetUid(layer); } } - +Controller.$inject = ['gmfExternalDataSourcesManager']; myModule.component('gmfWmtscapabilitylayertree', { bindings: { 'capabilities': '<', @@ -148,5 +144,4 @@ myModule.component('gmfWmtscapabilitylayertree', { controller: Controller, templateUrl: gmfWmtscapabilitylayertreTemplateUrl, }); - export default myModule; diff --git a/src/layertree/Controller.js b/src/layertree/Controller.js index 3430f0d865ad..dc207f82216e 100644 --- a/src/layertree/Controller.js +++ b/src/layertree/Controller.js @@ -1,3 +1,4 @@ +LayertreeController.$inject = ['$scope', '$rootScope', '$attrs']; // The MIT License (MIT) // // Copyright (c) 2014-2024 Camptocamp SA @@ -33,7 +34,6 @@ import olLayerLayer from 'ol/layer/Layer'; * @param {angular.IScope} $rootScope Angular rootScope. * @param {angular.IAttributes} $attrs Attributes. * @class - * @ngInject * @ngdoc controller * @ngname NgeoLayertreeController * @hidden @@ -45,7 +45,6 @@ export function LayertreeController($scope, $rootScope, $attrs) { * @type {boolean} */ this.isRoot = isRoot; - const nodeExpr = $attrs.gmfLayertreeNode; /** @@ -62,7 +61,6 @@ export function LayertreeController($scope, $rootScope, $attrs) { * @type {string} */ this.state_ = 'off'; - let node; if (isRoot) { $scope.$watch(nodeExpr, (newVal, oldVal) => { @@ -75,7 +73,6 @@ export function LayertreeController($scope, $rootScope, $attrs) { * @type {import('gmf/themes').GmfGroup|import('gmf/themes').GmfLayer} */ this.node = node; - const mapExpr = $attrs.gmfLayertreeNodeMap; /** * @type {import('ol/Map').default} @@ -93,11 +90,9 @@ export function LayertreeController($scope, $rootScope, $attrs) { * @type {import('ngeo/layertree/Controller').LayertreeController[]} */ this.children = []; - if (this.parent) { this.parent.children.push(this); } - $scope.$on('$destroy', () => { if (this.parent) { const index = this.parent.children.indexOf(this); @@ -128,7 +123,6 @@ export function LayertreeController($scope, $rootScope, $attrs) { * @type {import('ol/Map').default} */ this.map = map; - let nodelayerExpr = $attrs.gmfLayertreeNodeNodelayer; if (nodelayerExpr === undefined) { const nodelayerexprExpr = $attrs.gmfLayertreeNodeNodelayerexpr; @@ -149,7 +143,10 @@ export function LayertreeController($scope, $rootScope, $attrs) { */ this.layer = null; if (!isRoot) { - const layer = $scope.$eval(nodelayerExpr, {'treeCtrl': this}) || null; + const layer = + $scope.$eval(nodelayerExpr, { + 'treeCtrl': this, + }) || null; if (layer) { console.assert(layer instanceof olLayerLayer || layer instanceof olLayerGroup); this.layer = layer; @@ -160,11 +157,9 @@ export function LayertreeController($scope, $rootScope, $attrs) { * @type {?import('ngeo/datasource/DataSource').default} */ this.dataSource_ = null; - if (this.layer) { layerLoading(this.layer, $scope); layerDecoration(this.layer); - listen( this.layer, 'change:opacity', @@ -176,13 +171,11 @@ export function LayertreeController($scope, $rootScope, $attrs) { }, ); } - let listenersExpr = $attrs.gmfLayertreeNodeListeners; if (listenersExpr === undefined) { const listenersexprExpr = $attrs.gmfLayertreeNodeListenersexpr; listenersExpr = $scope.$eval(listenersexprExpr); } - if (listenersExpr !== undefined) { console.assert(typeof listenersExpr == 'string'); } @@ -194,7 +187,10 @@ export function LayertreeController($scope, $rootScope, $attrs) { // Eval function to bind functions to this tree's events. if (listenersExpr) { - $scope.$eval(listenersExpr, {'treeScope': $scope, 'treeCtrl': this}); + $scope.$eval(listenersExpr, { + 'treeScope': $scope, + 'treeCtrl': this, + }); } // @ts-ignore: scope ... @@ -227,9 +223,7 @@ LayertreeController.prototype.setState = function (state, opt_broadcast) { if (this.parent) { this.parent.refreshState(this, opt_broadcast); } - const firstParents = this.isRoot ? this.children : [getFirstParentTree(this)]; - if (opt_broadcast === undefined || opt_broadcast) { firstParents.forEach((firstParent) => { this.rootScope_.$broadcast('ngeo-layertree-state', this, firstParent); @@ -244,7 +238,6 @@ LayertreeController.prototype.setState = function (state, opt_broadcast) { LayertreeController.prototype.setStateInternal_ = function (state) { // Set the state this.state_ = state === 'on' ? 'on' : 'off'; - if (this.state_ === 'on' && this.node.metadata && this.node.metadata.exclusiveGroup) { let firstChild; for (const child of this.children) { @@ -273,7 +266,7 @@ LayertreeController.prototype.setStateInternal_ = function (state) { * @public */ LayertreeController.prototype.refreshState = function (opt_onChild, opt_broadcast) { - const group = /** @type {import('gmf/themes').GmfGroup} */ (this.node); + const group = /** @type {import('gmf/themes').GmfGroup} */ this.node; if ( group.children && opt_onChild && @@ -288,7 +281,6 @@ LayertreeController.prototype.refreshState = function (opt_onChild, opt_broadcas } }); } - const newState = this.getCalculateState(); if (this.state_ === newState) { return; @@ -305,7 +297,7 @@ LayertreeController.prototype.refreshState = function (opt_onChild, opt_broadcas * @returns {string} 'on', 'off', 'indeterminate', or '' if the children are not initialized. */ LayertreeController.prototype.getCalculateState = function () { - const group = /** @type {import('gmf/themes').GmfGroup} */ (this.node); + const group = /** @type {import('gmf/themes').GmfGroup} */ this.node; if (group.children === undefined) { return this.state_; } @@ -403,12 +395,13 @@ export const LayertreeVisitorDecision = { LayertreeController.prototype.traverseDepthFirst = function (visitor) { // First visit the current controller const decision = visitor(this) || LayertreeVisitorDecision.DESCEND; - switch (decision) { case LayertreeVisitorDecision.STOP: - return true; // stop traversing + return true; + // stop traversing case LayertreeVisitorDecision.SKIP: - return false; // continue traversing but skip current branch + return false; + // continue traversing but skip current branch case LayertreeVisitorDecision.DESCEND: for (const child of this.children) { const stop = child.traverseDepthFirst(visitor); @@ -416,7 +409,8 @@ LayertreeController.prototype.traverseDepthFirst = function (visitor) { return true; // stop traversing } } - return false; // continue traversing + return false; + // continue traversing default: throw new Error('Unhandled case'); } @@ -428,5 +422,4 @@ LayertreeController.prototype.traverseDepthFirst = function (visitor) { */ const myModule = angular.module('ngeoLayertreeController', []); myModule.controller('ngeoLayertreeController', LayertreeController); - export default myModule; diff --git a/src/layertree/SyncLayertreeMap.js b/src/layertree/SyncLayertreeMap.js index 31aa674c726c..160792684ca9 100644 --- a/src/layertree/SyncLayertreeMap.js +++ b/src/layertree/SyncLayertreeMap.js @@ -1,3 +1,10 @@ +SyncLayertreeMap.$inject = [ + '$rootScope', + 'ngeoLayerHelper', + 'ngeoWMSTime', + 'gmfThemes', + 'gmfWMSSourceOptions', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -41,7 +48,6 @@ import Group from 'ol/layer/Group'; * @param {import('ngeo/misc/WMSTime').WMSTime} ngeoWMSTime wms time service. * @param {import('gmf/theme/Themes').ThemesService} gmfThemes The gmf Themes service. * @param {import('gmf/options').gmfWMSSourceOptions} gmfWMSSourceOptions the WMS source options. - * @ngInject * @ngdoc service * @ngname gmfSyncLayertreeMap * @hidden @@ -67,11 +73,9 @@ export function SyncLayertreeMap($rootScope, ngeoLayerHelper, ngeoWMSTime, gmfTh * @type {?import('gmf/themes').GmfOgcServers} */ this.ogcServersObject_ = null; - gmfThemes.getOgcServersObject().then((ogcServersObject) => { this.ogcServersObject_ = ogcServersObject; }); - $rootScope.$on('ngeo-layertree-state', (map, treeCtrl, firstParent) => { this.sync_(firstParent); }); @@ -96,8 +100,8 @@ SyncLayertreeMap.prototype.createLayer = function (treeCtrl, map, dataLayerGroup * @type {?import('ol/layer/Base').default|import('ol/layer/Group').default} */ let layer = null; - const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); - const gmfParentGroup = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.parent.node); + const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; + const gmfParentGroup = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.parent.node; if (gmfGroup.children !== undefined && gmfGroup.mixed) { // Mixed groups layer = this.createGroup_(treeCtrl, map, dataLayerGroup, opt_position); @@ -111,11 +115,9 @@ SyncLayertreeMap.prototype.createLayer = function (treeCtrl, map, dataLayerGroup // First level group non mix layer = this.createGroup_(treeCtrl, map, dataLayerGroup, opt_position); } - if (layer && treeCtrl.node.metadata.opacity) { layer.setOpacity(treeCtrl.node.metadata.opacity); } - return layer; }; @@ -127,12 +129,11 @@ SyncLayertreeMap.prototype.createLayer = function (treeCtrl, map, dataLayerGroup */ SyncLayertreeMap.prototype.sync_ = function (treeCtrl) { treeCtrl.traverseDepthFirst((treeCtrl) => { - const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); + const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; if (treeCtrl.layer && !gmfGroup.mixed) { this.updateLayerState_( - /** @type {import('ol/layer/Image').default|import('ol/layer/WebGLTile').default} */ ( - treeCtrl.layer - ), + /** @type {import('ol/layer/Image').default|import('ol/layer/WebGLTile').default} */ + treeCtrl.layer, treeCtrl, ); return LayertreeVisitorDecision.DESCEND; @@ -147,8 +148,8 @@ SyncLayertreeMap.prototype.sync_ = function (treeCtrl) { * @param {import('ngeo/layertree/Controller').LayertreeController} treeCtrl ngeo layertree controller. */ SyncLayertreeMap.prototype.updateLayerState_ = function (layer, treeCtrl) { - const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); - const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ (treeCtrl.node); + const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; + const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ treeCtrl.node; const active = treeCtrl.getState() === 'on'; if (gmfLayer.type === 'WMTS') { layer.setVisible(active); @@ -162,11 +163,9 @@ SyncLayertreeMap.prototype.updateLayerState_ = function (layer, treeCtrl) { /** @type {string[]} */ const styles = []; treeCtrl.traverseDepthFirst((treeCtrl) => { - const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); + const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; if (gmfGroup.children === undefined && treeCtrl.getState() === 'on') { - const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ ( - /** @type {any} */ (treeCtrl.node) - ); + const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ /** @type {any} */ treeCtrl.node; names.push(gmfLayerWMS.layers); const style = gmfLayerWMS.style !== undefined ? gmfLayerWMS.style : ''; styles.push(style); @@ -176,7 +175,8 @@ SyncLayertreeMap.prototype.updateLayerState_ = function (layer, treeCtrl) { if (names.length === 0) { layer.setVisible(false); } - /** @type {import('ol/source/ImageWMS').default} */ (layer.getSource()).updateParams({ + /** @type {import('ol/source/ImageWMS').default} */ + layer.getSource().updateParams({ 'LAYERS': names.reverse().join(','), 'STYLES': styles.reverse().join(','), }); @@ -207,15 +207,13 @@ SyncLayertreeMap.prototype.updateLayerState_ = function (layer, treeCtrl) { * @returns {import('ol/layer/Image').default|import('ol/layer/Group').default} a new layer. */ SyncLayertreeMap.prototype.createGroup_ = function (treeCtrl, map, dataLayerGroup, opt_position) { - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; let layer = null; const isFirstLevelGroup = treeCtrl.parent.isRoot; - let printNativeAngle = true; if (groupNode.metadata.printNativeAngle !== undefined) { printNativeAngle = groupNode.metadata.printNativeAngle; } - if (isFirstLevelGroup) { // First level group layer = this.createLayerFromGroup_(treeCtrl, !!groupNode.mixed); @@ -234,7 +232,6 @@ SyncLayertreeMap.prototype.createGroup_ = function (treeCtrl, map, dataLayerGrou layerGroup.getLayers().insertAt(0, layer); } } - if (!layer) { throw new Error('Missing layer'); } @@ -253,7 +250,7 @@ SyncLayertreeMap.prototype.createGroup_ = function (treeCtrl, map, dataLayerGrou SyncLayertreeMap.prototype.createLayerFromGroup_ = function (treeCtrl, mixed) { /** @type {import('ol/layer/Image').default|import('ol/layer/Group').default} */ let layer; - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; if (mixed) { // Will be one ol.layer per each node. layer = this.layerHelper_.createBasicGroup(); @@ -282,21 +279,20 @@ SyncLayertreeMap.prototype.createLayerFromGroup_ = function (treeCtrl, mixed) { ogcServer.imageType, ogcServer.type, timeParam, - undefined, // WMS parameters + undefined, + // WMS parameters ogcServer.credential ? 'use-credentials' : 'anonymous', this.gmfWMSSourceOptions_, ); - layer.set(DATASOURCE_ID, groupNode.id); - let hasActiveChildren = false; treeCtrl.traverseDepthFirst((ctrl) => { // Update layer information and tree state. - this.updateLayerReferences_(/** @type {import('gmf/themes').GmfBaseNode} */ (ctrl.node), layer); + this.updateLayerReferences_(/** @type {import('gmf/themes').GmfBaseNode} */ ctrl.node, layer); if (ctrl.node.metadata.isChecked) { ctrl.setState('on', false); this.updateLayerState_( - /** @type {import('ol/layer/Image').default} */ (layer), + /** @type {import('ol/layer/Image').default} */ layer, ctrl, ); hasActiveChildren = true; @@ -317,18 +313,18 @@ SyncLayertreeMap.prototype.createLayerFromGroup_ = function (treeCtrl, mixed) { * @returns {import('ol/layer/WebGLTile').default|import('ol/layer/Image').default} a new layer. */ SyncLayertreeMap.prototype.createLeafInAMixedGroup_ = function (treeCtrl, map) { - const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ (treeCtrl.node); + const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ treeCtrl.node; let layer; // Make layer. if (gmfLayer.type === 'WMTS') { layer = this.createWMTSLayer_( - /** @type {import('gmf/themes').GmfLayerWMTS} */ (/** @type {any} */ (gmfLayer)), + /** @type {import('gmf/themes').GmfLayerWMTS} */ /** @type {any} */ gmfLayer, ); } else { if (!this.ogcServersObject_) { throw new Error('Missing ogcServersObject'); } - const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ (/** @type {any} */ (gmfLayer)); + const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ /** @type {any} */ gmfLayer; const timeParam = this.getTimeParam_(treeCtrl); const ogcServer = this.ogcServersObject_[gmfLayerWMS.ogcServer]; if (!ogcServer) { @@ -346,16 +342,17 @@ SyncLayertreeMap.prototype.createLeafInAMixedGroup_ = function (treeCtrl, map) { if (!gmfLayerWMS.layers) { throw new Error('Missing gmfLayerWMS.layers'); } - - const opt_params = {STYLES: gmfLayerWMS.style}; - + const opt_params = { + STYLES: gmfLayerWMS.style, + }; layer = this.layerHelper_.createBasicWMSLayer( ogcServer.url, gmfLayerWMS.layers, ogcServer.imageType, ogcServer.type, timeParam, - opt_params, // WMS parameters + opt_params, + // WMS parameters ogcServer.credential ? 'use-credentials' : 'anonymous', this.gmfWMSSourceOptions_, ); @@ -371,7 +368,7 @@ SyncLayertreeMap.prototype.createLeafInAMixedGroup_ = function (treeCtrl, map) { } layer.setVisible(checked); // Insert layer in the map. - const layerGroup = /** @type {import('ol/layer/Group').default} */ (getLayer(treeCtrl.parent)); + const layerGroup = /** @type {import('ol/layer/Group').default} */ getLayer(treeCtrl.parent); layerGroup.getLayers().insertAt(0, layer); return layer; }; @@ -385,7 +382,7 @@ SyncLayertreeMap.prototype.createLeafInAMixedGroup_ = function (treeCtrl, map) { * @param {import('ol/Map').default} map A map that contains the layer to update. */ SyncLayertreeMap.prototype.initGmfLayerInANotMixedGroup_ = function (treeCtrl, map) { - const leafNode = /** @type {import('gmf/themes').GmfLayer} */ (treeCtrl.node); + const leafNode = /** @type {import('gmf/themes').GmfLayer} */ treeCtrl.node; const firstLevelGroup = this.getFirstLevelGroupCtrl_(treeCtrl); if (!firstLevelGroup) { throw new Error('Missing firstLevelGroup'); @@ -424,7 +421,6 @@ SyncLayertreeMap.prototype.createWMTSLayer_ = function (gmfLayerWMTS) { } const minResolution = getNodeMinResolution(gmfLayerWMTS); const maxResolution = getNodeMaxResolution(gmfLayerWMTS); - this.layerHelper_ .createWMTSLayerFromCapabilitites( gmfLayerWMTS.url, @@ -463,7 +459,7 @@ SyncLayertreeMap.prototype.updateLayerReferences_ = function (node, layer) { // 'all' means that the disclaimer is for all the layer. let layers = 'all'; if ('layers' in node) { - layers = /** @type {import('gmf/themes').GmfLayerWMS} */ (node).layers; + layers = /** @type {import('gmf/themes').GmfLayerWMS} */ node.layers; } disclaimers[layers] = disclaimer; layer.set('disclaimers', disclaimers); @@ -480,12 +476,12 @@ SyncLayertreeMap.prototype.updateLayerReferences_ = function (node, layer) { SyncLayertreeMap.prototype.getTimeParam_ = function (treeCtrl) { let wmsTime; let timeParam; - const node = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); + const node = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; if (node.time) { wmsTime = node.time; } else if (node.children) { treeCtrl.traverseDepthFirst((treeCtrl) => { - const node = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); + const node = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; if (node.children === undefined && node.time) { wmsTime = node.time; return LayertreeVisitorDecision.STOP; @@ -494,8 +490,8 @@ SyncLayertreeMap.prototype.getTimeParam_ = function (treeCtrl) { } if (wmsTime) { const options = this.ngeoWMSTime_.getOptions(wmsTime); - const timeValue = /** @type {number} */ (options.values); - const timeValues = /** @type {number[]} */ (options.values); + const timeValue = /** @type {number} */ options.values; + const timeValues = /** @type {number[]} */ options.values; timeParam = this.ngeoWMSTime_.formatWMSTimeParam(wmsTime, { start: timeValues[0] || timeValue, end: timeValues[1], @@ -514,7 +510,7 @@ SyncLayertreeMap.prototype.isOneParentNotMixed_ = function (treeCtrl) { let tree = treeCtrl.parent; let isOneParentNotMix = false; do { - const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ (tree.node); + const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ tree.node; isOneParentNotMix = gmfGroup.mixed === false; tree = tree.parent; } while (tree.parent && !isOneParentNotMix); @@ -567,5 +563,4 @@ const myModule = angular.module('gmfSyncLayertreeMap', [ ngeoMiscWMSTime.name, ]); myModule.service('gmfSyncLayertreeMap', SyncLayertreeMap); - export default myModule; diff --git a/src/layertree/TreeManager.js b/src/layertree/TreeManager.js index 73f7c8b9f1ee..47560221056f 100644 --- a/src/layertree/TreeManager.js +++ b/src/layertree/TreeManager.js @@ -1,3 +1,12 @@ +LayertreeTreeManager.$inject = [ + '$rootScope', + '$timeout', + '$injector', + 'gettextCatalog', + 'ngeoLayerHelper', + 'gmfThemes', + 'ngeoStateManager', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -61,7 +70,6 @@ import {listen} from 'ol/events'; * @param {import('gmf/theme/Themes').ThemesService} gmfThemes gmf Themes service. * @param {import('ngeo/statemanager/Service').StatemanagerService} ngeoStateManager The ngeo * statemanager service. - * @ngInject * @ngdoc service * @ngname gmfTreeManager * @hidden @@ -112,9 +120,9 @@ export function LayertreeTreeManager( * @type {import('gmf/themes').GmfRootNode} * @public */ - this.root = /** @type {import('gmf/themes').GmfRootNode} */ ({ + this.root = /** @type {import('gmf/themes').GmfRootNode} */ { children: [], - }); + }; /** * The controller of the (unique) root layer tree. @@ -160,7 +168,6 @@ export function LayertreeTreeManager( * @type {?import('gmf/themes').GmfOgcServers} */ this.ogcServers_ = null; - listen(this.gmfThemes_, 'change', this.handleThemesChange_, this); } @@ -173,7 +180,6 @@ LayertreeTreeManager.prototype.handleThemesChange_ = function () { this.gmfThemes_.getOgcServersObject().then((ogcServers) => { this.ogcServers_ = ogcServers; }); - if (this.rootCtrl && this.rootCtrl.children) { this.gmfThemes_.getThemesObject().then((themes) => { this.refreshFirstLevelGroups_(themes); @@ -192,7 +198,6 @@ LayertreeTreeManager.prototype.handleThemesChange_ = function () { LayertreeTreeManager.prototype.setFirstLevelGroups = function (firstLevelGroups) { //Remove existing submenu if opened at theme refresh this.parseTreeNodes(this.root); - this.rootScope_.$broadcast('ngeo-pre-empty-layertree'); this.root.children.length = 0; this.rootScope_.$broadcast('ngeo-post-empty-layertree'); @@ -214,7 +219,6 @@ LayertreeTreeManager.prototype.setFirstLevelGroups = function (firstLevelGroups) LayertreeTreeManager.prototype.addFirstLevelGroups = function (firstLevelGroups, opt_add, opt_silent) { /** @type {import('gmf/themes').GmfGroup[]} */ const groupNotAdded = []; - firstLevelGroups .slice() .reverse() @@ -226,7 +230,6 @@ LayertreeTreeManager.prototype.addFirstLevelGroups = function (firstLevelGroups, if (groupNotAdded.length > 0 && !opt_silent) { this.notifyCantAddGroups_(groupNotAdded); } - return groupNotAdded.length === 0; }; @@ -252,7 +255,6 @@ LayertreeTreeManager.prototype.addSecondLevelGroups = function ( ) { /** @type {import('gmf/themes').GmfGroup[]} */ const groupNotAdded = []; - firstLevelGroups .slice() .reverse() @@ -260,7 +262,6 @@ LayertreeTreeManager.prototype.addSecondLevelGroups = function ( if (!this.addFirstLevelGroup_(group)) { groupNotAdded.push(group); } - group.children.forEach((child) => { // Find if the tree child is the one we searched let enabled = child.name === groupName; @@ -268,7 +269,6 @@ LayertreeTreeManager.prototype.addSecondLevelGroups = function ( // Set the tree child accordingly this.setSearchedChild(child, enabled); }); - setTimeout(() => { // Update the permalink const treeCtrl = this.getTreeCtrlByNodeId(group.id); @@ -278,7 +278,6 @@ LayertreeTreeManager.prototype.addSecondLevelGroups = function ( if (groupNotAdded.length > 0 && !opt_silent) { this.notifyCantAddGroups_(groupNotAdded); } - return groupNotAdded.length === 0; }; @@ -310,7 +309,7 @@ LayertreeTreeManager.prototype.setInitialFirstLevelGroups = function (firstGroup * @param {import('gmf/themes').GmfGroup | import('gmf/themes').GmfLayer | import('gmf/themes').GmfRootNode} node Layer tree node to remove. */ LayertreeTreeManager.prototype.parseTreeNodes = function (node) { - const group = /** @type {import('gmf/themes').GmfGroup} */ (node); + const group = /** @type {import('gmf/themes').GmfGroup} */ node; if (group.children) { /** * @param {unknown} child @@ -356,9 +355,9 @@ LayertreeTreeManager.prototype.updateTreeGroupsState_ = function (groups, remove treeGroupsParam[PermalinkParam.TREE_GROUPS] = groups.map((node) => node.name).join(','); this.ngeoStateManager_.updateState(treeGroupsParam); if (this.$injector_.has('gmfPermalink')) { - /** @type {import('gmf/permalink/Permalink').PermalinkService} */ ( - this.$injector_.get('gmfPermalink') - ).cleanParams(removedGroups); + /** @type {import('gmf/permalink/Permalink').PermalinkService} */ this.$injector_ + .get('gmfPermalink') + .cleanParams(removedGroups); } }; @@ -433,7 +432,6 @@ LayertreeTreeManager.prototype.addFirstLevelGroup_ = function (group) { this.groupsToAddInThisDigestLoop_.length = 0; this.promiseForGroupsToAddInThisDigestLoop_ = null; }); - return true; }; @@ -562,12 +560,12 @@ LayertreeTreeManager.prototype.cloneGroupNode_ = function (group, names) { * should have their checkbox checked) */ LayertreeTreeManager.prototype.toggleNodeCheck_ = function (node, names) { - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (node); + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ node; if (!groupNode.children) { return; } groupNode.children.forEach((childNode) => { - const childGroupNode = /** @type {import('gmf/themes').GmfGroup} */ (childNode); + const childGroupNode = /** @type {import('gmf/themes').GmfGroup} */ childNode; if (childGroupNode.children) { this.toggleNodeCheck_(childGroupNode, names); } else if (childNode.metadata) { @@ -633,9 +631,9 @@ LayertreeTreeManager.prototype.getOgcServer = function (treeCtrl) { if (!this.ogcServers_) { throw new Error('Missing ogcServers'); } - const gmfParentGroup = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.parent.node); + const gmfParentGroup = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.parent.node; if (gmfParentGroup.mixed) { - const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ (/** @type {any} */ (treeCtrl.node)); + const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ /** @type {any} */ treeCtrl.node; if (!gmfLayerWMS.ogcServer) { throw new Error('Missing gmfLayerWMS.ogcServer'); } @@ -645,7 +643,7 @@ LayertreeTreeManager.prototype.getOgcServer = function (treeCtrl) { while (!firstLevelGroupCtrl.parent.isRoot) { firstLevelGroupCtrl = firstLevelGroupCtrl.parent; } - const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ (firstLevelGroupCtrl.node); + const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ firstLevelGroupCtrl.node; if (!gmfGroup.ogcServer) { throw new Error('Missing gmfGroup.ogcServer'); } @@ -722,7 +720,6 @@ LayertreeTreeManager.prototype.getFirstLevelGroupFullState_ = function (treeCtrl treeCtrl.children.map((child) => { children[child.node.name] = this.getFirstLevelGroupFullState_(child); }); - let isChecked, isExpanded, isLegendExpanded; if (treeCtrl.children.length > 0) { const nodeElement = $(`#gmf-layertree-layer-group-${treeCtrl.uid}`); @@ -745,7 +742,6 @@ LayertreeTreeManager.prototype.getFirstLevelGroupFullState_ = function (treeCtrl isLegendExpanded = legendElement.hasClass('show'); } } - return { children, isChecked, @@ -764,7 +760,6 @@ LayertreeTreeManager.prototype.setFirstLevelGroupFullState_ = function (treeCtrl if (fullState === undefined) { return; } - if (treeCtrl.children.length > 0) { const nodeElement = $(`#gmf-layertree-layer-group-${treeCtrl.uid}`); // Set isExpanded only in groups. @@ -806,5 +801,4 @@ const myModule = angular.module('gmfTreeManager', [ ngeoStatemanagerService.name, ]); myModule.service('gmfTreeManager', LayertreeTreeManager); - export default myModule; diff --git a/src/layertree/component.js b/src/layertree/component.js index 0acb719b3b96..c84640686d5a 100644 --- a/src/layertree/component.js +++ b/src/layertree/component.js @@ -1,3 +1,18 @@ +Controller.$inject = [ + '$element', + '$scope', + 'ngeoLayerHelper', + 'gmfLayerBeingSwipe', + 'gmfDataSourceBeingFiltered', + 'gmfExternalDataSourcesManager', + 'gmfPermalink', + 'gmfTreeManager', + 'gmfSyncLayertreeMap', + 'ngeoWMSTime', + 'gmfThemes', + '$timeout', + 'gmfLayerTreeOptions', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -25,9 +40,7 @@ import gmfDatasourceDataSourceBeingFiltered from 'gmf/datasource/DataSourceBeing import gmfLayerBeingSwipe from 'gmf/datasource/LayerBeingSwipe'; import gmfDatasourceExternalDataSourcesManager from 'gmf/datasource/ExternalDataSourcesManager'; import gmfPermalinkPermalink from 'gmf/permalink/Permalink'; - import gmfLayertreeDatasourceGroupTreeComponent from 'gmf/layertree/datasourceGroupTreeComponent'; - import gmfLayertreeSyncLayertreeMap from 'gmf/layertree/SyncLayertreeMap'; import gmfLayertreeTreeManager from 'gmf/layertree/TreeManager'; import gmfThemeThemes, { @@ -37,7 +50,6 @@ import gmfThemeThemes, { } from 'gmf/theme/Themes'; import gmfDatasourceOGC from 'gmf/datasource/OGC'; import {ServerType} from 'ngeo/datasource/OGC'; - import gmfLayertreeNode from 'gmf/layertree/layertreeNode'; import ngeoLayertreeController, {LayertreeVisitorDecision} from 'ngeo/layertree/Controller'; import ngeoMapLayerHelper from 'ngeo/map/LayerHelper'; @@ -51,7 +63,6 @@ import olSourceTileWMS from 'ol/source/TileWMS'; import olSourceWMTS from 'ol/source/WMTS'; import LayerBase from 'ol/layer/Base'; import {getUid} from 'ol/util'; - import 'bootstrap/js/src/collapse'; /** @@ -95,18 +106,18 @@ myModule.value( */ (element, attrs) => 'gmf/layertree', ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/layertree', require('./component.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/layertree', require('./component.html')); + }, + ], ); - myModule.value( 'gmfLayertreeTemplate', /** @@ -132,10 +143,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(JQuery, angular.IAttributes): string} gmfLayertreeTemplate Template function. * @returns {string} Template. - * @ngInject * @private * @hidden */ +gmfLayertreeTemplate.$inject = ['$element', '$attrs', 'gmfLayertreeTemplate']; function gmfLayertreeTemplate($element, $attrs, gmfLayertreeTemplate) { return gmfLayertreeTemplate($element, $attrs); } @@ -199,7 +210,6 @@ const layertreeComponent = { }, template: gmfLayertreeTemplate, }; - myModule.component('gmfLayertree', layertreeComponent); /** @@ -223,7 +233,6 @@ myModule.component('gmfLayertree', layertreeComponent); * @param {import('gmf/options').gmfLayerTreeOptions} gmfLayerTreeOptions The options. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname gmfLayertreeController */ @@ -291,7 +300,6 @@ export function Controller( * @type {import('gmf/layertree/TreeManager').LayertreeTreeManager} */ this.gmfTreeManager_ = gmfTreeManager; - const root = gmfTreeManager.root; if (!root) { throw new Error('Missing root'); @@ -348,7 +356,6 @@ export function Controller( */ Controller.prototype.$onInit = function () { this.dataLayerGroup_ = this.layerHelper_.getGroupFromMap(this.map, DATALAYERGROUP_NAME); - ngeoMiscSyncArrays(this.dataLayerGroup_.getLayers().getArray(), this.layers, true, this.scope_, () => true); // watch any change on layers array to refresh the map @@ -393,8 +400,8 @@ Controller.prototype.updateDimensions_ = function (treeCtrl) { throw new Error('Wrong feature type'); } this.updateLayerDimensions_( - /** @type {olLayerLayer} */ (layer), - /** @type {import('gmf/themes').GmfGroup|import('gmf/themes').GmfLayer} */ (ctrl.node), + /** @type {olLayerLayer} */ layer, + /** @type {import('gmf/themes').GmfGroup|import('gmf/themes').GmfLayer} */ ctrl.node, ); return LayertreeVisitorDecision.DESCEND; } @@ -427,7 +434,7 @@ Controller.prototype.updateLayerDimensions_ = function (layer, node) { source.updateParams(dimensions); } else { // the source is not ready yet - layer.once(/** @type {import('ol/Observable').EventTypes} */ ('change:source'), () => { + layer.once(/** @type {import('ol/Observable').EventTypes} */ 'change:source', () => { if (!(layer instanceof olLayerLayer)) { throw new Error('Wrong feature type'); } @@ -461,14 +468,11 @@ Controller.prototype.getLayer = function (treeCtrl) { this.gmfTreeManager_.root.children.length - this.gmfTreeManager_.numberOfGroupsToAddInThisDigestLoop || 0; } - const layer = this.gmfSyncLayertreeMap_.createLayer(treeCtrl, this.map, this.dataLayerGroup_, opt_position); - if (layer instanceof olLayerLayer) { - const node = /** @type {import('gmf/themes').GmfGroup|import('gmf/themes').GmfLayer} */ (treeCtrl.node); + const node = /** @type {import('gmf/themes').GmfGroup|import('gmf/themes').GmfLayer} */ treeCtrl.node; this.updateLayerDimensions_(layer, node); } - return layer; }; @@ -556,7 +560,7 @@ Controller.prototype.updateWMSTimeLayerState = function (layertreeCtrl, time) { if (!time) { return; } - const dataSource = /** @type {?import("ngeo/datasource/OGC").default} */ (layertreeCtrl.getDataSource()); + const dataSource = /** @type {?import("ngeo/datasource/OGC").default} */ layertreeCtrl.getDataSource(); if (dataSource) { if (!(dataSource instanceof gmfDatasourceOGC)) { throw new Error('Wrong dataSource type'); @@ -579,25 +583,19 @@ Controller.prototype.updateWMSTimeLayerState = function (layertreeCtrl, time) { */ Controller.prototype.getLegendIconURL = function (treeCtrl) { const iconUrl = treeCtrl.node.metadata.iconUrl; - if (iconUrl !== undefined) { return iconUrl; } - - const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); + const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; if (gmfGroup.children !== undefined) { return undefined; } - - const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ (treeCtrl.node); + const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ treeCtrl.node; if (gmfLayer.type !== 'WMS') { return undefined; } - - const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ (/** @type {any} */ (gmfLayer)); - + const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ /** @type {any} */ gmfLayer; const legendRule = gmfLayerWMS.metadata.legendRule; - if (legendRule === undefined) { return undefined; } @@ -627,17 +625,15 @@ Controller.prototype.getLegendIconURL = function (treeCtrl) { Controller.prototype.getLegendsObject = function (treeCtrl) { /** @type {Object} */ const legendsObject = {}; - if (/** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node).children !== undefined) { + if (/** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node.children !== undefined) { return null; } - - const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ (treeCtrl.node); + const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ treeCtrl.node; const gmfLayerDefaultName = gmfLayer.name; if (gmfLayer.metadata.legendImage) { legendsObject[gmfLayerDefaultName] = gmfLayer.metadata.legendImage; return legendsObject; } - const layer = treeCtrl.layer; if (gmfLayer.type === 'WMTS') { if (!(layer instanceof olLayerTile)) { @@ -649,7 +645,7 @@ Controller.prototype.getLegendsObject = function (treeCtrl) { } return wmtsLegendURL ? legendsObject : null; } else { - const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ (/** @type {any} */ (gmfLayer)); + const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ /** @type {any} */ gmfLayer; const layersNames = gmfLayerWMS.layers; const gmfOgcServer = this.gmfTreeManager_.getOgcServer(treeCtrl); const scale = this.getScale_(); @@ -717,7 +713,7 @@ Controller.prototype.isSnappingActivated = function (treeCtrl) { return treeCtrl.properties.snapping; } // Default to node.metadata.activated - const node = /** @type {import('gmf/themes').GmfLayer} */ (treeCtrl.node); + const node = /** @type {import('gmf/themes').GmfLayer} */ treeCtrl.node; const config = getSnappingConfig(node); return config !== null && config.activated; }; @@ -758,7 +754,7 @@ Controller.prototype.afterReorder = function () { if (!this.gmfTreeManager_.rootCtrl) { throw new Error('Missing gmfTreeManager_.rootCtrl'); } - const gmfRootGroup = /** @type {import('gmf/themes').GmfGroup} */ (this.gmfTreeManager_.rootCtrl.node); + const gmfRootGroup = /** @type {import('gmf/themes').GmfGroup} */ this.gmfTreeManager_.rootCtrl.node; const groupNodes = gmfRootGroup.children; const currentTreeCtrls = this.gmfTreeManager_.rootCtrl.children; /** @type {import('ngeo/layertree/Controller').LayertreeController[]} */ @@ -816,7 +812,6 @@ Controller.prototype.removeNode = function (node) { this.gmfTreeManager_.parseTreeNodes(node); this.gmfTreeManager_.removeGroup(node); }; - Controller.prototype.removeAllNodes = function () { this.gmfTreeManager_.parseTreeNodes(this.root); this.gmfTreeManager_.removeAll(); @@ -863,7 +858,7 @@ Controller.prototype.getResolutionStyle = function (gmfLayer) { * from the current node. */ Controller.prototype.zoomToResolution = function (treeCtrl) { - const gmfLayer = /** @type {import('gmf/themes').GmfLayerWMS} */ (/** @type {any} */ (treeCtrl.node)); + const gmfLayer = /** @type {import('gmf/themes').GmfLayerWMS} */ /** @type {any} */ treeCtrl.node; const view = this.map.getView(); const resolution = view.getResolution(); if (resolution === undefined) { @@ -977,7 +972,7 @@ Controller.prototype.supportsCustomization = function (treeCtrl) { * legend being shown. */ Controller.prototype.supportsLegend = function (treeCtrl) { - const node = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); + const node = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; return !!node.metadata && !!node.metadata.legend && !!this.getLegendsObject(treeCtrl); }; @@ -987,9 +982,9 @@ Controller.prototype.supportsLegend = function (treeCtrl) { * layer opacity being changed or not. */ Controller.prototype.supportsOpacityChange = function (treeCtrl) { - const node = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); + const node = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; const parentNode = treeCtrl.parent - ? /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.parent.node) + ? /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.parent.node : undefined; return ( !!treeCtrl.layer && @@ -1003,7 +998,7 @@ Controller.prototype.supportsOpacityChange = function (treeCtrl) { * @returns {boolean} Whether the layer tree controller has a filtrable datasource or not. */ Controller.prototype.isFiltrable = function (treeCtrl) { - const datasource = /** @type {import('ngeo/datasource/OGC').OGC} */ (treeCtrl.getDataSource()); + const datasource = /** @type {import('ngeo/datasource/OGC').OGC} */ treeCtrl.getDataSource(); return datasource ? datasource.filtrable : false; }; @@ -1013,9 +1008,9 @@ Controller.prototype.isFiltrable = function (treeCtrl) { * opacity change or is filtrable. Or null if there is any parent with layer functions. */ Controller.prototype.getFirstParentWithLayerFunctions = function (treeCtrl) { - const parentTreeCtrl = /** @type {import('ngeo/layertree/Controller').LayertreeController} */ ( - treeCtrl.parent - ); + const parentTreeCtrl = + /** @type {import('ngeo/layertree/Controller').LayertreeController} */ + treeCtrl.parent; if (!parentTreeCtrl) { return null; } @@ -1024,7 +1019,5 @@ Controller.prototype.getFirstParentWithLayerFunctions = function (treeCtrl) { } return this.getFirstParentWithLayerFunctions(parentTreeCtrl); }; - myModule.controller('GmfLayertreeController', Controller); - export default myModule; diff --git a/src/layertree/datasourceGroupTreeComponent.js b/src/layertree/datasourceGroupTreeComponent.js index 3b20e362b656..87d2ef1ba09b 100644 --- a/src/layertree/datasourceGroupTreeComponent.js +++ b/src/layertree/datasourceGroupTreeComponent.js @@ -32,21 +32,21 @@ const myModule = angular.module('gmfLayertreeDatasourceGroupTreeComponent', [ ngeoDatasourceDataSources.name, ngeoMapLayerHelper.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - $templateCache.put( - 'gmf/layertree/datasourceGroupTreeComponent', - // @ts-ignore: webpack - require('./datasourceGroupTreeComponent.html'), - ); - }, + [ + '$templateCache', + ($templateCache) => { + $templateCache.put( + 'gmf/layertree/datasourceGroupTreeComponent', + // @ts-ignore: webpack + require('./datasourceGroupTreeComponent.html'), + ); + }, + ], ); - myModule.value( 'gmfLayertreeDatasourceGroupTreeTemplateUrl', /** @@ -64,10 +64,10 @@ myModule.value( * @param {function(angular.IAttributes): string} gmfLayertreeDatasourceGroupTreeTemplateUrl * Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfLayertreeDatasourceGroupTreeTemplateUrl.$inject = ['$attrs', 'gmfLayertreeDatasourceGroupTreeTemplateUrl']; function gmfLayertreeDatasourceGroupTreeTemplateUrl($attrs, gmfLayertreeDatasourceGroupTreeTemplateUrl) { return gmfLayertreeDatasourceGroupTreeTemplateUrl($attrs); } @@ -80,7 +80,6 @@ export class Controller { * @param {angular.IScope} $scope Angular scope. * @param {import('ngeo/datasource/DataSources').DataSource} ngeoDataSources Ngeo data sources service. * @param {import('ngeo/map/LayerHelper').LayerHelper} ngeoLayerHelper Ngeo data sources service. - * @ngInject * @ngdoc controller * @ngname GmfDatasourcegrouptreeController */ @@ -211,7 +210,7 @@ export class Controller { } } } - +Controller.$inject = ['$scope', 'ngeoDataSources', 'ngeoLayerHelper']; myModule.component('gmfDatasourcegrouptree', { bindings: { 'group': '<', @@ -220,5 +219,4 @@ myModule.component('gmfDatasourcegrouptree', { controller: Controller, templateUrl: gmfLayertreeDatasourceGroupTreeTemplateUrl, }); - export default myModule; diff --git a/src/layertree/layertreeNode.js b/src/layertree/layertreeNode.js index 391b97c6d8f6..222cc4e1fc5b 100644 --- a/src/layertree/layertreeNode.js +++ b/src/layertree/layertreeNode.js @@ -1,3 +1,4 @@ +gmfLayertreeNodeComponent.$inject = ['gmfLayertreeNodeTemplateUrl']; // The MIT License (MIT) // // Copyright (c) 2014-2024 Camptocamp SA @@ -21,7 +22,6 @@ import angular from 'angular'; import ngeoLayertreeController, {LayertreeController} from 'ngeo/layertree/Controller'; - import 'bootstrap/js/src/collapse'; // needed to collapse a layertree /** @@ -29,7 +29,6 @@ import 'bootstrap/js/src/collapse'; // needed to collapse a layertree * @hidden */ const myModule = angular.module('gmfLayertreeNode', [ngeoLayertreeController.name]); - myModule.value( 'gmfLayertreeNodeTemplateUrl', /** @@ -42,16 +41,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'gmf/layertree/layertreeNode'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/layertree/layertreeNode', require('./layertreeNode.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/layertree/layertreeNode', require('./layertreeNode.html')); + }, + ], ); /** @@ -138,7 +138,6 @@ myModule.run( * @param {string|function(JQuery=, angular.IAttributes=): string} gmfLayertreeNodeTemplateUrl * Template URL for the directive. * @returns {angular.IDirective} The Directive Definition Object. - * @ngInject * @ngdoc directive * @ngname gmfLayertreeNode */ @@ -150,7 +149,5 @@ function gmfLayertreeNodeComponent(gmfLayertreeNodeTemplateUrl) { controller: LayertreeController, }; } - myModule.directive('gmfLayertreeNode', gmfLayertreeNodeComponent); - export default myModule; diff --git a/src/layertree/timeSliderComponent.js b/src/layertree/timeSliderComponent.js index cbf45474b09f..c1228a099086 100644 --- a/src/layertree/timeSliderComponent.js +++ b/src/layertree/timeSliderComponent.js @@ -1,3 +1,4 @@ +Controller.$inject = ['ngeoWMSTime', 'ngeoDebounce']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,7 +23,6 @@ import angular from 'angular'; import ngeoMiscWMSTime from 'ngeo/misc/WMSTime'; import ngeoMiscDebounce from 'ngeo/misc/debounce'; - import 'jquery-ui/ui/widgets/slider'; import 'ngeo/sass/jquery-ui.scss'; import 'angular-ui-slider'; @@ -37,16 +37,17 @@ const myModule = angular.module('gmfLayertreeTimeSliderComponent', [ ngeoMiscDebounce.name, 'ui.slider', ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/layertree/timesliderComponent', require('./timesliderComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/layertree/timesliderComponent', require('./timesliderComponent.html')); + }, + ], ); /** @@ -66,7 +67,6 @@ myModule.run( * @htmlAttribute {function()} gmf-time-slider-on-date-selected Expression evaluated after * date(s) changed * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname gmfTimeSlider */ @@ -86,7 +86,6 @@ function layertreeTimeSliderComponent() { throw new Error('Missing ctrl'); } ctrl.init(); - ctrl.sliderOptions.stop = onSliderReleased_; ctrl.sliderOptions.slide = ctrl.ngeoDebounce_(onSliderReleased_, 300, true); @@ -136,7 +135,6 @@ function layertreeTimeSliderComponent() { }, }; } - myModule.directive('gmfTimeSlider', layertreeTimeSliderComponent); /** @@ -146,7 +144,6 @@ myModule.directive('gmfTimeSlider', layertreeTimeSliderComponent); * @param {import('ngeo/misc/debounce').miscDebounce} ngeoDebounce ngeo Debounce factory. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname gmfTimeSliderController */ @@ -255,7 +252,9 @@ Controller.prototype.init = function () { max: this.maxValue, }; // Call the callback with the current slider time. - this.onDateSelected({time: currentTime}); + this.onDateSelected({ + time: currentTime, + }); }; /** @@ -273,7 +272,6 @@ Controller.prototype.getTimeValueList_ = function () { let timeValueList = []; const minDate = new Date(this.minValue); const maxDate = new Date(this.maxValue); - if (wmsTime.values) { timeValueList = []; wmsTime.values.forEach((date) => { @@ -292,7 +290,6 @@ Controller.prototype.getTimeValueList_ = function () { minDate.getDate() + maxNbValues * wmsTime.interval[2], ); endDate.setSeconds(minDate.getSeconds() + maxNbValues * wmsTime.interval[3]); - if (endDate > maxDate) { // Transform interval to a list of values when the number // of values is below a threshold (maxNbValues) @@ -330,17 +327,14 @@ Controller.prototype.getClosestValue_ = function (timestamp) { if (timestamp <= this.minValue) { return this.minValue; } - if (timestamp >= this.maxValue) { return this.maxValue; } - if (this.timeValueList) { // Time stops are defined as a list of values let index; let leftIndex = 0; let rightIndex = this.timeValueList.length - 1; - while (rightIndex - leftIndex > 1) { index = Math.floor((leftIndex + rightIndex) / 2); if (this.timeValueList[index] >= timestamp) { @@ -349,10 +343,8 @@ Controller.prototype.getClosestValue_ = function (timestamp) { leftIndex = index; } } - const leftDistance = Math.abs(this.timeValueList[leftIndex] - timestamp); const rightDistance = Math.abs(this.timeValueList[rightIndex] - timestamp); - return this.timeValueList[leftDistance < rightDistance ? leftIndex : rightIndex]; } else { // Time stops are defined by a start date plus an interval @@ -361,7 +353,6 @@ Controller.prototype.getClosestValue_ = function (timestamp) { let bestDate = new Date(this.minValue); const maxDate = new Date(this.maxValue); let bestDistance = Math.abs(targetDate.getTime() - bestDate.getTime()); - for (let i = 1; ; i++) { // The start date should always be used as a reference // because adding a month twice could differ from adding @@ -373,11 +364,9 @@ Controller.prototype.getClosestValue_ = function (timestamp) { startDate.getDate() + i * this.time.interval[2], ); next.setSeconds(startDate.getSeconds() + i * this.time.interval[3]); - if (next > maxDate) { break; } - const distance = Math.abs(targetDate.getTime() - next.getTime()); if (distance <= bestDistance) { bestDate = next; @@ -386,7 +375,6 @@ Controller.prototype.getClosestValue_ = function (timestamp) { break; } } - return bestDate.getTime(); } }; @@ -403,7 +391,5 @@ Controller.prototype.getLocalizedDate = function (time) { } return this.ngeoWMSTime_.formatTimeValue(time, this.time.resolution); }; - myModule.controller('gmfTimeSliderController', Controller); - export default myModule; diff --git a/src/map/BackgroundLayerMgr.js b/src/map/BackgroundLayerMgr.js index 6194cfefe01a..67003ad2ddc1 100644 --- a/src/map/BackgroundLayerMgr.js +++ b/src/map/BackgroundLayerMgr.js @@ -89,7 +89,6 @@ const BACKGROUNDLAYERGROUP_NAME = 'background'; export class MapBackgroundLayerManager extends olObservable { /** * @param {import('ngeo/map/LayerHelper').LayerHelper} ngeoLayerHelper Themes service. - * @ngInject */ constructor(ngeoLayerHelper) { super(); @@ -139,9 +138,7 @@ export class MapBackgroundLayerManager extends olObservable { layer.setZIndex(ZIndex); this.ngeoLayerHelper_.setZIndexToFirstLevelChildren(layer, ZIndex); } - const bgGroup = this.ngeoLayerHelper_.getGroupFromMap(map, BACKGROUNDLAYERGROUP_NAME); - if (previous !== null) { console.assert(mapUid in this.mapUids_); if (layer !== null) { @@ -160,7 +157,6 @@ export class MapBackgroundLayerManager extends olObservable { previous: previous, }); this.dispatchEvent(event); - return previous; } @@ -195,7 +191,6 @@ export class MapBackgroundLayerManager extends olObservable { const ZIndex = -100; layer.setZIndex(ZIndex); this.ngeoLayerHelper_.setZIndexToFirstLevelChildren(layer, ZIndex); - const index = bgGroup.getLayers().getArray().indexOf(layer); if (index === -1) { bgGroup.getLayers().push(layer); @@ -214,7 +209,6 @@ export class MapBackgroundLayerManager extends olObservable { // Handle the first level of layers of the base background layer. layers = baseBgLayer.getLayers().getArray(); } - layers.forEach((layer) => { if (layer instanceof olLayerLayer) { let hasUpdates = false; @@ -242,12 +236,11 @@ export class MapBackgroundLayerManager extends olObservable { } } } - +MapBackgroundLayerManager.$inject = ['ngeoLayerHelper']; /** * @type {angular.IModule} * @hidden */ const myModule = angular.module('ngeoBackgroundLayerMgr', [ngeoLayerHelper.name]); myModule.service('ngeoBackgroundLayerMgr', MapBackgroundLayerManager); - export default myModule; diff --git a/src/map/LayerHelper.js b/src/map/LayerHelper.js index f9bd79bb02a3..b62ed4790620 100644 --- a/src/map/LayerHelper.js +++ b/src/map/LayerHelper.js @@ -1,3 +1,4 @@ +LayerHelper.$inject = ['$q', '$http', 'ngeoTilesPreloadingLimit']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -48,7 +49,6 @@ import {ServerType} from 'ngeo/datasource/OGC'; * @class * @ngdoc service * @ngname ngeoLayerHelper - * @ngInject * @hidden */ export function LayerHelper($q, $http, ngeoTilesPreloadingLimit) { @@ -167,7 +167,6 @@ LayerHelper.prototype.createBasicWMSLayer = function ( // OpenLayers expects 'qgis' instead of 'qgisserver' olServerType = opt_serverType.replace(ServerType.QGISSERVER, 'qgis'); } - const options = Object.assign({}, opt_customSourceOptions, { url: sourceURL, params: params, @@ -186,7 +185,6 @@ LayerHelper.prototype.createBasicWMSLayer = function ( if (opt_params) { source.updateParams(opt_params); } - if (!(opt_params && opt_params.STYLES)) { params.STYLES = ''; let i = sourceLayersName.split(',').length; @@ -195,8 +193,9 @@ LayerHelper.prototype.createBasicWMSLayer = function ( i--; } } - - const layerOptions = Object.assign({}, opt_customLayerOptions, {source}); + const layerOptions = Object.assign({}, opt_customLayerOptions, { + source, + }); return new olLayerImage(layerOptions); }; @@ -212,7 +211,6 @@ LayerHelper.prototype.createBasicWMSLayerFromDataSource = function (dataSource, if (url === undefined) { throw new Error('Missing url'); } - const layerNames = dataSource.getWMSLayerNames().join(','); const serverType = dataSource.ogcServerType; const imageType = dataSource.ogcImageType; @@ -236,7 +234,6 @@ LayerHelper.prototype.createBasicWMSLayerFromDataSource = function (dataSource, // (4) Set the datasource id property layer.set(DATASOURCE_ID, dataSource.id); - return layer; }; @@ -291,43 +288,45 @@ LayerHelper.prototype.createWMTSLayerFromCapabilitites = function ( className: 'canvas3d', }); const $q = this.$q_; - - return this.$http_.get(capabilitiesURL, {cache: true}).then((response) => { - let result; - if (response.data) { - result = parser.read(response.data); - } - if (result) { - const options = Object.assign( - {}, - opt_customOptions, - optionsFromCapabilities(result, { - matrixSet: opt_matrixSet, - crossOrigin: 'anonymous', - layer: layerName, - }), - ); - const source = new olSourceWMTS(/** @type {import('ol/source/WMTS').Options} */ (options)); - if (opt_dimensions && !isEmpty(opt_dimensions)) { - source.updateDimensions(opt_dimensions); + return this.$http_ + .get(capabilitiesURL, { + cache: true, + }) + .then((response) => { + let result; + if (response.data) { + result = parser.read(response.data); } - layer.setSource(source); - - // Add styles from capabilities as param of the layer - const layers = result.Contents.Layer; - const l = layers.find((elt) => elt.Identifier == layerName); - if (!l) { - return $q.reject(`Layer ${layerName} not available in WMTS capabilities from ${capabilitiesURL}`); + if (result) { + const options = Object.assign( + {}, + opt_customOptions, + optionsFromCapabilities(result, { + matrixSet: opt_matrixSet, + crossOrigin: 'anonymous', + layer: layerName, + }), + ); + const source = new olSourceWMTS(/** @type {import('ol/source/WMTS').Options} */ options); + if (opt_dimensions && !isEmpty(opt_dimensions)) { + source.updateDimensions(opt_dimensions); + } + layer.setSource(source); + + // Add styles from capabilities as param of the layer + const layers = result.Contents.Layer; + const l = layers.find((elt) => elt.Identifier == layerName); + if (!l) { + return $q.reject(`Layer ${layerName} not available in WMTS capabilities from ${capabilitiesURL}`); + } + layer.set('capabilitiesStyles', l.Style); + if (opt_opacity !== undefined) { + layer.setOpacity(opt_opacity); + } + return $q.resolve(layer); } - layer.set('capabilitiesStyles', l.Style); - if (opt_opacity !== undefined) { - layer.setOpacity(opt_opacity); - } - - return $q.resolve(layer); - } - return $q.reject(`Failed to get WMTS capabilities from ${capabilitiesURL}`); - }); + return $q.reject(`Failed to get WMTS capabilities from ${capabilitiesURL}`); + }); }; /** @@ -349,14 +348,11 @@ LayerHelper.prototype.createWMTSLayerFromCapabilititesObj = function ( layer: layerCap.Identifier, className: 'canvas3d', }); - console.assert(options); - const source = new olSourceWMTS(/** @type {import('ol/source/WMTS').Options} */ (options)); - + const source = new olSourceWMTS(/** @type {import('ol/source/WMTS').Options} */ options); if (opt_dimensions && !isEmpty(opt_dimensions)) { source.updateDimensions(opt_dimensions); } - const result = new olLayerTile({ preload: Infinity, source: source, @@ -443,7 +439,7 @@ LayerHelper.prototype.getGroupFromMap = function (map, groupName) { let group; groups.getArray().some((existingGroup) => { if (existingGroup.get(GROUP_KEY) === groupName) { - group = /** @type {import('ol/layer/Group').default} */ (existingGroup); + group = /** @type {import('ol/layer/Group').default} */ existingGroup; return true; } else { return false; @@ -466,9 +462,9 @@ LayerHelper.prototype.getGroupFromMap = function (map, groupName) { */ LayerHelper.prototype.getFlatLayers = function (layer) { if (layer instanceof olLayerGroup) { - const sublayers = /** @type {import('ol/layer/Layer').default[]} */ ( - layer.getLayers().getArray() - ); + const sublayers = + /** @type {import('ol/layer/Layer').default[]} */ + layer.getLayers().getArray(); const hasGroupLayer = sublayers.some((sublayer) => sublayer instanceof olLayerGroup); if (!hasGroupLayer) { return sublayers.slice(); @@ -531,7 +527,6 @@ LayerHelper.prototype.getLayerByNodeName = function (nodeName, layers) { } return !!found; }); - return found; }; @@ -643,7 +638,6 @@ LayerHelper.prototype.isLayerVisible = function (layer, map) { if (!layer.getVisible()) { return false; } - const currentResolution = map.getView().getResolution(); if (currentResolution === undefined) { throw new Error('Missing resolution'); @@ -659,9 +653,9 @@ LayerHelper.prototype.isLayerVisible = function (layer, map) { LayerHelper.prototype.refreshWMSLayer = function (layer) { const source_ = layer.getSource(); console.assert(source_ instanceof olSourceImageWMS || source_ instanceof olSourceTileWMS); - const source = /** @type {import('ol/source/ImageWMS').default|import('ol/source/TileWMS').default} */ ( - source_ - ); + const source = + /** @type {import('ol/source/ImageWMS').default|import('ol/source/TileWMS').default} */ + source_; const params = source.getParams(); params[REFRESH_PARAM] = Math.random(); source.updateParams(params); @@ -702,9 +696,14 @@ LayerHelper.prototype.updateWMSLayerState = function (layer, names, opt_time) { throw new Error('Wrong source type'); } if (opt_time) { - source.updateParams({'LAYERS': names, 'TIME': opt_time}); + source.updateParams({ + 'LAYERS': names, + 'TIME': opt_time, + }); } else { - source.updateParams({'LAYERS': names}); + source.updateParams({ + 'LAYERS': names, + }); } } }; @@ -715,7 +714,7 @@ LayerHelper.prototype.updateWMSLayerState = function (layer, names, opt_time) { * the data source ids this layer is composed of. */ LayerHelper.prototype.getQuerySourceIds = function (layer) { - return /** @type {number[]|undefined} */ (layer.get('querySourceIds')); + return /** @type {number[]|undefined} */ layer.get('querySourceIds'); }; /** @@ -724,5 +723,4 @@ LayerHelper.prototype.getQuerySourceIds = function (layer) { */ const myModule = angular.module('ngeoLayerHelper', []); myModule.service('ngeoLayerHelper', LayerHelper); - export default myModule; diff --git a/src/map/component.js b/src/map/component.js index 8362367e820b..a4e298962d4b 100644 --- a/src/map/component.js +++ b/src/map/component.js @@ -1,3 +1,4 @@ +Controller.$inject = ['gmfPermalink', 'gmfSnapping', '$injector', '$element']; // The MIT License (MIT) // // Copyright (c) 2014-2024 Camptocamp SA @@ -39,7 +40,6 @@ const myModule = angular.module('gmfMapComponent', [gmfPermalinkModule.name, gmf * * @htmlAttribute {import('ol/Map').default} gmf-map-map The map. * @returns {angular.IDirective} The Directive Definition Object. - * @ngInject * @ngdoc directive * @ngname gmfMap */ @@ -52,7 +52,6 @@ function gmfMapComponent() { bindToController: true, }; } - myModule.directive('gmfMap', gmfMapComponent); /** @@ -62,7 +61,6 @@ myModule.directive('gmfMap', gmfMapComponent); * @param {JQuery} $element * @class * @hidden - * @ngInject * @ngdoc controller * @ngname GmfMapController */ @@ -107,7 +105,5 @@ Controller.prototype.$onInit = function () { // Needed cypress e2e tests window['overlayMgr'] = ngeoMapFeatureOverlayMgr; }; - myModule.controller('GmfMapController', Controller); - export default myModule; diff --git a/src/map/mousepositionComponent.js b/src/map/mousepositionComponent.js index e3fb03a5eaec..e11a2fe7f9a7 100644 --- a/src/map/mousepositionComponent.js +++ b/src/map/mousepositionComponent.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$element', '$filter', '$scope', 'gettextCatalog', 'gmfMousePositionOptions']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -22,7 +23,6 @@ import angular from 'angular'; import ngeoMiscFilters from 'ngeo/misc/filters'; import olControlMousePosition from 'ol/control/MousePosition'; - import 'bootstrap/js/src/dropdown'; /** @@ -30,18 +30,18 @@ import 'bootstrap/js/src/dropdown'; * @hidden */ const myModule = angular.module('gmfMapMouseposition', [ngeoMiscFilters.name]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/map/mousepositionComponent', require('./mousepositionComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/map/mousepositionComponent', require('./mousepositionComponent.html')); + }, + ], ); - myModule.value( 'gmfMapMousepositionTemplateUrl', /** @@ -58,10 +58,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} gmfMapMousepositionTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfMapMousepositionTemplateUrl.$inject = ['$attrs', 'gmfMapMousepositionTemplateUrl']; function gmfMapMousepositionTemplateUrl($attrs, gmfMapMousepositionTemplateUrl) { return gmfMapMousepositionTemplateUrl($attrs); } @@ -87,7 +87,6 @@ const mapMousepositionComponent = { }, templateUrl: gmfMapMousepositionTemplateUrl, }; - myModule.component('gmfMouseposition', mapMousepositionComponent); /** @@ -98,7 +97,6 @@ myModule.component('gmfMouseposition', mapMousepositionComponent); * @param {import('gmf/options').gmfMousePositionOptions} gmfMousePositionOptions The options. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname gmfMousepositionController */ @@ -195,7 +193,6 @@ Controller.prototype.initOlControl_ = function () { args.unshift(coordinates); return filter.apply(this, args); }; - const gettextCatalog = this.gettextCatalog_; this.control_ = new olControlMousePosition({ className: 'gmf-mouseposition-control', @@ -203,9 +200,7 @@ Controller.prototype.initOlControl_ = function () { target: this.$element_.find('.gmf-mouseposition-control-target').get(0), placeholder: gettextCatalog.getString('Coordinates'), }); - this.setProjection(this.projections[0]); - this.map.addControl(this.control_); }; @@ -219,7 +214,5 @@ Controller.prototype.setProjection = function (projection) { this.control_.setProjection(projection.code); this.projection = projection; }; - myModule.controller('gmfMousepositionController', Controller); - export default myModule; diff --git a/src/map/resizemap.js b/src/map/resizemap.js index 8bc9a5542470..b0a012456b74 100644 --- a/src/map/resizemap.js +++ b/src/map/resizemap.js @@ -1,3 +1,4 @@ +mapResizeComponent.$inject = ['$window']; // The MIT License (MIT) // // Copyright (c) 2014-2024 Camptocamp SA @@ -45,13 +46,11 @@ const myModule = angular.module('ngeoResizemap', []); * * @param {angular.IWindowService} $window Angular window service. * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoResizemap */ function mapResizeComponent($window) { const /** @type {number} */ duration = 1000; - return { restrict: 'A', /** @@ -64,7 +63,6 @@ function mapResizeComponent($window) { const prop = attrs[attr]; const map = scope.$eval(prop); console.assert(map instanceof olMap); - const stateExpr = attrs.ngeoResizemapState; console.assert(stateExpr !== undefined); @@ -72,11 +70,9 @@ function mapResizeComponent($window) { let start; /** @type {number} */ let animationDelayKey; - const animationDelay = () => { map.updateSize(); map.renderSync(); - if (Date.now() - start < duration) { animationDelayKey = $window.requestAnimationFrame(animationDelay); } @@ -88,7 +84,6 @@ function mapResizeComponent($window) { map.updateSize(); map.renderSync(); }); - scope.$watch(stateExpr, (newVal, oldVal) => { if (newVal != oldVal) { start = Date.now(); @@ -99,7 +94,5 @@ function mapResizeComponent($window) { }, }; } - myModule.directive('ngeoResizemap', mapResizeComponent); - export default myModule; diff --git a/src/map/scaleselector.js b/src/map/scaleselector.js index 34c85a73fd66..701063bf47a9 100644 --- a/src/map/scaleselector.js +++ b/src/map/scaleselector.js @@ -29,7 +29,6 @@ import 'bootstrap/js/src/dropdown'; * @hidden */ const myModule = angular.module('ngeoScaleselector', []); - myModule.value( 'ngeoScaleselectorTemplateUrl', /** @@ -42,16 +41,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'ngeo/map/scaleselector'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/map/scaleselector', require('./scaleselector.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/map/scaleselector', require('./scaleselector.html')); + }, + ], ); /** @@ -94,7 +94,6 @@ myModule.run( * @param {string|function(JQuery=, angular.IAttributes=): string} ngeoScaleselectorTemplateUrl Template URL * for the directive. * @returns {angular.IDirective} Directive Definition Object. - * @ngInject * @ngdoc directive * @ngname ngeoScaleselector */ @@ -106,7 +105,8 @@ const mapScaleselectorComponent = function (ngeoScaleselectorTemplateUrl) { templateUrl: ngeoScaleselectorTemplateUrl, }; }; - +mapScaleselectorComponent.$inject = ['ngeoScaleselectorTemplateUrl']; +mapScaleselectorComponent.$inject = ['ngeoScaleselectorTemplateUrl']; myModule.directive('ngeoScaleselector', mapScaleselectorComponent); /** @@ -117,7 +117,6 @@ export class ScaleselectorController { * @param {angular.IScope} $scope Directive scope. * @param {angular.IAttributes} $attrs Attributes. * @param {import('ngeo/options').ngeoScaleSelectorOptions} ngeoScaleSelectorOptions The options. - * @ngInject */ constructor($scope, $attrs, ngeoScaleSelectorOptions) { /** @@ -126,14 +125,13 @@ export class ScaleselectorController { * @type {number[]} */ this.scales = ngeoScaleSelectorOptions.values; - const mapExpr = $attrs.ngeoScaleselectorMap; /** * @type {import('ol/Map').default} * @private */ - this.map_ = /** @type {import('ol/Map').default} */ ($scope.$eval(mapExpr)); + this.map_ = /** @type {import('ol/Map').default} */ $scope.$eval(mapExpr); console.assert(this.map_ instanceof olMap); /** @@ -157,14 +155,12 @@ export class ScaleselectorController { * @type {number|undefined} */ this.currentScale = undefined; - const view = this.map_.getView(); // See: https://www.w3.org/TR/CSS21/syndata.html#length-units const dpi = 96; const inchesPerMeter = 39.37; const warningRatio = 1.5; - if (this.scales) { for (let zoom = view.getMinZoom(); zoom <= view.getMaxZoom(); zoom++) { const calculatedScale = Math.round(view.getResolutionForZoom(zoom) * inchesPerMeter * dpi); @@ -190,14 +186,11 @@ export class ScaleselectorController { this.scales[zoom] = Math.round(view.getResolutionForZoom(zoom) * inchesPerMeter * dpi); } } - const currentZoom = this.map_.getView().getZoom(); if (currentZoom !== undefined) { this.currentScale = this.getScale(currentZoom); } - listen(this.map_, 'change:view', this.handleViewChange_, this); - this.registerResolutionChangeListener_(); // @ts-ignore: scope ... @@ -287,7 +280,6 @@ export class ScaleselectorController { this.resolutionChangeKey_ = listen(view, 'change:resolution', this.handleResolutionChange_, this); } } - +ScaleselectorController.$inject = ['$scope', '$attrs', 'ngeoScaleSelectorOptions']; myModule.controller('NgeoScaleselectorController', ScaleselectorController); - export default myModule; diff --git a/src/map/swipe.js b/src/map/swipe.js index 7daee2169eba..cba9fd571828 100644 --- a/src/map/swipe.js +++ b/src/map/swipe.js @@ -23,7 +23,6 @@ import angular from 'angular'; import {listen, unlistenByKey} from 'ol/events'; import RenderEvent from 'ol/render/Event'; import {getRenderPixel} from 'ol/render.js'; - import ResizeObserver from 'resize-observer-polyfill'; import 'jquery-ui/ui/widgets/draggable'; @@ -32,18 +31,18 @@ import 'jquery-ui/ui/widgets/draggable'; * @hidden */ const myModule = angular.module('ngeoMapswipe', []); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/src/map/swipe', require('./swipe.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/src/map/swipe', require('./swipe.html')); + }, + ], ); - myModule.value( 'ngeoMapswipeTemplateUrl', /** @@ -60,10 +59,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} ngeoMapswipeTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +ngeoMapswipeTemplateUrl.$inject = ['$attrs', 'ngeoMapswipeTemplateUrl']; function ngeoMapswipeTemplateUrl($attrs, ngeoMapswipeTemplateUrl) { return ngeoMapswipeTemplateUrl($attrs); } @@ -77,7 +76,6 @@ export class SwipeController { * @param {JQuery} $element Element. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname ngeoMapswipeController */ @@ -127,13 +125,11 @@ export class SwipeController { */ $onInit() { const view = this.map.getView(); - this.swipeValue = this.swipeValue !== undefined ? this.swipeValue : 0.5; this.listenerKeys_.push(listen(this.layer, 'prerender', this.handleLayerPrerender_, this)); this.listenerKeys_.push(listen(this.layer, 'postrender', this.handleLayerPostrender_, this)); this.listenerKeys_.push(listen(this.layer, 'change:visible', this.handleLayerVisibleChange_, this)); this.listenerKeys_.push(listen(view, 'change:rotation', this.handleViewRotationChange_, this)); - const halfDraggableWidth = this.draggableElement_.width() / 2; // When beginning to swipe a layer, reset the view rotation @@ -141,16 +137,13 @@ export class SwipeController { if (rotation) { view.setRotation(0); } - this.draggableElement_.draggable({ axis: 'x', containment: 'parent', drag: () => { const parentWidth = this.draggableElement_.parent().width(); const position = this.draggableElement_.position().left + halfDraggableWidth; - this.swipeValue = position / parentWidth; - this.map.render(); }, }); @@ -183,7 +176,6 @@ export class SwipeController { if (!ctx) { return; } - const width = ctx.canvas.width * this.swipeValue; const height = ctx.canvas.height; if (ctx instanceof CanvasRenderingContext2D) { @@ -259,7 +251,6 @@ export class SwipeController { this.deactivate(); } } - $onDestroy() { this.listenerKeys_.forEach(unlistenByKey); this.listenerKeys_.length = 0; @@ -267,7 +258,7 @@ export class SwipeController { this.resizeObserver_.disconnect(); } } - +SwipeController.$inject = ['$scope', '$element']; myModule.component('ngeoMapswipe', { controller: SwipeController, bindings: { @@ -277,5 +268,4 @@ myModule.component('ngeoMapswipe', { }, templateUrl: ngeoMapswipeTemplateUrl, }); - export default myModule; diff --git a/src/measure/area.js b/src/measure/area.js index 40434461d08f..a3b0d04ae920 100644 --- a/src/measure/area.js +++ b/src/measure/area.js @@ -1,3 +1,4 @@ +measureAreaComponent.$inject = ['$compile', 'gettextCatalog', '$filter', 'ngeoMeasurePrecision']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -38,7 +39,6 @@ const myModule = angular.module('ngeoMeasurearea', [ngeoDrawController.name]); * @param {angular.IFilterService} $filter Angular filter * @param {import('ngeo/options').ngeoMeasurePrecision} ngeoMeasurePrecision The precision. * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoDrawpoint */ @@ -56,7 +56,6 @@ function measureAreaComponent($compile, gettextCatalog, $filter, ngeoMeasurePrec if (!drawFeatureCtrl) { throw new Error('Missing drawFeatureCtrl'); } - const helpMsg = gettextCatalog.getString('Click to start drawing polygon'); const contMsg = gettextCatalog.getString( 'Click to continue drawing
' + 'Double-click or click starting point to finish', @@ -69,16 +68,12 @@ function measureAreaComponent($compile, gettextCatalog, $filter, ngeoMeasurePrec continueMsg: $compile(`
${contMsg}
`)($scope)[0], }; options.precision = ngeoMeasurePrecision; - const measureArea = new ngeoInteractionMeasureArea($filter('ngeoUnitPrefix'), gettextCatalog, options); - if (drawFeatureCtrl.uid) { measureArea.set('ngeo-interaction-draw-uid', `${drawFeatureCtrl.uid}-area`); } - drawFeatureCtrl.registerInteraction(measureArea); drawFeatureCtrl.measureArea = measureArea; - listen( measureArea, 'measureend', @@ -89,7 +84,5 @@ function measureAreaComponent($compile, gettextCatalog, $filter, ngeoMeasurePrec }, }; } - myModule.directive('ngeoMeasurearea', measureAreaComponent); - export default myModule; diff --git a/src/measure/azimut.js b/src/measure/azimut.js index b81b821b1133..612b6231b794 100644 --- a/src/measure/azimut.js +++ b/src/measure/azimut.js @@ -1,3 +1,10 @@ +measureAzimutComponent.$inject = [ + '$compile', + 'gettextCatalog', + '$filter', + 'ngeoMeasurePrecision', + 'ngeoMeasureDecimals', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -42,7 +49,6 @@ const myModule = angular.module('ngeoMeasureazimut', [ngeoDrawController.name, n * @param {import('ngeo/options').ngeoMeasurePrecision} ngeoMeasurePrecision The precision. * @param {import('ngeo/options').ngeoMeasureDecimals} ngeoMeasureDecimals The decimals. * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoDrawpoint */ @@ -66,7 +72,6 @@ function measureAzimutComponent( if (!drawFeatureCtrl) { throw new Error('Missing drawFeatureCtrl'); } - const helpMsg = gettextCatalog.getString('Click to start drawing circle'); const contMsg = gettextCatalog.getString('Click to finish'); @@ -83,14 +88,11 @@ function measureAzimutComponent( $filter('number'), options, ); - if (drawFeatureCtrl.uid) { measureAzimut.set('ngeo-interaction-draw-uid', `${drawFeatureCtrl.uid}-azimut`); } - drawFeatureCtrl.registerInteraction(measureAzimut); drawFeatureCtrl.measureAzimut = measureAzimut; - listen( measureAzimut, 'measureend', @@ -98,35 +100,31 @@ function measureAzimutComponent( * @type {import('ol/events').ListenerFunction} */ (event) => { - const myEvent = /** @type {import('ngeo/interaction/Measure').MeasureEvent} */ (event); + const myEvent = /** @type {import('ngeo/interaction/Measure').MeasureEvent} */ event; // In the case of azimut measure interaction, the feature's // geometry is actually a collection (line + circle) // For our purpose here, we only need the circle, which gets // transformed into a polygon with 64 sides. const geometry = /** @type {import('ol/geom/GeometryCollection').default} */ - (myEvent.detail.feature.getGeometry()); - const circle = /** @type {import('ol/geom/Circle').default} */ (geometry.getGeometries()[1]); + myEvent.detail.feature.getGeometry(); + const circle = /** @type {import('ol/geom/Circle').default} */ geometry.getGeometries()[1]; const polygon = fromCircle( circle, Number.parseInt(attrs.$$element.attr('ngeo-measureazimut-nbpoints') || 64), ); myEvent.detail.feature = new olFeature(polygon); const azimut = getAzimut( - /** @type {import('ol/geom/LineString').default} */ (geometry.getGeometries()[0]), + /** @type {import('ol/geom/LineString').default} */ geometry.getGeometries()[0], ); myEvent.detail.feature.set('azimut', azimut); - drawFeatureCtrl.handleDrawEnd(ngeoGeometryType.CIRCLE, event); }, drawFeatureCtrl, ); - listen(measureAzimut, 'change:active', drawFeatureCtrl.handleActiveChange, drawFeatureCtrl); }, }; } - myModule.directive('ngeoMeasureazimut', measureAzimutComponent); - export default myModule; diff --git a/src/measure/length.js b/src/measure/length.js index 6ed727461b9e..a5fd90b0cd10 100644 --- a/src/measure/length.js +++ b/src/measure/length.js @@ -1,3 +1,11 @@ +measureLengthComponent.$inject = [ + '$compile', + 'gettextCatalog', + '$filter', + '$injector', + 'ngeoMeasurePrecision', + 'ngeoSnappingTolerance', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -41,7 +49,6 @@ const myModule = angular.module('ngeoMeasurelength', [ngeoDrawController.name, n * @param {import('ngeo/options').ngeoMeasurePrecision} ngeoMeasurePrecision The precision. * @param {import('ngeo/options').ngeoSnappingTolerance} ngeoSnappingTolerance The tolerance. * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoDrawpoint */ @@ -66,7 +73,6 @@ function measureLengthComponent( if (!drawFeatureCtrl) { throw new Error('Missing drawFeatureCtrl'); } - const helpMsg = gettextCatalog.getString('Click to start drawing line'); const contMsg = gettextCatalog.getString( 'Click to continue drawing
' + 'Double-click or click last point to finish', @@ -88,14 +94,11 @@ function measureLengthComponent( gettextCatalog, options, ); - if (drawFeatureCtrl.uid) { measureLength.set('ngeo-interaction-draw-uid', `${drawFeatureCtrl.uid}-length`); } - drawFeatureCtrl.registerInteraction(measureLength); drawFeatureCtrl.measureLength = measureLength; - listen( measureLength, 'measureend', @@ -106,7 +109,5 @@ function measureLengthComponent( }, }; } - myModule.directive('ngeoMeasurelength', measureLengthComponent); - export default myModule; diff --git a/src/message/Disclaimer.js b/src/message/Disclaimer.js index 5bd6d4145c47..7a8cb2b1a6d0 100644 --- a/src/message/Disclaimer.js +++ b/src/message/Disclaimer.js @@ -21,7 +21,6 @@ import angular from 'angular'; import 'bootstrap/js/src/alert'; - import ngeoMessagePopup, {MessagePopup} from 'ngeo/message/Popup'; import ngeoMessageMessage, {MessageType} from 'ngeo/message/Message_OLD'; // TODO: Use new ts file when convert done import 'ngeo/sass/font.scss'; @@ -51,7 +50,6 @@ export class MessageDisclaimerService extends ngeoMessageMessage { * @param {angular.ISCEService} $sce Angular sce service. * @param {angular.gettext.gettextCatalog} gettextCatalog Gettext service. * @param {import('ngeo/message/Popup').PopupFactory} ngeoCreatePopup Popup service. - * @ngInject */ constructor($sce, gettextCatalog, ngeoCreatePopup) { super(); @@ -73,7 +71,6 @@ export class MessageDisclaimerService extends ngeoMessageMessage { * @type {import('ngeo/message/Popup').PopupFactory} */ this.createPopup_ = ngeoCreatePopup; - const container = angular.element('
'); angular.element(document.body).append(container); @@ -169,9 +166,7 @@ export class MessageDisclaimerService extends ngeoMessageMessage { // Set the message status as opened once this.validMessages_ = this.validMessages_.filter((msg) => msg !== uid); this.validMessages_.push(uid); - this.uids_[uid] = true; - if (message.popup === true) { // display the message in a popup, i.e. using the ngeo create popup const popup = this.createPopup_(); @@ -188,7 +183,6 @@ export class MessageDisclaimerService extends ngeoMessageMessage { this.closeMessage_(message); } }); - this.messages_[uid] = popup; } else { // get an already displayed compatible message. @@ -217,27 +211,21 @@ export class MessageDisclaimerService extends ngeoMessageMessage { default: break; } - const el = angular.element(``); const button = angular.element( - ``, + ``, ); const msg = angular.element('').html(message.msg); el.append(button).append(msg); // Set the message status as manually closed button.on('click', () => this.closedMessages_.push(uid)); - let container; - if (message.target) { container = angular.element(message.target); } else { container = this.container_; } - container.append(el); el.addClass('show'); @@ -316,7 +304,6 @@ export class MessageDisclaimerService extends ngeoMessageMessage { // the message is still used return; } - const obj = this.messages_[compatibleMessageUid]; // (2) Close message (popup or alert) @@ -332,7 +319,7 @@ export class MessageDisclaimerService extends ngeoMessageMessage { } else if (obj) { // (2.2) Check if the message hasn't been closed using the UI, i.e. by // clicking the close button. If not, then close it. - const jqueryObj = /** @type {JQuery} */ (obj); + const jqueryObj = /** @type {JQuery} */ obj; if (jqueryObj.hasClass('show')) { jqueryObj.alert('close'); } @@ -345,13 +332,11 @@ export class MessageDisclaimerService extends ngeoMessageMessage { delete this.messagesConsumerCount_[compatibleMessageUid]; } } - +MessageDisclaimerService.$inject = ['$sce', 'gettextCatalog', 'ngeoCreatePopup']; /** * @type {angular.IModule} * @hidden */ const myModule = angular.module('ngeoDisclaimer', [ngeoMessagePopup.name]); - myModule.service('ngeoDisclaimer', MessageDisclaimerService); - export default myModule; diff --git a/src/message/Notification_OLD.js b/src/message/Notification_OLD.js index 3ce85091931a..947df2eb89b0 100644 --- a/src/message/Notification_OLD.js +++ b/src/message/Notification_OLD.js @@ -21,7 +21,6 @@ import angular from 'angular'; import 'bootstrap/js/src/alert'; - import ngeoMessageMessage, {MessageType} from 'ngeo/message/Message'; import {getUid as olUtilGetUid} from 'ol/util'; @@ -49,7 +48,6 @@ export class MessageNotification extends ngeoMessageMessage { * properly. * * @param {angular.ITimeoutService} $timeout Angular timeout service. - * @ngInject */ constructor($timeout) { super(); @@ -59,7 +57,6 @@ export class MessageNotification extends ngeoMessageMessage { * @private */ this.timeout_ = $timeout; - const container = angular.element('
'); angular.element(document.body).append(container); @@ -106,7 +103,6 @@ export class MessageNotification extends ngeoMessageMessage { showMessage(message) { const type = message.type; console.assert(typeof type == 'string', 'Type should be set.'); - const classNames = ['alert', 'fade', 'show']; switch (type) { case MessageType.ERROR: // eslint-disable-line @typescript-eslint/no-unsafe-enum-comparison @@ -124,24 +120,19 @@ export class MessageNotification extends ngeoMessageMessage { default: break; } - const el = angular.element(`
`); let container; - if (message.target) { container = angular.element(message.target); } else { container = this.container_; } - container.append(el); el.html(message.msg).addClass('show'); - const delay = message.delay !== undefined ? message.delay : DEFAULT_DELAY; - - const item = /** @type {CacheItem} */ ({ + const item = /** @type {CacheItem} */ { el, - }); + }; // Keep a reference to the promise, in case we want to manually cancel it // before the delay @@ -150,7 +141,6 @@ export class MessageNotification extends ngeoMessageMessage { el.alert('close'); delete this.cache_[uid]; }, delay); - this.cache_[uid] = item; } @@ -176,7 +166,7 @@ export class MessageNotification extends ngeoMessageMessage { delete this.cache_[uid]; } } - +MessageNotification.$inject = ['$timeout']; /** * @typedef {Object} CacheItem * @property {JQuery} el @@ -188,7 +178,5 @@ export class MessageNotification extends ngeoMessageMessage { * @hidden */ const myModule = angular.module('ngeoNotification', []); - myModule.service('ngeoNotification', MessageNotification); - export default myModule; diff --git a/src/message/Popup.js b/src/message/Popup.js index c64d12d760f9..83181152191b 100644 --- a/src/message/Popup.js +++ b/src/message/Popup.js @@ -1,3 +1,4 @@ +Factory.$inject = ['$compile', '$rootScope', '$sce', '$timeout']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -232,27 +233,21 @@ MessagePopup.prototype.open = function (options) { } else { console.assert(false, 'ngeo.message.Popup options requirest "url" or "content".'); } - if (options.autoDestroy !== undefined) { this.setAutoDestroy(options.autoDestroy); } - if (options.cls !== undefined) { this.addClass(options.cls); } - if (options.height !== undefined) { this.setHeight(options.height); } - if (options.title !== undefined) { this.setTitle(options.title); } - if (options.width !== undefined) { this.setWidth(options.width); } - this.setOpen(true); }; @@ -262,7 +257,6 @@ MessagePopup.prototype.open = function (options) { * @param {angular.ISCEService} $sce Angular sce service. * @param {angular.ITimeoutService} $timeout Angular timeout service. * @returns {PopupFactory} The function to create a popup. - * @ngInject * @hidden */ export function Factory($compile, $rootScope, $sce, $timeout) { @@ -282,5 +276,4 @@ export function Factory($compile, $rootScope, $sce, $timeout) { */ const myModule = angular.module('ngeoCreatePopup', [ngeoMessagePopupComponent.name]); myModule.factory('ngeoCreatePopup', Factory); - export default myModule; diff --git a/src/message/displaywindowComponent.js b/src/message/displaywindowComponent.js index d7178ff68499..e730c083a7ac 100644 --- a/src/message/displaywindowComponent.js +++ b/src/message/displaywindowComponent.js @@ -20,7 +20,6 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - import 'ngeo/sass/font.scss'; import 'jquery-ui/ui/widgets/resizable'; import 'jquery-ui/ui/widgets/draggable'; @@ -32,18 +31,18 @@ import 'angular-sanitize'; * @hidden */ const myModule = angular.module('ngeoMessageDisplaywindowComponent', ['ngSanitize']); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/message/displaywindowComponent', require('./displaywindowComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/message/displaywindowComponent', require('./displaywindowComponent.html')); + }, + ], ); - myModule.value( 'ngeoMessageDisplaywindowTemplateUrl', /** @@ -60,10 +59,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} ngeoMessageDisplaywindowTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +ngeoMessageDisplaywindowTemplateUrl.$inject = ['$attrs', 'ngeoMessageDisplaywindowTemplateUrl']; function ngeoMessageDisplaywindowTemplateUrl($attrs, ngeoMessageDisplaywindowTemplateUrl) { return ngeoMessageDisplaywindowTemplateUrl($attrs); } @@ -77,7 +76,6 @@ export class Controller { * @param {angular.ISCEService} $sce Angular sce service. * @param {angular.IScope} $scope Scope. * @param {angular.ICompileService} $compile The compile provider. - * @ngInject * @ngdoc controller * @ngname ngeoDisplaywindowComponentController */ @@ -195,7 +193,6 @@ export class Controller { * @type {Element} */ this.containingElement = null; - if (typeof this.draggableContainment === 'string') { if (this.draggableContainment !== 'document') { let className = String(this.draggableContainment); @@ -209,7 +206,6 @@ export class Controller { } else { this.containingElement = this.draggableContainment; } - this.draggable = this.draggable !== undefined ? this.draggable : this.desktop; this.resizable = this.resizable !== undefined ? this.resizable : this.desktop; @@ -232,11 +228,9 @@ export class Controller { }, }); } - if (this.contentTemplate) { this.updateContentTemplate_(); } - this.scope_.$watch( () => this.contentTemplate, () => this.updateContentTemplate_(), @@ -256,7 +250,7 @@ export class Controller { '.ngeo-displaywindow .windowcontainer .animation-container .content-template-container', ); displayWindow.empty(); - displayWindow.append(/** @type {?} */ (compiled)); + displayWindow.append(/** @type {?} */ compiled); } /** @@ -287,7 +281,7 @@ export class Controller { */ get urlTrusted() { if (this.url) { - return /** @type {string} */ (this.sce_.trustAsResourceUrl(this.url)); + return /** @type {string} */ this.sce_.trustAsResourceUrl(this.url); } return undefined; } @@ -300,7 +294,7 @@ export class Controller { this.url = null; } } - +Controller.$inject = ['$element', '$sce', '$scope', '$compile']; /** * The `ngeo-displaywindow` component is an alternative to the `ngeo.message.Popup`. * What they have in common: @@ -367,5 +361,4 @@ const ngeoMessageDisplaywindowComponent = { templateUrl: ngeoMessageDisplaywindowTemplateUrl, }; myModule.component('ngeoDisplaywindow', ngeoMessageDisplaywindowComponent); - export default myModule; diff --git a/src/message/modalComponent.js b/src/message/modalComponent.js index 480c2ccc59c1..4d384c61e04d 100644 --- a/src/message/modalComponent.js +++ b/src/message/modalComponent.js @@ -86,7 +86,6 @@ const messageModalComponent = { 'closable': ' { if (!this.ngModel) { throw new Error('Missing model'); @@ -184,7 +174,6 @@ export class Controller { this.ngModel.$setViewValue(type == 'shown'); }); } - $onDestroy() { if (!this.modal_) { throw new Error('Missing modal'); @@ -199,7 +188,6 @@ export class Controller { } } } - +Controller.$inject = ['$scope', '$element']; myModule.controller('ngeoModalController', Controller); - export default myModule; diff --git a/src/message/popoverComponent.js b/src/message/popoverComponent.js index 631717c28874..f7190bdfb23f 100644 --- a/src/message/popoverComponent.js +++ b/src/message/popoverComponent.js @@ -1,3 +1,4 @@ +PopoverController.$inject = ['$scope']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -44,7 +45,6 @@ const myModule = angular.module('ngeoPopover', []); * * * @ngdoc directive - * @ngInject * @ngname ngeoPopover * @returns {angular.IDirective} The Directive Definition Object. */ @@ -57,12 +57,10 @@ function messagePopoverComponent() { if (!ngeoPopoverCtrl) { throw new Error('Missing ngeoPopoverCtrl'); } - ngeoPopoverCtrl.anchorElm.on('inserted.bs.popover', () => { ngeoPopoverCtrl.bodyElm.show(); ngeoPopoverCtrl.shown = true; }); - ngeoPopoverCtrl.anchorElm.popover({ container: 'body', html: true, @@ -70,13 +68,11 @@ function messagePopoverComponent() { boundary: 'viewport', placement: attrs['ngeoPopoverPlacement'] || 'right', }); - if (attrs['ngeoPopoverDismiss']) { $(attrs['ngeoPopoverDismiss']).on('scroll', () => { ngeoPopoverCtrl.dismissPopover(); }); } - scope.$on('$destroy', () => { ngeoPopoverCtrl.anchorElm.popover('dispose'); ngeoPopoverCtrl.anchorElm.unbind('inserted.bs.popover'); @@ -88,7 +84,6 @@ function messagePopoverComponent() { /** * @ngdoc directive - * @ngInject * @ngname ngeoPopoverAnchor * @returns {angular.IDirective} The Directive Definition Object */ @@ -107,7 +102,6 @@ function messagePopoverAnchorComponent() { /** * @ngdoc directive - * @ngInject * @ngname ngeoPopoverContent * @returns {angular.IDirective} The Directive Definition Object */ @@ -129,7 +123,6 @@ function messagePopoverContentComponent() { * The controller for the 'popover' directive. * * @class - * @ngInject * @ngdoc controller * @ngname NgeoPopoverController * @param {angular.IScope} $scope Scope. @@ -172,9 +165,7 @@ export function PopoverController($scope) { this.dismissPopover(); } }; - document.body.addEventListener('click', clickHandler); - $scope.$on('$destroy', () => { document.body.removeEventListener('click', clickHandler); }); @@ -190,10 +181,8 @@ PopoverController.prototype.dismissPopover = function () { this.shown = false; this.anchorElm.popover('hide'); }; - myModule.controller('NgeoPopoverController', PopoverController); myModule.directive('ngeoPopover', messagePopoverComponent); myModule.directive('ngeoPopoverAnchor', messagePopoverAnchorComponent); myModule.directive('ngeoPopoverContent', messagePopoverContentComponent); - export default myModule; diff --git a/src/message/popupComponent.js b/src/message/popupComponent.js index dafc19972b3f..e94a349acb71 100644 --- a/src/message/popupComponent.js +++ b/src/message/popupComponent.js @@ -1,3 +1,4 @@ +messagePopopComponent.$inject = ['ngeoPopupTemplateUrl']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -27,7 +28,6 @@ import 'angular-sanitize'; * @hidden */ const myModule = angular.module('ngeoPopup', ['ngSanitize']); - myModule.value( 'ngeoPopupTemplateUrl', /** @@ -40,16 +40,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'ngeo/message/popupcomponent'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/message/popupcomponent', require('./popupcomponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/message/popupcomponent', require('./popupcomponent.html')); + }, + ], ); /** @@ -69,7 +70,6 @@ myModule.run( * * @param {string} ngeoPopupTemplateUrl URL to popup template. * @returns {angular.IDirective} Directive Definition Object. - * @ngInject * @ngdoc directive * @ngname ngeoPopup */ @@ -104,7 +104,5 @@ function messagePopopComponent(ngeoPopupTemplateUrl) { }, }; } - myModule.directive('ngeoPopup', messagePopopComponent); - export default myModule; diff --git a/src/misc/EventHelper.js b/src/misc/EventHelper.js index 095fff5844bd..0861710ca629 100644 --- a/src/misc/EventHelper.js +++ b/src/misc/EventHelper.js @@ -28,7 +28,6 @@ import {unlistenByKey} from 'ol/events'; * @class * @ngdoc service * @ngname ngeoEventHelper - * @ngInject * @hidden */ export function EventHelper() { @@ -49,7 +48,7 @@ EventHelper.prototype.addListenerKey = function (uid, key) { if (!this.listenerKeys_[uid]) { this.initListenerKey_(uid); } - this.listenerKeys_[uid].push(/** @type {import('ol/events').EventsKey} */ (key)); + this.listenerKeys_[uid].push(/** @type {import('ol/events').EventsKey} */ key); }; /** @@ -87,5 +86,4 @@ EventHelper.prototype.initListenerKey_ = function (uid) { */ const myModule = angular.module('ngeoEventHelper', []); myModule.service('ngeoEventHelper', EventHelper); - export default myModule; diff --git a/src/misc/FeatureHelper.js b/src/misc/FeatureHelper.js index 9feea0c016a0..b1e3c69efabc 100644 --- a/src/misc/FeatureHelper.js +++ b/src/misc/FeatureHelper.js @@ -1,3 +1,10 @@ +FeatureHelper.$inject = [ + '$filter', + 'ngeoMeasurePrecision', + 'ngeoMeasureDecimals', + 'ngeoMeasureSpherical', + 'ngeoPointfilter', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -21,9 +28,7 @@ import angular from 'angular'; import ngeoMiscFilters from 'ngeo/misc/filters'; - import gmfDownloadService from 'ngeo/download/service'; - import ngeoFormatFeatureProperties from 'ngeo/format/FeatureProperties'; import ngeoGeometryType from 'ngeo/GeometryType'; import {getFormattedLength, getFormattedArea, getFormattedPoint} from 'ngeo/interaction/Measure'; @@ -131,7 +136,6 @@ export const ArrowPositions = { * @param {import('ngeo/options').ngeoPointfilter} ngeoPointfilter the point filter. * @ngdoc service * @ngname ngeoFeatureHelper - * @ngInject * @hidden */ export function FeatureHelper( @@ -164,19 +168,19 @@ export function FeatureHelper( /** * @type {import('ngeo/misc/filters').formatNumber} */ - this.numberFormat_ = /** @type {import('ngeo/misc/filters').formatNumber} */ ($filter('number')); + this.numberFormat_ = /** @type {import('ngeo/misc/filters').formatNumber} */ $filter('number'); /** * @type {import('ngeo/misc/filters').unitPrefix} */ - this.unitPrefixFormat_ = /** @type {import('ngeo/misc/filters').unitPrefix} */ ($filter('ngeoUnitPrefix')); + this.unitPrefixFormat_ = /** @type {import('ngeo/misc/filters').unitPrefix} */ $filter('ngeoUnitPrefix'); /** * @type {import('ngeo/misc/filters').numberCoordinates} */ - this.ngeoNumberCoordinates_ = /** @type {import('ngeo/misc/filters').numberCoordinates} */ ( - $filter('ngeoNumberCoordinates') - ); + this.ngeoNumberCoordinates_ = + /** @type {import('ngeo/misc/filters').numberCoordinates} */ + $filter('ngeoNumberCoordinates'); /** * Filter function to display point coordinates or null to don't use any filter. @@ -191,7 +195,6 @@ export function FeatureHelper( * @type {*[]} */ this.pointFilterArgs_ = []; - if (ngeoPointfilter) { const filterElements = ngeoPointfilter.split(':'); const filterName = filterElements.shift(); @@ -247,10 +250,9 @@ FeatureHelper.prototype.setStyle = function (feature, opt_select) { FeatureHelper.prototype.getStyle = function (feature) { const type = this.getType(feature); let style; - switch (type) { case ngeoGeometryType.LINE_STRING: - style = this.getLineStringStyle_(/** @type {olFeature} */ (feature)); + style = this.getLineStringStyle_(/** @type {olFeature} */ feature); break; case ngeoGeometryType.POINT: style = this.getPointStyle_(feature); @@ -266,7 +268,6 @@ FeatureHelper.prototype.getStyle = function (feature) { default: break; } - if (!style) { throw new Error('Missing style'); } @@ -278,7 +279,6 @@ FeatureHelper.prototype.getStyle = function (feature) { } else { styles = [style]; } - return styles; }; @@ -293,7 +293,6 @@ FeatureHelper.prototype.getLineStringStyle_ = function (feature) { const color = this.getRGBAColorProperty(feature); const arrowDirection = this.getArrowDirectionProperty(feature); const arrowPosition = this.getArrowPositionProperty(feature); - const styles = [ new olStyleStyle({ stroke: new olStyleStroke({ @@ -372,7 +371,8 @@ FeatureHelper.prototype.getArrowLineStyles_ = function (feature, arrowDirection, width: 1, color: color, }), - text: '\uf054', // Arrow symbol (chevron-right). + text: '\uf054', + // Arrow symbol (chevron-right). rotateWithView: true, rotation: invert ? Math.PI - rotation : -rotation, }), @@ -419,7 +419,6 @@ FeatureHelper.prototype.getArrowLineStyles_ = function (feature, arrowDirection, if (firstOrLastSegment) { addArrowToSegment(firstOrLastSegment[0], firstOrLastSegment[1]); } - return arrowStyles; }; @@ -521,9 +520,7 @@ FeatureHelper.prototype.getPolygonStyle_ = function (feature) { // fill color with opacity const fillColor = color.slice(); fillColor[3] = opacity; - const azimut = this.optNumber(feature, ngeoFormatFeatureProperties.AZIMUT); - const styles = [ new olStyleStyle({ fill: new olStyleFill({ @@ -543,7 +540,6 @@ FeatureHelper.prototype.getPolygonStyle_ = function (feature) { // Radius style: const line = this.getRadiusLine(feature, azimut); const length = getFormattedLength(line, this.projection_, this.precision_, this.unitPrefixFormat_); - styles.push( new olStyleStyle({ geometry: line, @@ -649,13 +645,11 @@ FeatureHelper.prototype.createEditingStyles = function (feature) { const blue = [0, 153, 255, 1]; const width = 3; const styles = []; - const geom = feature.getGeometry(); if (!geom) { throw new Error('Missing geom'); } const type = geom.getType(); - if (type === 'Point') { styles.push( new olStyleStyle({ @@ -707,7 +701,6 @@ FeatureHelper.prototype.createEditingStyles = function (feature) { // (2) Anything else than 'Point' requires the vertex style as well styles.push(this.getVertexStyle(true)); } - return styles; }; @@ -734,14 +727,12 @@ FeatureHelper.prototype.createEditingStyles = function (feature) { */ FeatureHelper.prototype.getVertexInfoAtCoordinate = function (feature, coordinate, resolution) { let info = null; - if (this.supportsVertexRemoval_(feature)) { const buffer = resolution * VertexStyleRegularShapeRadius; let coordinates = null; let coordinates2 = null; let coordinates3 = null; let minNumCoordinates = -1; - const geometry = feature.getGeometry(); if (geometry instanceof olGeomLineString) { coordinates = geometry.getCoordinates(); @@ -756,7 +747,6 @@ FeatureHelper.prototype.getVertexInfoAtCoordinate = function (feature, coordinat coordinates3 = geometry.getCoordinates(); minNumCoordinates = 4; } - if (coordinates) { // Array of ol.Coordinate - 1 index const index = this.getCoordinateIndexThatHitsAt_(coordinates, coordinate, minNumCoordinates, buffer); @@ -802,7 +792,6 @@ FeatureHelper.prototype.getVertexInfoAtCoordinate = function (feature, coordinat } } } - return info; }; @@ -823,7 +812,6 @@ FeatureHelper.prototype.getVertexInfoAtCoordinate = function (feature, coordinat FeatureHelper.prototype.getCoordinateIndexThatHitsAt_ = function (coordinates, coordinate, min, buffer) { let index = -1; const ii = coordinates.length; - if (ii > min) { for (let i = 0; i < ii; i++) { const hits = olExtent.containsCoordinate( @@ -836,7 +824,6 @@ FeatureHelper.prototype.getCoordinateIndexThatHitsAt_ = function (coordinates, c } } } - return index; }; @@ -868,7 +855,6 @@ FeatureHelper.prototype.getVertexStyle = function (opt_incGeomFunc) { }), }), }; - if (incGeomFunc) { options.geometry = function (feature) { const geom = feature.getGeometry(); @@ -878,7 +864,6 @@ FeatureHelper.prototype.getVertexStyle = function (opt_incGeomFunc) { if (geom.getType() == 'Point') { return; } - let innerMultiCoordinates; /** @type {number[][][]} */ let multiCoordinates = []; @@ -893,7 +878,6 @@ FeatureHelper.prototype.getVertexStyle = function (opt_incGeomFunc) { } else if (geom instanceof olGeomMultiPolygon) { innerMultiCoordinates = geom.getCoordinates(); } - if (innerMultiCoordinates) { for (let i = 0, ii = innerMultiCoordinates.length; i < ii; i++) { multiCoordinates = multiCoordinates.concat(innerMultiCoordinates[i]); @@ -902,7 +886,6 @@ FeatureHelper.prototype.getVertexStyle = function (opt_incGeomFunc) { for (let i = 0, ii = multiCoordinates.length; i < ii; i++) { coordinates = coordinates.concat(multiCoordinates[i]); } - if (coordinates.length) { return new olGeomMultiPoint(coordinates); } else { @@ -910,7 +893,6 @@ FeatureHelper.prototype.getVertexStyle = function (opt_incGeomFunc) { } }; } - return new olStyleStyle(options); }; @@ -923,12 +905,10 @@ FeatureHelper.prototype.getVertexStyle = function (opt_incGeomFunc) { */ FeatureHelper.prototype.removeVertex = function (feature, vertexInfo) { let deleted = false; - const geometry = feature.getGeometry(); if (!(geometry instanceof olGeomSimpleGeometry)) { throw new Error('Wrong geometry type'); } - if (geometry instanceof olGeomLineString) { // LineString const coordinates = geometry.getCoordinates(); @@ -937,7 +917,6 @@ FeatureHelper.prototype.removeVertex = function (feature, vertexInfo) { coordinates.splice(index, 1); deleted = true; } - if (deleted) { geometry.setCoordinates(coordinates); } @@ -956,7 +935,6 @@ FeatureHelper.prototype.removeVertex = function (feature, vertexInfo) { component.push(component[0]); } } - if (deleted) { geometry.setCoordinates(coordinates); } @@ -970,7 +948,6 @@ FeatureHelper.prototype.removeVertex = function (feature, vertexInfo) { component.splice(indexTwo, 1); deleted = true; } - if (deleted) { geometry.setCoordinates(coordinates); } @@ -990,7 +967,6 @@ FeatureHelper.prototype.removeVertex = function (feature, vertexInfo) { component.push(component[0]); } } - if (deleted) { geometry.setCoordinates(coordinates); } @@ -1037,7 +1013,6 @@ FeatureHelper.prototype.getHaloStyle_ = function (feature) { const type = this.getType(feature); let style; const haloSize = 3; - switch (type) { case ngeoGeometryType.POINT: const size = this.getSizeProperty(feature); @@ -1078,7 +1053,6 @@ FeatureHelper.prototype.getHaloStyle_ = function (feature) { default: break; } - if (!style) { throw new Error('Missing style'); } @@ -1118,7 +1092,7 @@ export function getFilteredFeatureValues(feature) { * @returns {number} Angle. */ FeatureHelper.prototype.getAngleProperty = function (feature) { - const angle = +(/** @type {string} */ (feature.get(ngeoFormatFeatureProperties.ANGLE))); + const angle = +(/** @type {string} */ feature.get(ngeoFormatFeatureProperties.ANGLE)); console.assert(typeof angle == 'number'); return angle; }; @@ -1272,7 +1246,7 @@ FeatureHelper.prototype.exportGPX = function (features) { const mimeType = 'application/gpx+xml'; const fileName = 'export.gpx'; // Typecast due OL issue ... - this.export_(features, /** @type {import('ol/format/Feature').default} */ (format), fileName, mimeType); + this.export_(features, /** @type {import('ol/format/Feature').default} */ format, fileName, mimeType); }; /** @@ -1286,7 +1260,7 @@ FeatureHelper.prototype.exportKML = function (features) { const mimeType = 'application/vnd.google-earth.kml+xml'; const fileName = 'export.kml'; // Typecast due OL issue ... - this.export_(features, /** @type {import('ol/format/Feature').default} */ (format), fileName, mimeType); + this.export_(features, /** @type {import('ol/format/Feature').default} */ format, fileName, mimeType); }; /** @@ -1312,14 +1286,12 @@ FeatureHelper.prototype.export_ = function (features, format, fileName, opt_mime this.setStyle(clone, false); clones.push(clone); }); - const writeOptions = this.projection_ ? { dataProjection: 'EPSG:4326', featureProjection: this.projection_, } : {}; - const data = format.writeFeatures(clones, writeOptions); if (typeof data == 'string') { gmfDownloadService(data, fileName, `${mimeType};charset=utf-8`); @@ -1343,22 +1315,19 @@ FeatureHelper.prototype.createTextStyle_ = function (options) { text_options.rotation = rotation; delete options.angle; } - text_options.overflow = true; - text_options.font = ['normal', `${options.size || 10}pt`, 'Arial'].join(' '); - if (options.color) { - text_options.fill = new olStyleFill({color: options.color || [0, 0, 0, 1]}); + text_options.fill = new olStyleFill({ + color: options.color || [0, 0, 0, 1], + }); delete options.color; } - text_options.stroke = new olStyleStroke({ color: [255, 255, 255, 1], width: options.width || 3, }); delete options.width; - return new olStyleText(text_options); }; @@ -1374,14 +1343,11 @@ FeatureHelper.prototype.getMeasure = function (feature) { if (!this.projection_) { throw new Error('Missing projection'); } - const geometry = feature.getGeometry(); if (!geometry) { throw new Error('Missing geometry'); } - let measure = ''; - if (geometry instanceof olGeomPolygon) { if (this.getType(feature) === ngeoGeometryType.CIRCLE) { const azimut = this.optNumber(feature, ngeoFormatFeatureProperties.AZIMUT); @@ -1389,7 +1355,6 @@ FeatureHelper.prototype.getMeasure = function (feature) { throw new Error('Missing azimut'); } const line = this.getRadiusLine(feature, azimut); - measure = getFormattedAzimutRadius( line, this.projection_, @@ -1429,7 +1394,6 @@ FeatureHelper.prototype.getMeasure = function (feature) { } } } - return measure; }; @@ -1443,9 +1407,7 @@ FeatureHelper.prototype.getMeasure = function (feature) { FeatureHelper.prototype.getType = function (feature) { const geometry = feature.getGeometry(); console.assert(geometry, 'Geometry should be thruthy'); - let type; - if (geometry instanceof olGeomPoint) { if (feature.get(ngeoFormatFeatureProperties.IS_TEXT)) { type = ngeoGeometryType.TEXT; @@ -1469,7 +1431,6 @@ FeatureHelper.prototype.getType = function (feature) { } else if (geometry instanceof olGeomMultiLineString) { type = ngeoGeometryType.MULTI_LINE_STRING; } - if (!type) { throw new Error('Missing type'); } @@ -1504,16 +1465,12 @@ FeatureHelper.prototype.fitMapToFeature = function (feature, map, opt_duration) if (!geometry) { throw new Error('Missing geometry'); } - const geomIsVisible = geometry.intersectsExtent(viewExtent); - const mapCenter = view.getCenter(); if (!Array.isArray(mapCenter)) { throw new Error('Missing mapCenter'); } - const featureExtent = geometry.getExtent(); - if (geomIsVisible) { if (!(geometry instanceof olGeomPoint)) { // == Action: Zoom out == @@ -1548,7 +1505,6 @@ FeatureHelper.prototype.fitMapToFeature = function (feature, map, opt_duration) const viewExtentHeight = olExtent.getHeight(viewExtent); const viewExtentWidth = olExtent.getWidth(viewExtent); const geomFitsInExtent = viewExtentHeight >= featureExtentHeight && viewExtentWidth >= featureExtentWidth; - if (geomFitsInExtent) { // == Action: Pan == // if geometry is not visible but fits in current map extent @@ -1562,7 +1518,6 @@ FeatureHelper.prototype.fitMapToFeature = function (feature, map, opt_duration) } else { featureCenter = olExtent.getCenter(geometry.getExtent()); } - view.animate( { center: mapCenter, @@ -1600,9 +1555,7 @@ FeatureHelper.prototype.getRadiusLine = function (feature, azimut) { // Determine the radius for the circle const extent = geometry.getExtent(); const radius = (extent[3] - extent[1]) / 2; - const center = olExtent.getCenter(geometry.getExtent()); - const x = Math.cos(((azimut - 90) * Math.PI) / 180) * radius; const y = -Math.sin(((azimut - 90) * Math.PI) / 180) * radius; const endPoint = [x + center[0], y + center[1]]; @@ -1665,5 +1618,4 @@ FeatureHelper.prototype.findFeatureIndexByFid = function (features, fid) { */ const myModule = angular.module('ngeoFeatureHelper', [ngeoMiscFilters.name]); myModule.service('ngeoFeatureHelper', FeatureHelper); - export default myModule; diff --git a/src/misc/File.js b/src/misc/File.js index e4d547e6fc86..6015f9afce38 100644 --- a/src/misc/File.js +++ b/src/misc/File.js @@ -1,3 +1,4 @@ +FileService.$inject = ['$q', '$http', 'gettext']; // The MIT License (MIT) // // Copyright (c) 2017-2024 Camptocamp SA @@ -26,7 +27,6 @@ import angular from 'angular'; * @param {angular.IQService} $q . * @param {angular.IHttpService} $http . * @param {angular.gettext.gettextFunction} gettext . - * @ngInject * @hidden */ export function FileService($q, $http, gettext) { @@ -153,7 +153,5 @@ export function FileService($q, $http, gettext) { * @hidden */ const myModule = angular.module('ngeoFile', []); - myModule.service('ngeoFile', FileService); - export default myModule; diff --git a/src/misc/Time.js b/src/misc/Time.js index 23e9c730b6d8..ef24d19499a5 100644 --- a/src/misc/Time.js +++ b/src/misc/Time.js @@ -25,7 +25,6 @@ import angular from 'angular'; * ngeo - Time service * * @class - * @ngInject * @ngdoc service * @ngname ngeoTime * @hidden @@ -63,7 +62,6 @@ Time.prototype.getTime = function (date, defaultValue = null) { Time.prototype.getOptions = function (time) { const minDate = this.createDate(time.minValue); const maxDate = this.createDate(time.maxValue); - const minDefaultDate = this.createDate(time.minDefValue, minDate); const maxDefaultDate = this.createDate(time.maxDefValue, maxDate); if (!minDefaultDate) { @@ -72,10 +70,8 @@ Time.prototype.getOptions = function (time) { if (!maxDefaultDate) { throw new Error('Missing maxDefaultDate'); } - const minTime = this.getTime(minDate); const maxTime = this.getTime(maxDate); - const minDefaultTime = this.getTime(minDefaultDate); const maxDefaultTime = this.getTime(maxDefaultDate); if (!minDefaultTime) { @@ -89,7 +85,6 @@ Time.prototype.getOptions = function (time) { } defaultValues = [minDefaultTime, maxDefaultTime]; } - return { minDate: minTime, maxDate: maxTime, @@ -113,5 +108,4 @@ Time.prototype.getUTCDate = function (localDate) { */ const myModule = angular.module('ngeoTime', []); myModule.service('ngeoTime', Time); - export default myModule; diff --git a/src/misc/ToolActivateMgr.js b/src/misc/ToolActivateMgr.js index ba102c800f81..1b400e3eca3c 100644 --- a/src/misc/ToolActivateMgr.js +++ b/src/misc/ToolActivateMgr.js @@ -1,3 +1,4 @@ +ToolActivateMgr.$inject = ['$rootScope']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -55,7 +56,6 @@ import angular from 'angular'; * @class * @ngdoc service * @ngname ngeoToolActivateMgr - * @ngInject * @hidden */ export function ToolActivateMgr($rootScope) { @@ -84,7 +84,6 @@ ToolActivateMgr.prototype.registerTool = function (groupName, tool, opt_defaultA if (!this.groups_[groupName]) { this.groups_[groupName] = []; } - const unlisten = this.scope_.$watch(tool.getActive, (newVal, oldVal) => { if (newVal === oldVal) { return; @@ -95,7 +94,6 @@ ToolActivateMgr.prototype.registerTool = function (groupName, tool, opt_defaultA this.activateDefault_(groupName); } }); - this.groups_[groupName].push({ tool: tool, defaultTool: opt_defaultActivate || false, @@ -179,15 +177,12 @@ ToolActivateMgr.prototype.activateDefault_ = function (groupName) { const entries = this.groups_[groupName]; let defaultTool = null; let hasActiveTool = false; - for (const entry of entries) { hasActiveTool = hasActiveTool || entry.tool.getActive(); - if (entry.defaultTool) { defaultTool = entry.tool; } } - if (!hasActiveTool && defaultTool !== null) { defaultTool.setActive(true); } @@ -199,5 +194,4 @@ ToolActivateMgr.prototype.activateDefault_ = function (groupName) { */ const myModule = angular.module('ngeoToolActivateMgr', []); myModule.service('ngeoToolActivateMgr', ToolActivateMgr); - export default myModule; diff --git a/src/misc/WMSTime.js b/src/misc/WMSTime.js index 0ed1bf64c0f3..21ca6a0830e0 100644 --- a/src/misc/WMSTime.js +++ b/src/misc/WMSTime.js @@ -33,7 +33,6 @@ export class WMSTime extends Time { /** * @param {angular.IFilterService} $filter angular filter service. * @param {angular.gettext.gettextCatalog} gettextCatalog service. - * @ngInject */ constructor($filter, gettextCatalog) { super(); @@ -81,7 +80,6 @@ export class WMSTime extends Time { dayResolution = gettextCatalog.getString('M/d/yyyy'); secondResolution = gettextCatalog.getString('M/d/yyyy HH:MM:ss'); } - switch (resolution) { case 'year': return this.$filter_('date')(date, yearResolution, utc); @@ -114,23 +112,17 @@ export class WMSTime extends Time { console.assert(wmsTimeProperty.resolution !== undefined); if (wmsTimeProperty.mode === 'range') { console.assert(times.end !== undefined); - return `${this.formatTimeValue( - times.start, - wmsTimeProperty.resolution, - true, - opt_toUTC, - )}/${this.formatTimeValue(times.end, wmsTimeProperty.resolution, true, opt_toUTC)}`; + return `${this.formatTimeValue(times.start, wmsTimeProperty.resolution, true, opt_toUTC)}/${this.formatTimeValue(times.end, wmsTimeProperty.resolution, true, opt_toUTC)}`; } else { return this.formatTimeValue(times.start, wmsTimeProperty.resolution, true, opt_toUTC); } } } - +WMSTime.$inject = ['$filter', 'gettextCatalog']; /** * @type {angular.IModule} * @hidden */ const myModule = angular.module('ngeoWMSTime', [ngeoMiscTime.name]); myModule.service('ngeoWMSTime', WMSTime); - export default myModule; diff --git a/src/misc/btnComponent.js b/src/misc/btnComponent.js index 1cc6a0bfeb01..f191b5ff532d 100644 --- a/src/misc/btnComponent.js +++ b/src/misc/btnComponent.js @@ -1,3 +1,5 @@ +buttonComponent.$inject = ['$parse']; +buttonGroupComponent.$inject = ['$parse']; // The MIT License (MIT) // // Copyright (c) 2014-2024 Camptocamp SA @@ -56,7 +58,6 @@ const myModule = angular.module('ngeoBtnComponent', []); * Tells whether at least one button of the group is active. * @param {angular.IParseService} $parse Angular parse service. * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoBtnGroup */ @@ -75,7 +76,6 @@ function buttonGroupComponent($parse) { throw new Error('Missing controller'); } const setActive = $parse(attrs.ngeoBtnGroupActive).assign; - if (setActive) { scope.$watch( // return true if at least one button is active otherwise false @@ -95,7 +95,6 @@ function buttonGroupComponent($parse) { }, }; } - myModule.directive('ngeoBtnGroup', buttonGroupComponent); /** @@ -105,7 +104,6 @@ myModule.directive('ngeoBtnGroup', buttonGroupComponent); export class BtnGroupController { /** * @param {angular.IScope} $scope Scope. - * @ngInject * @hidden */ constructor($scope) { @@ -142,7 +140,7 @@ export class BtnGroupController { return this.buttons_.length - 1; } } - +BtnGroupController.$inject = ['$scope']; myModule.controller('ngeoBtnGroupController', BtnGroupController); /** @@ -159,7 +157,6 @@ myModule.controller('ngeoBtnGroupController', BtnGroupController); * @htmlAttribute {*} ng-model Any property on the scope. Ideally a boolean. * @param {angular.IParseService} $parse Angular parse service. * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoBtn */ @@ -180,7 +177,6 @@ function buttonComponent($parse) { const buttonsCtrl = ctrls[0]; const ngModelCtrl = ctrls[1]; let indexInGroup = -1; - const ngModelGet = $parse(attrs.ngModel); const ngModelSet = ngModelGet.assign; @@ -210,7 +206,5 @@ function buttonComponent($parse) { }, }; } - myModule.directive('ngeoBtn', buttonComponent); - export default myModule; diff --git a/src/misc/colorpickerComponent.js b/src/misc/colorpickerComponent.js index dd3e777a4923..998d2517b4b0 100644 --- a/src/misc/colorpickerComponent.js +++ b/src/misc/colorpickerComponent.js @@ -1,3 +1,4 @@ +colorPickerComponent.$inject = ['ngeoColorpickerTemplateUrl']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -26,7 +27,6 @@ import angular from 'angular'; * @hidden */ const myModule = angular.module('ngeoColorpicker', []); - myModule.value( 'ngeoColorpickerTemplateUrl', /** @@ -39,16 +39,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'ngeo/misc/colorpickerComponent'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/misc/colorpickerComponent', require('./colorpickerComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/misc/colorpickerComponent', require('./colorpickerComponent.html')); + }, + ], ); /** @@ -64,7 +65,6 @@ myModule.run( * @param {string|function(JQuery=, angular.IAttributes=): string} ngeoColorpickerTemplateUrl * Template URL for the directive. * @returns {angular.IDirective} Directive Definition Object. - * @ngInject * @ngdoc directive * @ngname ngeoColorpicker */ @@ -80,7 +80,6 @@ function colorPickerComponent(ngeoColorpickerTemplateUrl) { templateUrl: ngeoColorpickerTemplateUrl, }; } - myModule.directive('ngeoColorpicker', colorPickerComponent); /** @@ -127,7 +126,6 @@ const DEFAULT_COLORS = [ /** * @class * @hidden - * @ngInject * @ngdoc controller * @ngname NgeoScaleselectorController */ @@ -153,7 +151,5 @@ export function Controller() { Controller.prototype.setColor = function (color) { this.color = color; }; - myModule.controller('NgeoColorpickerController', Controller); - export default myModule; diff --git a/src/misc/controlComponent.js b/src/misc/controlComponent.js index 4af7a7a4d16c..bc1db158e508 100644 --- a/src/misc/controlComponent.js +++ b/src/misc/controlComponent.js @@ -45,7 +45,6 @@ const myModule = angular.module('ngeoControl', []); * * @htmlAttribute {import('ol/Map').default} ngeo-control-map The map. * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoControl */ @@ -58,20 +57,14 @@ function controlComponent() { * @param {angular.IAttributes} attrs Attributes. */ link: (scope, element, attrs) => { - const control = - /** @type {import('ol/control/Control').default} */ - (scope.$eval(attrs['ngeoControl'])); + const control = /** @type {import('ol/control/Control').default} */ scope.$eval(attrs['ngeoControl']); console.assert(control instanceof olControlControl); - - const map = /** @type {import('ol/Map').default} */ (scope.$eval(attrs['ngeoControlMap'])); + const map = /** @type {import('ol/Map').default} */ scope.$eval(attrs['ngeoControlMap']); console.assert(map instanceof olMap); - control.setTarget(element[0]); map.addControl(control); }, }; } - myModule.directive('ngeoControl', controlComponent); - export default myModule; diff --git a/src/misc/datepickerComponent.js b/src/misc/datepickerComponent.js index e043df6b5625..164447dc699a 100644 --- a/src/misc/datepickerComponent.js +++ b/src/misc/datepickerComponent.js @@ -1,3 +1,5 @@ +Controller.$inject = ['$scope', 'ngeoTime', 'gettextCatalog']; +datePickerComponent.$inject = ['ngeoDatePickerTemplateUrl', '$timeout']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -21,7 +23,6 @@ import angular from 'angular'; import ngeoMiscTime from 'ngeo/misc/Time'; - import 'angular-ui-date'; import 'ngeo/sass/jquery-ui.scss'; @@ -36,7 +37,6 @@ import 'jquery-ui/ui/i18n/datepicker-it'; * @hidden */ const myModule = angular.module('ngeoDatePicker', [ngeoMiscTime.name, 'ui.date']); - myModule.value( 'ngeoDatePickerTemplateUrl', /** @@ -49,16 +49,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'ngeo/misc/datepickerComponent'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/misc/datepickerComponent', require('./datepickerComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/misc/datepickerComponent', require('./datepickerComponent.html')); + }, + ], ); /** @@ -69,7 +70,6 @@ myModule.run( * Template for the directive. * @param {angular.ITimeoutService} $timeout angular timeout service * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoDatePicker */ @@ -88,10 +88,8 @@ function datePickerComponent(ngeoDatePickerTemplateUrl, $timeout) { throw new Error('Missing ctrl'); } ctrl.init(); - const lang = ctrl.gettextCatalog_.getCurrentLanguage(); $.datepicker.setDefaults($.datepicker.regional[lang]); - ctrl.sdateOptions = angular.extend({}, ctrl.sdateOptions, { 'minDate': ctrl.initialMinDate, 'maxDate': ctrl.initialMaxDate, @@ -105,7 +103,6 @@ function datePickerComponent(ngeoDatePickerTemplateUrl, $timeout) { } }, }); - ctrl.edateOptions = angular.extend({}, ctrl.edateOptions, { 'minDate': ctrl.initialMinDate, 'maxDate': ctrl.initialMaxDate, @@ -119,14 +116,12 @@ function datePickerComponent(ngeoDatePickerTemplateUrl, $timeout) { } }, }); - angular.element('body').on('hidden.bs.popover', () => { const dp = angular.element('#ui-datepicker-div'); if (dp && dp.css('display') === 'block') { $(element[0]).find('input[name$="date"]').datepicker('hide'); } }); - $timeout(() => { angular.element('#ui-datepicker-div').on('click', (e) => { e.stopPropagation(); @@ -135,7 +130,6 @@ function datePickerComponent(ngeoDatePickerTemplateUrl, $timeout) { }, }; } - myModule.directive('ngeoDatePicker', datePickerComponent); /** @@ -146,7 +140,6 @@ myModule.directive('ngeoDatePicker', datePickerComponent); * @param {angular.gettext.gettextCatalog} gettextCatalog service. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname ngeoDatePickerController */ @@ -229,14 +222,12 @@ export function Controller($scope, ngeoTime, gettextCatalog) { * @type {?Date} */ this.edate = null; - $scope.$watchGroup(['datepickerCtrl.sdate', 'datepickerCtrl.edate'], (newDates, oldDates) => { if (!this.onDateSelected) { throw new Error('Missing onDateSelected'); } const sDate = newDates[0]; const eDate = newDates[1]; - if (angular.isDate(sDate) && (!this.isModeRange || angular.isDate(eDate))) { const start = this.ngeoTime_.getTime(sDate); const end = this.ngeoTime_.getTime(eDate); @@ -265,7 +256,6 @@ Controller.prototype.init = function () { this.initialMinDate = this.ngeoTime_.createDate(initialOptions_.minDate); this.initialMaxDate = this.ngeoTime_.createDate(initialOptions_.maxDate); this.isModeRange = this.time.mode === 'range'; - if (this.isModeRange) { if (!Array.isArray(initialOptions_.values)) { throw new Error('Value should be an array'); @@ -279,7 +269,5 @@ Controller.prototype.init = function () { this.sdate = this.ngeoTime_.createDate(initialOptions_.values); } }; - myModule.controller('ngeoDatePickerController', Controller); - export default myModule; diff --git a/src/misc/datetimepickerComponent.js b/src/misc/datetimepickerComponent.js index 75e55913891b..aaf0448b4dcc 100644 --- a/src/misc/datetimepickerComponent.js +++ b/src/misc/datetimepickerComponent.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$element', 'gettextCatalog']; // The MIT License (MIT) // // Copyright (c) 2018-2024 Camptocamp SA @@ -53,7 +54,6 @@ function dateTimeComponent() { }, }; } - myModule.directive('ngeoDatetimepicker', dateTimeComponent); /** @@ -61,7 +61,6 @@ myModule.directive('ngeoDatetimepicker', dateTimeComponent); * @param {angular.gettext.gettextCatalog} gettextCatalog service. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname ngeoDatetimepickerController */ @@ -100,7 +99,5 @@ Controller.prototype.$onInit = function () { } this.element_.datetimepicker(this.options); }; - myModule.controller('ngeoDateTimePickerController', Controller); - export default myModule; diff --git a/src/misc/debounce.js b/src/misc/debounce.js index c041a85a4541..c7408f6d0aa2 100644 --- a/src/misc/debounce.js +++ b/src/misc/debounce.js @@ -1,3 +1,4 @@ +factory.$inject = ['$timeout']; // The MIT License (MIT) // // Copyright (c) 2014-2024 Camptocamp SA @@ -75,7 +76,6 @@ export function debounce(func, wait, invokeApply, $timeout) { * @template {function(?): void} Targs * @param {angular.ITimeoutService} $timeout Angular timeout service. * @returns {import('ngeo/misc/debounce').miscDebounce} The debounce function. - * @ngInject * @private * @hidden */ @@ -86,7 +86,5 @@ function factory($timeout) { return deb(func, wait, invokeApply, $timeout); }; } - myModule.factory('ngeoDebounce', factory); - export default myModule; diff --git a/src/misc/filereaderComponent.js b/src/misc/filereaderComponent.js index 55ac6ad750ce..7f1b2afc0de1 100644 --- a/src/misc/filereaderComponent.js +++ b/src/misc/filereaderComponent.js @@ -1,3 +1,4 @@ +filereaderComponent.$inject = ['$window']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -45,7 +46,6 @@ const myModule = angular.module('ngeoFilereader', []); * @htmlAttribute {boolean} [ngeo]-filereader-supported Whether the FileReader API is supported. * @param {angular.IWindowService} $window The Angular $window service. * @returns {angular.IDirective} Directive Definition Object. - * @ngInject * @ngdoc directive * @ngname ngeoFilereader * @private @@ -81,7 +81,7 @@ function filereaderComponent($window) { * @param {ProgressEvent} evt Event. */ function (evt) { - const target = /** @type {FileReader} */ (evt.target); + const target = /** @type {FileReader} */ evt.target; scope.$apply(() => { // @ts-ignore: scope ... scope.fileContent = target.result; @@ -93,11 +93,11 @@ function filereaderComponent($window) { } fileReader.readAsText(files[0]); }; - element.on({change: ce}); + element.on({ + change: ce, + }); }, }; } - myModule.directive('ngeoFilereader', filereaderComponent); - export default myModule; diff --git a/src/misc/filters.js b/src/misc/filters.js index 5436d0cbe513..51b7c1dd1557 100644 --- a/src/misc/filters.js +++ b/src/misc/filters.js @@ -1,3 +1,10 @@ +DurationFilter.$inject = ['gettextCatalog']; +trustHtmlAutoFilter.$inject = ['$sce', 'ngeoStringToHtmlReplacements']; +trustHtmlFilter.$inject = ['$sce']; +NumberCoordinatesFilter.$inject = ['$filter']; +UnitPrefixFilter.$inject = ['$filter']; +NumberFilter.$inject = ['$locale']; +ScalifyFilter.$inject = ['$filter']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -96,7 +103,6 @@ const myModule = angular.module('ngeoAngularFilters', []); * @param {angular.IFilterService} $filter Angular filter * @returns {function(number): string} A function to format number into a 'scale' * string. - * @ngInject * @ngdoc filter * @ngname ngeoScalify */ @@ -117,7 +123,6 @@ export function ScalifyFilter($filter) { filterFn.$stateful = true; return filterFn; } - myModule.filter('ngeoScalify', ScalifyFilter); /** @@ -136,7 +141,6 @@ myModule.filter('ngeoScalify', ScalifyFilter); * * @param {angular.ILocaleService} $locale Angular locale * @returns {formatNumber} Function used to format number into a string. - * @ngInject * @ngdoc filter * @ngname ngeoNumber */ @@ -154,7 +158,6 @@ export function NumberFilter($locale) { if (opt_precision === undefined) { opt_precision = 3; } - if (number === Infinity) { return '\u221e'; } else if (number === -Infinity) { @@ -165,13 +168,11 @@ export function NumberFilter($locale) { } const sign = number < 0; number = Math.abs(number); - const nb_decimal = opt_precision - Math.floor(Math.log(number) / Math.log(10)) - 1; const factor = Math.pow(10, nb_decimal); number = Math.round(number * factor); let decimal = ''; const unit = Math.floor(number / factor); - if (nb_decimal > 0) { let str_number = `${number}`; // 0 padding @@ -183,7 +184,6 @@ export function NumberFilter($locale) { decimal = decimal.substring(0, decimal.length - 1); } } - const groups = []; let str_unit = `${unit}`; while (str_unit.length > 3) { @@ -192,12 +192,10 @@ export function NumberFilter($locale) { str_unit = str_unit.substring(0, index); } groups.unshift(str_unit); - return (sign ? '-' : '') + groups.join(groupSep) + (decimal.length === 0 ? '' : decimalSep + decimal); }; return result; } - myModule.filter('ngeoNumber', NumberFilter); /** @@ -218,7 +216,6 @@ myModule.filter('ngeoNumber', NumberFilter); * * @param {angular.IFilterService} $filter Angular filter * @returns {unitPrefix} Function used to format number into a string. - * @ngInject * @ngdoc filter * @ngname ngeoUnitPrefix */ @@ -247,21 +244,18 @@ export function UnitPrefixFilter($filter) { divisor = 1024; prefix = binaryPrefix; } - let index = 0; const index_max = prefix.length - 1; while (number >= divisor * comparatorFactor && index < index_max) { number = number / divisor; index++; } - const postfix = prefix[index] + opt_unit; const space = postfix.length == 0 ? '' : '\u00a0'; return numberFilter(number, opt_precision) + space + postfix; }; return result; } - myModule.filter('ngeoUnitPrefix', UnitPrefixFilter); /** @@ -288,7 +282,6 @@ myModule.filter('ngeoUnitPrefix', UnitPrefixFilter); * * @param {angular.IFilterService} $filter Angular filter * @returns {numberCoordinates} A function to format numbers into coordinates string. - * @ngInject * @ngdoc filter * @ngname ngeoNumberCoordinates */ @@ -307,14 +300,13 @@ export function NumberCoordinatesFilter($filter) { const template = opt_template ? opt_template : '{x} {y}'; const x = coordinates[0]; const y = coordinates[1]; - const fractionDigits = parseInt(/** @type {string} */ (opt_fractionDigits), 10) | 0; + const fractionDigits = parseInt(/** @type {string} */ opt_fractionDigits, 10) | 0; const x_str = $filter('number')(x, fractionDigits); const y_str = $filter('number')(y, fractionDigits); return template.replace('{x}', x_str).replace('{y}', y_str); }; return filterFn; } - myModule.filter('ngeoNumberCoordinates', NumberCoordinatesFilter); /** @@ -331,7 +323,6 @@ myModule.filter('ngeoNumberCoordinates', NumberCoordinatesFilter); * * * @returns {dmsCoordinates} A function to format numbers into a DMS coordinates string. - * @ngInject * @ngdoc filter * @ngname ngeoDMSCoordinates */ @@ -348,9 +339,7 @@ export function DMSCoordinatesFilter() { const d = Math.floor(dms / 3600); const m = Math.floor((dms / 60) % 60); const s = dms % 60; - return `${d}\u00b0 ${padNumber(m, 2)}\u2032 ${padNumber(s, 2, fractionDigits)}\u2033 ${hemispheres.charAt( - normalizedDegrees < 0 ? 1 : 0, - )}`; + return `${d}\u00b0 ${padNumber(m, 2)}\u2032 ${padNumber(s, 2, fractionDigits)}\u2033 ${hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0)}`; }; /** @@ -364,19 +353,14 @@ export function DMSCoordinatesFilter() { * @returns {string} DMS formatted coordinates. */ const filterFn = function (coordinates, opt_fractionDigits, opt_template) { - const fractionDigits = parseInt(/** @type {string} */ (opt_fractionDigits), 10) | 0; - + const fractionDigits = parseInt(/** @type {string} */ opt_fractionDigits, 10) | 0; const template = opt_template ? opt_template : '{x} {y}'; - const xdms = degreesToStringHDMS(coordinates[0], 'EW', fractionDigits); const ydms = degreesToStringHDMS(coordinates[1], 'NS', fractionDigits); - return template.replace('{x}', xdms).replace('{y}', ydms); }; - return filterFn; } - myModule.filter('ngeoDMSCoordinates', DMSCoordinatesFilter); /** @@ -389,7 +373,6 @@ myModule.filter('ngeoDMSCoordinates', DMSCoordinatesFilter); * If you use it, you don't require the "ngSanitize". * * @returns {function(?):string} The filter function. - * @ngInject * @ngdoc filter * @param {angular.ISCEService} $sce Angular sce service. * @ngname ngeoTrustHtml @@ -403,7 +386,6 @@ export function trustHtmlFilter($sce) { } }; } - myModule.filter('ngeoTrustHtml', trustHtmlFilter); /** @@ -418,7 +400,6 @@ myModule.filter('ngeoTrustHtml', trustHtmlFilter); * If you use it, you don't require the "ngSanitize". * * @returns {function(?):string} The filter function. - * @ngInject * @ngdoc filter * @param {angular.ISCEService} $sce Angular sce service. * @param {import('ngeo/options').ngeoStringToHtmlReplacements} ngeoStringToHtmlReplacements @@ -447,7 +428,6 @@ export function trustHtmlAutoFilter($sce, ngeoStringToHtmlReplacements) { } }; } - myModule.filter('ngeoTrustHtmlAuto', trustHtmlAutoFilter); /** @@ -463,7 +443,6 @@ myModule.filter('ngeoTrustHtmlAuto', trustHtmlAutoFilter); * * @param {angular.gettext.gettextCatalog} gettextCatalog Gettext catalog. * @returns {duration} Function used to format a time duration in seconds into a string. - * @ngInject * @ngdoc filter * @ngname ngeoDuration */ @@ -549,10 +528,8 @@ export function DurationFilter(gettextCatalog) { } return output; }; - return result; } - myModule.filter('ngeoDuration', DurationFilter); /** @@ -570,7 +547,5 @@ export const removeCDATA = function () { } }; }; - myModule.filter('removeCDATA', removeCDATA); - export default myModule; diff --git a/src/misc/sortableComponent.js b/src/misc/sortableComponent.js index 06c8062a94f5..2442ebc12867 100644 --- a/src/misc/sortableComponent.js +++ b/src/misc/sortableComponent.js @@ -1,3 +1,4 @@ +sortableComponent.$inject = ['$timeout']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -75,7 +76,6 @@ const myModule = angular.module('ngeoSortable', []); * the call of the callback function. * @param {angular.ITimeoutService} $timeout Angular timeout service. * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname ngeoSortable */ @@ -90,17 +90,14 @@ function sortableComponent($timeout) { link: (scope, element, attrs) => { const sortable = scope.$eval(attrs.ngeoSortable) || []; console.assert(Array.isArray(sortable)); - scope.$watchCollection( () => sortable, () => { sortable.length && $timeout(resetUpDragDrop, 0); }, ); - const optionsObject = scope.$eval(attrs.ngeoSortableOptions); const options = getOptions(optionsObject); - const callbackFn = scope.$eval(attrs.ngeoSortableCallback); const callbackCtx = scope.$eval(attrs.ngeoSortableCallbackCtx); @@ -115,7 +112,6 @@ function sortableComponent($timeout) { for (let i = 0; i < children.length; ++i) { angular.element(children[i]).data('idx', i); } - const sortableElement = $(element); // the element is already sortable; reset it. @@ -143,7 +139,6 @@ function sortableComponent($timeout) { sortableOptions.placeholder = options.placeholderClassName; sortableOptions.forcePlaceholderSize = true; } - sortableElement.sortable(sortableOptions); // This event is triggered when the user stopped sorting and @@ -176,19 +171,19 @@ function sortableComponent($timeout) { let ret; const defaultHandleClassName = 'ngeo-sortable-handle'; if (options === undefined) { - ret = {'handleClassName': defaultHandleClassName}; + ret = { + 'handleClassName': defaultHandleClassName, + }; } else { if (options.handleClassName === undefined) { options.handleClassName = defaultHandleClassName; } - ret = /** @type {miscSortableOptions} */ (options); + ret = /** @type {miscSortableOptions} */ options; } return ret; } }, }; } - myModule.directive('ngeoSortable', sortableComponent); - export default myModule; diff --git a/src/mobile/measure/areaComponent.js b/src/mobile/measure/areaComponent.js index 46b242efbe02..bcffe6f88f71 100644 --- a/src/mobile/measure/areaComponent.js +++ b/src/mobile/measure/areaComponent.js @@ -1,3 +1,4 @@ +mobileMeasureAreaComponent.$inject = ['gmfMobileMeasureAreaTemplateUrl']; // The MIT License (MIT) // // Copyright (c) 2018-2024 Camptocamp SA @@ -30,7 +31,6 @@ import {buildStyle} from 'ngeo/options'; * @hidden */ const myModule = angular.module('gmfMobileMeasureArea', [ngeoMiscFilters.name]); - myModule.value( 'gmfMobileMeasureAreaTemplateUrl', /** @@ -43,16 +43,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'gmf/measure/areaComponent'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/measure/areaComponent', require('./baseComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/measure/areaComponent', require('./baseComponent.html')); + }, + ], ); /** @@ -71,7 +72,6 @@ myModule.run( * @param {string|function(JQuery=, angular.IAttributes=):string} gmfMobileMeasureAreaTemplateUrl * Template URL for the directive. * @returns {angular.IDirective} The Directive Definition Object. - * @ngInject * @ngdoc directive * @ngname gmfMobileMeasureArea */ @@ -99,7 +99,6 @@ function mobileMeasureAreaComponent(gmfMobileMeasureAreaTemplateUrl) { }, }; } - myModule.directive('gmfMobileMeasurearea', mobileMeasureAreaComponent); /** @@ -111,7 +110,6 @@ export class Controller extends MeasueMobileBaseController { * @param {angular.IFilterService} $filter Angular filter * @param {angular.gettext.gettextCatalog} gettextCatalog Gettext catalog. * @param {import('gmf/options').gmfMobileMeasureAreaOptions} gmfMobileMeasureAreaOptions The options. - * @ngInject */ constructor($scope, $filter, gettextCatalog, gmfMobileMeasureAreaOptions) { super($scope, $filter, gettextCatalog); @@ -134,7 +132,6 @@ export class Controller extends MeasueMobileBaseController { precision: this.options.precision || 2, sketchStyle: buildStyle(this.options.sketchStyle), }); - super.init(); } @@ -175,7 +172,6 @@ export class Controller extends MeasueMobileBaseController { this.active = false; } } - +Controller.$inject = ['$scope', '$filter', 'gettextCatalog', 'gmfMobileMeasureAreaOptions']; myModule.controller('GmfMobileMeasureAreaController', Controller); - export default myModule; diff --git a/src/mobile/measure/baseComponent.js b/src/mobile/measure/baseComponent.js index 3246d0750844..cd51e85f9da3 100644 --- a/src/mobile/measure/baseComponent.js +++ b/src/mobile/measure/baseComponent.js @@ -1,3 +1,4 @@ +MeasueMobileBaseController.$inject = ['$scope', '$filter', 'gettextCatalog']; // The MIT License (MIT) // // Copyright (c) 2018-2024 Camptocamp SA @@ -38,7 +39,6 @@ const myModule = angular.module('gmfMobileMeasureBase', [ngeoMiscFilters.name]); * @param {angular.IFilterService} $filter Angular filter * @param {angular.gettext.gettextCatalog} gettextCatalog Gettext catalog. * @class - * @ngInject * @ngdoc controller * @ngname GmfMobileMeasureBaseController * @hidden @@ -68,7 +68,6 @@ export function MeasueMobileBaseController($scope, $filter, gettextCatalog) { * @type {boolean} */ this.active = false; - this.scope.$watch( () => this.active, (newVal) => { @@ -115,23 +114,19 @@ MeasueMobileBaseController.prototype.init = function () { if (!this.measure) { throw new Error('Missing measure'); } - this.measure.setActive(this.active); interactionDecoration(this.measure); - const drawInteraction = this.measure.getDrawInteraction(); if (!(drawInteraction instanceof MobileDraw)) { throw new Error('Wrong drawInteraction'); } this.drawInteraction = drawInteraction; interactionDecoration(drawInteraction); - Object.defineProperty(this, 'hasPoints', { get() { return this.drawInteraction.getFeature() !== null; }, }); - listen( drawInteraction, 'change:dirty', @@ -148,7 +143,6 @@ MeasueMobileBaseController.prototype.init = function () { }, this, ); - listen( drawInteraction, 'change:drawing', @@ -158,7 +152,6 @@ MeasueMobileBaseController.prototype.init = function () { }, this, ); - listen( drawInteraction, 'change:valid', @@ -168,10 +161,7 @@ MeasueMobileBaseController.prototype.init = function () { }, this, ); - this.map.addInteraction(this.measure); }; - myModule.controller('gmfMeasueMobileBaseController', MeasueMobileBaseController); - export default myModule; diff --git a/src/mobile/measure/lengthComponent.js b/src/mobile/measure/lengthComponent.js index f33c60bcc50f..d3985551b884 100644 --- a/src/mobile/measure/lengthComponent.js +++ b/src/mobile/measure/lengthComponent.js @@ -1,3 +1,4 @@ +mobileMeasureLenthComponent.$inject = ['gmfMobileMeasureLengthTemplateUrl']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -30,7 +31,6 @@ import {buildStyle} from 'ngeo/options'; * @hidden */ const myModule = angular.module('gmfMobileMeasureLength', [ngeoMiscFilters.name]); - myModule.value( 'gmfMobileMeasureLengthTemplateUrl', /** @@ -43,16 +43,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'gmf/measure/lengthComponent'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/measure/lengthComponent', require('./baseComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/measure/lengthComponent', require('./baseComponent.html')); + }, + ], ); /** @@ -71,7 +72,6 @@ myModule.run( * @param {string|function(JQuery=, angular.IAttributes=):string} gmfMobileMeasureLengthTemplateUrl * Template URL for the directive. * @returns {angular.IDirective} The Directive Definition Object. - * @ngInject * @ngdoc directive * @ngname gmfMobileMeasureLength */ @@ -99,7 +99,6 @@ function mobileMeasureLenthComponent(gmfMobileMeasureLengthTemplateUrl) { }, }; } - myModule.directive('gmfMobileMeasurelength', mobileMeasureLenthComponent); /** @@ -111,7 +110,6 @@ export class Controller extends MeasueMobileBaseController { * @param {angular.IFilterService} $filter Angular filter * @param {angular.gettext.gettextCatalog} gettextCatalog Gettext catalog. * @param {import('gmf/options').gmfMobileMeasureLengthOptions} gmfMobileMeasureLengthOptions The options. - * @ngInject */ constructor($scope, $filter, gettextCatalog, gmfMobileMeasureLengthOptions) { super($scope, $filter, gettextCatalog); @@ -138,7 +136,6 @@ export class Controller extends MeasueMobileBaseController { sketchStyle: buildStyle(this.options.sketchStyle), }, ); - super.init(); } @@ -179,7 +176,6 @@ export class Controller extends MeasueMobileBaseController { this.active = false; } } - +Controller.$inject = ['$scope', '$filter', 'gettextCatalog', 'gmfMobileMeasureLengthOptions']; myModule.controller('GmfMobileMeasureLengthController', Controller); - export default myModule; diff --git a/src/mobile/measure/pointComponent.js b/src/mobile/measure/pointComponent.js index 13f12fe82dce..a3eac0870583 100644 --- a/src/mobile/measure/pointComponent.js +++ b/src/mobile/measure/pointComponent.js @@ -1,3 +1,12 @@ +MobileMeasurePointController.$inject = [ + 'gettextCatalog', + '$scope', + '$filter', + 'gmfRaster', + 'ngeoDebounce', + 'gmfMobileMeasurePointOptions', +]; +mobileMeasurePointComponent.$inject = ['gmfMobileMeasurePointTemplateUrl']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -36,7 +45,6 @@ const myModule = angular.module('gmfMobileMeasurePoint', [ gmfRasterRasterService.name, ngeoMiscDebounce.name, ]); - myModule.value( 'gmfMobileMeasurePointTemplateUrl', /** @@ -49,16 +57,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'gmf/measure/pointComponent'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/measure/pointComponent', require('./pointComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/measure/pointComponent', require('./pointComponent.html')); + }, + ], ); /** @@ -86,7 +95,6 @@ myModule.run( * @param {string|function(JQuery=, angular.IAttributes=): string} gmfMobileMeasurePointTemplateUrl * Template URL for the directive. * @returns {angular.IDirective} The Directive Definition Object. - * @ngInject * @ngdoc directive * @ngname gmfMobileMeasurePoint */ @@ -114,7 +122,6 @@ function mobileMeasurePointComponent(gmfMobileMeasurePointTemplateUrl) { }, }; } - myModule.directive('gmfMobileMeasurepoint', mobileMeasurePointComponent); /** @@ -126,7 +133,6 @@ myModule.directive('gmfMobileMeasurepoint', mobileMeasurePointComponent); * @param {import('gmf/options').gmfMobileMeasurePointOptions} gmfMobileMeasurePointOptions The options. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname GmfMobileMeasurePointController */ @@ -172,7 +178,6 @@ export function MobileMeasurePointController( * @type {boolean} */ this.active = false; - $scope.$watch( () => this.active, (newVal) => { @@ -207,7 +212,7 @@ export function MobileMeasurePointController( */ MobileMeasurePointController.prototype.init = function () { this.measure = new ngeoInteractionMeasurePointMobile( - /** @type {import('ngeo/misc/filters').numberCoordinates} */ (this.$filter_('ngeoNumberCoordinates')), + /** @type {import('ngeo/misc/filters').numberCoordinates} */ this.$filter_('ngeoNumberCoordinates'), this.options.format, { decimals: this.options.decimals, @@ -222,7 +227,6 @@ MobileMeasurePointController.prototype.init = function () { } this.drawInteraction = drawInteraction; interactionDecoration(this.drawInteraction); - if (!this.map) { throw new Error('Missing map'); } @@ -302,7 +306,6 @@ MobileMeasurePointController.prototype.getMeasure_ = function () { const ctn = document.createElement('div'); const className = 'gmf-mobile-measure-point'; ctn.className = className; - for (const config of this.options.rasterLayers) { const key = config.name; if (key in object) { @@ -317,7 +320,6 @@ MobileMeasurePointController.prototype.getMeasure_ = function () { ctn.appendChild(childEl); } } - const previousCtn = el.getElementsByClassName(className); if (previousCtn[0]) { previousCtn[0].remove(); @@ -325,7 +327,5 @@ MobileMeasurePointController.prototype.getMeasure_ = function () { el.appendChild(ctn); }); }; - myModule.controller('GmfMobileMeasurePointController', MobileMeasurePointController); - export default myModule; diff --git a/src/mobile/navigation/component.js b/src/mobile/navigation/component.js index 973159101614..4b5a4579a194 100644 --- a/src/mobile/navigation/component.js +++ b/src/mobile/navigation/component.js @@ -78,7 +78,6 @@ const CLASS_NAMES = { * When an element slides in the directive changes the text in the header. * * @returns {angular.IDirective} The Directive Definition Object. - * @ngInject */ function mobileNavigationComponent() { return { @@ -100,13 +99,11 @@ function mobileNavigationComponent() { }, }; } - myModule.directive('gmfMobileNav', mobileNavigationComponent); /** * @class * @hidden - * @ngInject * @ngdoc controller * @ngname gmfMobileNavController */ @@ -146,7 +143,6 @@ export function Controller() { */ this.back = this.back_.bind(this); } - myModule.controller('gmfMobileNavController', Controller); /** @@ -191,7 +187,6 @@ Controller.prototype.init = function (element) { // update the navigation header this.updateNavigationHeader_(slideIn, false); - this.active_ = slideIn; }; element.find('[data-toggle=slide-in]').on({ @@ -246,7 +241,6 @@ Controller.prototype.updateNavigationHeader_ = function (active, back) { nav.css('display', 'none'); nav.offset(); nav.css('display', ''); - window.setTimeout(() => { // fix: calling `position()` makes sure that the animation // is always run @@ -281,7 +275,6 @@ Controller.prototype.back_ = function () { // update the navigation header this.updateNavigationHeader_(slideBack, true); - this.active_ = slideBack; }; @@ -315,7 +308,6 @@ Controller.prototype.backIfActive = function (element) { * active, the navigation will go back to the last slide. * * @returns {angular.IDirective} The Directive Definition Object. - * @ngInject */ function mobileNavigationBackComponent() { return { @@ -340,7 +332,6 @@ function mobileNavigationBackComponent() { }, }; } - myModule.directive('gmfMobileNavBack', mobileNavigationBackComponent); /** @@ -360,7 +351,6 @@ myModule.directive('gmfMobileNavBack', mobileNavigationBackComponent); * * * @returns {angular.IDirective} The Directive Definition Object. - * @ngInject */ function mobileNavigationBackOnClickComponent() { return { @@ -383,7 +373,5 @@ function mobileNavigationBackOnClickComponent() { }, }; } - myModule.directive('gmfMobileNavBackOnClick', mobileNavigationBackOnClickComponent); - export default myModule; diff --git a/src/objectediting/Manager.js b/src/objectediting/Manager.js index 88e1d6965e2a..0b8912d8b56b 100644 --- a/src/objectediting/Manager.js +++ b/src/objectediting/Manager.js @@ -1,3 +1,4 @@ +ObjecteditingManagerService.$inject = ['$q', 'gmfEditFeature', 'ngeoLocation']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -59,7 +60,6 @@ export const ObjecteditingParam = { * @param {import('gmf/editing/EditFeature').EditingEditFeature} gmfEditFeature Gmf edit feature service. * @param {import('ngeo/statemanager/Location').StatemanagerLocation} ngeoLocation ngeo location service. * @class - * @ngInject * @hidden */ export function ObjecteditingManagerService($q, gmfEditFeature, ngeoLocation) { @@ -97,13 +97,11 @@ export function ObjecteditingManagerService($q, gmfEditFeature, ngeoLocation) { ObjecteditingManagerService.prototype.getFeature = function () { if (!this.getFeatureDefered_) { this.getFeatureDefered_ = this.q_.defer(); - const geomType = this.ngeoLocation_.getParam(ObjecteditingParam.GEOM_TYPE); const id = this.ngeoLocation_.getParam(ObjecteditingParam.ID); const layer = this.ngeoLocation_.getParam(ObjecteditingParam.LAYER); const property = this.ngeoLocation_.getParam(ObjecteditingParam.PROPERTY); const theme = this.ngeoLocation_.getParam(ObjecteditingParam.THEME); - if (geomType && id && layer && property && theme) { this.gmfEditFeature_ .getFeaturesWithComparisonFilters( @@ -121,7 +119,6 @@ ObjecteditingManagerService.prototype.getFeature = function () { this.getFeatureDefered_.resolve(null); } } - return this.getFeatureDefered_.promise; }; @@ -151,7 +148,6 @@ ObjecteditingManagerService.prototype.getLayerNodeId = function () { */ ObjecteditingManagerService.prototype.handleGetFeatures_ = function (key, value, features) { let feature; - if (features.length) { feature = features[0]; } else { @@ -161,7 +157,6 @@ ObjecteditingManagerService.prototype.handleGetFeatures_ = function (key, value, featureProperties.geometry = null; feature = new olFeature(featureProperties); } - if (!this.getFeatureDefered_) { throw new Error('Missing getFeatureDefered'); } @@ -177,5 +172,4 @@ const myModule = angular.module('gmfObjectEditingManager', [ ngeoStatemanagerLocation.name, ]); myModule.service('gmfObjectEditingManager', ObjecteditingManagerService); - export default myModule; diff --git a/src/objectediting/Query.js b/src/objectediting/Query.js index 5a589ffa0d56..263a64ab4e24 100644 --- a/src/objectediting/Query.js +++ b/src/objectediting/Query.js @@ -1,3 +1,4 @@ +ObjectEditingQuery.$inject = ['$http', '$q', 'gmfThemes']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -35,7 +36,6 @@ import olSourceImageWMS from 'ol/source/ImageWMS'; * @param {angular.IQService} $q Angular $q service. * @param {import('gmf/theme/Themes').ThemesService} gmfThemes The gmf themes service. * @class - * @ngInject * @hidden */ export function ObjectEditingQuery($http, $q, gmfThemes) { @@ -85,12 +85,10 @@ ObjectEditingQuery.prototype.getQueryableLayersInfo = function () { queryableLayersInfo.push(allQueryableLayersInfo[i]); } } - this.getQueryableLayerNodesDefered_.resolve(queryableLayersInfo); }); }); } - return this.getQueryableLayerNodesDefered_.promise; }; @@ -108,7 +106,6 @@ ObjectEditingQuery.prototype.getQueryableLayersInfo = function () { */ function getQueryableLayersInfoFromThemes(themes, ogcServers) { const queryableLayersInfo = []; - for (let i = 0, ii = themes.length; i < ii; i++) { const theme = themes[i]; for (let j = 0, jj = theme.children.length; j < jj; j++) { @@ -122,10 +119,8 @@ function getQueryableLayersInfoFromThemes(themes, ogcServers) { /** @type {import('gmf/themes').GmfLayer[]} */ const nodes = []; getFlatNodes(group, nodes); - for (let k = 0, kk = nodes.length; k < kk; k++) { - const nodeWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ (/** @type {any} */ (nodes[k])); - + const nodeWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ /** @type {any} */ nodes[k]; if (nodeWMS.childLayers && nodeWMS.childLayers[0] && nodeWMS.childLayers[0].queryable) { queryableLayersInfo.push({ layerNode: nodeWMS, @@ -135,7 +130,6 @@ function getQueryableLayersInfoFromThemes(themes, ogcServers) { } } } - return queryableLayersInfo; } @@ -162,30 +156,26 @@ ObjectEditingQuery.prototype.getFeatureInfo = function (layerInfo, coordinate, m if (resolution === undefined) { throw new Error('Missing resolution'); } - const format = new olFormatWMSGetFeatureInfo({ layers: layersParam, }); - const wmsSource = new olSourceImageWMS({ url: ogcServer.url, params: { layers: layersParam, }, }); - - const url = /** @type {string} */ ( + const url = + /** @type {string} */ wmsSource.getFeatureInfoUrl(coordinate, resolution, projCode, { 'INFO_FORMAT': infoFormat, 'FEATURE_COUNT': 1, 'QUERY_LAYERS': layersParam, - }) - ); - + }); return this.http_.get(url).then((response) => { - const features = /** @type {import('ol/Feature').default[]} */ ( - format.readFeatures(response.data) - ); + const features = + /** @type {import('ol/Feature').default[]} */ + format.readFeatures(response.data); return features && features[0] ? features[0] : null; }); }; @@ -196,5 +186,4 @@ ObjectEditingQuery.prototype.getFeatureInfo = function (layerInfo, coordinate, m */ const myModule = angular.module('gmfObjectEditingQuery', [gmfThemeThemes.name]); myModule.service('gmfObjectEditingQuery', ObjectEditingQuery); - export default myModule; diff --git a/src/objectediting/component.js b/src/objectediting/component.js index 4eac5db0cb20..6a3ee162edba 100644 --- a/src/objectediting/component.js +++ b/src/objectediting/component.js @@ -1,3 +1,14 @@ +Controller.$inject = [ + '$scope', + '$timeout', + 'gettextCatalog', + 'gmfEditFeature', + 'gmfObjectEditingQuery', + 'gmfTreeManager', + 'ngeoFeatureHelper', + 'ngeoLayerHelper', + 'ngeoToolActivateMgr', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -27,16 +38,12 @@ import gmfLayertreeSyncLayertreeMap, { import gmfLayertreeTreeManager from 'gmf/layertree/TreeManager'; import {isEmpty, toXY} from 'gmf/objectediting/geom'; import gmfObjecteditingQuery from 'gmf/objectediting/Query'; - import gmfObjecteditingToolsComponent, {ObjecteditingProcessType} from 'gmf/objectediting/toolsComponent'; - import ngeoMapLayerHelper from 'ngeo/map/LayerHelper'; import {interactionDecoration as ngeoMiscDecorateInteraction} from 'ngeo/misc/decorate'; import ngeoMiscFeatureHelper from 'ngeo/misc/FeatureHelper'; import ngeoMiscToolActivate from 'ngeo/misc/ToolActivate'; - import ngeoMiscToolActivateMgr from 'ngeo/misc/ToolActivateMgr'; - import {toMulti, deleteCondition} from 'ngeo/utils'; import {getUid as olUtilGetUid} from 'ol/util'; import olCollection from 'ol/Collection'; @@ -95,18 +102,18 @@ const myModule = angular.module('gmfObjectEditingComponent', [ ngeoMiscFeatureHelper.name, ngeoMiscToolActivateMgr.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/objectediting', require('./component.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/objectediting', require('./component.html')); + }, + ], ); - myModule.value( 'gmfObjecteditingTemplateUrl', /** @@ -125,10 +132,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(JQuery, angular.IAttributes): string} gmfObjecteditingTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfObjecteditingTemplateUrl.$inject = ['$element', '$attrs', 'gmfObjecteditingTemplateUrl']; function gmfObjecteditingTemplateUrl($element, $attrs, gmfObjecteditingTemplateUrl) { return gmfObjecteditingTemplateUrl($element, $attrs); } @@ -171,7 +178,6 @@ const objecteditingComponent = { }, templateUrl: gmfObjecteditingTemplateUrl, }; - myModule.component('gmfObjectediting', objecteditingComponent); /** @@ -189,7 +195,6 @@ myModule.component('gmfObjectediting', objecteditingComponent); * manager service. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname GmfObjecteditingController */ @@ -441,7 +446,6 @@ export function Controller( */ Controller.prototype.$onInit = function () { this.gmfObjectEditingQuery_.getQueryableLayersInfo().then(this.handleGetQueryableLayersInfo_.bind(this)); - this.scope_.$watch( () => this.active, (newVal, oldVal) => { @@ -450,7 +454,6 @@ Controller.prototype.$onInit = function () { } }, ); - this.scope_.$watchCollection( () => { if (this.gmfTreeManager_.rootCtrl) { @@ -471,13 +474,11 @@ Controller.prototype.$onInit = function () { }); }, ); - if (!this.feature) { throw new Error('Missing feature'); } const geometry = this.feature.getGeometry(); this.state_ = geometry ? ObjecteditingState.UPDATE : ObjecteditingState.INSERT; - this.scope_.$watchCollection( () => this.geometryChanges_, (newVal, oldVal) => { @@ -490,25 +491,20 @@ Controller.prototype.$onInit = function () { } }, ); - const defaultColor = [39, 155, 145]; const dirtyColor = [153, 51, 51]; this.initializeStyles_(this.defaultStyles_, defaultColor); this.initializeStyles_(this.defaultStylesWoVertice_, defaultColor, false); this.initializeStyles_(this.dirtyStyles_, dirtyColor); this.initializeStyles_(this.dirtyStylesWoVertice_, dirtyColor, false); - this.scope_.$watch(() => this.dirty, this.setFeatureStyle_.bind(this)); - this.features_.push(this.feature); - this.featureHasGeom = !isEmpty(geometry); // Toggle on this.initializeInteractions_(); this.toggle_(true); this.resetGeometryChanges_(); - this.scope_.$on('$destroy', this.handleDestroy_.bind(this)); }; @@ -530,7 +526,6 @@ Controller.prototype.delete = function () { if (!this.feature) { throw new Error('Missing feature'); } - this.gmfEditFeature_ .deleteFeature(this.layerNodeId, this.feature) .then(this.handleDeleteFeature_.bind(this)); @@ -547,7 +542,6 @@ Controller.prototype.save = function () { if (!this.layerNodeId) { throw new Error('Missing layerNodeId'); } - this.pending = true; // The geometry of the feature may contain Z in its coordinates, which @@ -562,7 +556,6 @@ Controller.prototype.save = function () { if (geometry) { toXY(geometry); } - if (this.state_ === ObjecteditingState.INSERT) { this.gmfEditFeature_.insertFeatures(this.layerNodeId, [feature]).then(this.handleEditFeature_.bind(this)); } else if (this.state_ === ObjecteditingState.UPDATE) { @@ -577,17 +570,13 @@ Controller.prototype.undo = function () { if (!this.feature) { throw new Error('Missing feature'); } - if (this.geometryChanges_.length <= 1) { return; } - this.skipGeometryChange_ = true; - this.geometryChanges_.pop(); const clone = cloneGeometry(this.geometryChanges_[this.geometryChanges_.length - 1]); this.feature.setGeometry(clone); - this.skipGeometryChange_ = false; }; @@ -691,11 +680,9 @@ Controller.prototype.toggle_ = function (active) { if (!this.sketchFeatures) { throw new Error('Missing sketchFeatures'); } - const keys = this.listenerKeys_; const uid = `${NAMESPACE}-${olUtilGetUid(this)}`; const toolMgr = this.ngeoToolActivateMgr_; - if (active) { keys.push( listen( @@ -708,24 +695,19 @@ Controller.prototype.toggle_ = function (active) { keys.push(listen(this.modify_, 'change:active', this.setFeatureStyle_, this)); keys.push(listen(this.modify_, 'modifyend', this.handleModifyInteractionModifyEnd_, this)); keys.push( - listen(window, 'beforeunload', /** @type {function(?): ?} */ (this.handleWindowBeforeUnload_), this), + listen(window, 'beforeunload', /** @type {function(?): ?} */ this.handleWindowBeforeUnload_, this), ); keys.push(listen(this.sketchFeatures, 'add', this.handleSketchFeaturesAdd_, this)); - toolMgr.registerTool(uid, this.modifyToolActivate_, true); toolMgr.registerTool(uid, this.toolsToolActivate_, false); - this.registerInteractions_(); } else { this.unregisterInteractions_(); - keys.forEach(unlistenByKey); keys.length = 0; - toolMgr.unregisterTool(uid, this.modifyToolActivate_); toolMgr.unregisterTool(uid, this.toolsToolActivate_); } - this.toolsActive = active; this.modify_.setActive(active); }; @@ -742,7 +724,6 @@ Controller.prototype.undoAllChanges_ = function () { throw new Error('Missing clone'); } this.feature.setGeometry(clone); - this.resetGeometryChanges_(); this.dirty = false; this.setFeatureStyle_(); @@ -784,7 +765,6 @@ Controller.prototype.handleModifyInteractionModifyEnd_ = function (evt) { if (!geometry) { throw new Error('Missing geometry'); } - if (geometry.getType() === 'MultiPolygon') { const jstsGeom = this.jstsOL3Parser_.read(geometry); const jstsBuffered = jstsGeom.buffer(0, undefined, undefined); @@ -793,7 +773,6 @@ Controller.prototype.handleModifyInteractionModifyEnd_ = function (evt) { this.feature.setGeometry(geometry.clone()); this.skipGeometryChange_ = false; } - const clone = cloneGeometry(geometry); if (!clone) { throw new Error('Missing clone geometry'); @@ -811,23 +790,22 @@ Controller.prototype.initializeStyles_ = function (styles, color, opt_incVertice const incVertice = opt_incVertice !== false; const rgbaColor = color.slice(); rgbaColor.push(0.3); - const image = new olStyleCircle({ radius: 8, stroke: new olStyleStroke({ color: color, width: 1, }), - fill: new olStyleFill({color: rgbaColor}), + fill: new olStyleFill({ + color: rgbaColor, + }), }); - styles.Point = new olStyleStyle({ image, }); styles.MultiPoint = new olStyleStyle({ image, }); - styles.LineString = [ new olStyleStyle({ stroke: new olStyleStroke({ @@ -850,7 +828,6 @@ Controller.prototype.initializeStyles_ = function (styles, color, opt_incVertice if (incVertice) { styles.MultiLineString.push(this.ngeoFeatureHelper_.getVertexStyle(true)); } - styles.Polygon = [ new olStyleStyle({ stroke: new olStyleStroke({ @@ -926,12 +903,11 @@ Controller.prototype.setFeatureStyle_ = function () { */ Controller.prototype.registerTreeCtrl_ = function (treeCtrl) { // Skip any Layertree controller that has a node that is not a leaf - const nodeGroup = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); + const nodeGroup = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; if (nodeGroup.children && nodeGroup.children.length) { return; } - - const nodeLayer = /** @type {import('gmf/themes').GmfLayer} */ (treeCtrl.node); + const nodeLayer = /** @type {import('gmf/themes').GmfLayer} */ treeCtrl.node; // Set editable WMS layer for refresh purpose if (nodeLayer.id === this.layerNodeId) { const layer = syncLayertreeMapGetLayer(treeCtrl); @@ -995,14 +971,11 @@ Controller.prototype.handleSketchFeaturesAdd_ = function (evt) { } const sketchFeature = evt.element; const sketchGeom = sketchFeature.getGeometry(); - const geom = this.feature.getGeometry(); - if (geom) { const jstsGeom = this.jstsOL3Parser_.read(geom); const jstsSketchGeom = this.jstsOL3Parser_.read(sketchGeom); let jstsProcessedGeom; - if (this.process === ObjecteditingProcessType.ADD) { jstsProcessedGeom = jstsGeom.union(jstsSketchGeom); } else { @@ -1010,7 +983,6 @@ Controller.prototype.handleSketchFeaturesAdd_ = function (evt) { jstsProcessedGeom = jstsGeom.difference(jstsSketchGeom); } } - if (jstsProcessedGeom) { const processedGeom = this.jstsOL3Parser_.write(jstsProcessedGeom); const multiGeom = toMulti(processedGeom); @@ -1019,7 +991,6 @@ Controller.prototype.handleSketchFeaturesAdd_ = function (evt) { } else if (this.process === ObjecteditingProcessType.ADD) { this.feature.setGeometry(toMulti(sketchGeom.clone())); } - this.sketchFeatures.clear(); } }; @@ -1041,11 +1012,9 @@ Controller.prototype.handleFeatureGeometryChange_ = function () { this.timeout_(() => { this.featureHasGeom = !isEmpty(geom); }); - if (this.skipGeometryChange_) { return; } - if (geom) { // Use a timeout here, because there can be a scope digest already in // progress. For example, with tools that requires the user to draw @@ -1069,7 +1038,6 @@ Controller.prototype.handleGetQueryableLayersInfo_ = function (layersInfo) { this.selectedQueryableLayerInfo = this.queryableLayersInfo[0]; } }; - Controller.prototype.handleDestroy_ = function () { this.features_.clear(); this.toggle_(false); @@ -1096,7 +1064,5 @@ function cloneGeometry(geometry) { } return clone; } - myModule.controller('GmfObjecteditingController', Controller); - export default myModule; diff --git a/src/objectediting/getWMSFeatureComponent.js b/src/objectediting/getWMSFeatureComponent.js index e689a2bcf064..b01365215d36 100644 --- a/src/objectediting/getWMSFeatureComponent.js +++ b/src/objectediting/getWMSFeatureComponent.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$scope', 'gmfObjectEditingQuery']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -52,7 +53,6 @@ const myModule = angular.module('gmfObjecteditingGetWMSFeatureComponent', [gmfOb * gmf-objecteditinggetwmsfeature-layerinfo Queryable layer info. * @htmlAttribute {import('ol/Map').default} gmf-objecteditinggetwmsfeature-map The map. * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname gmfObjecteditinggetwmsfeature */ @@ -68,7 +68,6 @@ function objectEditingGetWMSFeatureComponent() { bindToController: true, }; } - myModule.directive('gmfObjecteditinggetwmsfeature', objectEditingGetWMSFeatureComponent); /** @@ -77,7 +76,6 @@ myModule.directive('gmfObjecteditinggetwmsfeature', objectEditingGetWMSFeatureCo * query service. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname GmfObjecteditinggetwmsfeatureController */ @@ -88,7 +86,6 @@ export function Controller($scope, gmfObjectEditingQuery) { * @type {boolean} */ this.active = false; - $scope.$watch(() => this.active, this.handleActiveChange_.bind(this)); /** @@ -154,7 +151,5 @@ Controller.prototype.handleMapClick_ = function (evt) { }); } }; - myModule.controller('gmfObjecteditinggetwmsfeatureController', Controller); - export default myModule; diff --git a/src/objectediting/toolsComponent.js b/src/objectediting/toolsComponent.js index 937300294952..f01c4c5aad7a 100644 --- a/src/objectediting/toolsComponent.js +++ b/src/objectediting/toolsComponent.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$scope', 'ngeoToolActivateMgr', 'gmfObjectEditingToolsOptions']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -20,17 +21,11 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - import gmfObjecteditingGetWMSFeatureComponent from 'gmf/objectediting/getWMSFeatureComponent'; - import ngeoEditingCreatefeatureComponent from 'ngeo/editing/createfeatureComponent'; - import ngeoEditingCreateregularpolygonfromclickComponent from 'ngeo/editing/createregularpolygonfromclickComponent'; - import ngeoGeometryType from 'ngeo/GeometryType'; - import ngeoMiscBtnComponent from 'ngeo/misc/btnComponent'; - import ngeoMiscToolActivate from 'ngeo/misc/ToolActivate'; import ngeoMiscToolActivateMgr from 'ngeo/misc/ToolActivateMgr'; import {getUid as olUtilGetUid} from 'ol/util'; @@ -61,16 +56,17 @@ const myModule = angular.module('gmfObjecteditingToolsComponent', [ ngeoMiscBtnComponent.name, ngeoMiscToolActivateMgr.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/objectediting/toolsComponent', require('./toolsComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/objectediting/toolsComponent', require('./toolsComponent.html')); + }, + ], ); /** @@ -111,7 +107,6 @@ myModule.run( * @htmlAttribute {import('ol/Collection').default>} gmf-objectediting-sketchfeatures * Collection of temporary features being drawn by the tools. * @returns {angular.IDirective} The directive specs. - * @ngInject * @ngdoc directive * @ngname gmfObjecteditingtools */ @@ -134,7 +129,6 @@ function objectEditingToolsComponent() { templateUrl: 'gmf/objectediting/toolsComponent', }; } - myModule.directive('gmfObjecteditingtools', objectEditingToolsComponent); /** @@ -150,7 +144,6 @@ const NAMESPACE = 'oet'; * @param {import('gmf/options').gmfObjectEditingToolsOptions} gmfObjectEditingToolsOptions The options. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname GmfObjecteditingtoolsController */ @@ -235,14 +228,12 @@ export function Controller($scope, ngeoToolActivateMgr, gmfObjectEditingToolsOpt * @type {boolean} */ this.drawActive = false; - this.registerTool_('drawActive', ObjecteditingProcessType.ADD); /** * @type {boolean} */ this.eraseActive = false; - this.registerTool_('eraseActive', ObjecteditingProcessType.DELETE); /** @@ -262,11 +253,9 @@ export function Controller($scope, ngeoToolActivateMgr, gmfObjectEditingToolsOpt */ this.triangleRadius = oeToolsOptions.regularPolygonRadius !== undefined ? oeToolsOptions.regularPolygonRadius : 100; - this.registerTool_('drawTriangleActive', ObjecteditingProcessType.ADD); this.registerTool_('copyFromActive', ObjecteditingProcessType.ADD, true); this.registerTool_('deleteFromActive', ObjecteditingProcessType.DELETE, true); - $scope.$on('$destroy', this.handleDestroy_.bind(this)); } @@ -309,17 +298,14 @@ Controller.prototype.$onInit = function () { */ Controller.prototype.registerTool_ = function (toolActiveName, process, opt_requiresLayer) { const requiresLayer = opt_requiresLayer === true; - this.scope_.$watch( // @ts-ignore: Strange behivior... () => this[toolActiveName], this.handleToolActiveChange_.bind(this, process, requiresLayer), ); - const group = `${NAMESPACE}-${olUtilGetUid(this)}`; const toolActivate = new ngeoMiscToolActivate(this, toolActiveName); this.ngeoToolActivateMgr_.registerTool(group, toolActivate, false); - this.toolActiveNames_.push(toolActiveName); }; @@ -349,9 +335,6 @@ Controller.prototype.handleToolActiveChange_ = function (process, requiresLayer, } this.active = active; }; - Controller.prototype.handleDestroy_ = function () {}; - myModule.controller('GmfObjecteditingtoolsController', Controller); - export default myModule; diff --git a/src/offline/Configuration.js b/src/offline/Configuration.js index e0ac83d70c22..f27709e45805 100644 --- a/src/offline/Configuration.js +++ b/src/offline/Configuration.js @@ -41,9 +41,8 @@ import localforage from 'localforage/src/localforage'; /** * implements {import('ngeo/offline/index').OfflineOnTileDownload} */ -export default class extends olObservable { +export default class _ngInjectAnonymousClass extends olObservable { /** - * @ngInject * @param {!angular.IScope} $rootScope The rootScope provider. * @param {!import('ngeo/map/BackgroundLayerMgr').MapBackgroundLayerManager} ngeoBackgroundLayerMgr * Background layer manager. @@ -51,7 +50,6 @@ export default class extends olObservable { */ constructor($rootScope, ngeoBackgroundLayerMgr, ngeoOfflineGutter) { super(); - this.localforage_ = this.createLocalforage(); this.configureLocalforage(); @@ -79,7 +77,9 @@ export default class extends olObservable { * @type {SerializerDeserializer} */ // @ts-ignore - this.serDes_ = new SerializerDeserializer({gutter: ngeoOfflineGutter}); + this.serDes_ = new SerializerDeserializer({ + gutter: ngeoOfflineGutter, + }); /** * @private @@ -137,7 +137,6 @@ export default class extends olObservable { traceGetSetItem(msg, key, promise) { return promise; } - createLocalforage() { if (location.search.includes('localforage=cordova')) { console.log('Using cordova localforage'); @@ -151,7 +150,6 @@ export default class extends olObservable { } return localforage; } - configureLocalforage() { this.localforage_.config({ 'name': 'ngeoOfflineStorage', @@ -210,7 +208,7 @@ export default class extends olObservable { * @returns {string} A key identifying an offline layer and used during restore. */ getLayerKey(layerItem) { - return /** @type {string} */ (layerItem.layer.get('label')); + return /** @type {string} */ layerItem.layer.get('label'); } /** @@ -220,7 +218,6 @@ export default class extends olObservable { */ onTileDownloadSuccess(progress, tile) { this.dispatchProgress_(progress); - if (tile.response) { return this.setItem(normalizeURL(tile.url), tile.response); } @@ -327,7 +324,6 @@ export default class extends olObservable { } else if (layer instanceof olLayerVector) { layerType = 'vector'; } - const backgroundLayer = this.ngeoBackgroundLayerMgr_.get(map) === layer; layersItems.push({ backgroundLayer, @@ -368,7 +364,8 @@ export default class extends olObservable { content = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='; } - /** @type {HTMLImageElement} */ (imageTile.getImage()).src = content; + /** @type {HTMLImageElement} */ + imageTile.getImage().src = content; }); }; return tileLoadFunction; @@ -398,3 +395,4 @@ export default class extends olObservable { return 11; } } +_ngInjectAnonymousClass.$inject = ['$rootScope', 'ngeoBackgroundLayerMgr', 'ngeoOfflineGutter']; diff --git a/src/offline/Downloader.js b/src/offline/Downloader.js index b696fb80ac76..c0d01bcbca65 100644 --- a/src/offline/Downloader.js +++ b/src/offline/Downloader.js @@ -37,10 +37,8 @@ function magnitude2(a, b) { } return magnitudeSquared; } - const Downloader = class { /** - * @ngInject * @param {import('ngeo/offline/Configuration').default} ngeoOfflineConfiguration * A service for customizing offline behavior. */ @@ -57,7 +55,6 @@ const Downloader = class { */ this.tileDownloader_ = null; } - cancel() { if (this.tileDownloader_) { this.tileDownloader_.cancel(); @@ -69,9 +66,8 @@ const Downloader = class { * @param {import('./index').OfflineTile[]} queue Queue of tiles to download. */ queueLayerTiles_(layerMetadata, queue) { - const source = /** @type {olSourceTileWMS|olSourceWMTS} */ (layerMetadata.source); + const source = /** @type {olSourceTileWMS|olSourceWMTS} */ layerMetadata.source; const {map, extentByZoom} = layerMetadata; - if (!source) { return; } @@ -79,7 +75,6 @@ const Downloader = class { const projection = map.getView().getProjection(); const tileGrid = source.getTileGrid(); const tileUrlFunction = source.getTileUrlFunction(); - console.assert(extentByZoom); for (const extentZoom of extentByZoom) { const z = extentZoom.zoom; @@ -113,16 +108,18 @@ const Downloader = class { } const url = tileUrlFunction(coord, DEVICE_PIXEL_RATIO, projection); console.assert(url); - if (url) { /** * @type {import('./index').OfflineTile} */ - const tile = {coord, url, response: null}; + const tile = { + coord, + url, + response: null, + }; queueByZ.push(tile); } }); - const centerTileCoord = [z, (minX + maxX) / 2, (minY + maxY) / 2]; queueByZ.sort((a, b) => magnitude2(a.coord, centerTileCoord) - magnitude2(b.coord, centerTileCoord)); queue.push(...queueByZ); @@ -167,7 +164,6 @@ const Downloader = class { layerSerialization: layerItem.layerSerialization, key: this.configuration_.getLayerKey(layerItem), }); - layerItem.extentByZoom.forEach((obj) => { const zoom = obj.zoom; if (!zooms.includes(zoom)) { @@ -185,21 +181,16 @@ const Downloader = class { zooms: zooms.sort((a, b) => (a < b ? -1 : 1)), }; const setOfflineContentPromise = this.configuration_.setItem('offline_content', persistentObject); - const maxDownloads = this.configuration_.getMaxNumberOfParallelDownloads(); this.tileDownloader_ = new TilesDownloader(queue, this.configuration_, maxDownloads); const tileDownloadPromise = this.tileDownloader_.download(); - const allPromise = Promise.all([setOfflineContentPromise, tileDownloadPromise]); const setHasOfflineData = () => this.configuration_.setHasOfflineData(true); allPromise.then(setHasOfflineData, setHasOfflineData); return allPromise; } }; - const name = 'offlineDownloader'; Downloader.module = angular.module(name, []).service(name, Downloader); - const exports = Downloader; - export default exports; diff --git a/src/offline/Mode.js b/src/offline/Mode.js index 8ac4e652af31..29f46e5b0229 100644 --- a/src/offline/Mode.js +++ b/src/offline/Mode.js @@ -20,12 +20,10 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - class Mode { /** * @param {import('ngeo/offline/Configuration').default} ngeoOfflineConfiguration * ngeo offline configuration service. - * @ngInject * @ngdoc service * @ngname ngeoOfflineState */ @@ -99,12 +97,11 @@ class Mode { return this.ngeoOfflineConfiguration_.hasOfflineData(); } } - +Mode.$inject = ['ngeoOfflineConfiguration']; /** * @type {!angular.IModule} */ const myModule = angular.module('ngeoOfflineMode', []); myModule.service('ngeoOfflineMode', Mode); Mode.module = myModule; - export default Mode; diff --git a/src/offline/NetworkStatus.js b/src/offline/NetworkStatus.js index e2c5b650e881..2610409b0eac 100644 --- a/src/offline/NetworkStatus.js +++ b/src/offline/NetworkStatus.js @@ -1,3 +1,4 @@ +configFunction_.$inject = ['$httpProvider']; // The MIT License (MIT) // // Copyright (c) 2018-2024 Camptocamp SA @@ -21,7 +22,6 @@ import ngeoMiscDebounce from 'ngeo/misc/debounce'; import angular from 'angular'; - const Service = class { /** * This service watches the status of network connection. @@ -37,7 +37,6 @@ const Service = class { * * During offline mode we test every 2 sec if we are back online. * - * @ngInject * @param {!jQuery} $document Angular document service. * @param {angular.IWindowService} $window Angular window service. * @param {angular.ITimeoutService} $timeout Angular timeout service. @@ -92,10 +91,8 @@ const Service = class { * @type {angular.IPromise|undefined} */ this.promise_; - this.initialize_(); } - initialize_() { this.offline_ = !this.$window_.navigator.onLine; @@ -183,14 +180,11 @@ const Service = class { return !!this.offline_; } }; - const name = 'ngeoNetworkStatus'; - Service.module = angular.module(name, [ngeoMiscDebounce.name]); Service.module.service(name, Service); /** - * @ngInject * @param {angular.IQService} $q The Angular $q service. * @param {import('ngeo/misc/debounce').miscDebounce} ngeoDebounce ngeo debounce service. * @param {Service} ngeoNetworkStatus ngeo network status service. @@ -214,10 +208,11 @@ const httpInterceptor = function ($q, ngeoDebounce, ngeoNetworkStatus) { }, }; }; +httpInterceptor.$inject = ['$q', 'ngeoDebounce', 'ngeoNetworkStatus']; +httpInterceptor.$inject = ['$q', 'ngeoDebounce', 'ngeoNetworkStatus']; Service.module.factory('httpInterceptor', httpInterceptor); /** - * @ngInject * @private * @param {angular.IHttpProvider} $httpProvider . */ @@ -225,7 +220,5 @@ function configFunction_($httpProvider) { $httpProvider.interceptors.push('httpInterceptor'); } Service.module.config(configFunction_); - const exports = Service; - export default exports; diff --git a/src/offline/Restorer.js b/src/offline/Restorer.js index 565c97ddb0df..e93aa2124b18 100644 --- a/src/offline/Restorer.js +++ b/src/offline/Restorer.js @@ -21,10 +21,8 @@ import ngeoMapBackgroundLayerMgr from 'ngeo/map/BackgroundLayerMgr'; import angular from 'angular'; - class Restorer { /** - * @ngInject * @param {import('ngeo/offline/Configuration').default} ngeoOfflineConfiguration * A service for customizing offline behavior. * @param {import('ngeo/map/BackgroundLayerMgr').MapBackgroundLayerManager} ngeoBackgroundLayerMgr @@ -74,10 +72,8 @@ class Restorer { return offlineContent.extent; } } - +Restorer.$inject = ['ngeoOfflineConfiguration', 'ngeoBackgroundLayerMgr']; const name = 'ngeoOfflineRestorer'; Restorer.module = angular.module(name, [ngeoMapBackgroundLayerMgr.name]).service(name, Restorer); - const exports = Restorer; - export default exports; diff --git a/src/offline/ServiceManager.js b/src/offline/ServiceManager.js index 2f9a8745f471..c21d45d6b05a 100644 --- a/src/offline/ServiceManager.js +++ b/src/offline/ServiceManager.js @@ -20,12 +20,10 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - class ServiceManager { /** * @param {angular.auto.IInjectorService} $injector Main injector. * @struct - * @ngInject * @ngdoc service * @ngname ngeoOfflineServiceManager */ @@ -94,7 +92,6 @@ class ServiceManager { setRestoreService(restoreLikeService) { this.restoreService_ = this.getOfflineService_(restoreLikeService, 'restore'); } - cancel() { if (!this.saveService_) { console.warn('You must register a saveService first'); @@ -131,8 +128,7 @@ class ServiceManager { return this.restoreService_.restore(map); } } - +ServiceManager.$inject = ['$injector']; ServiceManager.module = angular.module('ngeoOfflineServiceManager', []); ServiceManager.module.service('ngeoOfflineServiceManager', ServiceManager); - export default ServiceManager; diff --git a/src/offline/component.js b/src/offline/component.js index 9bd5f87be4bd..53642ba343dc 100644 --- a/src/offline/component.js +++ b/src/offline/component.js @@ -33,7 +33,6 @@ import MaskLayer from './Mask'; * @type {!angular.IModule} */ const myModule = angular.module('ngeoOffline', [ngeoMessageModalComponent.name]); - myModule.value( 'ngeoOfflineTemplateUrl', /** @@ -46,16 +45,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'ngeo/offline/component.html'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/offline/component.html', require('./component.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/offline/component.html', require('./component.html')); + }, + ], ); /** @@ -63,8 +63,8 @@ myModule.run( * @param {!angular.IAttributes} $attrs Attributes. * @param {!function(!JQuery, !angular.IAttributes): string} ngeoOfflineTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject */ +ngeoOfflineTemplateUrl.$inject = ['$element', '$attrs', 'ngeoOfflineTemplateUrl']; function ngeoOfflineTemplateUrl($element, $attrs, ngeoOfflineTemplateUrl) { return ngeoOfflineTemplateUrl($element, $attrs); } @@ -101,10 +101,8 @@ const component = { controller: 'ngeoOfflineController', templateUrl: ngeoOfflineTemplateUrl, }; - myModule.component('ngeoOffline', component); - -export const Controller = class { +export class Controller { /** * @param {angular.ITimeoutService} $timeout Angular timeout service. * @param {import('ngeo/offline/ServiceManager').default} ngeoOfflineServiceManager @@ -113,7 +111,6 @@ export const Controller = class { * ngeo offline configuration service. * @param {import('ngeo/offline/Mode').default} ngeoOfflineMode Offline mode manager. * @param {import('ngeo/offline/NetworkStatus').default} ngeoNetworkStatus ngeo network status service. - * @ngInject * @ngdoc controller * @ngname ngeoOfflineController */ @@ -186,7 +183,6 @@ export const Controller = class { * @private */ this.overlayCollection_ = new olCollection(); - this.featuresOverlay_.setFeatures(this.overlayCollection_); /** @@ -315,24 +311,29 @@ export const Controller = class { this.$timeout_(() => {}, 0); // FIXME: force redraw }; } - $onInit() { this.offlineMode.registerComponent(this); this.ngeoOfflineConfiguration_.on( - /** @type {import('ol/Observable').EventTypes} */ ('progress'), - /** @type {function(?): ?} */ (this.progressCallback_), + /** @type {import('ol/Observable').EventTypes} */ 'progress', + /** @type {function(?): ?} */ this.progressCallback_, ); this.maskMargin = this.maskMargin || 100; this.minZoom = this.minZoom || 10; this.maxZoom = this.maxZoom || 15; // @ts-ignore: extentInMeters does not exists... - this.maskLayer_ = new MaskLayer({extentInMeters: this.extentSize}, {margin: this.maskMargin}); + this.maskLayer_ = new MaskLayer( + { + extentInMeters: this.extentSize, + }, + { + margin: this.maskMargin, + }, + ); } - $onDestroy() { this.ngeoOfflineConfiguration_.un( - /** @type {import('ol/Observable').EventTypes} */ ('progress'), - /** @type {function(?): ?} */ (this.progressCallback_), + /** @type {import('ol/Observable').EventTypes} */ 'progress', + /** @type {function(?): ?} */ this.progressCallback_, ); } @@ -364,10 +365,8 @@ export const Controller = class { toggleViewExtentSelection(finished) { this.menuDisplayed = false; this.selectingExtent = !this.selectingExtent; - this.map.removeLayer(this.maskLayer_); this.removeZoomConstraints_(); - if (this.selectingExtent && !this.map.getLayers().getArray().includes(this.maskLayer_)) { this.addZoomConstraints_(); this.map.addLayer(this.maskLayer_); @@ -437,7 +436,9 @@ export const Controller = class { if (size === undefined) { throw new Error('Missing size'); } - this.map.getView().fit(extent, {size}); + this.map.getView().fit(extent, { + size, + }); this.menuDisplayed = false; this.displayExtent_(); this.offlineMode.enable(); @@ -487,7 +488,6 @@ export const Controller = class { if (this.networkStatus.isDisconnected()) { this.menuDisplayed = false; } - const reloadIfInOfflineMode = () => { if (this.offlineMode.isEnabled()) { this.deactivateOfflineMode(); @@ -515,10 +515,8 @@ export const Controller = class { addZoomConstraints_() { const view = this.map.getView(); const zoom = view.getZoom() || 0; - this.originalMinZoom = view.getMinZoom(); this.originalMaxZoom = view.getMaxZoom(); - if (zoom < this.minZoom) { view.setZoom(this.minZoom); } else if (zoom > this.maxZoom) { @@ -561,15 +559,19 @@ export const Controller = class { const halfLength = Math.ceil(this.extentSize || this.getExtentSize_()) / 2; return this.maskLayer_.createExtent(center, halfLength); } - getExtentSize_() { const mapSize = this.map.getSize() || [150, 150]; const maskSizePixel = DEVICE_PIXEL_RATIO * Math.min(mapSize[0], mapSize[1]) - this.maskMargin * 2; const maskSizeMeter = (maskSizePixel * (this.map.getView().getResolution() || 1)) / DEVICE_PIXEL_RATIO; return maskSizeMeter; } -}; - +} +Controller.$inject = [ + '$timeout', + 'ngeoOfflineServiceManager', + 'ngeoOfflineConfiguration', + 'ngeoOfflineMode', + 'ngeoNetworkStatus', +]; myModule.controller('ngeoOfflineController', Controller); - export default myModule; diff --git a/src/olcs/Service.js b/src/olcs/Service.js index 62ea162eaabd..2d766dfa6aa3 100644 --- a/src/olcs/Service.js +++ b/src/olcs/Service.js @@ -29,9 +29,8 @@ import {toDegrees} from 'ol/math'; /** * @hidden */ -export const OlcsService = class { +export class OlcsService { /** - * @ngInject * @param {import('ngeo/misc/debounce').miscDebounce} ngeoDebounce ngeo debounce * service. * @param {import('ngeo/statemanager/Location').StatemanagerLocation} ngeoLocation ngeo location @@ -70,11 +69,9 @@ export const OlcsService = class { */ initialize(manager) { this.manager_ = manager; - this.manager_.on('load', () => { this.cameraToState_(); }); - if (this.ngeoStateManager_.getInitialBooleanValue('3d_enabled')) { this.initialStateToCamera_(); } @@ -96,13 +93,11 @@ export const OlcsService = class { throw new Error('Missing manager'); } const stateManager = this.ngeoStateManager_; - const lon = stateManager.getInitialNumberValue(Permalink3dParam.LON); const lat = stateManager.getInitialNumberValue(Permalink3dParam.LAT); const elevation = stateManager.getInitialNumberValue(Permalink3dParam.ELEVATION); const heading = stateManager.getInitialNumberValue(Permalink3dParam.HEADING) || 0; const pitch = stateManager.getInitialNumberValue(Permalink3dParam.PITCH) || 0; - if (!lon) { throw new Error('Missing lon'); } @@ -125,7 +120,6 @@ export const OlcsService = class { const manager = this.manager_; const scene = manager.getOl3d().getCesiumScene(); const camera = scene.camera; - camera.moveEnd.addEventListener( this.ngeoDebounce_( () => { @@ -143,7 +137,6 @@ export const OlcsService = class { true, ), ); - this.manager_.on('toggle', (event) => { if (!event.target.is3dEnabled()) { this.remove3dState_(); @@ -159,8 +152,8 @@ export const OlcsService = class { this.ngeoStateManager_.deleteParam(key); }); } -}; - +} +OlcsService.$inject = ['ngeoDebounce', 'ngeoLocation', 'ngeoStateManager']; /** * @type {angular.IModule} * @hidden @@ -168,5 +161,4 @@ export const OlcsService = class { const myModule = angular .module(name, [ngeoMiscDebounce.name, ngeoStatemanagerLocation.name, ngeoStatemanagerService.name]) .service('ngeoOlcsService', OlcsService); - export default myModule; diff --git a/src/olcs/controls3d.js b/src/olcs/controls3d.js index 33bd4ed59a5e..340a32c3b7a3 100644 --- a/src/olcs/controls3d.js +++ b/src/olcs/controls3d.js @@ -1,3 +1,4 @@ +ngeoOlcsControls3dTemplateUrlInjectable.$inject = ['$attrs', 'ngeoOlcsControls3dTemplateUrl']; // The MIT License (MIT) // // Copyright (c) 2017-2024 Camptocamp SA @@ -46,9 +47,8 @@ function shouldUpdate(older, newer) { /** * @hidden */ -export const Controller = class { +export class Controller { /** - * @ngInject * @param {JQuery} $element The element * @param {import('ngeo/olcs/Service').OlcsService} ngeoOlcsService The ol-cesium service. */ @@ -123,7 +123,6 @@ export const Controller = class { */ this.olcsService_ = ngeoOlcsService; } - updateWidget_() { if (!this.ol3dm) { throw new Error('Missing ol3dm'); @@ -145,7 +144,6 @@ export const Controller = class { this.rotateElement_(this.rotation3dEl_, newRotation); this.previousRotation_ = newRotation; } - const newViewMatrix = this.ol3dm.getCesiumViewMatrix(); if (!Cesium.Matrix4.equalsEpsilon(this.previousViewMatrix_, newViewMatrix, 1e-5)) { const newTilt = this.ol3dm.getTiltOnGlobe(); // this is expensive!! @@ -167,16 +165,13 @@ export const Controller = class { } } } - this.animationFrameRequestId_ = requestAnimationFrame(() => this.updateWidget_()); } - $onDestroy() { if (this.animationFrameRequestId_) { cancelAnimationFrame(this.animationFrameRequestId_); } } - $onInit() { if (this.minTilt === undefined) { this.minTilt = 0; @@ -257,13 +252,12 @@ export const Controller = class { easing: olEasing.easeOut, }); } -}; - +} +Controller.$inject = ['$element', 'ngeoOlcsService']; /** * @param {angular.IAttributes} $attrs Attributes. * @param {string} ngeoOlcsControls3dTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ @@ -274,16 +268,17 @@ function ngeoOlcsControls3dTemplateUrlInjectable($attrs, ngeoOlcsControls3dTempl const templateUrl = $attrs['ngeoOlcsControls3dTemplateUrl']; return templateUrl ? templateUrl : 'ngeo/olsc/controls3d'; } - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/olsc/controls3d', require('./controls3d.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/olsc/controls3d', require('./controls3d.html')); + }, + ], ); /** @@ -314,9 +309,6 @@ const olscControls3dComponent = { controller: Controller, templateUrl: ngeoOlcsControls3dTemplateUrlInjectable, }; - myModule.component('ngeoOlcsControls3d', olscControls3dComponent); - myModule.value('ngeoOlcsControls3dTemplateUrl', ''); - export default myModule; diff --git a/src/permalink/Permalink.js b/src/permalink/Permalink.js index 3d362dfbe372..ac106fdb50fc 100644 --- a/src/permalink/Permalink.js +++ b/src/permalink/Permalink.js @@ -1,3 +1,18 @@ +PermalinkService.$inject = [ + '$q', + '$timeout', + '$rootScope', + '$injector', + 'ngeoDebounce', + 'gettextCatalog', + 'ngeoEventHelper', + 'ngeoStateManager', + 'ngeoLocation', + 'gmfLayerBeingSwipe', + 'gmfPermalinkOptions', + 'gmfDataSourcesManager', + 'ngeoWMSTime', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -20,26 +35,19 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - import {PermalinkParam} from 'gmf/index'; - import gmfLayerBeingSwipe from 'gmf/datasource/LayerBeingSwipe'; - import gmfThemeManager, {ThemeEventType} from 'gmf/theme/Manager'; - import gmfThemeThemes, {findThemeByName, findGroupByName} from 'gmf/theme/Themes'; import ngeoPopover from 'ngeo/Popover'; - import ngeoDrawFeatures from 'ngeo/draw/features'; import gmfDataSourcesManager from 'gmf/datasource/Manager'; - import ngeoDatasourceGroup from 'ngeo/datasource/Group'; import {guessServiceTypeByUrl, Type} from 'ngeo/datasource/OGC'; import gmfDatasourceOGC from 'gmf/datasource/OGC'; import {Permalink3dParam} from 'ngeo/olcs/constants'; import ngeoFormatFeatureHash from 'ngeo/format/FeatureHash'; import ngeoFormatFeatureProperties from 'ngeo/format/FeatureProperties'; - import {LAYER_NODE_NAME_KEY} from 'ngeo/map/LayerHelper'; import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; import ngeoMiscDebounce from 'ngeo/misc/debounce'; @@ -55,7 +63,6 @@ import olGeomPoint from 'ol/geom/Point'; import olLayerGroup from 'ol/layer/Group'; import {CollectionEvent} from 'ol/Collection'; import {buildStyle} from 'ngeo/options'; - import user, {loginMessageRequired} from 'gmfapi/store/user'; /** @@ -281,7 +288,6 @@ const ParamPrefix = { * @param {import('gmf/datasource/Manager').DatasourceManager} gmfDataSourcesManager The gmf datasourcemanager * service. * @param {import('ngeo/misc/WMSTime').WMSTime} ngeoWMSTime The ngeo wmstime service - * @ngInject * @ngdoc service * @ngname gmfPermalink */ @@ -382,7 +388,6 @@ export function PermalinkService( * @type {?import('ngeo/query/Querent').Querent} */ this.ngeoQuerent_ = $injector.has('ngeoQuerent') ? $injector.get('ngeoQuerent') : null; - if (gmfPermalinkOptions.useLocalStorage === true) { // localStorage is deactivated by default this.ngeoStateManager_.setUseLocalStorage(true); @@ -551,7 +556,7 @@ export function PermalinkService( * @param {import('ngeo/layertree/Controller').LayertreeController} ctrl */ (ctrl) => { - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (ctrl.node); + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ ctrl.node; if (groupNode.children === undefined) { const param = `${ParamPrefix.TREE_ENABLE}${ctrl.node.name}`; if ((groupNode.metadata.isChecked === true) !== visible) { @@ -570,7 +575,7 @@ export function PermalinkService( * @param {import('ngeo/layertree/Controller').LayertreeController} ctrl */ (ctrl) => { - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (ctrl.node); + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ ctrl.node; if (groupNode.children === undefined && ctrl.getState() === 'on') { gmfLayerNames.push(ctrl.node.name); } @@ -584,9 +589,7 @@ export function PermalinkService( /** @type {Object} */ const newState = {}; const opacity = treeCtrl.layer.getOpacity(); - const stateName = `${ - treeCtrl.parent.node.mixed ? ParamPrefix.TREE_OPACITY : ParamPrefix.TREE_GROUP_OPACITY - }${treeCtrl.node.name}`; + const stateName = `${treeCtrl.parent.node.mixed ? ParamPrefix.TREE_OPACITY : ParamPrefix.TREE_GROUP_OPACITY}${treeCtrl.node.name}`; newState[stateName] = opacity; this.ngeoStateManager_.updateState(newState); }); @@ -602,12 +605,10 @@ export function PermalinkService( } this.addNgeoFeature_(feature); }); - this.ngeoFeatures_.extend(features); listen(this.ngeoFeatures_, 'add', this.handleNgeoFeaturesAdd_, this); listen(this.ngeoFeatures_, 'remove', this.handleNgeoFeaturesRemove_, this); } - if (this.featureHelper_) { this.rootScope_.$on('$localeChangeSuccess', () => { features.forEach((feature) => { @@ -618,7 +619,6 @@ export function PermalinkService( }); }); } - if (this.gmfThemeManager_) { this.rootScope_.$on(ThemeEventType.THEME_NAME_SET, (event, name) => { this.setThemeInUrl_(name); @@ -637,7 +637,6 @@ export function PermalinkService( * @type {?angular.IPromise} */ this.setExternalDataSourcesStatePromise_ = null; - if (this.ngeoQuerent_ && this.gmfExternalDataSourcesManager_) { // First, load the external data sources that are defined in the url this.initExternalDataSources_() @@ -683,7 +682,6 @@ export function PermalinkService( }) .catch((err) => console.error(err)); } - this.initLayers_(); } @@ -737,7 +735,6 @@ PermalinkService.prototype.handleMapSwipeValue_ = function () { PermalinkService.prototype.getMapCenter = function () { const x = this.ngeoStateManager_.getInitialNumberValue(PermalinkParam.MAP_X); const y = this.ngeoStateManager_.getInitialNumberValue(PermalinkParam.MAP_Y); - if (x !== undefined && y !== undefined && !isNaN(x) && !isNaN(y)) { const center = [x, y]; if (this.sourceProjections_ !== null && this.ngeoAutoProjection_) { @@ -853,21 +850,17 @@ PermalinkService.prototype.setMapTooltip = function (tooltipText, opt_center) { if (!Array.isArray(tooltipPosition)) { throw new Error('Wrong tooltipPosition type'); } - const div = $('
', { 'class': 'gmf-permalink-tooltip', 'text': tooltipText, })[0]; - if (this.mapTooltip_ !== null) { this.map_.removeOverlay(this.mapTooltip_); } - this.mapTooltip_ = new ngeoPopover({ element: div, position: tooltipPosition, }); - this.map_.addOverlay(this.mapTooltip_); }; @@ -901,7 +894,6 @@ PermalinkService.prototype.setDimensions = function (dimensions) { } dimensions[key.slice(ParamPrefix.DIMENSIONS.length)] = value; } - this.rootScope_.$watchCollection( () => dimensions, (dimensions) => { @@ -928,12 +920,10 @@ PermalinkService.prototype.setMap = function (map) { if (map === this.map_) { return; } - if (this.map_) { this.unregisterMap_(); this.map_ = null; } - if (map) { this.map_ = map; if (this.gmfObjectEditingManager_) { @@ -1101,7 +1091,6 @@ PermalinkService.prototype.handleBackgroundLayerManagerChange_ = function () { const object = {}; object[PermalinkParam.BG_LAYER] = layerName; this.ngeoStateManager_.updateState(object); - const backgroundLayer = this.ngeoBackgroundLayerMgr_.getOpacityBgLayer(this.map_); if (backgroundLayer) { const opacity = this.getBackgroundLayerOpacity(); @@ -1143,7 +1132,7 @@ PermalinkService.prototype.refreshFirstLevelGroups = function () { throw new Error('Missing gmfTreeManager_.rootCtrl'); } // Get first-level-groups order - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (this.gmfTreeManager_.rootCtrl.node); + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ this.gmfTreeManager_.rootCtrl.node; const groupNodes = groupNode.children; const orderedNames = groupNodes ? groupNodes.map((node) => node.name) : []; @@ -1165,9 +1154,9 @@ PermalinkService.prototype.refreshLayerTime = function (treeCtrl, time) { /** @type {Object} */ const newState = {}; const stateName = `${ParamPrefix.TREE_TIME}${treeCtrl.node.name}`; - const timenode = /** @type {import('gmf/themes').GmfGroup|!import('gmf/themes').GmfLayerWMS} */ ( - treeCtrl.node - ); + const timenode = + /** @type {import('gmf/themes').GmfGroup|!import('gmf/themes').GmfLayerWMS} */ + treeCtrl.node; const timeParam = this.ngeoWMSTime_.formatWMSTimeParam(timenode.time, time); newState[stateName] = timeParam; this.ngeoStateManager_.updateState(newState); @@ -1232,7 +1221,6 @@ PermalinkService.prototype.defaultThemeName = function () { if (tn) { return tn; } - const defaultTheme = this.defaultThemeNameFromFunctionalities(); if (defaultTheme !== null) { return defaultTheme; @@ -1242,7 +1230,6 @@ PermalinkService.prototype.defaultThemeName = function () { if (this.defaultTheme_) { return this.defaultTheme_; } - return null; }; @@ -1265,11 +1252,9 @@ PermalinkService.prototype.defaultThemeNameFromFunctionalities = function () { } return null; }; - PermalinkService.prototype.initLayers_ = function () { const initialUri = window.location.href; let authenticationRequired = false; - if (!this.gmfThemes_) { return; } @@ -1287,9 +1272,7 @@ PermalinkService.prototype.initLayers_ = function () { } return false; }); - const themeName = this.defaultThemeName(); - if (this.gmfThemeManager_) { this.gmfThemeManager_.setThemeName(this.gmfThemeManager_.modeFlush ? themeName : ''); } @@ -1316,21 +1299,20 @@ PermalinkService.prototype.initLayers_ = function () { } }); } - if (this.gmfTreeManager_) { this.gmfTreeManager_.setFirstLevelGroups(firstLevelGroups); } - this.$timeout_(() => { /** * @type {string[]} */ const used_tree_enable = []; - if (!this.gmfTreeManager_ || !this.gmfTreeManager_.rootCtrl) { // we don't have any layertree if (authenticationRequired && this.gmfUser && this.gmfUser.roles === null) { - this.rootScope_.$broadcast('authenticationrequired', {url: initialUri}); + this.rootScope_.$broadcast('authenticationrequired', { + url: initialUri, + }); user.setLoginMessage(loginMessageRequired); } return; @@ -1349,8 +1331,8 @@ PermalinkService.prototype.initLayers_ = function () { if (treeCtrl.isRoot) { return undefined; } - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); - const parentGroupNode = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.parent.node); + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; + const parentGroupNode = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.parent.node; const opacity = this.ngeoStateManager_.getInitialNumberValue( parentGroupNode.mixed ? `${ParamPrefix.TREE_OPACITY}${treeCtrl.node.name}` @@ -1372,13 +1354,12 @@ PermalinkService.prototype.initLayers_ = function () { this.gmfLayerBeingSwipe_.layer = treeCtrl.layer; } } - const timenode = /** @type {import('gmf/themes').GmfGroup|!import('gmf/themes').GmfLayerWMS} */ ( - treeCtrl.node - ); + const timenode = + /** @type {import('gmf/themes').GmfGroup|!import('gmf/themes').GmfLayerWMS} */ + treeCtrl.node; if (timenode && timenode.time) { this.setNodeTime_(treeCtrl); } - if (treeCtrl.parent.node && parentGroupNode.mixed && groupNode.children == undefined) { // Layer of a mixed group const param = `${ParamPrefix.TREE_ENABLE}${treeCtrl.node.name}`; @@ -1402,7 +1383,7 @@ PermalinkService.prototype.initLayers_ = function () { * @returns {LayertreeVisitorDecision|undefined} the result */ const visitor = (treeCtrl) => { - const groupNode = /** @type {import('gmf/themes').GmfGroup} */ (treeCtrl.node); + const groupNode = /** @type {import('gmf/themes').GmfGroup} */ treeCtrl.node; if (groupNode.children === undefined) { const enable = groupLayersArray.includes(treeCtrl.node.name); if (enable) { @@ -1429,14 +1410,15 @@ PermalinkService.prototype.initLayers_ = function () { } }); }); - for (const key of tree_enable_keys) { if (!used_tree_enable.includes(key)) { authenticationRequired = true; } } if (authenticationRequired && this.gmfUser && this.gmfUser.roles === null) { - this.rootScope_.$broadcast('authenticationrequired', {url: initialUri}); + this.rootScope_.$broadcast('authenticationrequired', { + url: initialUri, + }); user.setLoginMessage(loginMessageRequired); } }).catch((err) => console.error(err)); @@ -1529,10 +1511,8 @@ PermalinkService.prototype.getWfsPermalinkData_ = function () { if (!wfsLayer) { return null; } - const numGroups = this.ngeoLocation_.getParamAsInt(PermalinkParam.WFS_NGROUPS); const paramKeys = this.ngeoLocation_.getParamKeysWithPrefix(ParamPrefix.WFS); - const filterGroups = []; let filterGroup; if (numGroups === undefined) { @@ -1551,14 +1531,11 @@ PermalinkService.prototype.getWfsPermalinkData_ = function () { } } } - if (filterGroups.length == 0) { return null; } - const showFeaturesParam = this.ngeoLocation_.getParam(PermalinkParam.WFS_SHOW_FEATURES); const showFeatures = !(showFeaturesParam === '0' || showFeaturesParam === 'false'); - return { wfsType: wfsLayer, showFeatures: showFeatures, @@ -1578,7 +1555,6 @@ PermalinkService.prototype.createFilterGroup_ = function (prefix, paramKeys) { * @type {import('ngeo/statemanager/WfsPermalink').WfsPermalinkFilter[]} */ const filters = []; - paramKeys.forEach((paramKey) => { if ( paramKey == PermalinkParam.WFS_LAYER || @@ -1592,7 +1568,6 @@ PermalinkService.prototype.createFilterGroup_ = function (prefix, paramKeys) { if (!value) { return; } - const condition = value.split(','); const filter = { property: paramKey.replace(prefix, ''), @@ -1600,8 +1575,11 @@ PermalinkService.prototype.createFilterGroup_ = function (prefix, paramKeys) { }; filters.push(filter); }); - - return filters.length > 0 ? {filters} : null; + return filters.length > 0 + ? { + filters, + } + : null; }; // === External Data Sources management === @@ -1619,35 +1597,26 @@ PermalinkService.prototype.initExternalDataSources_ = function () { } const ngeoQuerent = this.ngeoQuerent_; const gmfExtDSManager = this.gmfExternalDataSourcesManager_; - const promises = []; - const layerNamesString = this.ngeoStateManager_.getInitialStringValue( PermalinkParam.EXTERNAL_DATASOURCES_NAMES, ); const urlsString = this.ngeoStateManager_.getInitialStringValue(PermalinkParam.EXTERNAL_DATASOURCES_URLS); - if (layerNamesString && urlsString) { const layerNames = layerNamesString.split(ExtDSSeparator.LIST); const urls = urlsString.split(ExtDSSeparator.LIST); - for (let i = 0, ii = urls.length; i < ii; i++) { // Stop iterating if we do not have the same number of urls and layer // names const groupLayerNamesString = layerNames[i]; - if (!groupLayerNamesString) { break; } - const groupLayerNames = groupLayerNamesString.split(ExtDSSeparator.NAMES); const url = urls[i]; - const serviceType = guessServiceTypeByUrl(url); - const getCapabilitiesDefer = this.q_.defer(); promises.push(getCapabilitiesDefer.promise); - if (serviceType === Type.WMS) { ngeoQuerent.wmsGetCapabilities(url).then( (capabilities) => { @@ -1696,7 +1665,6 @@ PermalinkService.prototype.initExternalDataSources_ = function () { } } } - return this.q_.all(promises).then( (responses) => { for (const response of responses) { @@ -1820,7 +1788,6 @@ PermalinkService.prototype.setExternalDataSourcesState_ = function () { if (this.setExternalDataSourcesStatePromise_) { this.$timeout_.cancel(this.setExternalDataSourcesStatePromise_); } - this.setExternalDataSourcesStatePromise_ = this.$timeout_(() => { if (!this.gmfExternalDataSourcesManager_) { throw new Error('Missing gmfExternalDataSourcesManager'); @@ -1854,9 +1821,8 @@ PermalinkService.prototype.setExternalDataSourcesState_ = function () { // (2b) layer names const wmtsGroupLayerNames = []; - for (const wmtsDataSource of /** @type {import('ngeo/datasource/OGC').OGC[]} */ ( - wmtsGroup.dataSources - )) { + for (const wmtsDataSource of /** @type {import('ngeo/datasource/OGC').OGC[]} */ + wmtsGroup.dataSources) { if (!wmtsDataSource.wmtsLayer) { throw new Error('Missing wmtsDataSource.wmtsLayer'); } @@ -1937,13 +1903,10 @@ PermalinkService.prototype.setNodeTime_ = function (treeCtrl) { const time = this.ngeoStateManager_.getInitialStringValue(`${ParamPrefix.TREE_TIME}${treeCtrl.node.name}`); if (time) { const bounds = time.split('/'); - const node = /** @type {import('gmf/themes').GmfGroup|!import('gmf/themes').GmfLayerWMS} */ ( - treeCtrl.node - ); + const node = /** @type {import('gmf/themes').GmfGroup|!import('gmf/themes').GmfLayerWMS} */ treeCtrl.node; node.time.minDefValue = bounds[0]; node.time.maxDefValue = bounds[1]; const dataSource = this.gmfDataSourcesManager_.getDatasource(olUtilGetUid(treeCtrl.node)); - if (dataSource) { if (!(dataSource instanceof gmfDatasourceOGC)) { throw new Error('Wrong dataSource type'); @@ -1977,19 +1940,17 @@ const myModule = angular.module('gmfPermalink', [ ngeoMiscEventHelper.name, ngeoStatemanagerModule.name, ]); - myModule.service('gmfPermalink', PermalinkService); /** Configure the ngeo state manager */ (function () { const regexp = []; for (const key1 in ParamPrefix) { - regexp.push(new RegExp(`${/** @type {Object} */ (ParamPrefix)[key1]}.*`)); + regexp.push(new RegExp(`${/** @type {Object} */ ParamPrefix[key1]}.*`)); } for (const key2 in PermalinkParam) { - regexp.push(new RegExp(/** @type {Object} */ (ParamPrefix)[key2])); + regexp.push(new RegExp(/** @type {Object} */ ParamPrefix[key2])); } ngeoStatemanagerService.value('ngeoUsedKeyRegexp', regexp); })(); - export default myModule; diff --git a/src/permalink/ShareService.js b/src/permalink/ShareService.js index c4098f32fda0..befe723f14e1 100644 --- a/src/permalink/ShareService.js +++ b/src/permalink/ShareService.js @@ -1,3 +1,4 @@ +PermalinkShareService.$inject = ['$http', 'gmfShortenerCreateUrl']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -45,7 +46,6 @@ import angular from 'angular'; * @param {angular.IHttpService} $http Angular http service. * @param {string} gmfShortenerCreateUrl URL for the shortener API * @class - * @ngInject * @ngname gmfShareService * @hidden */ @@ -70,10 +70,9 @@ export function PermalinkShareService($http, gmfShortenerCreateUrl) { * shortened or the promise attached to the shortener API request */ PermalinkShareService.prototype.getShortUrl = function (url) { - const params = /** @type {ShortenerAPIRequestParams} */ ({ + const params = /** @type {ShortenerAPIRequestParams} */ { url, - }); - + }; if (!this.gmfShortenerCreateUrl_) { return { data: { @@ -82,7 +81,6 @@ PermalinkShareService.prototype.getShortUrl = function (url) { status: 200, }; } - return this.postShortUrl_(params); }; @@ -96,15 +94,13 @@ PermalinkShareService.prototype.getShortUrl = function (url) { * @returns {angular.IHttpPromise} the promise attached to the shortener API request */ PermalinkShareService.prototype.sendShortUrl = function (shortUrl, email, opt_message) { - const params = /** @type {ShortenerAPIRequestParams} */ ({ + const params = /** @type {ShortenerAPIRequestParams} */ { url: shortUrl, email: email, - }); - + }; if (opt_message) { params.message = opt_message; } - return this.postShortUrl_(params); }; @@ -115,7 +111,9 @@ PermalinkShareService.prototype.sendShortUrl = function (shortUrl, email, opt_me PermalinkShareService.prototype.postShortUrl_ = function (params) { // Override default behavior of $http.post method (sending data in json format) return this.$http_.post(this.gmfShortenerCreateUrl_, $.param(params), { - headers: {'Content-Type': 'application/x-www-form-urlencoded'}, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, }); }; @@ -142,7 +140,5 @@ export const URL_PATH_MAX_LEN = 2048; * @hidden */ const myModule = angular.module('gmfShareService', []); - myModule.service('gmfShareService', PermalinkShareService); - export default myModule; diff --git a/src/permalink/shareComponent.js b/src/permalink/shareComponent.js index cd388052a9a3..67cdec1ead46 100644 --- a/src/permalink/shareComponent.js +++ b/src/permalink/shareComponent.js @@ -32,18 +32,18 @@ const myModule = angular.module('gmfPermalinkShareComponent', [ gmfPermalinkShareService.name, ngeoStatemanagerLocation.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/permalink/shareComponent', require('./shareComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/permalink/shareComponent', require('./shareComponent.html')); + }, + ], ); - myModule.value( 'gmfPermalinkShareTemplateUrl', /** @@ -60,10 +60,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} gmfPermalinkShareTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfPermalinkShareTemplateUrl.$inject = ['$attrs', 'gmfPermalinkShareTemplateUrl']; function gmfPermalinkShareTemplateUrl($attrs, gmfPermalinkShareTemplateUrl) { return gmfPermalinkShareTemplateUrl($attrs); } @@ -96,7 +96,6 @@ export class ShareComponentController { * @param {angular.IAttributes} $attrs Attributes. * @param {import('gmf/options').gmfShareOptions} gmfShareOptions The options. * @class - * @ngInject * @ngdoc controller * @ngname GmfShareController */ @@ -152,7 +151,6 @@ export class ShareComponentController { * @private */ this.permalink_ = this.ngeoLocation_.getUriString(); - const path = ngeoLocation.getPath(); if (!path) { throw new Error('Missing path'); @@ -181,7 +179,6 @@ export class ShareComponentController { * @type {boolean} */ this.errorOnGetShortUrl = false; - this.getShortUrl(); } @@ -191,7 +188,7 @@ export class ShareComponentController { getShortUrl() { this.$q_.when(this.gmfShareService_.getShortUrl(this.permalink_)).then( (resp) => { - this.shortLink = /** @type {angular.IHttpResponse<{short_url: string}>} */ (resp).data.short_url; + this.shortLink = /** @type {angular.IHttpResponse<{short_url: string}>} */ resp.data.short_url; this.errorOnGetShortUrl = false; }, (resp) => { @@ -224,7 +221,13 @@ export class ShareComponentController { } } } - +ShareComponentController.$inject = [ + '$scope', + 'ngeoLocation', + 'gmfShareService', + '$q', + '$attrs', + 'gmfShareOptions', +]; myModule.controller('GmfShareController', ShareComponentController); - export default myModule; diff --git a/src/print/Service.js b/src/print/Service.js index 4cb35c16ee40..497ba16b6406 100644 --- a/src/print/Service.js +++ b/src/print/Service.js @@ -1,3 +1,5 @@ +PrintService.$inject = ['url', '$http', 'gettextCatalog', 'ngeoLayerHelper']; +createPrintServiceFactory.$inject = ['$http', 'gettextCatalog', 'ngeoLayerHelper']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -126,7 +128,7 @@ export function PrintService(url, $http, gettextCatalog, ngeoLayerHelper) { */ PrintService.prototype.cancel = function (ref, opt_httpConfig) { const httpConfig = - opt_httpConfig !== undefined ? opt_httpConfig : /** @type {angular.IRequestShortcutConfig} */ ({}); + opt_httpConfig !== undefined ? opt_httpConfig : /** @type {angular.IRequestShortcutConfig} */ {}; const url = `${this.url_}/cancel/${ref}`; // "delete" is a reserved word, so use ['delete'] return this.$http_['delete'](url, httpConfig); @@ -157,15 +159,13 @@ PrintService.prototype.createSpec = function ( email, goodnessOfFit, ) { - const specMap = /** @type {import('ngeo/print/mapfish-print-v3').MapFishPrintMap} */ ({ + const specMap = /** @type {import('ngeo/print/mapfish-print-v3').MapFishPrintMap} */ { dpi: dpi, rotation: rotation, - }); - + }; if (goodnessOfFit) { this.goodnessOfFit_ = goodnessOfFit; } - this.encodeMap_(map, scale, specMap, dpi); /** @type {import('ngeo/print/mapfish-print-v3').MapFishPrintAttributes} */ @@ -173,7 +173,6 @@ PrintService.prototype.createSpec = function ( map: specMap, }; Object.assign(attributes, customAttributes); - const lang = this.gettextCatalog_.getCurrentLanguage(); /** @type {import('ngeo/print/mapfish-print-v3').MapFishPrintSpec} */ @@ -183,11 +182,11 @@ PrintService.prototype.createSpec = function ( lang, layout, }; - if (email) { - spec.smtp = {to: email}; + spec.smtp = { + to: email, + }; } - return spec; }; @@ -202,7 +201,6 @@ PrintService.prototype.encodeMap_ = function (map, scale, object, destinationPri const viewCenter = view.getCenter(); const viewProjection = view.getProjection(); const viewResolution = view.getResolution(); - if (!viewCenter) { throw new Error('Missing viewCenter'); } @@ -212,13 +210,11 @@ PrintService.prototype.encodeMap_ = function (map, scale, object, destinationPri if (!viewResolution) { throw new Error('Missing viewResolution'); } - object.center = viewCenter; object.projection = viewProjection.getCode(); object.scale = scale; object.useNearestScale = false; object.layers = []; - const mapLayerGroup = map.getLayerGroup(); if (!mapLayerGroup) { throw new Error('Missing mapLayerGroup'); @@ -229,7 +225,6 @@ PrintService.prototype.encodeMap_ = function (map, scale, object, destinationPri // Sort the layer by ZIndex stableSort(layers, (layer_a, layer_b) => (layer_a.getZIndex() || 0) - (layer_b.getZIndex() || 0)); layers = layers.slice().reverse(); - layers.forEach((layer) => { if (layer.getVisible()) { this.encodeLayer(object.layers, layer, viewResolution, destinationPrintDpi); @@ -289,7 +284,6 @@ PrintService.prototype.encodeImageWmsLayer_ = function (arr, layer) { if (!(source instanceof olSourceImageWMS)) { throw new Error('source not instance of olSourceImageWMS'); } - const url = source.getUrl(); if (url !== undefined) { this.encodeWmsLayer_(arr, layer, url, source.getParams()); @@ -308,7 +302,9 @@ PrintService.prototype.encodeWmsLayer_ = function (arr, layer, url, params) { } const url_url = new URL(url); /** @type {Object} */ - const customParams = {'TRANSPARENT': 'true'}; + const customParams = { + 'TRANSPARENT': 'true', + }; if (url_url.searchParams) { url_url.searchParams.forEach( /** @@ -332,7 +328,6 @@ PrintService.prototype.encodeWmsLayer_ = function (arr, layer, url, params) { delete customParams.SERVERTYPE; delete customParams.VERSION; delete customParams.STYLES; - let serverType = undefined; if (params.SERVERTYPE !== 'arcgis') { serverType = params.SERVERTYPE; @@ -404,7 +399,6 @@ PrintService.prototype.encodeTileWmtsLayer_ = function (arr, layer) { if (!(source instanceof olSourceWMTS)) { throw new Error('source not instance of olSourceWMTS'); } - const projection = source.getProjection(); if (!projection) { throw new Error('Missing projection'); @@ -421,24 +415,21 @@ PrintService.prototype.encodeTileWmtsLayer_ = function (arr, layer) { /** @type {import('ngeo/print/mapfish-print-v3').MapFishPrintWmtsMatrix[]} */ const matrices = []; - for (let i = 0, ii = matrixIds.length; i < ii; ++i) { const tileRange = tileGrid.getFullTileRange(i); matrices.push( - /** @type {import('ngeo/print/mapfish-print-v3').MapFishPrintWmtsMatrix} */ ({ + /** @type {import('ngeo/print/mapfish-print-v3').MapFishPrintWmtsMatrix} */ { identifier: matrixIds[i], scaleDenominator: (tileGrid.getResolution(i) * metersPerUnit) / 0.28e-3, tileSize: olSize.toSize(tileGrid.getTileSize(i)), topLeftCorner: tileGrid.getOrigin(i), matrixSize: [tileRange.maxX - tileRange.minX, tileRange.maxY - tileRange.minY], - }), + }, ); } - const dimensions = source.getDimensions(); const dimensionKeys = Object.keys(dimensions); - - const object = /** @type {import('ngeo/print/mapfish-print-v3').MapFishPrintWmtsLayer} */ ({ + const object = /** @type {import('ngeo/print/mapfish-print-v3').MapFishPrintWmtsLayer} */ { baseURL: this.getWmtsUrl_(source), dimensions: dimensionKeys, dimensionParams: dimensions, @@ -451,8 +442,7 @@ PrintService.prototype.encodeTileWmtsLayer_ = function (arr, layer) { style: source.getStyle(), type: 'WMTS', version: source.getVersion(), - }); - + }; arr.push(object); }; @@ -468,7 +458,6 @@ PrintService.prototype.encodeTileWmsLayer_ = function (arr, layer) { if (!(source instanceof olSourceTileWMS)) { throw new Error('source not instance of olSourceTileWMS'); } - const urls = source.getUrls(); if (!urls) { throw new Error('Missing urls'); @@ -513,11 +502,11 @@ PrintService.prototype.getOpacityOrInherited_ = function (layer) { PrintService.prototype.createReport = function (printSpec, opt_httpConfig) { const format = printSpec.format || 'pdf'; const url = `${this.url_}/report.${format}`; - const httpConfig = /** @type {angular.IRequestShortcutConfig} */ ({ + const httpConfig = /** @type {angular.IRequestShortcutConfig} */ { headers: { 'Content-Type': 'application/json; charset=UTF-8', }, - }); + }; Object.assign(httpConfig, opt_httpConfig !== undefined ? opt_httpConfig : {}); return this.$http_.post(url, printSpec, httpConfig); }; @@ -531,7 +520,7 @@ PrintService.prototype.createReport = function (printSpec, opt_httpConfig) { */ PrintService.prototype.getStatus = function (ref, opt_httpConfig) { const httpConfig = - opt_httpConfig !== undefined ? opt_httpConfig : /** @type {angular.IRequestShortcutConfig} */ ({}); + opt_httpConfig !== undefined ? opt_httpConfig : /** @type {angular.IRequestShortcutConfig} */ {}; const url = `${this.url_}/status/${ref}.json`; return this.$http_.get(url, httpConfig); }; @@ -556,9 +545,9 @@ PrintService.prototype.getCapabilities = function (opt_httpConfig) { const httpConfig = opt_httpConfig !== undefined ? opt_httpConfig - : /** @type {angular.IRequestShortcutConfig} */ ({ + : /** @type {angular.IRequestShortcutConfig} */ { withCredentials: true, - }); + }; const url = `${this.url_}/capabilities.json`; return this.$http_.get(url, httpConfig); }; @@ -568,7 +557,6 @@ PrintService.prototype.getCapabilities = function (opt_httpConfig) { * @param {angular.gettext.gettextCatalog} gettextCatalog Gettext service. * @param {import('ngeo/map/LayerHelper').LayerHelper} ngeoLayerHelper Ngeo Layer Helper. * @returns {CreatePrint} The function to create a print service. - * @ngInject * @ngdoc service * @ngname ngeoCreatePrint * @hidden @@ -592,5 +580,4 @@ export function createPrintServiceFactory($http, gettextCatalog, ngeoLayerHelper const myModule = angular.module('ngeoPrint', [ngeoMapLayerHelper.name]); myModule.service('ngeoPrintService', PrintService); myModule.factory('ngeoCreatePrint', createPrintServiceFactory); - export default myModule; diff --git a/src/print/component.js b/src/print/component.js index 81d5f7321804..065f41611c5c 100644 --- a/src/print/component.js +++ b/src/print/component.js @@ -20,9 +20,7 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - import gmfAuthenticationService from 'ngeo/auth/service'; - import gmfThemeThemes from 'gmf/theme/Themes'; import LegendMapFishPrintV3 from 'gmf/print/LegendMapFishPrintV3'; import MaskLayer from 'ngeo/print/Mask'; @@ -71,7 +69,6 @@ const myModule = angular.module('gmfPrintComponent', [ ngeoPrintUtils.name, ngeoQueryMapQuerent.name, ]); - myModule.value( 'gmfPrintTemplateUrl', /** @@ -84,16 +81,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'gmf/print'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/print', require('./component.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/print', require('./component.html')); + }, + ], ); /** @@ -105,22 +103,18 @@ const PrintStateEnum = { * @type {string} */ NOT_IN_USE: 'notInUse', - /** * @type {string} */ PRINTING: 'printing', - /** * @type {string} */ ERROR_ON_REPORT: 'errorOnReport', - /** * @type {string} */ CAPABILITIES_NOT_LOADED: 'capabilitiesNotLoaded', - /** * @type {string} */ @@ -141,10 +135,10 @@ myModule.value('gmfPrintState', { * @param {angular.IAttributes} $attrs Attributes. * @param {function(JQuery, angular.IAttributes): string} gmfPrintTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfPrintTemplateUrl.$inject = ['$element', '$attrs', 'gmfPrintTemplateUrl']; function gmfPrintTemplateUrl($element, $attrs, gmfPrintTemplateUrl) { return gmfPrintTemplateUrl($element, $attrs); } @@ -200,7 +194,6 @@ const printComponent = { templateUrl: gmfPrintTemplateUrl, transclude: true, }; - myModule.component('gmfPrint', printComponent); /** @@ -226,7 +219,6 @@ export class PrintController { * @param {import('gmf/datasource/ExternalDataSourcesManager').ExternalDatSourcesManager} gmfExternalDataSourcesManager The manager of external datasources. * @param {import('gmf/options').gmfPrintOptions} gmfPrintOptions The options. * @param {string} cacheVersion The cache version - * @ngInject * @ngdoc controller * @ngname GmfPrintController */ @@ -271,7 +263,9 @@ export class PrintController { /** * @private */ - this.maskLayer_ = new MaskLayer({name: 'PrintMask'}); + this.maskLayer_ = new MaskLayer({ + name: 'PrintMask', + }); /** * @type {boolean} @@ -359,7 +353,6 @@ export class PrintController { * @type {?import("gmf/print/LegendMapFishPrintV3").default} */ this.legendMapFishPrintV3_ = null; - this.cacheVersion_ = cacheVersion; /** @@ -527,7 +520,6 @@ export class PrintController { if (!this.map) { throw new Error('Missing map'); } - this.legendMapFishPrintV3_ = new LegendMapFishPrintV3( this.gettextCatalog_, this.ngeoLayerHelper_, @@ -535,7 +527,6 @@ export class PrintController { this.options.legend, this.map, ); - listen( this.map.getView(), 'change:rotation', @@ -564,7 +555,6 @@ export class PrintController { this.smtpEmail = newValue; }, ); - this.$scope_.$watch( () => this.active, (active) => { @@ -581,11 +571,9 @@ export class PrintController { this.$rootScope_.$on('gmfCancelPrint', () => { this.cancel(); }); - this.gmfThemes_.getOgcServersObject().then((ogcServersObject) => { this.ogcServers_ = ogcServersObject; }); - listen( this.gmfThemes_, 'change', @@ -601,7 +589,6 @@ export class PrintController { * @returns {import('ol/size').Size} Size in dots of the map to print. */ const getSizeFn = () => this.paperSize_; - let getRotationFn; if (this.options.rotateMask) { /** @@ -609,7 +596,6 @@ export class PrintController { */ getRotationFn = () => -this.rotation; } - this.maskLayer_.getSize = getSizeFn; this.maskLayer_.getScale = this.getScaleFn.bind(this); this.maskLayer_.getRotation = getRotationFn; @@ -730,14 +716,11 @@ export class PrintController { this.formats_ = data.formats || []; this.layouts_ = data.layouts; this.layout_ = data.layouts[0]; - this.layoutInfo.layouts = []; this.layouts_.forEach((layout) => { this.layoutInfo.layouts.push(layout.name); }); - this.smtpSupported = data.smtp && data.smtp.enabled; - this.updateFields_(); } @@ -758,7 +741,6 @@ export class PrintController { throw new Error('Missing layout'); } this.layoutInfo.layout = this.layout_.name; - const mapInfo = this.isAttributeInCurrentLayout_('map'); if (!mapInfo) { throw new Error('Missing mapInfo'); @@ -768,30 +750,24 @@ export class PrintController { throw new Error('Missing clientInfo'); } this.paperSize_ = [clientInfo.width, clientInfo.height]; - this.updateCustomFields_(); - const fieldValues = this.options.fieldValues || {}; this.layoutInfo.legend = this.layoutInfo.attributes.includes('legend') ? fieldValues['legend'] !== false : undefined; this.layoutInfo.scales = clientInfo.scales || []; this.layoutInfo.dpis = clientInfo.dpiSuggestions || []; - const mapSize = this.map.getSize(); const viewResolution = this.map.getView().getResolution(); this.layoutInfo.scale = this.getOptimalScale_(mapSize, viewResolution); - this.layoutInfo.dpi = this.layoutInfo.dpi && this.layoutInfo.dpis.indexOf(this.layoutInfo.dpi) > 0 ? this.layoutInfo.dpi : this.layoutInfo.dpis[0]; - this.layoutInfo.formats = {}; this.formats_.forEach((format) => { this.layoutInfo.formats[format] = true; }); - this.attributesOut = this.layoutInfo.simpleAttributes; // Force the update of the mask @@ -812,14 +788,12 @@ export class PrintController { this.layoutInfo.simpleAttributes = []; } this.layoutInfo.attributes = []; - const simpleAttributes = this.layoutInfo.simpleAttributes; const previousAttributes = simpleAttributes.splice(0, simpleAttributes.length); // The attributes without 'clientParams' are the custom layout information (defined by end user). this.layout_.attributes.forEach((attribute) => { this.layoutInfo.attributes.push(attribute.name); - if (!attribute.clientParams) { const name = `${attribute.name}`; @@ -832,7 +806,6 @@ export class PrintController { }); return; } - const defaultValue = attribute.default; /** @type {string} */ let value = @@ -869,7 +842,6 @@ export class PrintController { return value; } }); - this.layoutInfo.simpleAttributes.push({ name, type, @@ -999,7 +971,6 @@ export class PrintController { } this.requestCanceler_ = this.$q_.defer(); this.gmfPrintState_.state = PrintStateEnum.PRINTING; - const mapSize = this.map.getSize(); const viewResolution = this.map.getView().getResolution() || 0; const scale = this.layoutInfo.scale || this.getOptimalScale_(mapSize, viewResolution); @@ -1007,21 +978,17 @@ export class PrintController { /** @type {Object} */ const customAttributes = {}; - if (this.layoutInfo.attributes.includes('datasource')) { customAttributes.datasource = datasource; } - if (this.layoutInfo.simpleAttributes) { this.layoutInfo.simpleAttributes.forEach((field) => { customAttributes[field.name] = field.value; }); } - if (this.layoutInfo.attributes.includes('username')) { customAttributes.username = gmfAuthenticationService.getUsername(); } - if (this.layoutInfo.legend) { const center = this.map.getView().getCenter(); if (!center) { @@ -1040,7 +1007,6 @@ export class PrintController { customAttributes.legend = legend; } } - if (typeof this.layoutInfo.dpi != 'number') { throw new Error('Wrong layoutInfo.dpi type'); } @@ -1072,7 +1038,9 @@ export class PrintController { undefined, undefined, undefined, - {opacity: layer.get('opacity')}, + { + opacity: layer.get('opacity'), + }, ); layer.setZIndex(-200); } else { @@ -1086,7 +1054,6 @@ export class PrintController { if (layer instanceof olLayerImage && layer.get('printNativeAngle') === false) { print_native_angle = false; } - new_ol_layers.push(layer); } const group = new olLayerGroup({ @@ -1094,9 +1061,7 @@ export class PrintController { }); group.set('printNativeAngle', print_native_angle); map.setLayerGroup(group); - const email = this.smtpSupported && this.smtpEmail && this.smtpEnabled ? this.smtpEmail : undefined; - const spec = this.ngeoPrint_.createSpec( map, scale, @@ -1116,13 +1081,12 @@ export class PrintController { if (layers.length > 0) { spec.attributes.map.layers.unshift(layers[0]); } - this.ngeoPrint_ .createReport( spec, - /** @type {angular.IRequestShortcutConfig} */ ({ + /** @type {angular.IRequestShortcutConfig} */ { timeout: this.requestCanceler_.promise, - }), + }, ) .then(this.handleCreateReportSuccess_.bind(this), this.handleCreateReportError_.bind(this)); @@ -1144,11 +1108,9 @@ export class PrintController { if (this.statusTimeoutPromise_ !== null) { this.$timeout_.cancel(this.statusTimeoutPromise_); } - if (this.curRef_.length > 0) { this.ngeoPrint_.cancel(this.curRef_); } - this.resetPrintStates_(); } @@ -1334,7 +1296,6 @@ export class PrintController { const mapSize = this.map.getSize() || [0, 0]; this.layoutInfo.scale = opt_scale; const res = this.ngeoPrintUtils_.getOptimalResolution(mapSize, this.paperSize_, opt_scale); - const view = this.map.getView(); const contrainRes = view.getConstraints().resolution(res, 1, mapSize, undefined); view.setResolution(contrainRes); @@ -1362,7 +1323,7 @@ export class PrintController { * state. False otherwise. */ isState(stateEnumKey) { - return this.gmfPrintState_.state === /** @type {Object} */ (PrintStateEnum)[stateEnumKey]; + return this.gmfPrintState_.state === /** @type {Object} */ PrintStateEnum[stateEnumKey]; } /** @@ -1372,7 +1333,24 @@ export class PrintController { this.smtpMessage = false; } } - +PrintController.$inject = [ + '$element', + '$rootScope', + '$scope', + '$timeout', + '$q', + 'gettextCatalog', + 'ngeoLayerHelper', + 'ngeoPrintUtils', + 'ngeoCreatePrint', + 'gmfPrintUrl', + 'ngeoQueryResult', + '$filter', + 'gmfPrintState', + 'gmfThemes', + 'gmfExternalDataSourcesManager', + 'gmfPrintOptions', + 'cacheVersion', +]; myModule.controller('GmfPrintController', PrintController); - export default myModule; diff --git a/src/profile/component.js b/src/profile/component.js index 00e6ea1ee222..f3504f27cdd4 100644 --- a/src/profile/component.js +++ b/src/profile/component.js @@ -1,3 +1,13 @@ +ProfileController.$inject = [ + '$scope', + '$http', + '$element', + '$filter', + 'gettextCatalog', + 'gmfProfileJsonUrl', + 'gmfProfileOptions', + 'ngeoProfileOptions', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -25,15 +35,10 @@ import olFeature from 'ol/Feature'; import olOverlay from 'ol/Overlay'; import olGeomLineString from 'ol/geom/LineString'; import olGeomPoint from 'ol/geom/Point'; - import ngeoDownloadCsv from 'ngeo/download/Csv'; - import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; - import ngeoProfileElevationComponent from 'ngeo/profile/elevationComponent'; - import {buildStyle} from 'ngeo/options'; - import 'bootstrap/js/src/dropdown'; import panels from 'gmfapi/store/panels'; @@ -69,7 +74,6 @@ import panels from 'gmfapi/store/panels'; * @hidden */ const myModule = angular.module('gmfProfile', [ngeoProfileElevationComponent.name]); - myModule.value( 'gmfProfileTemplateUrl', /** @@ -82,16 +86,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'gmf/profile'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/profile', require('./component.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/profile', require('./component.html')); + }, + ], ); /** @@ -99,10 +104,10 @@ myModule.run( * @param {angular.IAttributes} $attrs Attributes. * @param {function(JQuery, angular.IAttributes): string} gmfProfileTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfProfileTemplateUrl.$inject = ['$element', '$attrs', 'gmfProfileTemplateUrl']; function gmfProfileTemplateUrl($element, $attrs, gmfProfileTemplateUrl) { return gmfProfileTemplateUrl($element, $attrs); } @@ -149,7 +154,6 @@ const profileComponent = { }, templateUrl: gmfProfileTemplateUrl, }; - myModule.component('gmfProfile', profileComponent); /** @@ -163,7 +167,6 @@ myModule.component('gmfProfile', profileComponent); * @param {import('ngeo/options').ngeoProfileOptions} ngeoProfileOptions The options. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname GmfProfileController */ @@ -337,7 +340,6 @@ export function ProfileController( } }, ); - this.updateEventsListening_(); } @@ -347,9 +349,7 @@ export function ProfileController( ProfileController.prototype.$onInit = function () { this.map_ = this.getMapFn(); this.nbPoints_ = this.options.numberOfPoints || 100; - this.pointHoverOverlay_.setStyle(buildStyle(this.options.hoverPointStyle)); - for (const name in this.ngeoOptions.linesConfiguration) { // Keep an array of all layer names. this.layersNames_.push(name); @@ -360,16 +360,14 @@ ProfileController.prototype.$onInit = function () { this.ngeoOptions.linesConfiguration[name].zExtractor = this.getZFactory_(name); } } - this.profileOptions = - /** @type {import('ngeo/profile/elevationComponent').ProfileOptions} */ ({ + /** @type {import('ngeo/profile/elevationComponent').ProfileOptions} */ { linesConfiguration: this.ngeoOptions.linesConfiguration, distanceExtractor: this.getDist_, hoverCallback: this.hoverCallback_.bind(this), outCallback: this.outCallback_.bind(this), i18n: this.profileLabels_, - }); - + }; const optionsFn = this.getOptionsFn; if (optionsFn) { const options = optionsFn(); @@ -379,7 +377,6 @@ ProfileController.prototype.$onInit = function () { Object.assign(this.profileOptions, options); } }; - ProfileController.prototype.update_ = function () { this.isErrored = false; if (this.line) { @@ -393,41 +390,38 @@ ProfileController.prototype.update_ = function () { }; panels.openFooterPanel('profileresult', panelOptions); }; - ProfileController.prototype.updateEventsListening_ = function () { if (this.active && this.map_ !== null) { this.pointerMoveKey_ = listen( this.map_, 'pointermove', - /** @type {import('ol/events').ListenerFunction} */ ( - /** - * @param {import('ol/MapBrowserEvent').default} mapBrowserEvent - */ - (mapBrowserEvent) => { - if (!this.map_) { - throw new Error('Missing map'); - } - if (mapBrowserEvent.dragging || !this.line) { - return; - } - const coordinate = this.map_.getEventCoordinate(mapBrowserEvent.originalEvent); - const closestPoint = this.line.getClosestPoint(coordinate); - // compute distance to line in pixels - const eventToLine = new olGeomLineString([closestPoint, coordinate]); - const resolution = this.map_.getView().getResolution(); - if (resolution === undefined) { - throw new Error('Missing resolution'); - } - const pixelDist = eventToLine.getLength() / resolution; - - if (pixelDist < 16) { - this.profileHighlight = this.getDistanceOnALine_(closestPoint); - } else { - this.profileHighlight = -1; - } - this.$scope_.$apply(); + /** @type {import('ol/events').ListenerFunction} */ + /** + * @param {import('ol/MapBrowserEvent').default} mapBrowserEvent + */ + (mapBrowserEvent) => { + if (!this.map_) { + throw new Error('Missing map'); + } + if (mapBrowserEvent.dragging || !this.line) { + return; } - ), + const coordinate = this.map_.getEventCoordinate(mapBrowserEvent.originalEvent); + const closestPoint = this.line.getClosestPoint(coordinate); + // compute distance to line in pixels + const eventToLine = new olGeomLineString([closestPoint, coordinate]); + const resolution = this.map_.getView().getResolution(); + if (resolution === undefined) { + throw new Error('Missing resolution'); + } + const pixelDist = eventToLine.getLength() / resolution; + if (pixelDist < 16) { + this.profileHighlight = this.getDistanceOnALine_(closestPoint); + } else { + this.profileHighlight = -1; + } + this.$scope_.$apply(); + }, ); } else { if (this.pointerMoveKey_) { @@ -482,10 +476,9 @@ ProfileController.prototype.getDistanceOnALine_ = function (pointOnLine) { * @param {string} yUnits Y units label. */ ProfileController.prototype.hoverCallback_ = function (pointObject, dist, xUnits, elevationsRef, yUnits) { - const point = /** @type {Point} */ (pointObject); + const point = /** @type {Point} */ pointObject; // Update information point. const coordinate = [point.x, point.y]; - this.currentPoint.elevations = elevationsRef; this.currentPoint.distance = dist; this.currentPoint.xUnits = xUnits; @@ -499,7 +492,6 @@ ProfileController.prototype.hoverCallback_ = function (pointObject, dist, xUnits this.measureTooltip_.setPosition(coordinate); this.snappedPoint_.setGeometry(geom); }; - ProfileController.prototype.outCallback_ = function () { // Reset information point. delete this.currentPoint.coordinate; @@ -641,20 +633,16 @@ ProfileController.prototype.getJsonProfile_ = function () { if (!this.line) { throw new Error('Missing line'); } - this.isLoading = true; - const geom = { 'type': 'LineString', 'coordinates': this.line.getCoordinates(), }; - const params = { 'layers': this.layersNames_.join(','), 'geom': JSON.stringify(geom), 'nbPoints': this.nbPoints_, }; - this.$http_({ url: this.gmfProfileJsonUrl_, method: 'POST', @@ -699,38 +687,39 @@ ProfileController.prototype.downloadCsv = function () { let hasDistance = false; const firstPoint = this.profileData[0]; if ('dist' in firstPoint) { - headers.push({name: 'distance'}); + headers.push({ + name: 'distance', + }); hasDistance = true; } /** @type {string[]} */ const layers = []; for (const layer in firstPoint.values) { - headers.push({'name': layer}); + headers.push({ + 'name': layer, + }); layers.push(layer); } - headers.push({name: 'x'}); - headers.push({name: 'y'}); - + headers.push({ + name: 'x', + }); + headers.push({ + name: 'y', + }); const rows = this.profileData.map((point) => { /** @type {Object} */ const row = {}; if (hasDistance) { row.distance = point.dist; } - layers.forEach((layer) => { row[layer] = point.values[layer]; }); - row.x = point.x; row.y = point.y; - return row; }); - this.ngeoCsvDownload_.startDownload(rows, headers, 'profile.csv'); }; - myModule.controller('GmfProfileController', ProfileController); - export default myModule; diff --git a/src/profile/drawLineComponent.js b/src/profile/drawLineComponent.js index 84b14fa1ba4a..8843e7a7e8af 100644 --- a/src/profile/drawLineComponent.js +++ b/src/profile/drawLineComponent.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$scope', '$timeout']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -71,7 +72,6 @@ function profileDrawLineComponent() { }, }; } - myModule.directive('gmfDrawprofileline', profileDrawLineComponent); /** @@ -79,7 +79,6 @@ myModule.directive('gmfDrawprofileline', profileDrawLineComponent); * @param {angular.ITimeoutService} $timeout Angular timeout service. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname gmfDrawprofilelineController */ @@ -119,7 +118,6 @@ export function Controller($scope, $timeout) { */ const overlay = ngeoMapFeatureOverlayMgr.getFeatureOverlay(); overlay.setFeatures(this.features_); - const style = new olStyleStyle({ stroke: new olStyleStroke({ color: '#ffcc33', @@ -135,29 +133,27 @@ export function Controller($scope, $timeout) { type: 'LineString', features: this.features_, }); - interactionDecoration(this.interaction); // Clear the line as soon as a new drawing is started. - this.interaction.on(/** @type {import('ol/Observable').EventTypes} */ ('drawstart'), (event) => { + this.interaction.on(/** @type {import('ol/Observable').EventTypes} */ 'drawstart', (event) => { this.features_.clear(); }); // Update the profile with the new geometry. this.interaction.on( - /** @type {import('ol/Observable').EventTypes} */ ('drawend'), - /** @type {function(?): ?} */ ( - /** - * @param {import('lib/ol.interaction.Draw').DrawEvent} event - */ - (event) => { - this.line = /** @type {import('ol/geom/LineString').default} */ (event.feature.getGeometry()); - // using timeout to prevent double click to zoom the map - $timeout(() => { - this.interaction.setActive(false); - }, 0); - } - ), + /** @type {import('ol/Observable').EventTypes} */ 'drawend', + /** @type {function(?): ?} */ + /** + * @param {import('lib/ol.interaction.Draw').DrawEvent} event + */ + (event) => { + this.line = /** @type {import('ol/geom/LineString').default} */ event.feature.getGeometry(); + // using timeout to prevent double click to zoom the map + $timeout(() => { + this.interaction.setActive(false); + }, 0); + }, ); // Line may be removed from an other component @@ -170,7 +166,6 @@ export function Controller($scope, $timeout) { } }, ); - $scope.$watch( () => this.active, (newValue) => { @@ -205,7 +200,5 @@ Controller.prototype.clear_ = function () { this.features_.clear(); this.line = null; }; - myModule.controller('GmfDrawprofilelineController', Controller); - export default myModule; diff --git a/src/profile/elevationComponent.js b/src/profile/elevationComponent.js index 1f1f079938f2..2e4382b40735 100644 --- a/src/profile/elevationComponent.js +++ b/src/profile/elevationComponent.js @@ -1,3 +1,4 @@ +profileElevationComponent.$inject = ['ngeoDebounce', 'ngeoProfileOptions']; // The MIT License (MIT) // // Copyright (c) 2015-2024 Camptocamp SA @@ -23,7 +24,6 @@ import angular from 'angular'; import {listen} from 'ol/events'; import ngeoMiscDebounce from 'ngeo/misc/debounce'; import ngeoProfileD3Elevation from 'ngeo/profile/d3Elevation'; - import {select as d3select} from 'd3'; /** @@ -104,7 +104,6 @@ const myModule = angular.module('ngeoProfile', [ngeoMiscDebounce.name]); * ngeo Debounce factory. * @param {import('ngeo/options').ngeoProfileOptions} ngeoProfileOptions The options. * @returns {angular.IDirective} Directive Definition Object. - * @ngInject * @ngdoc directive * @ngname ngeoProfile */ @@ -119,7 +118,6 @@ function profileElevationComponent(ngeoDebounce, ngeoProfileOptions) { link: (scope, element, attrs) => { const optionsAttr = attrs.ngeoProfileOptions; console.assert(optionsAttr !== undefined); - const selection = d3select(element[0]); /** @type {*} */ @@ -127,7 +125,6 @@ function profileElevationComponent(ngeoDebounce, ngeoProfileOptions) { scope.$watchCollection(optionsAttr, (newVal) => { /** @type {ProfileOptions} */ const options = Object.assign({}, newVal); - if (options !== undefined) { // proxy the hoverCallback and outCallbackin order to be able to // call $applyAsync @@ -145,7 +142,6 @@ function profileElevationComponent(ngeoDebounce, ngeoProfileOptions) { scope.$applyAsync(); }; } - if (options.outCallback !== undefined) { const origOutCallback = options.outCallback; options.outCallback = function () { @@ -153,7 +149,6 @@ function profileElevationComponent(ngeoDebounce, ngeoProfileOptions) { scope.$applyAsync(); }; } - profile = ngeoProfileD3Elevation(ngeoProfileOptions, options); refreshData(); } @@ -172,7 +167,6 @@ function profileElevationComponent(ngeoDebounce, ngeoProfileOptions) { poiData = newVal; refreshData(); }); - scope.$watch(attrs.ngeoProfileHighlight, (newVal, oldVal) => { if (newVal === undefined) { return; @@ -183,7 +177,6 @@ function profileElevationComponent(ngeoDebounce, ngeoProfileOptions) { profile.clearHighlight(); } }); - listen(window, 'resize', ngeoDebounce(refreshData, 50, true)); /** @@ -200,7 +193,5 @@ function profileElevationComponent(ngeoDebounce, ngeoProfileOptions) { }, }; } - myModule.directive('ngeoProfile', profileElevationComponent); - export default myModule; diff --git a/src/query/MapQuerent.js b/src/query/MapQuerent.js index 5f8e95d2444e..ba4fffe971be 100644 --- a/src/query/MapQuerent.js +++ b/src/query/MapQuerent.js @@ -56,7 +56,6 @@ export class MapQuerent { * @param {import('ngeo/options').ngeoQueryOptions} ngeoQueryOptions The options. * @ngdoc service * @ngname ngeoQuerent - * @ngInject */ constructor( ngeoDataSources, @@ -115,7 +114,6 @@ export class MapQuerent { * @private */ this.tolerance_; - if (hasCoarsePointingDevice()) { this.tolerance_ = options.toleranceTouch !== undefined ? options.toleranceTouch : 10; } else { @@ -188,7 +186,6 @@ export class MapQuerent { if (this.cleared_) { return; } - this.result_.total = 0; for (const source of this.result_.sources) { if (!keep) { @@ -226,7 +223,6 @@ export class MapQuerent { } let label = dataSource.name; console.assert(dataSource); - const querentResultItem = response[id]; const features = querentResultItem.features; const limit = querentResultItem.limit; @@ -260,12 +256,10 @@ export class MapQuerent { } typeSeparatedFeatures[type].push(feature); }); - for (const type in typeSeparatedFeatures) { label = type ? type : label; const featuresByType = typeSeparatedFeatures[type]; let shouldPush = false; - if (action === ngeoQueryAction.REPLACE) { shouldPush = true; } else { @@ -276,7 +270,6 @@ export class MapQuerent { break; } } - if (existingSource) { for (const newFeature of featuresByType) { const existingFeatureIndex = this.featureHelper_.findFeatureIndexByFid( @@ -301,7 +294,6 @@ export class MapQuerent { } } } - if (shouldPush) { this.result_.sources.push({ features: featuresByType, @@ -325,7 +317,14 @@ export class MapQuerent { this.cleared_ = false; } } - +MapQuerent.$inject = [ + 'ngeoDataSources', + 'gmfDataSourcesHelper', + 'ngeoFeatureHelper', + 'ngeoQuerent', + 'ngeoQueryResult', + 'ngeoQueryOptions', +]; /** * @type {angular.IModule} * @hidden @@ -344,11 +343,10 @@ myModule.service('ngeoMapQuerent', MapQuerent); */ myModule.value( 'ngeoQueryResult', - /** @type {QueryResult} */ ({ + /** @type {QueryResult} */ { sources: [], total: 0, pending: false, - }), + }, ); - export default myModule; diff --git a/src/query/ModeSelector.js b/src/query/ModeSelector.js index 525682665888..757fdd92d15f 100644 --- a/src/query/ModeSelector.js +++ b/src/query/ModeSelector.js @@ -23,7 +23,6 @@ import angular from 'angular'; import ngeoQueryAction from 'ngeo/query/Action'; import ngeoQueryMode from 'ngeo/query/Mode'; import {isEventUsingCtrlKey} from 'ngeo/utils'; - import {listen as olEventsListen} from 'ol/events'; /** @@ -44,7 +43,6 @@ export class QueryModeSelector { * pressed. * * @param {angular.IScope} $rootScope The root scope. - * @ngInject */ constructor($rootScope) { // Constants @@ -222,10 +220,8 @@ export class QueryModeSelector { if (this.pending) { return; } - const key = evt.key; let updateScope = false; - if (this.keysAction_.includes(key) && !this.previousAction_) { // An 'action' key was pressed and none were already previously // pressed. In other words, only the first 'action key' is handled. @@ -257,7 +253,6 @@ export class QueryModeSelector { // after a ctrl+p.) updateScope = this.reset_(); } - if (updateScope) { this.rootScope_.$apply(); } @@ -275,7 +270,6 @@ export class QueryModeSelector { if (!(evt instanceof KeyboardEvent)) { return; } - let updateScope = false; // On any 'keyup', if it comes from a 'ctrl' (or 'meta' on mac) release and @@ -293,7 +287,6 @@ export class QueryModeSelector { this.activeActionKey_ = null; updateScope = true; } - if (updateScope) { this.rootScope_.$apply(); } @@ -329,12 +322,11 @@ export class QueryModeSelector { return true; } } - +QueryModeSelector.$inject = ['$rootScope']; /** * @type {angular.IModule} * @hidden */ const myModule = angular.module('ngeoQueryModeSelector', []); myModule.service('ngeoQueryModeSelector', QueryModeSelector); - export default myModule; diff --git a/src/query/Querent.js b/src/query/Querent.js index ec6223944339..e4b6ebe1cd57 100644 --- a/src/query/Querent.js +++ b/src/query/Querent.js @@ -117,7 +117,6 @@ export class Querent { * @param {import('ngeo/misc/WMSTime').WMSTime} ngeoWMSTime wms time service. * @ngdoc service * @ngname ngeoQuerent - * @ngInject */ constructor($http, $q, ngeoRuleHelper, ngeoWMSTime) { // === Injected properties === @@ -216,7 +215,6 @@ export class Querent { const combinedWMSDataSources = this.getCombinableWMSDataSources_(queryableDataSources.wms); promises.push(this.issueCombinedWMS_(combinedWMSDataSources, options)); } - return this.q_.all(promises).then(handleCombinedQueryResult_); } @@ -233,20 +231,18 @@ export class Querent { */ getQueryableDataSources(dataSources, map) { const queryableDataSources = { - wfs: /** @type {gmfDatasourceOGC[]} */ ([]), - wms: /** @type {gmfDatasourceOGC[]} */ ([]), + wfs: /** @type {gmfDatasourceOGC[]} */ [], + wms: /** @type {gmfDatasourceOGC[]} */ [], }; const resolution = map.getView().getResolution(); if (resolution === undefined) { throw new Error('Missing resolution'); } - for (const dataSource of dataSources) { // (1) Skip data source that can't be queried if (!this.isDataSourceQueryable_(dataSource, resolution)) { continue; } - if (dataSource instanceof gmfDatasourceOGC) { // (2) Split data sources if (dataSource.supportsWFS) { @@ -271,16 +267,13 @@ export class Querent { if (!dataSource.wfsUrl) { throw new Error('Missing WFS URL'); } - const wfsLayerNames = dataSource.getWFSLayerNames(); - const url = olUriAppendParams(dataSource.wfsUrl, { 'REQUEST': 'DescribeFeatureType', 'SERVICE': 'WFS', 'VERSION': '2.0.0', 'TYPENAME': wfsLayerNames, }); - return this.http_.get(url).then((response) => { const format = new ngeoWFSDescribeFeatureType(); return format.read(response.data); @@ -294,7 +287,6 @@ export class Querent { */ wmsFindLayerCapability(layerCapabilities, layerName) { let found = null; - for (const layerCapability of layerCapabilities) { if (layerCapability.Name === layerName) { found = layerCapability; @@ -306,7 +298,6 @@ export class Querent { } } } - return found; } @@ -319,16 +310,13 @@ export class Querent { */ wmsGetCapabilities(baseUrl, opt_cache) { const cache = opt_cache !== false; - const params = { 'REQUEST': 'GetCapabilities', 'SERVICE': 'WMS', 'VERSION': '1.3.0', }; - const url = olUriAppendParams(baseUrl, params); let promise; - if (!cache || !this.wmsGetCapabilitiesPromises_[baseUrl]) { promise = this.http_.get(url).then((response) => { const format = new olFormatWMSCapabilities(); @@ -337,15 +325,12 @@ export class Querent { } else if (cache && this.wmsGetCapabilitiesPromises_[baseUrl]) { promise = this.wmsGetCapabilitiesPromises_[baseUrl]; } - if (!promise) { throw new Error('Missing promise'); } - if (cache && !this.wmsGetCapabilitiesPromises_[baseUrl]) { this.wmsGetCapabilitiesPromises_[baseUrl] = promise; } - return promise; } @@ -376,7 +361,6 @@ export class Querent { wmtsGetCapabilities(url, opt_cache) { const cache = opt_cache !== false; let promise; - if (!cache || !this.wmtsGetCapabilitiesPromises_[url]) { promise = this.http_.get(url).then((response) => { const format = new olFormatWMTSCapabilities(); @@ -385,15 +369,12 @@ export class Querent { } else if (cache && this.wmtsGetCapabilitiesPromises_[url]) { promise = this.wmtsGetCapabilitiesPromises_[url]; } - if (!promise) { throw new Error('Missing promise'); } - if (cache && !this.wmtsGetCapabilitiesPromises_[url]) { this.wmtsGetCapabilitiesPromises_[url] = promise; } - return promise; } @@ -418,9 +399,10 @@ export class Querent { // For combination of layers the service gives some less than the maxFeatures allowed, so recompute the effective obtained number let formatWFS = new olFormatWFS(); if (dataSources.length > 0 && dataSources[0].wfsOutputFormat === 'GML2') { - formatWFS = new olFormatWFS({'version': '1.0.0'}); + formatWFS = new olFormatWFS({ + 'version': '1.0.0', + }); } - const limit = formatWFS.readFeatures(response.data).length; const tooManyFeatures = totalFeatureCount > limit; /** @type {string[]} */ @@ -446,7 +428,6 @@ export class Querent { value.tooManyFeatures = tooManyFeatures; value.requestPartners = datasourceNames; }); - return hash; } @@ -465,10 +446,8 @@ export class Querent { handleQueryResult_(dataSources, limit, wfs, response) { /** @type {QuerentResult} */ const hash = {}; - for (const dataSource of dataSources) { const dataSourceId = dataSource.id; - if (typeof response === 'number') { /** @type {import('ol/Feature').default[]} */ const features = []; @@ -493,7 +472,6 @@ export class Querent { }; } } - return hash; } @@ -522,16 +500,16 @@ export class Querent { if (!dataSource.wfsFormat) { throw new Error('Missing wfsFormat'); } - readFeatures = /** @type {import('ol/Feature').default[]} */ ( - dataSource.wfsFormat.readFeatures(data) - ); + readFeatures = + /** @type {import('ol/Feature').default[]} */ + dataSource.wfsFormat.readFeatures(data); } else { if (!dataSource.wmsFormat) { throw new Error('Missing wmsFormat'); } - readFeatures = /** @type {import('ol/Feature').default[]} */ ( - dataSource.wmsFormat.readFeatures(data) - ); + readFeatures = + /** @type {import('ol/Feature').default[]} */ + dataSource.wmsFormat.readFeatures(data); } if (readFeatures.length > 0) { readFeatures.forEach((feature) => { @@ -597,13 +575,11 @@ export class Querent { // The 'limit' option is mandatory in the querent service const maxFeatures = options.limit; - const map = options.map; const view = map.getView(); const resolution = view.getResolution(); const projection = view.getProjection(); const srsName = projection.getCode(); - if (resolution === undefined) { throw new Error('Missing resolution'); } @@ -635,7 +611,6 @@ export class Querent { let url = null; /** @type {Object} */ const params = {}; - if (options.bboxAsGETParam && bbox) { params.bbox = bbox.join(','); } @@ -653,7 +628,6 @@ export class Querent { if (!geometryName) { throw new Error('Missing geometryName'); } - getFeatureCommonOptions = { bbox, featureNS, @@ -663,7 +637,6 @@ export class Querent { srsName, featureTypes: [], }; - url = dataSource.wfsUrl; // All data sources combined share the same active dimensions @@ -694,7 +667,6 @@ export class Querent { `A data source having filterRules or timeRangeValue should issue a single query, alone.`, ); - filter = this.ngeoRuleHelper_.createFilter({ dataSource: dataSource, incDimensions: true, @@ -710,7 +682,6 @@ export class Querent { const spatialFilter = olFormatFilter.intersects(geometryName, options.geometry, srsName); filter = this.ngeoRuleHelper_.joinFilters(filter, spatialFilter); } - if (filter) { getFeatureCommonOptions.filter = filter; } @@ -744,7 +715,6 @@ export class Querent { if (!getFeatureCommonOptions) { throw new Error('Missing getFeatureCommonOptions'); } - if (hasAtLeastOneQueryIconPosition) { getFeatureCommonOptions.featureTypes = featureTypesObjects; // If featureTypes is set with FeatureType objects then bbox and geometryName is @@ -755,7 +725,6 @@ export class Querent { // If there is no queryIconPosition, use a simple array of names and a common geom. getFeatureCommonOptions.featureTypes = featureTypesNames; } - if (!url) { throw new Error('Missing url'); } @@ -779,7 +748,6 @@ export class Querent { if (!dataSources[0].wfsFormat) { throw new Error('Missing wfsFormat'); } - let numberOfFeatures = -1; if (response !== undefined) { const metadata = dataSources[0].wfsFormat.readFeatureCollectionMetadata(response.data); @@ -802,7 +770,9 @@ export class Querent { this.http_ .post(url, featureRequest, { params: params, - headers: {'Content-Type': 'text/xml; charset=UTF-8'}, + headers: { + 'Content-Type': 'text/xml; charset=UTF-8', + }, timeout: canceler.promise, }) .then((response) => { @@ -831,7 +801,9 @@ export class Querent { this.http_ .post(url, featureCountRequest, { params: params, - headers: {'Content-Type': 'text/xml; charset=UTF-8'}, + headers: { + 'Content-Type': 'text/xml; charset=UTF-8', + }, timeout: canceler.promise, }) .then((response) => { @@ -869,18 +841,24 @@ export class Querent { return olExtent.buffer(bbox, buffers[0]); } const fourValuesBuffers = [ - buffers[0], // Top is always set. - buffers[1], // Right is always set (with length > 1). - length === 2 ? buffers[0] : buffers[2], // Take bottom. + buffers[0], + // Top is always set. + buffers[1], + // Right is always set (with length > 1). + length === 2 ? buffers[0] : buffers[2], + // Take bottom. length === 4 ? buffers[3] : buffers[1], // Take left. ]; // To includes the feature's point into the queried zone relative to the click. Flip vertically and // horizontally the queryIconPosition (that is relative to the icon). // Ol extent coordinate order is [left, bottom, right, top]. return [ - bbox[0] - fourValuesBuffers[1], // Use right buffer for left. - bbox[1] - fourValuesBuffers[0], // Use top buffer for bottom. - bbox[2] + fourValuesBuffers[3], // Use left buffer for right. + bbox[0] - fourValuesBuffers[1], + // Use right buffer for left. + bbox[1] - fourValuesBuffers[0], + // Use top buffer for bottom. + bbox[2] + fourValuesBuffers[3], + // Use left buffer for right. bbox[3] + fourValuesBuffers[2], // Use bottom buffer for top. ]; } @@ -900,7 +878,6 @@ export class Querent { // The 'limit' option is mandatory in the querent service const FEATURE_COUNT = options.limit; - const map = options.map; const view = map.getView(); const resolution = view.getResolution(); @@ -968,11 +945,10 @@ export class Querent { console.assert(dataSources.length === 1); params.TIME = this.ngeoWMSTime_.formatWMSTimeParam( dataSource.timeProperty, - /** @type {import('ngeo/datasource/OGC').TimeRange} */ (dataSource.timeRangeValue), + /** @type {import('ngeo/datasource/OGC').TimeRange} */ dataSource.timeRangeValue, ); } } - params.LAYERS = LAYERS; params.QUERY_LAYERS = LAYERS; @@ -999,7 +975,6 @@ export class Querent { } params.FILTER = filterParamValue; } - if (!url) { throw new Error('Missing url'); } @@ -1018,7 +993,6 @@ export class Querent { if (!wmsGetFeatureInfoUrl) { throw new Error('Missing wmsGetFeatureInfoUrl'); } - const canceler = this.registerCanceler_(); promises.push( this.http_ @@ -1027,11 +1001,10 @@ export class Querent { }) .then( /** @type {function(angular.IHttpResponse|number): QuerentResult} */ - (this.handleQueryResult_.bind(this, dataSources, FEATURE_COUNT, false)), + this.handleQueryResult_.bind(this, dataSources, FEATURE_COUNT, false), ), ); } - return this.q_.all(promises).then(handleCombinedQueryResult_); } @@ -1046,7 +1019,6 @@ export class Querent { const combinableDataSources = []; /** @type {CombinedDataSources} */ const notCombinableDataSources = []; - for (const dataSource of dataSources) { if (dataSource.combinableForWFS) { let combined = false; @@ -1063,7 +1035,6 @@ export class Querent { notCombinableDataSources.push([dataSource]); } } - return combinableDataSources.concat(notCombinableDataSources); } @@ -1078,7 +1049,6 @@ export class Querent { const combinableDataSources = []; /** @type {CombinedDataSources} */ const notCombinableDataSources = []; - for (const dataSource of dataSources) { if (dataSource.combinableForWMS) { let combined = false; @@ -1095,7 +1065,6 @@ export class Querent { notCombinableDataSources.push([dataSource]); } } - return combinableDataSources.concat(notCombinableDataSources); } @@ -1162,7 +1131,7 @@ export class Querent { this.requestCancelers_.length = 0; } } - +Querent.$inject = ['$http', '$q', 'ngeoRuleHelper', 'ngeoWMSTime']; /** * Handles the response of multiple promises that did either * WMS GetFeatureInfo or WFS GetFeature requests, in which the result is @@ -1201,5 +1170,4 @@ function handleCombinedQueryResult_(response) { */ const myModule = angular.module('ngeoQuerent', [ngeoFilterRuleHelper.name, ngeoMiscWMSTime.name]); myModule.service('ngeoQuerent', Querent); - export default myModule; diff --git a/src/query/component.js b/src/query/component.js index c54fa0d18769..e3c7d142f3d4 100644 --- a/src/query/component.js +++ b/src/query/component.js @@ -20,18 +20,15 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - import {unlistenByKeys as ngeoEventsUnlistenByKeys} from 'ngeo/events'; import ngeoQueryMode from 'ngeo/query/Mode'; import ngeoQueryModeSelector from 'ngeo/query/ModeSelector'; import ngeoQueryMapQuerent from 'ngeo/query/MapQuerent'; - import {listen as olEventsListen} from 'ol/events'; import {always as olEventsConditionAlways} from 'ol/events/condition'; import olInteractionDraw, {createBox as olInteractionDrawCreateBox} from 'ol/interaction/Draw'; import olLayerVector from 'ol/layer/Vector'; import olSourceVector from 'ol/source/Vector'; - import ImageLayer from 'ol/layer/Image'; import TileLayer from 'ol/layer/Tile'; @@ -52,7 +49,6 @@ export class QueryController { * The ngeo query modeSelector service. * @param {angular.IScope} $scope Scope. * @param {import('ngeo/options').ngeoQueryOptions} ngeoQueryOptions The options. - * @ngInject * @ngdoc controller * @ngname NgeoQueryController */ @@ -159,7 +155,6 @@ export class QueryController { // === Event listeners that uses angular $scope $scope.$watch(() => this.active, this.handleActiveChange_.bind(this)); - $scope.$watch(() => { let value = null; if (this.active) { @@ -211,7 +206,6 @@ export class QueryController { this.listenerKeys_.push(olEventsListen(this.map, 'pointermove', this.handleMapPointerMove_, this)); } break; - case ngeoQueryMode.DRAW_BOX: this.map.addLayer(this.vectorLayer_); this.map.addInteraction(this.drawBoxInteraction_); @@ -219,12 +213,11 @@ export class QueryController { olEventsListen( this.drawBoxInteraction_, 'drawend', - /** @type {import('ol/events').ListenerFunction} */ (this.handleDrawBoxInteractionDrawEnd_), + /** @type {import('ol/events').ListenerFunction} */ this.handleDrawBoxInteractionDrawEnd_, this, ), ); break; - case ngeoQueryMode.DRAW_POLYGON: this.map.addLayer(this.vectorLayer_); this.map.addInteraction(this.drawPolygonInteraction_); @@ -232,16 +225,14 @@ export class QueryController { olEventsListen( this.drawPolygonInteraction_, 'drawend', - /** @type {import('ol/events').ListenerFunction} */ (this.handleDrawPolygonInteractionDrawEnd_), + /** @type {import('ol/events').ListenerFunction} */ this.handleDrawPolygonInteractionDrawEnd_, this, ), ); break; - default: break; } - this.mode_ = mode; } @@ -267,25 +258,20 @@ export class QueryController { this.map.getTargetElement().style.cursor = ''; } break; - case ngeoQueryMode.DRAW_BOX: this.vectorSource_.clear(); this.map.removeLayer(this.vectorLayer_); this.map.removeInteraction(this.drawBoxInteraction_); break; - case ngeoQueryMode.DRAW_POLYGON: this.vectorSource_.clear(); this.map.removeLayer(this.vectorLayer_); this.map.removeInteraction(this.drawPolygonInteraction_); break; - default: break; } - ngeoEventsUnlistenByKeys(this.listenerKeys_); - this.mode_ = null; } @@ -326,14 +312,11 @@ export class QueryController { */ handleDrawBoxInteractionDrawEnd_(evt) { const feature = evt.feature; - const action = this.ngeoQueryModeSelector_.action; const extent = feature.getGeometry().getExtent(); const limit = this.getLimitOption_(); const map = this.map; - this.ngeoQueryModeSelector_.pending = true; - this.ngeoMapQuerent_ .issue({ action, @@ -358,14 +341,11 @@ export class QueryController { */ handleDrawPolygonInteractionDrawEnd_(evt) { const feature = evt.feature; - const action = this.ngeoQueryModeSelector_.action; const geometry = feature.getGeometry(); const limit = this.getLimitOption_(); const map = this.map; - this.ngeoQueryModeSelector_.pending = true; - this.ngeoMapQuerent_ .issue({ action, @@ -394,13 +374,10 @@ export class QueryController { // not a MapBrowserEvent return; } - const action = this.ngeoQueryModeSelector_.action; const coordinate = evt.coordinate; const map = this.map; - this.ngeoQueryModeSelector_.pending = true; - this.ngeoMapQuerent_ .issue({ action, @@ -428,7 +405,6 @@ export class QueryController { // not a MapBrowserEvent return false; } - let hit = false; this.map.getAllLayers().forEach((layer) => { if (layer.get('visible') && !!layer.get('querySourceIds')) @@ -441,7 +417,7 @@ export class QueryController { this.map.getTargetElement().style.cursor = hit ? 'pointer' : ''; } } - +QueryController.$inject = ['ngeoMapQuerent', 'ngeoQueryModeSelector', '$scope', 'ngeoQueryOptions']; myModule.component('ngeoQuery', { bindings: { 'active': '=', @@ -450,5 +426,4 @@ myModule.component('ngeoQuery', { }, controller: QueryController, }); - export default myModule; diff --git a/src/query/gridComponent.js b/src/query/gridComponent.js index c49401e2775c..5e6c7c838f5e 100644 --- a/src/query/gridComponent.js +++ b/src/query/gridComponent.js @@ -1,3 +1,13 @@ +QueryGridController.$inject = [ + '$scope', + 'ngeoQueryResult', + 'ngeoMapQuerent', + '$timeout', + 'ngeoQueryOptions', + 'gmfCsvFilename', + '$element', + 'gmfDisplayQueryGridOptions', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -20,22 +30,16 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - import downloadCsvService from 'ngeo/download/Csv'; - import ngeoGridComponent from 'ngeo/grid/component'; - import ngeoGridConfig, {getRowUid} from 'ngeo/grid/Config'; import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; - import ngeoQueryMapQuerent from 'ngeo/query/MapQuerent'; - import olCollection from 'ol/Collection'; import * as olExtent from 'ol/extent'; import olMap from 'ol/Map'; import {buildStyle} from 'ngeo/options'; import panels from 'gmfapi/store/panels'; - import 'bootstrap/js/src/dropdown'; /** @@ -52,7 +56,6 @@ import 'bootstrap/js/src/dropdown'; * @hidden */ const myModule = angular.module('gmfQueryGridComponent', [ngeoGridComponent.name, ngeoQueryMapQuerent.name]); - myModule.value( 'gmfDisplayquerygridTemplateUrl', /** @@ -65,16 +68,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'gmf/query/gridComponent'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/query/gridComponent', require('./gridComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/query/gridComponent', require('./gridComponent.html')); + }, + ], ); /** @@ -82,10 +86,10 @@ myModule.run( * @param {angular.IAttributes} $attrs Attributes. * @param {function(JQuery, angular.IAttributes): string} gmfDisplayquerygridTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfDisplayquerygridTemplateUrl.$inject = ['$element', '$attrs', 'gmfDisplayquerygridTemplateUrl']; function gmfDisplayquerygridTemplateUrl($element, $attrs, gmfDisplayquerygridTemplateUrl) { return gmfDisplayquerygridTemplateUrl($element, $attrs); } @@ -125,7 +129,6 @@ const queryGridComponent = { }, templateUrl: gmfDisplayquerygridTemplateUrl, }; - myModule.component('gmfDisplayquerygrid', queryGridComponent); /** @@ -141,7 +144,6 @@ myModule.component('gmfDisplayquerygrid', queryGridComponent); * @param {import('gmf/options').gmfDisplayQueryGridOptions} gmfDisplayQueryGridOptions The options. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname GmfDisplayquerygridController */ @@ -278,9 +280,11 @@ export function QueryGridController( if (ngeoQueryResult.pending) { this.active = true; this.pending = true; - panels.openFooterPanel('queryresult', {state: true, noError: true}); + panels.openFooterPanel('queryresult', { + state: true, + noError: true, + }); } - if (newQueryResult !== oldQueryResult) { this.updateData_(); } @@ -308,17 +312,13 @@ QueryGridController.prototype.$onInit = function () { if (!this.getMapFn) { throw new Error('Missing getMapFn'); } - const featuresOverlay = ngeoMapFeatureOverlayMgr.getFeatureOverlay(); featuresOverlay.setFeatures(this.features_); - featuresOverlay.setStyle(buildStyle(this.options.featuresStyle)); - const highlightFeaturesOverlay = ngeoMapFeatureOverlayMgr.getFeatureOverlay(); highlightFeaturesOverlay.setFeatures(this.highlightFeatures_); const highlightFeatureStyle = buildStyle(this.options.selectedFeatureStyle); highlightFeaturesOverlay.setStyle(highlightFeatureStyle); - const mapFn = this.getMapFn; if (mapFn) { const map = mapFn(); @@ -337,7 +337,6 @@ QueryGridController.prototype.$onInit = function () { QueryGridController.prototype.getGridSources = function () { return this.loadedGridSources.map((sourceLabel) => this.gridSources[sourceLabel]); }; - QueryGridController.prototype.updateData_ = function () { // close if there are no results if ( @@ -349,12 +348,13 @@ QueryGridController.prototype.updateData_ = function () { if (oldActive) { // don't close if there are pending queries this.active = this.ngeoQueryResult.pending; - panels.openFooterPanel('queryresult', {state: this.active}); + panels.openFooterPanel('queryresult', { + state: this.active, + }); this.pending = this.ngeoQueryResult.pending; } return; } - this.sumOfAvailableResults = 0; this.sumOfFeatures = 0; @@ -371,9 +371,10 @@ QueryGridController.prototype.updateData_ = function () { } countedSources.push(source.label); }); - this.active = true; - panels.openFooterPanel('queryresult', {state: true}); + panels.openFooterPanel('queryresult', { + state: true, + }); this.pending = false; let sources = this.ngeoQueryResult.sources; // merge sources if requested @@ -393,11 +394,13 @@ QueryGridController.prototype.updateData_ = function () { } } }); - if (this.loadedGridSources.length === 0) { // if no grids were created, do not show this.active = false; - panels.openFooterPanel('queryresult', {state: false, noError: true}); + panels.openFooterPanel('queryresult', { + state: false, + noError: true, + }); return; } @@ -460,21 +463,17 @@ QueryGridController.prototype.getMergedSources_ = function (sources) { const allSources = []; /** @type {Object} */ const mergedSources = {}; - sources.forEach((source) => { // check if this source can be merged const mergedSource = this.getMergedSource_(source, mergedSources); - if (mergedSource === null) { // this source should not be merged, add as is allSources.push(source); } }); - for (const mergedSourceId in mergedSources) { allSources.push(mergedSources[mergedSourceId]); } - return allSources; }; @@ -491,7 +490,6 @@ QueryGridController.prototype.getMergedSources_ = function (sources) { */ QueryGridController.prototype.getMergedSource_ = function (source, mergedSources) { let mergeSourceId = null; - for (const currentMergeSourceId in this.options.mergeTabs || {}) { const sourceLabels = this.options.mergeTabs[currentMergeSourceId]; const containsSource = sourceLabels.some((sourceLabel) => sourceLabel == source.label); @@ -500,7 +498,6 @@ QueryGridController.prototype.getMergedSource_ = function (source, mergedSources break; } } - if (mergeSourceId === null) { // this source should not be merged return null; @@ -522,7 +519,8 @@ QueryGridController.prototype.getMergedSource_ = function (source, mergedSources features: [], id: mergeSourceId, label: mergeSourceId, - limit: 0, //the sum of the obtained results of the query is computed later + limit: 0, + //the sum of the obtained results of the query is computed later pending: false, tooManyResults: false, mergeComposants: [source.label], @@ -550,7 +548,6 @@ QueryGridController.prototype.getMergedSource_ = function (source, mergedSources } mergeSource.limit += source.limit; } - return mergeSource; }; @@ -576,12 +573,10 @@ QueryGridController.prototype.collectData_ = function (source) { if (!featureGeometriesNames.includes(featureGeometryName)) { featureGeometriesNames.push(featureGeometryName); } - allProperties.push(properties); featuresForSource[getRowUid(properties)] = feature; } }); - this.cleanProperties_(allProperties, featureGeometriesNames); if (allProperties.length > 0) { const gridCreated = this.makeGrid_(allProperties, source); @@ -605,7 +600,6 @@ QueryGridController.prototype.cleanProperties_ = function (allProperties, featur delete properties.boundedBy; delete properties.ngeo_feature_type_; }); - if (this.options.removeEmptyColumns === true) { this.removeEmptyColumnsFn_(allProperties); } @@ -689,12 +683,11 @@ QueryGridController.prototype.getGridConfiguration_ = function (data) { const columnDefs = []; columns.forEach((column) => { columnDefs.push( - /** @type {import('ngeo/download/Csv').GridColumnDef} */ ({ + /** @type {import('ngeo/download/Csv').GridColumnDef} */ { name: column, - }), + }, ); }); - if (columnDefs.length > 0) { return new ngeoGridConfig(data, columnDefs); } else { @@ -722,7 +715,10 @@ QueryGridController.prototype.getActiveGridSource = function () { */ QueryGridController.prototype.clear = function () { this.active = false; - panels.openFooterPanel('queryresult', {state: false, noError: true}); + panels.openFooterPanel('queryresult', { + state: false, + noError: true, + }); this.pending = false; this.gridSources = {}; this.loadedGridSources = []; @@ -745,12 +741,10 @@ QueryGridController.prototype.clear = function () { QueryGridController.prototype.selectTab = function (gridSource) { const source = gridSource.source; this.selectedTab = source.label; - if (this.unregisterSelectWatcher_) { this.unregisterSelectWatcher_(); this.unregisterSelectWatcher_ = null; } - if (gridSource.configuration !== undefined) { this.unregisterSelectWatcher_ = this.$scope_.$watchCollection( () => gridSource.configuration.selectedRows, @@ -762,10 +756,8 @@ QueryGridController.prototype.selectTab = function (gridSource) { ); } this.updateFeatures_(gridSource); - this.reflowGrid_(); }; - QueryGridController.prototype.reflowGrid_ = function () { // This is a "work-around" to make sure that the grid is rendered correctly. // When a pane is activated by setting `this.selectedTab`, the class `active` @@ -787,7 +779,6 @@ QueryGridController.prototype.onSelectionChanged_ = function () { if (this.selectedTab === null) { return; } - const gridSource = this.gridSources[`${this.selectedTab}`]; this.updateFeatures_(gridSource); }; @@ -798,15 +789,12 @@ QueryGridController.prototype.onSelectionChanged_ = function () { QueryGridController.prototype.updateFeatures_ = function (gridSource) { this.features_.clear(); this.highlightFeatures_.clear(); - if (!gridSource.configuration) { return; } - const sourceLabel = `${gridSource.source.label}`; const featuresForSource = this.featuresForSources_[sourceLabel]; const selectedRows = gridSource.configuration.selectedRows; - for (const rowId in featuresForSource) { const feature = featuresForSource[rowId]; if (rowId in selectedRows) { @@ -896,7 +884,10 @@ QueryGridController.prototype.zoomToSelection = function () { if (!size) { throw new Error('Missing size'); } - this.map_.getView().fit(extent, {size, maxZoom: this.options.maxRecenterZoom}); + this.map_.getView().fit(extent, { + size, + maxZoom: this.options.maxRecenterZoom, + }); } }; @@ -911,11 +902,8 @@ QueryGridController.prototype.downloadCsv = function () { throw new Error('Missing columnDefs'); } const selectedRows = source.configuration.getSelectedRows(); - this.ngeoCsvDownload_.startDownload(selectedRows, columnDefs, this.filename_); } }; - myModule.controller('GmfDisplayquerygridController', QueryGridController); - export default myModule; diff --git a/src/query/panelComponent.js b/src/query/panelComponent.js index caaff1248964..ee6b2e429ddc 100644 --- a/src/query/panelComponent.js +++ b/src/query/panelComponent.js @@ -20,7 +20,6 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import angular from 'angular'; - import ngeoQueryModeSelector from 'ngeo/query/ModeSelector'; /** @@ -28,21 +27,21 @@ import ngeoQueryModeSelector from 'ngeo/query/ModeSelector'; * @hidden */ const myModule = angular.module('ngeoQueryPanel', [ngeoQueryModeSelector.name]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - $templateCache.put( - 'ngeo/src/query/panelComponent', - // @ts-ignore: webpack - require('./panelComponent.html'), - ); - }, + [ + '$templateCache', + ($templateCache) => { + $templateCache.put( + 'ngeo/src/query/panelComponent', + // @ts-ignore: webpack + require('./panelComponent.html'), + ); + }, + ], ); - myModule.value( 'ngeoQueryPanelTemplateUrl', /** @@ -59,10 +58,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} ngeoQueryPanelTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +ngeoQueryPanelTemplateUrl.$inject = ['$attrs', 'ngeoQueryPanelTemplateUrl']; function ngeoQueryPanelTemplateUrl($attrs, ngeoQueryPanelTemplateUrl) { return ngeoQueryPanelTemplateUrl($attrs); } @@ -74,7 +73,6 @@ export class QueryPanelController { /** * @param {import('ngeo/query/ModeSelector').QueryModeSelector} ngeoQueryModeSelector * The ngeo query modeSelector service. - * @ngInject * @ngdoc controller * @ngname NgeoQueryController */ @@ -85,10 +83,9 @@ export class QueryPanelController { this.ngeoQueryModeSelector = ngeoQueryModeSelector; } } - +QueryPanelController.$inject = ['ngeoQueryModeSelector']; myModule.component('ngeoQueryPanel', { controller: QueryPanelController, templateUrl: ngeoQueryPanelTemplateUrl, }); - export default myModule; diff --git a/src/query/windowComponent.js b/src/query/windowComponent.js index 440d3b153d7a..afef2ec4947b 100644 --- a/src/query/windowComponent.js +++ b/src/query/windowComponent.js @@ -1,3 +1,11 @@ +QueryWindowController.$inject = [ + '$element', + '$scope', + 'ngeoQueryResult', + 'ngeoMapQuerent', + 'gmfCsvFilename', + 'gmfDisplayQueryWindowOptions', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -23,15 +31,11 @@ import angular from 'angular'; import downloadCsvService from 'ngeo/download/Csv'; import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; import ngeoMiscFeatureHelper, {getFilteredFeatureValues} from 'ngeo/misc/FeatureHelper'; - import ngeoMiscSwipe from 'ngeo/misc/swipe'; - import ngeoQueryMapQuerent from 'ngeo/query/MapQuerent'; - import olCollection from 'ol/Collection'; import {isEmpty} from 'ol/obj'; import {buildStyle} from 'ngeo/options'; - import 'jquery-ui/ui/widgets/resizable'; import 'ngeo/sass/jquery-ui.scss'; import 'angular-animate'; @@ -50,7 +54,6 @@ const myModule = angular.module('gmfQueryWindowComponent', [ 'ngAnimate', 'ngTouch', ]); - myModule.config([ '$animateProvider', /** @@ -63,7 +66,6 @@ myModule.config([ $animateProvider.classNameFilter(/gmf-animatable/); }, ]); - myModule.value( 'gmfDisplayquerywindowTemplateUrl', /** @@ -76,16 +78,17 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'gmf/query/windowComponent'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/query/windowComponent', require('./windowComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/query/windowComponent', require('./windowComponent.html')); + }, + ], ); /** @@ -94,10 +97,10 @@ myModule.run( * @param {function(JQuery, angular.IAttributes): string} gmfDisplayquerywindowTemplateUrl Template * function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfDisplayquerywindowTemplateUrl.$inject = ['$element', '$attrs', 'gmfDisplayquerywindowTemplateUrl']; function gmfDisplayquerywindowTemplateUrl($element, $attrs, gmfDisplayquerywindowTemplateUrl) { return gmfDisplayquerywindowTemplateUrl($element, $attrs); } @@ -130,7 +133,6 @@ const queryWindowComponent = { }, templateUrl: gmfDisplayquerywindowTemplateUrl, }; - myModule.component('gmfDisplayquerywindow', queryWindowComponent); /** @@ -142,7 +144,6 @@ myModule.component('gmfDisplayquerywindow', queryWindowComponent); * @param {import('gmf/options').gmfDisplayQueryWindowOptions} gmfDisplayQueryWindowOptions The options. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname GmfDisplayquerywindowController */ @@ -257,7 +258,6 @@ export function QueryWindowController( * @type {boolean} */ this.isLoading = false; - $scope.$watchCollection( () => ngeoQueryResult, (newQueryResult, oldQueryResult) => { @@ -281,15 +281,12 @@ QueryWindowController.prototype.$onInit = function () { this.collapsed = this.options.collapsed; } this.draggableContainment = this.draggableContainment || 'document'; - const featuresOverlay = ngeoMapFeatureOverlayMgr.getFeatureOverlay(); featuresOverlay.setFeatures(this.features_); featuresOverlay.setStyle(buildStyle(this.options.featuresStyle)); - const highlightFeaturesOverlay = ngeoMapFeatureOverlayMgr.getFeatureOverlay(); highlightFeaturesOverlay.setFeatures(this.highlightFeatures_); highlightFeaturesOverlay.setStyle(buildStyle(this.options.selectedFeatureStyle)); - const windowContainer = this.element_.find('.gmf-displayquerywindow .windowcontainer'); if (this.desktop) { windowContainer.draggable({ @@ -313,7 +310,6 @@ QueryWindowController.prototype.show = function () { this.clear(); this.updateFeatures_(); }; - QueryWindowController.prototype.updateFeatures_ = function () { this.setCurrentResult_(0, false); if (this.source !== null) { @@ -585,11 +581,12 @@ QueryWindowController.prototype.getCSVHeaderDefinition_ = function (data) { // From Set (distinct values) to array. /** @type {import('ngeo/download/Csv').GridColumnDef[]} */ const columnDefs = []; - distinctKeys.forEach((key) => columnDefs.push({name: key})); - + distinctKeys.forEach((key) => + columnDefs.push({ + name: key, + }), + ); return columnDefs; }; - myModule.controller('GmfDisplayquerywindowController', QueryWindowController); - export default myModule; diff --git a/src/raster/RasterService.js b/src/raster/RasterService.js index 01676f1d0c49..f62906a99f82 100644 --- a/src/raster/RasterService.js +++ b/src/raster/RasterService.js @@ -1,3 +1,4 @@ +RasterService.$inject = ['$http', 'gmfRasterUrl']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -29,7 +30,6 @@ import angular from 'angular'; * @class * @param {angular.IHttpService} $http Angular http service. * @param {string} gmfRasterUrl URL to a the c2cgeoportal raster service. - * @ngInject * @ngdoc service * @ngname gmfRaster * @hidden @@ -61,11 +61,14 @@ const Param = { * @returns {angular.IPromise>} Promise. */ RasterService.prototype.getRaster = function (coordinate, opt_params) { - const params = opt_params || /** @type {Object} */ ({}); + const params = opt_params || /** @type {Object} */ {}; params[Param.X] = coordinate[0]; params[Param.Y] = coordinate[1]; - - return this.$http_.get(this.url_, {params}).then((resp) => resp.data); + return this.$http_ + .get(this.url_, { + params, + }) + .then((resp) => resp.data); }; /** @@ -83,5 +86,4 @@ RasterService.prototype.handleGetRaster_ = function (resp) { */ const myModule = angular.module('gmfRaster', []); myModule.service('gmfRaster', RasterService); - export default myModule; diff --git a/src/raster/component.js b/src/raster/component.js index 099f93e94fe3..49e366ec0463 100644 --- a/src/raster/component.js +++ b/src/raster/component.js @@ -1,3 +1,12 @@ +WidgetController.$inject = ['gmfElevationOptions']; +Controller.$inject = [ + '$scope', + '$filter', + 'ngeoDebounce', + 'gmfRaster', + 'gettextCatalog', + 'gmfElevationOptions', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -21,12 +30,9 @@ import angular from 'angular'; import gmfRasterRasterService from 'gmf/raster/RasterService'; - import ngeoMiscDebounce from 'ngeo/misc/debounce'; - import {listen, unlistenByKey} from 'ol/events'; import MapBrowserEvent from 'ol/MapBrowserEvent'; - import 'bootstrap/js/src/dropdown'; /** @@ -34,18 +40,18 @@ import 'bootstrap/js/src/dropdown'; * @hidden */ const myModule = angular.module('gmfRasterComponent', [gmfRasterRasterService.name, ngeoMiscDebounce.name]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/raster/widgetComponent', require('./widgetComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/raster/widgetComponent', require('./widgetComponent.html')); + }, + ], ); - myModule.value( 'gmfElevationwidgetTemplateUrl', /** @@ -63,10 +69,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} gmfElevationwidgetTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfElevationwidgetTemplateUrl.$inject = ['$attrs', 'gmfElevationwidgetTemplateUrl']; function gmfElevationwidgetTemplateUrl($attrs, gmfElevationwidgetTemplateUrl) { return gmfElevationwidgetTemplateUrl($attrs); } @@ -142,7 +148,6 @@ function rasterComponent() { }, }; } - myModule.directive('gmfElevation', rasterComponent); /** @@ -155,7 +160,6 @@ myModule.directive('gmfElevation', rasterComponent); * @param {import('gmf/options').gmfElevationOptions} gmfElevationOptions The options * @class * @hidden - * @ngInject * @ngdoc controller * @ngname gmfElevationController */ @@ -164,7 +168,6 @@ export function Controller($scope, $filter, ngeoDebounce, gmfRaster, gettextCata * @type {import('gmf/options').gmfElevationOptions} */ this.options = gmfElevationOptions; - this.filter_ = $filter; this.ngeoDebounce_ = ngeoDebounce; this.gmfRaster_ = gmfRaster; @@ -320,7 +323,6 @@ Controller.prototype.getRasterSuccess_ = function (resp) { } this.loading = false; }; - Controller.prototype.getRasterError_ = function () { console.error('Error on getting the raster.'); this.clear_(); @@ -333,7 +335,6 @@ Controller.prototype.clear_ = function () { this.elevation = null; this.loading = false; }; - myModule.controller('GmfElevationController', Controller); /** @@ -364,7 +365,6 @@ myModule.component('gmfElevationwidget', rasterWidgetComponent); /** * @class * @hidden - * @nginject * @ngdoc controller * @param {import('gmf/options').gmfElevationOptions} gmfElevationOptions The options. */ @@ -390,7 +390,5 @@ export function WidgetController(gmfElevationOptions) { */ this.selectedElevationLayer = this.show ? this.options.layers[0] : ''; } - myModule.controller('gmfElevationwidgetController', WidgetController); - export default myModule; diff --git a/src/routing/NominatimInputComponent.js b/src/routing/NominatimInputComponent.js index 57f98230c718..e9c106989a0b 100644 --- a/src/routing/NominatimInputComponent.js +++ b/src/routing/NominatimInputComponent.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$element', '$scope', 'ngeoNominatimService']; // The MIT License (MIT) // // Copyright (c) 2018-2024 Camptocamp SA @@ -31,18 +32,18 @@ const myModule = angular.module('ngeoRoutingNominatimInputComponent', [ ngeoSearchSearchDirective.name, ngeoRoutingNominatimService.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/routing/nominatiminput', require('./nominatiminput.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/routing/nominatiminput', require('./nominatiminput.html')); + }, + ], ); - myModule.value( 'ngeoRoutingNominatimInputComponentTemplateUrl', /** @@ -60,10 +61,13 @@ myModule.value( * @param {function(angular.IAttributes): string} ngeoRoutingNominatimInputComponentTemplateUrl * Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +ngeoRoutingNominatimInputComponentTemplateUrl.$inject = [ + '$attrs', + 'ngeoRoutingNominatimInputComponentTemplateUrl', +]; function ngeoRoutingNominatimInputComponentTemplateUrl( $attrs, ngeoRoutingNominatimInputComponentTemplateUrl, @@ -78,7 +82,6 @@ function ngeoRoutingNominatimInputComponentTemplateUrl( * Nominatim * @class * @hidden - * @ngInject * @ngdoc controller * @ngname NgeoNominatimInputController */ @@ -111,7 +114,7 @@ export function Controller($element, $scope, ngeoNominatimService) { /** * @type {Twitter.Typeahead.Options} */ - this.options = /** @type {Twitter.Typeahead.Options} */ ({}); + this.options = /** @type {Twitter.Typeahead.Options} */ {}; /** * @type {Twitter.Typeahead.Dataset[]} @@ -182,7 +185,5 @@ const routingNominatimInputComponent = { }, templateUrl: ngeoRoutingNominatimInputComponentTemplateUrl, }; - myModule.component('ngeoNominatimInput', routingNominatimInputComponent); - export default myModule; diff --git a/src/routing/NominatimService.js b/src/routing/NominatimService.js index 887fad4ffc93..d17ef8afe61a 100644 --- a/src/routing/NominatimService.js +++ b/src/routing/NominatimService.js @@ -1,3 +1,4 @@ +NominatimService.$inject = ['$http', 'ngeoDebounce', 'ngeoNominatimUrl', 'ngeoNominatimSearchDefaultParams']; // The MIT License (MIT) // // Copyright (c) 2018-2024 Camptocamp SA @@ -47,7 +48,6 @@ import ngeoMiscDebounce from 'ngeo/misc/debounce'; * @param {import('ngeo/options').ngeoNominatimSearchDefaultParams} ngeoNominatimSearchDefaultParams The search parameters * @class * @ngdoc service - * @ngInject * @ngname ngeoNominatimService * @see https://wiki.openstreetmap.org/wiki/Nominatim * @hidden @@ -110,13 +110,11 @@ export function NominatimService($http, ngeoDebounce, ngeoNominatimUrl, ngeoNomi */ NominatimService.prototype.search = function (query, params) { let url = `${this.nominatimUrl_}search?q=${query}`; - params = params || {}; params = Object.assign({}, this.searchDefaultParams_, params); // require JSON response params.format = 'json'; - if (params) { url += '&'; const options = []; @@ -125,7 +123,6 @@ NominatimService.prototype.search = function (query, params) { } url += options.join('&'); } - return this.$http_.get(url); }; @@ -139,7 +136,6 @@ NominatimService.prototype.search = function (query, params) { */ NominatimService.prototype.reverse = function (coordinate, params) { let url = `${this.nominatimUrl_}reverse`; - params = Object.assign({}, params); // coordinate @@ -148,7 +144,6 @@ NominatimService.prototype.reverse = function (coordinate, params) { // require JSON response params.format = 'json'; - if (params) { url += '?'; const options = []; @@ -157,7 +152,6 @@ NominatimService.prototype.reverse = function (coordinate, params) { } url += options.join('&'); } - return this.$http_.get(url); }; @@ -200,7 +194,6 @@ NominatimService.prototype.typeaheadSource_ = function (query, syncResults, asyn syncResults([]); } }; - this.search(query, {}).then(onSuccess_, onError_); }; @@ -209,7 +202,5 @@ NominatimService.prototype.typeaheadSource_ = function (query, syncResults, asyn * @hidden */ const myModule = angular.module('ngeoNominatimService', [ngeoMiscDebounce.name]); - myModule.service('ngeoNominatimService', NominatimService); - export default myModule; diff --git a/src/routing/RoutingComponent.js b/src/routing/RoutingComponent.js index 3f8e9a744dea..179e46a89be1 100644 --- a/src/routing/RoutingComponent.js +++ b/src/routing/RoutingComponent.js @@ -54,18 +54,18 @@ const myModule = angular.module('ngeoRoutingComponent', [ ngeoRoutingRoutingService.name, ngeoRoutingRoutingFeatureComponent.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/routing/routing', require('./routing.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/routing/routing', require('./routing.html')); + }, + ], ); - myModule.value( 'ngeoRoutingTemplateUrl', /** @@ -82,10 +82,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} ngeoRoutingTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +ngeoRoutingTemplateUrl.$inject = ['$attrs', 'ngeoRoutingTemplateUrl']; function ngeoRoutingTemplateUrl($attrs, ngeoRoutingTemplateUrl) { return ngeoRoutingTemplateUrl($attrs); } @@ -106,7 +106,6 @@ export class Controller { * @param {import('ngeo/misc/debounce').miscDebounce} ngeoDebounce ngeo Debounce * service. * @param {import('ngeo/options').ngeoRoutingOptions} ngeoRoutingOptions The options. - * @ngInject */ constructor($scope, ngeoRoutingService, ngeoNominatimService, $q, ngeoDebounce, ngeoRoutingOptions) { /** @@ -150,7 +149,6 @@ export class Controller { * @type {?import('ngeo/options').RoutingProfile} */ this.selectedRoutingProfile = this.routingProfiles.length > 0 ? this.routingProfiles[0] : null; - $scope.$watch(() => this.selectedRoutingProfile, this.calculateRoute.bind(this)); /** @@ -248,7 +246,6 @@ export class Controller { * @private */ this.draw_ = null; - const debounceDelay = 200; // in milliseconds /** @@ -348,7 +345,11 @@ export class Controller { parsedRoutes = [].concat(...parsedRoutes_); } else if (route.geometry) { // otherwise parse (overview) geometry - parsedRoutes.push(new olFeature({geometry: format.readGeometry(route.geometry, formatConfig)})); + parsedRoutes.push( + new olFeature({ + geometry: format.readGeometry(route.geometry, formatConfig), + }), + ); } return parsedRoutes; } @@ -361,13 +362,12 @@ export class Controller { } // remove rendered routes this.routeSource_.clear(); - const coordFrom = this.getLonLatFromPoint_(this.startFeature_); const coordTo = this.getLonLatFromPoint_(this.targetFeature_); const vias = this.viaArray .filter((via) => via.feature !== null) .map((via) => this.getLonLatFromPoint_(via.feature)); - const route = /** @type {number[][]} */ ([coordFrom].concat(vias, [coordTo])); + const route = /** @type {number[][]} */ [coordFrom].concat(vias, [coordTo]); /** * @param {angular.IHttpResponse} resp @@ -386,26 +386,25 @@ export class Controller { // recenter map on route this.map.getView().fit(this.routeSource_.getExtent()); - this.routeDistance = resp.data.routes[0].distance; this.routeDuration = resp.data.routes[0].duration; // get first and last coordinate of route - const startRoute = /** @type {import('ol/geom/LineString').default} */ ( - features[0].getGeometry() - ).getCoordinateAt(0); - const endRoute = /** @type {import('ol/geom/LineString').default} */ ( - features[features.length - 1].getGeometry() - ).getCoordinateAt(1); + const startRoute = /** @type {import('ol/geom/LineString').default} */ features[0] + .getGeometry() + .getCoordinateAt(0); + const endRoute = /** @type {import('ol/geom/LineString').default} */ features[features.length - 1] + .getGeometry() + .getCoordinateAt(1); // build geometries to connect route to start and end point of query const startToRoute = [ - /** @type {import('ol/geom/Point').default} */ (this.startFeature_.getGeometry()).getCoordinates(), + /** @type {import('ol/geom/Point').default} */ this.startFeature_.getGeometry().getCoordinates(), startRoute, ]; const routeToEnd = [ endRoute, - /** @type {import('ol/geom/Point').default} */ (this.targetFeature_.getGeometry()).getCoordinates(), + /** @type {import('ol/geom/Point').default} */ this.targetFeature_.getGeometry().getCoordinates(), ]; const routeConnections = [ new olFeature(new olGeomLineString(startToRoute)), @@ -433,11 +432,9 @@ export class Controller { /** @type {import('./RoutingService').Config} */ const config = {}; config.options = options; - if (this.selectedRoutingProfile) { config.instance = this.selectedRoutingProfile.profile; } - this.$q_.when(this.ngeoRoutingService_.getRoute(route, config)).then(onSuccess_, onError_); } @@ -457,7 +454,14 @@ export class Controller { } } } - +Controller.$inject = [ + '$scope', + 'ngeoRoutingService', + 'ngeoNominatimService', + '$q', + 'ngeoDebounce', + 'ngeoRoutingOptions', +]; myModule.component('ngeoRouting', { controller: Controller, bindings: { @@ -465,5 +469,4 @@ myModule.component('ngeoRouting', { }, templateUrl: ngeoRoutingTemplateUrl, }); - export default myModule; diff --git a/src/routing/RoutingFeatureComponent.js b/src/routing/RoutingFeatureComponent.js index d1e17fe6514b..714540f00ae3 100644 --- a/src/routing/RoutingFeatureComponent.js +++ b/src/routing/RoutingFeatureComponent.js @@ -44,18 +44,18 @@ const myModule = angular.module('ngeoRoutingFeatureComponent', [ ngeoRoutingNominatimService.name, ngeoRoutingNominatimInputComponent.name, ]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/routing/routingfeature', require('./routingfeature.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/routing/routingfeature', require('./routingfeature.html')); + }, + ], ); - myModule.value( 'ngeoRoutingFeatureTemplateUrl', /** @@ -72,10 +72,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} ngeoRoutingFeatureTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +ngeoRoutingFeatureTemplateUrl.$inject = ['$attrs', 'ngeoRoutingFeatureTemplateUrl']; function ngeoRoutingFeatureTemplateUrl($attrs, ngeoRoutingFeatureTemplateUrl) { return ngeoRoutingFeatureTemplateUrl($attrs); } @@ -88,7 +88,6 @@ function ngeoRoutingFeatureTemplateUrl($attrs, ngeoRoutingFeatureTemplateUrl) { * Nominatim * @class * @hidden - * @ngInject * @ngdoc controller * @ngname NgeoRoutingFeatureController */ @@ -222,7 +221,6 @@ export class Controller { */ this.errorMessage = ''; } - $onInit() { if (!this.map) { return; @@ -232,21 +230,18 @@ export class Controller { // setup modify interaction this.modifyFeature_.setActive(true); this.map.addInteraction(this.modifyFeature_); - this.modifyFeature_.on( - /** @type {import('ol/Observable').EventTypes} */ ('modifyend'), - /** @type {function(?): ?} */ ( - /** - * @param {import('ol/interaction/Modify').ModifyEvent} event - */ - (event) => { - const feature = event.features.getArray()[0]; - this.vectorSource_.clear(); - this.snapFeature_(/** @type {olFeature} */ (feature)); - } - ), + /** @type {import('ol/Observable').EventTypes} */ 'modifyend', + /** @type {function(?): ?} */ + /** + * @param {import('ol/interaction/Modify').ModifyEvent} event + */ + (event) => { + const feature = event.features.getArray()[0]; + this.vectorSource_.clear(); + this.snapFeature_(/** @type {olFeature} */ feature); + }, ); - this.scope_.$watch( () => this.feature, (newVal, oldVal) => { @@ -282,34 +277,29 @@ export class Controller { if (this.draw_) { this.map.removeInteraction(this.draw_); } - this.draw_ = new olInteractionDraw({ features: this.vectorFeatures_, type: 'Point', }); - - this.draw_.on(/** @type {import('ol/Observable').EventTypes} */ ('drawstart'), () => { + this.draw_.on(/** @type {import('ol/Observable').EventTypes} */ 'drawstart', () => { if (this.feature) { this.vectorSource_.removeFeature(this.feature); } }); - this.draw_.on( - /** @type {import('ol/Observable').EventTypes} */ ('drawend'), - /** @type {function(?): ?} */ ( - /** - * @param {import('lib/ol.interaction.Draw').DrawEvent} event - */ - (event) => { - if (this.draw_ && this.map) { - this.map.removeInteraction(this.draw_); - } - this.snapFeature_(/** @type {olFeature} */ (event.feature)); - this.modifyFeature_.setActive(true); + /** @type {import('ol/Observable').EventTypes} */ 'drawend', + /** @type {function(?): ?} */ + /** + * @param {import('lib/ol.interaction.Draw').DrawEvent} event + */ + (event) => { + if (this.draw_ && this.map) { + this.map.removeInteraction(this.draw_); } - ), + this.snapFeature_(/** @type {olFeature} */ event.feature); + this.modifyFeature_.setActive(true); + }, ); - this.modifyFeature_.setActive(false); this.map.addInteraction(this.draw_); } @@ -327,20 +317,19 @@ export class Controller { if (label === '') { label = transformedCoordinate.join('/'); } - this.feature = /** @type {?olFeature} */ ( + this.feature = + /** @type {?olFeature} */ new olFeature({ geometry: new olGeomPoint(transformedCoordinate), name: label, - }) - ); + }); } - onFeatureChange_() { if (!this.feature) { return; } // Update label - this.featureLabel = /** @type {string} */ (this.feature.get('name') || ''); + this.featureLabel = /** @type {string} */ this.feature.get('name') || ''; // Update vector source this.vectorSource_.clear(); @@ -364,9 +353,9 @@ export class Controller { const coordinate = selected.coordinate.map(parseFloat); const label = selected.label; this.setFeature_(coordinate, label); - const newCoordinates = /** @type {import('ol/geom/Point').default} */ ( - this.feature.getGeometry() - ).getCoordinates(); + const newCoordinates = /** @type {import('ol/geom/Point').default} */ this.feature + .getGeometry() + .getCoordinates(); this.map.getView().setCenter(newCoordinates); } @@ -403,7 +392,6 @@ export class Controller { this.errorMessage = 'Error: nominatim server not responding.'; console.log(resp); }; - this.$q_.when(this.ngeoNominatimService_.reverse(coord, config)).then(onSuccess, onError); } @@ -424,7 +412,7 @@ export class Controller { return olProj.toLonLat(coords, projection); } } - +Controller.$inject = ['$scope', '$timeout', '$q', 'ngeoNominatimService']; /** * Provides a text input and draw interaction to allow a user to create and modify a ol.Feature * (point geometry). @@ -465,7 +453,5 @@ const routingFeatureComponent = { }, templateUrl: ngeoRoutingFeatureTemplateUrl, }; - myModule.component('ngeoRoutingFeature', routingFeatureComponent); - export default myModule; diff --git a/src/routing/RoutingService.js b/src/routing/RoutingService.js index f37778cae402..631a33c2d202 100644 --- a/src/routing/RoutingService.js +++ b/src/routing/RoutingService.js @@ -1,3 +1,4 @@ +RoutingService.$inject = ['$http', 'ngeoRoutingOptions']; // The MIT License (MIT) // // Copyright (c) 2018-2024 Camptocamp SA @@ -30,7 +31,6 @@ import angular from 'angular'; * @param {import('ngeo/options').ngeoRoutingOptions} ngeoRoutingOptions The options. * @class * @ngdoc service - * @ngInject * @ngname ngeoRoutingService * @hidden */ @@ -132,12 +132,10 @@ RoutingService.prototype.getRoute = function (coordinates, config) { if (config.instance) { url += `${config.instance}/`; } - url += `${config.service}/${this.protocolVersion_}/${config.profile}/`; // [ [a,b] , [c,d] ] -> 'a,b;c,d' const coordinateString = coordinates.map((c) => c.join(',')).join(';'); - url += coordinateString; // look for route service options @@ -150,7 +148,6 @@ RoutingService.prototype.getRoute = function (coordinates, config) { } url += options.join('&'); } - return this.$http_.get(url); }; @@ -182,7 +179,6 @@ RoutingService.prototype.getNearest = function (coordinate, config) { if (config.instance) { url += `${config.instance}/`; } - url += `${config.service}/${this.protocolVersion_}/${config.profile}/`; // [a,b] -> 'a,b' @@ -198,7 +194,6 @@ RoutingService.prototype.getNearest = function (coordinate, config) { } url += options.join('&'); } - return this.$http_.get(url); }; @@ -207,7 +202,5 @@ RoutingService.prototype.getNearest = function (coordinate, config) { * @hidden */ const myModule = angular.module('ngeoRoutingService', []); - myModule.service('ngeoRoutingService', RoutingService); - export default myModule; diff --git a/src/search/FulltextSearch.js b/src/search/FulltextSearch.js index fe44f56e5cd6..e4bea0f97bd6 100644 --- a/src/search/FulltextSearch.js +++ b/src/search/FulltextSearch.js @@ -1,3 +1,4 @@ +FulltextSearchService.$inject = ['$http', 'fulltextsearchUrl']; // The MIT License (MIT) // // Copyright (c) 2017-2024 Camptocamp SA @@ -28,7 +29,6 @@ import {encodeQueryString, decodeQueryString} from 'ngeo/utils'; * @param {angular.IHttpService} $http Angular http service. * @param {string} fulltextsearchUrl The service URL. * @class - * @ngInject * @ngname gmfFulltextSearch * @hidden */ @@ -42,13 +42,11 @@ export function FulltextSearchService($http, fulltextsearchUrl) { * @type {string} */ this.url_ = fulltextsearchUrl; - const url = this.url_.split('?'); /** * @type {string} */ this.baseUrl_ = url[0]; - const queryString = url.length == 2 ? `?${url[1]}` : ''; /** * @type {Object} @@ -65,11 +63,8 @@ export function FulltextSearchService($http, fulltextsearchUrl) { */ FulltextSearchService.prototype.search = function (query, params) { const queryParams = Object.assign({}, this.defaultParams_, params); - queryParams['query'] = query; - const url = `${this.baseUrl_}?${encodeQueryString(queryParams)}`; - return new Promise((resolve, reject) => { this.$http_ .get(url) @@ -84,5 +79,4 @@ FulltextSearchService.prototype.search = function (query, params) { */ const myModule = angular.module('gmfSearchFulltextSearch', []); myModule.service('gmfSearchFulltextSearch', FulltextSearchService); - export default myModule; diff --git a/src/search/component.js b/src/search/component.js index 6220751142a4..b83855b98489 100644 --- a/src/search/component.js +++ b/src/search/component.js @@ -27,11 +27,8 @@ import gmfSearchFulltextSearch from 'gmf/search/FulltextSearch'; import gmfThemeThemes, {findThemeByName} from 'gmf/theme/Themes'; import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr'; import ngeoMiscAutoProjection from 'ngeo/misc/AutoProjection'; - import ngeoMiscColorpickerComponent from 'ngeo/misc/colorpickerComponent'; - import ngeoMessagePopoverComponent from 'ngeo/message/popoverComponent'; - import olFeature from 'ol/Feature'; import {asArray as asColorArray} from 'ol/color'; import olGeomPoint from 'ol/geom/Point'; @@ -65,16 +62,17 @@ function gmfSearchTemplateUrl_(element, attrs) { const templateUrl = attrs.gmfSearchTemplateurl; return templateUrl !== undefined ? templateUrl : 'gmf/search'; } - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/search', require('./component.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/search', require('./component.html')); + }, + ], ); /** @@ -82,10 +80,10 @@ myModule.run( * @param {angular.IAttributes} $attrs Attributes. * @param {function(JQuery, angular.IAttributes): string} gmfSearchTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfSearchTemplateUrl.$inject = ['$element', '$attrs', 'gmfSearchTemplateUrl']; function gmfSearchTemplateUrl($element, $attrs, gmfSearchTemplateUrl) { return gmfSearchTemplateUrl($element, $attrs); } @@ -140,7 +138,6 @@ const searchComponent = { controller: 'gmfSearchController', templateUrl: gmfSearchTemplateUrl, }; - myModule.value('gmfSearchTemplateUrl', gmfSearchTemplateUrl_); // Register the controller in the module @@ -170,7 +167,6 @@ export class SearchController { * @param {import('gmf/options').gmfSearchOptions} gmfSearchOptions The options. * @param {import('gmf/options').gmfSearchGroups} gmfSearchGroups The groups. * @param {string} fulltextsearchUrl The service URL. - * @ngInject * @ngdoc controller * @ngname GmfSearchController */ @@ -298,9 +294,9 @@ export class SearchController { /** * @type {Twitter.Typeahead.Options} */ - this.typeaheadOptions = /** @type {Twitter.Typeahead.Options} */ ({ + this.typeaheadOptions = /** @type {Twitter.Typeahead.Options} */ { highlight: true, - }); + }; /** * @type {(Twitter.Typeahead.Dataset>|Twitter.Typeahead.Dataset)[]} @@ -341,18 +337,14 @@ export class SearchController { * @type {string} */ this.optionsName = null; - if (!this.clearButton) { // Empty the search field on focus and blur. this.element_.find('input').on('focus blur', () => { this.clear(); }); } - this.featureOverlay_.setStyle(this.getSearchStyle_.bind(this)); - this.scope_.$watch(() => this.color, this.setStyleColor.bind(this)); - if (this.ngeoLocation_) { const searchQuery = this.ngeoLocation_.getParam('search'); if (searchQuery) { @@ -386,7 +378,6 @@ export class SearchController { this.options = this.injector_.get(config); this.placeholder = this.options.placeholder || 'Search…'; gettextCatalog.getString('Search…'); - this.coordinatesProjectionsInstances_ = this.options.coordinatesProjections === undefined ? [this.map.getView().getProjection()] @@ -396,16 +387,13 @@ export class SearchController { if (this.typeaheadOptions) { Object.assign(this.options, this.typeaheadOptions); } - this.initDatasets_(); - this.listeners = this.mergeListeners_(this.additionalListeners, { select: this.select_.bind(this), change: this.handleChange_.bind(this), close: this.close_.bind(this), datasetsempty: this.datasetsempty_.bind(this), }); - if (this.onInitCallback) { this.onInitCallback(); } @@ -462,7 +450,6 @@ export class SearchController { const groupActions = datasource.groupActions || []; /** @type {{title: string, filter: function(import("geojson").Feature): boolean}[]} */ const filters = []; - if (groupValues.length === 0) { filters.push({ 'title': '', @@ -476,14 +463,12 @@ export class SearchController { }); }); } - groupActions.forEach((action) => { filters.push({ 'title': gettextCatalog.getString(action.title), 'filter': this.filterAction_(action.action), }); }); - filters.forEach((filter) => { this.datasets.push( this.createDataset_( @@ -517,7 +502,6 @@ export class SearchController { */ suggestion: (suggestion) => { const coordinates = suggestion.label; - let html = `

${coordinates}

`; html = `
${html}
`; return html; @@ -558,11 +542,8 @@ export class SearchController { const scope = componentScope.$new(true); // @ts-ignore: scope ... scope.feature = suggestion; - let html = `

${suggestion.get(config.labelKey)}

`; - html += `

${ - suggestion.get('layer_name') || config.datasetTitle - }

`; + html += `

${suggestion.get('layer_name') || config.datasetTitle}

`; html = `
${html}
`; return compile(html)(scope).html(); }, @@ -593,7 +574,7 @@ export class SearchController { // add it to the corresponding group return ( !properties.layer_name && - /** @type {import('gmf/options').SearchAction[]} */ (properties.actions).some( + /** @type {import('gmf/options').SearchAction[]} */ properties.actions.some( (act) => act.action === action, ) ); @@ -662,7 +643,7 @@ export class SearchController { */ getBloodhoudRemoteOptions_() { const gettextCatalog = this.gettextCatalog_; - return /** @type {Bloodhound.RemoteOptions} */ ({ + return /** @type {Bloodhound.RemoteOptions} */ { rateLimitWait: this.options.delay == undefined ? 50 : this.options.delay, prepare: (query, settings) => { const url = settings.url; @@ -679,7 +660,7 @@ export class SearchController { }); return settings; }, - }); + }; } /** @@ -738,28 +719,26 @@ export class SearchController { const style = buildStyle( this.options.styles[feature.get('layer_name')] || this.options.styles['default'], ); - const trueStyle = /** @type {import('ol/style/Style').default} */ (style); + const trueStyle = /** @type {import('ol/style/Style').default} */ style; if (this.color) { const color = asColorArray(this.color); - const strokeStyle = trueStyle.getStroke(); - const prevStrokeColor = /** @type {number[]} */ (strokeStyle.getColor()); + const prevStrokeColor = /** @type {number[]} */ strokeStyle.getColor(); const strokeColor = color.slice(); strokeColor[3] = prevStrokeColor[3]; if (strokeStyle) { strokeStyle.setColor(strokeColor); } const fillStyle = trueStyle.getFill(); - const prevFillColor = /** @type {number[]} */ (fillStyle.getColor()); + const prevFillColor = /** @type {number[]} */ fillStyle.getColor(); const fillColor = color.slice(); fillColor[3] = prevFillColor[3]; if (fillStyle) { fillStyle.setColor(fillColor); } - let imageStyle = trueStyle.getImage(); if (imageStyle) { - const circleStyle = /** @type {import('ol/style/Circle').default} */ (imageStyle); + const circleStyle = /** @type {import('ol/style/Circle').default} */ imageStyle; const imageStrokeStyle = circleStyle.getStroke(); if (imageStrokeStyle) { imageStrokeStyle.setColor(strokeColor); @@ -842,9 +821,8 @@ export class SearchController { } // @ts-ignore: extra parameter if (suggestion.tt_source === 'coordinates') { - const coordinateSuggestion = /** @type {CoordinateSuggestion} */ (suggestion); + const coordinateSuggestion = /** @type {CoordinateSuggestion} */ suggestion; const geom = new olGeomPoint(coordinateSuggestion.position); - this.featureOverlay_.clear(); this.featureOverlay_.addFeature( new olFeature({ @@ -891,9 +869,9 @@ export class SearchController { } else if (actionName == 'add_group') { this.gmfTreeManager_.addGroupByName(actionData, true); } else if (actionName == 'add_layer') { - const groupActions = /** @type {import('gmf/options').SearchAction[]} */ ( - this.options.datasources[0].groupActions - ); + const groupActions = + /** @type {import('gmf/options').SearchAction[]} */ + this.options.datasources[0].groupActions; let datasourcesActionsHaveAddLayer; groupActions.forEach((groupAction) => { if (groupAction.action === 'add_layer') { @@ -912,7 +890,6 @@ export class SearchController { } } } - const size = this.map.getSize(); if (featureGeometry instanceof Geometry && size) { const view = this.map.getView(); @@ -966,7 +943,6 @@ export class SearchController { this.featureOverlay_.clear(); this.displayColorPicker = false; } - const menu = this.element_.find('.twitter-typeahead .tt-menu'); const message = menu.children('.gmf-search-no-results'); if (message.length == 0) { @@ -997,33 +973,37 @@ export class SearchController { // can't be lower than one resultIndex = 1; } - this.fullTextSearch_.search(query, {limit: `${resultIndex}`}).then((data) => { - if (!this.map) { - throw new Error('Missing map'); - } - if (data && data.features[resultIndex - 1]) { - const format = new olFormatGeoJSON(); - const feature = /** @type {import('ol/Feature').default} */ ( - format.readFeature(data.features[resultIndex - 1]) - ); - feature.set('name', 'SearchFeature'); - this.featureOverlay_.addFeature(feature); - /** - * @type {import('ol/View').FitOptions} - */ - const fitOptions = {}; - if (opt_zoom !== undefined) { - fitOptions.maxZoom = opt_zoom; - fitOptions.size = this.map.getSize() || null; + this.fullTextSearch_ + .search(query, { + limit: `${resultIndex}`, + }) + .then((data) => { + if (!this.map) { + throw new Error('Missing map'); } - const geometry = feature.getGeometry(); - if (!geometry) { - throw new Error('Missing geometry'); + if (data && data.features[resultIndex - 1]) { + const format = new olFormatGeoJSON(); + const feature = + /** @type {import('ol/Feature').default} */ + format.readFeature(data.features[resultIndex - 1]); + feature.set('name', 'SearchFeature'); + this.featureOverlay_.addFeature(feature); + /** + * @type {import('ol/View').FitOptions} + */ + const fitOptions = {}; + if (opt_zoom !== undefined) { + fitOptions.maxZoom = opt_zoom; + fitOptions.size = this.map.getSize() || null; + } + const geometry = feature.getGeometry(); + if (!geometry) { + throw new Error('Missing geometry'); + } + this.map.getView().fit(geometry.getExtent(), fitOptions); + this.inputValue = /** @type {string} */ feature.get('label'); } - this.map.getView().fit(geometry.getExtent(), fitOptions); - this.inputValue = /** @type {string} */ (feature.get('label')); - } - }); + }); } /** @@ -1041,8 +1021,23 @@ export class SearchController { this.datasetsempty_(event, query, false); } } - +SearchController.$inject = [ + '$element', + '$scope', + '$compile', + '$timeout', + '$injector', + 'gettextCatalog', + 'ngeoAutoProjection', + 'ngeoSearchCreateGeoJSONBloodhound', + 'gmfThemes', + 'gmfTreeManager', + 'gmfSearchFulltextSearch', + 'ngeoLocation', + 'gmfSearchOptions', + 'gmfSearchGroups', + 'fulltextsearchUrl', +]; // Register the controller in the module myModule.controller('gmfSearchController', SearchController); - export default myModule; diff --git a/src/search/searchDirective.js b/src/search/searchDirective.js index a29a7fdfb3d6..56fbebe766d0 100644 --- a/src/search/searchDirective.js +++ b/src/search/searchDirective.js @@ -50,7 +50,6 @@ import angular from 'angular'; * @htmlAttribute {Twitter.Typeahead.Dataset[]} ngeo-search-datasets The sources datasets. * @htmlAttribute {SearchDirectiveListeners} ngeo-search-listeners The listeners. * @returns {angular.IDirective} Directive Definition Object. - * @ngInject * @template T */ function searchComponent() { @@ -65,13 +64,10 @@ function searchComponent() { const typeaheadOptionsExpr = attrs.ngeoSearch; /** @type {Twitter.Typeahead.Options} */ const typeaheadOptions = scope.$eval(typeaheadOptionsExpr); - const typeaheadDatasetsExpr = attrs.ngeoSearchDatasets; /** @type {Twitter.Typeahead.Dataset[]} */ const typeaheadDatasets = scope.$eval(typeaheadDatasetsExpr); - element.typeahead(typeaheadOptions, typeaheadDatasets); - const typeaheadListenersExpr = attrs.ngeoSearchListeners; /** @type {SearchDirectiveListeners} */ const typeaheadListeners_ = scope.$eval(typeaheadListenersExpr); @@ -80,19 +76,16 @@ function searchComponent() { * @type {SearchDirectiveListeners} */ const typeaheadListeners = adaptListeners_(typeaheadListeners_); - element.on('typeahead:open', () => { scope.$apply(() => { typeaheadListeners.open(); }); }); - element.on('typeahead:close', () => { scope.$apply(() => { typeaheadListeners.close(); }); }); - element.on( 'typeahead:cursorchange', /** @@ -106,7 +99,6 @@ function searchComponent() { }); }, ); - element.on( 'typeahead:select', /** @@ -120,7 +112,6 @@ function searchComponent() { }); }, ); - element.on( 'typeahead:autocomplete', /** @@ -134,7 +125,6 @@ function searchComponent() { }); }, ); - element.on( 'typeahead:asyncreceive', /** @@ -149,7 +139,6 @@ function searchComponent() { }); }, ); - element.on( 'typeahead:change', /** @@ -226,5 +215,4 @@ const myModule = angular.module('ngeoSearchDirective', []); // Register the directive in the module myModule.directive('ngeoSearch', searchComponent); - export default myModule; diff --git a/src/spinner/directive.js b/src/spinner/directive.js index bb5abf975a4f..6e9de299c41f 100644 --- a/src/spinner/directive.js +++ b/src/spinner/directive.js @@ -22,7 +22,6 @@ import angular from 'angular'; /** - * @ngInject * @param {angular.IHttpService} $http Angular HTTP service. * @returns {angular.IDirective} The Directive Definition Object. * @ngdoc directive @@ -52,13 +51,12 @@ const loaderSpinner = function ($http) { }, }; }; - +loaderSpinner.$inject = ['$http']; +loaderSpinner.$inject = ['$http']; /** * @type {angular.IModule} * @hidden */ const myModule = angular.module('gmfLoaderSpinner', []); - myModule.directive('gmfLoaderSpinner', loaderSpinner); - export default myModule; diff --git a/src/statemanager/Location.js b/src/statemanager/Location.js index 758888ab06d0..704bb32bd577 100644 --- a/src/statemanager/Location.js +++ b/src/statemanager/Location.js @@ -1,3 +1,4 @@ +LocationFactory.$inject = ['$rootScope', '$window']; // The MIT License (MIT) // // Copyright (c) 2014-2024 Camptocamp SA @@ -109,33 +110,26 @@ StatemanagerLocation.prototype.getPath = function () { */ StatemanagerLocation.prototype.getUriString = function () { const out = []; - if (this.schema_) { out.push(this.schema_, ':'); } - if (this.domain_ || this.schema_ === 'file') { out.push('//'); - out.push(this.domain_); - if (this.port_ !== undefined) { out.push(':', String(this.port_)); } } - if (this.path_) { if (this.domain_ && !this.path_.startsWith('/')) { out.push('/'); } out.push(this.path_); } - const encodedQueryData = encodeQueryString(this.queryData_); if (encodedQueryData.length > 0) { out.push('?', encodedQueryData); } - const encodedFragment = encodeQueryString(this.fragment_); if (encodedFragment.length > 0) { out.push('#', encodedFragment); @@ -357,13 +351,11 @@ StatemanagerLocation.prototype.setPath = function (path) { * @param {angular.IScope} $rootScope The root scope. * @param {angular.IWindowService} $window Angular window service. * @returns {StatemanagerLocation} The ngeo location service. - * @ngInject * @hidden */ export function LocationFactory($rootScope, $window) { const history = $window.history; const service = new StatemanagerLocation($window.location, $window.history); - let lastUri = service.getUriString(); $rootScope.$watch(() => { const newUri = service.getUriString(); @@ -377,7 +369,6 @@ export function LocationFactory($rootScope, $window) { }); } }); - return service; } @@ -388,5 +379,4 @@ export function LocationFactory($rootScope, $window) { */ const myModule = angular.module('ngeoLocation', []); myModule.factory('ngeoLocation', LocationFactory); - export default myModule; diff --git a/src/statemanager/Service.js b/src/statemanager/Service.js index 09cf435f42de..356ada7bcd4b 100644 --- a/src/statemanager/Service.js +++ b/src/statemanager/Service.js @@ -32,7 +32,6 @@ export class StatemanagerService { /** * @param {import('ngeo/statemanager/Location').StatemanagerLocation} ngeoLocation ngeo location service. * @param {import('ngeo/options').ngeoUsedKeyRegexp} ngeoUsedKeyRegexp regexp used to identify the used keys. - * @ngInject */ constructor(ngeoLocation, ngeoUsedKeyRegexp) { /** @@ -60,7 +59,6 @@ export class StatemanagerService { * @private */ this.useLocalStorage_ = false; - this.setUseLocalStorage(false); // Populate initialState with the application's initial state. The initial @@ -68,12 +66,10 @@ export class StatemanagerService { // is no state in the location URL. const paramKeys = ngeoLocation.getParamKeys().filter((key) => key != 'debug' && key != 'no_redirect'); - if (paramKeys.length === 0) { if (this.useLocalStorage_) { for (const key in window.localStorage) { console.assert(key); - this.usedKeyRegexp.some((keyRegexp) => { if (keyRegexp.exec(key)) { const value = window.localStorage[key]; @@ -195,12 +191,11 @@ export class StatemanagerService { } } } - +StatemanagerService.$inject = ['ngeoLocation', 'ngeoUsedKeyRegexp']; /** * @type {angular.IModule} * @hidden */ const myModule = angular.module('ngeoStateManager', [ngeoStatemanagerLocation.name]); myModule.service('ngeoStateManager', StatemanagerService); - export default myModule; diff --git a/src/statemanager/WfsPermalink.js b/src/statemanager/WfsPermalink.js index aa14c4d50379..06a25f705980 100644 --- a/src/statemanager/WfsPermalink.js +++ b/src/statemanager/WfsPermalink.js @@ -1,3 +1,10 @@ +WfsPermalinkService.$inject = [ + '$http', + 'ngeoPermalinkOgcserverUrl', + 'ngeoQueryResult', + 'ngeoWfsPermalinkOptions', + 'gmfFitOptions', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -113,7 +120,6 @@ import olFormatWFS from 'ol/format/WFS'; * @param {import('ngeo/options').gmfFitOptions} gmfFitOptions The fit options. * @ngdoc service * @ngname ngeoWfsPermalink - * @ngInject */ export function WfsPermalinkService( $http, @@ -133,14 +139,12 @@ export function WfsPermalinkService( * @type {number} */ this.maxFeatures_ = options.maxFeatures !== undefined ? options.maxFeatures : 50; - this._gmfFitOptions = gmfFitOptions; /** * @type {Object} */ this.wfsTypes_ = {}; - console.assert(Array.isArray(options.wfsTypes), 'wfsTypes is not correctly set'); options.wfsTypes.forEach((wfsType) => { this.wfsTypes_[wfsType.featureType] = wfsType; @@ -193,18 +197,15 @@ WfsPermalinkService.prototype.issue = function (queryData, map, zoomLevel = unde 'url is not set. to use the wfs permalink service, ' + 'set the value `ngeoWfsPermalinkOptions`', ); this.clearResult_(); - const typeName = queryData.wfsType; if (!this.wfsTypes_.hasOwnProperty(typeName)) { return; } const wfsType = this.wfsTypes_[typeName]; - const filters = this.createFilters_(queryData.filterGroups); if (filters === null) { return; } - this.issueRequest_(wfsType, filters, map, queryData.showFeatures, zoomLevel); }; @@ -232,10 +233,11 @@ WfsPermalinkService.prototype.issueRequest_ = function ( filter: filter, maxFeatures: this.maxFeatures_, }); - const featureRequest = new XMLSerializer().serializeToString(featureRequestXml); const config = { - headers: {'Content-Type': 'text/xml; charset=UTF-8'}, + headers: { + 'Content-Type': 'text/xml; charset=UTF-8', + }, }; this.$http_.post(this.url_, featureRequest, config).then((response) => { const features = wfsFormat.readFeatures(response.data); @@ -249,7 +251,11 @@ WfsPermalinkService.prototype.issueRequest_ = function ( if (size !== undefined) { const defaultMaxZoomLevel = zoomLevel === undefined ? this.pointRecenterZoom_ : zoomLevel; const defaultPadding = [50, 50, 50, 50]; - const fitOptions = {size, maxZoom: defaultMaxZoomLevel, padding: defaultPadding}; + const fitOptions = { + size, + maxZoom: defaultMaxZoomLevel, + padding: defaultPadding, + }; Object.apply(fitOptions, this._gmfFitOptions); map.getView().fit(this.getExtent_(features), fitOptions); } @@ -257,14 +263,13 @@ WfsPermalinkService.prototype.issueRequest_ = function ( // then show if requested if (showFeatures) { - const resultSource = /** @type {QueryResultSource} */ ({ + const resultSource = /** @type {QueryResultSource} */ { 'features': features, 'id': wfsType.featureType, 'identifierAttributeField': wfsType.label, 'label': wfsType.featureType, 'pending': false, - }); - + }; this.result_.sources.push(resultSource); this.result_.total = features.length; } @@ -276,18 +281,15 @@ WfsPermalinkService.prototype.issueRequest_ = function ( * @returns {import('ol/extent').Extent} The extent of all features. */ WfsPermalinkService.prototype.getExtent_ = function (features) { - return /** @type {import('ol/extent').Extent} */ /** @type {any[]} */ (features).reduce( - (extent, feature) => { - if (feature instanceof Feature) { - const geometry = feature.getGeometry(); - if (geometry) { - return extendExtent(extent, geometry.getExtent()); - } - return extent; + return /** @type {import('ol/extent').Extent} */ /** @type {any[]} */ features.reduce((extent, feature) => { + if (feature instanceof Feature) { + const geometry = feature.getGeometry(); + if (geometry) { + return extendExtent(extent, geometry.getExtent()); } - }, - createEmptyExtent(), - ); + return extent; + } + }, createEmptyExtent()); }; /** @@ -381,7 +383,5 @@ WfsPermalinkService.prototype.clearResult_ = function () { const myModule = angular.module('ngeoWfsPermalink', [ // FIXME add dependencies ]); - myModule.service('ngeoWfsPermalink', WfsPermalinkService); - export default myModule; diff --git a/src/streetview/GoogleStreetviewService.js b/src/streetview/GoogleStreetviewService.js index 172de300b386..8105e1fd5114 100644 --- a/src/streetview/GoogleStreetviewService.js +++ b/src/streetview/GoogleStreetviewService.js @@ -32,7 +32,6 @@ export default class GoogleStreetviewService extends StreetviewService { * @param {(newCoordinates: import('ol/coordinate').Coordinate | null) => void}handlePanoramaPositionChange Position change handler * @param {number} radius The radius * @param {JQuery} $element Element - * @ngInject */ constructor($scope, map, handlePanoramaPositionChange, radius, $element) { super($scope, map, handlePanoramaPositionChange); @@ -100,14 +99,12 @@ export default class GoogleStreetviewService extends StreetviewService { throw new Error('Missing data.location.latLng'); } const panorama = this.panorama_; - if (status === google.maps.StreetViewStatus.OK) { this.noDataAtLocation = false; panorama.setPosition(data.location.latLng); } else { this.noDataAtLocation = true; } - this.scope_.$apply(); } @@ -137,7 +134,6 @@ export default class GoogleStreetviewService extends StreetviewService { */ toggleShow(show) { this.panorama_.setVisible(show); - if (show) { this.panoramaListener_ = google.maps.event.addListener( this.panorama_, @@ -150,3 +146,4 @@ export default class GoogleStreetviewService extends StreetviewService { } } } +GoogleStreetviewService.$inject = ['$scope', 'map', 'handlePanoramaPositionChange', 'radius', '$element']; diff --git a/src/streetview/MapillaryService.js b/src/streetview/MapillaryService.js index 15225e6f0696..b8c7f73876c2 100644 --- a/src/streetview/MapillaryService.js +++ b/src/streetview/MapillaryService.js @@ -21,7 +21,6 @@ import {StreetviewService} from './Service'; import 'mapillary-js/dist/mapillary.css'; import {buffer} from 'ol/extent'; - const MLY_METADATA_ENDPOINT = 'https://graph.mapillary.com'; /** @@ -36,7 +35,6 @@ export default class MapillaryService extends StreetviewService { * @param {(newCoordinates: import('ol/coordinate').Coordinate | null) => void} handlePanoramaPositionChange Position change handler. * @param {string} accessToken The key to access the mapillary api. * @param {number} bufferSize The size to add to the bbox buffer. - * @ngInject */ constructor($scope, $timeout, $http, map, handlePanoramaPositionChange, accessToken, bufferSize) { super($scope, map, handlePanoramaPositionChange); @@ -73,10 +71,8 @@ export default class MapillaryService extends StreetviewService { */ this.mapillaryElement = document.getElementById('mly'); this.mapillaryElement.hidden = true; - import(/* webpackChunkName: "mapillary" */ 'mapillary-js/src/Mapillary').then((Mapillary) => { this.Mapillary = Mapillary; - this.mly = new Mapillary.Viewer({ accessToken: this.accessToken_, container: 'mly', @@ -196,3 +192,12 @@ export default class MapillaryService extends StreetviewService { ); } } +MapillaryService.$inject = [ + '$scope', + '$timeout', + '$http', + 'map', + 'handlePanoramaPositionChange', + 'accessToken', + 'bufferSize', +]; diff --git a/src/streetview/component.js b/src/streetview/component.js index ba8252ae3683..cd0ed83044ff 100644 --- a/src/streetview/component.js +++ b/src/streetview/component.js @@ -34,7 +34,6 @@ import MapillaryService from './MapillaryService'; * @hidden */ const myModule = angular.module('ngeoStreetview', []); - myModule.value( 'ngeoStreetviewTemplateUrl', /** @@ -46,26 +45,27 @@ myModule.value( return templateUrl !== undefined ? templateUrl : 'ngeo/streetview'; }, ); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('ngeo/streetview', require('./component.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('ngeo/streetview', require('./component.html')); + }, + ], ); /** * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} ngeoStreetviewTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +ngeoStreetviewTemplateUrl.$inject = ['$attrs', 'ngeoStreetviewTemplateUrl']; function ngeoStreetviewTemplateUrl($attrs, ngeoStreetviewTemplateUrl) { return ngeoStreetviewTemplateUrl($attrs); } @@ -102,7 +102,6 @@ class StreetviewController { * @param {angular.auto.IInjectorService} $injector Main injector. * @param {angular.ITimeoutService} $timeout * FeatureOverlay manager. - * @ngInject * @ngdoc controller * @ngname NgeoStreetviewController */ @@ -123,7 +122,6 @@ class StreetviewController { * @type {boolean} */ this.active = false; - $scope.$watch(() => this.active, this.handleActiveChange_.bind(this)); /** @@ -208,7 +206,6 @@ class StreetviewController { * @private */ this.point_ = new olGeomPoint([0, 0]); - this.feature_.setGeometry(this.point_); /** @@ -237,7 +234,7 @@ class StreetviewController { this.handlePanoramaPositionChange_ = (newCoordinates) => { this.panoramaPositionChanging_ = true; this.map.getView().setCenter(newCoordinates); - const point = /** @type {import('ol/geom/Point').default} */ (this.feature_.getGeometry()); + const point = /** @type {import('ol/geom/Point').default} */ this.feature_.getGeometry(); point.setCoordinates(newCoordinates); this.location = newCoordinates; this.scope_.$apply(); @@ -263,9 +260,7 @@ class StreetviewController { * @type {import('ngeo/options').ngeoStreetviewOptions} */ this.options = this.injector_.has(config) ? this.injector_.get(config) : null; - this.viewer = this.options.viewer || 'mapillary'; - if (this.viewer === 'mapillary') { this.initMapillary_(); } else { @@ -279,7 +274,6 @@ class StreetviewController { this.addWatchers_(); } } - addWatchers_() { // === Watchers === @@ -354,9 +348,7 @@ class StreetviewController { if (!this.map) { throw new Error('Missing map'); } - const keys = this.listenerKeys_; - if (active) { keys.push(listen(this.map, 'click', this.handleMapClick_, this)); } else { @@ -421,7 +413,6 @@ class StreetviewController { if (ready === oldReady) { return; } - if (ready) { this.featureOverlay_.addFeature(this.feature_); setTimeout(() => { @@ -432,7 +423,7 @@ class StreetviewController { } } } - +StreetviewController.$inject = ['$element', '$scope', '$http', '$injector', '$timeout']; myModule.component('ngeoStreetview', { bindings: { 'active': '<', @@ -445,5 +436,4 @@ myModule.component('ngeoStreetview', { controller: StreetviewController, templateUrl: ngeoStreetviewTemplateUrl, }); - export default myModule; diff --git a/src/theme/Manager.js b/src/theme/Manager.js index cc0d2896e095..370793a9be98 100644 --- a/src/theme/Manager.js +++ b/src/theme/Manager.js @@ -1,3 +1,10 @@ +ThemeManagerService.$inject = [ + '$rootScope', + 'gmfThemes', + 'gmfTreeManagerModeFlush', + 'gmfTreeManager', + 'ngeoStateManager', +]; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -55,7 +62,6 @@ export const ThemeEventType = { * @param {import('gmf/layertree/TreeManager').LayertreeTreeManager} gmfTreeManager the tree manager. * @param {import('ngeo/statemanager/Service').StatemanagerService} ngeoStateManager The ngeo statemanager * service. - * @ngInject * @ngdoc service * @ngname gmfTreeManager * @hidden @@ -194,7 +200,5 @@ const myModule = angular.module('gmfThemeManager', [ gmfThemeThemes.name, ngeoStatemanagerService.name, ]); - myModule.service('gmfThemeManager', ThemeManagerService); - export default myModule; diff --git a/src/theme/Themes.js b/src/theme/Themes.js index a79d555bf34b..11c4e4613c9e 100644 --- a/src/theme/Themes.js +++ b/src/theme/Themes.js @@ -47,7 +47,6 @@ export class ThemesService extends olEventsEventTarget { * @param {string} gmfVectorTilesUrl The Vector Tiles URL. * @param {import('gmf/options').gmfVectorTilesOptions} gmfVectorTilesOptions the VectorTiles options. * @param {import('gmf/options').gmfWMSSourceOptions} gmfWMSSourceOptions the WMS source options. - * @ngInject */ constructor( $http, @@ -162,8 +161,8 @@ export class ThemesService extends olEventsEventTarget { if (this.bgLayerPromise_) { return this.bgLayerPromise_; } - - this.bgLayerPromise_ = /** @type {angular.IPromise} */ ( + this.bgLayerPromise_ = + /** @type {angular.IPromise} */ this.promise_.then(this.bgLayerPromiseSuccessFn_.bind(this)).then((values) => { /** @type {import('ol/layer/Base').default[]} */ const layers = []; @@ -181,9 +180,7 @@ export class ThemesService extends olEventsEventTarget { } }); return layers; - }) - ); - + }); return this.bgLayerPromise_; } @@ -193,7 +190,7 @@ export class ThemesService extends olEventsEventTarget { */ getLayerGroupIds_(item, array) { array.push(olUtilGetUid(item)); - const groupItem = /** @type {import('gmf/themes').GmfGroup} */ (item); + const groupItem = /** @type {import('gmf/themes').GmfGroup} */ item; const children = groupItem.children || []; children.forEach((child) => { this.getLayerGroupIds_(child, array); @@ -225,17 +222,17 @@ export class ThemesService extends olEventsEventTarget { */ layerLayerCreationFn_(ogcServers, gmfLayer) { if (gmfLayer.type === 'WMTS') { - const gmfLayerWMTS = /** @type {import('gmf/themes').GmfLayerWMTS} */ (/** @type {any} */ (gmfLayer)); + const gmfLayerWMTS = /** @type {import('gmf/themes').GmfLayerWMTS} */ /** @type {any} */ gmfLayer; return this.layerLayerWMTSCreationFn_(gmfLayerWMTS); } if (gmfLayer.type === 'WMS') { - const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ (/** @type {any} */ (gmfLayer)); + const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ /** @type {any} */ gmfLayer; return this.layerLayerWMSCreationFn_(ogcServers, gmfLayerWMS); } if (gmfLayer.type === 'VectorTiles') { - const gmfLayerVectorTiles = /** @type {import('gmf/themes').GmfLayerVectorTiles} */ ( - /** @type {any} */ (gmfLayer) - ); + const gmfLayerVectorTiles = + /** @type {import('gmf/themes').GmfLayerVectorTiles} */ + /** @type {any} */ gmfLayer; return this.layerLayerVectorTilesCreationFn_(gmfLayerVectorTiles); } throw new Error(`Unsupported type: ${gmfLayer.type}`); @@ -296,7 +293,9 @@ export class ThemesService extends olEventsEventTarget { // Manage WMS styles /** @type {Object} */ - const opt_params = {STYLES: gmfLayerWMS.style}; + const opt_params = { + STYLES: gmfLayerWMS.style, + }; if (gmfLayerWMS.dimensions) { for (const [key, value] of Object.entries(gmfLayerWMS.dimensions)) { if (value !== null) { @@ -304,7 +303,6 @@ export class ThemesService extends olEventsEventTarget { } } } - return this.setLayerProperties_( gmfLayerWMS, this.layerHelper_.createBasicWMSLayer( @@ -312,7 +310,8 @@ export class ThemesService extends olEventsEventTarget { gmfLayerWMS.layers || '', server.imageType, server.type, - undefined, // time + undefined, + // time opt_params, server.credential ? 'use-credentials' : 'anonymous', Object.assign({}, this.gmfWMSSourceOptions_, gmfLayerWMS.metadata.customOpenLayersOptions), @@ -367,7 +366,7 @@ export class ThemesService extends olEventsEventTarget { // The order of insertion in OL3 is the contrary of the theme const orderedChildren = item.children.map((x) => x).reverse(); const promises = orderedChildren.map((item) => - this.layerLayerCreationFn_(ogcServers, /** @type {import('gmf/themes').GmfLayer} */ (item)), + this.layerLayerCreationFn_(ogcServers, /** @type {import('gmf/themes').GmfLayer} */ item), ); return this.$q_.all(promises).then((layers) => { let collection; @@ -387,22 +386,21 @@ export class ThemesService extends olEventsEventTarget { * @returns {angular.IPromise} Promise. */ bgLayerPromiseSuccessFn_(data) { - const promises = /** @type {angular.IPromise} */ ( - /** @type {*} */ ( - data.background_layers.map((item) => { - const itemLayer = /** @type {import('gmf/themes').GmfLayer} */ (item); - const itemGroup = /** @type {import('gmf/themes').GmfGroup} */ (item); - if (['WMS', 'WMTS', 'VectorTiles'].includes(itemLayer.type)) { - return this.layerLayerCreationFn_(data.ogcServers, itemLayer); - } else if (itemGroup.children) { - // group of layers - return this.layerGroupCreationFn_(data.ogcServers, itemGroup); - } else { - return undefined; - } - }) - ) - ); + const promises = + /** @type {angular.IPromise} */ + /** @type {*} */ + data.background_layers.map((item) => { + const itemLayer = /** @type {import('gmf/themes').GmfLayer} */ item; + const itemGroup = /** @type {import('gmf/themes').GmfGroup} */ item; + if (['WMS', 'WMTS', 'VectorTiles'].includes(itemLayer.type)) { + return this.layerLayerCreationFn_(data.ogcServers, itemLayer); + } else if (itemGroup.children) { + // group of layers + return this.layerGroupCreationFn_(data.ogcServers, itemGroup); + } else { + return undefined; + } + }); return /** @type {angular.IPromise} */ /** @type {*} */ this.$q_.all( promises, ); @@ -420,7 +418,9 @@ export class ThemesService extends olEventsEventTarget { source: new VectorSource(), }); layer.set('label', 'blank'); - layer.set('metadata', {thumbnail: ''}); + layer.set('metadata', { + thumbnail: '', + }); return layer; } @@ -523,12 +523,11 @@ export class ThemesService extends olEventsEventTarget { * @returns {boolean} Editable layers? */ hasNodeEditableLayers_(node) { - const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ (node); - const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ (node); + const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ node; + const gmfLayer = /** @type {import('gmf/themes').GmfLayer} */ node; if (gmfLayer.editable) { return true; } - let hasEditableLayers = false; const children = gmfGroup.children; if (children && children.length) { @@ -545,7 +544,6 @@ export class ThemesService extends olEventsEventTarget { if (!this.treeUrl_) { throw new Error('gmfTreeUrl should be defined.'); } - if (this.loaded) { // reload the themes this.deferred_ = this.$q_.defer(); @@ -553,7 +551,6 @@ export class ThemesService extends olEventsEventTarget { this.bgLayerPromise_ = null; this.loaded = false; } - this.$http_ .get(this.treeUrl_, { params: @@ -579,7 +576,6 @@ export class ThemesService extends olEventsEventTarget { Object.values(response.data.ogcServers).forEach((server) => { server.geometryName = server.geometryName || 'geometry'; }); - this.deferred_.resolve(response.data); this.dispatchEvent('change'); this.loaded = true; @@ -590,7 +586,18 @@ export class ThemesService extends olEventsEventTarget { ); } } - +ThemesService.$inject = [ + '$http', + '$injector', + '$q', + 'ngeoLayerHelper', + 'gettextCatalog', + 'gmfThemesOptions', + 'gmfTreeUrl', + 'gmfVectorTilesUrl', + 'gmfVectorTilesOptions', + 'gmfWMSSourceOptions', +]; /** * @param {import('gmf/themes').GmfTheme[]} themes Array of "theme" objects. * @param {string} name The layer name. @@ -672,10 +679,10 @@ export function findThemeByName(themes, themeName) { * @hidden */ function getFlatInternalNodes(node, nodes) { - const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ (node); + const gmfGroup = /** @type {import('gmf/themes').GmfGroup} */ node; const children = gmfGroup.children; if (children !== undefined) { - nodes.push(/** @type {import('gmf/themes').GmfGroup} */ (node)); + nodes.push(/** @type {import('gmf/themes').GmfGroup} */ node); for (const child of children) { getFlatInternalNodes(child, nodes); } @@ -690,14 +697,14 @@ function getFlatInternalNodes(node, nodes) { * @hidden */ export function getFlatNodes(node, nodes) { - const gmfGroup = /** @type {import('gmf/themes').GmfTheme|import('gmf/themes').GmfGroup} */ (node); + const gmfGroup = /** @type {import('gmf/themes').GmfTheme|import('gmf/themes').GmfGroup} */ node; const children = gmfGroup.children; if (children !== undefined) { for (const child of children) { getFlatNodes(child, nodes); } } else { - nodes.push(/** @type {import('gmf/themes').GmfLayer} */ (node)); + nodes.push(/** @type {import('gmf/themes').GmfLayer} */ node); } } @@ -728,7 +735,7 @@ export function getSnappingConfig(node) { */ export function getNodeMaxResolution(gmfLayer) { const metadata = gmfLayer.metadata; - const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ (gmfLayer); + const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ gmfLayer; let maxResolution = gmfLayerWMS.maxResolutionHint; if (maxResolution === undefined && metadata !== undefined) { maxResolution = metadata.maxResolution; @@ -746,7 +753,7 @@ export function getNodeMaxResolution(gmfLayer) { */ export function getNodeMinResolution(gmfLayer) { const metadata = gmfLayer.metadata; - const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ (gmfLayer); + const gmfLayerWMS = /** @type {import('gmf/themes').GmfLayerWMS} */ gmfLayer; let minResolution = gmfLayerWMS.minResolutionHint; if (minResolution === undefined && metadata !== undefined) { minResolution = metadata.minResolution; @@ -771,7 +778,5 @@ export const ThemeNodeType = { * @hidden */ const myModule = angular.module('gmfThemes', [ngeoMapLayerHelper.name]); - myModule.service('gmfThemes', ThemesService); - export default myModule; diff --git a/src/theme/selectorComponent.js b/src/theme/selectorComponent.js index 2e8a1d0d358c..330cfbf4b7c0 100644 --- a/src/theme/selectorComponent.js +++ b/src/theme/selectorComponent.js @@ -1,3 +1,4 @@ +Controller.$inject = ['$scope', 'gmfThemeManager', 'gmfThemes']; // The MIT License (MIT) // // Copyright (c) 2016-2024 Camptocamp SA @@ -24,7 +25,6 @@ import {gmfBackgroundlayerStatus} from 'gmf/backgroundlayerselector/status'; import gmfThemeManager from 'gmf/theme/Manager'; import gmfThemeThemes from 'gmf/theme/Themes'; import {listen, unlistenByKey} from 'ol/events'; - import 'bootstrap/js/src/dropdown'; /** @@ -32,18 +32,18 @@ import 'bootstrap/js/src/dropdown'; * @hidden */ const myModule = angular.module('gmfThemeSelectorComponent', [gmfThemeManager.name, gmfThemeThemes.name]); - myModule.run( /** - * @ngInject * @param {angular.ITemplateCacheService} $templateCache */ - ($templateCache) => { - // @ts-ignore: webpack - $templateCache.put('gmf/theme/selectorComponent', require('./selectorComponent.html')); - }, + [ + '$templateCache', + ($templateCache) => { + // @ts-ignore: webpack + $templateCache.put('gmf/theme/selectorComponent', require('./selectorComponent.html')); + }, + ], ); - myModule.value( 'gmfThemeSelectorTemplateUrl', /** @@ -60,10 +60,10 @@ myModule.value( * @param {angular.IAttributes} $attrs Attributes. * @param {function(angular.IAttributes): string} gmfThemeSelectorTemplateUrl Template function. * @returns {string} Template URL. - * @ngInject * @private * @hidden */ +gmfThemeSelectorTemplateUrl.$inject = ['$attrs', 'gmfThemeSelectorTemplateUrl']; function gmfThemeSelectorTemplateUrl($attrs, gmfThemeSelectorTemplateUrl) { return gmfThemeSelectorTemplateUrl($attrs); } @@ -112,7 +112,6 @@ const themeSelectorComponent = { controller: 'gmfThemeselectorController', templateUrl: gmfThemeSelectorTemplateUrl, }; - myModule.component('gmfThemeselector', themeSelectorComponent); /** @@ -121,7 +120,6 @@ myModule.component('gmfThemeselector', themeSelectorComponent); * @param {import('gmf/theme/Themes').ThemesService} gmfThemes Themes service. * @class * @hidden - * @ngInject * @ngdoc controller * @ngname gmfThemeselectorController */ @@ -150,9 +148,7 @@ export function Controller($scope, gmfThemeManager, gmfThemes) { * @type {import('ol/events').EventsKey[]} */ this.listenerKeys_ = []; - this.listenerKeys_.push(listen(this.gmfThemes_, 'change', this.setThemes_, this)); - $scope.$on('$destroy', this.handleDestroy_.bind(this)); } @@ -177,12 +173,9 @@ Controller.prototype.setTheme = function (theme, opt_silent) { this.gmfThemeManager.addTheme(theme, opt_silent); } }; - Controller.prototype.handleDestroy_ = function () { this.listenerKeys_.forEach(unlistenByKey); this.listenerKeys_.length = 0; }; - myModule.controller('gmfThemeselectorController', Controller); - export default myModule;