-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DAS-2180: Extracts get_harmony_message_from_params
Also adds back __init__.py to get tests running locally. (outside of docker and workflows)
- Loading branch information
1 parent
bdde01e
commit 257a462
Showing
3 changed files
with
36 additions
and
22 deletions.
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Module containing utility functionality for browse generation.""" | ||
|
||
from harmony.message import Message as HarmonyMessage | ||
|
||
|
||
def get_harmony_message_from_params(params: dict | None) -> HarmonyMessage: | ||
"""Constructs a harmony message from the input parms. | ||
We have to create a harmony message to pass to the create_browse_imagery | ||
function so that both the library and service calls are identical. | ||
""" | ||
if params is None: | ||
params = {} | ||
mime = params.get('mime', 'image/png') | ||
crs = params.get('crs', None) | ||
scale_extent = params.get('scale_extent', None) | ||
scale_size = params.get('scale_size', None) | ||
height = params.get('height', None) | ||
width = params.get('width', None) | ||
|
||
return HarmonyMessage( | ||
{ | ||
"format": { | ||
"mime": mime, | ||
"crs": crs, | ||
"srs": crs, | ||
"scaleExtent": scale_extent, | ||
"scaleSize": scale_size, | ||
"height": height, | ||
"width": width, | ||
}, | ||
} | ||
) |
Empty file.