Skip to content

Commit

Permalink
Merge branch 'master' into query-bool
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap committed May 11, 2017
2 parents e9076cd + c84fd7b commit 904f922
Show file tree
Hide file tree
Showing 58 changed files with 967 additions and 395 deletions.
15 changes: 11 additions & 4 deletions docma-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,10 @@
"label": "Reference",
"items": [
{ "label": "Framework", "href": "api/framework"},

{ "separator": true },
{ "label": "JavaScript API", "href": "api/jsapi" },
{ "separator": true },
{ "label": "Plugins", "href": "api/plugins" }

]
},
{
Expand Down Expand Up @@ -105,7 +103,7 @@
},
"src": [
{
"framework" : [
"framework": [
"web/client/components/index.jsdoc",
"web/client/components/buttons/FullScreenButton.jsx",
"web/client/components/buttons/GlobeViewSwitcherButton.jsx",
Expand Down Expand Up @@ -136,7 +134,9 @@
"web/client/epics/search.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 @@ -147,11 +147,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
14 changes: 10 additions & 4 deletions web/client/components/TOC/fragments/settings/Display.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
const React = require('react');

const Slider = require('react-nouislider');
const {Label} = require('react-bootstrap');
const {Label, Checkbox} = require('react-bootstrap');
const {DropdownList} = require('react-widgets');
const Message = require('../../../I18N/Message');
require('react-widgets/lib/less/react-widgets.less');
Expand Down Expand Up @@ -45,9 +45,15 @@ module.exports = React.createClass({
<Label key="opacity-percent" >{Math.round(this.props.settings.options.opacity * 100) + "%"}</Label>
</div>
{this.props.element.type === "wms" ?
[(<div key="transparent-check"><input type="checkbox" key="transparent" checked={this.props.element && (this.props.element.transparent === undefined ? true : this.props.element.transparent)}
onChange={(event) => {this.props.onChange("transparent", event.target.checked); }}/>
<label key="transparent-label" className="control-label">Transparent</label></div>)] : null}
[(<div key="transparent-check">
<Checkbox key="transparent" checked={this.props.element && (this.props.element.transparent === undefined ? true : this.props.element.transparent)} onChange={(event) => {this.props.onChange("transparent", event.target.checked); }}>
<Message msgId="layerProperties.transparent"/></Checkbox>
<Checkbox key="cache" value="tiled" key="tiled"
onChange={(e) => this.props.onChange("tiled", e.target.checked)}
checked={this.props.element && this.props.element.tiled !== undefined ? this.props.element.tiled : true} >
<Message msgId="layerProperties.cached"/>
</Checkbox>
</div>)] : null}
</div>);
}
});
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 @@ -68,7 +68,7 @@ describe('test Layer Properties Display module component', () => {
expect(comp).toExist();
const inputs = ReactTestUtils.scryRenderedDOMComponentsWithTag( comp, "input" );
expect(inputs).toExist();
expect(inputs.length).toBe(1);
expect(inputs.length).toBe(2);
inputs[0].click();
expect(spy.calls.length).toBe(1);
});
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
9 changes: 5 additions & 4 deletions web/client/components/map/cesium/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ let CesiumMap = React.createClass({

if (this.props.onClick && movement.position !== null) {
const cartesian = map.camera.pickEllipsoid(movement.position, map.scene.globe.ellipsoid);
if (cartesian) {
let cartographic = ClickUtils.getMouseXYZ(map, movement) || Cesium.Cartographic.fromCartesian(cartesian);
let cartographic = ClickUtils.getMouseXYZ(map, movement) || cartesian && Cesium.Cartographic.fromCartesian(cartesian);
if (cartographic) {
const latitude = cartographic.latitude * 180.0 / Math.PI;
const longitude = cartographic.longitude * 180.0 / Math.PI;

Expand All @@ -118,6 +118,7 @@ let CesiumMap = React.createClass({
y: y
},
height: this.props.mapOptions && this.props.mapOptions.terrainProvider ? cartographic.height : undefined,
cartographic,
latlng: {
lat: latitude,
lng: longitude
Expand All @@ -130,8 +131,8 @@ let CesiumMap = React.createClass({
onMouseMove(movement) {
if (this.props.onMouseMove && movement.endPosition) {
const cartesian = this.map.camera.pickEllipsoid(movement.endPosition, this.map.scene.globe.ellipsoid);
if (cartesian) {
const cartographic = ClickUtils.getMouseXYZ(this.map, movement) || Cesium.Cartographic.fromCartesian(cartesian);
let cartographic = ClickUtils.getMouseXYZ(this.map, movement) || cartesian && Cesium.Cartographic.fromCartesian(cartesian);
if (cartographic) {
this.props.onMouseMove({
y: cartographic.latitude * 180.0 / Math.PI,
x: cartographic.longitude * 180.0 / Math.PI,
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ Layers.registerType('tileprovider', (options) => {
const isCORS = useCORS.reduce((found, current) => found || url.indexOf(current) === 0, false);
proxy = !isCORS && proxyUrl;
}
const cr = opt.credits;
const credit = cr ? new Cesium.Credit(cr.text, cr.imageUrl, cr.link) : opt.attribution;
return new Cesium.UrlTemplateImageryProvider({
url: template(url, opt),
enablePickFeatures: false,
subdomains: opt.subdomains,
maximumLevel: opt.maxZoom,
minimumLevel: opt.minZoom,
credit: opt.attribution,
credit,
proxy: proxy && opt.noCors ? new TileProviderProxy(proxyUrl) : new NoProxy()
});
});
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
Loading

0 comments on commit 904f922

Please sign in to comment.