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

Add opacity parameter to create_coverage #138

Merged
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
3 changes: 3 additions & 0 deletions geo/Geoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,7 @@ def create_coveragestyle(
color_ramp: str = "RdYlGn_r",
cmap_type: str = "ramp",
number_of_classes: int = 5,
opacity: float = 1,
):
"""Dynamically create style for raster.

Expand All @@ -1192,6 +1193,7 @@ def create_coveragestyle(
color_ramp : str
cmap_type : str TODO: This should be a set of the available options : {"ramp", "linear", ... }
number_of_classes : int
opacity : float
overwrite : bool

Notes
Expand All @@ -1213,6 +1215,7 @@ def create_coveragestyle(
min_value,
max_value,
number_of_classes,
opacity,
)
style_xml = "<style><name>{}</name><filename>{}</filename></style>".format(
style_name, style_name + ".sld"
Expand Down
5 changes: 3 additions & 2 deletions geo/Style.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def coverage_style_colormapentry(


def coverage_style_xml(
color_ramp, style_name, cmap_type, min_value, max_value, number_of_classes
color_ramp, style_name, cmap_type, min_value, max_value, number_of_classes, opacity
):
min_max_difference = max_value - min_value
style_append = ""
Expand All @@ -108,6 +108,7 @@ def coverage_style_xml(
<sld:FeatureTypeStyle>
<sld:Rule>
<sld:RasterSymbolizer>
<sld:Opacity>{3}</sld:Opacity>
<sld:ChannelSelection>
<sld:GrayChannel>
<sld:SourceChannelName>1</sld:SourceChannelName>
Expand All @@ -123,7 +124,7 @@ def coverage_style_xml(
</UserLayer>
</StyledLayerDescriptor>
""".format(
cmap_type, style_append, style_name
cmap_type, style_append, style_name, opacity
)

with open("style.sld", "w") as f:
Expand Down