Skip to content

Commit

Permalink
metcouncil .lin file update
Browse files Browse the repository at this point in the history
  • Loading branch information
i-am-sijia committed Apr 14, 2021
1 parent fc51e00 commit 62f4f56
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lasso/transit.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,7 @@ def write_as_cube_lin(self, outpath: str = None):
trip_cube_df["LIN"] = trip_cube_df.apply(self.cube_format, axis=1)

l = trip_cube_df["LIN"].tolist()
l = [";;<<PT>><<LINE>>;;"] + l

with open(outpath, "w") as f:
f.write("\n".join(l))
Expand Down Expand Up @@ -978,24 +979,26 @@ def route_properties_gtfs_to_cube(self):
trip_df["shp_id"] = trip_df["shp_id"].astype(str)
trip_df["shp_id"] = "shp" + trip_df["shp_id"]

trip_df["route_short_name"] = trip_df["route_short_name"].str.replace("-", "_").str.replace(" ", ".").str.replace(",", "_").str.slice(stop = 50)

trip_df["route_long_name"] = trip_df["route_long_name"].str.replace(",", "_").str.slice(stop = 50)

trip_df["NAME"] = trip_df.apply(
lambda x: x.agency_id
+ "_"
+ x.route_id
+ "_"
+ x.route_short_name
+ "_"
+ x.tod_name
+ "_"
+ "dir"
+ "d"
+ str(x.direction_id)
+ "_"
+ x.shp_id,
+ "_s"
+ x.shape_id,
axis=1,
)

# CUBE max string length
trip_df["NAME"] = trip_df["NAME"].str.slice(stop = 30)
trip_df["NAME"] = trip_df["NAME"].str.slice(stop = 28)

trip_df["LONGNAME"] = trip_df["route_long_name"]
# CUBE max string length
Expand All @@ -1005,6 +1008,7 @@ def route_properties_gtfs_to_cube(self):
trip_df["MODE"] = trip_df.apply(self.calculate_cube_mode, axis=1)
trip_df["ONEWAY"] = "T"
trip_df["OPERATOR"] = trip_df["agency_id"].map(metro_operator_dict)
trip_df["SHORTNAME"] = trip_df["route_short_name"].str.slice(stop = 30)

return trip_df

Expand Down Expand Up @@ -1183,6 +1187,7 @@ def cube_format(self, row):
s += "\n MODE={},".format(row.MODE)
s += "\n ONEWAY={},".format(row.ONEWAY)
s += "\n OPERATOR={},".format(row.OPERATOR)
s += '\n SHORTNAME="{}",'.format(row.SHORTNAME)
s += "\n NODES={}".format(self.shape_gtfs_to_cube(row))

return s
Expand Down

0 comments on commit 62f4f56

Please sign in to comment.