diff --git a/web/client/components/TOC/fragments/SettingsModal.jsx b/web/client/components/TOC/fragments/SettingsModal.jsx index f06ab3a925..e3b512d9d6 100644 --- a/web/client/components/TOC/fragments/SettingsModal.jsx +++ b/web/client/components/TOC/fragments/SettingsModal.jsx @@ -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: { @@ -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: () => {}, @@ -76,7 +76,8 @@ const SettingsModal = React.createClass({ includeDeleteButton: true, realtimeUpdate: true, deleteText: , - confirmDeleteText: + confirmDeleteText: , + getDimension: LayersUtils.getDimension }; }, getInitialState() { @@ -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 ( this.updateParams({[key]: value}, this.props.realtimeUpdate)} />); } diff --git a/web/client/components/TOC/fragments/settings/Elevation.jsx b/web/client/components/TOC/fragments/settings/Elevation.jsx index a45e727f4c..203ed0a6d5 100644 --- a/web/client/components/TOC/fragments/settings/Elevation.jsx +++ b/web/client/components/TOC/fragments/settings/Elevation.jsx @@ -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 (
diff --git a/web/client/components/TOC/fragments/settings/__tests__/Elevation-test.jsx b/web/client/components/TOC/fragments/settings/__tests__/Elevation-test.jsx index 1f5479c3c3..ce2ab3b914 100644 --- a/web/client/components/TOC/fragments/settings/__tests__/Elevation-test.jsx +++ b/web/client/components/TOC/fragments/settings/__tests__/Elevation-test.jsx @@ -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", diff --git a/web/client/components/TOC/fragments/settings/__tests__/ElevationChart-test.jsx b/web/client/components/TOC/fragments/settings/__tests__/ElevationChart-test.jsx index 1aff2544f8..9eaa32ddc2 100644 --- a/web/client/components/TOC/fragments/settings/__tests__/ElevationChart-test.jsx +++ b/web/client/components/TOC/fragments/settings/__tests__/ElevationChart-test.jsx @@ -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", @@ -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", diff --git a/web/client/components/catalog/RecordItem.jsx b/web/client/components/catalog/RecordItem.jsx index 51979e9ad2..8900c63f24 100644 --- a/web/client/components/catalog/RecordItem.jsx +++ b/web/client/components/catalog/RecordItem.jsx @@ -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: { diff --git a/web/client/utils/CatalogUtils.js b/web/client/utils/CatalogUtils.js index eb343dd953..8454cac262 100644 --- a/web/client/utils/CatalogUtils.js +++ b/web/client/utils/CatalogUtils.js @@ -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, diff --git a/web/client/utils/LayersUtils.js b/web/client/utils/LayersUtils.js index dcb52bb4bf..ac04c6fed6 100644 --- a/web/client/utils/LayersUtils.js +++ b/web/client/utils/LayersUtils.js @@ -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); },