From 32384c253e8f6511872d737bc4e1de21d30cb75d Mon Sep 17 00:00:00 2001 From: Sharon Fitzpatrick Date: Wed, 25 Oct 2023 22:58:59 -0700 Subject: [PATCH] #198 load shorelines even if date col already str --- src/coastseg/coastseg_map.py | 21 +++++++++++++++++---- src/coastseg/common.py | 1 - 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/coastseg/coastseg_map.py b/src/coastseg/coastseg_map.py index 06f2c749..baa2506d 100644 --- a/src/coastseg/coastseg_map.py +++ b/src/coastseg/coastseg_map.py @@ -2280,13 +2280,26 @@ def update_loadable_shorelines(self, selected_id: str): # if extracted shorelines exist, load them onto map, if none exist nothing loads if hasattr(extracted_shorelines, "gdf"): if not extracted_shorelines.gdf.empty: - self.extract_shorelines_container.load_list = ( - extracted_shorelines.gdf["satname"] - + "_" - + extracted_shorelines.gdf["date"].apply( + if extracted_shorelines.gdf["date"].dtype == "object": + # If the "date" column is already of string type, concatenate directly + formatted_dates = extracted_shorelines.gdf["date"] + else: + # If the "date" column is not of string type, convert to string with the required format + formatted_dates = extracted_shorelines.gdf["date"].apply( lambda x: x.strftime("%Y-%m-%d %H:%M:%S") ) + + self.extract_shorelines_container.load_list = ( + extracted_shorelines.gdf["satname"] + "_" + formatted_dates ).tolist() + # if not extracted_shorelines.gdf.empty: + # self.extract_shorelines_container.load_list = ( + # extracted_shorelines.gdf["satname"] + # + "_" + # + extracted_shorelines.gdf["date"].apply( + # lambda x: x.strftime("%Y-%m-%d %H:%M:%S") + # ) + # ).tolist() else: return None return extracted_shorelines diff --git a/src/coastseg/common.py b/src/coastseg/common.py index 5e77565c..00d0d267 100644 --- a/src/coastseg/common.py +++ b/src/coastseg/common.py @@ -219,7 +219,6 @@ def update_extracted_shorelines_dict_transects_dict( selected_indexes = get_selected_indexes( extracted_shorelines_dict, dates_list, sat_list ) - print("selected_indexes", selected_indexes) # attempt to delete the selected indexes from the "transect_cross_distances.json" transect_cross_distances_path = os.path.join( session_path, "transects_cross_distances.json"