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

More typecheck fixes for gmf #4585

Merged
merged 1 commit into from
Feb 4, 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
7 changes: 5 additions & 2 deletions contribs/gmf/src/layertree/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,10 @@ Controller.prototype.afterReorder = function() {
currentTreeCtrls.some((treeCtrl) => {
if (treeCtrl.node === node) {
treeCtrls.push(treeCtrl);
return;
// TODO - validate this, used to be a plain `return`, which is
// not truthy and doesn't break the `some`, but I suspect this
// is not the wanted behaviour...
return false;
}
});
});
Expand Down Expand Up @@ -698,7 +701,7 @@ Controller.prototype.zoomToResolution = function(treeCtrl) {
const gmfLayer = /** @type {import('gmf/themes.js').GmfLayerWMS} */ (treeCtrl.node);
const view = this.map.getView();
const resolution = view.getResolution();
const minResolution = gmfThemeThemes.getNodeMinResolution(gmfLayer);
const minResolution = getNodeMinResolution(gmfLayer);
if (minResolution !== undefined && resolution < minResolution) {
view.setResolution(view.constrainResolution(minResolution, 0, 1));
} else {
Expand Down
12 changes: 6 additions & 6 deletions contribs/gmf/src/layertree/timeSliderComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function directive() {
controller: 'gmfTimeSliderController as sliderCtrl',
restrict: 'AE',
templateUrl: 'gmf/layertree/timesliderComponent',
link: /** @type {!angular.LinkingFunctions} */ ({
link: {
pre: function preLink(scope, element, attrs, ctrl) {
ctrl.init();

Expand Down Expand Up @@ -85,7 +85,7 @@ function directive() {
return wmstime;
}
}
})
}
};
}

Expand All @@ -112,7 +112,7 @@ function Controller(ngeoWMSTime) {

/**
* Function called after date(s) changed/selected
* @function
* @type {Function}
* @export
*/
this.onDateSelected;
Expand Down Expand Up @@ -148,7 +148,7 @@ function Controller(ngeoWMSTime) {

/**
* Used when WMS time object has a property 'values' instead of an interval
* @type (?Array<number>)
* @type {?Array.<number>}
*/
this.timeValueList;

Expand Down Expand Up @@ -279,7 +279,7 @@ Controller.prototype.getClosestValue_ = function(timestamp) {
const startDate = new Date(this.minValue);
let bestDate = new Date(this.minValue);
const maxDate = new Date(this.maxValue);
let bestDistance = Math.abs(targetDate - bestDate);
let bestDistance = Math.abs(targetDate.getTime() - bestDate.getTime());

for (let i = 1; ; i++) {
// The start date should always be used as a reference
Expand All @@ -295,7 +295,7 @@ Controller.prototype.getClosestValue_ = function(timestamp) {
break;
}

const distance = Math.abs(targetDate - next);
const distance = Math.abs(targetDate.getTime() - next.getTime());
if (distance <= bestDistance) {
bestDate = next;
bestDistance = distance;
Expand Down
12 changes: 7 additions & 5 deletions contribs/gmf/src/lidarprofile/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import angular from 'angular';


/**
* @typedef {Object.<number, !LidarprofileServerConfigClassification}
* @typedef {Object.<number, !LidarprofileServerConfigClassification>}
* LidarprofileServerConfigClassifications
*/

Expand All @@ -11,11 +11,11 @@ import angular from 'angular';
* @property {string} [color] Color
* @property {string} [name] Name
* @property {string} [value] Value
* @property {boolean} [visible] Visible
* @property {number} [visible] Visible (Value can be 1 or 0)
*/

/**
* @typedef {Object.<number, !LidarprofileServerConfigLevel}
* @typedef {Object.<number, !LidarprofileServerConfigLevel>}
* LidarprofileServerConfigLevels
*/

Expand All @@ -26,7 +26,7 @@ import angular from 'angular';
*/

/**
* @typedef {Object.<number, !LidarprofileServerConfigPointAttribute}
* @typedef {Object.<number, !LidarprofileServerConfigPointAttribute>}
* LidarprofileServerConfigPointAttributes
*/

Expand Down Expand Up @@ -54,6 +54,8 @@ import angular from 'angular';
* attribute
* @property {string} [default_point_cloud] Default point cloud
* @property {number} [initialLOD] Initial LOD
* @property {LidarprofileServerConfigLevels} [max_levels] Max levels
* @property {number} [max_point_number] Max point number
* @property {number} [minLOD] Min LOD
* @property {LidarprofileServerConfigPointAttributes}
* [point_attributes] Point attributes
Expand Down Expand Up @@ -94,7 +96,7 @@ export class LidarprofileConfigService {

/**
* The client configuration.
* @type {LidarprofileClientConfig}
* @type {import("gmf/lidarprofile/Utils.js").LidarprofileClientConfig}
*/
this.clientConfig = {
autoWidth: true,
Expand Down
10 changes: 5 additions & 5 deletions contribs/gmf/src/lidarprofile/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class LidarprofileManager {
* @param {angular.IHttpService} $http Angular http service.
* @param {angular.IFilterService} $filter Angular filter.
* @param {angular.gettext.gettextCatalog} gettextCatalog Gettext catalog.
* @param {import("ngeo/misc/Debounce.js").miscDebounce} ngeoDebounce ngeo debounce service.
* @param {import("ngeo/misc/debounce.js").miscDebounce<function(): void>} ngeoDebounce ngeo debounce service.
* @ngInject
* @ngdoc service
* @ngname gmflidarprofileManager
Expand All @@ -44,7 +44,7 @@ export class LidarprofileManager {
this.gettextCatalog = gettextCatalog;

/**
* @type {import("ngeo/misc/Debounce.js").miscDebounce}
* @type {import("ngeo/misc/debounce.js").miscDebounce<function(): void>}
* @private
*/
this.ngeoDebounce_ = ngeoDebounce;
Expand Down Expand Up @@ -113,7 +113,7 @@ export class LidarprofileManager {

/**
* The variable where all points of the profile are stored
* @type {LidarprofilePoints}
* @type {import("gmf/lidarprofile/Utils.js").LidarprofilePoints}
*/
this.profilePoints = this.getEmptyProfilePoints_();

Expand All @@ -136,7 +136,7 @@ export class LidarprofileManager {
}

/**
* @param {import("gmf/lidarprofile.js").LidarprofileConfigService} config Config
* @param {import("gmf/lidarprofile/Config.js").LidarprofileConfigService} config Config
* @param {import("ol/Map.js").default} map The map.
*/
init(config, map) {
Expand Down Expand Up @@ -179,7 +179,7 @@ export class LidarprofileManager {
}

/**
* @return {LidarprofilePoints} An empty lidarprofile points object.
* @return {import("gmf/lidarprofile/Utils.js").LidarprofilePoints} An empty lidarprofile points object.
* @private
*/
getEmptyProfilePoints_() {
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/lidarprofile/Measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export default class {
this.manager_ = gmfLidarprofileManagerInstance;

/**
* @type {!LidarPoint}
* @type {!import("gmf/lidarprofile/Utils").LidarPoint}
* @private
*/
this.pStart_ = {};

/**
* @type {!LidarPoint}
* @type {!import("gmf/lidarprofile/Utils").LidarPoint}
* @private
*/
this.pEnd_ = {};
Expand Down
10 changes: 5 additions & 5 deletions contribs/gmf/src/lidarprofile/Plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class {

/**
* Draw the points to the canvas element
* @param {LidarprofilePoints} points of the profile
* @param {import("gmf/lidarprofile/Utils.js").LidarprofilePoints} points of the profile
* @export
*/
drawPoints(points) {
Expand Down Expand Up @@ -341,7 +341,7 @@ export default class {

this.manager_.cartoHighlight.setElement(el);
this.manager_.cartoHighlight.setPosition([p.coords[0], p.coords[1]]);
/** @type {olSourceVector} */(this.manager_.lidarPointHighlight.getSource()).clear();
/** @type {import("ol/source/Vector.js").default} */(this.manager_.lidarPointHighlight.getSource()).clear();
const lidarPointGeom = new olGeomPoint([p.coords[0], p.coords[1]]);
const lidarPointFeature = new olFeature(lidarPointGeom);
if (typeof (pointClassification.color) !== undefined) {
Expand All @@ -356,9 +356,9 @@ export default class {
}));
}

/** @type {olSourceVector} */(this.manager_.lidarPointHighlight.getSource()).addFeature(lidarPointFeature);
/** @type {import("ol/source/Vector.js").default} */(this.manager_.lidarPointHighlight.getSource()).addFeature(lidarPointFeature);
} else {
/** @type {olSourceVector} */(this.manager_.lidarPointHighlight.getSource()).clear();
/** @type {import("ol/source/Vector.js").default} */(this.manager_.lidarPointHighlight.getSource()).clear();
svg.select('#highlightCircle').remove();
lidarInfo.html('');
this.manager_.cartoHighlight.setPosition(undefined);
Expand All @@ -367,7 +367,7 @@ export default class {


/**
* @param {LidarPoint} point the concerned point.
* @param {import("gmf/lidarprofile/Utils.js").LidarPoint} point the concerned point.
* @param {import("gmf/lidarprofile/Config.js").LidarprofileServerConfigClassification} classification_color the classification
* object concerning this point.
* @param {number} distDecimal the number of decimal to keep.
Expand Down
11 changes: 9 additions & 2 deletions contribs/gmf/src/lidarprofile/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import {select as d3select} from 'd3';
/**
* Profile point after measure or after parsing of the binary array returned by Pytree
* @typedef {Object} LidarPoint
* @property {number} [cx]
* @property {number} [cy]
* @property {number} [distance]
* @property {number} [altitude]
* @property {Array.<number>} [color_packed]
Expand All @@ -60,7 +62,12 @@ export default class {
* @param {import("ol/geom/LineString.js").default} linestring an OpenLayer Linestring
* @param {number} dLeft domain minimum
* @param {number} dRight domain maximum
* @return {{clippedLine: Array.<import("ol/coordinate.js").Coordinate>, distanceOffset: number}} Object with clipped lined coordinates and left domain value
* @return {{
* bufferGeom: olFeature,
* bufferStyle: Array.<olStyleStyle>,
* clippedLine: Array.<import("ol/coordinate.js").Coordinate>,
* distanceOffset: number
* }} Object with clipped lined coordinates and left domain value
*/
clipLineByMeasure(config, map_resolution, linestring, dLeft, dRight) {

Expand Down Expand Up @@ -287,7 +294,7 @@ export default class {

/**
* Get the data for a CSV export of the profile.
* @param {LidarPoint} points a lidar profile points object.
* @param {Array.<LidarPoint>} points A list of lidar profile point objects.
* @return {Array.<Object>} Objects for a csv export (column: value).
* @export
*/
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/lidarprofile/panelComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class Controller {
*/
csvExport() {
if (this.line) {
const points = this.profile.utils.getFlatPointsByDistance(this.profile.profilePoints) || {};
const points = this.profile.utils.getFlatPointsByDistance(this.profile.profilePoints) || [];
const csvData = this.profile.utils.getCSVData(points);
const headerColumnNames = Object.keys(points[0]);
const headerColumns = headerColumnNames.map((columnName) => {
Expand Down