mikonvergence commited on
Commit
1ca5bdf
·
verified ·
1 Parent(s): c8230d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -4
app.py CHANGED
@@ -29,9 +29,10 @@ gridcell = solara.reactive('')
29
  timestamp = solara.reactive('')
30
  zoom= solara.reactive(4)
31
  source = solara.reactive('Sentinel-2 L2A')
 
32
 
33
  @solara.component
34
- def Page():
35
  with solara.Column():
36
 
37
  with solara.Card(margin=10):
@@ -59,6 +60,16 @@ def Page():
59
  center.value = (20,0)
60
  zoom.value = 4
61
 
 
 
 
 
 
 
 
 
 
 
62
  def update_source(val):
63
  source.value = val
64
  update_image()
@@ -72,6 +83,7 @@ def Page():
72
  layout=ipywidgets.Layout(max_width='60vw', max_height='80vh'),
73
  zoom=zoom.value,
74
  center=center.value,
 
75
  draw_control=False,
76
  measure_control=False,
77
  fullscreen_control=False,
@@ -79,7 +91,12 @@ def Page():
79
  attribution_control=True,
80
  )
81
  display(m)
82
- button = solara.Button("Find Sample", on_click=update_image, height='80px')
 
 
 
 
 
83
  solara.Select(label="Data Source", value=source, values=['Sentinel-2 L2A','Sentinel-2 L1C', 'Sentinel-1 RTC', 'COP-DEM'], on_value=update_source)
84
  with solara.Column(align='center'):
85
  output = solara.Image(image_data.value)
@@ -88,5 +105,4 @@ def Page():
88
  |--------------------:|:----:|
89
  | Latitude, Longitude | {:.3f}, {:.3f} |
90
  | MajorTOM Grid | {} |
91
- | Timestamp| {} |
92
- '''.format(center.value[0], center.value[1], gridcell.value, timestamp.value))
 
29
  timestamp = solara.reactive('')
30
  zoom= solara.reactive(4)
31
  source = solara.reactive('Sentinel-2 L2A')
32
+ search_prompt = solara.reactive("")
33
 
34
  @solara.component
35
+ def Page(style='background-image: linear-gradient(to right, #2f3192, #0171bd, #3ab64b, #f25a24);'):
36
  with solara.Column():
37
 
38
  with solara.Card(margin=10):
 
60
  center.value = (20,0)
61
  zoom.value = 4
62
 
63
+ def update_image_with_text():
64
+ ret = text_to_image(search_prompt.value, return_centre=True, return_gridcell=True, return_timestamp=True, source=source.value)
65
+ if ret is not None:
66
+ image_data.value, center.value, gridcell.value, timestamp.value = ret
67
+ zoom.value=12
68
+ else:
69
+ image_data.value = Image.new('RGB',(1068,1068))
70
+ center.value = (20,0)
71
+ zoom.value = 4
72
+
73
  def update_source(val):
74
  source.value = val
75
  update_image()
 
83
  layout=ipywidgets.Layout(max_width='60vw', max_height='80vh'),
84
  zoom=zoom.value,
85
  center=center.value,
86
+ on_center=center.set,
87
  draw_control=False,
88
  measure_control=False,
89
  fullscreen_control=False,
 
91
  attribution_control=True,
92
  )
93
  display(m)
94
+ button = solara.Button("Find Sample at Map Center", on_click=update_image, height='80px')
95
+
96
+ with solara.Row():
97
+ solara.InputText("(Optional) Text Prompt:", value=search_prompt)
98
+ text_button = solara.Button("Search with Text", on_click=update_image_with_text, height='50px')
99
+
100
  solara.Select(label="Data Source", value=source, values=['Sentinel-2 L2A','Sentinel-2 L1C', 'Sentinel-1 RTC', 'COP-DEM'], on_value=update_source)
101
  with solara.Column(align='center'):
102
  output = solara.Image(image_data.value)
 
105
  |--------------------:|:----:|
106
  | Latitude, Longitude | {:.3f}, {:.3f} |
107
  | MajorTOM Grid | {} |
108
+ '''.format(center.value[0], center.value[1], gridcell.value))