diff --git a/Package.swift b/Package.swift index 9610ba34..7255e070 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,7 @@ if useLocalFramework { path: "./common/target/ios/libferrostar-rs.xcframework" ) } else { - let releaseTag = "0.14.0" + let releaseTag = "0.15.0" let releaseChecksum = "f8503dc1657b99c83489bac78dd2f4c014ae3d20e9d83f3e779260d255b6cbbb" binaryTarget = .binaryTarget( name: "FerrostarCoreRS", diff --git a/android/build.gradle b/android/build.gradle index be704e9b..609801f9 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -12,5 +12,5 @@ plugins { allprojects { group = "com.stadiamaps.ferrostar" - version = "0.14.0" + version = "0.15.0" } diff --git a/android/core/src/androidTest/java/com/stadiamaps/ferrostar/core/ValhallaCoreTest.kt b/android/core/src/androidTest/java/com/stadiamaps/ferrostar/core/ValhallaCoreTest.kt index 201e5a4f..3a68c8bf 100644 --- a/android/core/src/androidTest/java/com/stadiamaps/ferrostar/core/ValhallaCoreTest.kt +++ b/android/core/src/androidTest/java/com/stadiamaps/ferrostar/core/ValhallaCoreTest.kt @@ -303,7 +303,7 @@ class ValhallaCoreTest { navigationControllerConfig = NavigationControllerConfig( StepAdvanceMode.Manual, RouteDeviationTracking.None, CourseFiltering.RAW), - costingOptions = mapOf("auto" to mapOf("useTolls" to 0))) + options = mapOf("costing_options" to mapOf("auto" to mapOf("useTolls" to 0)))) return runTest { val routes = diff --git a/android/core/src/main/java/com/stadiamaps/ferrostar/core/FerrostarCore.kt b/android/core/src/main/java/com/stadiamaps/ferrostar/core/FerrostarCore.kt index 59f4d187..53571f4b 100644 --- a/android/core/src/main/java/com/stadiamaps/ferrostar/core/FerrostarCore.kt +++ b/android/core/src/main/java/com/stadiamaps/ferrostar/core/FerrostarCore.kt @@ -136,11 +136,11 @@ class FerrostarCore( locationProvider: LocationProvider, navigationControllerConfig: NavigationControllerConfig, foregroundServiceManager: ForegroundServiceManager? = null, - costingOptions: Map = emptyMap(), + options: Map = emptyMap(), ) : this( RouteProvider.RouteAdapter( RouteAdapter.newValhallaHttp( - valhallaEndpointURL.toString(), profile, jsonAdapter.toJson(costingOptions))), + valhallaEndpointURL.toString(), profile, jsonAdapter.toJson(options))), httpClient, locationProvider, foregroundServiceManager, diff --git a/android/demo-app/src/main/java/com/stadiamaps/ferrostar/AppModule.kt b/android/demo-app/src/main/java/com/stadiamaps/ferrostar/AppModule.kt index c4a1f899..1c7a4dc4 100644 --- a/android/demo-app/src/main/java/com/stadiamaps/ferrostar/AppModule.kt +++ b/android/demo-app/src/main/java/com/stadiamaps/ferrostar/AppModule.kt @@ -79,7 +79,7 @@ object AppModule { minimumHorizontalAccuracy = 25U, automaticAdvanceDistance = 10U), RouteDeviationTracking.StaticThreshold(15U, 25.0), CourseFiltering.SNAP_TO_ROUTE), - costingOptions = mapOf("bicycle" to mapOf("use_roads" to 0.2))) + options = mapOf("costingOptions" to mapOf("bicycle" to mapOf("use_roads" to 0.2)))) // Not all navigation apps will require this sort of extra configuration. // In fact, we hope that most don't! diff --git a/apple/DemoApp/Demo/DemoNavigationView.swift b/apple/DemoApp/Demo/DemoNavigationView.swift index fa0e62e6..4c78e220 100644 --- a/apple/DemoApp/Demo/DemoNavigationView.swift +++ b/apple/DemoApp/Demo/DemoNavigationView.swift @@ -55,7 +55,7 @@ struct DemoNavigationView: View { profile: "bicycle", locationProvider: locationProvider, navigationControllerConfig: config, - costingOptions: ["bicycle": ["use_roads": 0.2]] + options: ["costing_options": ["bicycle": ["use_roads": 0.2]]] ) // NOTE: Not all applications will need a delegate. Read the NavigationDelegate documentation for details. ferrostarCore.delegate = navigationDelegate diff --git a/apple/Sources/FerrostarCore/FerrostarCore.swift b/apple/Sources/FerrostarCore/FerrostarCore.swift index 4ccd9f69..bf26648d 100644 --- a/apple/Sources/FerrostarCore/FerrostarCore.swift +++ b/apple/Sources/FerrostarCore/FerrostarCore.swift @@ -93,6 +93,10 @@ public protocol FerrostarCoreDelegate: AnyObject { private var config: SwiftNavigationControllerConfig + /// Initializes a core instance with the given parameters. + /// + /// This designated initializer is the most flexible, but the convenience ones may be easier to use. + /// for common configuraitons. public init( routeProvider: RouteProvider, locationProvider: LocationProviding, @@ -110,25 +114,36 @@ public protocol FerrostarCoreDelegate: AnyObject { locationProvider.delegate = self } + /// Initializes a core instance for a Valhalla API accessed over HTTP. + /// + /// - Parameters + /// - valhallaEndpointUrl: The URL of the Valhalla endpoint you're trying to hit for route requests. If necessary, + /// include your API key here. + /// - profile: The Valhalla costing model to use for route requests. + /// - navigationControllerConfig: Configuration of the navigation session. + /// - options: A dictionary of options to include in the request. The Valhalla request generator sets several + /// automatically (like `format`), but this lets you add arbitrary options so you can access the full API. + /// - networkSession: The network session to use. Don't set this unless you need to replace the networking stack + /// (ex: for testing). public convenience init( valhallaEndpointUrl: URL, profile: String, locationProvider: LocationProviding, navigationControllerConfig: SwiftNavigationControllerConfig, - costingOptions: [String: Any] = [:], + options: [String: Any] = [:], networkSession: URLRequestLoading = URLSession.shared ) throws { - guard let jsonCostingOptions = try String( - data: JSONSerialization.data(withJSONObject: costingOptions), + guard let jsonOptions = try String( + data: JSONSerialization.data(withJSONObject: options), encoding: .utf8 ) else { - throw InstantiationError.JsonError + throw InstantiationError.OptionsJsonParseError } let adapter = try RouteAdapter.newValhallaHttp( endpointUrl: valhallaEndpointUrl.absoluteString, profile: profile, - costingOptionsJson: jsonCostingOptions + optionsJson: jsonOptions ) self.init( routeProvider: .routeAdapter(adapter), diff --git a/apple/Sources/UniFFI/ferrostar.swift b/apple/Sources/UniFFI/ferrostar.swift index 1ce53f75..c1b31d46 100644 --- a/apple/Sources/UniFFI/ferrostar.swift +++ b/apple/Sources/UniFFI/ferrostar.swift @@ -809,13 +809,13 @@ open class RouteAdapter: } public static func newValhallaHttp(endpointUrl: String, profile: String, - costingOptionsJson: String?) throws -> RouteAdapter + optionsJson: String?) throws -> RouteAdapter { try FfiConverterTypeRouteAdapter.lift(rustCallWithError(FfiConverterTypeInstantiationError.lift) { uniffi_ferrostar_fn_constructor_routeadapter_new_valhalla_http( FfiConverterString.lower(endpointUrl), FfiConverterString.lower(profile), - FfiConverterOptionString.lower(costingOptionsJson), $0 + FfiConverterOptionString.lower(optionsJson), $0 ) }) } @@ -2708,7 +2708,7 @@ public func FfiConverterTypeCourseFiltering_lower(_ value: CourseFiltering) -> R extension CourseFiltering: Equatable, Hashable {} public enum InstantiationError { - case JsonError + case OptionsJsonParseError } public struct FfiConverterTypeInstantiationError: FfiConverterRustBuffer { @@ -2717,7 +2717,7 @@ public struct FfiConverterTypeInstantiationError: FfiConverterRustBuffer { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> InstantiationError { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .JsonError + case 1: return .OptionsJsonParseError default: throw UniffiInternalError.unexpectedEnumCase } @@ -2725,7 +2725,7 @@ public struct FfiConverterTypeInstantiationError: FfiConverterRustBuffer { public static func write(_ value: InstantiationError, into buf: inout [UInt8]) { switch value { - case .JsonError: + case .OptionsJsonParseError: writeInt(&buf, Int32(1)) } } @@ -4075,13 +4075,13 @@ public func createRouteFromOsrm(routeData: Data, waypointData: Data, polylinePre * This is provided as a convenience for use from foreign code when creating your own [`routing_adapters::RouteAdapter`]. */ public func createValhallaRequestGenerator(endpointUrl: String, profile: String, - costingOptionsJson: String?) throws -> RouteRequestGenerator + optionsJson: String?) throws -> RouteRequestGenerator { try FfiConverterTypeRouteRequestGenerator.lift(rustCallWithError(FfiConverterTypeInstantiationError.lift) { uniffi_ferrostar_fn_func_create_valhalla_request_generator( FfiConverterString.lower(endpointUrl), FfiConverterString.lower(profile), - FfiConverterOptionString.lower(costingOptionsJson), $0 + FfiConverterOptionString.lower(optionsJson), $0 ) }) } @@ -4172,7 +4172,7 @@ private var initializationResult: InitializationResult = { if uniffi_ferrostar_checksum_func_create_route_from_osrm() != 42270 { return InitializationResult.apiChecksumMismatch } - if uniffi_ferrostar_checksum_func_create_valhalla_request_generator() != 62919 { + if uniffi_ferrostar_checksum_func_create_valhalla_request_generator() != 16275 { return InitializationResult.apiChecksumMismatch } if uniffi_ferrostar_checksum_func_get_route_polyline() != 31480 { @@ -4217,7 +4217,7 @@ private var initializationResult: InitializationResult = { if uniffi_ferrostar_checksum_constructor_routeadapter_new() != 32290 { return InitializationResult.apiChecksumMismatch } - if uniffi_ferrostar_checksum_constructor_routeadapter_new_valhalla_http() != 63624 { + if uniffi_ferrostar_checksum_constructor_routeadapter_new_valhalla_http() != 3524 { return InitializationResult.apiChecksumMismatch } diff --git a/apple/Tests/FerrostarCoreTests/FerrostarCoreTests.swift b/apple/Tests/FerrostarCoreTests/FerrostarCoreTests.swift index 9e18292e..cb0a9913 100644 --- a/apple/Tests/FerrostarCoreTests/FerrostarCoreTests.swift +++ b/apple/Tests/FerrostarCoreTests/FerrostarCoreTests.swift @@ -237,7 +237,7 @@ final class FerrostarCoreTests: XCTestCase { routeDeviationTracking: .none, snappedLocationCourseFiltering: .raw ), - costingOptions: ["low_speed_vehicle": ["vehicle_type": "golf_cart"]], + options: ["costing_options": ["low_speed_vehicle": ["vehicle_type": "golf_cart"]]], networkSession: mockSession ) diff --git a/common/Cargo.lock b/common/Cargo.lock index c806da7e..63ec804c 100644 --- a/common/Cargo.lock +++ b/common/Cargo.lock @@ -337,7 +337,7 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "ferrostar" -version = "0.14.0" +version = "0.15.0" dependencies = [ "assert-json-diff", "geo", diff --git a/common/ferrostar/Cargo.toml b/common/ferrostar/Cargo.toml index 95af0236..1b9ba209 100644 --- a/common/ferrostar/Cargo.toml +++ b/common/ferrostar/Cargo.toml @@ -2,7 +2,7 @@ lints.workspace = true [package] name = "ferrostar" -version = "0.14.0" +version = "0.15.0" readme = "README.md" description = "The core of modern turn-by-turn navigation." keywords = ["navigation", "routing", "valhalla", "osrm"] diff --git a/common/ferrostar/src/lib.rs b/common/ferrostar/src/lib.rs index fb5e4bcd..42fb2bc7 100644 --- a/common/ferrostar/src/lib.rs +++ b/common/ferrostar/src/lib.rs @@ -82,15 +82,13 @@ impl UniffiCustomTypeConverter for Uuid { fn create_valhalla_request_generator( endpoint_url: String, profile: String, - costing_options_json: Option, + options_json: Option, ) -> Result, InstantiationError> { - Ok(Arc::new( - ValhallaHttpRequestGenerator::with_costing_options_json( - endpoint_url, - profile, - costing_options_json, - )?, - )) + Ok(Arc::new(ValhallaHttpRequestGenerator::with_options_json( + endpoint_url, + profile, + options_json.as_deref(), + )?)) } /// Creates a [`RouteResponseParser`] capable of parsing OSRM responses. diff --git a/common/ferrostar/src/routing_adapters/error.rs b/common/ferrostar/src/routing_adapters/error.rs index 8c2d29c0..e5cd9b1d 100644 --- a/common/ferrostar/src/routing_adapters/error.rs +++ b/common/ferrostar/src/routing_adapters/error.rs @@ -8,8 +8,11 @@ use alloc::string::{String, ToString}; #[cfg_attr(feature = "uniffi", derive(uniffi::Error))] #[cfg_attr(feature = "std", derive(thiserror::Error))] pub enum InstantiationError { - #[cfg_attr(feature = "std", error("Error generating JSON for the request."))] - JsonError, + #[cfg_attr( + feature = "std", + error("Error parsing the JSON options for the request.") + )] + OptionsJsonParseError, } // TODO: See comment above @@ -40,7 +43,7 @@ impl From for RoutingRequestGenerationErr impl From for InstantiationError { fn from(_: serde_json::Error) -> Self { - InstantiationError::JsonError + InstantiationError::OptionsJsonParseError } } diff --git a/common/ferrostar/src/routing_adapters/mod.rs b/common/ferrostar/src/routing_adapters/mod.rs index ecf2fff9..c65ce6a2 100644 --- a/common/ferrostar/src/routing_adapters/mod.rs +++ b/common/ferrostar/src/routing_adapters/mod.rs @@ -152,12 +152,12 @@ impl RouteAdapter { pub fn new_valhalla_http( endpoint_url: String, profile: String, - costing_options_json: Option, + options_json: Option, ) -> Result { - let request_generator = Arc::new(ValhallaHttpRequestGenerator::with_costing_options_json( + let request_generator = Arc::new(ValhallaHttpRequestGenerator::with_options_json( endpoint_url, profile, - costing_options_json, + options_json.as_deref(), )?); let response_parser = Arc::new(OsrmResponseParser::new(6)); Ok(Self::new(request_generator, response_parser)) diff --git a/common/ferrostar/src/routing_adapters/valhalla.rs b/common/ferrostar/src/routing_adapters/valhalla.rs index b19dbd69..4a9905ec 100644 --- a/common/ferrostar/src/routing_adapters/valhalla.rs +++ b/common/ferrostar/src/routing_adapters/valhalla.rs @@ -5,10 +5,11 @@ use crate::models::{UserLocation, Waypoint, WaypointKind}; use crate::routing_adapters::RouteRequestGenerator; #[cfg(all(not(feature = "std"), feature = "alloc"))] use alloc::collections::BTreeMap as HashMap; -use serde_json::{json, Value as JsonValue}; +use serde_json::{json, Map, Value as JsonValue}; #[cfg(feature = "std")] use std::collections::HashMap; +use crate::routing_adapters::error::InstantiationError; #[cfg(feature = "alloc")] use alloc::{ string::{String, ToString}, @@ -30,32 +31,102 @@ pub struct ValhallaHttpRequestGenerator { /// The Valhalla costing model to use. profile: String, // TODO: Language, units, and other top-level parameters - /// JSON costing options to pass through. - costing_options: JsonValue, + /// Arbitrary key/value pairs which override the defaults. + /// + /// These can contain complex nested structures, + /// as in the case of `costing_options`. + options: Map, } impl ValhallaHttpRequestGenerator { - pub fn new(endpoint_url: String, profile: String, costing_options: Option) -> Self { + /// Creates a new Valhalla request generator given an endpoint URL, a profile name, + /// and options to include in the request JSON. + /// + /// # Examples + /// + /// ``` + /// use serde_json::{json, Map, Value as JsonValue}; + /// # use ferrostar::routing_adapters::valhalla::ValhallaHttpRequestGenerator; + /// // Example for illustration; you should do proper error checking when parsing this way, + /// // or else use [`ValhallaHttpRequestGenerator::with_options_json`] + /// let options: Map = json!({ + /// "costing_options": { + /// "low_speed_vehicle": { + /// "vehicle_type": "golf_cart" + /// } + /// } + /// }).as_object().unwrap().to_owned(); + /// + /// // Without options + /// let request_generator_no_opts = ValhallaHttpRequestGenerator::new( + /// "https://api.stadiamaps.com/route/v1?api_key=YOUR-API-KEY".to_string(), + /// "low_speed_vehicle".to_string(), + /// Map::new() + /// ); + /// + /// // With options + /// let request_generator_opts = ValhallaHttpRequestGenerator::new( + /// "https://api.stadiamaps.com/route/v1?api_key=YOUR-API-KEY".to_string(), + /// "low_speed_vehicle".to_string(), + /// options + /// ); + /// ``` + pub fn new(endpoint_url: String, profile: String, options: Map) -> Self { Self { endpoint_url, profile, - costing_options: costing_options.unwrap_or(json!({})), + options, } } - pub fn with_costing_options_json( + /// Creates a new Valhalla request generator given an endpoint URL, a profile name, + /// and options to include in the request JSON. + /// Options in this constructor are a JSON fragment representing any + /// options you want to add along with the request. + /// + /// # Examples + /// + /// ``` + /// # use ferrostar::routing_adapters::valhalla::ValhallaHttpRequestGenerator; + /// let options = r#"{ + /// "costing_options": { + /// "low_speed_vehicle": { + /// "vehicle_type": "golf_cart" + /// } + /// } + /// }"#; + /// + /// // Without options + /// let request_generator_no_opts = ValhallaHttpRequestGenerator::with_options_json( + /// "https://api.stadiamaps.com/route/v1?api_key=YOUR-API-KEY".to_string(), + /// "low_speed_vehicle".to_string(), + /// None, + /// ); + /// + /// // With options + /// let request_generator_opts = ValhallaHttpRequestGenerator::with_options_json( + /// "https://api.stadiamaps.com/route/v1?api_key=YOUR-API-KEY".to_string(), + /// "low_speed_vehicle".to_string(), + /// Some(options), + /// ); + /// ``` + pub fn with_options_json( endpoint_url: String, profile: String, - costing_options_json: Option, - ) -> Result { - let parsed_costing_options: JsonValue = match costing_options_json.as_deref() { - Some(options) => serde_json::from_str(options)?, - None => json!({}), + options_json: Option<&str>, + ) -> Result { + let parsed_options = match options_json.as_deref() { + // TODO: Another error variant + Some(options) => serde_json::from_str::(options)? + .as_object() + .ok_or(InstantiationError::OptionsJsonParseError)? + .to_owned(), + None => Map::new(), }; Ok(Self { endpoint_url, profile, - costing_options: parsed_costing_options, + options: parsed_options, }) } } @@ -99,7 +170,7 @@ impl RouteRequestGenerator for ValhallaHttpRequestGenerator { // Though it would be nice to use PBF if we can get the required data. // However, certain info (like banners) are only available in the OSRM format. // TODO: Trace attributes as we go rather than pulling a fat payload upfront that we might ditch later? - let args = json!({ + let mut args = json!({ "format": "osrm", "filters": { "action": "include", @@ -114,8 +185,12 @@ impl RouteRequestGenerator for ValhallaHttpRequestGenerator { "voice_instructions": true, "costing": &self.profile, "locations": locations, - "costing_options": &self.costing_options, }); + + for (k, v) in &self.options { + args[k] = v.clone(); + } + let body = serde_json::to_vec(&args)?; Ok(RouteRequest::HttpPost { url: self.endpoint_url.clone(), @@ -170,8 +245,11 @@ mod tests { #[test] fn not_enough_locations() { - let generator = - ValhallaHttpRequestGenerator::new(ENDPOINT_URL.to_string(), COSTING.to_string(), None); + let generator = ValhallaHttpRequestGenerator::new( + ENDPOINT_URL.to_string(), + COSTING.to_string(), + Map::new(), + ); // At least two locations are required assert!(matches!( @@ -183,12 +261,12 @@ mod tests { fn generate_body( user_location: UserLocation, waypoints: Vec, - costing_options_json: Option, + options_json: Option<&str>, ) -> JsonValue { - let generator = ValhallaHttpRequestGenerator::with_costing_options_json( + let generator = ValhallaHttpRequestGenerator::with_options_json( ENDPOINT_URL.to_string(), COSTING.to_string(), - costing_options_json, + options_json, ) .expect("Unable to create request generator"); @@ -271,20 +349,48 @@ mod tests { fn request_body_without_costing_options() { let body_json = generate_body(USER_LOCATION, WAYPOINTS.to_vec(), None); + assert!(body_json["costing_options"].is_null()); + } + + #[test] + #[should_panic] + fn request_body_invalid_costing_options() { + // Valid JSON, but it's not an object. + let body_json = generate_body( + USER_LOCATION, + WAYPOINTS.to_vec(), + Some(r#"["costing_options"]"#), + ); + + assert!(body_json["costing_options"].is_null()); + } + + #[test] + fn request_body_with_costing_options() { + let body_json = generate_body( + USER_LOCATION, + WAYPOINTS.to_vec(), + Some(r#"{"costing_options": {"bicycle": {"bicycle_type": "Road"}}}"#), + ); + assert_json_include!( actual: body_json, expected: json!({ - "costing_options": {}, + "costing_options": { + "bicycle": { + "bicycle_type": "Road", + }, + }, }) ); } #[test] - fn request_body_with_costing_options() { + fn request_body_with_multiple_options() { let body_json = generate_body( USER_LOCATION, WAYPOINTS.to_vec(), - Some(r#"{"bicycle": {"bicycle_type": "Road"}}"#.to_string()), + Some(r#"{"units": "mi", "costing_options": {"bicycle": {"bicycle_type": "Road"}}}"#), ); assert_json_include!( @@ -295,14 +401,18 @@ mod tests { "bicycle_type": "Road", }, }, + "units": "mi" }) ); } #[test] fn request_body_with_invalid_horizontal_accuracy() { - let generator = - ValhallaHttpRequestGenerator::new(ENDPOINT_URL.to_string(), COSTING.to_string(), None); + let generator = ValhallaHttpRequestGenerator::new( + ENDPOINT_URL.to_string(), + COSTING.to_string(), + Map::new(), + ); let location = UserLocation { coordinates: GeographicCoordinate { lat: 0.0, lng: 0.0 }, horizontal_accuracy: -6.0, diff --git a/web/index.html b/web/index.html index 02b1434e..80d2aba8 100644 --- a/web/index.html +++ b/web/index.html @@ -96,7 +96,7 @@ ferrostar.center = {lng: -122.42, lat: 37.81}; ferrostar.zoom = 18; - ferrostar.costingOptions = { bicycle: { use_roads: 0.2 } }; + ferrostar.options = {costing_options: { bicycle: { use_roads: 0.2 } } }; ferrostar.customStyles = searchBoxStyle; ferrostar.geolocateOnLoad = false; diff --git a/web/package-lock.json b/web/package-lock.json index 5eef0de3..c5585ffa 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "@stadiamaps/ferrostar-webcomponents", - "version": "0.14.0", + "version": "0.15.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@stadiamaps/ferrostar-webcomponents", - "version": "0.14.0", + "version": "0.15.0", "license": "BSD-3-Clause", "dependencies": { "@stadiamaps/ferrostar": "file:../common/ferrostar/pkg", diff --git a/web/package.json b/web/package.json index d68b59cc..1f451624 100644 --- a/web/package.json +++ b/web/package.json @@ -6,7 +6,7 @@ "CatMe0w (https://github.com/CatMe0w)", "Luke Seelenbinder " ], - "version": "0.14.0", + "version": "0.15.0", "license": "BSD-3-Clause", "type": "module", "main": "./dist/ferrostar-webcomponents.js", diff --git a/web/src/ferrostar-map.ts b/web/src/ferrostar-map.ts index f8f1af94..63050cdd 100644 --- a/web/src/ferrostar-map.ts +++ b/web/src/ferrostar-map.ts @@ -45,7 +45,7 @@ export class FerrostarMap extends LitElement { // TODO: type @property({ type: Object, attribute: false }) - costingOptions: object = {}; + options: object = {}; // TODO: type @state() @@ -216,7 +216,7 @@ export class FerrostarMap extends LitElement { async getRoutes(initialLocation: any, waypoints: any) { // Initialize the route adapter // (NOTE: currently only supports Valhalla, but working toward expansion) - this.routeAdapter = new RouteAdapter(this.valhallaEndpointUrl, this.profile, JSON.stringify(this.costingOptions)); + this.routeAdapter = new RouteAdapter(this.valhallaEndpointUrl, this.profile, JSON.stringify(this.options)); // Generate the request body const routeRequest = this.routeAdapter.generateRequest(initialLocation, waypoints);