Skip to content

Commit

Permalink
fix: add suggested performance improvements to viewer
Browse files Browse the repository at this point in the history
And fix typo.
  • Loading branch information
rdnfn committed Mar 17, 2021
1 parent 2ac8f4e commit 42eae9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/visualisation/control_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self, viewer: geoviewer.GeoGraphViewer) -> None:
super().__init__(viewer=viewer)

# Resetting all prior visibility control
self.viewer.hidde_all_layers()
self.viewer.hide_all_layers()

widget = self.assemble_widget()
self.children = [widget]
Expand Down
15 changes: 7 additions & 8 deletions src/visualisation/geoviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,17 @@ def set_layer_visibility(
"""
self.layer_dict[layer_type][layer_name][layer_subtype]["active"] = active

def hidde_all_layers(self) -> None:
def hide_all_layers(self) -> None:
""" Hide all layers in self.layer_dict."""
for layer_type, type_dict in self.layer_dict.items():
for layer_name in type_dict:
if layer_type == "maps":
self.set_layer_visibility(layer_type, layer_name, "map", False)
elif layer_type == "graphs":
self.set_layer_visibility(layer_type, layer_name, "graph", False)
self.set_layer_visibility(layer_type, layer_name, "pgons", False)
self.set_layer_visibility(
layer_type, layer_name, "components", False
)
for layer_subtype in self.graph_subtypes:
self.set_layer_visibility(
layer_type, layer_name, layer_subtype, False
)
self.layer_update()

def add_layer(self, layer: Union[dict, ipyleaflet.Layer], name=None) -> None:
Expand Down Expand Up @@ -217,7 +216,7 @@ def add_graph(self, graph: geograph.GeoGraph, name: str = "Graph") -> None:
)

discon_nodes, _ = graph_utils.create_node_edge_geometries(
disconnected_nx_graph, crs=current_graph.crs
disconnected_nx_graph, crs=current_graph.crs, include_edges=False
)

discon_nodes_geo_data = ipyleaflet.GeoData(
Expand All @@ -231,7 +230,7 @@ def add_graph(self, graph: geograph.GeoGraph, name: str = "Graph") -> None:
[node for node in nx_graph.nodes() if nx_graph.degree[node] == 1]
)
poorly_con_nodes, _ = graph_utils.create_node_edge_geometries(
poorly_connected_nx_graph, crs=current_graph.crs
poorly_connected_nx_graph, crs=current_graph.crs, include_edges=False
)
poorly_con_nodes_geo_data = ipyleaflet.GeoData(
geo_dataframe=poorly_con_nodes.to_crs(self.gpd_crs_code),
Expand Down

0 comments on commit 42eae9e

Please sign in to comment.