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

Fixes #1924: better handling of WMTS caps parsing and improved matrix… #1925

Merged
merged 1 commit into from
Jun 13, 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
2 changes: 1 addition & 1 deletion web/client/components/map/leaflet/plugins/WMTSLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ L.tileLayer.wmts = function(urls, options, matrixOptions) {

function wmtsToLeafletOptions(options) {
const srs = CoordinatesUtils.normalizeSRS(options.srs || 'EPSG:3857', options.allowedSRS);
const tileMatrixSet = WMTSUtils.getTileMatrixSet(options.tileMatrixSet, srs, options.allowedSRS);
const tileMatrixSet = WMTSUtils.getTileMatrixSet(options.tileMatrixSet, srs, options.allowedSRS, options.matrixIds);
return assign({
layer: options.name,
style: options.style || "",
Expand Down
2 changes: 1 addition & 1 deletion web/client/components/map/openlayers/plugins/WMTSLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Layers.registerType('wmts', {
create: (options) => {
const urls = getWMSURLs(isArray(options.url) ? options.url : [options.url]);
const srs = CoordinatesUtils.normalizeSRS(options.srs || 'EPSG:3857', options.allowedSRS);
const tileMatrixSet = WMTSUtils.getTileMatrixSet(options.tileMatrixSet, srs, options.allowedSRS);
const tileMatrixSet = WMTSUtils.getTileMatrixSet(options.tileMatrixSet, srs, options.allowedSRS, options.matrixIds);
const resolutions = options.resolutions || mapUtils.getResolutions();
const matrixIds = WMTSUtils.limitMatrix(options.matrixIds && WMTSUtils.getMatrixIds(options.matrixIds, tileMatrixSet || srs) || WMTSUtils.getDefaultMatrixId(options), resolutions.length);
const extent = options.bbox ? ol.extent.applyTransform([parseFloat(options.bbox.bounds.minx), parseFloat(options.bbox.bounds.miny), parseFloat(options.bbox.bounds.maxx), parseFloat(options.bbox.bounds.maxy)], ol.proj.getTransform(options.bbox.crs, options.srs)) : null;
Expand Down
12 changes: 8 additions & 4 deletions web/client/utils/CatalogUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const assign = require('object-assign');
const {head, isArray, isString} = require('lodash');
const urlUtil = require('url');
const CoordinatesUtils = require('./CoordinatesUtils');
const {castArray} = require('lodash');
const {castArray, isObject} = require('lodash');

const getWMSBBox = (record) => {
let layer = record;
Expand Down Expand Up @@ -45,6 +45,10 @@ const getWMTSBBox = (record) => {
return bbox;
};

const getNodeText = (node) => {
return isObject(node) && node._ || node;
};

const converters = {
csw: (records, options) => {
let result = records;
Expand Down Expand Up @@ -176,9 +180,9 @@ const converters = {
return records.records.map((record) => {
const bbox = getWMTSBBox(record);
return {
title: record["ows:Title"] || record["ows:Identifier"],
description: record["ows:Abstract"] || record["ows:Title"] || record["ows:Identifier"],
identifier: record["ows:Identifier"],
title: getNodeText(record["ows:Title"] || record["ows:Identifier"]),
description: getNodeText(record["ows:Abstract"] || record["ows:Title"] || record["ows:Identifier"]),
identifier: getNodeText(record["ows:Identifier"]),
tags: "",
tileMatrixSet: record.TileMatrixSet,
matrixIds: castArray(record.TileMatrixSetLink).reduce((previous, current) => {
Expand Down
4 changes: 2 additions & 2 deletions web/client/utils/WMTSUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const WMTSUtils = {
if (tileMatrixSet) {
return CoordinatesUtils.getEquivalentSRS(srs, allowedSRS).reduce((previous, current) => {
if (isArray(tileMatrixSet)) {
const matching = head(tileMatrixSet.filter((matrix) => (matrix["ows:Identifier"] === current || CoordinatesUtils.getEPSGCode(matrix["ows:SupportedCRS"]) === current)));
return matching && matching["ows:Identifier"] && !matrixIds[previous] ? current : previous;
const matching = head(tileMatrixSet.filter((matrix) => ((matrix["ows:Identifier"] === current || CoordinatesUtils.getEPSGCode(matrix["ows:SupportedCRS"]) === current) && matrixIds[matrix["ows:Identifier"]])));
return matching && matching["ows:Identifier"] ? matching["ows:Identifier"] : previous;
} else if (isObject(tileMatrixSet)) {
return tileMatrixSet[current] || previous;
}
Expand Down
2 changes: 1 addition & 1 deletion web/client/utils/mapinfo/wmts.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
let centerProjected = CoordinatesUtils.reproject(center, 'EPSG:4326', props.map.projection);

const srs = CoordinatesUtils.normalizeSRS(layer.srs || props.map.projection || 'EPSG:3857', layer.allowedSRS);
const tileMatrixSet = WMTSUtils.getTileMatrixSet(layer.tileMatrixSet, srs, layer.allowedSRS);
const tileMatrixSet = WMTSUtils.getTileMatrixSet(layer.tileMatrixSet, srs, layer.allowedSRS, layer.matrixIds);

const fx = (centerProjected.x - tileOrigin[0]) / (resolution * tileSize);
const fy = (tileOrigin[1] - centerProjected.y) / (resolution * tileSize);
Expand Down