Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Even more typecheck fixes for gmf #4588

Merged
merged 4 commits into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions contribs/gmf/src/datasource/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import gmfEditingEnumerateAttribute from 'gmf/editing/EnumerateAttribute.js';
import ngeoDatasourceHelper from 'ngeo/datasource/Helper.js';
import ngeoFormatAttributeType from 'ngeo/format/AttributeType.js';

class Helper {
export class DatasourceHelper {

/**
* A service that provides utility methods to manipulate or get GMF data
Expand All @@ -12,7 +12,7 @@ class Helper {
* @param {angular.IQService} $q The Angular $q service.
* @param {import("gmf/editing/EnumerateAttribute.js").EditingEnumerateAttributeService} gmfEnumerateAttribute The Gmf enumerate
* attribute service.
* @param {import("ngeo/datasource/Helper.js").Helper} ngeoDataSourcesHelper Ngeo data
* @param {import("ngeo/datasource/Helper.js").DatasourceHelper} ngeoDataSourcesHelper Ngeo data
* source helper service.
* @ngdoc service
* @ngname gmfDataSourcesHelper
Expand All @@ -35,7 +35,7 @@ class Helper {
this.gmfEnumerateAttribute_ = gmfEnumerateAttribute;

/**
* @type {import("ngeo/datasource/Helper.js").Helper}
* @type {import("ngeo/datasource/Helper.js").DatasourceHelper}
* @private
*/
this.ngeoDataSourcesHelper_ = ngeoDataSourcesHelper;
Expand Down Expand Up @@ -135,7 +135,7 @@ const module = angular.module('gmfDataSourcesHelper', [
ngeoDatasourceHelper.name,
gmfEditingEnumerateAttribute.name,
]);
module.service('gmfDataSourcesHelper', Helper);
module.service('gmfDataSourcesHelper', DatasourceHelper);


export default module;
4 changes: 3 additions & 1 deletion contribs/gmf/src/datasource/OGC.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ngeoDatasourceOGC from 'ngeo/datasource/OGC.js';
*/


export default class extends ngeoDatasourceOGC {
class gmfDatasourceOGC extends ngeoDatasourceOGC {

/**
* A `gmf.datasource.OGC` extends a `ngeo.datasource.OGC` and
Expand Down Expand Up @@ -42,3 +42,5 @@ export default class extends ngeoDatasourceOGC {
}

}

export default gmfDatasourceOGC;
adube marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions contribs/gmf/src/datasource/WFSAliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class DatasourceWFSAlias {
* Service that provides methods to get additional information and actions
* when performing WFS requests.
*
* @param {import("ngeo/datasource/Helper.js").Helper} ngeoDataSourcesHelper Ngeo data
* @param {import("ngeo/datasource/Helper.js").DatasourceHelper} ngeoDataSourcesHelper Ngeo data
* source helper service.
* @ngdoc service
* @ngname gmfWFSAliases
Expand All @@ -19,7 +19,7 @@ export class DatasourceWFSAlias {
// === Injected properties ===

/**
* @type {import("ngeo/datasource/Helper.js").Helper}
* @type {import("ngeo/datasource/Helper.js").DatasourceHelper}
* @private
*/
this.ngeoDataSourcesHelper_ = ngeoDataSourcesHelper;
Expand Down
5 changes: 3 additions & 2 deletions contribs/gmf/src/editing/Snapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ EditingSnappingService.prototype.registerTreeCtrl_ = function(treeCtrl) {

// Skip any Layertree controller that has a node that is not a leaf
let node = /** @type {import('gmf/themes.js').GmfGroup|import('gmf/themes.js').GmfLayer} */ (treeCtrl.node);
if (node.children) {
const groupNode = /** @type import('gmf/themes.js').GmfGroup */ (node);
if (groupNode.children) {
return;
}

Expand Down Expand Up @@ -268,7 +269,7 @@ EditingSnappingService.prototype.unregisterAllTreeCtrl_ = function() {
* Get the OGC server.
*
* @param {import("ngeo/layertree/Controller.js").LayertreeController} treeCtrl The layer tree controller
* @return {?import('gmf/themes.js').GmfOgcServers} The OGC server.
* @return {?import('gmf/themes.js').GmfOgcServer} The OGC server.
* @private
*/
EditingSnappingService.prototype.getOGCServer_ = function(treeCtrl) {
Expand Down
24 changes: 15 additions & 9 deletions contribs/gmf/src/editing/editFeatureComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,21 +520,25 @@ function Controller($element, $q, $scope, $timeout,
*/
Controller.prototype.$onInit = function() {
const lang = this.gettextCatalog_.getCurrentLanguage();

// @ts-ignore: $.datetimepicker is available, as it is imported
$.datetimepicker.setLocale(lang);
// @ts-ignore: $.datetimepicker is available, as it is imported
$.datetimepicker.setDateFormatter(new DateFormatter());

// (1) Set default values and other properties
this.dirty = this.dirty === true;
this.editableNode_ = /** @type {import('gmf/themes.js').GmfLayer} */ (
this.editableTreeCtrl.node);
this.features = /** @type {olSourceVector} */(this.vectorLayer.getSource()).getFeaturesCollection();
const source = /** @type {import('ol/source/Vector.js').default} */(this.vectorLayer.getSource());
this.features = source.getFeaturesCollection();
this.tolerance = this.tolerance !== undefined ? this.tolerance : 10;

// (1.1) Set editable WMS layer
const layer = syncLayertreeMapGetLayer(this.editableTreeCtrl);
console.assert(
layer instanceof olLayerImage || layer instanceof olLayerTile);
this.editableWMSLayer_ = layer;
this.editableWMSLayer_ = /** @type {olLayerImage|olLayerTile} */ (layer);

// (1.2) Create, set and initialize interactions
this.modify_ = new olInteractionModify({
Expand Down Expand Up @@ -1030,14 +1034,15 @@ Controller.prototype.handleMapClick_ = function(evt) {
const feature = this.map.forEachFeatureAtPixel(
pixel,
(feature) => {
let ret = false;
let ret = null;
if (this.features.getArray().includes(feature)) {
ret = feature;
}
return ret;
},
{
hitTolerance: 5
hitTolerance: 5,
layerFilter: undefined
}
);

Expand Down Expand Up @@ -1081,19 +1086,20 @@ Controller.prototype.handleMapContextMenu_ = function(evt) {
const pixel = this.map.getEventPixel(evt);
const coordinate = this.map.getCoordinateFromPixel(pixel);

let feature = this.map.forEachFeatureAtPixel(
let feature = /** @type {olFeature|undefined} */ (this.map.forEachFeatureAtPixel(
pixel,
(feature) => {
let ret = false;
let ret = null;
if (this.features.getArray().includes(feature)) {
ret = feature;
}
return ret;
},
{
hitTolerance: 7
hitTolerance: 7,
layerFilter: undefined
}
);
));

feature = feature ? feature : null;

Expand Down Expand Up @@ -1291,7 +1297,7 @@ Controller.prototype.handleMenuVertexActionClick_ = function(evt) {


/**
* @param {import("ol/interaction/Translate/Event.js").default} evt Event.
* @param {import("ol/interaction/Translate.js").TranslateEvent} evt Event.
* @private
*/
Controller.prototype.handleTranslateEnd_ = function(evt) {
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/filters/SavedFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ SavedFilterItem.prototype.condition;

/**
* The list of custom rules of the saved filter item.
* @type {!Array.<!AnyOptions>}
* @type {!Array.<!import("ngeo/filter/RuleHelper.js").AnyOptions>}
* @export
*/
SavedFilterItem.prototype.customRules;
Expand All @@ -250,7 +250,7 @@ SavedFilterItem.prototype.dataSourceId;

/**
* The list of directed rules of the saved filter item.
* @type {!Array.<!AnyOptions>}
* @type {!Array.<!import("ngeo/filter/RuleHelper.js").AnyOptions>}
* @export
*/
SavedFilterItem.prototype.directedRules;
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/filters/filterselectorComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Controller {
* @param {import('gmf/datasource/DataSourceBeingFiltered.js').DataSourceBeingFiltered} gmfDataSourceBeingFiltered
* The Gmf value service that determines the data source currently being
* filtered.
* @param {import("gmf/datasource/Helper.js").Helper} gmfDataSourcesHelper Gmf data
* @param {import("gmf/datasource/Helper.js").DatasourceHelper} gmfDataSourcesHelper Gmf data
* sources helper service.
* @param {import("gmf/filters/SavedFilters.js").SavedFilter} gmfSavedFilters Gmf saved filters service.
* @param {import('gmf/authentication/Service.js').User} gmfUser User.
Expand Down Expand Up @@ -149,7 +149,7 @@ class Controller {
);

/**
* @type {import("gmf/datasource/Helper.js").Helper}
* @type {import("gmf/datasource/Helper.js").DatasourceHelper}
* @private
*/
this.gmfDataSourcesHelper_ = gmfDataSourcesHelper;
Expand Down
6 changes: 3 additions & 3 deletions contribs/gmf/src/import/importdatasourceComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@ class Controller {
return datumTokenizers;
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
identify: false,
local: serverUrls
});
}

// Register input[type=file] onchange event, use HTML5 File api
this.fileInput_.on('change', () => {
this.file = this.fileInput_[0].files && this.fileInput_[0].files[0] ?
this.fileInput_[0].files[0] : undefined;
const fileInput = /** @type HTMLInputElement */ (this.fileInput_[0]);
const files = fileInput.files;
this.file = files && files[0] ? files[0] : undefined;
this.scope_.$apply();
});
}
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/import/wmsCapabilityLayertreeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Controller {

/**
* @param {!Object} layer WMS Capability Layer object
* @return {number} Unique id for the Capability Layer.
* @return {string} Unique id for the Capability Layer.
* @export
*/
getUid(layer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Controller {

/**
* @param {!Object} layer WMTS Capability Layer object
* @return {number} Unique id for the Capability Layer.
* @return {string} Unique id for the Capability Layer.
* @export
*/
getUid(layer) {
Expand Down
8 changes: 5 additions & 3 deletions contribs/gmf/src/layertree/SyncLayertreeMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function SyncLayertreeMap($rootScope, ngeoLayerHelper, ngeoWMSTime, gmfTh
});

$rootScope.$on('ngeo-layertree-state', (map, treeCtrl, firstParent) => {
this.sync_(/** @type import("ol/Map.js").default */ (map), firstParent);
this.sync_(firstParent);
});
}

Expand Down Expand Up @@ -94,14 +94,14 @@ SyncLayertreeMap.prototype.createLayer = function(treeCtrl, map, dataLayerGroup,
/**
* Synchronise the state of each layers corresponding to the given tree and
* all its children.
* @param {import("ol/Map.js").default} map A map that contains the layers.
* @param {import("ngeo/layertree/Controller.js").LayertreeController} treeCtrl ngeo layertree controller.
* @private
*/
SyncLayertreeMap.prototype.sync_ = function(map, treeCtrl) {
SyncLayertreeMap.prototype.sync_ = function(treeCtrl) {
treeCtrl.traverseDepthFirst((treeCtrl) => {
if (treeCtrl.layer && !treeCtrl.node.mixed) {
this.updateLayerState_(/** @type import("ol/layer/Image.js").default|import("ol/layer/Tile.js").default */ (treeCtrl.layer), treeCtrl);
return LayertreeVisitorDecision.DESCEND;
}
});
};
Expand All @@ -127,6 +127,7 @@ SyncLayertreeMap.prototype.updateLayerState_ = function(layer, treeCtrl) {
names.push(treeCtrl.node.layers);
const style = (treeCtrl.node.style !== undefined) ? treeCtrl.node.style : '';
styles.push(style);
return LayertreeVisitorDecision.DESCEND;
}
});
if (names.length === 0) {
Expand Down Expand Up @@ -231,6 +232,7 @@ SyncLayertreeMap.prototype.createLayerFromGroup_ = function(treeCtrl,
ctrl.setState('on', false);
this.updateLayerState_(/** @type {import("ol/layer/Image.js").default} */ (layer), ctrl);
hasActiveChildren = true;
return LayertreeVisitorDecision.DESCEND;
}
});
layer.setVisible(hasActiveChildren);
Expand Down
30 changes: 18 additions & 12 deletions contribs/gmf/src/layertree/TreeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ LayertreeTreeManager.prototype.addFirstLevelGroups = function(firstLevelGroups,
* @private
*/
LayertreeTreeManager.prototype.updateTreeGroupsState_ = function(groups) {
const treeGroupsParam = {};
const treeGroupsParam = /** @type Object.<string, string> */ ({});
treeGroupsParam[PermalinkParam.TREE_GROUPS] = groups.map(node => node.name).join(',');
this.ngeoStateManager_.updateState(treeGroupsParam);
if (this.$injector_.has('gmfPermalink')) {
Expand Down Expand Up @@ -286,11 +286,13 @@ LayertreeTreeManager.prototype.addFirstLevelGroup_ = function(group) {
* @private
*/
LayertreeTreeManager.prototype.manageExclusiveGroupSingleChecked_ = function(node, found) {
const children = node.children;
const groupNode = /** @type import('gmf/themes.js').GmfGroup */ (node);
const children = groupNode.children;
if (children) {
for (const child of children) {
if (child.children) {
found = this.manageExclusiveGroupSingleChecked_(child, found);
const childGroup = /** @type import('gmf/themes.js').GmfGroup */ (child);
if (childGroup.children) {
found = this.manageExclusiveGroupSingleChecked_(childGroup, found);
} else {
if (child.metadata.isChecked) {
if (found) {
Expand Down Expand Up @@ -342,7 +344,7 @@ LayertreeTreeManager.prototype.addGroupByLayerName = function(layerName, opt_add
console.warn('Tree controller not found, unable to add the group');
return;
}
let treeCtrlToActive;
let treeCtrlToActive = /** @type import("ngeo/layertree/Controller.js").LayertreeController */ (null);
treeCtrl.traverseDepthFirst((treeCtrl) => {
if (treeCtrl.node.name === layerName) {
treeCtrlToActive = treeCtrl;
Expand Down Expand Up @@ -423,12 +425,15 @@ LayertreeTreeManager.prototype.cloneGroupNode_ = function(group, names) {
* @private
*/
LayertreeTreeManager.prototype.toggleNodeCheck_ = function(node, names) {
if (!node.children) {
const groupNode = /** @type import('gmf/themes.js').GmfGroup */ (node);
if (!groupNode.children) {
return;
}
node.children.forEach((childNode) => {
if (childNode.children) {
this.toggleNodeCheck_(childNode, names);
groupNode.children.forEach((childNode) => {
const childGroupNode = /** @type import('gmf/themes.js').GmfGroup */ (
childNode);
if (childGroupNode.children) {
this.toggleNodeCheck_(childGroupNode, names);
} else if (childNode.metadata) {
childNode.metadata.isChecked = names.includes(childNode.name);
}
Expand Down Expand Up @@ -557,7 +562,7 @@ LayertreeTreeManager.prototype.refreshFirstLevelGroups_ = function(themes) {
* @private
*/
LayertreeTreeManager.prototype.getFirstLevelGroupFullState_ = function(treeCtrl) {
const children = {};
const children = /** @type Object.<string, TreeManagerFullState>} */ ({});
// Get the state of the treeCtrl children recursively.
treeCtrl.children.map((child) => {
children[child.node.name] = this.getFirstLevelGroupFullState_(child);
Expand Down Expand Up @@ -610,8 +615,9 @@ LayertreeTreeManager.prototype.setNodeMetadataFromFullState_ = function(node, fu
}

// Set the metadata of the node children recursively.
if (node.children) {
node.children.map((child) => {
const groupNode = /** @type import('gmf/themes.js').GmfGroup */ (node);
if (groupNode.children) {
groupNode.children.map((child) => {
this.setNodeMetadataFromFullState_(child, fullState.children[child.name]);
});
}
Expand Down