Skip to content

Commit

Permalink
Fix the new checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jun 27, 2019
1 parent fd606a4 commit 35cbc9a
Show file tree
Hide file tree
Showing 46 changed files with 192 additions and 169 deletions.
4 changes: 2 additions & 2 deletions contribs/gmf/apps/desktop_alt/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Controller extends AbstractDesktopController {
const fill = new Fill({color: [255, 255, 255, 0.6]});
const stroke = new Stroke({color: [255, 0, 0, 1], width: 2});
const image = new Circle({fill, radius, stroke});
const default_search_style = new Style({
const defaultSearchStyle = new Style({
fill,
image,
stroke
Expand All @@ -128,7 +128,7 @@ class Controller extends AbstractDesktopController {
* @export
*/
this.searchStyles = {
'default': default_search_style
'default': defaultSearchStyle
};

// Allow angular-gettext-tools to collect the strings to translate
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/examples/objecteditinghub.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ MainController.appendParams = function(uri, params) {
// remove any trailing ? or &
uri = uri.replace(/[?&]$/, '');
// append ? or & depending on whether uri has existing parameters
uri = uri.indexOf('?') === -1 ? `${uri}?` : `${uri}&`;
uri = uri.includes('?') ? `${uri}&` : `${uri}?`;
return uri + qs;
};

Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/examples/xsdattributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function MainController($timeout, gmfThemes, gmfXSDAttributes) {
flatNodes.forEach((node) => {
const groupNode = /** @type {import('gmf/themes.js').GmfGroup} */(node);
// Get an array of all layers
if (groupNode.children === undefined && layerNames.indexOf(node.name) !== -1) {
if (groupNode.children === undefined && layerNames.includes(node.name)) {
this.layers.push(/** @type {import('gmf/themes.js').GmfLayer} */(node));
}
});
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/authentication/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class AuthenticationService extends olEventsEventTarget {
* @return {angular.IPromise<void>} Promise.
*/
logout() {
const noReload = this.noReloadRole_ ? this.getRolesNames().indexOf(this.noReloadRole_) !== -1 : false;
const noReload = this.noReloadRole_ ? this.getRolesNames().includes(this.noReloadRole_) : false;
const url = `${this.baseUrl_}/${RouteSuffix.LOGOUT}`;
return this.$http_.get(url, {withCredentials: true}).then(() => {
this.resetUser_(noReload);
Expand Down
1 change: 1 addition & 0 deletions contribs/gmf/src/controllers/AbstractMobileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export class AbstractMobileController extends AbstractAppController {
*/
openNavMenu(target) {
const navElements = document.getElementsByClassName('gmf-mobile-nav-button');
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < navElements.length; i++) {
const element = /** @type {HTMLElement} */(navElements[i]);
if (element.dataset && element.dataset.target === target) {
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/controllers/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import angular from 'angular';
function bootstrap(module) {
// Hack to make the bootstrap type check working with polyfill.io
const oldObjectToString = Object.prototype.toString;
if (oldObjectToString.toString().indexOf('[native code]') < 0) {
if (!oldObjectToString.toString().includes('[native code]')) {
Object.prototype.toString = function() {
if (this === null) {
return '[object Null]';
Expand Down
17 changes: 12 additions & 5 deletions contribs/gmf/src/datasource/Manager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import angular from 'angular';
import gmfDatasourceOGC from 'gmf/datasource/OGC.js';
import GmfDatasourceOGC from 'gmf/datasource/OGC.js';
import gmfDatasourceWFSAliases from 'gmf/datasource/WFSAliases.js';
import gmfLayertreeSyncLayertreeMap, {getLayer} from 'gmf/layertree/SyncLayertreeMap.js';
import gmfLayertreeTreeManager from 'gmf/layertree/TreeManager.js';
Expand All @@ -21,6 +21,7 @@ import {clear as clearObject} from 'ol/obj.js';
import olLayerImage from 'ol/layer/Image.js';
import olSourceImageWMS from 'ol/source/ImageWMS.js';
import olSourceTileWMS from 'ol/source/TileWMS.js';
import BaseLayer from 'ol/layer/Base.js';


/**
Expand Down Expand Up @@ -254,7 +255,13 @@ export class DatasourceManager {
handleDimensionsChange_() {

// Create a layer list to update each one only once
/**
* @type {BaseLayer[]}
*/
const layers = [];
/**
* @type {string[]}
*/
const layerIds = [];

const dataSources = this.dataSources_.getArray();
Expand All @@ -267,7 +274,7 @@ export class DatasourceManager {
return;
}
const id = olUtilGetUid(layer);
if (layerIds.indexOf(id) == -1) {
if (!layerIds.includes(id)) {
layers.push(layer);
layerIds.push(id);
}
Expand Down Expand Up @@ -667,7 +674,7 @@ export class DatasourceManager {
options.wmtsUrl = wmtsUrl;
}
// Create the data source and add it to the cache
this.dataSourcesCache_[id] = new gmfDatasourceOGC(options);
this.dataSourcesCache_[id] = new GmfDatasourceOGC(options);
}

/**
Expand Down Expand Up @@ -884,8 +891,8 @@ export class DatasourceManager {
}
const gmfLayerWMS = /** @type {import('gmf/themes.js').GmfLayerWMS} */(dataSource.gmfLayer);
if (olUtilGetUid(dsLayer) == olUtilGetUid(layer) &&
layer.get('querySourceIds').indexOf(String(dataSource.id)) >= 0 &&
gmfLayerWMS.layers.split(',').indexOf(wmsLayerName) >= 0) {
layer.get('querySourceIds').includes(String(dataSource.id)) &&
gmfLayerWMS.layers.split(',').includes(wmsLayerName)) {

const id = olUtilGetUid(dataSource.gmfLayer);
const item = this.treeCtrlCache_[id];
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/datasource/OGC.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import ngeoDatasourceOGC from 'ngeo/datasource/OGC.js';
* @private
* @hidden
*/
class gmfDatasourceOGC extends ngeoDatasourceOGC {
class GmfDatasourceOGC extends ngeoDatasourceOGC {

/**
* A `gmf.datasource.OGC` extends a `ngeo.datasource.OGC` and
Expand Down Expand Up @@ -113,4 +113,4 @@ class gmfDatasourceOGC extends ngeoDatasourceOGC {

}

export default gmfDatasourceOGC;
export default GmfDatasourceOGC;
2 changes: 1 addition & 1 deletion contribs/gmf/src/disclaimer/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ DisclaimerController.prototype.$onDestroy = function() {
DisclaimerController.prototype.showDisclaimerMessage_ = function(msg) {
msg = this.gettextCatalog_.getString(msg);
if (this.external) {
if (this.msgs_.indexOf(msg) < 0) {
if (!this.msgs_.includes(msg)) {
this.msgs_.push(msg);
}
this.msg = `${this.sce_.trustAsHtml(this.msgs_.join('<br />'))}`;
Expand Down
7 changes: 6 additions & 1 deletion contribs/gmf/src/editing/editFeatureComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,13 @@ Controller.prototype.save = function() {
if (attribute.format) {
if (this.feature.get(attribute.name)) {
const name = this.feature.get(attribute.name);
console.assert(typeof name == 'string');
if (typeof name == 'string') {
throw new Error('Wrong name type');
}
const value = dateFormatter.parseDate(name, attribute.format);
if (value === null) {
throw new Error('Missing date');
}
let jsonFormat = 'Y-m-d\\TH:i:s';
if (attribute.type === 'date') {
jsonFormat = 'Y-m-d';
Expand Down
6 changes: 3 additions & 3 deletions contribs/gmf/src/filters/filterselectorComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import gmfDatasourceDataSourceBeingFiltered from 'gmf/datasource/DataSourceBeing

import gmfDatasourceHelper from 'gmf/datasource/Helper.js';

import gmfDatasourceOGC from 'gmf/datasource/OGC.js';
import GmfDatasourceOGC from 'gmf/datasource/OGC.js';
import gmfFiltersSavedFilters from 'gmf/filters/SavedFilters.js';

import ngeoMessageModalComponent from 'ngeo/message/modalComponent.js';
Expand Down Expand Up @@ -410,7 +410,7 @@ class FilterSelectorController {
handleDataSourcesAdd_(evt) {
if (evt instanceof CollectionEvent) {
const dataSource = evt.element;
if (dataSource instanceof gmfDatasourceOGC) {
if (dataSource instanceof GmfDatasourceOGC) {
this.registerDataSource_(dataSource);
}
}
Expand All @@ -429,7 +429,7 @@ class FilterSelectorController {
handleDataSourcesRemove_(evt) {
if (evt instanceof CollectionEvent) {
const dataSource = evt.element;
if (dataSource instanceof gmfDatasourceOGC) {
if (dataSource instanceof GmfDatasourceOGC) {
this.unregisterDataSource_(dataSource);
}
}
Expand Down
50 changes: 32 additions & 18 deletions contribs/gmf/src/lidarprofile/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ export class LidarprofileManager {
const domain = this.plot.updateScaleX.domain();
pytreeLinestring = '';

for (let i = 0; i < clippedLine.length; i++) {
pytreeLinestring += `{${clippedLine[i][0]},${clippedLine[i][1]}},`;
for (const clipped of clippedLine) {
pytreeLinestring += `{${clipped[0]},${clipped[1]}},`;
}
pytreeLinestring = pytreeLinestring.substr(0, pytreeLinestring.length - 1);
maxLODWith = this.utils.getNiceLOD(domain[1] - domain[0], max_levels);
Expand Down Expand Up @@ -364,8 +364,8 @@ export class LidarprofileManager {

const uInt8header = new Uint8Array(profile, 4, headerSize);
let strHeaderLocal = '';
for (let i = 0; i < uInt8header.length; i++) {
strHeaderLocal += String.fromCharCode(uInt8header[i]);
for (const header of uInt8header) {
strHeaderLocal += String.fromCharCode(header);
}

try {
Expand Down Expand Up @@ -403,11 +403,14 @@ export class LidarprofileManager {

const attr = jHeader.pointAttributes;
const attributes = [];
for (let j = 0; j < attr.length; j++) {
if (this.config.serverConfig.point_attributes[attr[j]] != undefined) {
attributes.push(this.config.serverConfig.point_attributes[attr[j]]);
for (const att of attr) {
if (this.config.serverConfig.point_attributes[att] != undefined) {
attributes.push(this.config.serverConfig.point_attributes[att]);
}
}
/**
* @type {number}
*/
const scale = jHeader.scale;

if (jHeader.points < 3) {
Expand All @@ -422,41 +425,52 @@ export class LidarprofileManager {
const byteOffset = bytesPerPoint * i;
const view = new DataView(buffer, byteOffset, bytesPerPoint);
let aoffset = 0;
for (let k = 0; k < attributes.length; k++) {

if (attributes[k].value == 'POSITION_PROJECTED_PROFILE') {
for (const attribute of attributes) {
if (attribute.value == 'POSITION_PROJECTED_PROFILE') {
const udist = view.getUint32(aoffset, true);
const dist = udist * scale;
points.distance.push(Math.round(100 * (distanceOffset + dist)) / 100);
this.profilePoints.distance.push(Math.round(100 * (distanceOffset + dist)) / 100);

} else if (attributes[k].value == 'CLASSIFICATION') {
} else if (attribute.value == 'CLASSIFICATION') {
const classif = view.getUint8(aoffset);
points.classification.push(classif);
this.profilePoints.classification.push(classif);

} else if (attributes[k].value == 'INTENSITY') {
} else if (attribute.value == 'INTENSITY') {
const intensity = view.getUint8(aoffset);
points.intensity.push(intensity);
this.profilePoints.intensity.push(intensity);

} else if (attributes[k].value == 'COLOR_PACKED') {
} else if (attribute.value == 'COLOR_PACKED') {
const r = view.getUint8(aoffset);
const g = view.getUint8(aoffset + 1);
const b = view.getUint8(aoffset + 2);
points.color_packed.push([r, g, b]);
this.profilePoints.color_packed.push([r, g, b]);

} else if (attributes[k].value == 'POSITION_CARTESIAN') {
const x = view.getInt32(aoffset, true) * scale + jHeader.boundingBox.lx;
const y = view.getInt32(aoffset + 4, true) * scale + jHeader.boundingBox.ly;
const z = view.getInt32(aoffset + 8, true) * scale + jHeader.boundingBox.lz;
} else if (attribute.value == 'POSITION_CARTESIAN') {
const lx = jHeader.boundingBox.lx;
if (typeof lx != 'number') {
throw new Error('Wrong lx type');
}
const ly = jHeader.boundingBox.ly;
if (typeof ly != 'number') {
throw new Error('Wrong ly type');
}
const lz = jHeader.boundingBox.lz;
if (typeof lz != 'number') {
throw new Error('Wrong lz type');
}
const x = view.getInt32(aoffset, true) * scale + lx;
const y = view.getInt32(aoffset + 4, true) * scale + ly;
const z = view.getInt32(aoffset + 8, true) * scale + lz;
points.coords.push([x, y]);
points.altitude.push(z);
this.profilePoints.altitude.push(z);
this.profilePoints.coords.push([x, y]);
}
aoffset = aoffset + attributes[k].bytes;
aoffset = aoffset + attribute.bytes;
}
}

Expand Down
20 changes: 10 additions & 10 deletions contribs/gmf/src/lidarprofile/Plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export default class {

/**
* d3.scaleLinear X scale.
* @type {Function}
* @type {function(number): number}
*/
this.updateScaleX = () => undefined;
this.updateScaleX = (x) => x;

/**
* d3.scaleLinear Y scale.
Expand All @@ -54,9 +54,9 @@ export default class {

/**
* d3.scaleLinear Y scale.
* @type {Function}
* @type {function(number): number}
*/
this.updateScaleY = () => undefined;
this.updateScaleY = (y) => y;

/**
* The material used for the drawing process. Initialized in the setup
Expand Down Expand Up @@ -309,11 +309,11 @@ export default class {
const yAxis = d3axisLeft(this.scaleY)
.tickSize(-this.width_);

const new_scaleX = tr.rescaleX(this.scaleX);
const new_scaleY = tr.rescaleY(this.scaleY);
const newScaleX = tr.rescaleX(this.scaleX);
const newScaleY = tr.rescaleY(this.scaleY);

svg.select('.x.axis').call(/** @type {any} */ (xAxis.scale(new_scaleX)));
svg.select('.y.axis').call(/** @type {any} */ (yAxis.scale(new_scaleY)));
svg.select('.x.axis').call(/** @type {any} */ (xAxis.scale(newScaleX)));
svg.select('.y.axis').call(/** @type {any} */ (yAxis.scale(newScaleY)));

const canvas = d3select('#gmf-lidarprofile-container .lidar-canvas');
const canvasEl = /** @type {HTMLCanvasElement} */(canvas.node());
Expand All @@ -327,8 +327,8 @@ export default class {
.style('opacity', '0.5')
.style('stroke', '#b7cff7');

this.updateScaleX = new_scaleX;
this.updateScaleY = new_scaleY;
this.updateScaleX = newScaleX;
this.updateScaleY = newScaleY;

}

Expand Down
12 changes: 6 additions & 6 deletions contribs/gmf/src/lidarprofile/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ export default class {
*/
arrayMin(array) {
let minVal = Infinity;
for (let i = 0; i < array.length; i++) {
if (array[i] < minVal) {
minVal = array[i];
for (const element of array) {
if (element < minVal) {
minVal = element;
}
}
return minVal;
Expand All @@ -367,9 +367,9 @@ export default class {
getPytreeLinestring(line) {
const coords = line.getCoordinates();
let pytreeLineString = '';
for (let i = 0; i < coords.length; i++) {
const px = coords[i][0];
const py = coords[i][1];
for (const coord of coords) {
const px = coord[0];
const py = coord[1];
pytreeLineString += `{${Math.round(100 * px) / 100}, ${Math.round(100 * py) / 100}},`;
}
return pytreeLineString.substr(0, pytreeLineString.length - 1);
Expand Down
Loading

0 comments on commit 35cbc9a

Please sign in to comment.