Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes for mapscript API updates in MapServer 8 #99

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion geomet_climate/mapfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ def gen_layer(layer_name, layer_info, template_path, service='WMS'):
'classes': []
}
layer['type'] = 'RASTER'
layer['dump'] = True
layer['template'] = template_path
layer['name'] = layer_name
layer['tolerance'] = 150
Expand Down
1 change: 0 additions & 1 deletion geomet_climate/resources/mapfile-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"name": "geomet-climate",
"imagetype": "PNG",
"status": "ON",
"transparent": "ON",
"debug": "OFF",
"maxsize": 4096,
"size": [500, 300],
Expand Down
76 changes: 29 additions & 47 deletions geomet_climate/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,46 +60,28 @@ def metadata_lang(m, lg):
function to update the mapfile MAP metadata
keys in function of the lang of the request

:param m: mapfile object to update language
:param m: mapfile.web object to update language
:param lg: lang of the request
"""

m.setMetaData('ows_address',
m.getMetaData('ows_address_{}'.format(lg)))
m.setMetaData('ows_contactperson',
m.getMetaData('ows_contactperson_{}'.format(lg)))
m.setMetaData('ows_city',
m.getMetaData('ows_city_{}'.format(lg)))
m.setMetaData('ows_country',
m.getMetaData('ows_country_{}'.format(lg)))
m.setMetaData('ows_keywordlist_http://purl.org/dc/terms/_items',
m.getMetaData('ows_keywordlist_http://purl.org/dc/terms/_items_{}'.format(lg))) # noqa
m.setMetaData('wms_attribution_title',
m.getMetaData('wms_attribution_title_{}'.format(lg)))
m.setMetaData('ows_contactinstructions',
m.getMetaData('ows_contactinstructions_{}'.format(lg)))
m.setMetaData('ows_contactposition',
m.getMetaData('ows_contactposition_{}'.format(lg)))
m.setMetaData('ows_contactorganization',
m.getMetaData('ows_contactorganization_{}'.format(lg)))
m.setMetaData('wms_attribution_onlineresource',
m.getMetaData('wms_attribution_onlineresource_{}'.format(lg))) # noqa
m.setMetaData('ows_onlineresource',
m.getMetaData('ows_onlineresource_{}'.format(lg)))
m.setMetaData('ows_abstract',
m.getMetaData('ows_abstract_{}'.format(lg)))
m.setMetaData('ows_service_onlineresource',
m.getMetaData('ows_service_onlineresource_{}'.format(lg)))
m.setMetaData('ows_title',
m.getMetaData('ows_title_{}'.format(lg)))
m.setMetaData('ows_hoursofservice',
m.getMetaData('ows_hoursofservice_{}'.format(lg)))
m.setMetaData('ows_stateorprovince',
m.getMetaData('ows_stateorprovince_{}'.format(lg)))
m.setMetaData('ows_keywordlist',
m.getMetaData('ows_keywordlist_{}'.format(lg)))
m.setMetaData('wcs_description',
m.getMetaData('wcs_description_{}'.format(lg)))
m.metadata['ows_address'] = m.metadata[f'ows_address_{lg}']
m.metadata['ows_contactperson'] = m.metadata[f'ows_contactperson_{lg}']
m.metadata['ows_city'] = m.metadata[f'ows_city_{lg}']
m.metadata['ows_country'] = m.metadata[f'ows_country_{lg}']
m.metadata['ows_keywordlist_http://purl.org/dc/terms/_items'] = m.metadata[f'ows_keywordlist_http://purl.org/dc/terms/_items_{lg}'] # noqa
m.metadata['wms_attribution_title'] = m.metadata[f'wms_attribution_title_{lg}'] # noqa
m.metadata['ows_contactinstructions'] = m.metadata[f'ows_contactinstructions_{lg}'] # noqa
m.metadata['ows_contactposition'] = m.metadata[f'ows_contactposition_{lg}'] # noqa
m.metadata['ows_contactorganization'] = m.metadata[f'ows_contactorganization_{lg}'] # noqa
m.metadata['wms_attribution_onlineresource'] = m.metadata[f'wms_attribution_onlineresource_{lg}'] # noqa
m.metadata['ows_onlineresource'] = m.metadata[f'ows_onlineresource_{lg}']
m.metadata['ows_abstract'] = m.metadata[f'ows_abstract_{lg}']
m.metadata['ows_service_onlineresource'] = m.metadata[f'ows_service_onlineresource_{lg}'] # noqa
m.metadata['ows_title'] = m.metadata[f'ows_title_{lg}']
m.metadata['ows_hoursofservice'] = m.metadata[f'ows_hoursofservice_{lg}']
m.metadata['ows_stateorprovince'] = m.metadata[f'ows_stateorprovince_{lg}'] # noqa
m.metadata['ows_keywordlist'] = m.metadata[f'ows_keywordlist_{lg}']
m.metadata['wcs_description'] = m.metadata[f'wcs_description_{lg}']


def get_custom_service_exception(code, locator, text):
Expand Down Expand Up @@ -192,12 +174,14 @@ def application(env, start_response):
LOGGER.debug('Loading mapfile: {}'.format(mapfile_))
mapfile = mapscript.mapObj(mapfile_)
if request_ == 'GetCapabilities' and lang == 'fr':
metadata_lang(mapfile, lang)
metadata_lang(mapfile.web, lang)
layerobj = mapfile.getLayerByName(layer)
layerobj.setMetaData('ows_title',
layerobj.getMetaData('ows_title_{}'.format(lang))) # noqa
layerobj.setMetaData('ows_layer_group',
layerobj.getMetaData('ows_layer_group_{}'.format(lang))) # noqa
layerobj.metadata['ows_title'] = layerobj.metadata[
f'ows_title_{lang}'
]
layerobj.metadata['ows_layer_group'] = layerobj.metadata[
f'ows_layer_group_{lang}'
]

elif request_ == 'GetLegendGraphic' and layer is not None:
mapfile = mapscript.mapObj(mapfile_)
Expand All @@ -218,15 +202,13 @@ def application(env, start_response):
layerobj = mapfile.getLayerByName(layer)
if request_ == 'GetCapabilities' and lang == 'fr':
metadata_lang(mapfile, lang)
layerobj.setMetaData('ows_title',
layerobj.getMetaData('ows_title_{}'.format(lang))) # noqa
layerobj.setMetaData('ows_layer_group',
layerobj.getMetaData('ows_layer_group_{}'.format(lang))) # noqa
layerobj.metadata['ows_title'] = layerobj.metadata[f'ows_title_{lang}'] # noqa
layerobj.metadata['ows_layer_group'] = layerobj.metadata[f'ows_layer_group_{lang}'] # noqa

if time_ and 'ows_timeextent' in layerobj.metadata.keys():
try:
dates = []
timeextent = layerobj.getMetaData('ows_timeextent')
timeextent = layerobj.metadata['ows_timeextent']

start_date, end_date, duration = timeextent.split('/')
start_date = isoparse(start_date)
Expand Down
Loading