Skip to content

Commit

Permalink
#553: Restore support of arcgis layers (#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap authored Oct 28, 2021
1 parent df2ff2e commit 3d8f5ce
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 151 deletions.
100 changes: 52 additions & 48 deletions geonode_mapstore_client/client/js/apps/gn-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,61 +72,65 @@ document.addEventListener('DOMContentLoaded', function() {
geoNodeConfiguration,
pluginsConfigKey,
configEpics,
mapType = 'openlayers',
onStoreInit,
geoNodePageConfig,
targetId = 'ms-container',
settings
} = setupConfiguration({ localConfig, user });

main({
targetId,
appComponent: withRoutes(routes)(ConnectedRouter),
pluginsConfig: getPluginsConfiguration(localConfig.plugins, pluginsConfigKey),
loaderComponent: MainLoader,
lazyPlugins: pluginsDefinition.lazyPlugins,
pluginsDef: {
plugins: {
...pluginsDefinition.plugins
},
requires: {
...requires,
...pluginsDefinition.requires
}
},
initialState: {
defaultState: {
maptype: {
mapType: 'openlayers'
import('@js/map/' + mapType + '/plugins/ArcGisMapServer')
.then(() => {
main({
targetId,
appComponent: withRoutes(routes)(ConnectedRouter),
pluginsConfig: getPluginsConfiguration(localConfig.plugins, pluginsConfigKey),
loaderComponent: MainLoader,
lazyPlugins: pluginsDefinition.lazyPlugins,
pluginsDef: {
plugins: {
...pluginsDefinition.plugins
},
requires: {
...requires,
...pluginsDefinition.requires
}
},
...securityState
}
},
themeCfg: null,
appReducers: {
dashboard,
gnresource,
gnsettings,
security,
maptype,
widgets
},
appEpics: {
...configEpics,
...gnresourceEpics
},
onStoreInit,
geoNodeConfiguration,
initialActions: [
// add some settings in the global state to make them accessible in the monitor state
// later we could use expression in localConfig
updateGeoNodeSettings.bind(null, settings),
...(geoNodePageConfig.resourceId !== undefined
? [ requestResourceConfig.bind(null, ResourceTypes.DASHBOARD, geoNodePageConfig.resourceId, {
readOnly: geoNodePageConfig.isEmbed
}) ]
: [])
]
});
initialState: {
defaultState: {
maptype: {
mapType: 'openlayers'
},
...securityState
}
},
themeCfg: null,
appReducers: {
dashboard,
gnresource,
gnsettings,
security,
maptype,
widgets
},
appEpics: {
...configEpics,
...gnresourceEpics
},
onStoreInit,
geoNodeConfiguration,
initialActions: [
// add some settings in the global state to make them accessible in the monitor state
// later we could use expression in localConfig
updateGeoNodeSettings.bind(null, settings),
...(geoNodePageConfig.resourceId !== undefined
? [ requestResourceConfig.bind(null, ResourceTypes.DASHBOARD, geoNodePageConfig.resourceId, {
readOnly: geoNodePageConfig.isEmbed
}) ]
: [])
]
});
});
});
});

Expand Down
95 changes: 50 additions & 45 deletions geonode_mapstore_client/client/js/apps/gn-geostory.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,57 +73,62 @@ document.addEventListener('DOMContentLoaded', function() {
pluginsConfigKey,
geoNodePageConfig,
configEpics,
mapType = 'openlayers',
onStoreInit,
targetId = 'ms-container',
settings
} = setupConfiguration({ localConfig, user });

main({
targetId,
appComponent: withRoutes(routes)(ConnectedRouter),
pluginsConfig: getPluginsConfiguration(localConfig.plugins, pluginsConfigKey),
loaderComponent: MainLoader,
lazyPlugins: pluginsDefinition.lazyPlugins,
pluginsDef: {
plugins: {
...pluginsDefinition.plugins
},
requires: {
...requires,
...pluginsDefinition.requires
}
},
initialState: {
defaultState: {
maptype: {
mapType: 'openlayers'
// register custom arcgis layer
import('@js/map/' + mapType + '/plugins/ArcGisMapServer')
.then(() => {
main({
targetId,
appComponent: withRoutes(routes)(ConnectedRouter),
pluginsConfig: getPluginsConfiguration(localConfig.plugins, pluginsConfigKey),
loaderComponent: MainLoader,
lazyPlugins: pluginsDefinition.lazyPlugins,
pluginsDef: {
plugins: {
...pluginsDefinition.plugins
},
requires: {
...requires,
...pluginsDefinition.requires
}
},
...securityState
}
},
themeCfg: null,
appReducers: {
geostory,
gnresource,
gnsettings,
security,
maptype
},
appEpics: {
...configEpics,
...gnresourceEpics
},
onStoreInit,
geoNodeConfiguration,
initialActions: [
// add some settings in the global state to make them accessible in the monitor state
// later we could use expression in localConfig
updateGeoNodeSettings.bind(null, settings),
...(geoNodePageConfig.resourceId !== undefined
? [ requestResourceConfig.bind(null, ResourceTypes.GEOSTORY, geoNodePageConfig.resourceId) ]
: [])
]
});
initialState: {
defaultState: {
maptype: {
mapType: 'openlayers'
},
...securityState
}
},
themeCfg: null,
appReducers: {
geostory,
gnresource,
gnsettings,
security,
maptype
},
appEpics: {
...configEpics,
...gnresourceEpics
},
onStoreInit,
geoNodeConfiguration,
initialActions: [
// add some settings in the global state to make them accessible in the monitor state
// later we could use expression in localConfig
updateGeoNodeSettings.bind(null, settings),
...(geoNodePageConfig.resourceId !== undefined
? [ requestResourceConfig.bind(null, ResourceTypes.GEOSTORY, geoNodePageConfig.resourceId) ]
: [])
]
});
});
});

});
143 changes: 86 additions & 57 deletions geonode_mapstore_client/client/js/utils/ResourceUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ function getExtentFromResource({ ll_bbox_polygon: llBboxPolygon }) {
return bbox;
}

const GXP_PTYPES = {
'AUTO': 'gxp_wmscsource',
'OWS': 'gxp_wmscsource',
'WMS': 'gxp_wmscsource',
'WFS': 'gxp_wmscsource',
'WCS': 'gxp_wmscsource',
'REST_MAP': 'gxp_arcrestsource',
'REST_IMG': 'gxp_arcrestsource',
'HGL': 'gxp_hglsource',
'GN_WMS': 'gxp_geonodecataloguesource'
};

/**
* convert resource layer configuration to a mapstore layer object
* @memberof MenuUtils
Expand All @@ -47,67 +59,84 @@ export const resourceToLayerConfig = (resource) => {
pk,
has_time: hasTime,
default_style: defaultStyle,
styles
styles,
ptype
} = resource;

const bbox = getExtentFromResource(resource);
switch (ptype) {
case GXP_PTYPES.REST_MAP:
case GXP_PTYPES.REST_IMG: {
const { url: arcgisUrl } = links.find(({ mime }) => mime === 'text/html') || {};
return {
perms,
id: uuid(),
pk,
type: 'arcgis',
name: alternate.replace('remoteWorkspace:', ''),
url: arcgisUrl,
...(bbox && { bbox }),
title,
visibility: true
};
}
default:
const { url: wfsUrl } = links.find(({ link_type: linkType }) => linkType === 'OGC:WFS') || {};
const { url: wmsUrl } = links.find(({ link_type: linkType }) => linkType === 'OGC:WMS') || {};
const { url: wmtsUrl } = links.find(({ link_type: linkType }) => linkType === 'OGC:WMTS') || {};

const { url: wfsUrl } = links.find(({ link_type: linkType }) => linkType === 'OGC:WFS') || {};
const { url: wmsUrl } = links.find(({ link_type: linkType }) => linkType === 'OGC:WMS') || {};
const { url: wmtsUrl } = links.find(({ link_type: linkType }) => linkType === 'OGC:WMTS') || {};

const dimensions = [
...(hasTime ? [{
name: 'time',
source: {
type: 'multidim-extension',
url: wmtsUrl || (wmsUrl || '').split('/geoserver/')[0] + '/geoserver/gwc/service/wmts'
}
}] : [])
];

const params = wmsUrl && url.parse(wmsUrl, true).query;
const format = getConfigProp('defaultLayerFormat') || 'image/png';
const dimensions = [
...(hasTime ? [{
name: 'time',
source: {
type: 'multidim-extension',
url: wmtsUrl || (wmsUrl || '').split('/geoserver/')[0] + '/geoserver/gwc/service/wmts'
}
}] : [])
];

return {
perms,
id: uuid(),
pk,
type: 'wms',
name: alternate,
url: wmsUrl || '',
format,
...(wfsUrl && {
search: {
type: 'wfs',
url: wfsUrl
}
}),
...(bbox && { bbox }),
...(template && {
featureInfo: {
format: 'TEMPLATE',
template
}
}),
style: '',
title,
visibility: true,
...(defaultStyle && {
defaultStyle: {
title: defaultStyle.sld_title,
name: defaultStyle.workspace ? `${defaultStyle.workspace}:${defaultStyle.name}` : defaultStyle.name
}
}),
...(styles && {
availableStyles: [ ...styles ].map((style) => ({
title: style.sld_title,
name: style.workspace ? `${style.workspace}:${style.name}` : style.name
}))
}),
...(params && { params }),
...(dimensions.length > 0 && ({ dimensions }))
};
const params = wmsUrl && url.parse(wmsUrl, true).query;
const format = getConfigProp('defaultLayerFormat') || 'image/png';
return {
perms,
id: uuid(),
pk,
type: 'wms',
name: alternate,
url: wmsUrl || '',
format,
...(wfsUrl && {
search: {
type: 'wfs',
url: wfsUrl
}
}),
...(bbox && { bbox }),
...(template && {
featureInfo: {
format: 'TEMPLATE',
template
}
}),
style: '',
title,
visibility: true,
...(defaultStyle && {
defaultStyle: {
title: defaultStyle.sld_title,
name: defaultStyle.workspace ? `${defaultStyle.workspace}:${defaultStyle.name}` : defaultStyle.name
}
}),
...(styles && {
availableStyles: [ ...styles ].map((style) => ({
title: style.sld_title,
name: style.workspace ? `${style.workspace}:${style.name}` : style.name
}))
}),
...(params && { params }),
...(dimensions.length > 0 && ({ dimensions }))
};
}
};

function updateUrlQueryParameter(requestUrl, query) {
Expand Down Expand Up @@ -216,7 +245,7 @@ export const getResourceTypesInfo = () => ({
})),
formatDetailUrl: (resource) => resource?.detail_url && parseDevHostname(resource.detail_url),
name: 'Dataset',
formatMetadataUrl: (resource) => (`/datasets/${resource.alternate}/metadata`)
formatMetadataUrl: (resource) => (`/datasets/${resource.store}:${resource.alternate}/metadata`)
},
[ResourceTypes.MAP]: {
icon: 'map',
Expand Down
Loading

0 comments on commit 3d8f5ce

Please sign in to comment.