diff --git a/.travis.yml b/.travis.yml index f7dd0fce38a8..109cb68c74c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,9 +63,7 @@ script: - buildtools/test_examples.py 1/1 #- npm run typecheck # Generate API doc -- npm install --prefix openlayers_src https://api.github.com/repos/openlayers/openlayers/tarball/v5.3.1 -- '! (npm run typecheck|sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g"|grep ^src)' -- '! (npm run typecheck|grep -E "api|gmf|test/|examples")' +- "! (npm run typecheck|grep -v '^node_modules/'|grep '^[a-z]')" - npm run doc - npm run build-api diff --git a/api/src/Map.js b/api/src/Map.js index c6326304f123..04cab3d74134 100644 --- a/api/src/Map.js +++ b/api/src/Map.js @@ -117,9 +117,10 @@ class Map { } this.map_.addControl(new OverviewMap({ collapsed: !options.miniMapExpanded, + layers: [], view: new View({ projection: this.view_.getProjection(), - resolutions + resolutions, }) })); } @@ -151,7 +152,7 @@ class Map { /** * @private - * @type {VectorSource} + * @type {VectorSource} */ this.vectorSource_ = new VectorSource(); diff --git a/api/src/Querent.js b/api/src/Querent.js index 4413797c2733..3b8826b9bf39 100644 --- a/api/src/Querent.js +++ b/api/src/Querent.js @@ -15,14 +15,14 @@ import olFormatWFS from 'ol/format/WFS.js'; * * @param {string} layer Name of the layer to query * @param {string[]} ids List of ids - * @return {Promise>} Promise. + * @return {Promise>>} Promise. * @hidden */ export function getFeaturesFromLayer(layer, ids) { return new Promise((resolve, reject) => { getOverlayDefs().then((overlayDefs) => { - /** @type {Array} */ + /** @type {Array>} */ let features = []; const overlayDef = overlayDefs.get(layer); diff --git a/api/src/Themes.js b/api/src/Themes.js index 8790ba34cc2f..766bbd40f8f3 100644 --- a/api/src/Themes.js +++ b/api/src/Themes.js @@ -38,7 +38,7 @@ let overlayDefPromise; * @return {Promise>} Promise */ export function getBackgroundLayers() { - return getThemesPromise().then((themes) => { + return getThemesPromise().then(themes => { const promises = []; for (const config of themes.background_layers) { const layerConfig = /** @type {import('gmf/themes.js').GmfLayer} */(config); @@ -61,32 +61,35 @@ export function getBackgroundLayers() { return layer; }) ); - } else if (/** @type {import('gmf/themes.js').GmfGroup} */ (config).children) { + } else if (/** @type {import('gmf/themes.js').GmfGroup} */(config).children) { // reverse children order - const reversed = /** @type {import('gmf/themes.js').GmfGroup} */ (config).children.slice().reverse(); + const reversed = /** @type {import('gmf/themes.js').GmfGroup} */(config).children.slice().reverse(); // create all the layers for the layer group - const groupPromise = Promise.all(reversed.map((item) => { - const child = /** @type {import('gmf/themes.js').GmfLayer} */ (item); + + /** @type {Promise[]} */ + const groupPromises = reversed.map(item => { + const child = /** @type {import('gmf/themes.js').GmfLayer} */(item); if (child.type === 'WMTS') { - const layerWMTS = /** @type {import('gmf/themes.js').GmfLayerWMTS} */ (child); + const layerWMTS = /** @type {import('gmf/themes.js').GmfLayerWMTS} */(child); return createWMTSLayer(layerWMTS); } else if (child.type === 'WMS') { - const layerWMS = /** @type {import('gmf/themes.js').GmfLayerWMS} */ (child); + const layerWMS = /** @type {import('gmf/themes.js').GmfLayerWMS} */(child); return createWMSLayer(layerWMS, themes.ogcServers[child.ogcServer]); } throw new Error('Unknow layer type'); - })); - promises.push( - groupPromise.then((layers) => { + }); + const groupPromise = Promise.all(groupPromises); + promises.push(groupPromise.then( + layers => { // create a layer group for the children. const group = new GroupLayer({ - layers: layers + layers }); group.set('config.name', config.name); return group; - }) - ); + } + )); } } return Promise.all(/** @type {Array>} */ (promises)); @@ -154,11 +157,12 @@ export function writeOverlayDefs(config, ogcServers, opt_ogcServer) { * Returns a list of OpenLayers layer objects from the given layer names. * * @param {string[]} layerNames List of layer names - * @return {Promise} Promise. + * @return {Promise<(TileLayer|ImageLayer)[]>} Promise. * @hidden */ export function getOverlayLayers(layerNames) { return getOverlayDefs().then((overlayDefs) => { + /** @type {Promise[]} */ const promises = []; for (const layerName of layerNames) { diff --git a/contribs/gmf/apps/oeedit/Controller.js b/contribs/gmf/apps/oeedit/Controller.js index cfad91d12b24..ee3e54cb1637 100644 --- a/contribs/gmf/apps/oeedit/Controller.js +++ b/contribs/gmf/apps/oeedit/Controller.js @@ -94,7 +94,7 @@ class Controller extends AbstractDesktopController { }); /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ this.sketchFeatures = new olCollection(); @@ -139,7 +139,7 @@ class Controller extends AbstractDesktopController { this.oeLayerNodeId = gmfObjectEditingManager.getLayerNodeId(); /** - * @type {?import("ol/Feature.js").default} + * @type {?import("ol/Feature.js").default} */ this.oeFeature = null; diff --git a/contribs/gmf/examples/drawfeature.js b/contribs/gmf/examples/drawfeature.js index 1944a5bee58c..b5a448a446ee 100644 --- a/contribs/gmf/examples/drawfeature.js +++ b/contribs/gmf/examples/drawfeature.js @@ -41,7 +41,7 @@ module.constant('angularLocaleScript', '../build/angular-locale_{{locale}}.js'); /** * @param {angular.IScope} $scope Angular scope. * @param {import("ngeo/misc/FeatureHelper.js").FeatureHelper} ngeoFeatureHelper Gmf feature helper service. - * @param {import("ol/Collection.js").default} ngeoFeatures Collection of + * @param {import("ol/Collection.js").default>} ngeoFeatures Collection of * features. * @param {import("ngeo/misc/ToolActivateMgr.js").ToolActivateMgr} ngeoToolActivateMgr Ngeo ToolActivate * manager service. diff --git a/contribs/gmf/examples/editfeature.js b/contribs/gmf/examples/editfeature.js index e633f0af30c4..db7c7aa56e3d 100644 --- a/contribs/gmf/examples/editfeature.js +++ b/contribs/gmf/examples/editfeature.js @@ -96,7 +96,7 @@ function MainController($scope, gmfEditFeature, gmfUser) { this.layerId_ = 113; /** - * @type {?import("ol/Feature.js").default} + * @type {?olFeature} */ this.feature = null; @@ -167,7 +167,7 @@ MainController.prototype.handleMapSingleClick_ = function(evt) { /** - * @param {Array} features Features. + * @param {Array>} features Features. * @private */ MainController.prototype.handleGetFeatures_ = function(features) { diff --git a/contribs/gmf/examples/editfeatureselector.js b/contribs/gmf/examples/editfeatureselector.js index bad99a5b8248..434cfafbe8f4 100644 --- a/contribs/gmf/examples/editfeatureselector.js +++ b/contribs/gmf/examples/editfeatureselector.js @@ -99,7 +99,7 @@ function MainController($scope, gmfThemes, gmfTreeManager, gmfUser, features: new olCollection() }), style: (feature, resolution) => ngeoFeatureHelper.createEditingStyles( - /** @type {import('ol/Feature.js').default} */(feature) + /** @type {import('ol/Feature.js').default} */(feature) ) }); diff --git a/contribs/gmf/examples/featurestyle.js b/contribs/gmf/examples/featurestyle.js index 383d84c2e64a..e92a29c7e3cc 100644 --- a/contribs/gmf/examples/featurestyle.js +++ b/contribs/gmf/examples/featurestyle.js @@ -189,7 +189,7 @@ function MainController($scope, ngeoFeatureHelper) { }); /** - * @type {?import("ol/Feature.js").default} + * @type {?olFeature} */ this.selectedFeature = null; @@ -206,9 +206,9 @@ function MainController($scope, ngeoFeatureHelper) { MainController.prototype.handleMapSingleClick_ = function(evt) { const pixel = evt.pixel; - const feature = /** @type {import("ol/Feature.js").default} */(this.map.forEachFeatureAtPixel( - pixel, feature => feature - )); + const feature = /** @type {olFeature} */( + this.map.forEachFeatureAtPixel(pixel, feature => feature) + ); if (this.selectedFeature) { this.featureHelper_.setStyle(this.selectedFeature); diff --git a/contribs/gmf/examples/objectediting.js b/contribs/gmf/examples/objectediting.js index 8d8364f528eb..c08a514d4e9a 100644 --- a/contribs/gmf/examples/objectediting.js +++ b/contribs/gmf/examples/objectediting.js @@ -74,7 +74,7 @@ function MainController(gmfObjectEditingManager, gmfThemes, projection.setExtent([485869.5728, 76443.1884, 837076.5648, 299941.7864]); /** - * @type {import("ol/source/Vector.js").default} + * @type {import("ol/source/Vector.js").default} * @private */ this.vectorSource_ = new olSourceVector({ @@ -90,7 +90,7 @@ function MainController(gmfObjectEditingManager, gmfThemes, }); /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ this.sketchFeatures = new olCollection(); @@ -161,7 +161,7 @@ function MainController(gmfObjectEditingManager, gmfThemes, 'mapTools', dummyToolActivate, false); /** - * @type {?import("ol/Feature.js").default} + * @type {?import("ol/Feature.js").default} */ this.objectEditingFeature = null; diff --git a/contribs/gmf/examples/objecteditinghub.js b/contribs/gmf/examples/objecteditinghub.js index 32e0657565f0..9cd5a35cada8 100644 --- a/contribs/gmf/examples/objecteditinghub.js +++ b/contribs/gmf/examples/objecteditinghub.js @@ -111,17 +111,17 @@ function MainController($http, $q, $scope, gmfThemes, gmfXSDAttributes) { this.selectedGmfLayerNode = null; /** - * @type {Object>} + * @type {Object>>} */ this.featuresCache_ = {}; /** - * @type {Array} + * @type {Array>} */ this.features = []; /** - * @type {?import("ol/Feature.js").default} + * @type {?import("ol/Feature.js").default} */ this.selectedFeature = null; @@ -308,16 +308,17 @@ MainController.prototype.issueGetFeatures_ = function(gmfLayerNode) { * @private */ MainController.prototype.handleGetFeatures_ = function(gmfLayerNode) { - const features = /** @type Array */ ( - this.getFeaturesFromCache_(gmfLayerNode)); - this.features = features; + this.features = + /** @type {Array>} */ ( + this.getFeaturesFromCache_(gmfLayerNode) + ); this.selectedFeature = this.features[0]; }; /** * @param {import('gmf/themes.js').GmfLayerWMS} gmfLayerNode Layer node. - * @return {?Array} List of features + * @return {?Array>} List of features * @private */ MainController.prototype.getFeaturesFromCache_ = function(gmfLayerNode) { diff --git a/contribs/gmf/examples/profile.js b/contribs/gmf/examples/profile.js index 05d4421cb72d..7434c36f8308 100644 --- a/contribs/gmf/examples/profile.js +++ b/contribs/gmf/examples/profile.js @@ -91,7 +91,7 @@ function MainController($scope, ngeoFeatureOverlayMgr) { }); /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ const features = new olCollection(); diff --git a/contribs/gmf/examples/xsdattributes.js b/contribs/gmf/examples/xsdattributes.js index 4b77645ae135..fe6b7d236648 100644 --- a/contribs/gmf/examples/xsdattributes.js +++ b/contribs/gmf/examples/xsdattributes.js @@ -53,7 +53,7 @@ function MainController($timeout, gmfThemes, gmfXSDAttributes) { this.attributes = null; /** - * @type {?import("ol/Feature.js").default} + * @type {?olFeature} */ this.feature = null; diff --git a/contribs/gmf/src/controllers/AbstractAPIController.js b/contribs/gmf/src/controllers/AbstractAPIController.js index 11d71765f2fb..54deeb3a2684 100644 --- a/contribs/gmf/src/controllers/AbstractAPIController.js +++ b/contribs/gmf/src/controllers/AbstractAPIController.js @@ -54,9 +54,7 @@ export class AbstractAPIController extends AbstractAppController { interactions: config.mapInteractions || olInteraction.defaults({ pinchRotate: true, altShiftDragRotate: true - }), - loadTilesWhileAnimating: true, - loadTilesWhileInteracting: true + }) }), $scope, $injector); } } diff --git a/contribs/gmf/src/controllers/AbstractAppController.js b/contribs/gmf/src/controllers/AbstractAppController.js index 6d074a4c78f4..2e48b66107a5 100644 --- a/contribs/gmf/src/controllers/AbstractAppController.js +++ b/contribs/gmf/src/controllers/AbstractAppController.js @@ -87,7 +87,7 @@ export function AbstractAppController(config, map, $scope, $injector) { /** * Collection of features for the draw interaction - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ const ngeoFeatures = $injector.get('ngeoFeatures'); diff --git a/contribs/gmf/src/datasource/ExternalDataSourcesManager.js b/contribs/gmf/src/datasource/ExternalDataSourcesManager.js index a3029075cef3..72265235b0e6 100644 --- a/contribs/gmf/src/datasource/ExternalDataSourcesManager.js +++ b/contribs/gmf/src/datasource/ExternalDataSourcesManager.js @@ -297,7 +297,7 @@ export class ExternalDatSourcesManager { } /** - * @param {import("ol/layer/Layer.js").default} layer Layer. + * @param {import("ol/layer/Layer.js").default} layer Layer. * @private */ addLayer_(layer) { @@ -305,7 +305,7 @@ export class ExternalDatSourcesManager { } /** - * @param {import("ol/layer/Layer.js").default} layer Layer. + * @param {import("ol/layer/Layer.js").default} layer Layer. * @private */ removeLayer_(layer) { diff --git a/contribs/gmf/src/drawing/drawFeatureComponent.js b/contribs/gmf/src/drawing/drawFeatureComponent.js index 29f23f6e7085..a7d959a8575b 100644 --- a/contribs/gmf/src/drawing/drawFeatureComponent.js +++ b/contribs/gmf/src/drawing/drawFeatureComponent.js @@ -96,7 +96,7 @@ module.directive('gmfDrawfeature', drawinfDrawFeatureComponent); * @param {angular.ITimeoutService} $timeout Angular timeout service. * @param {angular.gettext.gettextCatalog} gettextCatalog Gettext catalog. * @param {import("ngeo/misc/FeatureHelper.js").FeatureHelper} ngeoFeatureHelper Ngeo feature helper service. - * @param {import("ol/Collection.js").default} ngeoFeatures Collection + * @param {import("ol/Collection.js").default>} ngeoFeatures Collection * of features. * @param {import("ngeo/misc/ToolActivateMgr.js").ToolActivateMgr} ngeoToolActivateMgr Ngeo ToolActivate * manager service. @@ -164,7 +164,7 @@ function Controller($scope, $timeout, gettextCatalog, ngeoFeatureHelper, ngeoFea this.featureHelper_ = ngeoFeatureHelper; /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ this.features = ngeoFeatures; @@ -175,12 +175,12 @@ function Controller($scope, $timeout, gettextCatalog, ngeoFeatureHelper, ngeoFea this.ngeoToolActivateMgr_ = ngeoToolActivateMgr; /** - * @type {?import("ol/Feature.js").default} + * @type {?Feature} */ this.selectedFeature = null; /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ this.selectedFeatures = new olCollection(); @@ -460,7 +460,7 @@ Controller.prototype.handleActiveChange_ = function(active) { * Method called when a selection occurs from the list, i.e. when an item in * the list of features is clicked. Called from the template, so no need to * update Angular's scope. - * @param {import("ol/Feature.js").default} feature Feature to select. + * @param {Feature} feature Feature to select. */ Controller.prototype.selectFeatureFromList = function(feature) { this.listSelectionInProgress_ = true; @@ -470,7 +470,7 @@ Controller.prototype.selectFeatureFromList = function(feature) { /** - * @return {Array} Array. + * @return {Array>} Array. */ Controller.prototype.getFeaturesArray = function() { return this.features.getArray(); @@ -490,7 +490,7 @@ Controller.prototype.clearFeatures = function() { /** - * @param {import("ol/Feature.js").default} feature The feature to remove from the selection. + * @param {Feature} feature The feature to remove from the selection. */ Controller.prototype.removeFeature = function(feature) { const gettextCatalog = this.gettextCatalog_; @@ -510,7 +510,7 @@ Controller.prototype.handleFeaturesAdd_ = function(evt) { if (evt instanceof CollectionEvent) { // timeout to prevent double-click to zoom the map this.timeout_(() => { - this.selectedFeature = /** @type {import("ol/Feature.js").default} */ (evt.element); + this.selectedFeature = /** @type {Feature} */ (evt.element); this.drawActive = false; this.scope_.$apply(); }); @@ -634,21 +634,23 @@ Controller.prototype.handleMapContextMenu_ = function(evt) { const pixel = this.map.getEventPixel(evt); const coordinate = this.map.getCoordinateFromPixel(pixel); - let feature = this.map.forEachFeatureAtPixel( - pixel, - (feature) => { - if (feature instanceof Feature) { - let ret = null; - if (this.features.getArray().includes(feature)) { - ret = feature; + let feature = /** @type {?import('ol/Feature.js').default} */ ( + this.map.forEachFeatureAtPixel( + pixel, + (feature) => { + if (feature instanceof Feature) { + let ret = null; + if (this.features.getArray().includes(feature)) { + ret = feature; + } + return ret; } - return ret; + }, + { + hitTolerance: 7, + layerFilter: undefined } - }, - { - hitTolerance: 7, - layerFilter: undefined - } + ) ); feature = feature ? feature : null; @@ -711,7 +713,7 @@ Controller.prototype.handleMapContextMenu_ = function(evt) { this.modify_.setActive(true); - this.selectedFeature = /** @type import('ol/Feature.js').default */ (feature); + this.selectedFeature = feature; this.scope_.$apply(); } diff --git a/contribs/gmf/src/drawing/featureStyleComponent.js b/contribs/gmf/src/drawing/featureStyleComponent.js index 73672eb29e21..05bf1a920ec5 100644 --- a/contribs/gmf/src/drawing/featureStyleComponent.js +++ b/contribs/gmf/src/drawing/featureStyleComponent.js @@ -38,7 +38,7 @@ module.run( * gmf-featurestyle-feature="ctrl.selectedFeature"> * * - * @htmlAttribute {import("ol/Feature.js").default} gmf-featurestyle-feature The feature. + * @htmlAttribute {import("ol/Feature.js").default} gmf-featurestyle-feature The feature. * @return {angular.IDirective} The directive specs. * @ngInject * @ngdoc directive @@ -77,7 +77,7 @@ function Controller($scope, ngeoFeatureHelper) { this.uid = olUtilGetUid(this); /** - * @type {?import("ol/Feature.js").default} + * @type {?import("ol/Feature.js").default} */ this.feature = null; @@ -134,8 +134,8 @@ function Controller($scope, ngeoFeatureHelper) { /** * Called when a new feature is set, which can also be null. - * @param {?import("ol/Feature.js").default} newFeature New feature or null value. - * @param {?import("ol/Feature.js").default} previousFeature Previous feature or null value. + * @param {?import("ol/Feature.js").default} newFeature New feature or null value. + * @param {?import("ol/Feature.js").default} previousFeature Previous feature or null value. * @private */ Controller.prototype.handleFeatureSet_ = function(newFeature, previousFeature) { diff --git a/contribs/gmf/src/editing/EditFeature.js b/contribs/gmf/src/editing/EditFeature.js index e6fc820edfd9..775fb0757b0b 100644 --- a/contribs/gmf/src/editing/EditFeature.js +++ b/contribs/gmf/src/editing/EditFeature.js @@ -51,7 +51,7 @@ export function EditingEditFeature($http, gmfLayersUrl) { * * @param {number[]} layerIds List of layer ids to get the features from. * @param {import("ol/extent.js").Extent} extent The extent where to get the features from. - * @return {angular.IPromise} Promise. + * @return {angular.IPromise[]>} Promise. */ EditingEditFeature.prototype.getFeaturesInExtent = function(layerIds, extent) { const url = olUriAppendParams(`${this.baseUrl_}/${layerIds.join(',')}`, { @@ -72,7 +72,7 @@ EditingEditFeature.prototype.getFeaturesInExtent = function(layerIds, extent) { * * @param {string[]} layerIds List of layer ids to get the features from. * @param {ComparisonFilter[]} filters List of comparison filters - * @return {angular.IPromise} Promise. + * @return {angular.IPromise[]>} Promise. */ EditingEditFeature.prototype.getFeaturesWithComparisonFilters = function(layerIds, filters) { const properties = []; @@ -94,7 +94,7 @@ EditingEditFeature.prototype.getFeaturesWithComparisonFilters = function(layerId /** * @param {number} layerId The layer id that contains the feature. - * @param {Array} features List of features to insert. + * @param {Array>} features List of features to insert. * @return {angular.IPromise} Promise. */ EditingEditFeature.prototype.insertFeatures = function(layerId, features) { @@ -109,7 +109,7 @@ EditingEditFeature.prototype.insertFeatures = function(layerId, features) { /** * @param {number} layerId The layer id that contains the feature. - * @param {import("ol/Feature.js").default} feature The feature to update. + * @param {import("ol/Feature.js").default} feature The feature to update. * @return {angular.IPromise} Promise. */ EditingEditFeature.prototype.updateFeature = function(layerId, feature) { @@ -124,7 +124,7 @@ EditingEditFeature.prototype.updateFeature = function(layerId, feature) { /** * @param {number} layerId The layer id that contains the feature. - * @param {import("ol/Feature.js").default} feature The feature to delete. + * @param {import("ol/Feature.js").default} feature The feature to delete. * @return {angular.IPromise} Promise. */ EditingEditFeature.prototype.deleteFeature = function(layerId, feature) { diff --git a/contribs/gmf/src/editing/Snapping.js b/contribs/gmf/src/editing/Snapping.js index bd68aab5e142..f142ec36020e 100644 --- a/contribs/gmf/src/editing/Snapping.js +++ b/contribs/gmf/src/editing/Snapping.js @@ -585,7 +585,7 @@ EditingSnappingService.prototype.handleMapMoveEnd_ = function() { * @property {boolean} active * @property {string} featureNS * @property {string} featurePrefix - * @property {import("ol/Collection.js").default} features + * @property {import("ol/Collection.js").default>} features * @property {string} geometryName * @property {?import("ol/interaction/Snap.js").default} interaction * @property {number} maxFeatures diff --git a/contribs/gmf/src/editing/editFeatureComponent.js b/contribs/gmf/src/editing/editFeatureComponent.js index bd2aa2c35e05..25ad5d1f3b68 100644 --- a/contribs/gmf/src/editing/editFeatureComponent.js +++ b/contribs/gmf/src/editing/editFeatureComponent.js @@ -397,7 +397,7 @@ function Controller($element, $q, $scope, $timeout, this.mapSelectToolActivate = new ngeoMiscToolActivate(this, 'mapSelectActive'); /** - * @type {?import("ol/Feature.js").default} + * @type {?olFeature} */ this.feature = null; @@ -412,7 +412,7 @@ function Controller($element, $q, $scope, $timeout, this.featureId = undefined; /** - * @type {?import("ol/Collection.js").default} + * @type {?import("ol/Collection.js").default>} */ this.features = null; @@ -1240,7 +1240,7 @@ Controller.prototype.handleMapContextMenu_ = function(evt) { /** - * @param {Array} features Features. + * @param {Array>} features Features. * @private */ Controller.prototype.handleGetFeatures_ = function(features) { @@ -1300,8 +1300,8 @@ Controller.prototype.unregisterInteractions_ = function() { /** - * @param {?import("ol/Feature.js").default} newFeature The new feature. - * @param {?import("ol/Feature.js").default} oldFeature The old feature. + * @param {?olFeature} newFeature The new feature. + * @param {?olFeature} oldFeature The old feature. * @private */ Controller.prototype.handleFeatureChange_ = function(newFeature, oldFeature) { diff --git a/contribs/gmf/src/layertree/component.js b/contribs/gmf/src/layertree/component.js index 3304db144b0f..02c94d1c11a3 100644 --- a/contribs/gmf/src/layertree/component.js +++ b/contribs/gmf/src/layertree/component.js @@ -13,9 +13,7 @@ import ngeoDatasourceOGC, {ServerType} from 'ngeo/datasource/OGC.js'; import ngeoLayertreeComponent from 'ngeo/layertree/component.js'; -import ngeoLayertreeController, { - LayertreeVisitorDecision -} from 'ngeo/layertree/Controller.js'; +import ngeoLayertreeController, {LayertreeVisitorDecision} from 'ngeo/layertree/Controller.js'; import ngeoMapLayerHelper from 'ngeo/map/LayerHelper.js'; import ngeoMiscSyncArrays from 'ngeo/misc/syncArrays.js'; import ngeoMiscWMSTime from 'ngeo/misc/WMSTime.js'; @@ -354,8 +352,8 @@ Controller.prototype.updateDimensions_ = function(treeCtrl) { const layer = ctrl.layer; console.assert(layer instanceof olLayerLayer); this.updateLayerDimensions_( - /** @type olLayerLayer */ (layer), - /** @type import('gmf/themes.js').GmfGroup|import('gmf/themes.js').GmfLayer */ (ctrl.node) + /** @type {olLayerLayer} */ (layer), + /** @type {import('gmf/themes.js').GmfGroup|import('gmf/themes.js').GmfLayer} */ (ctrl.node) ); return LayertreeVisitorDecision.DESCEND; } @@ -364,7 +362,7 @@ Controller.prototype.updateDimensions_ = function(treeCtrl) { /** - * @param {import("ol/layer/Layer.js").default} layer Layer to update. + * @param {olLayerLayer} layer Layer to update. * @param {import('gmf/themes.js').GmfGroup|import('gmf/themes.js').GmfLayer} node Layer tree node. * @private */ @@ -780,12 +778,17 @@ Controller.prototype.zoomToResolution = function(treeCtrl) { throw new Error('Missing resolution'); } const minResolution = getNodeMinResolution(gmfLayer); + const constrainResolution = view.getConstraints().resolution; + const size = this.map.getSize(); + if (size === undefined) { + throw new Error('Missing size'); + } if (minResolution !== undefined && resolution < minResolution) { - view.setResolution(view.constrainResolution(minResolution, 0, 1)); + view.setResolution(constrainResolution(minResolution, 1, size)); } else { const maxResolution = getNodeMaxResolution(gmfLayer); if (maxResolution !== undefined && resolution > maxResolution) { - view.setResolution(view.constrainResolution(maxResolution, 0, -1)); + view.setResolution(constrainResolution(maxResolution, -1, size)); } } }; diff --git a/contribs/gmf/src/lidarprofile/Manager.js b/contribs/gmf/src/lidarprofile/Manager.js index b2ec4d70d45e..12e0d09fd6e7 100644 --- a/contribs/gmf/src/lidarprofile/Manager.js +++ b/contribs/gmf/src/lidarprofile/Manager.js @@ -155,7 +155,8 @@ export class LidarprofileManager { */ clearBuffer() { if (this.lidarBuffer) { - /** @type {olSourceVector} */(this.lidarBuffer.getSource()).clear(); + /** @type {olSourceVector} */(this.lidarBuffer.getSource()) + .clear(); } } @@ -521,8 +522,11 @@ export class LidarprofileManager { const clip = this.utils.clipLineByMeasure(this.config, map_resolution, this.line_, domainX[0], domainX[1]); - /** @type {olSourceVector} */(this.lidarBuffer.getSource()).clear(); - /** @type {olSourceVector} */(this.lidarBuffer.getSource()).addFeature(clip.bufferGeom); + const source = /** @type {olSourceVector} */( + this.lidarBuffer.getSource() + ); + source.clear(); + source.addFeature(clip.bufferGeom); this.lidarBuffer.setStyle(clip.bufferStyle); const span = domainX[1] - domainX[0]; diff --git a/contribs/gmf/src/lidarprofile/Plot.js b/contribs/gmf/src/lidarprofile/Plot.js index 0fd47e4738c4..d002571c456c 100644 --- a/contribs/gmf/src/lidarprofile/Plot.js +++ b/contribs/gmf/src/lidarprofile/Plot.js @@ -349,6 +349,9 @@ export default class { this.updateScaleX, this.updateScaleY, classification_colors ); + const source = /** @type {import("ol/source/Vector.js").default} */( + this.manager_.lidarPointHighlight.getSource() + ); if (p != undefined) { cx = this.updateScaleX(p.distance) + margin.left; @@ -376,8 +379,7 @@ export default class { this.manager_.cartoHighlight.setElement(el); this.manager_.cartoHighlight.setPosition([p.coords[0], p.coords[1]]); - /** @type {import("ol/source/Vector.js").default} */(this.manager_.lidarPointHighlight.getSource()) - .clear(); + source.clear(); const lidarPointGeom = new olGeomPoint([p.coords[0], p.coords[1]]); const lidarPointFeature = new olFeature(lidarPointGeom); if (typeof (pointClassification.color) !== undefined) { @@ -392,13 +394,9 @@ export default class { })); } - /** @type {import("ol/source/Vector.js").default} */( - this.manager_.lidarPointHighlight.getSource() - ).addFeature(lidarPointFeature); + source.addFeature(lidarPointFeature); } else { - /** @type {import("ol/source/Vector.js").default} */( - this.manager_.lidarPointHighlight.getSource() - ).clear(); + source.clear(); svg.select('#highlightCircle').remove(); lidarInfo.html(''); this.manager_.cartoHighlight.setPosition(undefined); diff --git a/contribs/gmf/src/lidarprofile/Utils.js b/contribs/gmf/src/lidarprofile/Utils.js index 4f1605cb4213..986c0f272939 100644 --- a/contribs/gmf/src/lidarprofile/Utils.js +++ b/contribs/gmf/src/lidarprofile/Utils.js @@ -67,7 +67,7 @@ export default class { * @param {number} dLeft domain minimum * @param {number} dRight domain maximum * @return {{ - * bufferGeom: olFeature, + * bufferGeom: olFeature, * bufferStyle: olStyleStyle[], * clippedLine: Array, * distanceOffset: number @@ -113,9 +113,9 @@ export default class { }); - const feat = new olFeature({ + const feat = /** @type {olFeature} */(new olFeature({ geometry: clippedLine - }); + })); const lineStyle = new olStyleStyle({ stroke: new olStyleStroke({ diff --git a/contribs/gmf/src/objectediting/Manager.js b/contribs/gmf/src/objectediting/Manager.js index bec49218634a..2112fb0a6ce9 100644 --- a/contribs/gmf/src/objectediting/Manager.js +++ b/contribs/gmf/src/objectediting/Manager.js @@ -64,7 +64,7 @@ export function ObjecteditingManagerService($q, gmfEditFeature, ngeoLocation) { this.ngeoLocation_ = ngeoLocation; /** - * @type {?angular.IDeferred} + * @type {?angular.IDeferred>} * @private */ this.getFeatureDefered_ = null; @@ -80,7 +80,7 @@ export function ObjecteditingManagerService($q, gmfEditFeature, ngeoLocation) { * is returned, otherwise one is created with empty geometry and with the * property set. * - * @return {angular.IPromise} Promise. + * @return {angular.IPromise>} Promise. */ ObjecteditingManagerService.prototype.getFeature = function() { @@ -138,7 +138,7 @@ ObjecteditingManagerService.prototype.getLayerNodeId = function() { * * @param {string} key Property key. * @param {string} value Property value. - * @param {Array} features List of features. + * @param {Array>} features List of features. * @private */ ObjecteditingManagerService.prototype.handleGetFeatures_ = function(key, value, features) { diff --git a/contribs/gmf/src/objectediting/Query.js b/contribs/gmf/src/objectediting/Query.js index 49917320e714..678fd5dd31da 100644 --- a/contribs/gmf/src/objectediting/Query.js +++ b/contribs/gmf/src/objectediting/Query.js @@ -153,7 +153,7 @@ function getQueryableLayersInfoFromThemes( * Queryable layer information. * @param {import("ol/coordinate.js").Coordinate} coordinate Coordinate. * @param {import("ol/Map.js").default} map Map. - * @return {angular.IPromise} Promise. + * @return {angular.IPromise>} Promise. */ ObjectEditingQuery.prototype.getFeatureInfo = function(layerInfo, coordinate, map) { const view = map.getView(); diff --git a/contribs/gmf/src/objectediting/component.js b/contribs/gmf/src/objectediting/component.js index 59fd1374d53d..737da10865e6 100644 --- a/contribs/gmf/src/objectediting/component.js +++ b/contribs/gmf/src/objectediting/component.js @@ -135,11 +135,11 @@ function gmfObjecteditingTemplateUrl($element, $attrs, gmfObjecteditingTemplateU * * @htmlAttribute {boolean} gmf-objectediting-active Whether the component is * active or not. - * @htmlAttribute {import("ol/Feature.js").default} gmf-objectediting-feature The feature to edit. + * @htmlAttribute {import("ol/Feature.js").default} gmf-objectediting-feature The feature to edit. * @htmlAttribute {string} gmf-objectediting-geomtype The geometry type. * @htmlAttribute {number} gmf-objectediting-layernodeid The GMF layer node id. * @htmlAttribute {import("ol/Map.js").default} gmf-objectediting-map The map. - * @htmlAttribute {import("ol/Collection.js").default} gmf-objectediting-sketchfeatures + * @htmlAttribute {import("ol/Collection.js").default>} gmf-objectediting-sketchfeatures * Collection of temporary features being drawn by the tools. * @ngdoc component * @ngname gmfObjectediting @@ -192,7 +192,7 @@ function Controller($scope, $timeout, gettextCatalog, this.active = false; /** - * @type {?import("ol/Feature.js").default} + * @type {?import("ol/Feature.js").default} */ this.feature = null; @@ -212,7 +212,7 @@ function Controller($scope, $timeout, gettextCatalog, this.map = null; /** - * @type {?import("ol/Collection.js").default} + * @type {?import("ol/Collection.js").default>} */ this.sketchFeatures = null; @@ -392,7 +392,7 @@ function Controller($scope, $timeout, gettextCatalog, this.listenerKeys_ = []; /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.features_ = new olCollection(); diff --git a/contribs/gmf/src/objectediting/getWMSFeatureComponent.js b/contribs/gmf/src/objectediting/getWMSFeatureComponent.js index fa05e923efda..c4d33c382049 100644 --- a/contribs/gmf/src/objectediting/getWMSFeatureComponent.js +++ b/contribs/gmf/src/objectediting/getWMSFeatureComponent.js @@ -80,7 +80,7 @@ function Controller($scope, gmfObjectEditingQuery) { ); /** - * @type {?import("ol/Collection.js").default} + * @type {?import("ol/Collection.js").default>} */ this.features = null; diff --git a/contribs/gmf/src/objectediting/toolsComponent.js b/contribs/gmf/src/objectediting/toolsComponent.js index c4f5c7f9d141..63e90c5c8c12 100644 --- a/contribs/gmf/src/objectediting/toolsComponent.js +++ b/contribs/gmf/src/objectediting/toolsComponent.js @@ -99,7 +99,7 @@ module.value('gmfObjectEditingToolsOptions', {}); * 'Copy from' tool is active or not. * @htmlAttribute {boolean} gmf-objecteditingtools-deletefromactive Whether the * 'Delete from' tool is active or not. - * @htmlAttribute {import("ol/Feature.js").default} gmf-objecteditingtools-feature The feature to + * @htmlAttribute {import('ol/Feature.js').default} gmf-objecteditingtools-feature The feature to * edit. * @htmlAttribute {string} gmf-objecteditingtools-geomtype The geometry type. * @htmlAttribute {import("ol/Map.js").default} gmf-objecteditingtools-map The map. @@ -109,7 +109,7 @@ module.value('gmfObjectEditingToolsOptions', {}); * Queryable layer information. * @htmlAttribute {boolean} gmf-objectediting-requireslayer Flag that determines * if the currently active tool requires a queryable layer or not. - * @htmlAttribute {import("ol/Collection.js").default} gmf-objectediting-sketchfeatures + * @htmlAttribute {import("ol/Collection.js").default>} gmf-objectediting-sketchfeatures * Collection of temporary features being drawn by the tools. * @return {angular.IDirective} The directive specs. * @ngInject @@ -178,7 +178,7 @@ function Controller($injector, $scope, ngeoToolActivateMgr) { this.deleteFromActive = false; /** - * @type {?import("ol/Feature.js").default} + * @type {?import('ol/Feature.js').default} */ this.feature = null; @@ -208,7 +208,7 @@ function Controller($injector, $scope, ngeoToolActivateMgr) { this.requiresLayer = false; /** - * @type {?import("ol/Collection.js").default} + * @type {?import("ol/Collection.js").default>} */ this.sketchFeatures = null; diff --git a/contribs/gmf/src/permalink/Permalink.js b/contribs/gmf/src/permalink/Permalink.js index 8a6e07d5f996..d2c5b6140157 100644 --- a/contribs/gmf/src/permalink/Permalink.js +++ b/contribs/gmf/src/permalink/Permalink.js @@ -318,7 +318,7 @@ export function PermalinkService( this.ngeoStateManager_ = ngeoStateManager; /** - * @type {?import("ol/Collection.js").default} + * @type {?import("ol/Collection.js").default>} * @private */ this.ngeoFeatures_ = $injector.has('ngeoFeatures') ? @@ -464,7 +464,7 @@ export function PermalinkService( } /** - * @type {?import("ol/Feature.js").default} + * @type {?olFeature} * @private */ this.crosshairFeature_ = null; @@ -824,7 +824,7 @@ PermalinkService.prototype.setMapTooltip = function(tooltipText, opt_center) { /** * Get the ngeo features from the state manager for initialization purpose - * @return {Array} The features read from the state manager. + * @return {Array>} The features read from the state manager. */ PermalinkService.prototype.getFeatures = function() { const f = this.ngeoStateManager_.getInitialStringValue(PermalinkParam.FEATURES); @@ -897,7 +897,7 @@ PermalinkService.prototype.setMap = function(map) { /** * Listen to the map view property change and update the state accordingly. * @param {import("ol/Map.js").default} map The ol3 map object. - * @param {?import("ol/Feature.js").default} oeFeature ObjectEditing feature + * @param {?olFeature} oeFeature ObjectEditing feature * @private */ PermalinkService.prototype.registerMap_ = function(map, oeFeature) { @@ -1362,7 +1362,7 @@ PermalinkService.prototype.handleNgeoFeaturesRemove_ = function(event) { /** * Listen to any changes that may occur within the feature in order to * update the state of the permalink accordingly. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private */ PermalinkService.prototype.addNgeoFeature_ = function(feature) { @@ -1377,7 +1377,7 @@ PermalinkService.prototype.addNgeoFeature_ = function(feature) { /** * Unregister any event listener from the feature. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private */ PermalinkService.prototype.removeNgeoFeature_ = function(feature) { diff --git a/contribs/gmf/src/print/component.js b/contribs/gmf/src/print/component.js index 19f4e4033db0..b64222e19eed 100644 --- a/contribs/gmf/src/print/component.js +++ b/contribs/gmf/src/print/component.js @@ -1283,7 +1283,8 @@ export class PrintController { if (!this.map) { throw new Error('Missing map'); } - const legend = {classes: /** @type {any[]} */([])}; + /** @type {import('ngeo/print/mapfish-print-v3').MapFishPrintLegend} */ + const legend = {classes: []}; const gettextCatalog = this.gettextCatalog_; // Get layers from layertree only. @@ -1295,7 +1296,7 @@ export class PrintController { if (!this.map) { throw new Error('Missing map'); } - /** @type {{name: string, icons: string[]}[]} */ + /** @type {import('ngeo/print/mapfish-print-v3').MapFishPrintLegendClass[]} */ const classes = []; if (layer.getVisible() && layer.getSource()) { // For WMTS layers. @@ -1366,7 +1367,7 @@ export class PrintController { // Add classes object only if it contains something. if (classes.length > 0) { - legend.classes.push({classes: classes}); + legend.classes = legend.classes.concat(classes); } }); @@ -1458,8 +1459,10 @@ 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 contrainRes = this.map.getView().constrainResolution(res, 0, 1); - this.map.getView().setResolution(contrainRes); + + const view = this.map.getView(); + const contrainRes = view.getConstraints().resolution(res, 1, mapSize); + view.setResolution(contrainRes); // Render the map to update the postcompose mask manually this.map.render(); this.scaleManuallySelected_ = true; diff --git a/contribs/gmf/src/profile/component.js b/contribs/gmf/src/profile/component.js index 20408107bff2..e0cc11083b28 100644 --- a/contribs/gmf/src/profile/component.js +++ b/contribs/gmf/src/profile/component.js @@ -272,7 +272,7 @@ export function ProfileController($scope, $http, $element, $filter, gettextCatal this.measureTooltipElement_ = null; /** - * @type {import("ol/Feature.js").default} + * @type {olFeature} * @private */ this.snappedPoint_ = new olFeature(); diff --git a/contribs/gmf/src/profile/drawLineComponent.js b/contribs/gmf/src/profile/drawLineComponent.js index f8abb5a617cb..d579f3e01558 100644 --- a/contribs/gmf/src/profile/drawLineComponent.js +++ b/contribs/gmf/src/profile/drawLineComponent.js @@ -89,7 +89,7 @@ function Controller($scope, $timeout, ngeoFeatureOverlayMgr) { this.active = false; /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.features_ = new olCollection(); diff --git a/contribs/gmf/src/query/gridComponent.js b/contribs/gmf/src/query/gridComponent.js index 61002158295f..06bcc3af3252 100644 --- a/contribs/gmf/src/query/gridComponent.js +++ b/contribs/gmf/src/query/gridComponent.js @@ -266,7 +266,7 @@ export function QueryGridController($injector, $scope, ngeoQueryResult, ngeoMapQ /** * A mapping between row uid and the corresponding feature for each * source. - * @type {Object>} + * @type {Object>>} * @private */ this.featuresForSources_ = {}; @@ -274,7 +274,7 @@ export function QueryGridController($injector, $scope, ngeoQueryResult, ngeoMapQ // Styles for displayed features (features) and selected features // (highlightFeatures_) (user can set both styles). /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.features_ = new olCollection(); @@ -286,7 +286,7 @@ export function QueryGridController($injector, $scope, ngeoQueryResult, ngeoMapQ this.ngeoFeatureOverlayMgr_ = ngeoFeatureOverlayMgr; /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.highlightFeatures_ = new olCollection(); @@ -607,7 +607,7 @@ QueryGridController.prototype.collectData_ = function(source) { const allProperties = []; /** @type {string[]} */ const featureGeometriesNames = []; - /** @type {Object} */ + /** @type {Object>} */ const featuresForSource = {}; let properties, featureGeometryName; features.forEach((feature) => { diff --git a/contribs/gmf/src/query/windowComponent.js b/contribs/gmf/src/query/windowComponent.js index e1e7f4d6bb36..39a1364cc3b5 100644 --- a/contribs/gmf/src/query/windowComponent.js +++ b/contribs/gmf/src/query/windowComponent.js @@ -200,7 +200,7 @@ export function QueryWindowController( this.selectedSource = null; /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.features_ = new olCollection(); @@ -212,7 +212,7 @@ export function QueryWindowController( this.ngeoFeatureOverlayMgr_ = ngeoFeatureOverlayMgr; /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.highlightFeatures_ = new olCollection(); @@ -223,7 +223,7 @@ export function QueryWindowController( this.source = null; /** - * @type {?import("ol/Feature.js").default} + * @type {?import('ol/Feature.js').default} */ this.feature = null; @@ -534,7 +534,7 @@ QueryWindowController.prototype.collectFeatures_ = function() { /** * Highlight the current displayed feature. - * @param {import("ol/Feature.js").default=} opt_lastFeature last highlighted feature. Require if + * @param {import('ol/Feature.js').default=} opt_lastFeature last highlighted feature. Require if * it exists because it must be added to the 'non-selected' features collection. * @private */ diff --git a/contribs/gmf/src/search/component.js b/contribs/gmf/src/search/component.js index c138ec3481e5..aa35c0c4cd7a 100644 --- a/contribs/gmf/src/search/component.js +++ b/contribs/gmf/src/search/component.js @@ -44,7 +44,7 @@ import SimpleGeometry from 'ol/geom/SimpleGeometry.js'; * @property {gmfSearchAction[]} [groupActions] List of allowed actions. The list may contain a * combination of `add_theme`, `add_group` or `add_layer` * @property {string} [projection] The geometry's projection for this set of data. - * @property {Twitter.Typeahead.Dataset} [typeaheadDatasetOptions] The optional Twitter.Typeahead. + * @property {Twitter.Typeahead.Dataset>} [typeaheadDatasetOptions] The optional Twitter.Typeahead. * configuration for this dataset. See: https://github.com/twitter/typeahead.js/blob/master/ * @property {string} url URL of the search service. Must contain a '%QUERY' term that will be * replaced by the input string. @@ -421,7 +421,7 @@ class SearchController { this.featuresStyles = {}; /** - * @type {(Twitter.Typeahead.Dataset|Twitter.Typeahead.Dataset)[]} + * @type {(Twitter.Typeahead.Dataset>|Twitter.Typeahead.Dataset)[]} */ this.datasets = []; @@ -441,12 +441,12 @@ class SearchController { this.displayColorPicker = false; /** - * @type {?import('ngeo/search/searchDirective.js').SearchDirectiveListeners} + * @type {?import('ngeo/search/searchDirective.js').SearchDirectiveListeners>} */ this.listeners = null; /** - * @type {import('ngeo/search/searchDirective.js').SearchDirectiveListeners} + * @type {import('ngeo/search/searchDirective.js').SearchDirectiveListeners>} */ this.additionalListeners = {}; } @@ -534,10 +534,10 @@ class SearchController { /** * Merges the custom listeners received via the component attributes and the * listeners that are needed for this controller to function (close and select). - * @param {import('ngeo/search/searchDirective.js').SearchDirectiveListeners} additionalListeners + * @param {import('ngeo/search/searchDirective.js').SearchDirectiveListeners>} additionalListeners * Custom provided listeners. - * @param {import('ngeo/search/searchDirective.js').SearchDirectiveListeners} listeners Default listeners. - * @return {import('ngeo/search/searchDirective.js').SearchDirectiveListeners} Merged listeners. + * @param {import('ngeo/search/searchDirective.js').SearchDirectiveListeners>} listeners Default listeners. + * @return {import('ngeo/search/searchDirective.js').SearchDirectiveListeners>} Merged listeners. * @private */ mergeListeners_(additionalListeners, listeners) { @@ -645,7 +645,7 @@ class SearchController { * @param {SearchComponentDatasource} config The config of the dataset. * @param {(function(import("geojson").Feature): boolean)=} opt_filter A filter function * based on a GeoJSONFeaturesCollection's array. - * @return {Twitter.Typeahead.Dataset} A typeahead dataset. + * @return {Twitter.Typeahead.Dataset>} A typeahead dataset. * @private */ createDataset_(config, opt_filter) { @@ -653,7 +653,7 @@ class SearchController { const componentScope = this.scope_; const compile = this.compile_; const bloodhoundEngine = this.createAndInitBloodhound_(config, opt_filter); - /** @type {Twitter.Typeahead.Dataset} */ + /** @type {Twitter.Typeahead.Dataset>} */ const typeaheadDataset = { limit: Infinity, source: bloodhoundEngine.ttAdapter(), @@ -750,7 +750,7 @@ class SearchController { * @param {SearchComponentDatasource} config The config of the dataset. * @param {(function(import("geojson").Feature): boolean)=} opt_filter Afilter function * based on a GeoJSONFeaturesCollection's array. - * @return {Bloodhound} The bloodhound engine. + * @return {Bloodhound[]>} The bloodhound engine. * @private */ createAndInitBloodhound_(config, opt_filter) { @@ -871,7 +871,7 @@ class SearchController { /** * Style for search results. - * @param {null|import("ol/Feature.js").default|import("ol/render/Feature.js").default} feature + * @param {null|olFeature|import("ol/render/Feature.js").default} feature * The searched feature. * @param {number} resolution The current resolution of the map. * @return {import("ol/style/Style.js").default} A style for this kind of features. @@ -978,8 +978,8 @@ class SearchController { /** * @param {JQueryEventObject} event Event. - * @param {Object|import("ol/Feature.js").default} suggestion Suggestion. - * @param {Twitter.Typeahead.Dataset} dataset Dataset. + * @param {Object|olFeature} suggestion Suggestion. + * @param {Twitter.Typeahead.Dataset>} dataset Dataset. * @private */ select_(event, suggestion, dataset) { @@ -1005,8 +1005,8 @@ class SearchController { /** * @param {JQueryEventObject} event Event. - * @param {import("ol/Feature.js").default} feature Feature. - * @param {Twitter.Typeahead.Dataset} dataset Dataset. + * @param {olFeature} feature Feature. + * @param {Twitter.Typeahead.Dataset>} dataset Dataset. * @private */ selectFromGMF_(event, feature, dataset) { diff --git a/examples/attributes.js b/examples/attributes.js index a8229442cf19..a0bfd39a2ccc 100644 --- a/examples/attributes.js +++ b/examples/attributes.js @@ -43,7 +43,7 @@ function MainController($http, $timeout, $scope) { this.disabled = false; /** - * @type {import("ol/Feature.js").default} + * @type {olFeature} */ this.feature = new olFeature({ 'name': 'A feature', diff --git a/examples/createfeature.js b/examples/createfeature.js index 9ddaf206e6ac..02ed85681dd3 100644 --- a/examples/createfeature.js +++ b/examples/createfeature.js @@ -37,7 +37,7 @@ const module = angular.module('app', [ function MainController(ngeoToolActivateMgr) { /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ this.features = new olCollection(); diff --git a/examples/drawfeature.js b/examples/drawfeature.js index f9d508b70039..a6fb2cfc93a2 100644 --- a/examples/drawfeature.js +++ b/examples/drawfeature.js @@ -24,7 +24,7 @@ const module = angular.module('app', [ /** * @param {angular.IScope} $scope Angular scope. - * @param {import("ol/Collection.js").default} ngeoFeatures Collection + * @param {import("ol/Collection.js").default>} ngeoFeatures Collection * of features. * @param {import("ngeo/misc/ToolActivateMgr.js").ToolActivateMgr} ngeoToolActivateMgr Ngeo ToolActivate * manager service. diff --git a/examples/elevationProfile.js b/examples/elevationProfile.js index 79dd2e457177..d97563e778b7 100644 --- a/examples/elevationProfile.js +++ b/examples/elevationProfile.js @@ -80,7 +80,8 @@ function MainController($http, $scope) { }); 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. diff --git a/examples/importfeatures.js b/examples/importfeatures.js index 3d10eb27e327..622f175f8ebe 100644 --- a/examples/importfeatures.js +++ b/examples/importfeatures.js @@ -42,7 +42,7 @@ function MainController($scope) { /** * @private - * @type {import("ol/source/Vector.js").default} + * @type {import("ol/source/Vector.js").default} */ this.vectorSource_ = new olSourceVector(); diff --git a/examples/interactionbtngroup.js b/examples/interactionbtngroup.js index 17f9b551f2a5..8018e4c235cf 100644 --- a/examples/interactionbtngroup.js +++ b/examples/interactionbtngroup.js @@ -36,7 +36,7 @@ function MainController(ngeoFeatureOverlayMgr) { /** * Collection shared between the drawing interactions and the feature * overlay used to render the drawn features. - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ const features = new olCollection(); diff --git a/examples/layertree.js b/examples/layertree.js index 88fb8a92a4f0..0f83d6946ab9 100644 --- a/examples/layertree.js +++ b/examples/layertree.js @@ -64,7 +64,8 @@ module.component('appLayertree', layertreeComponent); * @constructor * @param {angular.IHttpService} $http Angular http service. * @param {angular.ISCEService} $sce Angular sce service. - * @param {function(Object):import("ol/layer/Layer.js").default} appGetLayer Get layer service. + * @param {function(Object):import("ol/layer/Layer.js").default} + * appGetLayer Get layer service. * @param {import("ngeo/message/Popup.js").PopupFactory} ngeoCreatePopup Popup service. * @ngInject */ @@ -93,7 +94,7 @@ function LayertreeController($http, $sce, appGetLayer, ngeoCreatePopup) { /** * @private - * @type {function(Object):import("ol/layer/Layer.js").default} + * @type {function(Object):import("ol/layer/Layer.js").default} */ this.getLayer_ = appGetLayer; @@ -116,7 +117,8 @@ function LayertreeController($http, $sce, appGetLayer, ngeoCreatePopup) { * from a tree node. The function should return `null` if no layer should * be associated to the node (because it's not a leaf). * @param {Object} node Node object. - * @return {import("ol/layer/Layer.js").default} The layer for this node. + * @return {import("ol/layer/Layer.js").default} The layer for this + * node. */ LayertreeController.prototype.getLayer = function(node) { return this.getLayer_(node); @@ -125,7 +127,7 @@ LayertreeController.prototype.getLayer = function(node) { /** * @param {Object} node Tree node. - * @param {import("ol/layer/Layer.js").default} layer Layer. + * @param {import("ol/layer/Layer.js").default} layer Layer. */ LayertreeController.prototype.onButtonClick = function(node, layer) { const layerType = node.layerType; @@ -160,13 +162,13 @@ module.controller('AppLayertreeController', LayertreeController); */ const getLayer = (function() { /** - * @type {Object} + * @type {Object.>} */ const layerCache = {}; return ( /** * @param {Object} node Tree node. - * @return {?import("ol/layer/Layer.js").default} Layer. + * @return {?import("ol/layer/Layer.js").default} Layer. */ function(node) { if (!('layerType' in node)) { diff --git a/examples/locationsearch.js b/examples/locationsearch.js index b323225eb016..abf0a0762810 100644 --- a/examples/locationsearch.js +++ b/examples/locationsearch.js @@ -51,7 +51,7 @@ function SearchController(ngeoCreateLocationSearchBloodhound) { this.map = null; const limit = 10; - /** @type {Bloodhound} */ + /** @type {Bloodhound[]>} */ const bloodhoundEngine = this.createAndInitBloodhound_(ngeoCreateLocationSearchBloodhound, limit); /** @@ -64,7 +64,7 @@ function SearchController(ngeoCreateLocationSearchBloodhound) { }); /** - * @type {Array>} + * @type {Array>>} */ this.datasets = [{ source: bloodhoundEngine.ttAdapter(), @@ -83,14 +83,16 @@ function SearchController(ngeoCreateLocationSearchBloodhound) { }]; /** - * @type {import('ngeo/search/searchDirective.js').SearchDirectiveListeners} + * @type {import('ngeo/search/searchDirective.js').SearchDirectiveListeners>} */ this.listeners = { select: (event, suggestion, dataset) => { if (!this.map) { throw new Error('Missing map'); } - const feature = /** @type {import("ol/Feature.js").default} */ (suggestion); + const feature = /** @type {import('ol/Feature.js').default} */ ( + suggestion + ); const bbox = /** @type {import("ol/extent.js").Extent} */ (feature.get('bbox')); const size = this.map.getSize(); if (!size) { @@ -108,7 +110,7 @@ function SearchController(ngeoCreateLocationSearchBloodhound) { * @param {import("ngeo/search/createLocationSearchBloodhound.js").createLocationSearchBloodhoundFunction} ngeoCreateLocationSearchBloodhound * Bloodhound service. * @param {number} limit Limit. - * @return {Bloodhound} The bloodhound engine. + * @return {Bloodhound[]>} The bloodhound engine. * @private */ SearchController.prototype.createAndInitBloodhound_ = function(ngeoCreateLocationSearchBloodhound, limit) { diff --git a/examples/modifycircle.js b/examples/modifycircle.js index 6fae905a2d57..e1aec18aafff 100644 --- a/examples/modifycircle.js +++ b/examples/modifycircle.js @@ -49,7 +49,7 @@ function MainController() { const circle = new olGeomCircle([-10691093, 4966327], 465000); /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ this.features = new olCollection(); diff --git a/examples/modifyrectangle.js b/examples/modifyrectangle.js index 481577d10ee1..08c09efc7827 100644 --- a/examples/modifyrectangle.js +++ b/examples/modifyrectangle.js @@ -53,7 +53,7 @@ function MainController() { ]]); /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ this.features = new olCollection(); @@ -105,7 +105,7 @@ function MainController() { return ( /** - * @param {olFeature|import('ol/render/Feature.js').default} feature + * @param {olFeature|import('ol/render/Feature.js').default} feature * @param {number} resolution */ function(feature, resolution) { diff --git a/examples/permalink.js b/examples/permalink.js index 915b716f1c9d..dccbbdd377c1 100644 --- a/examples/permalink.js +++ b/examples/permalink.js @@ -187,7 +187,9 @@ DrawComponentController.prototype.$onInit = function() { if (!this.layer) { throw new Error('Missing layer'); } - const vectorSource = /** @type {olSourceVector} */(this.layer.getSource()); + const vectorSource = /** @type {olSourceVector} */( + this.layer.getSource() + ); this.interaction = new olInteractionDraw({ type: /** @type {import("ol/geom/GeometryType.js").default} */ ('LineString'), diff --git a/examples/rotate.js b/examples/rotate.js index c7e60103dc9a..ed4212980074 100644 --- a/examples/rotate.js +++ b/examples/rotate.js @@ -58,7 +58,7 @@ function MainController() { ]]); /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ this.features = new olCollection(); @@ -115,7 +115,7 @@ function MainController() { return ( /** - * @param {olFeature|import('ol/render/Feature.js').default} feature + * @param {olFeature|import('ol/render/Feature.js').default} feature * @param {number} resolution */ function(feature, resolution) { diff --git a/examples/search.js b/examples/search.js index 1d42f8cea94f..02d55edd1271 100644 --- a/examples/search.js +++ b/examples/search.js @@ -83,18 +83,23 @@ function SearchController($element, $rootScope, $compile, ngeoSearchCreateGeoJSO }); /** - * @type {Array>} + * @type {Array>>} */ this.datasets = [{ source: bloodhoundEngine.ttAdapter(), display: (suggestion) => { - const feature = /** @type {import("ol/Feature.js").default} */ (suggestion); + const feature = /** @type {import('ol/Feature.js').default} */ ( + suggestion + ); return feature.get('label'); }, templates: { header: () => '
Addresses
', suggestion: (suggestion) => { - const feature = /** @type {import("ol/Feature.js").default} */ (suggestion); + const feature = + /** @type {import('ol/Feature.js').default} */ ( + suggestion + ); // A scope for the ng-click on the suggestion's « i » button. const scope = $rootScope.$new(true); @@ -121,7 +126,9 @@ function SearchController($element, $rootScope, $compile, ngeoSearchCreateGeoJSO if (!this.map) { throw new Error('Missing map'); } - const feature = /** @type {import('ol/Feature.js').default} */ (suggestion); + const feature = /** @type {import('ol/Feature.js').default} */ ( + suggestion + ); const featureGeometry = /** @type {import('ol/geom/SimpleGeometry.js').default} */( feature.getGeometry() ); @@ -129,7 +136,9 @@ function SearchController($element, $rootScope, $compile, ngeoSearchCreateGeoJSO if (!size) { throw new Error('Missing size'); } - const source = /** @type {olSourceVector} */(this.vectorLayer_.getSource()); + const source = /** @type {olSourceVector} */( + this.vectorLayer_.getSource() + ); source.clear(true); source.addFeature(feature); this.map.getView().fit(featureGeometry, { diff --git a/examples/toolActivate.js b/examples/toolActivate.js index 3c8da73aecdd..c65dd087d1c6 100644 --- a/examples/toolActivate.js +++ b/examples/toolActivate.js @@ -60,7 +60,7 @@ function MainController(ngeoFeatureOverlayMgr, ngeoToolActivateMgr) { /** * Collection shared between the drawing interactions and the feature * overlay used to render the drawn features. - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ const features = new olCollection(); diff --git a/package.json b/package.json index 5caa272496c7..55ec524302cf 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "serve-gmf-apps": "DEV_SERVER=1 TARGET=gmf-apps webpack-dev-server --https --cert=private.crt --key=private.key --port 3000 --mode development --progress --debug", "serve-api": "webpack-dev-server --content-base api/dist/apihelp/ --config buildtools/webpack.api.js --https --cert=private.crt --key=private.key --port 3000 --mode development --progress --watch --debug", "build-gmf-apps-profile": "TARGET=gmf-apps webpack --profile --json > profile.json", - "typecheck": "tsc --pretty", + "typecheck": "tsc", "doc": "typedoc --name ngeo --mode file --excludePrivate --excludeProtected --ignoreCompilerErrors --excludeExternals --exclude '**/examples/**,**/test/**' --out apidoc" }, "sideEffects": false, @@ -105,7 +105,7 @@ "moment": "^2.24.0", "node-sass": "^4.12.0", "node-sass-importer": "^1.0.0", - "ol": "^5.3.3", + "ol": "^6.0.0-beta.6", "ol-cesium": "^2.9.0", "ol-layerswitcher": "^3.2.0", "phantomjs-polyfill-string-includes": "^1.0.0", diff --git a/src/datasource/File.js b/src/datasource/File.js index 90479a57c296..45a0d132943b 100644 --- a/src/datasource/File.js +++ b/src/datasource/File.js @@ -9,8 +9,8 @@ import olSourceVector from 'ol/source/Vector.js'; * * extends DataSourceOptions * @typedef {Object} FileOptions - * @property {import("ol/Collection.js").default} [features] - * Collection of `import("ol/Feature.js").default` objects. + * @property {import("ol/Collection.js").default>} [features] + * Collection of `import('ol/Feature.js').default` objects. * @property {Array} [attributes] (DataSourceOptions) * @property {import('ngeo/datasource/OGC.js').DimensionsFiltersConfig} [dimensionsFiltersConfig] * (DataSourceOptions) @@ -42,13 +42,13 @@ export default class extends ngeoDatasourceDataSource { // === STATIC properties (i.e. that never change) === /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.featuresCollection_ = options.features || new olCollection(); /** - * @type {import("ol/source/Vector.js").default} + * @type {import("ol/source/Vector.js").default} * @private */ this.source_ = new olSourceVector({ @@ -71,7 +71,7 @@ export default class extends ngeoDatasourceDataSource { // ======================================== /** - * @return {Array} Features + * @return {Array>} Features */ get features() { return this.featuresCollection_.getArray(); @@ -83,7 +83,7 @@ export default class extends ngeoDatasourceDataSource { // ======================================= /** - * @return {import("ol/Collection.js").default} Features collection + * @return {import("ol/Collection.js").default>} Features collection */ get featuresCollection() { return this.featuresCollection_; diff --git a/src/draw/Controller.js b/src/draw/Controller.js index 4d8eeb1155e8..f872270d2fc9 100644 --- a/src/draw/Controller.js +++ b/src/draw/Controller.js @@ -18,7 +18,7 @@ export class DrawController { * @param {angular.gettext.gettextCatalog} gettextCatalog Gettext service. * @param {import("ngeo/misc/FeatureHelper.js").FeatureHelper} ngeoFeatureHelper Ngeo feature helper * service. - * @param {import("ol/Collection.js").default} ngeoFeatures Collection of + * @param {import("ol/Collection.js").default>} ngeoFeatures Collection of * features. * @ngInject */ @@ -31,7 +31,7 @@ export class DrawController { /** * Alternate collection of features in which to push the drawn features. * If not defined, then `ngeoFeatures` is used instead. - * @type {?import("ol/Collection.js").default} + * @type {?import("ol/Collection.js").default>} */ this.features = null; @@ -65,7 +65,7 @@ export class DrawController { this.featureHelper_ = ngeoFeatureHelper; /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.ngeoFeatures_ = ngeoFeatures; diff --git a/src/editing/attributesComponent.js b/src/editing/attributesComponent.js index 7f9087023f33..b5fc76c60d99 100644 --- a/src/editing/attributesComponent.js +++ b/src/editing/attributesComponent.js @@ -64,7 +64,7 @@ function ngeoAttributesTemplateUrl($attrs, ngeoAttributesTemplateUrl) { * list of attributes to use. * @htmlAttribute {boolean} ngeo-attributes-disabled Whether the fieldset should * be disabled or not. - * @htmlAttribute {import("ol/Feature.js").default} ngeo-attributes-feature The feature. + * @htmlAttribute {import('ol/Feature.js').default} ngeo-attributes-feature The feature. * * @ngdoc component * @ngname ngeoAttributes @@ -111,7 +111,7 @@ function Controller($scope, ngeoEventHelper) { /** * The feature containing the values. - * @type {?import("ol/Feature.js").default} + * @type {?import('ol/Feature.js').default} */ this.feature = null; diff --git a/src/editing/createfeatureComponent.js b/src/editing/createfeatureComponent.js index 3f48ee3dacc5..dfd17b68d7dd 100644 --- a/src/editing/createfeatureComponent.js +++ b/src/editing/createfeatureComponent.js @@ -99,7 +99,7 @@ function Controller(gettextCatalog, $compile, $filter, $scope, $timeout, ngeoEve this.active = false; /** - * @type {?import("ol/Collection.js").default|import("ol/source/Vector.js").default} + * @type {?import("ol/Collection.js").default>|import("ol/source/Vector.js").default} */ this.features = null; diff --git a/src/editing/createregularpolygonfromclickComponent.js b/src/editing/createregularpolygonfromclickComponent.js index d4f687d383f6..f4228f926dc8 100644 --- a/src/editing/createregularpolygonfromclickComponent.js +++ b/src/editing/createregularpolygonfromclickComponent.js @@ -108,7 +108,7 @@ function Controller($scope) { this.angle = null; /** - * @type {?import("ol/Collection.js").default} + * @type {?import("ol/Collection.js").default>} */ this.features = null; diff --git a/src/editing/exportfeaturesComponent.js b/src/editing/exportfeaturesComponent.js index 23707b83ff07..31fc6841a527 100644 --- a/src/editing/exportfeaturesComponent.js +++ b/src/editing/exportfeaturesComponent.js @@ -28,7 +28,7 @@ const module = angular.module('ngeoExportfeatures', [ * ngeo-exportfeatures-features="ctrl.features" * class="btn btn-link">Export * - * @htmlAttribute {import("ol/Collection.js").default} + * @htmlAttribute {import("ol/Collection.js").default>} * ngeo-exportfeatures-features The features to export * @return {angular.IDirective} The directive specs. * @ngInject @@ -64,7 +64,7 @@ module.directive('ngeoExportfeatures', editingExportFeaturesComponent); function Controller($element, $injector, $scope, ngeoFeatureHelper) { /** - * @type {?import("ol/Collection.js").default} + * @type {?import("ol/Collection.js").default>} * @private */ this.features = null; diff --git a/src/filter/ruleComponent.js b/src/filter/ruleComponent.js index f276ffd618d7..2d2411c7f7e9 100644 --- a/src/filter/ruleComponent.js +++ b/src/filter/ruleComponent.js @@ -282,7 +282,7 @@ class RuleController { this.drawToolActivate = new ngeoMiscToolActivate(this, 'drawActive'); /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ this.drawnFeatures = new olCollection(); @@ -293,7 +293,7 @@ class RuleController { this.menu_ = null; /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} */ this.selectedFeatures = new olCollection(); @@ -940,7 +940,7 @@ class RuleController { const feature = this.map.forEachFeatureAtPixel( pixel, (feature) => { - /** @type {?Feature} */ + /** @type {?Feature} */ let ret = null; if (!(feature instanceof Feature)) { throw new Error('Wrong feature type'); diff --git a/src/format/FeatureHash.js b/src/format/FeatureHash.js index 3bc35718e1f4..b7d139bc84ba 100644 --- a/src/format/FeatureHash.js +++ b/src/format/FeatureHash.js @@ -3,7 +3,7 @@ import ngeoFormatFeatureHashStyleType from 'ngeo/format/FeatureHashStyleType.js' import {rgbArrayToHex} from 'ngeo/utils.js'; import {asArray as asColorArray} from 'ol/color.js'; import olFeature from 'ol/Feature.js'; -import * as olFormatFeature from 'ol/format/Feature.js'; +import {transformGeometryWithOptions} from 'ol/format/Feature.js'; import olFormatTextFeature from 'ol/format/TextFeature.js'; import olGeomGeometryLayout from 'ol/geom/GeometryLayout.js'; import olGeomLineString from 'ol/geom/LineString.js'; @@ -25,9 +25,9 @@ import Geometry from 'ol/geom/Geometry.js'; * * @typedef {Object} FeatureHashOptions * @property {number} [accuracy] The encoding and decoding accuracy. Optional. Default value is 1. - * @property {Object} [defaultValues] defaultValues. + * @property {Object)>} [defaultValues] defaultValues. * @property {boolean} [encodeStyles=true] Encode styles. Optional. - * @property {function(import("ol/Feature.js").default): Object} [properties] + * @property {function(olFeature): Object} [properties] * A function that returns serializable properties for a feature. Optional. By default the feature * properties (as returned by `feature.getProperties()`) are used. To be serializable the returned * properties should be numbers or strings. @@ -155,7 +155,7 @@ class FeatureHash extends olFormatTextFeature { this.encodeStyles_ = options.encodeStyles || true; /** - * @type {function(import("ol/Feature.js").default):Object} + * @type {function(olFeature):Object} * @private */ this.propertiesFunction_ = options.properties || defaultPropertiesFunction_; @@ -185,7 +185,7 @@ class FeatureHash extends olFormatTextFeature { LegacyProperties_ = options.propertiesType || {}; /** - * @type {Object} + * @type {Object): void>} * @private */ this.defaultValues_ = options.defaultValues || {}; @@ -266,7 +266,7 @@ class FeatureHash extends olFormatTextFeature { * Read a feature from a logical sequence of characters. * @param {string} text Text. * @param {import('ol/format/Feature.js').ReadOptions=} opt_options Read options. - * @return {import("ol/Feature.js").default} Feature. + * @return {olFeature} Feature. * @protected * @override */ @@ -316,7 +316,7 @@ class FeatureHash extends olFormatTextFeature { * Read multiple features from a logical sequence of characters. * @param {string} text Text. * @param {import('ol/format/Feature.js').ReadOptions=} opt_options Read options. - * @return {Array} Features. + * @return {Array>} Features. * @protected * @override */ @@ -324,7 +324,7 @@ class FeatureHash extends olFormatTextFeature { console.assert(text[0] === 'F'); this.prevX_ = 0; this.prevY_ = 0; - /** @type {Array} */ + /** @type {Array>} */ const features = []; text = text.substring(1); while (text.length > 0) { @@ -364,7 +364,7 @@ class FeatureHash extends olFormatTextFeature { /** * Encode a feature into a logical sequence of characters. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @param {import('ol/format/Feature.js').ReadOptions=} opt_options Read options. * @return {string} Encoded feature. * @protected @@ -440,7 +440,7 @@ class FeatureHash extends olFormatTextFeature { /** * Encode an array of features into a logical sequence of characters. - * @param {Array} features Feature. + * @param {Array>} features Feature. * @param {import('ol/format/Feature.js').ReadOptions=} opt_options Read options. * @return {string} Encoded features. * @protected @@ -470,7 +470,7 @@ class FeatureHash extends olFormatTextFeature { writeGeometryText(geometry, opt_options) { const geometryWriter = GEOMETRY_WRITERS_[geometry.getType()]; console.assert(geometryWriter !== undefined); - const transformedGeometry = olFormatFeature.transformWithOptions(geometry, true, opt_options); + const transformedGeometry = transformGeometryWithOptions(geometry, true, opt_options); if (!(transformedGeometry instanceof Geometry)) { throw new Error('Missing transformedGeometry'); } @@ -486,7 +486,7 @@ export default FeatureHash; /** * Get features's properties. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {Object} The feature properties to * serialize. * @private @@ -858,7 +858,7 @@ function readMultiPolygonGeometry_(text) { * Read a logical sequence of characters and apply the decoded style on the * given feature. * @param {string} text Text. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private * @hidden */ @@ -939,7 +939,7 @@ function setStyleInFeature_(text, feature) { * style properties for the feature. Legacy keys are converted to the new ones * for compatibility. * @param {string} text Text. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private * @hidden */ @@ -1039,7 +1039,7 @@ function castValue_(key, value) { * depending on the property. Some properties are also deleted when they don't * match the geometry of the feature. * @param {string} text Text. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {Object} The style properties for the feature. * @private * @hidden diff --git a/src/geolocation/desktop.js b/src/geolocation/desktop.js index 1f555d3e6641..89172e1ce769 100644 --- a/src/geolocation/desktop.js +++ b/src/geolocation/desktop.js @@ -144,7 +144,7 @@ function Controller($scope, $element, ngeoFeatureOverlayMgr, ngeoNotification) { }); /** - * @type {import("ol/Feature.js").default} + * @type {olFeature} * @private */ this.positionFeature_ = new olFeature(); @@ -154,7 +154,7 @@ function Controller($scope, $element, ngeoFeatureOverlayMgr, ngeoNotification) { } /** - * @type {import("ol/Feature.js").default} + * @type {olFeature} * @private */ this.accuracyFeature_ = new olFeature(); diff --git a/src/geolocation/mobile.js b/src/geolocation/mobile.js index 0dfe6e648271..23aaea5d2aaa 100644 --- a/src/geolocation/mobile.js +++ b/src/geolocation/mobile.js @@ -169,7 +169,7 @@ function Controller($scope, $element, gettextCatalog, ngeoFeatureOverlayMgr, nge }); /** - * @type {import("ol/Feature.js").default} + * @type {olFeature} * @private */ this.positionFeature_ = new olFeature(); @@ -179,7 +179,7 @@ function Controller($scope, $element, gettextCatalog, ngeoFeatureOverlayMgr, nge } /** - * @type {import("ol/Feature.js").default} + * @type {olFeature} * @private */ this.accuracyFeature_ = new olFeature(); diff --git a/src/googlestreetview/component.js b/src/googlestreetview/component.js index 044f875d7ed9..b33f103677f1 100644 --- a/src/googlestreetview/component.js +++ b/src/googlestreetview/component.js @@ -119,7 +119,7 @@ class GoogleStreetviewController { // Inner properties /** - * @type {import("ol/Feature.js").default} + * @type {olFeature} * @private */ this.feature_ = new olFeature(); diff --git a/src/interaction/DrawAzimut.js b/src/interaction/DrawAzimut.js index 635b3d48c7f5..450958523a9d 100644 --- a/src/interaction/DrawAzimut.js +++ b/src/interaction/DrawAzimut.js @@ -1,6 +1,6 @@ import {getDefaultDrawStyleFunction} from 'ngeo/interaction/common.js'; import ngeoCustomEvent from 'ngeo/CustomEvent.js'; -import olFeature from 'ol/Feature.js'; +import Feature from 'ol/Feature.js'; import * as olEvents from 'ol/events.js'; import {FALSE} from 'ol/functions.js'; import olGeomCircle from 'ol/geom/Circle.js'; @@ -9,13 +9,11 @@ import olGeomLineString from 'ol/geom/LineString.js'; import olGeomPoint from 'ol/geom/Point.js'; import olInteractionPointer from 'ol/interaction/Draw.js'; import olLayerVector from 'ol/layer/Vector.js'; -import olSourceVector from 'ol/source/Vector.js'; import VectorSource from 'ol/source/Vector.js'; -import Feature from 'ol/Feature.js'; /** * @typedef {Object} Options - * @property {olSourceVector} source + * @property {VectorSource} source * @property {import('ol/style/Style.js').StyleLike} style */ @@ -25,6 +23,7 @@ import Feature from 'ol/Feature.js'; * @private * @hidden */ +// @ts-ignore: error «error TS2415: Class 'DrawAzimut' incorrectly extends base class 'Draw'.» is unclear... class DrawAzimut extends olInteractionPointer { /** * @param {Options} options Options. @@ -44,7 +43,7 @@ class DrawAzimut extends olInteractionPointer { /** * Target source for drawn features. - * @type {import("ol/source/Vector.js").default} + * @type {import("ol/source/Vector.js").default} * @private */ this.source_ = options.source; @@ -58,14 +57,14 @@ class DrawAzimut extends olInteractionPointer { /** * Sketch feature. - * @type {Feature} + * @type {Feature} * @private */ this.sketchFeature_ = new Feature(); /** * Sketch point. - * @type {Feature} + * @type {Feature} * @private */ this.sketchPoint_ = new Feature(); @@ -87,7 +86,7 @@ class DrawAzimut extends olInteractionPointer { * @private */ this.sketchLayer_ = new olLayerVector({ - source: new olSourceVector({ + source: new VectorSource({ useSpatialIndex: false, wrapX: false }), @@ -119,7 +118,7 @@ class DrawAzimut extends olInteractionPointer { createOrUpdateSketchPoint_(event) { const coordinates = event.coordinate.slice(); if (this.sketchPoint_.getGeometry() === null) { - this.sketchPoint_ = new olFeature(new olGeomPoint(coordinates)); + this.sketchPoint_ = new Feature(new olGeomPoint(coordinates)); this.updateSketchFeatures_(); } else { const sketchPointGeom = this.sketchPoint_.getGeometry(); @@ -137,7 +136,9 @@ class DrawAzimut extends olInteractionPointer { const sketchFeatures = []; sketchFeatures.push(this.sketchFeature_); sketchFeatures.push(this.sketchPoint_); - const source = /** @type {olSourceVector} */(this.sketchLayer_.getSource()); + const source = /** @type {VectorSource} */( + this.sketchLayer_.getSource() + ); source.clear(true); source.addFeatures(sketchFeatures); } @@ -153,8 +154,7 @@ class DrawAzimut extends olInteractionPointer { const line = new olGeomLineString([start.slice(), start.slice()]); const circle = new olGeomCircle(start, 0); const geometry = new olGeomGeometryCollection([line, circle]); - console.assert(geometry !== undefined); - this.sketchFeature_ = new olFeature(); + this.sketchFeature_ = new Feature(); this.sketchFeature_.setGeometry(geometry); this.updateSketchFeatures_(); /** @type {import('ngeo/interaction/common.js').DrawEvent} */ @@ -196,7 +196,7 @@ class DrawAzimut extends olInteractionPointer { /** * Stop drawing without adding the sketch feature to the target layer. - * @return {Feature} The sketch feature (or null if none). + * @return {Feature} The sketch feature (or null if none). * @private */ abortDrawing_() { diff --git a/src/interaction/Measure.js b/src/interaction/Measure.js index 8459f0f0d727..0284a8ddd991 100644 --- a/src/interaction/Measure.js +++ b/src/interaction/Measure.js @@ -34,7 +34,7 @@ import VectorSource from 'ol/source/Vector.js'; /** * @typedef {Object} MeasureEventItem - * @property {import("ol/Feature.js").default} feature + * @property {import('ol/Feature.js').default} feature */ /** @@ -97,7 +97,7 @@ class Measure extends olInteractionInteraction { /** * The sketch feature. - * @type {?import("ol/Feature.js").default} + * @type {?import('ol/Feature.js').default} * @protected */ this.sketchFeature = null; @@ -231,7 +231,7 @@ class Measure extends olInteractionInteraction { * @abstract * @param {import("ol/style/Style.js").StyleLike} style The sketchStyle used for the drawing * interaction. - * @param {VectorSource} source Vector source. + * @param {VectorSource} source Vector source. * @return {?import("ol/interaction/Draw.js").default|import("ngeo/interaction/DrawAzimut.js").default|import("ngeo/interaction/MobileDraw.js").default} * The interaction * @protected diff --git a/src/interaction/MeasureArea.js b/src/interaction/MeasureArea.js index 79ef39c3003c..e04d5108ef0f 100644 --- a/src/interaction/MeasureArea.js +++ b/src/interaction/MeasureArea.js @@ -43,7 +43,7 @@ export default class extends ngeoInteractionMeasure { /** * @param {import("ol/style/Style.js").StyleLike} style The sketchStyle used for the drawing * interaction. - * @param {import("ol/source/Vector.js").default} source Vector source. + * @param {import("ol/source/Vector.js").default} source Vector source. * @return {olInteractionDraw|import("ngeo/interaction/MobileDraw.js").default} The interaction */ createDrawInteraction(style, source) { diff --git a/src/interaction/MeasureAreaMobile.js b/src/interaction/MeasureAreaMobile.js index 3f260d467b80..f232957c61d1 100644 --- a/src/interaction/MeasureAreaMobile.js +++ b/src/interaction/MeasureAreaMobile.js @@ -20,7 +20,7 @@ class MeasureAreaMobile extends ngeoInteractionMeasureArea { /** * @param {import("ol/style/Style.js").StyleLike} style The sketchStyle used for the drawing * interaction. - * @param {import("ol/source/Vector.js").default} source Vector source. + * @param {import("ol/source/Vector.js").default} source Vector source. * @return {ngeoInteractionMobileDraw} The interaction */ createDrawInteraction(style, source) { diff --git a/src/interaction/MeasureAzimut.js b/src/interaction/MeasureAzimut.js index 65b890b7a843..a3a04332aa61 100644 --- a/src/interaction/MeasureAzimut.js +++ b/src/interaction/MeasureAzimut.js @@ -46,12 +46,11 @@ export default class extends ngeoInteractionMeasure { /** * @param {import("ol/style/Style.js").StyleLike} style The sketchStyle used for the drawing * interaction. - * @param {import('ol/source/Vector.js').default} source Vector source. + * @param {import('ol/source/Vector.js').default} source Vector source. * @return {?import("ol/interaction/Draw.js").default|import("ngeo/interaction/DrawAzimut.js").default| * import("ngeo/interaction/MobileDraw.js").default} The interaction */ createDrawInteraction(style, source) { - return new ngeoInteractionDrawAzimut({ source, style diff --git a/src/interaction/MeasureLength.js b/src/interaction/MeasureLength.js index 11d53142f627..d80dd5a3b0b8 100644 --- a/src/interaction/MeasureLength.js +++ b/src/interaction/MeasureLength.js @@ -36,7 +36,7 @@ export default class extends ngeoInteractionMeasure { /** * @param {import("ol/style/Style.js").StyleLike} style The sketchStyle used for the drawing * interaction. - * @param {import("ol/source/Vector.js").default} source Vector source. + * @param {import("ol/source/Vector.js").default} source Vector source. * @return {olInteractionDraw|import("ngeo/interaction/MobileDraw.js").default} The interaction */ createDrawInteraction(style, source) { diff --git a/src/interaction/MeasureLengthMobile.js b/src/interaction/MeasureLengthMobile.js index 42fa248e8fcf..bacf07868e56 100644 --- a/src/interaction/MeasureLengthMobile.js +++ b/src/interaction/MeasureLengthMobile.js @@ -22,7 +22,7 @@ export default class extends ngeoInteractionMeasureLength { /** * @param {import("ol/style/Style.js").StyleLike} * style The sketchStyle used for the drawing interaction. - * @param {import("ol/source/Vector.js").default} source Vector source. + * @param {import("ol/source/Vector.js").default} source Vector source. * @return {ngeoInteractionMobileDraw} The interaction */ createDrawInteraction(style, source) { diff --git a/src/interaction/MeasurePointMobile.js b/src/interaction/MeasurePointMobile.js index 558346e395fb..6c710b41270f 100644 --- a/src/interaction/MeasurePointMobile.js +++ b/src/interaction/MeasurePointMobile.js @@ -33,7 +33,7 @@ export default class extends ngeoInteractionMeasure { /** * @param {import("ol/style/Style.js").StyleLike} style The sketchStyle used for the drawing * interaction. - * @param {import('ol/source/Vector.js').default} source Vector source. + * @param {import('ol/source/Vector.js').default} source Vector source. * @return {import("ol/interaction/Draw.js").default|import("ngeo/interaction/DrawAzimut.js").default| * import("ngeo/interaction/MobileDraw.js").default} The interaction */ diff --git a/src/interaction/MobileDraw.js b/src/interaction/MobileDraw.js index d693bac6ea9b..781732cb070a 100644 --- a/src/interaction/MobileDraw.js +++ b/src/interaction/MobileDraw.js @@ -72,21 +72,21 @@ export default class extends olInteractionInteraction { /** * Sketch feature. - * @type {?import("ol/Feature.js").default} + * @type {?olFeature} * @private */ this.sketchFeature_ = null; /** * Previous sketch points, saved to be able to display them on the layer. - * @type {Array} + * @type {Array>} * @private */ this.sketchPoints_ = []; /** * Current sketch point. - * @type {?import("ol/Feature.js").default} + * @type {?olFeature} * @private */ this.sketchPoint_ = null; @@ -174,7 +174,7 @@ export default class extends olInteractionInteraction { /** * Returns the current sketch feature. - * @return {?import("ol/Feature.js").default} The sketch feature, or null if none. + * @return {?olFeature} The sketch feature, or null if none. */ getFeature() { return this.sketchFeature_; @@ -376,7 +376,7 @@ export default class extends olInteractionInteraction { /** * Stop drawing without adding the sketch feature to the target layer. - * @return {?import("ol/Feature.js").default} The sketch feature (or null if none). + * @return {?olFeature} The sketch feature (or null if none). * @private */ abortDrawing_() { @@ -384,7 +384,8 @@ export default class extends olInteractionInteraction { if (sketchFeature || this.sketchPoints_.length > 0) { this.sketchFeature_ = null; this.sketchPoint_ = null; - /** @type {olSourceVector} */(this.overlay_.getSource()).clear(true); + /** @type {olSourceVector} */(this.overlay_.getSource()) + .clear(true); } this.sketchPoints_ = []; this.set('dirty', false); @@ -457,7 +458,9 @@ export default class extends olInteractionInteraction { if (this.sketchPoint_) { sketchFeatures.push(this.sketchPoint_); } - const overlaySource = /** @type {olSourceVector} */(this.overlay_.getSource()); + const overlaySource = /** @type {olSourceVector} */( + this.overlay_.getSource() + ); overlaySource.clear(true); overlaySource.addFeatures(sketchFeatures); overlaySource.addFeatures(this.sketchPoints_); diff --git a/src/interaction/Modify.js b/src/interaction/Modify.js index 585c6840285f..909f4b995e15 100644 --- a/src/interaction/Modify.js +++ b/src/interaction/Modify.js @@ -13,7 +13,7 @@ import {CollectionEvent} from 'ol/Collection.js'; /** * @typedef {Object} ModifyEventItem - * @property {import("ol/Feature.js").default} features + * @property {olFeature} features */ @@ -50,7 +50,7 @@ export default class extends olInteractionInteraction { console.assert(options.features); /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.features_ = options.features; @@ -68,7 +68,7 @@ export default class extends olInteractionInteraction { this.interactions_ = []; /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.otherFeatures_ = new olCollection(); @@ -82,7 +82,7 @@ export default class extends olInteractionInteraction { })); /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.circleFeatures_ = new olCollection(); @@ -95,7 +95,7 @@ export default class extends olInteractionInteraction { })); /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.rectangleFeatures_ = new olCollection(); @@ -194,13 +194,13 @@ export default class extends olInteractionInteraction { */ handleFeaturesRemove_(evt) { if (evt instanceof CollectionEvent) { - const feature = /** @type {import("ol/Feature.js").default} */ (evt.element); + const feature = /** @type {olFeature} */ (evt.element); this.removeFeature_(feature); } } /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private */ addFeature_(feature) { @@ -209,7 +209,7 @@ export default class extends olInteractionInteraction { } /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private */ removeFeature_(feature) { @@ -218,8 +218,8 @@ export default class extends olInteractionInteraction { } /** - * @param {import("ol/Feature.js").default} feature Feature. - * @return {import("ol/Collection.js").default} Collection of features for + * @param {olFeature} feature Feature. + * @return {import("ol/Collection.js").default>} Collection of features for * this feature. * @private */ diff --git a/src/interaction/ModifyCircle.js b/src/interaction/ModifyCircle.js index adf5427367d3..74399f607f01 100644 --- a/src/interaction/ModifyCircle.js +++ b/src/interaction/ModifyCircle.js @@ -40,7 +40,7 @@ export default class extends olInteractionPointer { /** * Editing vertex. - * @type {?import("ol/Feature.js").default} + * @type {?olFeature} * @private */ this.vertexFeature_ = null; @@ -107,7 +107,7 @@ export default class extends olInteractionPointer { }); /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.features_ = options.features; @@ -119,7 +119,7 @@ export default class extends olInteractionPointer { } /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private */ addFeature_(feature) { @@ -152,7 +152,7 @@ export default class extends olInteractionPointer { } /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private */ removeFeature_(feature) { @@ -160,13 +160,14 @@ export default class extends olInteractionPointer { // Remove the vertex feature if the collection of canditate features // is empty. if (this.vertexFeature_ && this.features_.getLength() === 0) { - /** @type {olSourceVector} */(this.overlay_.getSource()).removeFeature(this.vertexFeature_); + /** @type {olSourceVector} */(this.overlay_.getSource()) + .removeFeature(this.vertexFeature_); this.vertexFeature_ = null; } } /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private */ removeFeatureSegmentData_(feature) { @@ -213,13 +214,13 @@ export default class extends olInteractionPointer { */ handleFeatureRemove_(evt) { if (evt instanceof CollectionEvent) { - const feature = /** @type {import("ol/Feature.js").default} */ (evt.element); + const feature = /** @type {olFeature} */ (evt.element); this.removeFeature_(feature); } } /** - * @param {import("ol/Feature.js").default} feature Feature + * @param {olFeature} feature Feature * @param {import("ol/geom/Polygon.js").default} geometry Geometry. * @private */ @@ -244,7 +245,7 @@ export default class extends olInteractionPointer { /** * @param {import("ol/coordinate.js").Coordinate} coordinates Coordinates. - * @return {import("ol/Feature.js").default} Vertex feature. + * @return {olFeature} Vertex feature. * @private */ createOrUpdateVertexFeature_(coordinates) { @@ -252,7 +253,8 @@ export default class extends olInteractionPointer { if (!vertexFeature) { vertexFeature = new olFeature(new olGeomPoint(coordinates)); this.vertexFeature_ = vertexFeature; - /** @type {olSourceVector} */(this.overlay_.getSource()).addFeature(vertexFeature); + /** @type {olSourceVector} */(this.overlay_.getSource()) + .addFeature(vertexFeature); } else { const geometry = /** @type {import("ol/geom/Point.js").default} */ (vertexFeature.getGeometry()); geometry.setCoordinates(coordinates); @@ -332,7 +334,8 @@ export default class extends olInteractionPointer { } } if (this.vertexFeature_) { - /** @type {olSourceVector} */(this.overlay_.getSource()).removeFeature(this.vertexFeature_); + /** @type {olSourceVector} */(this.overlay_.getSource()) + .removeFeature(this.vertexFeature_); this.vertexFeature_ = null; } } diff --git a/src/interaction/ModifyRectangle.js b/src/interaction/ModifyRectangle.js index 54693bc59589..62139048565f 100644 --- a/src/interaction/ModifyRectangle.js +++ b/src/interaction/ModifyRectangle.js @@ -49,14 +49,14 @@ class ModifyRectangle extends olInteractionPointer { }); /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.features_ = options.features; /** * The feature currently modified. - * @type {?import("ol/Feature.js").default} + * @type {?olFeature} * @private */ this.feature_ = null; @@ -93,7 +93,7 @@ class ModifyRectangle extends olInteractionPointer { } /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private */ addFeature_(feature) { @@ -107,7 +107,9 @@ class ModifyRectangle extends olInteractionPointer { return; } - const pointSource = /** @type {olSourceVector} */(this.vectorPoints_.getSource()); + const pointSource = /** @type {olSourceVector} */( + this.vectorPoints_.getSource() + ); // from each corners, create a point feature and add it to the point layer. // each point is then associated with 2 siblings in order to update the @@ -121,7 +123,7 @@ class ModifyRectangle extends olInteractionPointer { corners.shift(); } } - /** @type {olFeature[]} */ + /** @type {olFeature[]} */ const pointFeatures = []; let cornerPoint; let cornerFeature; @@ -253,7 +255,7 @@ class ModifyRectangle extends olInteractionPointer { } /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private */ removeFeature_(feature) { @@ -261,7 +263,8 @@ class ModifyRectangle extends olInteractionPointer { const item = this.cache_[uid]; const corners = item.corners; for (let i = 0; i < corners.length; i++) { - /** @type {olSourceVector} */(this.vectorPoints_.getSource()).removeFeature(corners[i]); + /** @type {olSourceVector} */(this.vectorPoints_.getSource()) + .removeFeature(corners[i]); } this.feature_ = null; corners.length = 0; @@ -294,7 +297,7 @@ class ModifyRectangle extends olInteractionPointer { */ handleFeatureRemove_(evt) { if (evt instanceof CollectionEvent) { - const feature = /** @type {import("ol/Feature.js").default} */ (evt.element); + const feature = /** @type {olFeature} */ (evt.element); this.removeFeature_(feature); } } @@ -307,8 +310,10 @@ class ModifyRectangle extends olInteractionPointer { handleDown_(evt) { const map = evt.map; - const feature = /** @type {olFeature} */(map.forEachFeatureAtPixel(evt.pixel, feature => - (feature.get('siblingX') && feature.get('siblingY') ? feature : undefined)) + const feature = /** @type {olFeature} */( + map.forEachFeatureAtPixel(evt.pixel, feature => + (feature.get('siblingX') && feature.get('siblingY') ? feature : undefined) + ) ); if (feature) { @@ -411,7 +416,7 @@ class ModifyRectangle extends olInteractionPointer { /** * @typedef {Object} CacheItem - * @property {Array} corners + * @property {Array>} corners */ diff --git a/src/interaction/Rotate.js b/src/interaction/Rotate.js index 17a0231d6ef2..2cee014eff5f 100644 --- a/src/interaction/Rotate.js +++ b/src/interaction/Rotate.js @@ -15,7 +15,7 @@ import {CollectionEvent} from 'ol/Collection.js'; /** * @typedef {Object} RotateEventItem - * @property {import("ol/Feature.js").default} feature + * @property {olFeature} feature */ @@ -74,14 +74,14 @@ export default class extends olInteractionPointer { options.pixelTolerance : 10; /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.features_ = options.features; /** * The feature currently modified. - * @type {?import("ol/Feature.js").default} + * @type {?olFeature} * @private */ this.feature_ = null; @@ -114,7 +114,7 @@ export default class extends olInteractionPointer { }); /** - * @type {Object} + * @type {Object>} * @private */ this.centerFeatures_ = {}; @@ -157,7 +157,7 @@ export default class extends olInteractionPointer { } /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private */ addFeature_(feature) { @@ -173,7 +173,9 @@ export default class extends olInteractionPointer { const point = new olGeomPoint(this.getCenterCoordinate_(geometry)); const centerFeature = new olFeature(point); this.centerFeatures_[uid] = centerFeature; - /** @type {olSourceVector} */(this.overlay_.getSource()).addFeature(centerFeature); + /** @type {olSourceVector} */( + this.overlay_.getSource() + ).addFeature(centerFeature); } /** @@ -189,7 +191,7 @@ export default class extends olInteractionPointer { } /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private */ removeFeature_(feature) { @@ -236,7 +238,7 @@ export default class extends olInteractionPointer { */ handleFeatureRemove_(evt) { if (evt instanceof CollectionEvent) { - const feature = /** @type {import("ol/Feature.js").default} */ (evt.element); + const feature = /** @type {olFeature} */ (evt.element); this.removeFeature_(feature); } } @@ -266,7 +268,7 @@ export default class extends olInteractionPointer { if (feature) { this.coordinate_ = evt.coordinate; - this.feature_ = /** @type {olFeature} */(feature); + this.feature_ = /** @type {olFeature} */(feature); const geometry = (this.feature_.getGeometry()); if (geometry !== undefined) { this.centerCoordinate_ = this.getCenterCoordinate_(geometry); diff --git a/src/interaction/Translate.js b/src/interaction/Translate.js index 16cd3ee4a302..d24c5282cc37 100644 --- a/src/interaction/Translate.js +++ b/src/interaction/Translate.js @@ -14,7 +14,7 @@ import {CollectionEvent} from 'ol/Collection.js'; /** * @typedef {Object} TranslateOptions - * @property {import("ol/Collection.js").default} [features] Only features + * @property {import("ol/Collection.js").default>} [features] Only features * contained in this collection will be able to be translated. If not specified, all features on the map * will be able to be translated. * @property {import("ol/style/Style.js").StyleLike} [style] Style for the center features added by the @@ -57,13 +57,13 @@ export default class extends olInteractionTranslate { this.keyPressListenerKey_ = null; /** - * @type {?import("ol/Collection.js").default} + * @type {?import("ol/Collection.js").default>} * @private */ this.myFeatures_ = options.features !== undefined ? options.features : null; /** - * @type {import("ol/source/Vector.js").default} + * @type {import("ol/source/Vector.js").default} * @private */ this.vectorSource_ = new olSourceVector({ @@ -82,7 +82,7 @@ export default class extends olInteractionTranslate { }); /** - * @type {Object} + * @type {Object>} * @private */ this.centerFeatures_ = {}; @@ -190,13 +190,13 @@ export default class extends olInteractionTranslate { */ handleFeaturesRemove_(evt) { if (evt instanceof CollectionEvent) { - const feature = /** @type {import("ol/Feature.js").default} */ (evt.element); + const feature = /** @type {olFeature} */ (evt.element); this.removeFeature_(feature); } } /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private */ addFeature_(feature) { @@ -220,7 +220,7 @@ export default class extends olInteractionTranslate { } /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @private */ removeFeature_(feature) { @@ -235,7 +235,7 @@ export default class extends olInteractionTranslate { } /** - * @param {import("ol/Feature.js").default} feature Feature being moved. + * @param {olFeature} feature Feature being moved. * @param {Event|import("ol/events/Event.js").default} evt Event. * @private */ diff --git a/src/layertree/Controller.js b/src/layertree/Controller.js index 3229dc10da53..a07647f35ef1 100644 --- a/src/layertree/Controller.js +++ b/src/layertree/Controller.js @@ -124,7 +124,8 @@ export function LayertreeController($scope, $rootScope, $attrs) { this.nodelayerExpr = nodelayerExpr; /** - * @type {?import("ol/layer/Layer.js").default|import("ol/layer/Group.js").default} + * @type {?import("ol/layer/Layer.js").default| + * import("ol/layer/Group.js").default} */ this.layer = null; if (!isRoot) { @@ -374,7 +375,7 @@ export const LayertreeVisitorDecision = { /** - * @typedef {function(LayertreeController): (!LayertreeVisitorDecision|void)} Visitor + * @typedef {function(LayertreeController): (LayertreeVisitorDecision|undefined|void)} Visitor */ diff --git a/src/map/FeatureOverlay.js b/src/map/FeatureOverlay.js index 0748ee13cfd4..53ca43c7c93f 100644 --- a/src/map/FeatureOverlay.js +++ b/src/map/FeatureOverlay.js @@ -17,7 +17,7 @@ export function FeatureOverlay(manager, index) { this.manager_ = manager; /** - * @type {?import("ol/Collection.js").default} + * @type {?import("ol/Collection.js").default>} * @private */ this.features_ = null; @@ -32,7 +32,7 @@ export function FeatureOverlay(manager, index) { /** * Add a feature to the feature overlay. - * @param {import("ol/Feature.js").default} feature The feature to add. + * @param {import('ol/Feature.js').default} feature The feature to add. */ FeatureOverlay.prototype.addFeature = function(feature) { this.manager_.addFeature(feature, this.index_); @@ -41,7 +41,7 @@ FeatureOverlay.prototype.addFeature = function(feature) { /** * Remove a feature from the feature overlay. - * @param {import("ol/Feature.js").default} feature The feature to remove. + * @param {import('ol/Feature.js').default} feature The feature to remove. */ FeatureOverlay.prototype.removeFeature = function(feature) { this.manager_.removeFeature(feature, this.index_); @@ -62,7 +62,7 @@ FeatureOverlay.prototype.clear = function() { * configure the feature overlay with a feature collection you will use the * collection to add and remove features instead of using the overlay's * `addFeature`, `removeFeature` and `clear` functions. - * @param {import("ol/Collection.js").default} features Feature collection. + * @param {import("ol/Collection.js").default>} features Feature collection. */ FeatureOverlay.prototype.setFeatures = function(features) { if (this.features_ !== null) { @@ -97,7 +97,9 @@ FeatureOverlay.prototype.setStyle = function(style) { */ FeatureOverlay.prototype.handleFeatureAdd_ = function(evt) { if (evt instanceof CollectionEvent) { - const feature = /** @type {import("ol/Feature.js").default} */ (evt.element); + const feature = /** @type {import('ol/Feature.js').default} */ ( + evt.element + ); this.addFeature(feature); } }; @@ -109,7 +111,9 @@ FeatureOverlay.prototype.handleFeatureAdd_ = function(evt) { */ FeatureOverlay.prototype.handleFeatureRemove_ = function(evt) { if (evt instanceof CollectionEvent) { - const feature = /** @type {import("ol/Feature.js").default} */ (evt.element); + const feature = /** @type {import('ol/Feature.js').default} */ ( + evt.element + ); this.removeFeature(feature); } }; diff --git a/src/map/FeatureOverlayMgr.js b/src/map/FeatureOverlayMgr.js index e380e369c31d..eee2725713cd 100644 --- a/src/map/FeatureOverlayMgr.js +++ b/src/map/FeatureOverlayMgr.js @@ -10,7 +10,7 @@ import {toFunction as toStyleFunction, createDefaultStyle as olStyleDefaultFunct /** * @typedef {Object} MapFeatureOverlayGroup * @property {import('ol/style/Style.js').StyleFunction} styleFunction - * @property {Object} features + * @property {Object>} features */ @@ -52,7 +52,7 @@ export function FeatureOverlayMgr() { this.groups_ = []; /** - * @type {import("ol/source/Vector.js").default} + * @type {import("ol/source/Vector.js").default} * @private */ this.source_ = new olSourceVector({ @@ -74,7 +74,7 @@ export function FeatureOverlayMgr() { /** - * @param {import("ol/Feature.js").default} feature The feature to add. + * @param {import('ol/Feature.js').default} feature The feature to add. * @param {number} groupIndex The group groupIndex. */ FeatureOverlayMgr.prototype.addFeature = function(feature, groupIndex) { @@ -88,7 +88,7 @@ FeatureOverlayMgr.prototype.addFeature = function(feature, groupIndex) { /** - * @param {import("ol/Feature.js").default} feature The feature to add. + * @param {import('ol/Feature.js').default} feature The feature to add. * @param {number} groupIndex The group groupIndex. */ FeatureOverlayMgr.prototype.removeFeature = function(feature, groupIndex) { @@ -157,7 +157,7 @@ FeatureOverlayMgr.prototype.setStyle = function(style, groupIndex) { /** - * @param {import("ol/Feature.js").default|import("ol/render/Feature.js").default} feature Feature. + * @param {import('ol/Feature.js').default|import("ol/render/Feature.js").default} feature Feature. * @param {number} resolution Resolution. * @return {Array|import("ol/style/Style.js").default} Styles. * @private diff --git a/src/map/LayerHelper.js b/src/map/LayerHelper.js index 28754089500a..ff4f0f127cbf 100644 --- a/src/map/LayerHelper.js +++ b/src/map/LayerHelper.js @@ -291,14 +291,17 @@ LayerHelper.prototype.getGroupFromMap = function(map, groupName) { * Get an array of all layers in a group. The group can contain multiple levels * of others groups. * @param {import("ol/layer/Base.js").default} layer The base layer, mostly a group of layers. - * @return {Array} Layers. + * @return {Array>} Layers. */ LayerHelper.prototype.getFlatLayers = function(layer) { if (layer instanceof olLayerGroup) { - const sublayers = layer.getLayers().getArray(); + const sublayers = + /** @type {import("ol/layer/Layer.js").default[]} */( + layer.getLayers().getArray() + ); const hasGroupLayer = sublayers.some(sublayer => sublayer instanceof olLayerGroup); if (!hasGroupLayer) { - return /** @type {Array} */(sublayers.slice()); + return sublayers.slice(); } } return this.getFlatLayers_(layer, [], undefined); @@ -312,9 +315,9 @@ LayerHelper.prototype.getFlatLayers = function(layer) { * Computed opacity is a custom 'back-up' value that contains * the calculated value of all ancestors and the given layer. * @param {import("ol/layer/Base.js").default} layer The base layer, mostly a group of layers. - * @param {olLayerLayer[]} array An array to add layers. + * @param {olLayerLayer[]} array An array to add layers. * @param {number|undefined} computedOpacity Opacity inherited from ancestor layer groups. - * @return {olLayerLayer[]} Layers. + * @return {olLayerLayer[]} Layers. * @private */ LayerHelper.prototype.getFlatLayers_ = function(layer, array, computedOpacity) { diff --git a/src/misc/FeatureHelper.js b/src/misc/FeatureHelper.js index 3e63ac8d666d..3108cef5b0cf 100644 --- a/src/misc/FeatureHelper.js +++ b/src/misc/FeatureHelper.js @@ -165,7 +165,7 @@ FeatureHelper.prototype.setProjection = function(projection) { /** * Set the style of a feature using its inner properties and depending on * its geometry type. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @param {boolean=} opt_select Whether the feature should be rendered as * selected, which includes additional vertex and halo styles. */ @@ -184,7 +184,7 @@ FeatureHelper.prototype.setStyle = function(feature, opt_select) { /** * Create and return a style object from a given feature using its inner * properties and depending on its geometry type. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {Array} The style object. */ FeatureHelper.prototype.getStyle = function(feature) { @@ -227,7 +227,7 @@ FeatureHelper.prototype.getStyle = function(feature) { /** - * @param {import("ol/Feature.js").default} feature Feature with linestring geometry. + * @param {olFeature} feature Feature with linestring geometry. * @return {Array} Style. * @private */ @@ -267,7 +267,7 @@ FeatureHelper.prototype.getLineStringStyle_ = function(feature) { /** - * @param {import("ol/Feature.js").default} feature Feature with point geometry. + * @param {olFeature} feature Feature with point geometry. * @return {Array} Style. * @private */ @@ -315,7 +315,7 @@ FeatureHelper.prototype.getPointStyle_ = function(feature) { /** * Get an optional number feature attribute. * - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @param {string} attrib The attribute name. * @return {number|undefined}, The attribute value */ @@ -336,7 +336,7 @@ FeatureHelper.prototype.optNumber = function(feature, attrib) { /** * Get a number feature attribute. * - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @param {string} attrib The attribute name. * @return {number}, The attribute value */ @@ -351,7 +351,7 @@ FeatureHelper.prototype.getNumber = function(feature, attrib) { /** - * @param {import("ol/Feature.js").default} feature Feature with polygon geometry. + * @param {olFeature} feature Feature with polygon geometry. * @return {Array} Style. * @private */ @@ -457,7 +457,7 @@ FeatureHelper.prototype.getPolygonStyle_ = function(feature) { /** - * @param {import("ol/Feature.js").default} feature Feature with point geometry, rendered as text. + * @param {olFeature} feature Feature with point geometry, rendered as text. * @return {import("ol/style/Style.js").default} Style. * @private */ @@ -478,7 +478,7 @@ FeatureHelper.prototype.getTextStyle_ = function(feature) { /** - * @param {import("ol/Feature.js").default} feature Feature to create the editing styles with. + * @param {olFeature} feature Feature to create the editing styles with. * @return {Array} List of style. */ FeatureHelper.prototype.createEditingStyles = function(feature) { @@ -566,7 +566,7 @@ FeatureHelper.prototype.createEditingStyles = function(feature) { * If removing a vertex would make the geometry invalid, then the * vertex info is not returned. * - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @param {import("ol/coordinate.js").Coordinate} coordinate Coordinate. * @param {number} resolution Current map view resolution. * @return {?number[]} The indexes of the vertex (coordinate) that hits. @@ -760,7 +760,7 @@ FeatureHelper.prototype.getVertexStyle = function(opt_incGeomFunc) { /** * Remove a vertex from a feature using the given information (indexes). * - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @param {number[]} vertexInfo The indexes of the vertex * (coordinate) to remove. */ @@ -842,7 +842,7 @@ FeatureHelper.prototype.removeVertex = function(feature, vertexInfo) { /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {boolean} Whether the feature supports vertex or not. * @private */ @@ -860,7 +860,7 @@ FeatureHelper.prototype.supportsVertex_ = function(feature) { /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {boolean} Whether the feature supports having its vertex * removed or not. Does not validate the number of coordinates. * @private @@ -878,7 +878,7 @@ FeatureHelper.prototype.supportsVertexRemoval_ = function(feature) { /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {import("ol/style/Style.js").default} Style. * @private */ @@ -939,7 +939,7 @@ FeatureHelper.prototype.getHaloStyle_ = function(feature) { /** * Delete the unwanted ol3 properties from the current feature then return the properties. * Also delete the 'ngeo_feature_type_' from the ngeo query system. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {Object} Filtered properties of the current feature. * @hidden */ @@ -952,7 +952,7 @@ export function getFilteredFeatureValues(feature) { } /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {number} Angle. */ FeatureHelper.prototype.getAngleProperty = function(feature) { @@ -963,7 +963,7 @@ FeatureHelper.prototype.getAngleProperty = function(feature) { /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {string} Color. */ FeatureHelper.prototype.getColorProperty = function(feature) { @@ -974,7 +974,7 @@ FeatureHelper.prototype.getColorProperty = function(feature) { /** - * @param {import('ol/Feature.js').default} feature Feature. + * @param {olFeature} feature Feature. * @return {import('ol/color.js').Color} Color. */ FeatureHelper.prototype.getRGBAColorProperty = function(feature) { @@ -984,7 +984,7 @@ FeatureHelper.prototype.getRGBAColorProperty = function(feature) { /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {string} Name. */ FeatureHelper.prototype.getNameProperty = function(feature) { @@ -995,7 +995,7 @@ FeatureHelper.prototype.getNameProperty = function(feature) { /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {number} Opacity. */ FeatureHelper.prototype.getOpacityProperty = function(feature) { @@ -1004,7 +1004,7 @@ FeatureHelper.prototype.getOpacityProperty = function(feature) { /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {boolean} Show measure. */ FeatureHelper.prototype.getShowMeasureProperty = function(feature) { @@ -1018,7 +1018,7 @@ FeatureHelper.prototype.getShowMeasureProperty = function(feature) { }; /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {boolean} Show feature label. */ FeatureHelper.prototype.getShowLabelProperty = function(feature) { @@ -1032,7 +1032,7 @@ FeatureHelper.prototype.getShowLabelProperty = function(feature) { }; /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {number} Size. */ FeatureHelper.prototype.getSizeProperty = function(feature) { @@ -1041,7 +1041,7 @@ FeatureHelper.prototype.getSizeProperty = function(feature) { /** - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {number} Stroke. */ FeatureHelper.prototype.getStrokeProperty = function(feature) { @@ -1055,7 +1055,7 @@ FeatureHelper.prototype.getStrokeProperty = function(feature) { /** * Export features in the given format. The projection of the exported features * is: `EPSG:4326`. - * @param {Array} features Array of vector features. + * @param {Array>} features Array of vector features. * @param {string} formatType Format type to export the features. */ FeatureHelper.prototype.export = function(features, formatType) { @@ -1075,28 +1075,33 @@ FeatureHelper.prototype.export = function(features, formatType) { /** * Export features in GPX and download the result to the browser. The * projection of the exported features is: `EPSG:4326`. - * @param {Array} features Array of vector features. + * @param {Array>} features Array of vector features. */ FeatureHelper.prototype.exportGPX = function(features) { const format = new olFormatGPX(); const mimeType = 'application/gpx+xml'; const fileName = 'export.gpx'; // Typecast due OL issue ... - this.export_(features, /** @type {import("ol/format/Feature.js").default} */(format), fileName, mimeType); + this.export_( + features, /** @type {import('ol/format/Feature.js').default} */(format), + fileName, mimeType + ); }; /** * Export features in KML and download the result to the browser. The * projection of the exported features is: `EPSG:4326`. - * @param {Array} features Array of vector features. + * @param {Array>} features Array of vector features. */ FeatureHelper.prototype.exportKML = function(features) { const format = new olFormatKML(); const mimeType = 'application/vnd.google-earth.kml+xml'; const fileName = 'export.kml'; // Typecast due OL issue ... - this.export_(features, /** @type {import("ol/format/Feature.js").default} */(format), fileName, mimeType); + this.export_( + features, /** @type {import('ol/format/Feature.js').default} */(format), + fileName, mimeType); }; @@ -1104,8 +1109,8 @@ FeatureHelper.prototype.exportKML = function(features) { * Export features using a given format to a specific filename and download * the result to the browser. The projection of the exported features is: * `EPSG:4326`. - * @param {Array} features Array of vector features. - * @param {import("ol/format/Feature.js").default} format Format + * @param {Array>} features Array of vector features. + * @param {import('ol/format/Feature.js').default} format Format * @param {string} fileName Name of the file. * @param {string=} opt_mimeType Mime type. Defaults to 'text/plain'. * @private @@ -1115,7 +1120,7 @@ FeatureHelper.prototype.export_ = function(features, format, fileName, opt_mimeT // clone the features to apply the original style to the clone // (the original may have select style active) - /** @type {olFeature[]} */ + /** @type {olFeature[]} */ const clones = []; let clone; features.forEach((feature) => { @@ -1174,7 +1179,7 @@ FeatureHelper.prototype.createTextStyle_ = function(options) { * Get the measure of the given feature as a string. For points, you can format * the result by setting a filter to apply on the coordinate with the function * {@link import("ngeo/misc/FeatureHelper.js").setPointFilterFn}. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {string} Measure. */ FeatureHelper.prototype.getMeasure = function(feature) { @@ -1227,7 +1232,7 @@ FeatureHelper.prototype.getMeasure = function(feature) { /** * Return the type of geometry of a feature using its geometry property and * some inner properties. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {string} The type of geometry. */ FeatureHelper.prototype.getType = function(feature) { @@ -1279,7 +1284,7 @@ FeatureHelper.prototype.getType = function(feature) { * If the feature is not visible and would not fit in the map view, * the map is fix to the feature's extent. * - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @param {import("ol/Map.js").default} map Map. * @param {number=} opt_duration Aimation duration. Defaults to `250`. */ @@ -1378,7 +1383,7 @@ FeatureHelper.prototype.fitMapToFeature = function(feature, map, opt_duration) { /** * This method generates a line string geometry that represents the radius for * a given azimut. It expects the input geometry to be a circle. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @param {number} azimut Azimut in degrees. * @return {import("ol/geom/LineString.js").default} The line geometry. */ @@ -1402,7 +1407,7 @@ FeatureHelper.prototype.getRadiusLine = function(feature, azimut) { /** * Return the properties of a feature, with the exception of the geometry. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. * @return {Object} Object. */ FeatureHelper.prototype.getNonSpatialProperties = function(feature) { @@ -1421,7 +1426,7 @@ FeatureHelper.prototype.getNonSpatialProperties = function(feature) { /** * Clear all properties of a feature, with the exception of the geometry. - * @param {import("ol/Feature.js").default} feature Feature. + * @param {olFeature} feature Feature. */ FeatureHelper.prototype.clearNonSpatialProperties = function(feature) { const geometryName = feature.getGeometryName(); @@ -1435,7 +1440,7 @@ FeatureHelper.prototype.clearNonSpatialProperties = function(feature) { /** - * @param {Array} features Features. + * @param {Array>} features Features. * @param {string} fid Feature id * @return {number} Index of found feature */ diff --git a/src/offline/Configuration.js b/src/offline/Configuration.js index 7d969336ab3e..d5d4bb3961ae 100644 --- a/src/offline/Configuration.js +++ b/src/offline/Configuration.js @@ -222,14 +222,13 @@ const exports = class extends olObservable { /** * @param {import("ol/Map.js").default} map A map - * @param {import("ol/layer/Layer.js").default} layer A layer + * @param {import("ol/layer/Layer.js").default} layer A layer * @param {Array} ancestors The ancestors of that layer * @param {import("ol/extent.js").Extent} userExtent The extent selected by the user. * @return {Array} The extent to download per zoom level */ getExtentByZoom(map, layer, ancestors, userExtent) { const currentZoom = /** @type {!number} */ (map.getView().getZoom()); - // const viewportExtent = map.calculateExtent(map.getSize()); /** * @type {import("./index.js").OfflineExtentByZoom[]} @@ -354,7 +353,7 @@ const exports = class extends olObservable { /** * @param {import("./index.js").OfflinePersistentLayer} offlineLayer The layer to recreate - * @return {?import("ol/layer/Layer.js").default} the layer. + * @return {?import("ol/layer/Layer.js").default} the layer. */ recreateOfflineLayer(offlineLayer) { if (offlineLayer.layerType === 'tile') { diff --git a/src/offline/component.js b/src/offline/component.js index afdfd38724d3..249831edec67 100644 --- a/src/offline/component.js +++ b/src/offline/component.js @@ -1,10 +1,10 @@ import ngeoMapFeatureOverlayMgr from 'ngeo/map/FeatureOverlayMgr.js'; import ngeoMessageModalComponent from 'ngeo/message/modalComponent.js'; import {extentToRectangle} from 'ngeo/utils.js'; -import OlCollection from 'ol/Collection.js'; +import olCollection from 'ol/Collection.js'; import {unByKey} from 'ol/Observable.js'; -import OlFeature from 'ol/Feature.js'; -import OlGeomPolygon from 'ol/geom/Polygon.js'; +import Feature from 'ol/Feature.js'; +import Polygon from 'ol/geom/Polygon.js'; import olGeomGeometryLayout from 'ol/geom/GeometryLayout.js'; import {DEVICE_PIXEL_RATIO} from 'ol/has.js'; import angular from 'angular'; @@ -160,10 +160,10 @@ export const Controller = class { this.featuresOverlay_ = ngeoFeatureOverlayMgr.getFeatureOverlay(); /** - * @type {!OlCollection} + * @type {!olCollection>} * @private */ - this.overlayCollection_ = new OlCollection(); + this.overlayCollection_ = new olCollection(); this.featuresOverlay_.setFeatures(this.overlayCollection_); @@ -180,7 +180,7 @@ export const Controller = class { /** - * @type {?OlGeomPolygon} + * @type {?Polygon} * @private */ this.dataPolygon_ = null; @@ -457,7 +457,7 @@ export const Controller = class { */ displayExtent_() { if (!this.isExtentVisible() && this.dataPolygon_) { - const feature = new OlFeature(this.dataPolygon_); + const feature = new Feature(this.dataPolygon_); this.overlayCollection_.push(feature); } } @@ -543,13 +543,13 @@ export const Controller = class { /** * A polygon on the whole extent of the projection, with a hole for the offline extent. * @param {import("ol/extent.js").Extent} extent An extent - * @return {OlGeomPolygon} Polygon to save, based on the projection extent, the center of the map and + * @return {Polygon} Polygon to save, based on the projection extent, the center of the map and * the extentSize property. * @private */ createPolygonFromExtent_(extent) { const projExtent = this.map.getView().getProjection().getExtent(); - return new OlGeomPolygon([ + return new Polygon([ extentToRectangle(projExtent), extentToRectangle(extent), ], olGeomGeometryLayout.XY); diff --git a/src/print/Service.js b/src/print/Service.js index b4d2cc608531..c6c1f0f6a3bd 100644 --- a/src/print/Service.js +++ b/src/print/Service.js @@ -273,7 +273,7 @@ PrintService.prototype.encodeImageWmsLayer_ = function(arr, layer) { /** * @param {Array} arr Array. - * @param {import("ol/layer/Image.js").default} layer The layer. + * @param {import("ol/layer/Image.js").default|import("ol/layer/Tile.js").default} layer The layer. * @param {string} url Url of the WMS server. * @param {Object} params Url parameters * @private diff --git a/src/print/VectorEncoder.js b/src/print/VectorEncoder.js index f7d27d1f8830..8da3dd868f90 100644 --- a/src/print/VectorEncoder.js +++ b/src/print/VectorEncoder.js @@ -1,7 +1,6 @@ import {rgbArrayToHex} from 'ngeo/utils.js'; import {getUid as olUtilGetUid} from 'ol/util.js'; import olFormatGeoJSON from 'ol/format/GeoJSON.js'; -import olSourceVector from 'ol/source/Vector.js'; import olStyleRegularShape from 'ol/style/RegularShape.js'; import {toDegrees} from 'ol/math.js'; import olStyleIcon from 'ol/style/Icon.js'; @@ -54,8 +53,9 @@ const PRINT_STYLE_TYPES = { * @param {number} resolution Resolution. */ VectorEncoder.prototype.encodeVectorLayer = function(arr, layer, resolution) { - const source = /** @type {olSourceVector} */(layer.getSource()); - console.assert(source instanceof olSourceVector); + const source = /** @type {import("ol/source/Vector.js").default} */( + layer.getSource() + ); const features = source.getFeatures(); diff --git a/src/print/mapfish-print-v3.js b/src/print/mapfish-print-v3.js index d11a2080b2a4..66fd3bdb4e41 100644 --- a/src/print/mapfish-print-v3.js +++ b/src/print/mapfish-print-v3.js @@ -239,6 +239,19 @@ */ +/** + * @typedef {Object} MapFishPrintLegend + * @property {MapFishPrintLegendClass[]} classes + */ + + +/** + * @typedef {Object} MapFishPrintLegendClass + * @property {string} name + * @property {string[]} icons + */ + + /** * @hidden * @type {null} diff --git a/src/query/MapQuerent.js b/src/query/MapQuerent.js index 08b9a8a2fee2..8e9b61888d07 100644 --- a/src/query/MapQuerent.js +++ b/src/query/MapQuerent.js @@ -237,7 +237,7 @@ export class MapQuerent { const tooManyResults = querentResultItem.tooManyFeatures === true; const totalFeatureCount = querentResultItem.totalFeatureCount; - /** @type {Object>} */ + /** @type {Object>>} */ const typeSeparatedFeatures = {}; features.forEach((feature) => { /** @type {string} */ diff --git a/src/query/Querent.js b/src/query/Querent.js index 7349a7e58a94..96d2937b15d9 100644 --- a/src/query/Querent.js +++ b/src/query/Querent.js @@ -25,7 +25,7 @@ import olSourceImageWMS from 'ol/source/ImageWMS.js'; /** * @typedef {Object} QuerentResultItem - * @property {Array} features + * @property {Array>} features * @property {number} limit * @property {boolean} [tooManyFeatures] * @property {number} [totalFeatureCount] @@ -414,7 +414,7 @@ export class Querent { const dataSourceId = dataSource.id; if (typeof response === 'number') { - /** @type {Array} */ + /** @type {Array>} */ const features = []; const tooManyFeatures = true; const totalFeatureCount = response; @@ -446,11 +446,11 @@ export class Querent { * @param {ngeoDatasourceOGC} dataSource used to read the features. * @param {Document|Element|string} data the response data. * @param {boolean} wfs Whether the query was WFS or WMS. - * @return {Array} returned features with a type in each features. + * @return {Array>} returned features with a type in each features. * @private */ readAndTypeFeatures_(dataSource, data, wfs) { - /** @type {Array} */ + /** @type {Array>} */ const features = []; let readFeatures; // Copy the types to be able to set it AND iterate on it. @@ -993,7 +993,7 @@ export class Querent { /** * Make sure that feature ids are unique, because the same features might * be returned for different layers. - * @param {Array} features Features + * @param {Array>} features Features * @param {number} dataSourceId Data source id. * @private */ diff --git a/src/routing/RoutingComponent.js b/src/routing/RoutingComponent.js index b9449d2f6d2f..4011ab5dc193 100644 --- a/src/routing/RoutingComponent.js +++ b/src/routing/RoutingComponent.js @@ -18,7 +18,7 @@ import 'ngeo/sass/font.scss'; /** * @typedef {Object} RoutingVia - * @property {import("ol/Feature.js").default} [feature] + * @property {olFeature} [feature] * @property {function(import('ngeo/routing/NominatimService').NominatimSearchResult)} [onSelect] */ @@ -156,12 +156,12 @@ class Controller { this.errorMessage = ''; /** - * @type {?import("ol/Feature.js").default} + * @type {?olFeature} */ this.startFeature_ = null; /** - * @type {?import("ol/Feature.js").default} + * @type {?olFeature} */ this.targetFeature_ = null; @@ -183,7 +183,7 @@ class Controller { }; /** - * @type {import("ol/source/Vector.js").default} + * @type {import("ol/source/Vector.js").default} * @private */ this.routeSource_ = new olSourceVector({ @@ -265,7 +265,7 @@ class Controller { /** * Converts feature point into LonLat coordinate. - * @param {import("ol/Feature.js").default} point Feature point to convert + * @param {olFeature} point Feature point to convert * @return {?import("ol/coordinate.js").Coordinate} LonLat coordinate * @private */ @@ -296,14 +296,14 @@ class Controller { /** * @param {import('./RoutingService').Route} route Routes of OSRM response - * @return {Array} parsed route features + * @return {Array>} parsed route features * @private */ parseRoute_(route) { if (!this.map) { return []; } - /** @type {olFeature[]} */ + /** @type {olFeature[]} */ let parsedRoutes = []; const format = new olFormatGeoJSON(); const formatConfig = { @@ -312,7 +312,7 @@ class Controller { }; // if there are is useful "legs" data, parse this if (route.legs) { - /** @type {olFeature[][]} */ + /** @type {olFeature[][]} */ const parsedRoutes_ = route.legs.map(leg => leg.steps.map(step => new olFeature({ geometry: format.readGeometry(step.geometry, formatConfig) }))); diff --git a/src/routing/RoutingFeatureComponent.js b/src/routing/RoutingFeatureComponent.js index a98c46708bab..577eae6f5f7e 100644 --- a/src/routing/RoutingFeatureComponent.js +++ b/src/routing/RoutingFeatureComponent.js @@ -116,7 +116,7 @@ class Controller { this.map = null; /** - * @type {?import("ol/Feature.js").default} + * @type {?olFeature} */ this.feature = null; @@ -136,18 +136,18 @@ class Controller { this.strokeColor = ''; /** - * @type {?function(import("ol/Feature.js").default): void} + * @type {?function(olFeature): void} */ this.onChange = null; /** - * @type {import("ol/Collection.js").default} + * @type {import("ol/Collection.js").default>} * @private */ this.vectorFeatures_ = new olCollection(); /** - * @type {import("ol/source/Vector.js").default} + * @type {import("ol/source/Vector.js").default} * @private */ this.vectorSource_ = new olSourceVector({ @@ -338,7 +338,7 @@ class Controller { /** * Snaps a feature to the street network using the getNearest * function of the routing service. Replaces the feature. - * @param {import("ol/Feature.js").default} feature Feature to snap + * @param {olFeature} feature Feature to snap * @private */ snapFeature_(feature) { @@ -373,7 +373,7 @@ class Controller { /** * Converts feature point into LonLat coordinate. - * @param {import("ol/Feature.js").default} point Feature point to convert + * @param {olFeature} point Feature point to convert * @return {?import("ol/coordinate.js").Coordinate} LonLat coordinate * @private */ @@ -410,10 +410,10 @@ class Controller { * See the [../examples/routing.html](../examples/routing.html) example for a usage sample. * * @htmlAttribute {import("ol/Map.js").default} ngeo-routing-feature-map The map. - * @htmlAttribute {import("ol/Feature.js").default} ngeo-routing-feature-feature The feature. + * @htmlAttribute {olFeature} ngeo-routing-feature-feature The feature. * @htmlAttribute {string} ngeo-routing-feature-fill-color The marker fill color. * @htmlAttribute {string} ngeo-routing-feature-stroke-color The marker stroke color. - * @htmlAttribute {function(import("ol/Feature.js").default)} ngeo-routing-feature-on-change Event fired when + * @htmlAttribute {function(olFeature)} ngeo-routing-feature-on-change Event fired when * feature changes. * @ngdoc directive * @ngname ngeoRoutingFeature diff --git a/src/rule/Geometry.js b/src/rule/Geometry.js index 6fcde1287c19..719dae0a950c 100644 --- a/src/rule/Geometry.js +++ b/src/rule/Geometry.js @@ -44,7 +44,7 @@ export default class extends ngeoRuleRule { const properties = options.featureProperties || {}; /** - * @type {import("ol/Feature.js").default} + * @type {olFeature} * @private */ this.feature_ = new olFeature(properties); @@ -89,7 +89,7 @@ export default class extends ngeoRuleRule { // === Static property getters/setters === /** - * @return {import("ol/Feature.js").default} Feature. + * @return {olFeature} Feature. */ get feature() { return this.feature_; diff --git a/src/search/createGeoJSONBloodhound.js b/src/search/createGeoJSONBloodhound.js index 8632ce489958..f3cca7a4c756 100644 --- a/src/search/createGeoJSONBloodhound.js +++ b/src/search/createGeoJSONBloodhound.js @@ -14,13 +14,13 @@ import 'corejs-typeahead'; * undefined, the default Bloodhound config will be used. * @param {Bloodhound.RemoteOptions=} opt_remoteOptions optional Bloodhound * remote options. Effective only if `remote` is not defined in `opt_options`. - * @return {Bloodhound} The Bloodhound object. + * @return {Bloodhound[]>} The Bloodhound object. * @hidden */ export function createGeoJSONBloodhound(url, opt_filter, opt_featureProjection, opt_dataProjection, opt_options, opt_remoteOptions) { const geojsonFormat = new olFormatGeoJSON(); - /** @type {Bloodhound.BloodhoundOptions>} */ + /** @type {Bloodhound.BloodhoundOptions>>} */ const bloodhoundOptions = { remote: { url, @@ -78,7 +78,9 @@ export function createGeoJSONBloodhound(url, opt_filter, opt_featureProjection, Object.assign(bloodhoundOptions, options); Object.assign(bloodhoundOptions.remote, remoteOptions); - return /** @type {Bloodhound} */(new Bloodhound(bloodhoundOptions)); + return /** @type {Bloodhound[]>} */( + new Bloodhound(bloodhoundOptions) + ); } @@ -122,7 +124,7 @@ module.value('ngeoSearchCreateGeoJSONBloodhound', createGeoJSONBloodhound); * ); * bloodhound.initialize(); * - * @typedef {function(string, (function(import("geojson").Feature): boolean)=, import("ol/proj/Projection.js").default=, import("ol/proj/Projection.js").default=, Bloodhound.Options=, Bloodhound.RemoteOptions=):Bloodhound>} + * @typedef {function(string, (function(import("geojson").Feature): boolean)=, import("ol/proj/Projection.js").default=, import("ol/proj/Projection.js").default=, Bloodhound.Options=, Bloodhound.RemoteOptions=):Bloodhound>>} */ diff --git a/src/search/createLocationSearchBloodhound.js b/src/search/createLocationSearchBloodhound.js index 951ee91576d1..8a475b69fe1d 100644 --- a/src/search/createLocationSearchBloodhound.js +++ b/src/search/createLocationSearchBloodhound.js @@ -55,7 +55,7 @@ import 'corejs-typeahead'; /** * @param {LocationSearchOptions=} opt_options Options. - * @return {Bloodhound} The Bloodhound object. + * @return {Bloodhound[]>} The Bloodhound object. * @private * @hidden */ @@ -103,7 +103,7 @@ function createLocationSearchBloodhound(opt_options) { } }; - /** @type {Bloodhound.BloodhoundOptions} */ + /** @type {Bloodhound.BloodhoundOptions[]|Results>} */ const bloodhoundOptions = { remote: { url: 'https://api3.geo.admin.ch/rest/services/api/SearchServer?type=locations&searchText=%QUERY', @@ -182,7 +182,9 @@ function createLocationSearchBloodhound(opt_options) { Object.assign(bloodhoundOptions, bhOptions); Object.assign(bloodhoundOptions.remote, remoteOptions); - return /** @type {Bloodhound} */(new Bloodhound(bloodhoundOptions)); + return /** @type {Bloodhound[]>} */( + new Bloodhound(bloodhoundOptions) + ); } @@ -210,7 +212,7 @@ module.value('ngeoCreateLocationSearchBloodhound', createLocationSearchBloodhoun * }); * bloodhound.initialize(); * - * @typedef {function(LocationSearchOptions=):Bloodhound} + * @typedef {function(LocationSearchOptions=):Bloodhound[]>} * @ngdoc service * @ngname search.createLocationSearchBloodhound * @private diff --git a/src/statemanager/WfsPermalink.js b/src/statemanager/WfsPermalink.js index 1fffb56dd5a3..a26be5f2f4e5 100644 --- a/src/statemanager/WfsPermalink.js +++ b/src/statemanager/WfsPermalink.js @@ -11,7 +11,7 @@ import olFormatWFS from 'ol/format/WFS.js'; /** * Results for a query source. * @typedef {Object} QueryResultSource - * @property {Array} features The matching features for this source. + * @property {Array>} features The matching features for this source. * @property {number|string} id Identifier (can be not unique). * @property {string} label Label. * @property {number} [limit] The maximum number of features that can be returned for a query with this @@ -270,12 +270,12 @@ WfsPermalinkService.prototype.issueRequest_ = function(wfsType, filter, map, sho /** - * @param {Feature[]} features Features. + * @param {Feature[]} features Features. * @return {import('ol/extent.js').Extent} The extent of all features. * @private */ WfsPermalinkService.prototype.getExtent_ = function(features) { - return /** @type{import('ol/extent.js').Extent} */(/** @type{any[]} */(features).reduce( + return /** @type {import('ol/extent.js').Extent} */(/** @type {any[]} */(features).reduce( (extent, feature) => { if (feature instanceof Feature) { const geometry = feature.getGeometry(); diff --git a/test/spec/services/print.spec.js b/test/spec/services/print.spec.js index 20856b5a42af..95b49cc0144c 100644 --- a/test/spec/services/print.spec.js +++ b/test/spec/services/print.spec.js @@ -65,7 +65,7 @@ describe('ngeo.print.Service', () => { beforeEach(() => { const view = map.getView(); - view.rotate(Math.PI); + view.adjustRotation(Math.PI); }); it('rotation angle is correct', () => { diff --git a/tsconfig.json b/tsconfig.json index 0cc8a748f1e1..485cf13d1dcf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "pretty": false, /* Basic Options */ "target": "ES6", "module": "system", @@ -7,29 +8,17 @@ "allowJs": true, "checkJs": true, "noEmit": true, - // Start strict - //"strict": true, - "noImplicitAny": true, - "noImplicitThis": true, - "alwaysStrict": true, - "strictBindCallApply": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - //"strictPropertyInitialization": true, - // End strict + "strict": true, "baseUrl": "./", "paths": { "ngeo/*": ["src/*"], "gmf/*": ["contribs/gmf/src/*"], - // "ol/*": ["node_modules/ol/*"], - // Temporary, run that to use it: - // npm install --prefix openlayers_src https://api.github.com/repos/openlayers/openlayers/tarball/v5.3.1 - "localforage/*": ["node_modules/localforage/*"], - "ol/*": ["openlayers_src/node_modules/ol/src/ol/*"], + "ol/*": ["node_modules/ol/src/*"], "olcs/*": ["node_modules/ol-cesium/src/olcs/*"], "@geoblocks/proj/*": ["node_modules/@geoblocks/proj/*"], "moment": ["node_modules/moment/moment.d.ts"], "jsts/*": ["node_modules/@types/jsts/index.d.ts"], + "localforage/*": ["node_modules/localforage/*"], } }, "include": [ @@ -40,5 +29,8 @@ "contribs/gmf/test/spec/**/*.js", "examples/*.js", "contribs/gmf/examples/*.js", + ], + "files": [ + "types/dom.d.ts" ] } diff --git a/types/dom.d.ts b/types/dom.d.ts new file mode 100644 index 000000000000..8ae4e45c602e --- /dev/null +++ b/types/dom.d.ts @@ -0,0 +1,33 @@ +/** + * Type declarations extending TypeScript's lib/lib.dom.d.ts. + * https://github.com/Microsoft/TypeScript/blob/master/lib/lib.dom.d.ts + */ + +interface Document { + readonly mozFullScreen: boolean; + readonly webkitIsFullScreen: boolean; + + readonly fullscreenElement: Element; + readonly mozFullScreenElement: Element; + readonly msFullscreenElement: Element; + readonly webkitFullscreenElement: Element; + + readonly mozFullScreenEnabled: boolean; + readonly msFullscreenEnabled: boolean; + readonly webkitFullscreenEnabled: boolean; + + mozCancelFullScreen(): void; + msExitFullscreen(): void; + webkitExitFullscreen(): void; +} + +interface Element { + mozRequestFullScreen(): Promise; + mozRequestFullScreenWithKeys(): Promise; + msRequestFullscreen(): Promise; + webkitRequestFullscreen(allowKeyboardInput?: number): Promise; +} + +interface CSSStyleDeclaration { + msTransform: string | null; +}