Skip to content

Commit

Permalink
Fixes geosolutions-it#1701: improvements to the elevation slider
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarto committed Apr 7, 2017
1 parent b41c97a commit fd797a0
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 9 deletions.
12 changes: 7 additions & 5 deletions web/client/components/TOC/fragments/SettingsModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const Elevation = require('./settings/Elevation');
const Portal = require('../../misc/Portal');
const assign = require('object-assign');
const Message = require('../../I18N/Message');
const LayersUtils = require('../../../utils/LayersUtils');

const SettingsModal = React.createClass({
propTypes: {
Expand Down Expand Up @@ -48,14 +49,13 @@ const SettingsModal = React.createClass({
includeDeleteButton: React.PropTypes.bool,
realtimeUpdate: React.PropTypes.bool,
groups: React.PropTypes.array,
elevations: React.PropTypes.object
getDimension: React.PropTypes.func
},
getDefaultProps() {
return {
id: "mapstore-layer-settings",
settings: {expanded: false},
options: {},
elevations: {},
updateSettings: () => {},
hideSettings: () => {},
updateNode: () => {},
Expand All @@ -76,7 +76,8 @@ const SettingsModal = React.createClass({
includeDeleteButton: true,
realtimeUpdate: true,
deleteText: <Message msgId="layerProperties.delete" />,
confirmDeleteText: <Message msgId="layerProperties.confirmDelete" />
confirmDeleteText: <Message msgId="layerProperties.confirmDelete" />,
getDimension: LayersUtils.getDimension
};
},
getInitialState() {
Expand Down Expand Up @@ -129,12 +130,13 @@ const SettingsModal = React.createClass({
}
},
renderElevationTab() {
if (this.props.element.type === "wms" && this.props.element.elevations) {
const elevationDim = this.props.getDimension(this.props.element.dimensions, 'elevation');
if (this.props.element.type === "wms" && this.props.element.dimensions && elevationDim) {
return (<Elevation
elevationText={this.props.elevationText}
chartStyle={this.props.chartStyle}
element={this.props.element}
elevations={this.props.element.elevations}
elevations={elevationDim}
appState={this.state || {}}
onChange={(key, value) => this.updateParams({[key]: value}, this.props.realtimeUpdate)} />);
}
Expand Down
2 changes: 1 addition & 1 deletion web/client/components/TOC/fragments/settings/Elevation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = React.createClass({
const lastVal = parseFloat(values[values.length - 1]);
const start = this.props.element &&
this.props.element.params &&
this.props.element.params[this.props.elevations.name][0] || values[0];
this.props.element.params[this.props.elevations.name] || values[0];
const elevationName = {};
return (
<div id="mapstore-elevation">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('test Layer Properties Elevation component', () => {
type: 'shapefile',
url: 'base/web/client/test-resources/geoserver/wms',
params: {
"ELEVATION": ["1.5"]
"ELEVATION": "1.5"
},
elevations: {
name: "ELEVATION",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('test Layer Properties Elevation Chart component', () => {
type: 'shapefile',
url: 'base/web/client/test-resources/geoserver/wms',
params: {
"ELEVATION": ["1.5"]
"ELEVATION": "1.5"
},
elevations: {
name: "ELEVATION",
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('test Layer Properties Elevation Chart component', () => {
type: 'shapefile',
url: 'base/web/client/test-resources/geoserver/wms',
params: {
"ELEVATION": ["1.5"]
"ELEVATION": "1.5"
},
elevations: {
name: "ELEVATION",
Expand Down
1 change: 1 addition & 0 deletions web/client/components/catalog/RecordItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ const RecordItem = React.createClass({
type: "wms",
url: url,
visibility: true,
dimensions: this.props.record.dimensions || [],
name: wms.params && wms.params.name,
title: this.props.record.title || (wms.params && wms.params.name),
bbox: {
Expand Down
3 changes: 3 additions & 0 deletions web/client/utils/CatalogUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ const converters = {
],
crs: "EPSG:4326"
},
dimensions: (record.Dimension && castArray(record.Dimension) || []).map((dim) => assign({}, {
values: dim._.split(',')
}, dim.$ || {})),
references: [{
type: "OGC:WMS",
url: options.url,
Expand Down
20 changes: 20 additions & 0 deletions web/client/utils/LayersUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,27 @@ const createGroup = (groupId, groupName, layers, addLayers) => {
});
};

const getElevationDimension = (dimensions = []) => {
return dimensions.reduce((previous, dim) => {
return (dim.name.toLowerCase() === 'elevation' || dim.name.toLowerCase() === 'depth') ?
assign({
showChart: true,
positive: dim.name.toLowerCase() === 'elevation'
}, dim, {
name: dim.name.toLowerCase() === 'elevation' ? dim.name : 'DIM_' + dim.name
}) : previous;
}, null);
};

var LayersUtils = {
getDimension: (dimensions, dimension) => {
switch (dimension.toLowerCase()) {
case 'elevation':
return getElevationDimension(dimensions);
default:
return null;
}
},
getLayerId: (layerObj, layers) => {
return layerObj && layerObj.id || (layerObj.name + "__" + layers.length);
},
Expand Down

0 comments on commit fd797a0

Please sign in to comment.