Skip to content

Commit

Permalink
More type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthetechie committed Sep 4, 2024
1 parent 4f61672 commit a13bfe0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
10 changes: 5 additions & 5 deletions apple/Sources/OSRM/Models/Annotation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import Foundation

public struct Annotation: Codable, Hashable {
/** The distance, in meters, between each pair of coordinates. */
public var distance: [Double]
public var distance: [Double]?
/** The duration between each pair of coordinates, in seconds. */
public var duration: [Double]
public var duration: [Double]?
/** The index of the datasource for the speed between each pair of coordinates. 0 is the default profile. Other values are supplied via --segment-speed-file to osrm-contract. This is OSRM-specific and not supported by most other routers. */
public var datasources: [Int]?
/** The OSM node ID for each coordinate along the route (excluding the first/last user-supplied coordinates). This is not included in Valhalla-derived routers. */
Expand All @@ -24,7 +24,7 @@ public struct Annotation: Codable, Hashable {
public var speed: [Double]?
public var maxspeed: [SpeedLimit]?

public init(distance: [Double], duration: [Double], datasources: [Int]? = nil, nodes: [Int]? = nil, weight: [Int]? = nil, speed: [Double]? = nil, maxspeed: [SpeedLimit]? = nil) {
public init(distance: [Double]? = nil, duration: [Double]? = nil, datasources: [Int]? = nil, nodes: [Int]? = nil, weight: [Int]? = nil, speed: [Double]? = nil, maxspeed: [SpeedLimit]? = nil) {
self.distance = distance
self.duration = duration
self.datasources = datasources
Expand All @@ -48,8 +48,8 @@ public struct Annotation: Codable, Hashable {

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(distance, forKey: .distance)
try container.encode(duration, forKey: .duration)
try container.encodeIfPresent(distance, forKey: .distance)
try container.encodeIfPresent(duration, forKey: .duration)
try container.encodeIfPresent(datasources, forKey: .datasources)
try container.encodeIfPresent(nodes, forKey: .nodes)
try container.encodeIfPresent(weight, forKey: .weight)
Expand Down
6 changes: 3 additions & 3 deletions apple/Sources/OSRM/Models/RouteStep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public struct RouteStep: Codable, Hashable {
public var ref: String?
/** Pronunciation of the name (if available). The format of this varies by implementation/vendor. */
public var pronunciation: String?
public var destinations: AnyCodable?
public var exits: AnyCodable?
public var destinations: String?
public var exits: String?
/** The mode of travel. */
public var mode: String
public var maneuver: StepManeuver
Expand All @@ -55,7 +55,7 @@ public struct RouteStep: Codable, Hashable {
/** The unit of measure that is used locally along the step. This may be different from the unit used in maxspeed annotations, and is provided so that apps can localize their display. This is a Valhalla extension to the OSRM spec, and is only included when speed limits are present in the response. */
public var speedLimitUnit: String?

public init(distance: Double, duration: Double, geometry: AnyCodable, weight: Double? = nil, name: String? = nil, ref: String? = nil, pronunciation: String? = nil, destinations: AnyCodable? = nil, exits: AnyCodable? = nil, mode: String, maneuver: StepManeuver, intersections: [Intersection]? = nil, rotaryName: String? = nil, rotaryPronunciation: String? = nil, drivingSide: DrivingSide? = nil, voiceInstructions: [VoiceInstruction]? = nil, bannerInstructions: [BannerInstruction]? = nil, speedLimitSign: SpeedLimitSign? = nil, speedLimitUnit: String? = nil) {
public init(distance: Double, duration: Double, geometry: AnyCodable, weight: Double? = nil, name: String? = nil, ref: String? = nil, pronunciation: String? = nil, destinations: String? = nil, exits: String? = nil, mode: String, maneuver: StepManeuver, intersections: [Intersection]? = nil, rotaryName: String? = nil, rotaryPronunciation: String? = nil, drivingSide: DrivingSide? = nil, voiceInstructions: [VoiceInstruction]? = nil, bannerInstructions: [BannerInstruction]? = nil, speedLimitSign: SpeedLimitSign? = nil, speedLimitUnit: String? = nil) {
self.distance = distance
self.duration = duration
self.geometry = geometry
Expand Down
9 changes: 2 additions & 7 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,9 @@ components:
Pronunciation of the name (if available).
The format of this varies by implementation/vendor.
destinations:
# FIXME
type: object
type: string
exits:
# FIXME
type: object
type: string
mode:
type: string
description: The mode of travel.
Expand Down Expand Up @@ -273,9 +271,6 @@ components:
and is only included when speed limits are present in the response.
Annotation:
type: object
required:
- distance
- duration
properties:
distance:
type: array
Expand Down

0 comments on commit a13bfe0

Please sign in to comment.