react-native-nitro-location-tracking 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -8
- package/android/CMakeLists.txt +4 -1
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/AirplaneModeMonitor.kt +72 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/MockLocationMonitor.kt +145 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/NitroLocationTracking.kt +75 -0
- package/cpp/HybridNitroLocationComplexLogicsCalculation.cpp +204 -0
- package/cpp/HybridNitroLocationComplexLogicsCalculation.hpp +29 -0
- package/ios/MockLocationMonitor.swift +120 -0
- package/ios/NitroLocationTracking.swift +29 -0
- package/lib/module/NitroLocationComplexLogicsCalculation.nitro.js +4 -0
- package/lib/module/NitroLocationComplexLogicsCalculation.nitro.js.map +1 -0
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroLocationComplexLogicsCalculation.nitro.d.ts +25 -0
- package/lib/typescript/src/NitroLocationComplexLogicsCalculation.nitro.d.ts.map +1 -0
- package/lib/typescript/src/NitroLocationTracking.nitro.d.ts +5 -0
- package/lib/typescript/src/NitroLocationTracking.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.cpp +17 -0
- package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.hpp +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/HybridNitroLocationTrackingSpec.kt +26 -0
- package/nitrogen/generated/android/nitrolocationtracking+autolinking.cmake +1 -0
- package/nitrogen/generated/ios/c++/HybridNitroLocationTrackingSpecSwift.hpp +26 -0
- package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec.swift +4 -0
- package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec_cxx.swift +55 -0
- package/nitrogen/generated/shared/c++/HybridNitroLocationComplexLogicsCalculationSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridNitroLocationComplexLogicsCalculationSpec.hpp +72 -0
- package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.hpp +7 -0
- package/nitrogen/generated/shared/c++/LocationPoint.hpp +99 -0
- package/nitrogen/generated/shared/c++/TripMathStats.hpp +95 -0
- package/package.json +1 -1
- package/src/NitroLocationComplexLogicsCalculation.nitro.ts +37 -0
- package/src/NitroLocationTracking.nitro.ts +7 -0
- package/src/index.tsx +11 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import CoreLocation
|
|
3
|
+
|
|
4
|
+
/// Periodically checks whether the device is using simulated/mock locations.
|
|
5
|
+
/// Works independently of location tracking — fires the callback when the state changes.
|
|
6
|
+
///
|
|
7
|
+
/// Detection methods:
|
|
8
|
+
/// - iOS 15+: Uses CLLocation.sourceInformation.isSimulatedBySoftware on a one-shot location request
|
|
9
|
+
/// - Simulator: Compile-time detection via #targetEnvironment(simulator)
|
|
10
|
+
/// - Jailbreak indicators: Checks for known mock location tool files
|
|
11
|
+
class MockLocationMonitor: NSObject, CLLocationManagerDelegate {
|
|
12
|
+
|
|
13
|
+
private let locationManager = CLLocationManager()
|
|
14
|
+
private var callback: ((Bool) -> Void)?
|
|
15
|
+
private var lastState: Bool?
|
|
16
|
+
private var pollTimer: Timer?
|
|
17
|
+
private let pollInterval: TimeInterval = 3.0
|
|
18
|
+
|
|
19
|
+
override init() {
|
|
20
|
+
super.init()
|
|
21
|
+
locationManager.delegate = self
|
|
22
|
+
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
func setCallback(_ callback: @escaping (Bool) -> Void) {
|
|
26
|
+
self.callback = callback
|
|
27
|
+
|
|
28
|
+
// Emit current state immediately
|
|
29
|
+
let current = checkMockLocationSync()
|
|
30
|
+
lastState = current
|
|
31
|
+
callback(current)
|
|
32
|
+
|
|
33
|
+
// Start periodic polling
|
|
34
|
+
startPolling()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private func startPolling() {
|
|
38
|
+
stopPolling()
|
|
39
|
+
pollTimer = Timer.scheduledTimer(withTimeInterval: pollInterval, repeats: true) { [weak self] _ in
|
|
40
|
+
self?.performCheck()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private func stopPolling() {
|
|
45
|
+
pollTimer?.invalidate()
|
|
46
|
+
pollTimer = nil
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private func performCheck() {
|
|
50
|
+
// First check compile-time and file-system indicators
|
|
51
|
+
let syncResult = checkMockLocationSync()
|
|
52
|
+
if syncResult != lastState {
|
|
53
|
+
lastState = syncResult
|
|
54
|
+
callback?(syncResult)
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// On iOS 15+, also do a one-shot location check for runtime detection
|
|
59
|
+
if #available(iOS 15.0, *) {
|
|
60
|
+
let status = CLLocationManager.authorizationStatus()
|
|
61
|
+
if status == .authorizedAlways || status == .authorizedWhenInUse {
|
|
62
|
+
locationManager.requestLocation()
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// MARK: - Synchronous checks (no location needed)
|
|
68
|
+
|
|
69
|
+
private func checkMockLocationSync() -> Bool {
|
|
70
|
+
#if targetEnvironment(simulator)
|
|
71
|
+
return true
|
|
72
|
+
#else
|
|
73
|
+
// Check for common jailbreak/mock location indicators
|
|
74
|
+
let suspiciousPaths = [
|
|
75
|
+
"/Applications/Cydia.app",
|
|
76
|
+
"/Library/MobileSubstrate/MobileSubstrate.dylib",
|
|
77
|
+
"/usr/sbin/sshd",
|
|
78
|
+
"/etc/apt",
|
|
79
|
+
"/private/var/lib/apt/",
|
|
80
|
+
"/Applications/LocationFaker.app",
|
|
81
|
+
"/Applications/LocationHandle.app",
|
|
82
|
+
"/Applications/LocationChanger.app"
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
for path in suspiciousPaths {
|
|
86
|
+
if FileManager.default.fileExists(atPath: path) {
|
|
87
|
+
return true
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return false
|
|
92
|
+
#endif
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// MARK: - CLLocationManagerDelegate (for iOS 15+ runtime detection)
|
|
96
|
+
|
|
97
|
+
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
|
|
98
|
+
guard let location = locations.last else { return }
|
|
99
|
+
|
|
100
|
+
if #available(iOS 15.0, *) {
|
|
101
|
+
if let sourceInfo = location.sourceInformation {
|
|
102
|
+
let isMock = sourceInfo.isSimulatedBySoftware
|
|
103
|
+
if isMock != lastState {
|
|
104
|
+
lastState = isMock
|
|
105
|
+
callback?(isMock)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
|
|
112
|
+
// Silently ignore — this is a best-effort check
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
func destroy() {
|
|
116
|
+
stopPolling()
|
|
117
|
+
callback = nil
|
|
118
|
+
lastState = nil
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -8,6 +8,7 @@ class NitroLocationTracking: HybridNitroLocationTrackingSpec {
|
|
|
8
8
|
private let dbWriter = NativeDBWriter()
|
|
9
9
|
private let notificationService = NotificationService()
|
|
10
10
|
private let geofenceManager = GeofenceManager()
|
|
11
|
+
private let mockLocationMonitor = MockLocationMonitor()
|
|
11
12
|
|
|
12
13
|
private var locationCallback: ((LocationData) -> Void)?
|
|
13
14
|
private var motionCallback: ((Bool) -> Void)?
|
|
@@ -17,6 +18,7 @@ class NitroLocationTracking: HybridNitroLocationTrackingSpec {
|
|
|
17
18
|
private var speedAlertCallback: ((SpeedAlertType, Double) -> Void)?
|
|
18
19
|
private var providerStatusCallback: ((LocationProviderStatus, LocationProviderStatus) -> Void)?
|
|
19
20
|
private var permissionStatusCallback: ((PermissionStatus) -> Void)?
|
|
21
|
+
private var mockLocationCallback: ((Bool) -> Void)?
|
|
20
22
|
private var permissionPromise: Promise<PermissionStatus>?
|
|
21
23
|
|
|
22
24
|
override init() {
|
|
@@ -125,6 +127,11 @@ class NitroLocationTracking: HybridNitroLocationTrackingSpec {
|
|
|
125
127
|
locationEngine.rejectMockLocations = reject
|
|
126
128
|
}
|
|
127
129
|
|
|
130
|
+
func onMockLocationDetected(callback: @escaping (Bool) -> Void) throws {
|
|
131
|
+
mockLocationCallback = callback
|
|
132
|
+
mockLocationMonitor.setCallback(callback)
|
|
133
|
+
}
|
|
134
|
+
|
|
128
135
|
// MARK: - Geofencing
|
|
129
136
|
|
|
130
137
|
func addGeofence(region: GeofenceRegion) throws {
|
|
@@ -242,6 +249,27 @@ class NitroLocationTracking: HybridNitroLocationTrackingSpec {
|
|
|
242
249
|
locationEngine.permissionStatusCallback = callback
|
|
243
250
|
}
|
|
244
251
|
|
|
252
|
+
func openLocationSettings(accuracy: AccuracyLevel, intervalMs: Double) throws {
|
|
253
|
+
DispatchQueue.main.async {
|
|
254
|
+
if let url = URL(string: UIApplication.openSettingsURLString) {
|
|
255
|
+
if UIApplication.shared.canOpenURL(url) {
|
|
256
|
+
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// MARK: - Device State Monitoring
|
|
263
|
+
|
|
264
|
+
func isAirplaneModeEnabled() throws -> Bool {
|
|
265
|
+
// iOS does not provide a public API for Airplane Mode detection
|
|
266
|
+
return false
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
func onAirplaneModeChange(callback: @escaping (Bool) -> Void) throws {
|
|
270
|
+
// iOS does not provide public broadcasts for Airplane Mode changes
|
|
271
|
+
}
|
|
272
|
+
|
|
245
273
|
// MARK: - Distance Utilities
|
|
246
274
|
|
|
247
275
|
func getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double) throws -> Double {
|
|
@@ -270,5 +298,6 @@ class NitroLocationTracking: HybridNitroLocationTrackingSpec {
|
|
|
270
298
|
locationEngine.stop()
|
|
271
299
|
connectionManager.disconnect()
|
|
272
300
|
geofenceManager.destroy()
|
|
301
|
+
mockLocationMonitor.destroy()
|
|
273
302
|
}
|
|
274
303
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["NitroLocationComplexLogicsCalculation.nitro.ts"],"mappings":"","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
import { useState, useEffect, useCallback, useRef } from 'react';
|
|
4
4
|
import { NitroModules } from 'react-native-nitro-modules';
|
|
5
5
|
const NitroLocationModule = NitroModules.createHybridObject('NitroLocationTracking');
|
|
6
|
+
export const NitroLocationCalculations = NitroModules.createHybridObject('NitroLocationComplexLogicsCalculation');
|
|
6
7
|
export default NitroLocationModule;
|
|
7
8
|
export { requestLocationPermission } from "./requestPermission.js";
|
|
8
9
|
export { LocationSmoother } from "./LocationSmoother.js";
|
|
9
10
|
export { shortestRotation, calculateBearing } from "./bearing.js";
|
|
10
|
-
// export * from './db'
|
|
11
|
-
|
|
12
11
|
export function useDriverLocation(config) {
|
|
13
12
|
const [location, setLocation] = useState(null);
|
|
14
13
|
const [isMoving, setIsMoving] = useState(false);
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useState","useEffect","useCallback","useRef","NitroModules","NitroLocationModule","createHybridObject","requestLocationPermission","LocationSmoother","shortestRotation","calculateBearing","useDriverLocation","config","location","setLocation","isMoving","setIsMoving","isTracking","setIsTracking","configJson","JSON","stringify","trackingRef","parsed","parse","configure","onLocation","onMotionChange","current","stopTracking","startTracking","useRideConnection","connectionState","setConnectionState","lastMessage","setLastMessage","configureConnection","onConnectionStateChange","onMessage","disconnectWebSocket","connect","connectWebSocket","disconnect","send","m","sendMessage"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,SAAS,EAAEC,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAChE,SAASC,YAAY,QAAQ,4BAA4B;AAQzD,MAAMC,mBAAmB,GACvBD,YAAY,CAACE,kBAAkB,CAC7B,uBACF,CAAC;AAEH,eAAeD,mBAAmB;AAClC,
|
|
1
|
+
{"version":3,"names":["useState","useEffect","useCallback","useRef","NitroModules","NitroLocationModule","createHybridObject","NitroLocationCalculations","requestLocationPermission","LocationSmoother","shortestRotation","calculateBearing","useDriverLocation","config","location","setLocation","isMoving","setIsMoving","isTracking","setIsTracking","configJson","JSON","stringify","trackingRef","parsed","parse","configure","onLocation","onMotionChange","current","stopTracking","startTracking","useRideConnection","connectionState","setConnectionState","lastMessage","setLastMessage","configureConnection","onConnectionStateChange","onMessage","disconnectWebSocket","connect","connectWebSocket","disconnect","send","m","sendMessage"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,SAAS,EAAEC,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAChE,SAASC,YAAY,QAAQ,4BAA4B;AAQzD,MAAMC,mBAAmB,GACvBD,YAAY,CAACE,kBAAkB,CAC7B,uBACF,CAAC;AAEH,OAAO,MAAMC,yBAAyB,GAAGH,YAAY,CAACE,kBAAkB,CAEtE,uCAAuC,CAAC;AAE1C,eAAeD,mBAAmB;AAClC,SAASG,yBAAyB,QAAQ,wBAAqB;AAC/D,SAASC,gBAAgB,QAAQ,uBAAoB;AACrD,SAASC,gBAAgB,EAAEC,g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AAC,KAAK,CAAC;IACtB,CAAC,EAAE,EAAE;EACP,CAAC;AACH;AAEA,OAAO,SAASa,iBAAiBA,CAACnB,MAAwB,EAAE;EAC1D,MAAM,CAACoB,eAAe,EAAEC,kBAAkB,CAAC,GAAGlC,QAAQ,CAEpD,cAAc,CAAC;EACjB,MAAM,CAACmC,WAAW,EAAEC,cAAc,CAAC,GAAGpC,QAAQ,CAAgB,IAAI,CAAC;EAEnEC,SAAS,CAAC,MAAM;IACdI,mBAAmB,CAACgC,mBAAmB,CAACxB,MAAM,CAAC;IAC/CR,mBAAmB,CAACiC,uBAAuB,CAACJ,kBAAkB,CAAC;IAC/D7B,mBAAmB,CAACkC,SAAS,CAACH,cAAc,CAAC;IAC7C,OAAO,MAAM;MACX/B,mBAAmB,CAACmC,mBAAmB,CAAC,CAAC;IAC3C,CAAC;EACH,CAAC,EAAE,CAAC3B,MAAM,CAAC,CAAC;EAEZ,OAAO;IACLoB,eAAe;IACfE,WAAW;IACXM,OAAO,EAAEvC,WAAW,CAAC,MAAMG,mBAAmB,CAACqC,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC;IACtEC,UAAU,EAAEzC,WAAW,CACrB,MAAMG,mBAAmB,CAACmC,mBAAmB,CAAC,CAAC,EAC/C,EACF,CAAC;IACDI,IAAI,EAAE1C,WAAW,CAAE2C,CAAS,IAAKxC,mBAAmB,CAACyC,WAAW,CAACD,CAAC,CAAC,EAAE,EAAE;EACzE,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
export interface LocationPoint {
|
|
3
|
+
latitude: number;
|
|
4
|
+
longitude: number;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
speed: number;
|
|
7
|
+
accuracy: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TripMathStats {
|
|
10
|
+
totalDistanceMeters: number;
|
|
11
|
+
elapsedTimeMs: number;
|
|
12
|
+
maxSpeedKmh: number;
|
|
13
|
+
averageSpeedKmh: number;
|
|
14
|
+
}
|
|
15
|
+
export interface NitroLocationComplexLogicsCalculation extends HybridObject<{
|
|
16
|
+
ios: 'c++';
|
|
17
|
+
android: 'c++';
|
|
18
|
+
}> {
|
|
19
|
+
calculateTotalTripStats(points: LocationPoint[]): TripMathStats;
|
|
20
|
+
filterAnomalousPoints(points: LocationPoint[], maxSpeedLimitMs: number): LocationPoint[];
|
|
21
|
+
smoothPath(points: LocationPoint[], toleranceMeters: number): LocationPoint[];
|
|
22
|
+
calculateBearing(lat1: number, lon1: number, lat2: number, lon2: number): number;
|
|
23
|
+
encodeGeohash(latitude: number, longitude: number, precision: number): string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=NitroLocationComplexLogicsCalculation.nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NitroLocationComplexLogicsCalculation.nitro.d.ts","sourceRoot":"","sources":["../../../src/NitroLocationComplexLogicsCalculation.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,qCACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;IACpD,uBAAuB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC;IAEhE,qBAAqB,CACnB,MAAM,EAAE,aAAa,EAAE,EACvB,eAAe,EAAE,MAAM,GACtB,aAAa,EAAE,CAAC;IAEnB,UAAU,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,eAAe,EAAE,MAAM,GAAG,aAAa,EAAE,CAAC;IAE9E,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,MAAM,CAAC;IAEV,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/E"}
|
|
@@ -34,6 +34,7 @@ export interface ConnectionConfig {
|
|
|
34
34
|
export type LocationCallback = (location: LocationData) => void;
|
|
35
35
|
export type ConnectionStateCallback = (state: ConnectionState) => void;
|
|
36
36
|
export type MessageCallback = (message: string) => void;
|
|
37
|
+
export type MockLocationCallback = (isMockEnabled: boolean) => void;
|
|
37
38
|
export interface GeofenceRegion {
|
|
38
39
|
id: string;
|
|
39
40
|
latitude: number;
|
|
@@ -83,6 +84,7 @@ export interface NitroLocationTracking extends HybridObject<{
|
|
|
83
84
|
forceSync(): Promise<boolean>;
|
|
84
85
|
isFakeGpsEnabled(): boolean;
|
|
85
86
|
setRejectMockLocations(reject: boolean): void;
|
|
87
|
+
onMockLocationDetected(callback: MockLocationCallback): void;
|
|
86
88
|
addGeofence(region: GeofenceRegion): void;
|
|
87
89
|
removeGeofence(regionId: string): void;
|
|
88
90
|
removeAllGeofences(): void;
|
|
@@ -99,6 +101,9 @@ export interface NitroLocationTracking extends HybridObject<{
|
|
|
99
101
|
getLocationPermissionStatus(): PermissionStatus;
|
|
100
102
|
requestLocationPermission(): Promise<PermissionStatus>;
|
|
101
103
|
onPermissionStatusChange(callback: PermissionStatusCallback): void;
|
|
104
|
+
openLocationSettings(accuracy: AccuracyLevel, intervalMs: number): void;
|
|
105
|
+
isAirplaneModeEnabled(): boolean;
|
|
106
|
+
onAirplaneModeChange(callback: (isEnabled: boolean) => void): void;
|
|
102
107
|
getDistanceBetween(lat1: number, lon1: number, lat2: number, lon2: number): number;
|
|
103
108
|
getDistanceToGeofence(regionId: string): number;
|
|
104
109
|
showLocalNotification(title: string, body: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroLocationTracking.nitro.d.ts","sourceRoot":"","sources":["../../../src/NitroLocationTracking.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI/D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;AACxD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,cAAc,GAAG,cAAc,CAAC;AAI5E,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,aAAa,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,2BAA2B,EAAE,MAAM,CAAC;IACpC,0BAA0B,EAAE,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,MAAM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,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,MAAM,CAAC;IACV,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAGhD,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzD,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAGhE,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { NitroLocationTracking, LocationData, LocationConfig, ConnectionConfig } from './NitroLocationTracking.nitro';
|
|
2
2
|
declare const NitroLocationModule: NitroLocationTracking;
|
|
3
|
+
export declare const NitroLocationCalculations: import("./NitroLocationComplexLogicsCalculation.nitro").NitroLocationComplexLogicsCalculation;
|
|
3
4
|
export default NitroLocationModule;
|
|
4
5
|
export { requestLocationPermission } from './requestPermission';
|
|
5
6
|
export { LocationSmoother } from './LocationSmoother';
|
|
6
7
|
export { shortestRotation, calculateBearing } from './bearing';
|
|
7
|
-
export type { NitroLocationTracking, LocationData, LocationConfig, ConnectionConfig, GeofenceRegion, GeofenceEvent, GeofenceCallback, SpeedConfig, SpeedAlertType, SpeedAlertCallback, TripStats, LocationProviderStatus, ProviderStatusCallback, PermissionStatus, PermissionStatusCallback, } from './NitroLocationTracking.nitro';
|
|
8
|
+
export type { NitroLocationTracking, LocationData, LocationConfig, ConnectionConfig, GeofenceRegion, GeofenceEvent, GeofenceCallback, SpeedConfig, SpeedAlertType, SpeedAlertCallback, TripStats, LocationProviderStatus, ProviderStatusCallback, PermissionStatus, PermissionStatusCallback, MockLocationCallback, } from './NitroLocationTracking.nitro';
|
|
9
|
+
export type { NitroLocationComplexLogicsCalculation, LocationPoint, TripMathStats, } from './NitroLocationComplexLogicsCalculation.nitro';
|
|
8
10
|
export declare function useDriverLocation(config: LocationConfig): {
|
|
9
11
|
location: LocationData | null;
|
|
10
12
|
isMoving: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,gBAAgB,EACjB,MAAM,+BAA+B,CAAC;AAEvC,QAAA,MAAM,mBAAmB,uBAGtB,CAAC;AAEJ,eAAe,mBAAmB,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,gBAAgB,EACjB,MAAM,+BAA+B,CAAC;AAEvC,QAAA,MAAM,mBAAmB,uBAGtB,CAAC;AAEJ,eAAO,MAAM,yBAAyB,+FAEI,CAAC;AAE3C,eAAe,mBAAmB,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC/D,YAAY,EACV,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,SAAS,EACT,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EACV,qCAAqC,EACrC,aAAa,EACb,aAAa,GACd,MAAM,+CAA+C,CAAC;AAEvD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc;;;;;;EAuCvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB;;;;;cAuBhC,MAAM;EAE/B"}
|
|
@@ -205,6 +205,10 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
205
205
|
static const auto method = javaClassStatic()->getMethod<void(jboolean /* reject */)>("setRejectMockLocations");
|
|
206
206
|
method(_javaPart, reject);
|
|
207
207
|
}
|
|
208
|
+
void JHybridNitroLocationTrackingSpec::onMockLocationDetected(const std::function<void(bool /* isMockEnabled */)>& callback) {
|
|
209
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_bool::javaobject> /* callback */)>("onMockLocationDetected_cxx");
|
|
210
|
+
method(_javaPart, JFunc_void_bool_cxx::fromCpp(callback));
|
|
211
|
+
}
|
|
208
212
|
void JHybridNitroLocationTrackingSpec::addGeofence(const GeofenceRegion& region) {
|
|
209
213
|
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JGeofenceRegion> /* region */)>("addGeofence");
|
|
210
214
|
method(_javaPart, JGeofenceRegion::fromCpp(region));
|
|
@@ -286,6 +290,19 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
286
290
|
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_PermissionStatus::javaobject> /* callback */)>("onPermissionStatusChange_cxx");
|
|
287
291
|
method(_javaPart, JFunc_void_PermissionStatus_cxx::fromCpp(callback));
|
|
288
292
|
}
|
|
293
|
+
void JHybridNitroLocationTrackingSpec::openLocationSettings(AccuracyLevel accuracy, double intervalMs) {
|
|
294
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JAccuracyLevel> /* accuracy */, double /* intervalMs */)>("openLocationSettings");
|
|
295
|
+
method(_javaPart, JAccuracyLevel::fromCpp(accuracy), intervalMs);
|
|
296
|
+
}
|
|
297
|
+
bool JHybridNitroLocationTrackingSpec::isAirplaneModeEnabled() {
|
|
298
|
+
static const auto method = javaClassStatic()->getMethod<jboolean()>("isAirplaneModeEnabled");
|
|
299
|
+
auto __result = method(_javaPart);
|
|
300
|
+
return static_cast<bool>(__result);
|
|
301
|
+
}
|
|
302
|
+
void JHybridNitroLocationTrackingSpec::onAirplaneModeChange(const std::function<void(bool /* isEnabled */)>& callback) {
|
|
303
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_bool::javaobject> /* callback */)>("onAirplaneModeChange_cxx");
|
|
304
|
+
method(_javaPart, JFunc_void_bool_cxx::fromCpp(callback));
|
|
305
|
+
}
|
|
289
306
|
double JHybridNitroLocationTrackingSpec::getDistanceBetween(double lat1, double lon1, double lat2, double lon2) {
|
|
290
307
|
static const auto method = javaClassStatic()->getMethod<double(double /* lat1 */, double /* lon1 */, double /* lat2 */, double /* lon2 */)>("getDistanceBetween");
|
|
291
308
|
auto __result = method(_javaPart, lat1, lon1, lat2, lon2);
|
|
@@ -72,6 +72,7 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
72
72
|
std::shared_ptr<Promise<bool>> forceSync() override;
|
|
73
73
|
bool isFakeGpsEnabled() override;
|
|
74
74
|
void setRejectMockLocations(bool reject) override;
|
|
75
|
+
void onMockLocationDetected(const std::function<void(bool /* isMockEnabled */)>& callback) override;
|
|
75
76
|
void addGeofence(const GeofenceRegion& region) override;
|
|
76
77
|
void removeGeofence(const std::string& regionId) override;
|
|
77
78
|
void removeAllGeofences() override;
|
|
@@ -88,6 +89,9 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
88
89
|
PermissionStatus getLocationPermissionStatus() override;
|
|
89
90
|
std::shared_ptr<Promise<PermissionStatus>> requestLocationPermission() override;
|
|
90
91
|
void onPermissionStatusChange(const std::function<void(PermissionStatus /* status */)>& callback) override;
|
|
92
|
+
void openLocationSettings(AccuracyLevel accuracy, double intervalMs) override;
|
|
93
|
+
bool isAirplaneModeEnabled() override;
|
|
94
|
+
void onAirplaneModeChange(const std::function<void(bool /* isEnabled */)>& callback) override;
|
|
91
95
|
double getDistanceBetween(double lat1, double lon1, double lat2, double lon2) override;
|
|
92
96
|
double getDistanceToGeofence(const std::string& regionId) override;
|
|
93
97
|
void showLocalNotification(const std::string& title, const std::string& body) override;
|
|
@@ -134,6 +134,15 @@ abstract class HybridNitroLocationTrackingSpec: HybridObject() {
|
|
|
134
134
|
@Keep
|
|
135
135
|
abstract fun setRejectMockLocations(reject: Boolean): Unit
|
|
136
136
|
|
|
137
|
+
abstract fun onMockLocationDetected(callback: (isMockEnabled: Boolean) -> Unit): Unit
|
|
138
|
+
|
|
139
|
+
@DoNotStrip
|
|
140
|
+
@Keep
|
|
141
|
+
private fun onMockLocationDetected_cxx(callback: Func_void_bool): Unit {
|
|
142
|
+
val __result = onMockLocationDetected(callback)
|
|
143
|
+
return __result
|
|
144
|
+
}
|
|
145
|
+
|
|
137
146
|
@DoNotStrip
|
|
138
147
|
@Keep
|
|
139
148
|
abstract fun addGeofence(region: GeofenceRegion): Unit
|
|
@@ -218,6 +227,23 @@ abstract class HybridNitroLocationTrackingSpec: HybridObject() {
|
|
|
218
227
|
return __result
|
|
219
228
|
}
|
|
220
229
|
|
|
230
|
+
@DoNotStrip
|
|
231
|
+
@Keep
|
|
232
|
+
abstract fun openLocationSettings(accuracy: AccuracyLevel, intervalMs: Double): Unit
|
|
233
|
+
|
|
234
|
+
@DoNotStrip
|
|
235
|
+
@Keep
|
|
236
|
+
abstract fun isAirplaneModeEnabled(): Boolean
|
|
237
|
+
|
|
238
|
+
abstract fun onAirplaneModeChange(callback: (isEnabled: Boolean) -> Unit): Unit
|
|
239
|
+
|
|
240
|
+
@DoNotStrip
|
|
241
|
+
@Keep
|
|
242
|
+
private fun onAirplaneModeChange_cxx(callback: Func_void_bool): Unit {
|
|
243
|
+
val __result = onAirplaneModeChange(callback)
|
|
244
|
+
return __result
|
|
245
|
+
}
|
|
246
|
+
|
|
221
247
|
@DoNotStrip
|
|
222
248
|
@Keep
|
|
223
249
|
abstract fun getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double
|
|
@@ -33,6 +33,7 @@ target_sources(
|
|
|
33
33
|
# Autolinking Setup
|
|
34
34
|
../nitrogen/generated/android/nitrolocationtrackingOnLoad.cpp
|
|
35
35
|
# Shared Nitrogen C++ sources
|
|
36
|
+
../nitrogen/generated/shared/c++/HybridNitroLocationComplexLogicsCalculationSpec.cpp
|
|
36
37
|
../nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.cpp
|
|
37
38
|
# Android-specific Nitrogen C++ sources
|
|
38
39
|
../nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.cpp
|
|
@@ -216,6 +216,12 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
216
216
|
std::rethrow_exception(__result.error());
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
+
inline void onMockLocationDetected(const std::function<void(bool /* isMockEnabled */)>& callback) override {
|
|
220
|
+
auto __result = _swiftPart.onMockLocationDetected(callback);
|
|
221
|
+
if (__result.hasError()) [[unlikely]] {
|
|
222
|
+
std::rethrow_exception(__result.error());
|
|
223
|
+
}
|
|
224
|
+
}
|
|
219
225
|
inline void addGeofence(const GeofenceRegion& region) override {
|
|
220
226
|
auto __result = _swiftPart.addGeofence(std::forward<decltype(region)>(region));
|
|
221
227
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -324,6 +330,26 @@ namespace margelo::nitro::nitrolocationtracking {
|
|
|
324
330
|
std::rethrow_exception(__result.error());
|
|
325
331
|
}
|
|
326
332
|
}
|
|
333
|
+
inline void openLocationSettings(AccuracyLevel accuracy, double intervalMs) override {
|
|
334
|
+
auto __result = _swiftPart.openLocationSettings(static_cast<int>(accuracy), std::forward<decltype(intervalMs)>(intervalMs));
|
|
335
|
+
if (__result.hasError()) [[unlikely]] {
|
|
336
|
+
std::rethrow_exception(__result.error());
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
inline bool isAirplaneModeEnabled() override {
|
|
340
|
+
auto __result = _swiftPart.isAirplaneModeEnabled();
|
|
341
|
+
if (__result.hasError()) [[unlikely]] {
|
|
342
|
+
std::rethrow_exception(__result.error());
|
|
343
|
+
}
|
|
344
|
+
auto __value = std::move(__result.value());
|
|
345
|
+
return __value;
|
|
346
|
+
}
|
|
347
|
+
inline void onAirplaneModeChange(const std::function<void(bool /* isEnabled */)>& callback) override {
|
|
348
|
+
auto __result = _swiftPart.onAirplaneModeChange(callback);
|
|
349
|
+
if (__result.hasError()) [[unlikely]] {
|
|
350
|
+
std::rethrow_exception(__result.error());
|
|
351
|
+
}
|
|
352
|
+
}
|
|
327
353
|
inline double getDistanceBetween(double lat1, double lon1, double lat2, double lon2) override {
|
|
328
354
|
auto __result = _swiftPart.getDistanceBetween(std::forward<decltype(lat1)>(lat1), std::forward<decltype(lon1)>(lon1), std::forward<decltype(lat2)>(lat2), std::forward<decltype(lon2)>(lon2));
|
|
329
355
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -30,6 +30,7 @@ public protocol HybridNitroLocationTrackingSpec_protocol: HybridObject {
|
|
|
30
30
|
func forceSync() throws -> Promise<Bool>
|
|
31
31
|
func isFakeGpsEnabled() throws -> Bool
|
|
32
32
|
func setRejectMockLocations(reject: Bool) throws -> Void
|
|
33
|
+
func onMockLocationDetected(callback: @escaping (_ isMockEnabled: Bool) -> Void) throws -> Void
|
|
33
34
|
func addGeofence(region: GeofenceRegion) throws -> Void
|
|
34
35
|
func removeGeofence(regionId: String) throws -> Void
|
|
35
36
|
func removeAllGeofences() throws -> Void
|
|
@@ -46,6 +47,9 @@ public protocol HybridNitroLocationTrackingSpec_protocol: HybridObject {
|
|
|
46
47
|
func getLocationPermissionStatus() throws -> PermissionStatus
|
|
47
48
|
func requestLocationPermission() throws -> Promise<PermissionStatus>
|
|
48
49
|
func onPermissionStatusChange(callback: @escaping (_ status: PermissionStatus) -> Void) throws -> Void
|
|
50
|
+
func openLocationSettings(accuracy: AccuracyLevel, intervalMs: Double) throws -> Void
|
|
51
|
+
func isAirplaneModeEnabled() throws -> Bool
|
|
52
|
+
func onAirplaneModeChange(callback: @escaping (_ isEnabled: Bool) -> Void) throws -> Void
|
|
49
53
|
func getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double) throws -> Double
|
|
50
54
|
func getDistanceToGeofence(regionId: String) throws -> Double
|
|
51
55
|
func showLocalNotification(title: String, body: String) throws -> Void
|
|
@@ -350,6 +350,22 @@ open class HybridNitroLocationTrackingSpec_cxx {
|
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
+
@inline(__always)
|
|
354
|
+
public final func onMockLocationDetected(callback: bridge.Func_void_bool) -> bridge.Result_void_ {
|
|
355
|
+
do {
|
|
356
|
+
try self.__implementation.onMockLocationDetected(callback: { () -> (Bool) -> Void in
|
|
357
|
+
let __wrappedFunction = bridge.wrap_Func_void_bool(callback)
|
|
358
|
+
return { (__isMockEnabled: Bool) -> Void in
|
|
359
|
+
__wrappedFunction.call(__isMockEnabled)
|
|
360
|
+
}
|
|
361
|
+
}())
|
|
362
|
+
return bridge.create_Result_void_()
|
|
363
|
+
} catch (let __error) {
|
|
364
|
+
let __exceptionPtr = __error.toCpp()
|
|
365
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
353
369
|
@inline(__always)
|
|
354
370
|
public final func addGeofence(region: GeofenceRegion) -> bridge.Result_void_ {
|
|
355
371
|
do {
|
|
@@ -559,6 +575,45 @@ open class HybridNitroLocationTrackingSpec_cxx {
|
|
|
559
575
|
}
|
|
560
576
|
}
|
|
561
577
|
|
|
578
|
+
@inline(__always)
|
|
579
|
+
public final func openLocationSettings(accuracy: Int32, intervalMs: Double) -> bridge.Result_void_ {
|
|
580
|
+
do {
|
|
581
|
+
try self.__implementation.openLocationSettings(accuracy: margelo.nitro.nitrolocationtracking.AccuracyLevel(rawValue: accuracy)!, intervalMs: intervalMs)
|
|
582
|
+
return bridge.create_Result_void_()
|
|
583
|
+
} catch (let __error) {
|
|
584
|
+
let __exceptionPtr = __error.toCpp()
|
|
585
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
@inline(__always)
|
|
590
|
+
public final func isAirplaneModeEnabled() -> bridge.Result_bool_ {
|
|
591
|
+
do {
|
|
592
|
+
let __result = try self.__implementation.isAirplaneModeEnabled()
|
|
593
|
+
let __resultCpp = __result
|
|
594
|
+
return bridge.create_Result_bool_(__resultCpp)
|
|
595
|
+
} catch (let __error) {
|
|
596
|
+
let __exceptionPtr = __error.toCpp()
|
|
597
|
+
return bridge.create_Result_bool_(__exceptionPtr)
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
@inline(__always)
|
|
602
|
+
public final func onAirplaneModeChange(callback: bridge.Func_void_bool) -> bridge.Result_void_ {
|
|
603
|
+
do {
|
|
604
|
+
try self.__implementation.onAirplaneModeChange(callback: { () -> (Bool) -> Void in
|
|
605
|
+
let __wrappedFunction = bridge.wrap_Func_void_bool(callback)
|
|
606
|
+
return { (__isEnabled: Bool) -> Void in
|
|
607
|
+
__wrappedFunction.call(__isEnabled)
|
|
608
|
+
}
|
|
609
|
+
}())
|
|
610
|
+
return bridge.create_Result_void_()
|
|
611
|
+
} catch (let __error) {
|
|
612
|
+
let __exceptionPtr = __error.toCpp()
|
|
613
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
562
617
|
@inline(__always)
|
|
563
618
|
public final func getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double) -> bridge.Result_double_ {
|
|
564
619
|
do {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroLocationComplexLogicsCalculationSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridNitroLocationComplexLogicsCalculationSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::nitrolocationtracking {
|
|
11
|
+
|
|
12
|
+
void HybridNitroLocationComplexLogicsCalculationSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("calculateTotalTripStats", &HybridNitroLocationComplexLogicsCalculationSpec::calculateTotalTripStats);
|
|
18
|
+
prototype.registerHybridMethod("filterAnomalousPoints", &HybridNitroLocationComplexLogicsCalculationSpec::filterAnomalousPoints);
|
|
19
|
+
prototype.registerHybridMethod("smoothPath", &HybridNitroLocationComplexLogicsCalculationSpec::smoothPath);
|
|
20
|
+
prototype.registerHybridMethod("calculateBearing", &HybridNitroLocationComplexLogicsCalculationSpec::calculateBearing);
|
|
21
|
+
prototype.registerHybridMethod("encodeGeohash", &HybridNitroLocationComplexLogicsCalculationSpec::encodeGeohash);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
} // namespace margelo::nitro::nitrolocationtracking
|