Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

holy week sched for PNR #4

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
42 changes: 18 additions & 24 deletions build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,23 @@
require 'rexml/document'
require 'net/http'

prefix = 'MSC'
stations = 1..26
$route_id = 'MSC'
stations = 1..34
$service_id = 'EVERYDAY'

# STOPS

stop_list = CSV.read("stops.csv")
stops = CSV.open("gtfs/stops.txt", "wb")

stops << ["stop_id", "stop_name", "stop_lat", "stop_lon", "zone_id", "location_type", "parent_station"]
stops << ["stop_id", "stop_name", "stop_lat", "stop_lon", "zone_id"]

stations.each do |i|
stop_id = stop_list[i][1]
stop_name = stop_list[i][0]
stop_id = stop_list[i][1]
stop_lat = stop_list[i][2]
stop_lng = stop_list[i][3]
exit_lat = stop_list[i][4]
exit_lng = stop_list[i][5]

if exit_lat == nil && exit_lng == nil
stops << [stop_id, stop_name+" PNR", stop_lat, stop_lng, stop_id, 0, nil]
else
stops << [stop_id+'_STATION', stop_name+" PNR", stop_lat, stop_lng, stop_id, 1, nil]
stops << [stop_id, stop_name+" PNR", stop_lat, stop_lng, stop_id, 0, stop_id+'_STATION']
stops << [stop_id+'_EXIT', stop_name+" PNR", exit_lat, exit_lng, stop_id, 2, stop_id+'_STATION']
end
stops << [stop_id, stop_name+" PNR", stop_lat, stop_lng, stop_id]
end

# TIMETABLE
Expand Down Expand Up @@ -58,10 +48,10 @@ def parse_trip(timetable, i, dir)
.drop(2)
.reject { |r| r[i] == nil }
.each.with_index do |r, index|
last_stop_name = r[0]
stop_id = r[1]
arrival_time = r[i]
departure_time = r[i+1]
last_stop_name = r[0]
departure_time = r[i]
$stop_times << [trip_id, index+1, stop_id, arrival_time, departure_time]
end
dir_expanded = case dir
Expand All @@ -72,8 +62,9 @@ def parse_trip(timetable, i, dir)
else
''
end
headsign = $route_id+' to '+last_stop_name+' ('+dir_expanded+')'
$trips << [trip_id, $route_id, $service_id, dir, headsign]
route_id = trip_id[/\w+/]
headsign = route_id+' to '+last_stop_name+' ('+dir_expanded+')'
$trips << [trip_id, route_id, $service_id, dir, headsign]
end

parse_timetable(timetable_nb, 'NB')
Expand All @@ -89,12 +80,14 @@ def parse_trip(timetable, i, dir)
fare_attributes << ["fare_id", "price", "currency_type", "payment_method", "transfers"]

stations.each do |i|
break if fare_table[i+1] == nil
from_code = fare_table[i+1][1]
stations.each do |j|
break if fare_table[j+1] == nil
to_code = fare_table[1][j+1]
if i != j
fare = fare_table[i+1][j+1]
fare_id = sprintf("%s-%s-%s", prefix, from_code, to_code)
fare_id = sprintf("%s-%s", from_code, to_code)

fare_rules << [fare_id, from_code, to_code]
fare_attributes << [fare_id, fare, "PHP", 1, 0]
Expand Down Expand Up @@ -138,10 +131,10 @@ def parse_shape_xml(doc)
coords
end

def fetch_shape(name)
def fetch_shape(route_id, rel_name)
uri = URI('http://overpass-api.de/api/interpreter')
query = <<EOF
rel["name"="#{name}"];
rel["name"="#{rel_name}"];
(._; way(r));
(._; node(w));
out;
Expand All @@ -150,14 +143,15 @@ def fetch_shape(name)
if res.is_a?(Net::HTTPSuccess)
coords = parse_shape_xml(res.body)
coords.each.with_index do |coord, index|
$shapes << ['SB', coord[1], coord[0], index]
$shapes << [route_id + ' SB', coord[1], coord[0], index]
end
coords.reverse.each.with_index do |coord, index|
$shapes << ['NB', coord[1], coord[0], index]
$shapes << [route_id + ' NB', coord[1], coord[0], index]
end
else
puts "Failed to get shape data"
end
end

fetch_shape('PNR Metro Commuter Line : Tutuban - Calamba')
fetch_shape('MSC', 'PNR Metro Commuter Line : Tutuban - Calamba')
fetch_shape('MNC', 'PNR Shuttle Service Line: Governor Pascual - FTI')
54 changes: 26 additions & 28 deletions fares.csv
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
,,Tutuban,Blumentritt,"Laon Laan",España,"Sta. Mesa",Pandacan,Paco,"San Andres","Vito Cruz",Buendia,"Pasay Road",EDSA,Nichols,FTI,Bicutan,Sucat,Alabang,Muntinlupa,"San Pedro","Pacita Main Gate","Golden City 1",Biñan,"Sta. Rosa",Cabuyao,Mamatid,Calamba
,,TU,BLU,LLN,SPÑ,SA,PD,PC,SAN,VTC,DIA,PRD,EDS,NIC,FTI,BIC,SU,AA,MP,SPL,PMG,GC1,ÑA,SRL,AO,TD,LA
Tutuban,TU,0,15,15,15,15,15,15,15,15,15,15,15,20,20,20,25,30,35,40,40,40,45,45,50,55,60
Blumentritt,BLU,15,0,15,15,15,15,15,15,15,15,15,15,15,15,20,25,30,30,35,35,40,40,45,50,55,55
"Laon Laan",LLN,15,15,0,15,15,15,15,15,15,15,15,15,15,15,20,25,25,30,35,35,35,40,45,45,55,55
España,SPÑ,15,15,15,0,15,15,15,15,15,15,15,15,15,15,20,20,25,30,35,35,35,40,40,45,50,55
"Sta. Mesa",SA,15,15,15,15,0,15,15,15,15,15,15,15,15,15,15,20,25,25,30,35,35,35,40,45,50,55
Pandacan,PD,15,15,15,15,15,0,15,15,15,15,15,15,15,15,15,20,20,25,30,30,35,35,40,40,50,50
Paco,PC,15,15,15,15,15,15,0,15,15,15,15,15,15,15,15,15,20,25,30,30,30,30,35,40,45,50
"San Andres",SAN,15,15,15,15,15,15,15,0,15,15,15,15,15,15,15,15,20,25,25,30,30,30,35,40,45,50
"Vito Cruz",VTC,15,15,15,15,15,15,15,15,0,15,15,15,15,15,15,15,20,20,25,30,30,30,35,40,45,50
Buendia,DIA,15,15,15,15,15,15,15,15,15,0,15,15,15,15,15,15,20,20,25,25,30,30,35,40,45,45
"Pasay Road",PRD,15,15,15,15,15,15,15,15,15,15,0,15,15,15,15,15,15,20,25,25,25,30,35,35,45,45
EDSA,EDS,15,15,15,15,15,15,15,15,15,15,15,0,15,15,15,15,15,20,25,25,25,25,30,35,40,45
Nichols,NIC,20,15,15,15,15,15,15,15,15,15,15,15,0,15,15,15,15,15,20,20,20,25,30,30,40,40
FTI,FTI,20,15,15,15,15,15,15,15,15,15,15,15,15,0,15,15,15,15,20,20,20,25,25,30,35,40
Bicutan,BIC,20,20,20,20,15,15,15,15,15,15,15,15,15,15,0,15,15,15,15,20,20,20,25,30,35,40
Sucat,SU,25,25,25,20,20,20,15,15,15,15,15,15,15,15,15,0,15,15,15,15,15,15,20,25,30,35
Alabang,AA,30,30,25,25,25,20,20,20,20,20,15,15,15,15,15,15,0,15,15,15,15,15,15,20,25,30
Muntinlupa,MP,35,30,30,30,25,25,25,25,20,20,20,20,15,15,15,15,15,0,15,15,15,15,15,15,20,25
"San Pedro",SPL,40,35,35,35,30,30,30,25,25,25,25,25,20,20,15,15,15,15,0,15,15,15,15,15,20,20
"Pacita Main Gate",PMG,40,35,35,35,35,30,30,30,30,25,25,25,20,20,20,15,15,15,15,0,15,15,15,15,15,20
"Golden City 1",GC1,40,40,35,35,35,35,30,30,30,30,25,25,20,20,20,15,15,15,15,15,0,15,15,15,15,20
Biñan,ÑA,45,40,40,40,35,35,30,30,30,30,30,25,25,25,20,15,15,15,15,15,15,0,15,15,15,20
"Sta. Rosa",SRL,45,45,45,40,40,40,35,35,35,35,35,30,30,25,25,20,15,15,15,15,15,15,0,15,15,15
Cabuyao,AO,50,50,45,45,45,40,40,40,40,40,35,35,30,30,30,25,20,15,15,15,15,15,15,0,15,15
Mamatid,TD,55,55,55,50,50,50,45,45,45,45,45,40,40,35,35,30,25,20,20,15,15,15,15,15,0,15
Calamba,LA,60,55,55,55,55,50,50,50,50,45,45,45,40,40,40,35,30,25,20,20,20,20,15,15,15,0
,,Tutuban,Blumentritt,Laon Laan,España,Sta. Mesa,Pandacan,Paco,San Andres,Vito Cruz,Dela Rosa,Pasay Road,EDSA,Nichols,FTI,Bicutan,Sucat,Alabang,Muntinlupa,San Pedro,Biñan,Sta. Rosa,Cabuyao,Mamatid,Calamba
,,TU,BLU,LLN,SPÑ,SA,PD,PC,SAN,VTC,DLR,PRD,EDS,NIC,FTI,BIC,SU,AA,MP,SPL,ÑA,SRL,AO,TD,LA
Tutuban,TU,0,15,15,15,15,15,15,15,15,15,15,15,20,20,20,25,30,35,40,45,45,50,55,60
Blumentritt,BLU,15,0,15,15,15,15,15,15,15,15,15,15,15,15,20,25,30,30,35,40,45,50,55,55
Laon Laan,LLN,15,15,0,15,15,15,15,15,15,15,15,15,15,15,20,25,25,30,35,40,45,45,55,55
España,SPÑ,15,15,15,0,15,15,15,15,15,15,15,15,15,15,20,20,25,30,35,40,40,45,50,55
Sta. Mesa,SA,15,15,15,15,0,15,15,15,15,15,15,15,15,15,15,20,25,25,30,35,40,45,50,55
Pandacan,PD,15,15,15,15,15,0,15,15,15,15,15,15,15,15,15,20,20,25,30,35,40,40,50,50
Paco,PC,15,15,15,15,15,15,0,15,15,15,15,15,15,15,15,15,20,25,30,30,35,40,45,50
San Andres,SAN,15,15,15,15,15,15,15,0,15,15,15,15,15,15,15,15,20,25,25,30,35,40,45,50
Vito Cruz,VTC,15,15,15,15,15,15,15,15,0,15,15,15,15,15,15,15,20,20,25,30,35,40,45,50
Dela Rosa,DLR,15,15,15,15,15,15,15,15,15,0,15,15,15,15,15,15,20,20,25,30,35,40,45,45
Pasay Road,PRD,15,15,15,15,15,15,15,15,15,15,0,15,15,15,15,15,15,20,25,30,35,35,45,45
EDSA,EDS,15,15,15,15,15,15,15,15,15,15,15,0,15,15,15,15,15,20,25,25,30,35,40,45
Nichols,NIC,20,15,15,15,15,15,15,15,15,15,15,15,0,15,15,15,15,15,20,25,30,30,40,40
FTI,FTI,20,15,15,15,15,15,15,15,15,15,15,15,15,0,15,15,15,15,20,25,25,30,35,40
Bicutan,BIC,20,20,20,20,15,15,15,15,15,15,15,15,15,15,0,15,15,15,15,20,25,30,35,40
Sucat,SU,25,25,25,20,20,20,15,15,15,15,15,15,15,15,15,0,15,15,15,15,20,25,30,35
Alabang,AA,30,30,25,25,25,20,20,20,20,20,15,15,15,15,15,15,0,15,15,15,15,20,25,30
Muntinlupa,MP,35,30,30,30,25,25,25,25,20,20,20,20,15,15,15,15,15,0,15,15,15,15,20,25
San Pedro,SPL,40,35,35,35,30,30,30,25,25,25,25,25,20,20,15,15,15,15,0,15,15,15,20,20
Biñan,ÑA,45,40,40,40,35,35,30,30,30,30,30,25,25,25,20,15,15,15,15,0,15,15,15,20
Sta. Rosa,SRL,45,45,45,40,40,40,35,35,35,35,35,30,30,25,25,20,15,15,15,15,0,15,15,15
Cabuyao,AO,50,50,45,45,45,40,40,40,40,40,35,35,30,30,30,25,20,15,15,15,15,0,15,15
Mamatid,TD,55,55,55,50,50,50,45,45,45,45,45,40,40,35,35,30,25,20,20,15,15,15,0,15
Calamba,LA,60,55,55,55,55,50,50,50,50,45,45,45,40,40,40,35,30,25,20,20,15,15,15,0
3 changes: 2 additions & 1 deletion gtfs/calendar.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date
EVERYDAY,1,1,1,1,1,1,1,20170701,20200919
EVERYDAY,1,1,1,1,1,1,1,20200601,20221231
HOLYWEEK_2021,1,1,1,0,0,0,1,20210401,20210404
19 changes: 19 additions & 0 deletions gtfs/calendar_dates.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
service_id,date,exception_type
EVERYDAY,20200804,2
EVERYDAY,20200805,2
EVERYDAY,20200806,2
EVERYDAY,20200807,2
EVERYDAY,20200808,2
EVERYDAY,20200809,2
EVERYDAY,20200810,2
EVERYDAY,20200811,2
EVERYDAY,20200812,2
EVERYDAY,20200813,2
EVERYDAY,20200814,2
EVERYDAY,20200815,2
EVERYDAY,20200816,2
EVERYDAY,20200817,2
EVERYDAY,20200818,2
HOLYWEEK_2021,20210401,2
HOLYWEEK_2021,20210402,2
HOLYWEEK_2021,20210403,2
Loading