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

Merge remote-tracking branch 'origin/2.3' #4345

Merged
merged 14 commits into from
Oct 30, 2018
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
4 changes: 2 additions & 2 deletions contribs/gmf/apps/desktop/contextualdata.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
<td translate>
Elevation (SRTM)
</td>
<td>
<td ng-if="srtm">
{{srtm | number}} [m]
</td>
</tr>
<tr>
<td translate>
Elevation (Aster)
</td>
<td>
<td ng-if="aster">
{{aster | number}} [m]
</td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/apps/oeedit/contextualdata.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
<td translate>
Elevation (SRTM)
</td>
<td>
<td ng-if="srtm">
{{srtm | number}} [m]
</td>
</tr>
<tr>
<td translate>
Elevation (Aster)
</td>
<td>
<td ng-if="aster">
{{aster | number}} [m]
</td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/apps/oeview/contextualdata.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
<td translate>
Elevation (SRTM)
</td>
<td>
<td ng-if="srtm">
{{srtm | number}} [m]
</td>
</tr>
<tr>
<td translate>
Elevation (Aster)
</td>
<td>
<td ng-if="aster">
{{aster | number}} [m]
</td>
</tr>
Expand Down
11 changes: 9 additions & 2 deletions contribs/gmf/src/layertree/SyncLayertreeMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,20 @@ exports.prototype.updateLayerState_ = function(layer, treeCtrl) {
// First level non mixed group
googAsserts.assertInstanceof(layer, olLayerImage);
const names = [];
const styles = [];
treeCtrl.traverseDepthFirst((treeCtrl) => {
if (treeCtrl.node.children === undefined && treeCtrl.getState() === 'on') {
names.push(treeCtrl.node.layers);
const style = (treeCtrl.node.style !== undefined) ? treeCtrl.node.style : '';
styles.push(style);
}
});
if (names.length === 0) {
layer.setVisible(false);
}
/** @type {ol.source.ImageWMS} */ (layer.getSource()).updateParams({
'LAYERS': names.reverse().join(',')
'LAYERS': names.reverse().join(','),
'STYLES': styles.reverse().join(',')
});
if (names.length !== 0) {
layer.setVisible(true);
Expand Down Expand Up @@ -262,13 +266,16 @@ exports.prototype.createLeafInAMixedGroup_ = function(treeCtrl, map) {
googAsserts.assert(ogcServer.type);
googAsserts.assert(gmfLayerWMS.layers);
googAsserts.assert(ogcServer.imageType);

const opt_params = {STYLES: gmfLayerWMS.style};

layer = this.layerHelper_.createBasicWMSLayer(
ogcServer.url,
gmfLayerWMS.layers,
ogcServer.imageType,
ogcServer.type,
timeParam,
undefined, // WMS parameters
opt_params, // WMS parameters
ogcServer.credential ? 'use-credentials' : 'anonymous'
);
}
Expand Down
7 changes: 5 additions & 2 deletions contribs/gmf/src/profile/component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
<li ng-repeat="name in ::ctrl.getLayersNames()">
<i
class="fa fa-minus"
style="color:{{::ctrl.getColor(name)}};"></i>
&nbsp;{{name | translate}}&nbsp;{{ctrl.currentPoint.elevations[name]}}&nbsp;{{ctrl.currentPoint.yUnits}}
ng-style="ctrl.getStyle(name)"></i>
{{name | translate}}
<span ng-if="ctrl.currentPoint.elevations[name] != null">
{{ctrl.currentPoint.elevations[name]}}&nbsp;{{ctrl.currentPoint.yUnits}}
</span>
</li>
</ul>

Expand Down
47 changes: 21 additions & 26 deletions contribs/gmf/src/profile/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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 = '&nbsp;: ';
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}&nbsp;${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)}&nbsp;${this.currentPoint.yUnits}`;
innerHTML.push(`${translatedElevationName} ${separator} ${value}`);
}
return innerHTML.join('</br>');
};
Expand Down Expand Up @@ -559,26 +553,27 @@ 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_);
}
};


/**
* 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'
};
};


Expand All @@ -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;
Expand Down
14 changes: 11 additions & 3 deletions contribs/gmf/src/raster/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ exports.directive('gmfElevation', exports.component_);
* @param {!angular.$filter} $filter Angular filter.
* @param {!ngeox.miscDebounce} ngeoDebounce Ngeo debounce factory
* @param {!gmf.raster.RasterService} gmfRaster Gmf Raster service
* @param {!angularGettext.Catalog} gettextCatalog Gettext catalog.
* @constructor
* @private
* @ngInject
* @ngdoc controller
* @ngname gmfElevationController
*/
exports.Controller_ = function($scope, $filter, ngeoDebounce, gmfRaster) {
exports.Controller_ = function($scope, $filter, ngeoDebounce, gmfRaster, gettextCatalog) {

/**
* @type {!angular.$filter}
Expand All @@ -153,6 +154,12 @@ exports.Controller_ = function($scope, $filter, ngeoDebounce, gmfRaster) {
*/
this.gmfRaster_ = gmfRaster;

/**
* @type {angularGettext.Catalog}
* @private
*/
this.gettextCatalog = gettextCatalog;

/**
* @type {!Object.<string, gmf.raster.component.LayerConfig>}
* @private
Expand Down Expand Up @@ -281,9 +288,10 @@ exports.Controller_.prototype.getRasterSuccess_ = function(resp) {
const separator = postfix.length > 0 ?
(options.hasOwnProperty('separator') ? options.separator : '\u00a0') : '';
const args = Array.prototype.concat([value], custom_args);
this.elevation = this.filter_(filter).apply(args) + separator + postfix;
this.elevation = this.filter_(filter)(...args) + separator + postfix;
} else {
this.elevation = undefined;
const gettextCatalog = this.gettextCatalog;
this.elevation = gettextCatalog.getString('No value');
}
this.loading = false;
};
Expand Down
11 changes: 10 additions & 1 deletion contribs/gmf/src/theme/Themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,22 @@ exports.prototype.getBgLayers = function() {
googAsserts.assert(server, 'The OGC server was not found');
googAsserts.assert(server.url, 'The server URL is required');
googAsserts.assert(server.imageType, 'The server image type is required');

// Manage WMS styles
const opt_params = {STYLES: gmfLayerWMS.styles};
if (gmfLayer.dimensions) {
for (const [key, value] of Object.entries(gmfLayer.dimensions)) {
opt_params[key] = value;
}
}

return callback(gmfLayer, layerHelper.createBasicWMSLayer(
server.url,
gmfLayerWMS.layers || '',
server.imageType,
server.type,
undefined, // time
gmfLayer.dimensions,
opt_params,
server.credential ? 'use-credentials' : 'anonymous',
gmfLayerWMS.metadata.customOpenLayersOptions
));
Expand Down
24 changes: 8 additions & 16 deletions src/profile/d3Elevation.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const exports = function(options) {
* @return {string} Elevation.
*/
yhover(ele, units) {
return `${Math.round(ele)} m`;
return ele !== null ? `${Math.round(ele)} m` : '';
},
/**
* @param {number} dist Distance.
Expand Down Expand Up @@ -545,20 +545,18 @@ const exports = function(options) {
g.select('.x.grid-hover text')
.text(formatter.xhover(dist / xFactor, xUnits))
.style('text-anchor', right ? 'end' : 'start')
.attr('transform', `translate(${xtranslate},${
height - 10})`);
.attr('transform', `translate(${xtranslate},${height - 10})`);

const yUnits = 'm';
// Display altitude on guides only if there is one line.
if (numberOfLines === 1) {
const text = elevations[0] === null ? 'no value' : formatter.yhover(elevations[0], 'm');
g.select('.y.grid-hover text')
.text(formatter.yhover(elevations[0], 'm'))
.text(text)
.style('text-anchor', right ? 'end' : 'start')
.attr('transform', `translate(${xtranslate},${
y(elevations[0]) - 10})`);
.attr('transform', `translate(${xtranslate},${y(elevations[0]) - 10})`);
}
hoverCallback.call(null, point, dist / xFactor, xUnits, elevationsRef,
yUnits);
hoverCallback.call(null, point, dist / xFactor, xUnits, elevationsRef, yUnits);
};


Expand Down Expand Up @@ -607,15 +605,9 @@ const exports = function(options) {
poiEnterG.selectAll('text')
.attr('transform', (d) => {
if (light) {
return ['translate(',
x(pe.dist(d)), ',',
y(pe.z(d)) - 10, ')'
].join('');
return [`translate(${x(pe.dist(d))},${y(pe.z(d)) - 10})`];
} else {
return ['translate(',
x(pe.dist(d)), ',',
y(pe.z(d)) - 20, ') rotate(', poiLabelAngle, ')'
].join('');
return [`translate(${x(pe.dist(d))},${y(pe.z(d)) - 20}) rotate(${poiLabelAngle})`];
}
})
.text(d => pe.sort(d) + (light ? '' : (` - ${pe.title(d)}`)));
Expand Down