Spaces:
Runtime error
Runtime error
Commit
·
2a67034
1
Parent(s):
a8bdd36
Increased the number of columns in article summary
Browse files
tomorrowcities/pages/engine.py
CHANGED
|
@@ -371,7 +371,7 @@ def building_click_handler(event=None, feature=None, id=None, properties=None):
|
|
| 371 |
layers.value['map_info_button'].set("detail")
|
| 372 |
|
| 373 |
def road_node_click_handler(event=None, feature=None, id=None, properties=None):
|
| 374 |
-
print(properties)
|
| 375 |
layers.value['map_info_detail'].set(properties)
|
| 376 |
layers.value['map_info_button'].set("detail")
|
| 377 |
|
|
@@ -384,7 +384,7 @@ def road_edge_colors(feature):
|
|
| 384 |
return {'color': 'red' if is_damaged else color}
|
| 385 |
|
| 386 |
def road_edge_click_handler(event=None, feature=None, id=None, properties=None):
|
| 387 |
-
print(properties)
|
| 388 |
layers.value['map_info_detail'].set(properties)
|
| 389 |
layers.value['map_info_button'].set("detail")
|
| 390 |
#layers.value['map_info_force_render'].set(True)
|
|
@@ -395,7 +395,7 @@ def landuse_click_handler(event=None, feature=None, id=None, properties=None):
|
|
| 395 |
#layers.value['map_info_force_render'].set(True)
|
| 396 |
|
| 397 |
def landuse_colors(feature):
|
| 398 |
-
print(feature)
|
| 399 |
luf_type = feature['properties']['luf']
|
| 400 |
if luf_type == 'RESIDENTIAL (HIGH DENSITY)':
|
| 401 |
luf_color = {
|
|
@@ -465,7 +465,7 @@ def landuse_colors(feature):
|
|
| 465 |
return luf_color
|
| 466 |
|
| 467 |
def power_node_colors(feature):
|
| 468 |
-
print(feature)
|
| 469 |
ds_to_color = {0: 'lavender', 1:'violet',2:'fuchsia',3:'indigo',4:'darkslateblue',5:'black'}
|
| 470 |
ds = random.randint(0,5) #feature['properties']['ds']
|
| 471 |
return {'color': ds_to_color[ds], 'fillColor': ds_to_color[ds]}
|
|
@@ -488,7 +488,7 @@ def create_map_layer(df, name):
|
|
| 488 |
im_col = 'pga' if 'pga' in df.columns else 'im'
|
| 489 |
df_limited = df.sort_values(by=im_col,ascending=False).head(500_000)
|
| 490 |
locs = np.array([df_limited.geometry.y.to_list(), df_limited.geometry.x.to_list(), df_limited[im_col].to_list()]).transpose().tolist()
|
| 491 |
-
map_layer = ipyleaflet.Heatmap(locations=locs, radius =
|
| 492 |
elif name == "landuse":
|
| 493 |
map_layer = ipyleaflet.GeoJSON(data = json.loads(df.to_json()),
|
| 494 |
style={'opacity': 1, 'dashArray': '9', 'fillOpacity': 0.5, 'weight': 1},
|
|
@@ -1070,7 +1070,7 @@ def ExecutePanel():
|
|
| 1070 |
household['hospital_access'] = list(household_hospital_access)
|
| 1071 |
individual['facility_access'] = list(individual_facility_access)
|
| 1072 |
|
| 1073 |
-
print(buildings.head())
|
| 1074 |
print('number of damaged roads/bridges',len(edges[edges['is_damaged']]))
|
| 1075 |
|
| 1076 |
return edges, buildings, household, individual
|
|
@@ -1122,7 +1122,7 @@ def ExecutePanel():
|
|
| 1122 |
|
| 1123 |
buildings_freqincome = buildings[['bldid']].merge(freqincome,on='bldid',how='left')
|
| 1124 |
buildings['freqincome'] = buildings_freqincome['freqincome']
|
| 1125 |
-
print('policies',policies)
|
| 1126 |
if layers.value['hazard'].value == 'landslide':
|
| 1127 |
fragility = layers.value['layers']['landslide fragility']['data'].value
|
| 1128 |
intensity = layers.value['layers']['landslide susceptibility']['data'].value
|
|
@@ -1328,7 +1328,7 @@ def MapInfo():
|
|
| 1328 |
@solara.component
|
| 1329 |
def ImportDataZone():
|
| 1330 |
def s3_file_open(p):
|
| 1331 |
-
print(p)
|
| 1332 |
storage.value.s3.download_file(storage.value.bucket_name, str(p)[1:], f'/tmp/aws.tmp')
|
| 1333 |
|
| 1334 |
with open(f'/tmp/aws.tmp', 'rb') as fileObj:
|
|
|
|
| 371 |
layers.value['map_info_button'].set("detail")
|
| 372 |
|
| 373 |
def road_node_click_handler(event=None, feature=None, id=None, properties=None):
|
| 374 |
+
#print(properties)
|
| 375 |
layers.value['map_info_detail'].set(properties)
|
| 376 |
layers.value['map_info_button'].set("detail")
|
| 377 |
|
|
|
|
| 384 |
return {'color': 'red' if is_damaged else color}
|
| 385 |
|
| 386 |
def road_edge_click_handler(event=None, feature=None, id=None, properties=None):
|
| 387 |
+
#print(properties)
|
| 388 |
layers.value['map_info_detail'].set(properties)
|
| 389 |
layers.value['map_info_button'].set("detail")
|
| 390 |
#layers.value['map_info_force_render'].set(True)
|
|
|
|
| 395 |
#layers.value['map_info_force_render'].set(True)
|
| 396 |
|
| 397 |
def landuse_colors(feature):
|
| 398 |
+
#print(feature)
|
| 399 |
luf_type = feature['properties']['luf']
|
| 400 |
if luf_type == 'RESIDENTIAL (HIGH DENSITY)':
|
| 401 |
luf_color = {
|
|
|
|
| 465 |
return luf_color
|
| 466 |
|
| 467 |
def power_node_colors(feature):
|
| 468 |
+
#print(feature)
|
| 469 |
ds_to_color = {0: 'lavender', 1:'violet',2:'fuchsia',3:'indigo',4:'darkslateblue',5:'black'}
|
| 470 |
ds = random.randint(0,5) #feature['properties']['ds']
|
| 471 |
return {'color': ds_to_color[ds], 'fillColor': ds_to_color[ds]}
|
|
|
|
| 488 |
im_col = 'pga' if 'pga' in df.columns else 'im'
|
| 489 |
df_limited = df.sort_values(by=im_col,ascending=False).head(500_000)
|
| 490 |
locs = np.array([df_limited.geometry.y.to_list(), df_limited.geometry.x.to_list(), df_limited[im_col].to_list()]).transpose().tolist()
|
| 491 |
+
map_layer = ipyleaflet.Heatmap(locations=locs, radius = 5)
|
| 492 |
elif name == "landuse":
|
| 493 |
map_layer = ipyleaflet.GeoJSON(data = json.loads(df.to_json()),
|
| 494 |
style={'opacity': 1, 'dashArray': '9', 'fillOpacity': 0.5, 'weight': 1},
|
|
|
|
| 1070 |
household['hospital_access'] = list(household_hospital_access)
|
| 1071 |
individual['facility_access'] = list(individual_facility_access)
|
| 1072 |
|
| 1073 |
+
#print(buildings.head())
|
| 1074 |
print('number of damaged roads/bridges',len(edges[edges['is_damaged']]))
|
| 1075 |
|
| 1076 |
return edges, buildings, household, individual
|
|
|
|
| 1122 |
|
| 1123 |
buildings_freqincome = buildings[['bldid']].merge(freqincome,on='bldid',how='left')
|
| 1124 |
buildings['freqincome'] = buildings_freqincome['freqincome']
|
| 1125 |
+
#print('policies',policies)
|
| 1126 |
if layers.value['hazard'].value == 'landslide':
|
| 1127 |
fragility = layers.value['layers']['landslide fragility']['data'].value
|
| 1128 |
intensity = layers.value['layers']['landslide susceptibility']['data'].value
|
|
|
|
| 1328 |
@solara.component
|
| 1329 |
def ImportDataZone():
|
| 1330 |
def s3_file_open(p):
|
| 1331 |
+
#print(p)
|
| 1332 |
storage.value.s3.download_file(storage.value.bucket_name, str(p)[1:], f'/tmp/aws.tmp')
|
| 1333 |
|
| 1334 |
with open(f'/tmp/aws.tmp', 'rb') as fileObj:
|