Skip to content

Commit

Permalink
Take care of ghost values
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrahoang686 committed Aug 2, 2023
1 parent af86131 commit a13d31e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
27 changes: 22 additions & 5 deletions stac_ipyleaflet/widgets/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,30 @@ def template(self, **kwargs) -> Box(style={"max_height: 200px"}):
"repeatMode": False,
}

area_tab = (
main.interact_widget.children[0]
.children[1]
tabs = {}

for i in range(2):
tabs[f'child{i}'] = (main.interact_widget.children[0]
.children[i]
.children[0]
.children[0]
.children
)
aoi_coords = area_tab[1]
aoi_clear_button = area_tab[2]

point_tab_children = tabs['child0']
area_tab_children = tabs['child1']

# area_tab = (
# main.interact_widget.children[0]
# .children[1]
# .children[0]
# .children[0]
# .children
# )
aoi_coords = area_tab_children[1]
aoi_clear_button = area_tab_children[2]

# @TODO-CLEANUP: Duplication between tabs, pull logic out into a common utilities file
def handle_clear(self):
draw_layer = main.find_layer("draw_layer")
main.remove_layer(draw_layer)
Expand All @@ -51,6 +65,9 @@ def handle_draw(self, action, geo_json, **kwargs):
main.aoi_coordinates = []
main.aoi_bbox = ()

if('Coordinates' in point_tab_children[1].value):
area_tab_children[1].value = "<code>Waiting for points of interest...</code>"

if action == "created":
if geo_json["geometry"]:
geojson_layer = GeoJSON(
Expand Down
22 changes: 18 additions & 4 deletions stac_ipyleaflet/widgets/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,21 @@ def template(
"repeatMode": False,
}

interact_tab = (
interact_widget.children[0].children[0].children[0].children[0].children
tabs = {}

for i in range(2):
tabs[f'child{i}'] = (main.interact_widget.children[0]
.children[i]
.children[0]
.children[0]
.children
)
point_data = interact_tab[1]
clear_button = interact_tab[2]

point_tab_children = tabs['child0']
area_tab_children = tabs['child1']

point_data = point_tab_children[1]
clear_button = point_tab_children[2]

def get_visible_layers_data(coordinates) -> List[LayerData]:
visible_layers_data = []
Expand Down Expand Up @@ -93,6 +103,7 @@ def create_html_template(layer_name, coordinates, values, band_names):
return

def handle_interaction(self, action, geo_json, **kwargs):
# @TODO-CLEANUP: Duplication between tabs, pull logic out into a common utilities file
def handle_clear(event):
draw_layer = main.find_layer("draw_layer")
main.remove_layer(draw_layer)
Expand All @@ -101,6 +112,8 @@ def handle_clear(event):
return

self.coordinates = []
if('Coordinates' in area_tab_children[1].value):
area_tab_children[1].value = "<code>Waiting for area of interest...</code>"

if action == "created":
if geo_json["geometry"] and geo_json["geometry"]["type"] == "Point":
Expand All @@ -119,6 +132,7 @@ def handle_clear(event):
point_data.value = f"<p><b>Coordinates:</b></p><code>{self.coordinates}</code><br/>"
elif not len(applied_layers):
point_data.value = f"<p><b>Coordinates:</b></p><code>{self.coordinates}</code><br/>"

self.clear()
clear_button.disabled = False
clear_button.on_click(handle_clear)
Expand Down

0 comments on commit a13d31e

Please sign in to comment.