Skip to content

Commit

Permalink
Fix layer with no data
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Nov 26, 2018
1 parent ff614aa commit f024bd1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 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
18 changes: 18 additions & 0 deletions contribs/gmf/src/profile/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,11 @@ exports.Controller_.prototype.getJsonProfile_ = function() {
exports.Controller_.prototype.getProfileDataSuccess_ = function(resp) {
const profileData = resp.data['profile'];
if (profileData instanceof Array) {
if (profileData.length == 0) {
this.profileData = profileData;
return
}

const nonempty_layers = [];
for (const d of profileData) {
for (const v in d['values']) {
Expand All @@ -670,6 +675,19 @@ exports.Controller_.prototype.getProfileDataSuccess_ = function(resp) {
}
}

const empty_layers = [];
for (const v in profileData[0]['values']) {
if (!nonempty_layers.includes(v)) {
empty_layers.push(v);
}
}

for (const d of profileData) {
for (const l of empty_layers) {
delete d['values'][l];
}
}

this.profileOptions.linesConfiguration = {};
for (const layer of nonempty_layers) {
this.profileOptions.linesConfiguration[layer] = this.linesConfiguration_[layer];
Expand Down

0 comments on commit f024bd1

Please sign in to comment.