Skip to content

Commit c77b33e

Browse files
committed
fix(ios): fixed isLocationOnPath and distanceToEnd
1 parent e48eee9 commit c77b33e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/typings/ak.carto.ios.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,19 @@
55
// constructor(o?: { minZoom: number; maxZoom: number; baseURL: string });
66
// setAutoHD(value: boolean);
77
// }
8+
9+
declare class CartoAdditionsUtils extends NSObject {
10+
static alloc(): CartoAdditionsUtils; // inherited from NSObject
11+
12+
static distanceToEndWithIntPoly(index: number, poly: NTMapPosVector): number;
13+
14+
static isLocationOnPoly(point: NTMapPos, poly: NTMapPosVector): number;
15+
16+
static isLocationOnPolyClosed(point: NTMapPos, poly: NTMapPosVector, closed: boolean): number;
17+
18+
static isLocationOnPolyClosedGeodesic(point: NTMapPos, poly: NTMapPosVector, closed: boolean, geodesic: boolean): number;
19+
20+
static isLocationOnPolyClosedGeodesicToleranceEarth(point: NTMapPos, poly: NTMapPosVector, closed: boolean, geodesic: boolean, toleranceEarth: number): number;
21+
22+
static new(): CartoAdditionsUtils; // inherited from NSObject
23+
}

src/utils/index.ios.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { BaseNative, getFileName, getRelativePathToApp } from '../index.common';
22
import { DirAssetPackageOptions, ZippedAssetPackageOptions } from '.';
33
import { File, FileSystemEntity, Folder, knownFolders, path } from '@nativescript/core/file-system';
4+
import { DefaultLatLonKeys, GenericMapPos, MapPosVector, toNativeMapPos } from '../core';
5+
import { mapPosVectorFromArgs } from '..';
46

57
export function nativeVectorToArray(nVector: NTStringVector) {
68
const count = nVector.size();
@@ -145,3 +147,15 @@ export class DirAssetPackage extends BaseNative<NTDirAssetPackageImpl, DirAssetP
145147
}
146148
}
147149
}
150+
export function distanceToEnd<T = DefaultLatLonKeys>(index: number, coordinates: MapPosVector<T> | GenericMapPos<T>[]) {
151+
return CartoAdditionsUtils.distanceToEndWithIntPoly(index, mapPosVectorFromArgs<T>(coordinates));
152+
}
153+
export function isLocationOnPath<T = DefaultLatLonKeys>(
154+
point: GenericMapPos<T>,
155+
coordinates: MapPosVector<T> | GenericMapPos<T>[],
156+
closed?: boolean,
157+
geodesic?: boolean,
158+
toleranceEarth?: number
159+
): number {
160+
return CartoAdditionsUtils.isLocationOnPolyClosedGeodesicToleranceEarth(toNativeMapPos<T>(point), mapPosVectorFromArgs<T>(coordinates), closed, geodesic, toleranceEarth);
161+
}

0 commit comments

Comments
 (0)