公共汽车和公共汽车路线信息包
straeto的Python项目详细描述
斯特拉托
straeto是一个python 3.x包,封装了关于总线和总线的数据 Str_tóbs路线,冰岛市政巴士服务。
数据是从straeto.is website中获取的,
存储在名为GTFS.zip
的文件中。不幸的是,那个文件
还没有位于一个固定的、众所周知的url。
示例
import straeto
# Your location here, as a (lat, lon) tuple
location = straeto._MIDEIND_LOCATION # Fiskislóð 31, Reykjavík
s = straeto.BusStop.closest_to(location)
print(f"The bus stop closest to {location} is {s.name}")
# Load the bus schedule for today
schedule = straeto.BusSchedule()
# Your route identifier here
route_id = "14"
# Print the next two arrivals of that route at the closest bus stop
for direction, times in schedule.arrivals(route_id, s.name, n=2).items():
print(
"Direction {0}: {1}"
.format(
direction,
", ".join(
"{0:02}:{1:02}".format(hms[0], hms[1]) for hms in times
)
)
)
文档
这是一个alpha之前的版本,还没有合适的文档
产生。但是代码是相当不言而喻的;看看这个文件
src/straeto/straeto.py
查看主类的源代码
以及一些使用示例。
实时数据
此包支持从url读取有关总线位置的实时数据
由Str_tóbs提供。但是,这些url不是公共的,您需要签名
与str_tó达成协议,获取数据并获得您自己的url。一旦你
拥有您的url,将其放入文件config/status_url.txt
,以启用straeto
包以获取实时数据。
版权所有
版权所有(c)2019 mi_eind ehf。
许可证
此程序是免费软件:您可以重新分发和/或修改 根据由 自由软件基金会,或者许可证的第3版,或者 (由您选择)任何更高版本。
这个程序的发布是希望它能有用, 但没有任何保证;甚至没有 适销性或适合某一特定目的的适销性。见 GNU通用公共许可证了解更多详细信息。
GNU通用公共许可证全文可在 http://www.gnu.org/licenses/。
如果您想以不兼容的方式使用此软件 使用标准GNU GPLV3许可证,请联系mi_eind ehf。 谈判其他安排。