Skip to content

Commit 4fcdd42

Browse files
committed
fix: routing ensure we use the correct profile
1 parent 1d7838d commit 4fcdd42

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/routing/index.android.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,15 @@ export const RoutingAction = {
7070
},
7171
};
7272
abstract class RoutingService<T extends com.akylas.carto.additions.AKRoutingService, U extends RoutingServiceOptions> extends BaseRoutingService<T, U> {
73+
@nativeProperty profile: string;
7374
// createNative(options: RoutingServiceOptions) {
7475
// return new com.carto.geocoding.RoutingService();
7576
// }
7677
public calculateRoute(options: RoutingRequest, callback: (err: any, res: RoutingResult) => void) {
7778
return new Promise((resolve, reject) => {
7879
const nRequest = new com.carto.routing.RoutingRequest(options.projection.getNative(), mapPosVectorFromArgs(options.points));
80+
// ensure the profile is set
81+
this.getNative().setProfile(this.profile);
7982
if (options.customOptions) {
8083
Object.keys(options.customOptions).forEach((k) => {
8184
nRequest.setCustomParameter(k, JSVariantToNative(options.customOptions[k]));
@@ -129,13 +132,14 @@ class OSRMOfflineRoutingService extends RoutingService<com.akylas.carto.addition
129132
}
130133

131134
class ValhallaOfflineRoutingService extends RoutingService<com.akylas.carto.additions.AKValhallaOfflineRoutingService, ValhallaOfflineRoutingServiceOptions> {
132-
@nativeProperty profile: string;
133135
createNative(options: ValhallaOfflineRoutingServiceOptions) {
134136
return new com.akylas.carto.additions.AKValhallaOfflineRoutingService(options.path);
135137
}
136138
public matchRoute(options: RouteMatchingRequest, callback: (err: any, res: RouteMatchingResult) => void) {
137139
return new Promise((resolve, reject) => {
138140
const nRequest = new com.carto.routing.RouteMatchingRequest(options.projection.getNative(), mapPosVectorFromArgs(options.points), options.accuracy);
141+
// ensure the profile is set
142+
this.getNative().setProfile(this.profile);
139143
this.getNative().matchRouteCallback(
140144
nRequest,
141145
new com.akylas.carto.additions.RoutingServiceRouteMatchingCallback({

src/routing/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export interface PackageManagerRoutingServiceOptions extends RoutingServiceOptio
7070
}
7171
export class PackageManagerRoutingService extends RoutingService<any, PackageManagerRoutingServiceOptions> {}
7272

73-
export type ValhallaProfile = 'car' | 'auto' | 'auto_shorter' | 'bus' | 'bicycle' | 'pedestrian' | 'truck';
73+
export type ValhallaProfile = 'car' | 'auto' | 'bus' | 'bicycle' | 'pedestrian' | 'truck';
7474

7575
export interface ValhallaOfflineRoutingServiceOptions extends RoutingServiceOptions {
7676
path: string;

src/routing/index.ios.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mapPosVectorFromArgs } from '..';
1+
import { mapPosVectorFromArgs, nativeProperty } from '..';
22
import { NativeVector } from '../core';
33
import {
44
CartoOnlineRoutingServiceOptions,
@@ -36,6 +36,7 @@ export enum RoutingAction {
3636
WAIT = NTRoutingAction.T_ROUTING_ACTION_WAIT,
3737
}
3838
abstract class RoutingService<T extends NTRoutingService, U extends RoutingServiceOptions> extends BaseRoutingService<T, U> {
39+
@nativeProperty profile: string;
3940
public calculateRoute(options: RoutingRequest, callback: (err: Error, res: RoutingResult) => void) {
4041
return new Promise((resolve, reject) => {
4142
const nRequest = NTRoutingRequest.alloc().initWithProjectionPoints(options.projection.getNative(), mapPosVectorFromArgs(options.points));
@@ -44,6 +45,9 @@ abstract class RoutingService<T extends NTRoutingService, U extends RoutingServi
4445
nRequest.setCustomParameterValue(k, JSVariantToNative(options.customOptions[k]));
4546
});
4647
}
48+
49+
// ensure the profile is set
50+
this.getNative().setProfile(this.profile);
4751
const nRes = this.getNative().calculateRoute(nRequest);
4852
const result = nRes ? new RoutingResult(nRes) : null;
4953
resolve(result);
@@ -110,7 +114,8 @@ class PackageManagerValhallaRoutingService extends RoutingService<NTPackageManag
110114
public matchRoute(options: RouteMatchingRequest, callback: (err: Error, res: RouteMatchingResult) => void) {
111115
return new Promise((resolve, reject) => {
112116
const nRequest = NTRouteMatchingRequest.alloc().initWithProjectionPointsAccuracy(options.projection.getNative(), mapPosVectorFromArgs(options.points), options.accuracy);
113-
117+
// ensure the profile is set
118+
this.getNative().setProfile(this.profile);
114119
const nRes = this.getNative().matchRoute(nRequest);
115120
const result = nRes ? new RouteMatchingResult(nRes) : null;
116121
resolve(result);

0 commit comments

Comments
 (0)