Skip to content

Commit

Permalink
v1.1.0 sequence bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
answerquest committed Apr 13, 2018
1 parent 1090ec8 commit 1908413
Show file tree
Hide file tree
Showing 17 changed files with 285 additions and 18,983 deletions.
4 changes: 3 additions & 1 deletion GTFS/sequence.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"_default": {}
}
43 changes: 35 additions & 8 deletions GTFSserverfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,14 +665,29 @@ def deletefromDB(dbfile,key,value,tables):
count = tableDb.search(Item['service_id'] == value)
print('Trying to zap shape_id values. Now the count is ' + str(count))

# sequence DB
if key == 'route_id':
# drop it from sequence DB too.
sdb = tinyDBopen(sequenceDBfile)
sDb = tinyDBopen(sequenceDBfile)
sItem = Query()
print('Removing entires for stop_id '+value +' in sequenceDB too if any.')
sdb.remove(sItem[key] == value)
sdb.close();
print('Removing entires for route_id '+value +' in sequenceDB too if any.')
sDb.remove(sItem[key] == value)
sDb.close();

if key == 'stop_id':
# drop the stop from sequence DB too.
sDb = tinyDBopen(sequenceDBfile)
sItem = Query()
rows = sDb.all()
for row in rows:
row['0'][:] = ( x for x in row['0'] if x != value )
row['1'][:] = ( x for x in row['1'] if x != value )
print('Zapped stop_id ' + value + ' from sequence db for route '+ row['route_id'])
sDb.write_back(rows)

sDb.close();

# Zones
if key == 'zone_id':
# drop either origin_id or destination_id rows
tableDb = db.table('fare_rules')
Expand All @@ -688,10 +703,8 @@ def deletefromDB(dbfile,key,value,tables):
tableDb.write_back(rows)
print('Zapped zone_id:' + value + ' values in stops table, while keeping those rows.')

'''
if key == 'stop_id':
# drop the stop from sequence DB too.
'''



db.close()
return True
Expand Down Expand Up @@ -736,5 +749,19 @@ def replaceIDfunc(valueFrom,valueTo,tableKeys):
returnList.append('Replaced ' + key + ' = ' + valueFrom + ' with <b>' + valueTo + '</b> in ' + tablename + ' table, <b>' + count + '</b> rows edited.')

db.close()

# additional: if it's a stop, replace it in sequence DB too.
if 'stop_id' in [x['key'] for x in tableKeys]:
sDb = tinyDBopen(sequenceDBfile)
sItem = Query()
rows = sDb.all()
for row in rows:
row['0'][:] = ( x if (x != valueFrom) else valueTo for x in row['0'] )
row['1'][:] = ( x if (x != valueFrom) else valueTo for x in row['1'] )
print('Replaced stop_id = ' + valueFrom + ' with ' + valueTo + ' in sequence DB for route '+ row['route_id'])
returnList.append('Replaced stop_id = ' + valueFrom + ' with <b>' + valueTo + '</b> in sequence DB for route '+ row['route_id'])
sDb.write_back(rows)
sDb.close();

returnMessage = '<br>'.join(returnList)
return returnMessage
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# static-GTFS-manager
A browser-based user interface for creating, editing, exporting of static GTFS (General Transit Feed Specification Reference) feeds for a public transit authority.

**Development Status** : V 1.0.0 is ready, open for Beta Testing.
**Development Status** : V 1.1.0 is ready, open for Beta Testing.

This project is the result of a collaboration between WRI ([World Resources Institute](http://wri-india.org/)) and KMRL ([Kochi Metro Rail Limited](http://kochimetro.org)).

Expand Down Expand Up @@ -102,7 +102,7 @@ This project stands on the shoulders of several solutions that have been shared
#### Open source libraries used on Python side :
- Tornado for web server with asynchronous callback
- TinyDB for portable JSON database
- Many python modules for various operations: json, os, time, datetime, xmltodict, csv, pandas, collections, zipfile, webbrowser
- Many python modules for various operations: json, os, time, datetime, xmltodict, csv, pandas, collections, zipfile, webbrowser, pycrptodome, shutil, pathlib, math, json.decoder

#### Many snippets
In addition to this, there are several code snippets used throughout the program that were found from online forums like stackoverflow and on various tech blogs. The links to the sources of the snippets are mentioned in comments in the program. Here is a shoutout to all the contributors on these forums and blogs : ***Thank You!***
Expand Down
5,986 changes: 0 additions & 5,986 deletions extra_files/8S0845_MACE.xml

This file was deleted.

6,910 changes: 0 additions & 6,910 deletions extra_files/8W0845_MACE.xml

This file was deleted.

17 changes: 0 additions & 17 deletions extra_files/fares-chart.csv

This file was deleted.

17 changes: 0 additions & 17 deletions extra_files/stations.csv

This file was deleted.

Loading

0 comments on commit 1908413

Please sign in to comment.