Skip to content

Commit

Permalink
Fixes #2608: custom mapOptions are not saved with maps (#2609)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarto committed Feb 28, 2018
1 parent c108aff commit fd27964
Show file tree
Hide file tree
Showing 2 changed files with 266 additions and 1 deletion.
3 changes: 2 additions & 1 deletion web/client/utils/MapUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ function saveMapConfiguration(currentMap, currentLayers, currentGroups, textSear
maxExtent: currentMap.maxExtent,
projection: currentMap.projection,
units: currentMap.units,
zoom: currentMap.zoom
zoom: currentMap.zoom,
mapOptions: currentMap.mapOptions || {}
};

const layers = currentLayers.map((layer) => {
Expand Down
264 changes: 264 additions & 0 deletions web/client/utils/__tests__/MapUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,269 @@ describe('Test the MapUtils', () => {
visibility: true,
catalogURL: "url"
}],
mapOptions: {},
maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34],
projection: 'EPSG:900913',
text_serch_config: '',
units: 'm',
zoom: 10
},
version: 2
});
});

it('save map configuration with map options', () => {
const flat = [
{
allowedSRS: {},
bbox: {},
dimensions: [],
id: "layer001",
loading: true,
name: "layer001",
params: {},
search: {},
singleTile: false,
thumbURL: "THUMB_URL",
title: "layer001",
type: "wms",
url: "",
visibility: true,
catalogURL: "url"
},
{
allowedSRS: {},
bbox: {},
dimensions: [],
id: "layer002",
loading: true,
name: "layer002",
params: {},
search: {},
singleTile: false,
title: "layer002",
type: "wms",
url: "",
visibility: true,
catalogURL: "url"
},
{
allowedSRS: {},
bbox: {},
dimensions: [],
id: "layer003",
loading: true,
name: "layer003",
params: {},
search: {},
singleTile: false,
title: "layer003",
type: "wms",
url: "",
visibility: true,
catalogURL: "url"
}
];

const groups = [
{ expanded: true, id: 'Default', name: 'Default', title: 'Default', nodes: ['layer001', 'layer002'] },
{
expanded: false, id: 'custom', name: 'custom', title: 'custom',
nodes: [{ expanded: true, id: 'custom.nested001', name: 'nested001', title: 'nested001', nodes: ['layer003'] }
]
}
];

const mapConfig = {
center: { x: 0, y: 0, crs: 'EPSG:4326' },
maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34],
projection: 'EPSG:900913',
units: 'm',
zoom: 10,
mapOptions: {
view: {
resolutions: [
84666.66666666688,
42333.33333333344,
21166.66666666672,
10583.33333333336,
5291.66666666668,
2645.83333333334,
1322.91666666667,
661.458333333335000,
529.166666666668000,
396.875000000001000,
264.583333333334000,
132.291666666667000,
66.145833333333500,
39.687500000000100,
26.458333333333400,
13.229166666666700,
6.614583333333350,
3.968750000000010,
2.645833333333340,
1.322916666666670,
0.661458333333335
]
}
}
};

const saved = saveMapConfiguration(mapConfig, flat, groups, '', {});
expect(saved).toEqual({
map: {
center: { crs: 'EPSG:4326', x: 0, y: 0 },
groups: [{
id: 'Default',
expanded: true
}, {
id: 'custom',
expanded: false
}, {
id: 'custom.nested001',
expanded: true
}],
layers: [{
allowedSRS: {},
thumbURL: "THUMB_URL",
availableStyles: undefined,
bbox: {},
capabilitiesURL: undefined,
description: undefined,
dimensions: [],
nativeCrs: undefined,
features: undefined,
featureInfo: undefined,
format: undefined,
group: undefined,
hideLoading: false,
handleClickOnLayer: false,
id: "layer001",
matrixIds: undefined,
maxZoom: undefined,
maxNativeZoom: undefined,
name: "layer001",
opacity: undefined,
params: {},
provider: undefined,
search: {},
singleTile: false,
source: undefined,
style: undefined,
styleName: undefined,
styles: undefined,
tileMatrixSet: undefined,
tiled: undefined,
title: "layer001",
transparent: undefined,
type: "wms",
url: "",
visibility: true,
catalogURL: "url"
},
{
allowedSRS: {},
thumbURL: undefined,
availableStyles: undefined,
bbox: {},
capabilitiesURL: undefined,
description: undefined,
dimensions: [],
nativeCrs: undefined,
features: undefined,
featureInfo: undefined,
format: undefined,
group: undefined,
hideLoading: false,
handleClickOnLayer: false,
id: "layer002",
matrixIds: undefined,
maxZoom: undefined,
maxNativeZoom: undefined,
name: "layer002",
opacity: undefined,
params: {},
provider: undefined,
search: {},
singleTile: false,
source: undefined,
style: undefined,
styleName: undefined,
styles: undefined,
tileMatrixSet: undefined,
tiled: undefined,
title: "layer002",
transparent: undefined,
type: "wms",
url: "",
visibility: true,
catalogURL: "url"
},
{
allowedSRS: {},
thumbURL: undefined,
availableStyles: undefined,
bbox: {},
capabilitiesURL: undefined,
description: undefined,
dimensions: [],
nativeCrs: undefined,
features: undefined,
featureInfo: undefined,
format: undefined,
group: undefined,
hideLoading: false,
handleClickOnLayer: false,
id: "layer003",
matrixIds: undefined,
maxZoom: undefined,
maxNativeZoom: undefined,
name: "layer003",
opacity: undefined,
params: {},
provider: undefined,
search: {},
singleTile: false,
source: undefined,
style: undefined,
styleName: undefined,
styles: undefined,
tileMatrixSet: undefined,
tiled: undefined,
title: "layer003",
transparent: undefined,
type: "wms",
url: "",
visibility: true,
catalogURL: "url"
}],
mapOptions: {
view: {
resolutions: [
84666.66666666688,
42333.33333333344,
21166.66666666672,
10583.33333333336,
5291.66666666668,
2645.83333333334,
1322.91666666667,
661.458333333335000,
529.166666666668000,
396.875000000001000,
264.583333333334000,
132.291666666667000,
66.145833333333500,
39.687500000000100,
26.458333333333400,
13.229166666666700,
6.614583333333350,
3.968750000000010,
2.645833333333340,
1.322916666666670,
0.661458333333335
]
}
},
maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34],
projection: 'EPSG:900913',
text_serch_config: '',
Expand Down Expand Up @@ -575,6 +838,7 @@ describe('Test the MapUtils', () => {
visibility: true,
catalogURL: "url"
}],
mapOptions: {},
maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34],
projection: 'EPSG:900913',
text_serch_config: '',
Expand Down

0 comments on commit fd27964

Please sign in to comment.