From 1dacfe07de25139f66380b4f5243326ae2ad5df3 Mon Sep 17 00:00:00 2001 From: Reto Lehnherr Date: Wed, 23 Jul 2025 14:29:17 +0200 Subject: [PATCH 1/3] Add more PTModes --- .../OJPSampleApp/Views/StopEventView.swift | 26 ++++++++++++++++--- Sources/OJP/Models/OJPv2.swift | 18 ++++++++++--- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/SampleApp/OJPSampleApp/Views/StopEventView.swift b/SampleApp/OJPSampleApp/Views/StopEventView.swift index 2be0a20..f2d0867 100644 --- a/SampleApp/OJPSampleApp/Views/StopEventView.swift +++ b/SampleApp/OJPSampleApp/Views/StopEventView.swift @@ -138,18 +138,36 @@ struct StopEventView: View { extension Pictograms { static func picto(mode: OJPv2.Mode) -> Image { switch mode.ptMode { + case .air: + Pictograms.aeroplane_right_framed + case .bus: + Pictograms.bus_right_framed + case .coach: + Pictograms.remote_bus_right_framed + case .ferry: + Pictograms.car_ferry_right_framed + case .metro: + Pictograms.metro_left_de_framed case .rail: Pictograms.train_right_framed - case .bus: + case .taxi: + Pictograms.taxi_right_framed + case .telecabin: + Pictograms.gondola_lift_right_framed + case .trolleyBus: Pictograms.bus_right_framed case .tram: Pictograms.tram_right_framed case .water: Pictograms.jetty_right_framed - case .telecabin: + case .cableway: Pictograms.cableway_right_framed - case .underground: - Pictograms.metro_right_de_framed + case .funicular: + Pictograms.funicular_railway_right_framed + case .lift: + Pictograms.lift + case .snowAndIce: + Pictograms.ski_lift_right_framed case .unknown: Pictograms.information_framed } diff --git a/Sources/OJP/Models/OJPv2.swift b/Sources/OJP/Models/OJPv2.swift index a2606d8..cc5a8a4 100644 --- a/Sources/OJP/Models/OJPv2.swift +++ b/Sources/OJP/Models/OJPv2.swift @@ -194,10 +194,11 @@ public struct OJPv2: Codable, Sendable { public struct Mode: Codable, Sendable, Hashable { public let ptMode: PtMode - public init(ptMode: PtMode, busSubmode: String?, railSubmode: String?, name: InternationalText?, shortName: InternationalText?) { + public init(ptMode: PtMode, busSubmode: String?, railSubmode: String?, funicularSubmode: String?, name: InternationalText?, shortName: InternationalText?) { self.ptMode = ptMode self.busSubmode = busSubmode self.railSubmode = railSubmode + self.funicularSubmode = funicularSubmode self.name = name self.shortName = shortName } @@ -207,6 +208,7 @@ public struct OJPv2: Codable, Sendable { // keep busSubmode, railSubmode for now public let busSubmode: String? public let railSubmode: String? + public let funicularSubmode: String? public let name: InternationalText? public let shortName: InternationalText? @@ -215,17 +217,27 @@ public struct OJPv2: Codable, Sendable { case ptMode = "PtMode" case busSubmode = "siri:BusSubmode" case railSubmode = "siri:RailSubmode" + case funicularSubmode = "siri:FunicularSubmode" case name = "Name" case shortName = "ShortName" } public enum PtMode: String, Codable, Sendable { - case rail + case air case bus + case coach + case ferry + case metro + case rail + case trolleyBus case tram case water + case cableway case telecabin - case underground + case taxi + case funicular + case lift + case snowAndIce case unknown public init(from decoder: Decoder) throws { From fa5d0405cd8ab58c0b592872d8734143ea4e0a23 Mon Sep 17 00:00:00 2001 From: Reto Lehnherr Date: Wed, 23 Jul 2025 14:38:58 +0200 Subject: [PATCH 2/3] re-add underground --- SampleApp/OJPSampleApp/Views/StopEventView.swift | 2 ++ Sources/OJP/Models/OJPv2.swift | 1 + 2 files changed, 3 insertions(+) diff --git a/SampleApp/OJPSampleApp/Views/StopEventView.swift b/SampleApp/OJPSampleApp/Views/StopEventView.swift index f2d0867..dd3286b 100644 --- a/SampleApp/OJPSampleApp/Views/StopEventView.swift +++ b/SampleApp/OJPSampleApp/Views/StopEventView.swift @@ -162,6 +162,8 @@ extension Pictograms { Pictograms.jetty_right_framed case .cableway: Pictograms.cableway_right_framed + case .underground: + Pictograms.metro_right_de_framed case .funicular: Pictograms.funicular_railway_right_framed case .lift: diff --git a/Sources/OJP/Models/OJPv2.swift b/Sources/OJP/Models/OJPv2.swift index cc5a8a4..5417a0f 100644 --- a/Sources/OJP/Models/OJPv2.swift +++ b/Sources/OJP/Models/OJPv2.swift @@ -234,6 +234,7 @@ public struct OJPv2: Codable, Sendable { case water case cableway case telecabin + case underground case taxi case funicular case lift From f3b2265a8074d7ce8c44226bb049e2f595f1e780 Mon Sep 17 00:00:00 2001 From: Reto Lehnherr Date: Wed, 23 Jul 2025 14:51:27 +0200 Subject: [PATCH 3/3] Add default nil for optionals in init --- Sources/OJP/Models/OJPv2.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/OJP/Models/OJPv2.swift b/Sources/OJP/Models/OJPv2.swift index 5417a0f..4b5a52a 100644 --- a/Sources/OJP/Models/OJPv2.swift +++ b/Sources/OJP/Models/OJPv2.swift @@ -194,7 +194,7 @@ public struct OJPv2: Codable, Sendable { public struct Mode: Codable, Sendable, Hashable { public let ptMode: PtMode - public init(ptMode: PtMode, busSubmode: String?, railSubmode: String?, funicularSubmode: String?, name: InternationalText?, shortName: InternationalText?) { + public init(ptMode: PtMode, busSubmode: String? = nil, railSubmode: String? = nil, funicularSubmode: String? = nil, name: InternationalText? = nil, shortName: InternationalText?) { self.ptMode = ptMode self.busSubmode = busSubmode self.railSubmode = railSubmode