Skip to content

Commit

Permalink
Fix reload if url changes for wms wmts wfs
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 committed Nov 8, 2024
1 parent d609157 commit 5e68376
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions web/client/components/map/openlayers/plugins/WMSLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ const mustCreateNewLayer = (oldOptions, newOptions) => {
|| oldOptions.localizedLayerStyles !== newOptions.localizedLayerStyles
|| oldOptions.tileSize !== newOptions.tileSize
|| oldOptions.forceProxy !== newOptions.forceProxy
|| oldOptions.url !== newOptions.url
|| oldOptions.tileGridStrategy !== newOptions.tileGridStrategy
|| !isEqual(oldOptions.tileGrids, newOptions.tileGrids)
);
Expand Down
1 change: 1 addition & 0 deletions web/client/components/map/openlayers/plugins/WMTSLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ const updateLayer = (layer, newOptions, oldOptions) => {
|| oldOptions.srs !== newOptions.srs
|| oldOptions.format !== newOptions.format
|| oldOptions.style !== newOptions.style
|| oldOptions.url !== newOptions.url
|| oldOptions.credits !== newOptions.credits) {
return createLayer(newOptions);
}
Expand Down
4 changes: 2 additions & 2 deletions web/client/utils/LayersUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export const deepChange = (nodes, findValue, propName, propValue) => {
};

export const updateAvailableTileMatrixSetsOptions = ({ tileMatrixSet, matrixIds, ...layer }) => {
if (!layer.availableTileMatrixSets && tileMatrixSet && matrixIds) {
if ( tileMatrixSet && matrixIds) {
const matrixIdsKeys = isArray(matrixIds) ? matrixIds : Object.keys(matrixIds);
const availableTileMatrixSets = matrixIdsKeys
.reduce((acc, key) => {
Expand Down Expand Up @@ -265,7 +265,7 @@ export const extractTileMatrixFromSources = (sources, layer) => {
const availableTileMatrixSets = Object.keys(layer.availableTileMatrixSets)
.reduce((acc, tileMatrixSetId) => {
const tileMatrixSetLink = getTileMatrixSetLink(layer, tileMatrixSetId);
const tileMatrixSet = get({ sources }, tileMatrixSetLink);
const tileMatrixSet = get({ sources }, tileMatrixSetLink) || get({ sources }, tileMatrixSetLink.replace("http:", "https:"));
if (tileMatrixSet) {
return {
...acc,
Expand Down
2 changes: 1 addition & 1 deletion web/client/utils/WFSLayerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const needsReload = (oldOptions, newOptions) => {
return true;
}
return found;
}, false);
}, false) || oldOptions.url !== newOptions.url;
};

export const toDescribeURL = ({ name, search = {}, url, describeFeatureTypeURL } = {}) => {
Expand Down
6 changes: 3 additions & 3 deletions web/client/utils/WMTSUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const getTileMatrixSet = (tileMatrixSet, srs, allowedSRS, matrixIds = {},
if (tileMatrixSet) {
return getEquivalentSRS(srs, allowedSRS).reduce((previous, current) => {
if (isArray(tileMatrixSet)) {
const matching = head(tileMatrixSet.filter((matrix) => ((matrix["ows:Identifier"] === current || getEPSGCode(matrix["ows:SupportedCRS"]) === current) && matrixIds[matrix["ows:Identifier"]])));
const matching = head(tileMatrixSet.filter((matrix) => ((matrix && (matrix["ows:Identifier"] === current || 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 Expand Up @@ -175,11 +175,11 @@ export const getTileMatrix = (_options, srs) => {
const tileMatrixSetName = getTileMatrixSet(options.tileMatrixSet, srs, options.allowedSRS, options.matrixIds);
const ids = options.matrixIds && getMatrixIds(options.matrixIds, tileMatrixSetName || srs);
const tileMatrixSet = sortTileMatrix(
head(options.tileMatrixSet.filter(tM => tM['ows:Identifier'] === tileMatrixSetName)),
head(options.tileMatrixSet.filter(tM => tM && tM['ows:Identifier'] === tileMatrixSetName)),
ids);
// identifiers are in the same order of scales and resolutions

const identifiers = tileMatrixSet?.TileMatrix.map?.(t => t["ows:Identifier"]);
const identifiers = tileMatrixSet?.TileMatrix.map?.(t => t && t["ows:Identifier"]);
// use same order of matrixIds in TileMatrix, if present.
const matrixIds = identifiers && ids
? ids.sort((a, b) => {
Expand Down

0 comments on commit 5e68376

Please sign in to comment.