From 1649bed7de409bb7e4fd2a621d143e273e7ad1f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Fri, 26 Oct 2018 15:10:03 +0200 Subject: [PATCH] Fix profile issues on null values --- contribs/gmf/src/profile/component.html | 7 ++- contribs/gmf/src/profile/component.js | 47 +++++++++----------- contribs/gmf/src/raster/widgetComponent.html | 2 +- src/profile/d3Elevation.js | 24 ++++------ 4 files changed, 35 insertions(+), 45 deletions(-) diff --git a/contribs/gmf/src/profile/component.html b/contribs/gmf/src/profile/component.html index ab68887cc90..768045fbd83 100644 --- a/contribs/gmf/src/profile/component.html +++ b/contribs/gmf/src/profile/component.html @@ -17,8 +17,11 @@
  • -  {{name | translate}} {{ctrl.currentPoint.elevations[name]}} {{ctrl.currentPoint.yUnits}} + ng-style="ctrl.getStyle(name)"> + {{name | translate}} + + {{ctrl.currentPoint.elevations[name]}} {{ctrl.currentPoint.yUnits}} +
  • diff --git a/contribs/gmf/src/profile/component.js b/contribs/gmf/src/profile/component.js index 381a25ac570..c354f4995b6 100644 --- a/contribs/gmf/src/profile/component.js +++ b/contribs/gmf/src/profile/component.js @@ -41,8 +41,7 @@ exports.value('gmfProfileTemplateUrl', */ ($element, $attrs) => { const templateUrl = $attrs['gmfProfileTemplateurl']; - return templateUrl !== undefined ? templateUrl : - 'gmf/profile'; + return templateUrl !== undefined ? templateUrl : 'gmf/profile'; }); exports.run(/* @ngInject */ ($templateCache) => { @@ -507,30 +506,25 @@ exports.Controller_.prototype.outCallback_ = function() { /** - * @return {string} A texte formatted to a tooltip. + * @return {string} A text formatted to a tooltip. * @private */ exports.Controller_.prototype.getTooltipHTML_ = function() { - const separator = ' : '; + const gettextCatalog = this.gettextCatalog_; + const separator = ' : '; let elevationName, translatedElevationName; const innerHTML = []; const number = this.$filter_('number'); const DistDecimal = this.currentPoint.xUnits === 'm' ? 0 : 2; - innerHTML.push( - `${this.profileLabels_.xAxis + - separator + - number(this.currentPoint.distance, DistDecimal) - } ${ - this.currentPoint.xUnits}` - ); + const value = number(this.currentPoint.distance, DistDecimal); + innerHTML.push(`${this.profileLabels_.xAxis} ${separator} ${value} ${this.currentPoint.xUnits}`); for (elevationName in this.currentPoint.elevations) { - translatedElevationName = this.gettextCatalog_.getString(elevationName); - innerHTML.push( - `${translatedElevationName + - separator + - number(this.currentPoint.elevations[elevationName], 0) - } ${this.currentPoint.yUnits}` - ); + translatedElevationName = gettextCatalog.getString(elevationName); + const int_value = this.currentPoint.elevations[elevationName]; + const value = int_value === null ? + gettextCatalog.getString('no value') : + `${number(int_value, 0)} ${this.currentPoint.yUnits}`; + innerHTML.push(`${translatedElevationName} ${separator} ${value}`); } return innerHTML.join('
    '); }; @@ -559,8 +553,7 @@ exports.Controller_.prototype.createMeasureTooltip_ = function() { */ exports.Controller_.prototype.removeMeasureTooltip_ = function() { if (this.measureTooltipElement_ !== null) { - this.measureTooltipElement_.parentNode.removeChild( - this.measureTooltipElement_); + this.measureTooltipElement_.parentNode.removeChild(this.measureTooltipElement_); this.measureTooltipElement_ = null; this.map_.removeOverlay(this.measureTooltip_); } @@ -568,17 +561,19 @@ exports.Controller_.prototype.removeMeasureTooltip_ = function() { /** - * Return the color value of a gmfx.ProfileLineConfiguration. + * Return the styler value of a gmfx.ProfileLineConfiguration. * @param {string} layerName name of the elevation layer. - * @return {string|undefined} A HEX color or undefined is nothing is found. + * @return {object} The object representation of the style. * @export */ -exports.Controller_.prototype.getColor = function(layerName) { +exports.Controller_.prototype.getStyle = function(layerName) { const lineConfiguration = this.linesConfiguration_[layerName]; if (!lineConfiguration) { - return undefined; + return {}; } - return lineConfiguration.color; + return { + 'color': lineConfiguration.color || '#F00' + }; }; @@ -605,7 +600,7 @@ exports.Controller_.prototype.getZFactory_ = function(layerName) { * @private */ const getZFn = function(item) { - if ('values' in item && layerName in item['values']) { + if ('values' in item && layerName in item['values'] && item['values'][layerName]) { return parseFloat(item['values'][layerName]); } return null; diff --git a/contribs/gmf/src/raster/widgetComponent.html b/contribs/gmf/src/raster/widgetComponent.html index 43a080891cb..58b2eb7c078 100644 --- a/contribs/gmf/src/raster/widgetComponent.html +++ b/contribs/gmf/src/raster/widgetComponent.html @@ -13,7 +13,7 @@ {{ctrl.elevationValue}} - Elevation… + Elevation…