Skip to content

Commit

Permalink
Bugfix: Load map baselayers from persisted settings
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv committed Apr 28, 2021
1 parent 2427301 commit d9368da
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def _store_intersection_traces(
State(get_uuid("leaflet-map1"), "polyline_points"),
State({"id": get_uuid("intersection-data"), "element": "well"}, "value"),
)
# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-branches
def _store_intersection_layout(
data: List,
initial_layout: Optional[dict],
Expand Down Expand Up @@ -319,7 +319,8 @@ def _store_intersection_layout(
layout.get("yaxis", {}).update(range=user_range)
# Else autocalculate range if not intersecting a well
elif intersection_source != "well":
del layout.get("yaxis", {})["range"]
if "range" in layout.get("yaxis", {}):
del layout["yaxis"]["range"]
layout.get("yaxis", {}).update({"autorange": "reversed"})

# Remove xaxis zero line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def _update_maps(
"""Generate Leaflet layers for the three map views"""
realizations = [int(real) for real in real_list]
ctx = dash.callback_context.triggered[0]

if "compute_diff" in ctx["prop_id"]:
if not compute_diff:
return (
Expand All @@ -159,7 +158,6 @@ def _update_maps(
or "stored_xline" in ctx["prop_id"]
)
)

if polyline is not None:
poly_layer = create_leaflet_polyline_layer(
polyline, name="Polyline", poly_id="random_line"
Expand Down Expand Up @@ -240,7 +238,10 @@ def _update_maps(

# Generate Leaflet layers
update_controls = check_if_update_needed(
ctx, current_map, compute_diff, color_range_settings
ctx=ctx,
current_maps=[current_map, current_map2],
compute_diff=compute_diff,
color_range_settings=color_range_settings,
)

surface_layers = create_or_return_base_layer(
Expand Down Expand Up @@ -468,11 +469,14 @@ def replace_or_add_map_layer(


def check_if_update_needed(
ctx: Dict, current_map: List[Dict], compute_diff: List, color_range_settings: Dict
ctx: Dict,
current_maps: List[List[Dict]],
compute_diff: List,
color_range_settings: Dict,
) -> Dict[str, Any]:

update_controls = {}
for map_id in ["map1", "map2"]:
for map_id, current_map in zip(["map1", "map2"], current_maps):
map_controllers_clicked = f'"map_id":"{map_id}"' in ctx["prop_id"]
change_calculate_well_intersections = (
map_controllers_clicked and "options" in ctx["prop_id"]
Expand All @@ -484,12 +488,18 @@ def check_if_update_needed(
"map-color-ranges" in ctx["prop_id"]
and color_range_settings[map_id]["update"]
)
initial_loading = True
if current_map:
for layer in current_map:
if layer.get("id") == map_id:
initial_loading = False

update_controls[map_id] = {
"update": (
map_controllers_clicked
or change_shade_map
or change_color_clip
or not current_map
or initial_loading
),
"use_base_layer": (change_shade_map or change_calculate_well_intersections),
}
Expand Down

0 comments on commit d9368da

Please sign in to comment.