Skip to content

Commit 5db031a

Browse files
authored
Merge pull request #1293 from cal-itp/deploy-new-speedmaps
new parameterized speedmaps!
2 parents bb10d51 + ec8c100 commit 5db031a

File tree

12 files changed

+570
-709
lines changed

12 files changed

+570
-709
lines changed

_shared_utils/shared_utils/rt_utils.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,12 @@ def get_operators(analysis_date, operator_list, verbose=False):
828828

829829

830830
def spa_map_export_link(
831-
gdf: gpd.GeoDataFrame, path: str, state: dict, site: str = SPA_MAP_SITE, cache_seconds: int = 3600
831+
gdf: gpd.GeoDataFrame,
832+
path: str,
833+
state: dict,
834+
site: str = SPA_MAP_SITE,
835+
cache_seconds: int = 3600,
836+
verbose: bool = False,
832837
):
833838
"""
834839
Called via set_state_export. Handles stream writing of gzipped geojson to GCS bucket,
@@ -837,7 +842,8 @@ def spa_map_export_link(
837842
assert cache_seconds in range(3601), "cache must be 0-3600 seconds"
838843
geojson_str = gdf.to_json()
839844
geojson_bytes = geojson_str.encode("utf-8")
840-
print(f"writing to {path}")
845+
if verbose:
846+
print(f"writing to {path}")
841847
with fs.open(path, "wb") as writer: # write out to public-facing GCS?
842848
with gzip.GzipFile(fileobj=writer, mode="w") as gz:
843849
gz.write(geojson_bytes)
@@ -853,7 +859,14 @@ def set_state_export(
853859
bucket: str = SPA_MAP_BUCKET,
854860
subfolder: str = "testing/",
855861
filename: str = "test2",
856-
map_type: Literal["speedmap", "speed_variation", "hqta_areas", "hqta_stops", "state_highway_network"] = None,
862+
map_type: Literal[
863+
"speedmap",
864+
"speed_variation",
865+
"new_speedmap",
866+
"new_speed_variation" "hqta_areas",
867+
"hqta_stops",
868+
"state_highway_network",
869+
] = None,
857870
map_title: str = "Map",
858871
cmap: branca.colormap.ColorMap = None,
859872
color_col: str = None,
@@ -890,7 +903,7 @@ def set_state_export(
890903
]
891904
if map_type:
892905
this_layer[0]["type"] = map_type
893-
if map_type == "speedmap":
906+
if map_type in ["new_speedmap", "speedmap"]:
894907
this_layer[0]["properties"]["tooltip_speed_key"] = "p20_mph"
895908
spa_map_state["layers"] += this_layer
896909
if manual_centroid:

0 commit comments

Comments
 (0)