Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chunlaw committed Oct 18, 2024
1 parent c0dc115 commit 15d877d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions crawling/hkkf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ async def getRouteStop(co):
"stops": [
"KF" + str(orig["pier_id"]),
"KF" + str(dest["pier_id"]),
]
],
"co": "hkkf",
})
routeList.append({
"route": "KF" + str(apiRoute["route_id"]),
Expand All @@ -70,7 +71,8 @@ async def getRouteStop(co):
"stops": [
"KF" + str(dest["pier_id"]),
"KF" + str(orig["pier_id"]),
]
],
"co": "hkkf",
})

for apiStop in apiStops:
Expand Down
1 change: 1 addition & 0 deletions crawling/kmb.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def isStopExist( stopId ):
r = await emitRequest('https://data.etabus.gov.hk/v1/transport/kmb/route/', a_client)
for route in r.json()['data']:
route['stops'] = {}
route['co'] = 'kmb'
routeList['+'.join([route['route'], route['service_type'], route['bound']])] = route

# load route stops
Expand Down
3 changes: 2 additions & 1 deletion crawling/lrtfeeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ async def getRouteStop(co = 'lrtfeeder'):
"dest_tc": end["zh"] if bound == 'O' else start['zh'],
"orig_en": start['en'] if bound == 'O' else end['en'],
"dest_en": end["en"] if bound == 'O' else start['en'],
"stops": []
"stops": [],
"co": "lrtfeeder"
}

# Parse stops
Expand Down
4 changes: 2 additions & 2 deletions crawling/matchGtfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def matchRoutes(co):
routeCandidate['co'] = gtfsRoute['co'] if co in gtfsRoute['co'] else ( gtfsRoute['co'] + [co] )
routeCandidate['stops'] = [route['stops'][j] for i, j in ret]
routeCandidate['gtfs'] = [gtfsId]
route['gtfs'] = [gtfsId]
route['found'] = True
else:
routeCandidate['stops'] = [route['stops'][j] for i, j in ret]
routeCandidate['fares'] = [gtfsRoute['fares'][bound][i] for i, j in ret[:-1]] if len(ret[:-1]) <= len(gtfsRoute["fares"][bound]) + 1 else None
Expand Down Expand Up @@ -184,7 +184,7 @@ def matchRoutes(co):
print (co, len([route for route in routeList if 'gtfs' not in route]), 'out of',len(routeList), 'not match')
if co != 'mtr': routeList.extend(routeCandidates)
routeList = [route for route in routeList if 'found' not in route or 'fares' in route] # skipping routes that just partially mapped to GTFS

with open( 'routeFareList.%s.json' % co, 'w', encoding='UTF-8' ) as f:
f.write(json.dumps(routeList, ensure_ascii=False))

Expand Down

0 comments on commit 15d877d

Please sign in to comment.