krakow_ztp.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // SPDX-FileCopyrightText: Adam Evyčędo
  2. //
  3. // SPDX-License-Identifier: AGPL-3.0-or-later
  4. package traffic
  5. import (
  6. "apiote.xyz/p/szczanieckiej/config"
  7. "apiote.xyz/p/szczanieckiej/transformers"
  8. "time"
  9. "golang.org/x/text/language"
  10. "golang.org/x/text/transform"
  11. )
  12. type KrakowZtp struct{}
  13. func (KrakowZtp) getTimezone() *time.Location {
  14. l, _ := time.LoadLocation("Europe/Warsaw")
  15. return l
  16. }
  17. func (KrakowZtp) ConvertVehicles() ([]Vehicle, error) {
  18. return []Vehicle{}, nil
  19. }
  20. func (f KrakowZtp) GetVersions(date time.Time, timezone *time.Location) ([]Version, error) {
  21. startDate := time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, timezone)
  22. endDate := time.Date(date.Year(), date.Month(), date.Day(), 23, 59, 59, 0, timezone)
  23. v := Version{
  24. Link: "https://gtfs.ztp.krakow.pl/GTFS_KRK_A.zip",
  25. ValidFrom: startDate,
  26. ValidTill: endDate,
  27. }
  28. // https://gtfs.ztp.krakow.pl/GTFS_KRK_T.zip
  29. return []Version{v}, nil
  30. }
  31. func (KrakowZtp) RealtimeFeeds() map[RealtimeFeedType]string {
  32. return map[RealtimeFeedType]string{
  33. ALERTS: "https://gtfs.ztp.krakow.pl/ServiceAlerts_A.pb",
  34. TRIP_UPDATES: "https://gtfs.ztp.krakow.pl/TripUpdates_A.pb",
  35. //"https://gtfs.ztp.krakow.pl/TripUpdates_T.pb",
  36. VEHICLE_POSITIONS: "https://gtfs.ztp.krakow.pl/VehiclePositions_A.pb",
  37. //"https://gtfs.ztp.krakow.pl/VehiclePositions_T.pb",
  38. }
  39. }
  40. func (KrakowZtp) LuaUpdatesScript(c config.Config) string {
  41. return ""
  42. }
  43. func (KrakowZtp) String() string {
  44. return "krakow_ztp"
  45. }
  46. func (z KrakowZtp) Transformer() transform.Transformer {
  47. return transformers.TransformerPL
  48. }
  49. func (z KrakowZtp) Name() string {
  50. return "ZTP Kraków"
  51. }
  52. func (z KrakowZtp) Attribution() map[language.Tag]string {
  53. return map[language.Tag]string{
  54. language.Und: "GTFS files downloaded from https://gtfs.ztp.krakow.pl/ and converted to TRAFFIC",
  55. language.English: "GTFS files downloaded from https://gtfs.ztp.krakow.pl/ and converted to TRAFFIC",
  56. language.Polish: "Pliki GTFS pobrane z https://gtfs.ztp.krakow.pl/ przekonwertowane do formatu TRAFFIC",
  57. }
  58. }
  59. func (z KrakowZtp) Description() map[language.Tag]string {
  60. return map[language.Tag]string{
  61. language.Und: "Buses timetable for Kraków public transport organised by Zarząd Transportu Publicznego (ZTP)",
  62. language.English: "Buses timetable for Kraków public transport organised by Zarząd Transportu Publicznego (ZTP)",
  63. language.BritishEnglish: "Buses timetable for Kraków public transport organised by Zarząd Transportu Publicznego (ZTP)",
  64. language.AmericanEnglish: "Buses timetable for Kraków public transport organized by Zarząd Transportu Publicznego (ZTP)",
  65. language.Polish: "Rozkład jazdy autobusów krakowskiego transportu publicznego organizowanego przez Zarząd Transportu Publicznego (ZTP)",
  66. }
  67. }
  68. func (z KrakowZtp) Flags() FeedFlags {
  69. return FeedFlags{
  70. Headsign: HeadsignTripHeadsing,
  71. StopIdFormat: "{{stop_id}}",
  72. StopName: "{{stop_name}}",
  73. LineName: "{{route_short_name}}",
  74. }
  75. }
  76. func (z KrakowZtp) FeedPrepareZip(path string) error {
  77. return nil
  78. }
  79. func (z KrakowZtp) QRInfo() (string, QRLocation, string) {
  80. return "", QRLocationNone, ""
  81. }