-
Notifications
You must be signed in to change notification settings - Fork 23
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
Use individual wms url parameters for the baseLayers #985
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,25 +170,35 @@ def archive_pdf_file(pdf_archive_path, binary_content, extract_as_dict): | |
return path_and_filename | ||
|
||
@staticmethod | ||
def get_wms_url_params(): | ||
def get_wms_url_params(params=None): | ||
""" | ||
Returns the list of additionally configured wms_url_params. | ||
Args: | ||
params: optional argument used for given custom parameters. Expecting a dict | ||
|
||
:return: The configured wms_url_params. | ||
:rtype: list | ||
:rtype: dict | ||
""" | ||
result = {} | ||
wms_url_params = Config.get('print', {}).get('wms_url_params', False) | ||
if wms_url_params: | ||
log.debug("get_wms_url_params() read configuration {}".format(wms_url_params)) | ||
if isinstance(wms_url_params, dict): | ||
result = wms_url_params | ||
result = params if params else {} | ||
if not params: | ||
wms_url_params = Config.get('print', {}).get('wms_url_params', False) | ||
if wms_url_params: | ||
log.debug("get_wms_url_params() read configuration {}".format(wms_url_params)) | ||
if isinstance(wms_url_params, dict): | ||
result = wms_url_params | ||
else: | ||
log.warning("get_wms_url_params() ignoring unaccepted configuration value {}" | ||
.format(wms_url_params)) | ||
else: | ||
log.warning("get_wms_url_params() ignoring unaccepted configuration value {}" | ||
.format(wms_url_params)) | ||
log.info("no wms_url_params configuration detected; using default value") | ||
result = {'TRANSPARENT': 'true'} | ||
|
||
else: | ||
log.info("no wms_url_params configuration detected; using default value") | ||
result = {'TRANSPARENT': 'true'} | ||
for param_key, param_value in params.items(): # TODO make this Python 2.x compatible! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about this todo ? |
||
if isinstance(param_value, str): | ||
result[param_key] = param_value | ||
else: | ||
result[param_key] = ",".join(param_value) | ||
|
||
return result | ||
|
||
|
@@ -277,17 +287,20 @@ def convert_to_printable_extract(self, extract_dict, feature_geometry, pdf_to_jo | |
[restriction_on_landownership['ResponsibleOffice']] | ||
|
||
url, params = parse_url(restriction_on_landownership['Map']['ReferenceWMS']) | ||
wms_url_keep_params = Config.get('print', {}).get('wms_url_keep_params', False) | ||
|
||
restriction_on_landownership['baseLayers'] = { | ||
'layers': [{ | ||
'type': 'wms', | ||
'type': params.pop('SERVICE', 'wms')[0].lower(), | ||
'opacity': restriction_on_landownership['Map'].get('layerOpacity', 0.6), | ||
'styles': 'default', | ||
'styles': params.pop('STYLES', 'default')[0], | ||
'baseURL': urlparse.urlunsplit((url.scheme, url.netloc, url.path, None, None)), | ||
'layers': params['LAYERS'][0].split(','), | ||
'imageFormat': 'image/png', | ||
'customParams': wms_url_params, | ||
'layers': params.pop('LAYERS', '')[0].split(','), | ||
'imageFormat': params.pop('FORMAT', 'image/png')[0], | ||
'customParams': self.get_wms_url_params(params if wms_url_keep_params else None), | ||
}, basemap] | ||
} | ||
|
||
restriction_on_landownership['legend'] = restriction_on_landownership['Map'].get( | ||
'LegendAtWeb', '') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pyramid_oereb: | ||
|
||
print: | ||
wms_url_keep_params: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See another function to have the right syntax to generate the documentation (I'm not sure for your "return" doc)