Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cesium tests for TileProvider and WMTS #1683

Merged
merged 1 commit into from
Apr 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions web/client/components/map/cesium/__tests__/Layer-test-chrome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const assign = require('object-assign');

require('../../../../utils/cesium/Layers');
require('../plugins/OSMLayer');
require('../plugins/TileProvider');
require('../plugins/TileProviderLayer');
require('../plugins/WMSLayer');
require('../plugins/WMTSLayer');
require('../plugins/BingLayer');
Expand Down Expand Up @@ -136,9 +136,7 @@ describe('Cesium layer', () => {
var layer = ReactDOM.render(
<CesiumLayer type="tileprovider"
options={options} map={map}/>, document.getElementById("container"));

expect(layer).toExist();
expect(map.imageryLayers.length).toBe(1);
});

it('creates a wms layer for CesiumLayer map', () => {
Expand Down Expand Up @@ -169,6 +167,14 @@ describe('Cesium layer', () => {
"group": "Meteo",
"format": "image/png",
"tileMatrixSet": "EPSG:900913",
"matrixIds": {
"EPSG:4326": [{
ranges: {
cols: {max: 0, min: 0},
rows: {max: 0, min: 0}
}
}]
},
"url": "http://sample.server/geoserver/gwc/service/wmts"
};
// create layers
Expand All @@ -179,8 +185,8 @@ describe('Cesium layer', () => {

expect(layer).toExist();
// count layers
expect(map.getLayers().getLength()).toBe(1);
expect(map.getLayers().item(0).getSource().urls.length).toBe(1);
expect(map.imageryLayers.length).toBe(1);
expect(map.imageryLayers._layers[0]._imageryProvider._url).toExist();
});

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,7 +75,7 @@ Layers.registerType('tileprovider', (options) => {
const isCORS = useCORS.reduce((found, current) => found || url.indexOf(current) === 0, false);
proxy = !isCORS && proxyUrl;
}
const layer = new Cesium.UrlTemplateImageryProvider({
return new Cesium.UrlTemplateImageryProvider({
url: template(url, opt),
enablePickFeatures: false,
subdomains: opt.subdomains,
Expand All @@ -84,5 +84,4 @@ Layers.registerType('tileprovider', (options) => {
credit: opt.attribution,
proxy: proxy && opt.noCors ? new TileProviderProxy(proxyUrl) : new NoProxy()
});
return layer;
});
4 changes: 2 additions & 2 deletions web/client/components/map/cesium/plugins/WMTSLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function WMTSProxy(proxy) {
}

const isValidTile = (tileMatrixSet) => (x, y, level) =>
tileMatrixSet[level] &&
tileMatrixSet && tileMatrixSet[level] &&
x <= parseInt(get(tileMatrixSet[level], "ranges.cols.max"), 10) &&
x >= parseInt(get(tileMatrixSet[level], "ranges.cols.min"), 10) &&
y <= parseInt(get(tileMatrixSet[level], "ranges.rows.max"), 10) &&
Expand All @@ -56,7 +56,7 @@ NoProxy.prototype.getURL = function(resource) {
let {url, queryString} = splitUrl(resource);
return url + queryString;
};
function getMatrixIds(matrix, srs) {
function getMatrixIds(matrix = [], srs) {
return (isObject(matrix) && matrix[srs] || matrix).map((el) => el.identifier);
}

Expand Down