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

Fix typecheck (mostly for gmf lidar profile) #4573

Merged
merged 1 commit into from
Feb 1, 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
185 changes: 0 additions & 185 deletions contribs/gmf/externs/lidarprofile.js

This file was deleted.

68 changes: 65 additions & 3 deletions contribs/gmf/src/lidarprofile/Config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,69 @@
import angular from 'angular';


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

/**
* @typedef {Object} LidarprofileServerConfigClassification
* @property {string} [color] Color
* @property {string} [name] Name
* @property {string} [value] Value
* @property {boolean} [visible] Visible
*/

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

/**
* @typedef {Object} LidarprofileServerConfigLevel
* @property {number} [max] Max
* @property {number} [width] Width
*/

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

/**
* @typedef {Object} LidarprofileServerConfigPointAttribute
* @property {number} [bytes] Bytes
* @property {number} [elements] Elements
* @property {string} [name] Name
* @property {string} [value] Value
* @property {number} [visible] Visible
*/

/**
* @typedef {Object} LidarprofileServerConfig
* @property {Object.<number, string>} [classes_names_normalized]
* Classes names normalized
* @property {Object.<number, string>} [classes_names_standard]
* Classes names standard
* @property {LidarprofileServerConfigClassifications}
* [classification_colors] Classification colors
* @property {boolean} [debug] Debug
* @property {string} [default_attribute] Default attribute
* @property {string} [default_color] Default color
* @property {string} [default_point_attribute] Default point
* attribute
* @property {string} [default_point_cloud] Default point cloud
* @property {number} [initialLOD] Initial LOD
* @property {number} [minLOD] Min LOD
* @property {LidarprofileServerConfigPointAttributes}
* [point_attributes] Point attributes
* @property {number} [point_size] Point size
* @property {number} [vertical_pan_tolerance] Vertical pan tolerance
* @property {number} [width] Width
*/


export class LidarprofileConfigService {
/**
* Configuration service to configure the gmf.lidarPanelComponent and gmf.lidarprofile instance
* Requires a Pytree service: https://github.com/sitn/pytree
Expand Down Expand Up @@ -49,7 +111,7 @@ class LidarprofileConfigService {

/**
* The configuration from the LIDAR server.
* @type {lidarprofileServer.Config}
* @type {import("gmf/lidarprofile/Config.js").LidarprofileServerConfig}
*/
this.serverConfig = null;
}
Expand All @@ -63,7 +125,7 @@ class LidarprofileConfigService {
initProfileConfig() {
return this.$http_.get(`${this.pytreeLidarprofileJsonUrl}/profile/config`).then((resp) => {

this.serverConfig = /** @type {lidarprofileServer.Config} */ ({
this.serverConfig = /** @type {import("gmf/lidarprofile/Config.js").LidarprofileServerConfig} */ ({
classification_colors: resp.data['classification_colors'] || null,
debug: !!resp.data['debug'],
default_attribute: resp.data['default_attribute'] || '',
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/lidarprofile/Plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export default class {

/**
* @param {LidarPoint} point the concerned point.
* @param {lidarprofileServer.ConfigClassification} classification_color the classification
* @param {import("gmf/lidarprofile/Config.js").LidarprofileServerConfigClassification} classification_color the classification
* object concerning this point.
* @param {number} distDecimal the number of decimal to keep.
* @return {string} the text for the html info.
Expand Down Expand Up @@ -421,7 +421,7 @@ export default class {

/**
* Show/Hide classes in the profile
* @param {lidarprofileServer.ConfigClassifications} classification value as defined in the Pytree classification_colors
* @param {import("gmf/lidarprofile/Config.js").LidarprofileServerConfigClassifications} classification value as defined in the Pytree classification_colors
* configuration
* @param {string} material value as defined in Pytree attribute configuration
* @export
Expand Down
10 changes: 5 additions & 5 deletions contribs/gmf/src/lidarprofile/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {select as d3select} from 'd3';
/**
* The lidar point attribute list width default option
* @typedef {Object} LidarPointAttributeList
* @property {Array.<lidarprofileServer.ConfigPointAttributes>} [availableOptions]
* @property {lidarprofileServer.ConfigPointAttributes} [selectedOption]
* @property {Array.<import("gmf/lidarprofile/Config.js").LidarprofileServerConfigPointAttributes>} [availableOptions]
* @property {import("gmf/lidarprofile/Config.js").LidarprofileServerConfigPointAttributes} [selectedOption]
*/


Expand Down Expand Up @@ -193,7 +193,7 @@ export default class {
* Get a Level Of Details and with for a given chart span
* Configuration is set up in Pytree configuration
* @param {number} span domain extent
* @param {lidarprofileServer.ConfigLevels} max_levels levels defined by a LIDAR server
* @param {import("gmf/lidarprofile/Config.js").LidarprofileServerConfigLevels} max_levels levels defined by a LIDAR server
* @return {{maxLOD: number, width: number}} Object with optimized Level Of Details and width for this profile span
*/
getNiceLOD(span, max_levels) {
Expand Down Expand Up @@ -360,7 +360,7 @@ export default class {
* @param {number} tolerance snap sensibility
* @param {Function} sx d3.scalelinear x scale
* @param {Function} sy d3.scalelinear y scale
* @param {lidarprofileServer.ConfigClassifications} classification_colors classification colors
* @param {import("gmf/lidarprofile/Config.js").LidarprofileServerConfigClassifications} classification_colors classification colors
* @return {LidarPoint} closestPoint the closest point to the clicked coordinates
*/
getClosestPoint(points, xs, ys, tolerance, sx, sy, classification_colors) {
Expand Down Expand Up @@ -393,7 +393,7 @@ export default class {
let closestPoint;

if (hP.length > 0) {
const minDist = Math.min(distances);
const minDist = Math.min.apply(Math, distances);
const indexMin = distances.indexOf(minDist);
if (indexMin != -1) {
closestPoint = hP[indexMin];
Expand Down
16 changes: 8 additions & 8 deletions contribs/gmf/src/lidarprofile/panelComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class Controller {

/**
* Get all available point attributes.
* @return {Array.<lidarprofileServer.ConfigPointAttributes>|undefined} available point attributes.
* @return {Array.<import("gmf/lidarprofile/Config.js").LidarprofileServerConfigPointAttributes>|undefined} available point attributes.
* @export
*/
getAvailablePointAttributes() {
Expand All @@ -290,8 +290,8 @@ class Controller {

/**
* Get / Set the selected point attribute
* @param {lidarprofileServer.ConfigPointAttributes=} opt_selectedOption the new selected point attribute.
* @return {lidarprofileServer.ConfigPointAttributes|undefined} Selected point attribute
* @param {import("gmf/lidarprofile/Config.js").LidarprofileServerConfigPointAttribute=} opt_selectedOption the new selected point attribute.
* @return {import("gmf/lidarprofile/Config.js").LidarprofileServerConfigPointAttributes|undefined} Selected point attribute
* @export
*/
getSetSelectedPointAttribute(opt_selectedOption) {
Expand All @@ -306,7 +306,7 @@ class Controller {
/**
* Get the available classifications for this dataset
* @export
* @return {lidarprofileServer.ConfigClassifications} classification list
* @return {import("gmf/lidarprofile/Config.js").LidarprofileServerConfigClassifications} classification list
*/
getClassification() {
return this.profileConfig_.serverConfig.classification_colors;
Expand All @@ -316,7 +316,7 @@ class Controller {
/**
* Sets the visible classification in the profile
* @export
* @param {lidarprofileServer.ConfigClassification} classification selected value
* @param {import("gmf/lidarprofile/Config.js").LidarprofileServerConfigClassification} classification selected value
* @param {number} key of the classification code
*/
setClassification(classification, key) {
Expand All @@ -336,9 +336,9 @@ class Controller {
if (this.line) {
const points = this.profile.utils.getFlatPointsByDistance(this.profile.profilePoints) || {};
const csvData = this.profile.utils.getCSVData(points);
let headerColumns = Object.keys(points[0]);
headerColumns = headerColumns.map((column) => {
return {'name': column};
const headerColumnNames = Object.keys(points[0]);
const headerColumns = headerColumnNames.map((columnName) => {
return {'name': columnName};
});
this.ngeoCsvDownload_.startDownload(csvData, headerColumns, 'LIDAR_profile.csv');
}
Expand Down