Kelbec commited on
Commit
a420b51
1 Parent(s): 9288468

fix dockerfile and map

Browse files
Files changed (2) hide show
  1. Dockerfile +3 -7
  2. pages/01_leafmap.py +39 -20
Dockerfile CHANGED
@@ -6,13 +6,9 @@ RUN mamba install -c conda-forge leafmap geopandas localtileserver -y && \
6
 
7
  USER root
8
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
9
- RUN apt-get install -y software-properties-common
10
- RUN add-apt-repository -y ppa:ubuntugis/ppa
11
- RUN apt-get install -y gdal-bin libgdal-dev
12
- RUN export CPLUS_INCLUDE_PATH=/usr/include/gdal
13
- RUN export C_INCLUDE_PATH=/usr/include/gdal
14
- RUN pip install GDAL==3.4.3
15
- RUN pip install git+https://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@github.com/saferplaces/dcascade_py.git@development
16
  COPY requirements.txt .
17
  RUN pip install -r requirements.txt
18
 
 
6
 
7
  USER root
8
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
9
+ RUN conda install -c conda-forge gdal
10
+ RUN pip install git+https://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@github.com/saferplaces/dcascade_py.git@test_no_click
11
+ RUN pip install keplergl
 
 
 
 
12
  COPY requirements.txt .
13
  RUN pip install -r requirements.txt
14
 
pages/01_leafmap.py CHANGED
@@ -115,10 +115,33 @@ config = {'version': 'v1',
115
  class Map(leafmap.Map):
116
  def __init__(self, **kwargs):
117
  super().__init__(**kwargs)
 
118
  # Add what you want below
119
  # self.add_basemap("OpenTopoMap")
120
  # change_basemap(self)
121
  # self.add_shp()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
 
124
  @solara.component
@@ -128,17 +151,7 @@ def Page():
128
  # solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
129
  # using 3rd party widget library require wiring up the events manually
130
  # using zoom.value and zoom.set
131
- m = Map()
132
- m.element( # type: ignore
133
- zoom=zoom.value,
134
- on_zoom=zoom.set,
135
- center=center.value,
136
- on_center=center.set,
137
- scroll_wheel_zoom=True,
138
- toolbar_ctrl=False,
139
- data_ctrl=False,
140
- )
141
- m.config = config
142
 
143
  # solara.Text(f"Zoom: {zoom.value}")
144
  # solara.Text(f"Center: {center.value}")
@@ -147,6 +160,10 @@ def Page():
147
  filename, set_filename = solara.use_state("")
148
  size, set_size = solara.use_state(0)
149
  file_browser, set_file_browser = solara.use_state(cast(Optional[Path], None))
 
 
 
 
150
 
151
 
152
  def on_file(file: FileInfo):
@@ -170,23 +187,25 @@ def Page():
170
  # m.add_shp(str(file_browser), "Countries")
171
 
172
  def run_dcascade():
173
- file_river = os.getcwd()+"/public/River_Network.shp"
174
- file_q = os.getcwd()+"/public/Q_Vjosa.csv"
175
  print(os.getcwd())
176
  print(os.listdir(os.getcwd()+"/public"))
177
- print(file_river)
178
- print(os.path.exists(Path(file_river)))
179
- dcascade_main.main(river=file_river, q=file_q,timescale=20, formula=3, partitioning=4, out="public/deposito.shp", version=False, verbose=False, debug=False, credits=False)
180
  # m = leafmap.Map.element(center=[20, 0], zoom=1)
181
- m.add_shp("public/deposito.shp", "Countries")
182
- m.config = config
183
- m
 
 
184
 
185
  with solara.Div() as main:
186
 
187
  with solara.Card("Upload files and run dcascade"):
188
  solara.FileDrop(
189
- label="Drag and drop a file here to read the first 100 bytes",
190
  on_file=on_file,
191
  lazy=True,
192
  )
 
115
  class Map(leafmap.Map):
116
  def __init__(self, **kwargs):
117
  super().__init__(**kwargs)
118
+ self.updateMap()
119
  # Add what you want below
120
  # self.add_basemap("OpenTopoMap")
121
  # change_basemap(self)
122
  # self.add_shp()
123
+ def updateMap(self):
124
+ print("ADDING SHP")
125
+ self.add_shp("public/deposito.shp", "Countries")
126
+ self.config = config
127
+ print("UPDATED MAP AND CONFIGS")
128
+ # self.add_basemap("OpenTopoMap")
129
+ # change_basemap(self)
130
+
131
+
132
+ @solara.component
133
+ def MapComponent():
134
+ m = Map()
135
+ m.element( # type: ignore
136
+ zoom=zoom.value,
137
+ on_zoom=zoom.set,
138
+ center=center.value,
139
+ on_center=center.set,
140
+ scroll_wheel_zoom=True,
141
+ toolbar_ctrl=False,
142
+ data_ctrl=False,
143
+ )
144
+ m.config = config
145
 
146
 
147
  @solara.component
 
151
  # solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
152
  # using 3rd party widget library require wiring up the events manually
153
  # using zoom.value and zoom.set
154
+
 
 
 
 
 
 
 
 
 
 
155
 
156
  # solara.Text(f"Zoom: {zoom.value}")
157
  # solara.Text(f"Center: {center.value}")
 
160
  filename, set_filename = solara.use_state("")
161
  size, set_size = solara.use_state(0)
162
  file_browser, set_file_browser = solara.use_state(cast(Optional[Path], None))
163
+ map_loaded, set_map_loaded = solara.use_state(False)
164
+
165
+ if map_loaded:
166
+ MapComponent()
167
 
168
 
169
  def on_file(file: FileInfo):
 
187
  # m.add_shp(str(file_browser), "Countries")
188
 
189
  def run_dcascade():
190
+ river = os.getcwd()+"/public/River_Network.shp"
191
+ q = os.getcwd()+"/public/Q_Vjosa.csv"
192
  print(os.getcwd())
193
  print(os.listdir(os.getcwd()+"/public"))
194
+ # print(file_river)
195
+ # print(os.path.exists(Path(file_river)))
196
+ dcascade_main.main(river, q, timescale=20, formula=3, partitioning=4, out="public/deposito.shp", version=False, verbose=False, debug=False, credits=False)
197
  # m = leafmap.Map.element(center=[20, 0], zoom=1)
198
+ # m.add_shp("public/deposito.shp", "Countries")
199
+ # m.config = config
200
+ print("UPDATING MAP")
201
+ set_map_loaded(True)
202
+ # m.updateMap()
203
 
204
  with solara.Div() as main:
205
 
206
  with solara.Card("Upload files and run dcascade"):
207
  solara.FileDrop(
208
+ label="Drag and drop a file here ",
209
  on_file=on_file,
210
  lazy=True,
211
  )