Skip to content

Commit

Permalink
Add missing travel type cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthetechie committed Jul 30, 2023
1 parent 5dd6081 commit 41d0b80
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
5 changes: 5 additions & 0 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ it to, so be careful.

```shell
openapi-generator generate -i https://api.stadiamaps.com/openapi.yaml -g swift5 --strict-spec=true -o . -p disallowAdditionalPropertiesIfNotPresent=false -p projectName="StadiaMaps" -p useSPMFileStructure=true -p responseAs="AsyncAwait"
swiftformat .
```

## Tagging a release

SPM releases are just tags. Publish a GitHub release for completeness.
12 changes: 11 additions & 1 deletion Sources/StadiaMaps/Models/RouteManeuver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@ import Foundation
public struct RouteManeuver: Codable, JSONEncodable, Hashable {
public enum TravelType: String, Codable, CaseIterable {
case car
case motorcycle
case bus
case tractorTrailer = "tractor_trailer"
case motorScooter = "motor_scooter"
case golfCart = "golf_cart"
case foot
case wheelchair
case segway
case road
case cross
case hybrid
case mountain
case tram
case metro
case rail
case bus
case ferry
case cableCar = "cable_car"
case gondola
Expand Down Expand Up @@ -77,6 +86,7 @@ public struct RouteManeuver: Codable, JSONEncodable, Hashable {
/** True if the `verbal_pre_transition_instruction` has been appended with the verbal instruction of the next maneuver. */
public var verbalMultiCue: Bool? = false
public var travelMode: TravelMode
/** The type of travel over the maneuver. This can be thought of as a specialization of the travel mode. For example, vehicular travel may be via car, motorcycle, etc.; and travel via bicycle may be via a road bike, mountain bike, etc. */
public var travelType: TravelType
/** Describes a bike share action when using bikeshare routing. */
public var bssManeuverType: BssManeuverType?
Expand Down
2 changes: 1 addition & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ targets:
sources: [Sources]
info:
path: ./Info.plist
version: 5.0.5
version: 5.0.6
settings:
APPLICATION_EXTENSION_API_ONLY: true
scheme: {}
Expand Down
2 changes: 1 addition & 1 deletion tests/GeocodingAPIIntegrationTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class GeocodingAPIIntegrationTestCase: IntegrationXCTestCase {
}

func testStructuredSearch() async throws {
let res = try await GeocodingAPI.searchStructured(address: address, country: "EE")
let res = try await GeocodingAPI.searchStructured(address: address, region: "Harju", country: "EE")
XCTAssert(!res.features.isEmpty)
XCTAssertEqual(res.features.first?.properties?.country, "Estonia")
XCTAssertEqual(res.features.first?.properties?.layer, .address)
Expand Down
21 changes: 19 additions & 2 deletions tests/RoutingAPITestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class RoutingAPITestCase: IntegrationXCTestCase {
RoutingWaypoint(lat: locationB.lat, lon: locationB.lon),
],
costing: .auto,
costingOptions: CostingOptions(auto: AutoCostingOptions(useTolls: 0.7)),
costingOptions: CostingOptions(auto: AutoCostingOptions(useHighways: 0.3)),
directionsOptions: DirectionsOptions(units: .mi))
let res = try await RoutingAPI.route(routeRequest: req)
XCTAssertEqual(req.id, res.id)
Expand All @@ -22,6 +22,23 @@ final class RoutingAPITestCase: IntegrationXCTestCase {
XCTAssertEqual(res.trip.legs.count, 1)
}

func testHybridBicycleRoute() async throws {
// Regression test for user-reported issue
let req = RouteRequest(id: "route",
locations: [
RoutingWaypoint(lat: locationA.lat, lon: locationA.lon),
RoutingWaypoint(lat: locationB.lat, lon: locationB.lon),
],
costing: .bicycle,
costingOptions: CostingOptions(bicycle: BicycleCostingOptions(bicycleType: .hybrid, useRoads: 0.4, useHills: 0.6)),
directionsOptions: DirectionsOptions(units: .km))
let res = try await RoutingAPI.route(routeRequest: req)
XCTAssertEqual(req.id, res.id)
XCTAssertEqual(res.trip.status, 0)
XCTAssertEqual(res.trip.units, .kilometers)
XCTAssertEqual(res.trip.legs.count, 1)
}

func testOptimizedRoute() async throws {
let req = OptimizedRouteRequest(id: "optimized_route",
locations: [
Expand All @@ -31,7 +48,7 @@ final class RoutingAPITestCase: IntegrationXCTestCase {
locationA,
],
costing: .auto,
costingOptions: CostingOptions(auto: AutoCostingOptions(useTolls: 0.7)),
costingOptions: CostingOptions(auto: AutoCostingOptions(useHighways: 0.3)),
directionsOptions: DirectionsOptions(units: .mi))
let res = try await RoutingAPI.optimizedRoute(optimizedRouteRequest: req)
XCTAssertEqual(req.id, res.id)
Expand Down

0 comments on commit 41d0b80

Please sign in to comment.