-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from OneBusAway/dialtone
Dialtone
- Loading branch information
Showing
22 changed files
with
942 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
disabled_rules: | ||
- identifier_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (C) Open Transit Software Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import Foundation | ||
|
||
/// `ErrorResponse` represents an error structure used across the application to handle and represent | ||
/// OTP errors uniformly. | ||
public struct ErrorResponse: Codable, Hashable { | ||
/// A unique identifier for the error. | ||
public let id: Int | ||
|
||
/// A descriptive message associated with the error, providing more detailed information about what went wrong. | ||
/// This message can be presented to the user or used in debugging to provide context about the error. | ||
public let message: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (C) Open Transit Software Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import Foundation | ||
|
||
/** | ||
A simple way to construct a `debugDescription` property for an object. | ||
|
||
Here's how you might use it: | ||
|
||
public override var debugDescription: String { | ||
var descriptionBuilder = DebugDescriptionBuilder(baseDescription: super.debugDescription) | ||
descriptionBuilder.add(key: "id", value: id) | ||
return descriptionBuilder.description | ||
} | ||
*/ | ||
public struct DebugDescriptionBuilder { | ||
let baseDescription: String | ||
var properties = [String: Any]() | ||
|
||
public init(baseDescription: String) { | ||
self.baseDescription = baseDescription | ||
} | ||
|
||
public mutating func add(key: String, value: Any?) { | ||
properties[key] = value ?? "(nil)" | ||
} | ||
|
||
public var description: String { | ||
"\(baseDescription) \(properties)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) Open Transit Software Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import Foundation | ||
|
||
/// Represents a travel itinerary with detailed segments and timings. | ||
public struct Itinerary: Codable, Hashable { | ||
/// Total duration of the itinerary in seconds. | ||
public let duration: Int | ||
|
||
/// Start time of the itinerary. | ||
public let startTime: Date | ||
|
||
/// End time of the itinerary. | ||
public let endTime: Date | ||
|
||
/// Total walking time in minutes within the itinerary. | ||
public let walkTime: Int | ||
|
||
/// Total transit time in minutes within the itinerary. | ||
public let transitTime: Int | ||
|
||
/// Total waiting time in minutes within the itinerary. | ||
public let waitingTime: Int | ||
|
||
/// Total walking distance in meters within the itinerary. | ||
public let walkDistance: Double | ||
|
||
/// Indicates whether the walking distance limit was exceeded. | ||
public let walkLimitExceeded: Bool | ||
|
||
/// Total elevation lost in meters within the itinerary. | ||
public let elevationLost: Double | ||
|
||
/// Total elevation gained in meters within the itinerary. | ||
public let elevationGained: Double | ||
|
||
/// Number of transfers within the itinerary. | ||
public let transfers: Int | ||
|
||
/// Array of `Leg` objects representing individual segments of the itinerary. | ||
public let legs: [Leg] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (C) Open Transit Software Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import Foundation | ||
|
||
// swiftlint:disable identifier_name | ||
|
||
/// Represents a single segment or leg of a travel itinerary. | ||
public struct Leg: Codable, Hashable { | ||
/// Start time of the leg. | ||
public let startTime: Date | ||
|
||
/// End time of the leg. | ||
public let endTime: Date | ||
|
||
/// Mode of transportation used in this leg (e.g., "BUS", "TRAIN"). | ||
public let mode: String | ||
|
||
/// Optional route identifier for this leg. | ||
public let route: String? | ||
|
||
/// Optional name of the transportation agency for this leg. | ||
public let agencyName: String? | ||
|
||
/// Starting point of the leg. | ||
public let from: Place | ||
|
||
/// Ending point of the leg. | ||
public let to: Place | ||
|
||
/// Distance covered in this leg, in meters. | ||
public let distance: Double | ||
|
||
/// Optional flag indicating whether this leg involves transit. | ||
public let transitLeg: Bool? | ||
|
||
/// Duration of the leg in minutes. | ||
public let duration: Int | ||
|
||
/// Optional flag indicating if the leg details are based on real-time data. | ||
public let realTime: Bool? | ||
|
||
/// Optional list of street names traversed in this leg. | ||
public let streetNames: [String]? | ||
|
||
/// Optional flag indicating whether the leg involves a pathway. | ||
public let pathway: Bool? | ||
|
||
/// Optional detailed steps for navigating this leg. | ||
public let steps: [Step]? | ||
} | ||
|
||
// swiftlint:enable identifier_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (C) Open Transit Software Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import Foundation | ||
|
||
/// Represents the response from the OpenTripPlanner (OTP) API. | ||
public struct OTPResponse: Codable, Hashable { | ||
/// Parameters used in the request that generated this response. | ||
public let requestParameters: RequestParameters | ||
|
||
/// Optional `Plan` object containing detailed itinerary plans if the request was successful. | ||
public let plan: Plan? | ||
|
||
/// Optional `ErrorResponse` object containing error details if the request failed. | ||
public let error: ErrorResponse? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (C) Open Transit Software Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import Foundation | ||
|
||
/// Represents a geographical location used in travel itineraries. | ||
public struct Place: Codable, Hashable { | ||
|
||
/// Name or description of the place. | ||
public let name: String | ||
|
||
/// Longitude of the place. | ||
public let lon: Double | ||
|
||
/// Latitude of the place. | ||
public let lat: Double | ||
|
||
/// Type of vertex representing the place, such as 'NORMAL', 'STOP', or 'STATION'. | ||
public let vertexType: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) Open Transit Software Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import Foundation | ||
|
||
// swiftlint:disable identifier_name | ||
|
||
/// Represents a comprehensive travel plan containing multiple itineraries. | ||
public struct Plan: Codable, Hashable { | ||
|
||
/// Date and time when the travel plan was generated. | ||
public let date: Date | ||
|
||
/// Starting point of the travel plan. | ||
public let from: Place | ||
|
||
/// Destination point of the travel plan. | ||
public let to: Place | ||
|
||
/// List of `Itinerary` objects providing different routing options within the travel plan. | ||
public let itineraries: [Itinerary] | ||
} | ||
|
||
// swiftlint:enable identifier_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (C) Open Transit Software Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import Foundation | ||
|
||
/// Contains parameters used to define the specifics of a request to the OpenTripPlanner API. | ||
public struct RequestParameters: Codable, Hashable { | ||
/// The starting location for the travel plan, expressed in a string format, typically as coordinates. | ||
public let fromPlace: String | ||
|
||
/// The destination location for the travel plan, expressed in a string format, typically as coordinates. | ||
public let toPlace: String | ||
|
||
/// The preferred time for departure or arrival, depending on `arriveBy`. | ||
public let time: String | ||
|
||
/// The date of travel. | ||
public let date: String | ||
|
||
/// Travel modes included in the trip planning, such as "TRANSIT", "WALK". | ||
public let mode: String | ||
|
||
/// Indicates whether the `time` parameter refers to arrival time ("true") or departure time ("false"). | ||
public let arriveBy: String | ||
|
||
/// Maximum walking distance the user is willing to walk, expressed in meters. | ||
public let maxWalkDistance: String | ||
|
||
/// Indicates whether the route should accommodate wheelchair access ("true" or "false"). | ||
public let wheelchair: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) Open Transit Software Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import Foundation | ||
|
||
/// Represents a detailed step within a leg of an itinerary, providing navigation details. | ||
public struct Step: Codable, Hashable { | ||
/// Distance of this step in meters. | ||
public let distance: Double | ||
|
||
/// Name of the street involved in this step. | ||
public let streetName: String | ||
|
||
/// Optional description of the direction to take at this step (e.g., "left", "right"). | ||
public let direction: String? | ||
|
||
/// Optional elevation change during this step, in meters. | ||
public let elevationChange: Double? | ||
} |
Oops, something went wrong.