Skip to content

Commit

Permalink
Add LSV; improve matrix
Browse files Browse the repository at this point in the history
ianthetechie committed Apr 30, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent fed8e3d commit de0a865
Showing 7 changed files with 100 additions and 20 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Version 3.0.0 - 2024-04-30

### Added

- Add support for low-speed vehicle routing
- The matrix endpoint now accepts its own model rather than coordinate. This includes a search cutoff and paves the way for future expansion.

### Changed

- Improved the documentation of the matrix endpoint failure modes

### Fixed

- The time and distance field on matrix source to target models are now marked as nullable

## Version 2.1.0 - 2024-03-21

### Added
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -65,8 +65,8 @@ dependencies {
implementation("com.stadiamaps:api:1.0.0")

// Dependencies
implementation("com.squareup.moshi:moshi-kotlin:1.14.0")
implementation("com.squareup.moshi:moshi-adapters:1.14.0")
implementation("com.squareup.moshi:moshi-kotlin:1.15.1")
implementation("com.squareup.moshi:moshi-adapters:1.15.1")
implementation("com.squareup.okhttp3:logging-interceptor:4.10.0")
implementation("com.squareup.retrofit2:retrofit:$retrofitVersion")
implementation("com.squareup.retrofit2:converter-moshi:$retrofitVersion")
@@ -84,8 +84,8 @@ dependencies {
implementation 'com.stadiamaps:api:1.0.0'
// Dependencies
implementation 'com.squareup.moshi:moshi-kotlin:1.14.0'
implementation 'com.squareup.moshi:moshi-adapters:1.14.0'
implementation 'com.squareup.moshi:moshi-kotlin:1.15.1'
implementation 'com.squareup.moshi:moshi-adapters:1.15.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
implementation "com.squareup.retrofit2:retrofit:${retrofitVersion}"
implementation "com.squareup.retrofit2:converter-moshi:${retrofitVersion}"
4 changes: 3 additions & 1 deletion example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -17,7 +17,9 @@ dependencies {

implementation(project(":generated-client"))

implementation("com.squareup.moshi:moshi-kotlin:1.14.0")
val moshiVersion = "1.15.1"
implementation("com.squareup.moshi:moshi-kotlin:$moshiVersion")
implementation("com.squareup.moshi:moshi-adapters:$moshiVersion")
implementation("com.squareup.moshi:moshi-adapters:1.14.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.10.0")
implementation("com.squareup.retrofit2:retrofit:$retrofitVersion")
2 changes: 1 addition & 1 deletion example/src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ fun testRoutingApis(client: ApiClient) {
println("Request failed with error code ${route.code()}")
}

val matrix = routingService.timeDistanceMatrix(MatrixRequest(listOf(Coordinate(tll.lat, tll.lon)), listOf(Coordinate(kultuurikatel.lat, kultuurikatel.lon)), MatrixCostingModel.pedestrian)).execute()
val matrix = routingService.timeDistanceMatrix(MatrixRequest(listOf(MatrixWaypoint(tll.lat, tll.lon)), listOf(MatrixWaypoint(kultuurikatel.lat, kultuurikatel.lon)), MatrixCostingModel.pedestrian)).execute()
if (matrix.isSuccessful) {
println("Found matrix response! ${matrix.body()?.sourcesToTargets}")
} else {
5 changes: 3 additions & 2 deletions generated-client/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,8 +20,9 @@ dependencies {
swaggerCodegen("org.openapitools:openapi-generator-cli:6.6.0")

// Dependencies of the generated code. Check out `build.gradle` in your build folder later if you're curious.
implementation("com.squareup.moshi:moshi-kotlin:1.14.0")
implementation("com.squareup.moshi:moshi-adapters:1.14.0")
val moshiVersion = "1.15.1"
implementation("com.squareup.moshi:moshi-kotlin:$moshiVersion")
implementation("com.squareup.moshi:moshi-adapters:$moshiVersion")
implementation("com.squareup.okhttp3:logging-interceptor:4.10.0")
implementation("com.squareup.retrofit2:retrofit:$retrofitVersion")
implementation("com.squareup.retrofit2:converter-moshi:$retrofitVersion")
78 changes: 70 additions & 8 deletions generated-client/openapi.yaml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ servers:
info:
description: >-
The Stadia Maps Geospatial APIs provide you with the data you need to build awesome applications.
version: 6.1.0
version: 6.3.0
title: Stadia Maps Geospatial APIs
contact:
name: Stadia Maps Support
@@ -181,7 +181,9 @@ paths:
schema:
$ref: '#/components/schemas/matrixResponse'
'400':
description: Bad request; more details will be included
description: >-
Bad request; more details will be included.
NOTE: failure to find suitable edges near a location will result in a 400.
/isochrone/v1:
post:
tags:
@@ -683,6 +685,17 @@ components:
The timestamp of the waypoint, in seconds. This can inform the map matching algorithm about when the
point was measured. A UNIX timestamp, or any increasing integer sequence measuring seconds from some
reference point can be used.
matrixWaypoint:
allOf:
- $ref: '#/components/schemas/coordinate'
- type: object
properties:
search_cutoff:
type: integer
description: >-
The cutoff (in meters) at which we will assume the input is too far away from civilisation to be worth correlating to the nearest graph elements.
The default is 35 km.
default: break
roadClass:
type: string
enum:
@@ -707,11 +720,14 @@ components:
- motor_scooter
- motorcycle
- pedestrian
- low_speed_vehicle
description: >-
Costing models for determining the most optimal route to take. Note that bikeshare and motorcycle are
still in beta. While Valhalla supports multimodal routing, we do not currently process transit data and
have excluded it from the list. See https://valhalla.github.io/valhalla/api/turn-by-turn/api-reference/#costing-models
for detailed descriptions of each model.
A model which influences the routing based on the type of travel.
The costing model affects parameters ranging from which roads are legally accessible
to preferences based on comfort or speed.
See https://valhalla.github.io/valhalla/api/turn-by-turn/api-reference/#costing-models
for in-depth descriptions of each costing model.
isochroneCostingModel:
type: string
enum:
@@ -730,6 +746,7 @@ components:
- motor_scooter
- motorcycle
- pedestrian
- low_speed_vehicle
mapMatchCostingModel:
type: string
enum:
@@ -756,6 +773,8 @@ components:
$ref: '#/components/schemas/motorcycleCostingOptions'
pedestrian:
$ref: '#/components/schemas/pedestrianCostingOptions'
low_speed_vehicle:
$ref: '#/components/schemas/lowSpeedVehicleCostingOptions'
useFerryCostingOption:
type: number
format: double
@@ -1173,6 +1192,41 @@ components:
type: integer
description: A penalty (in seconds) to rent a bicycle in `bikeshare` mode.
default: 0
lowSpeedVehicleCostingOptions:
allOf:
- $ref: '#/components/schemas/baseCostingOptions'
- type: object
properties:
vehicle_type:
type: string
enum:
- low_speed_vehicle
- golf_cart
default: low_speed_vehicle
description: >-
The type of vehicle:
* low_speed_vehicle (BETA): a low-speed vehicle which falls under a different regulatory and licensing regime than automobiles (ex: LSV in the US and Canada, Quadricycles in the EU, etc.)
* golf_cart: a street legal golf cart that is under a similar regulator regime as the generic LSV laws, but may need to follow special paths when available or abide by restrictions specific to golf carts.
top_speed:
type: integer
description: >-
The top speed (in kph) that the vehicle is capable of travelling.
This impacts travel time calculations as well as which roads are preferred.
A very low speed vehicle will tend to prefer lower speed roads even in the presence of other legal routes.
default: 35
minimum: 20
maximum: 60
max_allowed_speed_limit:
type: integer
description: >-
The maximum speed limit for highways on which it is legal for the vehicle to travel.
Defaults to 57 (kph; around 35 mph). Acceptable values range from 20 to 80.
Highways with *tagged* speed limits higher than this value will not be routed over (some caveats apply; this feature is still BETA).
default: 57
minimum: 20
maximum: 80
directionsOptions:
type: object
properties:
@@ -1202,14 +1256,22 @@ components:
distance:
type: number
format: double
nullable: true
description: >-
The distance (in `units`) between the location in `sources` at `from_index`
and the location in `targets` at `to_index`.
This value may be 0 in the case that the source and destination are the same,
and `null` if no route was found between the locations.
time:
type: integer
nullable: true
description: >-
The travel time (in seconds) between the location in `sources` at `from_index`
and the location in `targets` at `to_index`.
This value may be 0 in the case that the source and destination are the same,
and `null` if no route was found between the locations.
from_index:
type: integer
description: The index of the start location in the `sources` array.
@@ -1664,13 +1726,13 @@ components:
sources:
type: array
items:
$ref: '#/components/schemas/coordinate'
$ref: '#/components/schemas/matrixWaypoint'
description: The list of starting locations
minItems: 1
targets:
type: array
items:
$ref: '#/components/schemas/coordinate'
$ref: '#/components/schemas/matrixWaypoint'
description: The list of ending locations
minItems: 1
costing:
8 changes: 4 additions & 4 deletions generated-client/src/test/kotlin/TestRoutingApi.kt
Original file line number Diff line number Diff line change
@@ -120,9 +120,9 @@ internal class TestRoutingApi {
fun testTimeDistanceMatrix() {
val req = MatrixRequest(
id = "matrix",
sources = listOf(locationA),
targets = listOf(locationB, locationC),
costing = MatrixCostingModel.auto,
sources = listOf(MatrixWaypoint(58.891957, 22.726262), MatrixWaypoint(59.1558, 23.762758)),
targets = listOf(MatrixWaypoint(59.176153, 23.846605), MatrixWaypoint(59.562853, 23.096114)),
costing = MatrixCostingModel.bicycle,
costingOptions = costingOptions,
)
val res = service.timeDistanceMatrix(req).execute()
@@ -132,7 +132,7 @@ internal class TestRoutingApi {
assertEquals(req.sources.count(), body.sources.count())
assertEquals(req.targets.count(), body.targets.count())
assertEquals(ValhallaLongUnits.kilometers, body.units)
assertTrue(body.sourcesToTargets.isNotEmpty())
assertTrue(body.sourcesToTargets.first().isNotEmpty())
}

@Test

0 comments on commit de0a865

Please sign in to comment.