Skip to content

Commit

Permalink
add X, Y to new node properties, add new node id to crosswalk
Browse files Browse the repository at this point in the history
  • Loading branch information
yueshuaing committed Oct 13, 2023
1 parent 35abe28 commit 0e668f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
7 changes: 7 additions & 0 deletions lasso/parameters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pyproj
from .logger import WranglerLogger


Expand Down Expand Up @@ -937,4 +938,10 @@ def __init__(self, **kwargs):

self.drive_buffer = 6

self.network_build_crs = CRS("EPSG:2875")
self.project_card_crs = CRS("EPSG:4326")
self.transformer = pyproj.Transformer.from_crs(
self.network_build_crs, self.project_card_crs, always_xy=True
)

self.__dict__.update(kwargs)
23 changes: 19 additions & 4 deletions lasso/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,16 @@ def emme_id_to_wrangler_id(emme_link_change_df, emme_node_change_df, emme_transi

# add crosswalk for new emme nodes
for new_emme_node in new_emme_node_id_list:
new_wrangler_node = new_wrangler_node + 1
emme_node_id_dict.update({new_emme_node : new_wrangler_node})

if new_emme_node in emme_node_id_dict.keys():
msg = "new node id {} has already been added to the crosswalk".format(new_emme_node)
WranglerLogger.error(msg)
raise ValueError(msg)
else:
new_wrangler_node = new_wrangler_node + 1
emme_node_id_dict.update({new_emme_node : new_wrangler_node})
new_emme_node_id_crosswalk_df = pd.DataFrame(emme_node_id_dict.items(), columns=['emme_node_id', 'model_node_id'])
new_emme_node_id_crosswalk_df.to_csv(emme_node_id_crosswalk_file, index=False)

# for nodes update model_node_id
emme_node_change_df['model_node_id'] = emme_node_change_df['emme_id'].map(emme_node_id_dict).fillna(0)

Expand Down Expand Up @@ -873,7 +880,7 @@ def determine_roadway_network_changes_compatibility(
roadway_link_changes.rename(columns=dbf_to_net_dict, inplace=True)

for c in roadway_node_changes.columns:
if (c not in log_to_net_df["log"].tolist() + log_to_net_df["net"].tolist()) & (c not in ["A", "B"]):
if (c not in log_to_net_df["log"].tolist() + log_to_net_df["net"].tolist()) & (c not in ["A", "B", "X", "Y"]):
roadway_node_changes.rename(columns={c : c.lower()}, inplace=True)
roadway_node_changes.rename(columns=log_to_net_dict, inplace=True)
roadway_node_changes.rename(columns=dbf_to_net_dict, inplace=True)
Expand Down Expand Up @@ -1083,6 +1090,8 @@ def _process_node_additions(node_add_df):

node_add_df = node_add_df.drop(["operation_final"], axis=1)

node_add_df = node_add_df.apply(_reproject_coordinates, axis=1)

for x in node_add_df.columns:
node_add_df[x] = node_add_df[x].astype(self.base_roadway_network.nodes_df[x].dtype)

Expand All @@ -1093,6 +1102,12 @@ def _process_node_additions(node_add_df):

return add_nodes_dict_list

def _reproject_coordinates(row):
reprojected_x, reprojected_y = self.parameters.transformer.transform(row['X'], row['Y'])
row['X'] = reprojected_x
row['Y'] = reprojected_y
return row

def _process_single_link_change(change_row, changeable_col):
""""""

Expand Down

0 comments on commit 0e668f8

Please sign in to comment.