Skip to content

Commit 5bd4fc8

Browse files
committed
Add opacity parameter to create_coverage
1 parent 6310edc commit 5bd4fc8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

geo/Geoserver.py

+3
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,7 @@ def create_coveragestyle(
11811181
color_ramp: str = "RdYlGn_r",
11821182
cmap_type: str = "ramp",
11831183
number_of_classes: int = 5,
1184+
opacity: float = 1,
11841185
):
11851186
"""Dynamically create style for raster.
11861187
@@ -1192,6 +1193,7 @@ def create_coveragestyle(
11921193
color_ramp : str
11931194
cmap_type : str TODO: This should be a set of the available options : {"ramp", "linear", ... }
11941195
number_of_classes : int
1196+
opacity : float
11951197
overwrite : bool
11961198
11971199
Notes
@@ -1213,6 +1215,7 @@ def create_coveragestyle(
12131215
min_value,
12141216
max_value,
12151217
number_of_classes,
1218+
opacity,
12161219
)
12171220
style_xml = "<style><name>{}</name><filename>{}</filename></style>".format(
12181221
style_name, style_name + ".sld"

geo/Style.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def coverage_style_colormapentry(
8282

8383

8484
def coverage_style_xml(
85-
color_ramp, style_name, cmap_type, min_value, max_value, number_of_classes
85+
color_ramp, style_name, cmap_type, min_value, max_value, number_of_classes, opacity
8686
):
8787
min_max_difference = max_value - min_value
8888
style_append = ""
@@ -108,6 +108,7 @@ def coverage_style_xml(
108108
<sld:FeatureTypeStyle>
109109
<sld:Rule>
110110
<sld:RasterSymbolizer>
111+
<sld:Opacity>{3}</sld:Opacity>
111112
<sld:ChannelSelection>
112113
<sld:GrayChannel>
113114
<sld:SourceChannelName>1</sld:SourceChannelName>
@@ -123,7 +124,7 @@ def coverage_style_xml(
123124
</UserLayer>
124125
</StyledLayerDescriptor>
125126
""".format(
126-
cmap_type, style_append, style_name
127+
cmap_type, style_append, style_name, opacity
127128
)
128129

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

0 commit comments

Comments
 (0)