Skip to content

Commit

Permalink
Fix layer with no data
Browse files Browse the repository at this point in the history
  • Loading branch information
fredj committed Nov 27, 2018
1 parent ff614aa commit 6b8c334
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
5 changes: 3 additions & 2 deletions contribs/gmf/apps/desktop/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const exports = function($scope, $injector) {
* @type {Array.<string>}
* @export
*/
this.elevationLayers = ['aster', 'srtm'];
this.elevationLayers = ['aster', 'srtm', 'srtm-partial'];

/**
* @type {Object.<string, gmf.raster.component.LayerConfig>}
Expand All @@ -78,7 +78,8 @@ const exports = function($scope, $injector) {
*/
this.profileLinesconfiguration = {
'aster': {color: '#0000A0'},
'srtm': {color: '#00A000'}
'srtm': {color: '#00A000'},
'srtm-partial': {color: '#FF66FF'},
};

/**
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/apps/desktop/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
<% } %>
<script>
document.write(
'<script src="https://geomapfish-demo.camptocamp.com/2.3/wsgi/dynamic.js?' +
'<script src="https://geomapfish-demo.camptocamp.com/sbrunner23/wsgi/dynamic.js?' +
'interface=desktop&' +
'query=' + encodeURIComponent(document.location.search) +
'"><' + '/script>');
Expand Down
33 changes: 19 additions & 14 deletions src/profile/d3Elevation.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,13 @@ const exports = function(options) {
// each lines.
const yDomain = function() {
let elevationsValues = [];
let extent, name;
// Get min/max values (extent) of each lines.
for (name in linesConfiguration) {
extent = d3.extent(data, d => linesConfiguration[name].zExtractor(d));
elevationsValues = elevationsValues.concat(extent);
for (const name in linesConfiguration) {
const extent = d3.extent(data, d => linesConfiguration[name].zExtractor(d));
// only include defined extent
if (extent.every(Number.isFinite)) {
elevationsValues = elevationsValues.concat(extent);
}
}
return [
Math.min.apply(null, elevationsValues),
Expand Down Expand Up @@ -519,24 +521,27 @@ const exports = function(options) {

for (lineName in linesConfiguration) {
elevation = linesConfiguration[lineName].zExtractor(point);
elevations.push(elevation);
elevationsRef[lineName] = elevation;
g.select(`.y.grid-hover.${lineName}`)
.style('display', 'inline')
.select('line')
.attr('x1', x(0))
.attr('y1', y(elevation))
.attr('x2', width)
.attr('y2', y(elevation));
if (Number.isFinite(elevation)) {
elevations.push(elevation);
elevationsRef[lineName] = elevation;
g.select(`.y.grid-hover.${lineName}`)
.style('display', 'inline')
.select('line')
.attr('x1', x(0))
.attr('y1', y(elevation))
.attr('x2', width)
.attr('y2', y(elevation));
}
}

const y2 = y(Math.max.apply(null, elevations));
g.select('.x.grid-hover')
.style('display', 'inline')
.select('line')
.attr('x1', x(dist))
.attr('y1', height)
.attr('x2', x(dist))
.attr('y2', y(Math.max.apply(null, elevations)));
.attr('y2', Number.isFinite(y2) ? y2 : 0);

const right = dist > xDomain[1] / 2;
let xtranslate = x(dist);
Expand Down

0 comments on commit 6b8c334

Please sign in to comment.