Skip to content

Commit d2987a6

Browse files
committed
Merge pull request #1 from nrferguson/linkshape
reorder vertices on reverse links
2 parents 1a3e0ab + bb8d05c commit d2987a6

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

linkshape.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
''' LINKSHAPE.PY
22
Nick Ferguson
33
Created 07/16/2013
4-
Last Revised --/--/----
4+
Last Revised 02/25/2016
55
66
PURPOSE:
77
This module is called by
88
create_scenario_files_GTFS.py to create
99
link shape batchin files for each scenario
1010
1111
REVISIONS:
12-
-
12+
- NRF 02/25/2016: Added a sort to the write_vertices function to solve a batchin problem
13+
related to reverse direction vertices being listed in order from last to first. Emme expects
14+
them to be ordered from first to last.
1315
1416
----------------------------------------------------------------------------'''
1517
# -----------------------------------------------------------------------------
@@ -50,6 +52,16 @@ def write_vertices(in_arcs, out_vertices): # parameters: (arc feature class [
5052
f += 1
5153

5254
arcpy.AddMessage("---> Vertices Written for " + str(f) + " Arcs")
55+
56+
with open(out_vertices, 'rb') as vrtxfile:
57+
vrtxcsv = csv.reader(vrtxfile, delimiter = ',')
58+
for col in (2, 1, 0):
59+
vrtxcsv = sorted(vrtxcsv, key = lambda row: int(row[col])) # results in records sorted by from node, then by to node, then by vertex order
60+
61+
with open(out_vertices, 'wb') as vrtxfile:
62+
vrtxwriter = csv.writer(vrtxfile)
63+
for row in vrtxcsv:
64+
vrtxwriter.writerow([row[0], row[1], row[2], row[3], row[4]]) # overwrite vertex file with sorted records
5365

5466
# -----------------------------------------------------------------------------
5567
# Create Link Shape File

0 commit comments

Comments
 (0)