WRI-Cities / static-GTFS-manager

GUI interface for creating, editing, exporting of static GTFS data for a public transit authority
GNU General Public License v3.0
148 stars 46 forks source link

handle fare_rules that aren't station pairs #105

Open answerquest opened 6 years ago

answerquest commented 6 years ago

There are other fare_rules models besides station-pairs : https://code.google.com/archive/p/googletransitdatafeed/wikis/FareExamples.wiki

In Fares page, the pivoted fare rules API call errors out when it encounters fare_rules entries that don't have origin_id and destination_id values. (example: if a bus service charges a flat rate for all trips)

ERROR:tornado.application:Uncaught exception GET /API/fareRulesPivoted (::1)
HTTPServerRequest(protocol='http', host='localhost:5000', method='GET', uri='/API/fareRulesPivoted', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
  File "/mnt/STUFF/py36/lib/python3.6/site-packages/tornado/web.py", line 1590, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "GTFSManager.py", line 247, in get
    columns='destination_id', values='fare_id')\
  File "/mnt/STUFF/py36/lib/python3.6/site-packages/pandas/core/frame.py", line 5194, in pivot
    return pivot(self, index=index, columns=columns, values=values)
  File "/mnt/STUFF/py36/lib/python3.6/site-packages/pandas/core/reshape/reshape.py", line 415, in pivot
    return indexed.unstack(columns)
  File "/mnt/STUFF/py36/lib/python3.6/site-packages/pandas/core/series.py", line 2899, in unstack
    return unstack(self, level, fill_value)
  File "/mnt/STUFF/py36/lib/python3.6/site-packages/pandas/core/reshape/reshape.py", line 501, in unstack
    constructor=obj._constructor_expanddim)
  File "/mnt/STUFF/py36/lib/python3.6/site-packages/pandas/core/reshape/reshape.py", line 137, in __init__
    self._make_selectors()
  File "/mnt/STUFF/py36/lib/python3.6/site-packages/pandas/core/reshape/reshape.py", line 175, in _make_selectors
    raise ValueError('Index contains duplicate entries, '
ValueError: Index contains duplicate entries, cannot reshape
ERROR:tornado.access:500 GET /API/fareRulesPivoted (::1) 257.19ms
answerquest commented 6 years ago

To do: