Skip to content

Commit cdcfcdd

Browse files
authored
Merge pull request #25 from nrferguson/master
c17q3 changes and fixes
2 parents 345765c + 7e5b551 commit cdcfcdd

9 files changed

Lines changed: 139 additions & 30 deletions

Rail Network Management.tbx

-2 KB
Binary file not shown.

apply_future_rail_actions.sas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ filename inrte "&inpath.\Temp\rte_out.txt";
7878
data a2rpt(keep=descr ln reduc); set a2rpt(where=(layover='99'));
7979
ln=substr(tr_line,1,3);
8080
reduc=trv_time*100;
81-
proc sort data=a2rpt nodupkey; by ln;
81+
proc sort data=a2rpt nodupkey; by descr;
8282
data __null__; set a2rpt;
8383
file "&reportpath" mod;
8484
put "--> " descr ": reduced " ln "travel time along entire line by " reduc "percent";

create_Emme_rail_files_GTFS.sas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ________________________________________________________________________________
2929
%let reportpath=&outpath.\&scen.00\rail_changes.txt;
3030
%let maxzone=1961; *** highest zn09 POE zone number;
3131
%let dropnode=48007; *** Exclude South Bend station until zone system expands to include it;
32-
%let basescen=200; *** base year scenario;
32+
%let basescen=100; *** base year scenario;
3333
%let counter=1;
3434
%let tod=0;
3535
%let a1=0;%let a2=0;%let a3=0;%let a4=0;%let a5=0;%let a7=0; *** initialize action code counts;
@@ -72,7 +72,7 @@ data __null__;
7272
put "--> removed scenario = " scenario "people mover link anode = " anode "bnode = " bnode "from network";
7373

7474
*---------------------------------------------------------------*;
75-
*** READ IN FUTURE CODING DATA FOR SCENARIOS 200 - 600 ***;
75+
*** READ IN FUTURE CODING DATA FOR SCENARIOS 200 - 700 ***;
7676
*---------------------------------------------------------------*;
7777
%macro future;
7878
%if &sc>&basescen %then %do;
@@ -223,7 +223,7 @@ run;
223223

224224
* - - - - - - - - - - - - - - - - - - - - - - - - - - *;
225225
**VERIFY THAT ITINERARIES DO NOT STOP AT JUNCTIONS**;
226-
data check; set combine(where=(((itin_b>38999 & itin_b<40000) | (itin_b>48999 & itin_b<50000)) & dw_code=0));
226+
data check; set combine(where=(((itin_b>39000 & itin_b<40000) | (itin_b>49000 & itin_b<50000)) & dw_code=0));
227227
proc print; title "NETWORK &scen.00 ITINERARY SEGMENTS THAT STOP AT A JUNCTION";
228228
* - - - - - - - - - - - - - - - - - - - - - - - - - - *;
229229

create_scenario_files_GTFS.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@
3333

3434
##======================================================================##
3535

36-
## scenario options: beginning with c10q3
36+
## scenario options: beginning with c17q3
3737
## --------------------------------------
38-
## 100 - 2010 network
39-
## 200 - 2015 network
40-
## 300 - 2020 network
41-
## 400 - 2025 network
42-
## 500 - 2030 network
38+
## 100 - 2015 network
39+
## 200 - 2020 network
40+
## 300 - 2025 network
41+
## 400 - 2030 network
42+
## 500 - 2035 network
4343
## 600 - 2040 network
44+
## 700 - 2050 network
4445

4546
##======================================================================##
4647

@@ -66,7 +67,7 @@
6667
f = string.replace(c, "\\", '/') + "/mrn_programs"
6768
newdir = path + "\\" + scenario
6869
current = "all_runs" # current routes
69-
if scenario in ("200","900"):
70+
if scenario in ("100","900"):
7071
current = "all_runs_base" # base year routes
7172
future = "future" # future coding
7273
rail_routes = current

geometry_update.sas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
2626
- SECTION 5 - Creates final files for input into geodatabase.
2727
28-
28+
NRF revised 5-30-2017 to take future routes .dbf as parameter.
2929
__________________________________________________________________________________________________________________________ */
3030

3131
%let dir=%scan(&sysparm,1,$); ***shapefile storage directory;
@@ -34,6 +34,7 @@ ________________________________________________________________________________
3434
%let code=%scan(&sysparm,4,$); ***choice flag for Section 3 processing;
3535
%let segfile=%scan(&sysparm,5,$); ***name of GTFS segment file (entire path);
3636
%let use900=%scan(&sysparm,6,$); ***use new station itinerary during GTFS import;
37+
%let origfrts=%scan(&sysparm,7,$); ***original future routes .dbf file (entire path);
3738

3839

3940
%let tot=0;

itinerary_node_update_Aug2012.sas

Lines changed: 102 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
NRF 5/30/2017 - corrected future it_order overwrite issue using action codes to inform future it_order after split link.
3+
NRF 6/2/2017 - corrected error in rebuilding future route geo. was not using node ID of 0 to find coordinates for new node.
4+
NRF 6/23/2017 - corrected error in rebuiding future route geo. new node coordinates were being used to apply node ids to
5+
route geo based on original node coordinates when node is moved.
6+
*/
17
*================================================================*;
28
*** UPDATE ITINERARY TO REFLECT SPLIT LINKS W/ TEMPORARY ANODE-BNODE VALUES (ONLY IF NEW_MILE.DBF EXISTS) ***;
39
*================================================================*;
@@ -123,14 +129,93 @@ filename delndf "&dir.\Temp\deleted_node.dbf";
123129
* --> put all itinerary coding back together *;
124130
proc summary nway data=fix1; class tr_line it_order; output out=y1;
125131
data fix; merge fix y1 (in=hit); by tr_line it_order; if hit then delete;
126-
data good(drop=_type_ _freq_ it_order); set ok fix fix1; proc sort; by tr_line f_meas;
127-
data good; set good; group=lag(tr_line);
128-
data good(drop=group); set good;
129-
retain it_order 1;
130-
it_order+1;
131-
if tr_line ne group then it_order=1;
132-
output;
133-
proc sort; by itin_a itin_b;
132+
data good(drop=_type_ _freq_ it_order); set ok fix fix1; proc sort; by tr_line f_meas;
133+
%if %index(&origitin,future) %then %do; *rewrite future it_order according to action codes;
134+
proc import datafile="&origfrts" dbms=dbf out=frts replace;
135+
proc sort;
136+
by tr_line;
137+
run;
138+
data actcodes(keep=tr_line action);
139+
set frts;
140+
run;
141+
data good;
142+
merge good(in=hit) actcodes;
143+
by tr_line;
144+
if hit;
145+
run;
146+
data act1 act2 act3;
147+
set good;
148+
if action in (1,5) then output act1;
149+
else if action=4 then output act2;
150+
else output act3;
151+
run;
152+
data act1;
153+
set act1;
154+
group=lag(tr_line);
155+
run;
156+
data act1(drop=group);
157+
set act1;
158+
retain it_order 1;
159+
it_order+1;
160+
if tr_line ne group then it_order=1;
161+
output;
162+
run;
163+
proc sql;
164+
create table y3 as
165+
select tr_line, count(tr_line) as itincnt
166+
from act2
167+
group by tr_line;
168+
quit;
169+
data act2;
170+
merge act2(in=hit) y3;
171+
by tr_line;
172+
if hit;
173+
run;
174+
data act2(drop=itincnt n i);
175+
set act2;
176+
by tr_line f_meas;
177+
retain n i;
178+
if first.tr_line then do;
179+
n=itincnt;
180+
i=itincnt+(itincnt/2);
181+
end;
182+
if i>n then do;
183+
it_order=n-i;
184+
i=i-1;
185+
end;
186+
if i<n then do;
187+
it_order=(n-i)+1000;
188+
i=i-1;
189+
end;
190+
if i=n then i=i-1;
191+
run;
192+
data act3;
193+
set act3;
194+
it_order=0;
195+
run;
196+
data good(drop=action);
197+
set act1 act2 act3;
198+
run;
199+
proc sort;
200+
by itin_a itin_b;
201+
run;
202+
%end;
203+
%else %do;
204+
data good;
205+
set good;
206+
group=lag(tr_line);
207+
run;
208+
data good(drop=group);
209+
set good;
210+
retain it_order 1;
211+
it_order+1;
212+
if tr_line ne group then it_order=1;
213+
output;
214+
run;
215+
proc sort;
216+
by itin_a itin_b;
217+
run;
218+
%end;
134219

135220
data goodout;
136221
set good;
@@ -285,16 +370,18 @@ filename delndf "&dir.\Temp\deleted_node.dbf";
285370
input line_num tr_line $ x y m;
286371

287372
proc import datafile="&dir.\Temp\new_node.dbf" out=rail_nodes replace;
288-
data rail_nodes(keep=node point_x point_y); set rail_nodes;
289-
data rail_nodes(drop=point_x point_y); set rail_nodes;
373+
data rail_nodes(keep=node point_x point_y point_x0 point_y0); set rail_nodes;
374+
data rail_nodes(drop=point_x point_y point_x0 point_y0); set rail_nodes;
290375
x=point_x;
291-
y=point_y;
376+
y=point_y;
377+
x0=point_x0;
378+
y0=point_y0;run;
292379

293380
proc sql noprint;
294381
create table rte_nodes as
295-
select rte_geo.line_num,rte_geo.tr_line,rte_geo.x,rte_geo.y,rte_geo.m,rail_nodes.node
382+
select rte_geo.line_num,rte_geo.tr_line,rail_nodes.x,rail_nodes.y,rte_geo.m,rail_nodes.node
296383
from rte_geo,rail_nodes
297-
where rte_geo.x=rail_nodes.x & rte_geo.y=rail_nodes.y;
384+
where rte_geo.x=rail_nodes.x0 & rte_geo.y=rail_nodes.y0;
298385
proc sort data=rte_nodes;
299386
by line_num m;
300387

@@ -309,6 +396,8 @@ filename delndf "&dir.\Temp\deleted_node.dbf";
309396
set tmpnode;
310397
itin_a=anode;
311398
itin_b=bnode;
399+
if tempa>90000 then itin_a=0;
400+
if tempb>90000 then itin_b=0;
312401

313402
proc sort data=rte_itin;
314403
by itin_a itin_b;

update_network_edits_Aug2012.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
# replaced by more efficient Search and Update cursor code. #
2626
# 01-23-2012: y2 variable for cmd2 re-written for new required parameters.#
2727
# 08-07-2012: Revised to iterate through & update all route systems. #
28+
# 05-30-2017: revised to pass future route action codes to SAS for #
29+
# processing split links. #
30+
# 06-23-2017: revised to remove point_x0 and point_y0 fields from final #
31+
# node feature class. #
2832
# #
2933
#############################################################################
3034

@@ -183,6 +187,7 @@
183187
arcpy.AddMessage("---> Updating Node Feature Class")
184188
arcpy.MakeXYEventLayer_management(new_node_dbf, "point_x", "point_y", temp_node_Layer, "PROJCS['NAD_1927_StatePlane_Illinois_East_FIPS_1201',GEOGCS['GCS_North_American_1927',DATUM['D_North_American_1927',SPHEROID['Clarke_1866',6378206.4,294.9786982]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-88.33333333333333],PARAMETER['Scale_Factor',0.999975],PARAMETER['Latitude_Of_Origin',36.66666666666666],UNIT['Foot_US',0.3048006096012192]];IsHighPrecision")
185189
arcpy.FeatureClassToFeatureClass_conversion(temp_node_Layer, mrn_gdb, "temp")
190+
arcpy.DeleteField_management(temp, ["point_x0", "point_y0"])
186191
arcpy.SelectLayerByAttribute_management(railnet_node, "CLEAR_SELECTION", "")
187192
arcpy.DeleteRows_management(railnet_node)
188193
arcpy.Append_management(temp, railnet_node, "TEST", "", "")
@@ -237,11 +242,13 @@
237242
env.workspace = "V:/Secure/Master_Rail/mrn.gdb/railnet" ## point inside feature dataset
238243
fcs = arcpy.ListFeatureClasses('',"arc")
239244
fcs.remove("railnet_arc")
245+
240246
i = 0
241247
for fc in fcs:
242248
arcpy.AddMessage("---> Updating Geometry for " + fcs[i] + " Route System ...")
243249
itinerary = d + "\\mrn.gdb\\" + fc + "_itin"
244250
orig_itinerary_dbf = d + "\\" + fc + "_itin_" + x1 + ".dbf"
251+
orig_future_routes_dbf = d + "\\future_routes_" + x1 + ".dbf"
245252
## Store copy of current itinerary coding for safekeeping ##
246253
if os.path.exists(orig_itinerary_dbf):
247254
arcpy.Delete_management(orig_itinerary_dbf, "DbaseTable")
@@ -255,6 +262,9 @@
255262
arcpy.SelectLayerByAttribute_management(rail_lines, "CLEAR_SELECTION", "")
256263
arcpy.FeatureClassToFeatureClass_conversion(rail_lines, e, "temp_route.shp", "", "", "")
257264
if fc == "future":
265+
if os.path.exists(orig_future_routes_dbf):
266+
arcpy.Delete_management(orig_future_routes_dbf, "DbaseTable")
267+
arcpy.TableSelect_analysis(railrt, orig_future_routes_dbf, "\"OBJECTID\" >= 1")
258268
outFile = open(outRtFl, "w")
259269
f = 1 # row id number
260270
for row in arcpy.SearchCursor(railrt): # loop through rows (features)
@@ -272,14 +282,14 @@
272282

273283
## Run SAS to Update Itineraries ##
274284
# -- finish set up to run SAS
275-
y2 = c + "$" + orig_itinerary_dbf + "$X$3$X"
285+
y2 = c + "$" + orig_itinerary_dbf + "$X$3$X$X$" + orig_future_routes_dbf
276286
cmd2 = [ bat, z2, y2, sas_log_file2, sas_list_file2 ]
277287
subprocess.call(cmd2)
278288
if os.path.exists(sas_list_file2):
279289
arcpy.AddMessage("---> SAS Processing Error!! Review the List File: " + sas_list_file2)
280290
arcpy.AddMessage("---> If there is an Errorlevel Message, Review the Log File: " + sas_log_file2)
281291
arcpy.AddMessage("-------------------------------------------------------------------")
282-
sys.exit([1])
292+
sys.exit([1])
283293

284294

285295
## << Part 3a: Create Routes with Updated Geometry >> ##

update_nodes.sas

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
3. new nodes due to added link - new XY coordinates will be calculated automatically, will need node number
1414
4. new nodes due to split links - extra processing required to determine which node(s) are new because arc
1515
table will show duplicate entries of original link with anode & bnode values.
16-
*/
16+
17+
6/23/17 NRF: revised to retain original coordinates (point_x0, point_y0) in new_node.dbf for use when rebuilding route geo.
18+
*/
1719

1820

1921
%let tot=0;
@@ -115,13 +117,13 @@ proc sort data=keepnodes; by node;
115117

116118
*** READ IN CURRENT NODE DATA AND ATTACH ATTRIBUTE DATA TO NEW NODE DATASET ***;
117119
proc import datafile="&dir.\Temp\temp_node.dbf" out=c replace;
118-
data c(drop=point_x point_y); set c; proc sort; by node;
120+
data c(rename=(point_x=point_x0 point_y=point_y0)); set c; proc sort; by node;
119121
data keepnodes(drop=_type_ _freq_); merge keepnodes (in=hit) c; by node; if hit;
120122
if pspace=. then pspace=0; if pcost=. then pcost=0;
121123

122124

123125
*** RE-ORDER VARIABLES TO MATCH FEATURE CLASS ORDER ***;
124-
data final; retain node label pspace pcost ftr_pspace ftr_pcost point_x point_y; set keepnodes;
126+
data final; retain node label pspace pcost ftr_pspace ftr_pcost point_x point_y point_x0 point_y0; set keepnodes;
125127

126128
proc export data=final outfile="&dir.\Temp\new_node.dbf" dbms=dbf replace;
127129

update_split_itinerary_Aug2012.sas

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Craig Heither, revised 08/07/2012
33
44
Program updates the values of itin_a and itin_b in the itinerary coding for rail routes whose links have been split.
5+
6+
NRF 6/2/2017 - added logic to set dwell code and dwell time in itin as no stop if node ID represents junction.
57
68
*/
79

@@ -38,6 +40,10 @@ data a(drop=c newc); set a;
3840
data itin(drop=newa newb); merge x (in=hit) a; by itin_a itin_b; if hit;
3941
if newa>0 then itin_a=newa;
4042
if newb>0 then itin_b=newb;
43+
if not(index(tr_line,'*')) and (39000<itin_b<40000 or 49000<itin_b<50000) then do;
44+
dw_code=1;
45+
dw_time=0;
46+
end;
4147
proc sort; by tr_line it_order;
4248

4349
*** RE-ORDER VARIABLES ***;

0 commit comments

Comments
 (0)