Skip to content

Commit

Permalink
Merge branch 'master' into id-fails
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap committed May 11, 2017
2 parents 869016a + c84fd7b commit f513469
Show file tree
Hide file tree
Showing 48 changed files with 857 additions and 375 deletions.
11 changes: 10 additions & 1 deletion docma-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@
"web/client/epics/wfsquery.js",

"web/client/utils/index.jsdoc",
"web/client/utils/CoordinatesUtils.js",
"web/client/utils/PluginsUtils.js",
"web/client/utils/PrintUtils.js",
"web/client/utils/ShareUtils.js"
],
"jsapi": "web/client/jsapi/MapStore2.js",
Expand All @@ -146,11 +148,18 @@
"web/client/plugins/GlobeViewSwitcher.jsx",
"web/client/plugins/GoFull.jsx",
"web/client/plugins/Map.jsx",
"web/client/plugins/Measure.jsx",
"web/client/plugins/MeasurePanel.jsx",
"web/client/plugins/MeasureResults.jsx",
"web/client/plugins/FullScreen.jsx",
"web/client/plugins/Identify.jsx",
"web/client/plugins/Locate.jsx",
"web/client/plugins/Login.jsx",
"web/client/plugins/ScaleBox.jsx",
"web/client/plugins/ScrollTop.jsx",
"web/client/plugins/Search.jsx"
"web/client/plugins/Search.jsx",
"web/client/plugins/ZoomIn.jsx",
"web/client/plugins/ZoomOut.jsx"
]
},
"./docs/**/*md",
Expand Down
1 change: 1 addition & 0 deletions inch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"included": [
"web/client/plugins/*.jsx",
"web/client/actions/*js",
"web/client/selectors/*js",
"web/client/reducers/*js",
"web/client/utils/*.js",
"web/client/epics/*js",
Expand Down
2 changes: 2 additions & 0 deletions web/client/components/TOC/fragments/SettingsModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const SettingsModal = React.createClass({
closeText: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]),
options: React.PropTypes.object,
chartStyle: React.PropTypes.object,
showElevationChart: React.PropTypes.bool,
buttonSize: React.PropTypes.string,
closeGlyph: React.PropTypes.string,
panelStyle: React.PropTypes.object,
Expand Down Expand Up @@ -135,6 +136,7 @@ const SettingsModal = React.createClass({
return (<Elevation
elevationText={this.props.elevationText}
chartStyle={this.props.chartStyle}
showElevationChart={this.props.showElevationChart}
element={this.props.element}
elevations={elevationDim}
appState={this.state || {}}
Expand Down
10 changes: 6 additions & 4 deletions web/client/components/TOC/fragments/settings/Elevation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ module.exports = React.createClass({
elevations: React.PropTypes.object,
onChange: React.PropTypes.func,
appState: React.PropTypes.object,
chartStyle: React.PropTypes.object
chartStyle: React.PropTypes.object,
showElevationChart: React.PropTypes.bool
},
getDefaultProps() {
return {
onChange: () => {}
onChange: () => {},
showElevationChart: true
};
},
shouldComponentUpdate(nextProps) {
return this.props.element.id !== nextProps.element.id;
},
renderElevationsChart(elevations) {
if (this.props.elevations.showChart) {
if (this.props.showElevationChart) {
return (
<ElevationChart
elevations={elevations}
Expand Down Expand Up @@ -66,7 +68,7 @@ module.exports = React.createClass({
}
}
}}
tooltips={!this.props.elevations.showChart}
tooltips={!this.props.showElevationChart}
onChange={(value) => {
this.props.onChange("params", Object.assign({}, {
[this.props.elevations.name]: value[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ describe('test Layer Properties Elevation component', () => {
name: "ELEVATION",
units: "Meters",
positive: false,
showChart: true,
values: ["1.5", "5.0", "10.0", "15.0", "20.0", "25.0", "30.0"]
}
};
Expand Down
54 changes: 52 additions & 2 deletions web/client/components/map/cesium/__tests__/Layer-test-chrome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('Cesium layer', () => {
expect(layer).toExist();
});

it('creates a wms layer for CesiumLayer map', () => {
it('creates a wms layer for Cesium map', () => {
var options = {
"type": "wms",
"visibility": true,
Expand All @@ -157,9 +157,30 @@ describe('Cesium layer', () => {
expect(map.imageryLayers.length).toBe(1);
expect(map.imageryLayers._layers[0]._imageryProvider._url).toBe('{s}');
expect(map.imageryLayers._layers[0]._imageryProvider._tileProvider._subdomains.length).toBe(1);
expect(map.imageryLayers._layers[0]._imageryProvider.proxy.proxy).toExist();
});
it('check wms layer proxy skip for relative urls', () => {
var options = {
"type": "wms",
"visibility": true,
"name": "nurc:Arc_Sample",
"group": "Meteo",
"format": "image/png",
"url": "/geoserver/wms"
};
// create layers
var layer = ReactDOM.render(
<CesiumLayer type="wms"
options={options} map={map}/>, document.getElementById("container"));

it('creates a wmts layer for openlayers map', () => {
expect(layer).toExist();
expect(map.imageryLayers.length).toBe(1);
expect(map.imageryLayers._layers[0]._imageryProvider._url).toBe('{s}');
expect(map.imageryLayers._layers[0]._imageryProvider._tileProvider._subdomains.length).toBe(1);
expect(map.imageryLayers._layers[0]._imageryProvider.proxy.proxy).toNotExist();
});

it('creates a wmts layer for Cesium map', () => {
var options = {
"type": "wmts",
"visibility": true,
Expand Down Expand Up @@ -187,6 +208,35 @@ describe('Cesium layer', () => {
// count layers
expect(map.imageryLayers.length).toBe(1);
expect(map.imageryLayers._layers[0]._imageryProvider._url).toExist();
expect(map.imageryLayers._layers[0]._imageryProvider.proxy.proxy).toExist();
});
it('check a wmts layer skips proxy config', () => {
var options = {
"type": "wmts",
"visibility": true,
"name": "nurc:Arc_Sample",
"group": "Meteo",
"format": "image/png",
"tileMatrixSet": "EPSG:900913",
"matrixIds": {
"EPSG:4326": [{
ranges: {
cols: {max: 0, min: 0},
rows: {max: 0, min: 0}
}
}]
},
"url": "/geoserver/gwc/service/wmts"
};
// create layers
var layer = ReactDOM.render(
<CesiumLayer type="wmts"
options={options} map={map}/>, document.getElementById("container"));
expect(layer).toExist();
// count layers
expect(map.imageryLayers.length).toBe(1);
expect(map.imageryLayers._layers[0]._imageryProvider._url).toExist();
expect(map.imageryLayers._layers[0]._imageryProvider.proxy.proxy).toNotExist();
});

it('creates a wms layer with single tile for CesiumLayer map', () => {
Expand Down
25 changes: 8 additions & 17 deletions web/client/components/map/cesium/plugins/WMSLayer.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/**
/*
* Copyright 2015, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

var Layers = require('../../../../utils/cesium/Layers');
var ConfigUtils = require('../../../../utils/ConfigUtils');
var Cesium = require('../../../../libs/cesium');
var assign = require('object-assign');
var {isObject, isArray} = require('lodash');
const Layers = require('../../../../utils/cesium/Layers');
const ConfigUtils = require('../../../../utils/ConfigUtils');
const ProxyUtils = require('../../../../utils/ProxyUtils');
const Cesium = require('../../../../libs/cesium');
const assign = require('object-assign');
const {isArray} = require('lodash');

function getWMSURLs( urls ) {
return urls.map((url) => url.split("\?")[0]);
Expand Down Expand Up @@ -76,17 +77,7 @@ function wmsToCesiumOptions(options) {
let proxyUrl = ConfigUtils.getProxyUrl({});
let proxy;
if (proxyUrl) {
let useCORS = [];
if (isObject(proxyUrl)) {
useCORS = proxyUrl.useCORS || [];
proxyUrl = proxyUrl.url;
}
let url = options.url;
if (isArray(url)) {
url = url[0];
}
const isCORS = useCORS.reduce((found, current) => found || url.indexOf(current) === 0, false);
proxy = !isCORS && proxyUrl;
proxy = ProxyUtils.needProxy(options.url) && proxyUrl;
}
// NOTE: can we use opacity to manage visibility?
return assign({
Expand Down
13 changes: 2 additions & 11 deletions web/client/components/map/cesium/plugins/WMTSLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
var Layers = require('../../../../utils/cesium/Layers');
var ConfigUtils = require('../../../../utils/ConfigUtils');
const CoordinatesUtils = require('../../../../utils/CoordinatesUtils');
const ProxyUtils = require('../../../../utils/ProxyUtils');
const WMTSUtils = require('../../../../utils/WMTSUtils');
var Cesium = require('../../../../libs/cesium');
var assign = require('object-assign');
Expand Down Expand Up @@ -95,17 +96,7 @@ function wmtsToCesiumOptions(options) {
let proxyUrl = ConfigUtils.getProxyUrl({});
let proxy;
if (proxyUrl) {
let useCORS = [];
if (isObject(proxyUrl)) {
useCORS = proxyUrl.useCORS || [];
proxyUrl = proxyUrl.url;
}
let url = options.url;
if (isArray(url)) {
url = url[0];
}
const isCORS = useCORS.reduce((found, current) => found || url.indexOf(current) === 0, false);
proxy = !isCORS && proxyUrl;
proxy = ProxyUtils.needProxy(options.url) && proxyUrl;
}
// NOTE: can we use opacity to manage visibility?
const isValid = isValidTile(options.matrixIds && options.matrixIds[tileMatrixSet]);
Expand Down
21 changes: 13 additions & 8 deletions web/client/components/map/openlayers/Feature.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015, GeoSolutions Sas.
/*
* Copyright 2017, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
Expand All @@ -14,6 +14,7 @@ let Feature = React.createClass({
propTypes: {
type: React.PropTypes.string,
properties: React.PropTypes.object,
crs: React.PropTypes.string,
container: React.PropTypes.object, // TODO it must be a ol.layer.vector (maybe pass the source is more correct here?)
geometry: React.PropTypes.object, // TODO check for geojson format for geometry
msId: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]),
Expand All @@ -29,8 +30,12 @@ let Feature = React.createClass({
const geometry = this.props.geometry && this.props.geometry.coordinates;

if (this.props.container && geometry) {
this._feature = format.readFeatures({type: this.props.type, properties: this.props.properties, geometry: this.props.geometry, id: this.props.msId});
this._feature.forEach((f) => f.getGeometry().transform(this.props.featuresCrs, 'EPSG:3857'));
this._feature = format.readFeatures({
type: this.props.type,
properties: this.props.properties,
geometry: this.props.geometry,
id: this.props.msId});
this._feature.forEach((f) => f.getGeometry().transform(this.props.featuresCrs, this.props.crs || 'EPSG:3857'));
this.props.container.getSource().addFeatures(this._feature);
}
},
Expand All @@ -42,7 +47,7 @@ let Feature = React.createClass({

if (newProps.container && geometry) {
this._feature = format.readFeatures({type: newProps.type, properties: newProps.properties, geometry: newProps.geometry, id: this.props.msId});
this._feature.forEach((f) => f.getGeometry().transform(newProps.featuresCrs, 'EPSG:3857'));
this._feature.forEach((f) => f.getGeometry().transform(newProps.featuresCrs, this.props.crs || 'EPSG:3857'));
newProps.container.getSource().addFeatures(this._feature);
}
}
Expand All @@ -61,11 +66,11 @@ let Feature = React.createClass({
if (Array.isArray(this._feature)) {
const layersSource = this.props.container.getSource();
this._feature.map((feature) => {
let fetureId = feature.getId();
if (fetureId === undefined) {
let featureId = feature.getId();
if (featureId === undefined) {
layersSource.removeFeature(feature);
}else {
layersSource.removeFeature(layersSource.getFeatureById(fetureId));
layersSource.removeFeature(layersSource.getFeatureById(featureId));
}
});
} else {
Expand Down
Loading

0 comments on commit f513469

Please sign in to comment.