Skip to content

Commit

Permalink
Merge pull request #138 from MarkTNO/create_coverage_add_opacity_para…
Browse files Browse the repository at this point in the history
…meter

Add opacity parameter to create_coverage
  • Loading branch information
iamtekson authored Jan 26, 2024
2 parents 6310edc + 5bd4fc8 commit b23d542
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit b23d542

Please sign in to comment.