Skip to content

Commit

Permalink
Fix #10508 fix tileprovider crash when using {-y} (#10509) (#10555)
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 authored Sep 18, 2024
1 parent a4e4f36 commit f3894e0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions web/client/components/map/cesium/plugins/TileProviderLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ export function template(str, data) {
if (['x', 'y', 'z', 's'].includes(key)) {
return textMatched;
}
if (key === '-x') {
return "{reverseX}";
}
if (key === '-y') {
return "{reverseY}";
}

let value = data[key];

if (value === undefined) {
Expand Down
2 changes: 1 addition & 1 deletion web/client/utils/TileProviderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function template(str = "", data = {}) {
return str.replace(/(\{(.*?)\})/g, function() {
let st = arguments[0];
let key = arguments[2] ? arguments[2] : arguments[1];
if (["x", "y", "z"].includes(key)) {
if (["x", "-x", "y", "-y", "z"].includes(key)) {
return arguments[0];
}
let value = data[key];
Expand Down
9 changes: 7 additions & 2 deletions web/client/utils/__tests__/TileProviderUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ describe('Test the TileProviderUtils', () => {
expect(
template("https://test.com/6510a8722129af6954196fbb26dfadc/1.0.0/topowebb/default/3857/{z}/{y}/{x}.png", optArray))
.toEqual("https://test.com/6510a8722129af6954196fbb26dfadc/1.0.0/topowebb/default/3857/{z}/{y}/{x}.png");
// expect().toBe();
// test negative y (-y in template)
expect(
template("https://test.com/default/3857/{z}/{-y}/{x}.png", optArray))
.toEqual("https://test.com/default/3857/{z}/{-y}/{x}.png");
expect(
template("https://test.com/default/3857/{z}/{-y}/{-x}.png", optArray))
.toEqual("https://test.com/default/3857/{z}/{-y}/{-x}.png");
});


});

0 comments on commit f3894e0

Please sign in to comment.