Skip to content

Commit

Permalink
Color ramp builder fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmooney committed Oct 7, 2024
1 parent 54fc9da commit a2fa0cb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions python/jupytergis_qgis/jupytergis_qgis/qgis_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def qgis_layer_to_jgis(
if colorRampType == "exact":
color = _build_color_ramp("==", colorList, band, source_min, source_max)

# TODO: Could probably look at RGB values to see what normalize should be
source_parameters.update(urls=urls, normalize=True, wrapX=True)
layer_parameters.update(color=color)

Expand Down Expand Up @@ -276,7 +275,7 @@ def _build_color_ramp(operator, colorList, band, source_min, source_max):
[0.0, 0.0, 0.0, 0.0],
]

# Last entry is inf so handle differently
# Last entry is inf for discrete, so handle differently
for node in colorList[:-1]:
unscaled_val = (node.value * (1 - 0) - source_min * (1 - 0)) / (
source_max - source_min
Expand All @@ -292,9 +291,11 @@ def _build_color_ramp(operator, colorList, band, source_min, source_max):
)

lastElement = colorList[-1]
last_value = (source_max * (1 - 0) - source_min * (1 - 0)) / (
source_max - source_min
)
last_value = (
source_max
if operator == "<="
else lastElement.value * (1 - 0) - source_min * (1 - 0)
) / (source_max - source_min)
color.append([operator, ["band", float(band)], last_value])
color.append(
[
Expand All @@ -306,7 +307,7 @@ def _build_color_ramp(operator, colorList, band, source_min, source_max):
)

# Fallback value for openlayers
color.append([0, 0, 0, 1])
color.append([0.0, 0.0, 0.0, 0.0])

return color

Expand Down

0 comments on commit a2fa0cb

Please sign in to comment.