Skip to content

Commit

Permalink
geosolutions-it#9154 Fixed map crash when expanding timeline with tim…
Browse files Browse the repository at this point in the history
…e intervals (geosolutions-it#9155)
  • Loading branch information
offtherailz committed May 17, 2023
1 parent da7a876 commit 7fa3a5f
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
61 changes: 61 additions & 0 deletions web/client/epics/__tests__/timeline-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,67 @@ describe('timeline Epics', () => {
});
});
});
it("setRangeOnInit when the values stored are intervals", (done) => {
testEpic(setRangeOnInit, 3, initializeRange(), ([action1, action2, action3]) => {
try {
const { time, type } = action1;
const { offsetTime, type: typeOff} = action2;
const { type: typeRange, start, end } = action3;
expect(time).toBeTruthy();
expect(offsetTime).toBeTruthy();
expect(type).toBe(SET_CURRENT_TIME);
expect(typeOff).toBe(SET_OFFSET_TIME);
expect(typeRange).toBe(RANGE_CHANGED);
expect(start).toBe("2001-01-01T00:00:00.000Z");
expect(end).toBe("2001-12-31T00:00:00.000Z");
done();
} catch (e) {
done(e);
}
}, {
timeline: {
selectedLayer: "TEST_LAYER",
settings: {
initialMode: 'range',
initialSnap: 'fullRange'
}
},
dimension: {
currentTime: "2000-01-01T00:00:00.000Z",
offsetTime: "2001-12-31T00:00:00.000Z",
data: {
time: {
TEST_LAYER: {
name: "time",
domain: "2001-01-01T00:00:00.000Z/2001-12-31T00:00:00.000Z"
}
}
}
},
layers: {
flat: [{
id: 'TEST_LAYER',
name: 'TEST_LAYER',
type: 'wms',
visibility: true,
url: 'base/web/client/test-resources/wmts/DomainIntervalValues.xml',
dimensions: [
{
source: {
type: 'multidim-extension',
url: 'base/web/client/test-resources/wmts/DomainIntervalValues.xml'
},
name: 'time'
}
],
params: {
time: '2000-06-08T00:00:00.000Z'
}
}]
}
});
});

it("updateTimelineDataOnMapLoad", (done) =>{
const config = {
timelineData: {
Expand Down
3 changes: 2 additions & 1 deletion web/client/epics/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ const updateRangeOnInit = (state, value, currentTime) => {
} else {
values = value;
}

// if values are intervals (separated by /) spread them in the array
values = values.reduce((acc, v) => acc.concat(v.split('/')), []);
if (values.length > 2) {
values = [values[0], values[values.length - 1]]; // more than 2 values, start and end are the first and last values
}
Expand Down

0 comments on commit 7fa3a5f

Please sign in to comment.