react-native-nitro-location-tracking 0.1.12 → 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.
Files changed (34) hide show
  1. package/README.md +30 -8
  2. package/android/CMakeLists.txt +4 -1
  3. package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/AirplaneModeMonitor.kt +72 -0
  4. package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/NitroLocationTracking.kt +65 -0
  5. package/cpp/HybridNitroLocationComplexLogicsCalculation.cpp +204 -0
  6. package/cpp/HybridNitroLocationComplexLogicsCalculation.hpp +29 -0
  7. package/ios/NitroLocationTracking.swift +21 -0
  8. package/lib/module/NitroLocationComplexLogicsCalculation.nitro.js +4 -0
  9. package/lib/module/NitroLocationComplexLogicsCalculation.nitro.js.map +1 -0
  10. package/lib/module/index.js +1 -2
  11. package/lib/module/index.js.map +1 -1
  12. package/lib/typescript/src/NitroLocationComplexLogicsCalculation.nitro.d.ts +25 -0
  13. package/lib/typescript/src/NitroLocationComplexLogicsCalculation.nitro.d.ts.map +1 -0
  14. package/lib/typescript/src/NitroLocationTracking.nitro.d.ts +3 -0
  15. package/lib/typescript/src/NitroLocationTracking.nitro.d.ts.map +1 -1
  16. package/lib/typescript/src/index.d.ts +2 -0
  17. package/lib/typescript/src/index.d.ts.map +1 -1
  18. package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.cpp +13 -0
  19. package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.hpp +3 -0
  20. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/HybridNitroLocationTrackingSpec.kt +17 -0
  21. package/nitrogen/generated/android/nitrolocationtracking+autolinking.cmake +1 -0
  22. package/nitrogen/generated/ios/c++/HybridNitroLocationTrackingSpecSwift.hpp +20 -0
  23. package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec.swift +3 -0
  24. package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec_cxx.swift +39 -0
  25. package/nitrogen/generated/shared/c++/HybridNitroLocationComplexLogicsCalculationSpec.cpp +25 -0
  26. package/nitrogen/generated/shared/c++/HybridNitroLocationComplexLogicsCalculationSpec.hpp +72 -0
  27. package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.cpp +3 -0
  28. package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.hpp +6 -0
  29. package/nitrogen/generated/shared/c++/LocationPoint.hpp +99 -0
  30. package/nitrogen/generated/shared/c++/TripMathStats.hpp +95 -0
  31. package/package.json +1 -1
  32. package/src/NitroLocationComplexLogicsCalculation.nitro.ts +37 -0
  33. package/src/NitroLocationTracking.nitro.ts +5 -0
  34. package/src/index.tsx +10 -1
package/README.md CHANGED
@@ -703,14 +703,17 @@ type PermissionStatus =
703
703
  | `stopTripCalculation()` | `TripStats` | Stop recording and get final stats |
704
704
  | `getTripStats()` | `TripStats` | Get current trip stats without stopping |
705
705
  | `resetTripCalculation()` | `void` | Reset trip calculator |
706
- | `isLocationServicesEnabled()` | `boolean` | Check if GPS/location is enabled on device |
707
- | `onProviderStatusChange(callback)` | `void` | Register GPS/network provider status callback |
708
- | `getLocationPermissionStatus()` | `PermissionStatus` | Check current location permission without prompting |
709
- | `requestLocationPermission()` | `Promise<PermissionStatus>` | Request location permission and return the resulting status |
710
- | `onPermissionStatusChange(callback)` | `void` | Register a callback that fires when location permission status changes |
711
- | `showLocalNotification(title, body)` | `void` | Show a local notification |
712
- | `updateForegroundNotification(title, body)` | `void` | Update the foreground service notification |
713
- | `destroy()` | `void` | Stop tracking and disconnect |
706
+ | `isLocationServicesEnabled()` | `boolean` | Check if GPS/location is enabled on device |
707
+ | `openLocationSettings(accuracy, interval)` | `void` | Native app dialog to enable GPS or redirect to system settings |
708
+ | `onProviderStatusChange(callback)` | `void` | Register GPS/network provider status callback |
709
+ | `isAirplaneModeEnabled()` | `boolean` | Check if Airplane mode is active on Android |
710
+ | `onAirplaneModeChange(callback)` | `void` | Register Airplane mode state-transition callback |
711
+ | `getLocationPermissionStatus()` | `PermissionStatus` | Check current location permission without prompting |
712
+ | `requestLocationPermission()` | `Promise<PermissionStatus>` | Request location permission and return the resulting status |
713
+ | `onPermissionStatusChange(callback)` | `void` | Register a callback that fires when location permission status changes |
714
+ | `showLocalNotification(title, body)` | `void` | Show a local notification |
715
+ | `updateForegroundNotification(title, body)` | `void` | Update the foreground service notification |
716
+ | `destroy()` | `void` | Stop tracking and disconnect |
714
717
 
715
718
  ### Utility Exports
716
719
 
@@ -721,6 +724,25 @@ type PermissionStatus =
721
724
  | `shortestRotation(from, to)` | Calculate shortest rotation path to avoid spinning |
722
725
  | `requestLocationPermission()` | Request location + notification permissions (Android) |
723
726
 
727
+ ### Pure C++ Math Engine
728
+
729
+ For computationally heavy tasks like array slicing and trip mapping, use the pure C++ Math Engine to bypass the JS thread entirely.
730
+
731
+ ```typescript
732
+ import { NitroLocationCalculations } from 'react-native-nitro-location-tracking';
733
+
734
+ // Instantly compute heavy math directly in C++
735
+ const stats = NitroLocationCalculations.calculateTotalTripStats(points);
736
+ ```
737
+
738
+ | Method | Returns | Description |
739
+ | :--- | :--- | :--- |
740
+ | `calculateTotalTripStats(points)` | `TripMathStats` | Instantly computes exact Haversine distance, time, and max/average speed over an array of thousands of points. |
741
+ | `filterAnomalousPoints(points, maxSpeedMps)` | `LocationPoint[]` | Cleans an array of points by mathematically stripping out teleportation jumps that exceed the given speed limit. |
742
+ | `smoothPath(points, toleranceMeters)` | `LocationPoint[]` | Simplifies a highly dense GPS path into perfect drawing lines using the Ramer-Douglas-Peucker algorithm. |
743
+ | `calculateBearing(lat1, lon1, lat2, lon2)` | `number` | Lightning fast C++ trigonometric bearing computation for raw coordinates. |
744
+ | `encodeGeohash(lat, lon, precision)` | `string` | Converts coordinates into a Geohash string instantly representing geological boundaries. |
745
+
724
746
  ## Publishing to npm
725
747
 
726
748
  ### Prerequisites
@@ -6,7 +6,10 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
6
6
  set(CMAKE_CXX_STANDARD 20)
7
7
 
8
8
  # Define C++ library and add all sources
9
- add_library(${PACKAGE_NAME} SHARED src/main/cpp/cpp-adapter.cpp)
9
+ add_library(${PACKAGE_NAME} SHARED
10
+ src/main/cpp/cpp-adapter.cpp
11
+ ../cpp/HybridNitroLocationComplexLogicsCalculation.cpp
12
+ )
10
13
 
11
14
  # Add Nitrogen specs :)
12
15
  include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/nitrolocationtracking+autolinking.cmake)
@@ -0,0 +1,72 @@
1
+ package com.margelo.nitro.nitrolocationtracking
2
+
3
+ import android.content.BroadcastReceiver
4
+ import android.content.Context
5
+ import android.content.Intent
6
+ import android.content.IntentFilter
7
+ import android.os.Build
8
+ import android.provider.Settings
9
+ import android.util.Log
10
+
11
+ class AirplaneModeMonitor(private val context: Context) {
12
+
13
+ companion object {
14
+ private const val TAG = "AirplaneModeMonitor"
15
+ }
16
+
17
+ private var callback: ((Boolean) -> Unit)? = null
18
+ private var lastState: Boolean? = null
19
+ private var receiver: BroadcastReceiver? = null
20
+
21
+ fun setCallback(callback: (Boolean) -> Unit) {
22
+ this.callback = callback
23
+
24
+ // Emit current state immediately
25
+ val current = isAirplaneModeEnabled()
26
+ lastState = current
27
+ callback.invoke(current)
28
+
29
+ registerReceiver()
30
+ }
31
+
32
+ fun isAirplaneModeEnabled(): Boolean {
33
+ return Settings.Global.getInt(
34
+ context.contentResolver,
35
+ Settings.Global.AIRPLANE_MODE_ON, 0
36
+ ) != 0
37
+ }
38
+
39
+ private fun registerReceiver() {
40
+ if (receiver != null) return
41
+
42
+ receiver = object : BroadcastReceiver() {
43
+ override fun onReceive(context: Context?, intent: Intent?) {
44
+ if (intent?.action == Intent.ACTION_AIRPLANE_MODE_CHANGED) {
45
+ val isAirplaneModeOn = intent.getBooleanExtra("state", false)
46
+ if (isAirplaneModeOn != lastState) {
47
+ lastState = isAirplaneModeOn
48
+ Log.d(TAG, "Airplane mode changed: $isAirplaneModeOn")
49
+ callback?.invoke(isAirplaneModeOn)
50
+ }
51
+ }
52
+ }
53
+ }
54
+
55
+ val filter = IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED)
56
+ context.registerReceiver(receiver, filter)
57
+ Log.d(TAG, "Airplane mode receiver registered")
58
+ }
59
+
60
+ fun destroy() {
61
+ receiver?.let {
62
+ try {
63
+ context.unregisterReceiver(it)
64
+ } catch (e: Exception) {
65
+ Log.w(TAG, "Error unregistering receiver: ${e.message}")
66
+ }
67
+ }
68
+ receiver = null
69
+ callback = null
70
+ lastState = null
71
+ }
72
+ }
@@ -28,6 +28,7 @@ class NitroLocationTracking : HybridNitroLocationTrackingSpec() {
28
28
  private var providerStatusMonitor: ProviderStatusMonitor? = null
29
29
  private var permissionStatusMonitor: PermissionStatusMonitor? = null
30
30
  private var mockLocationMonitor: MockLocationMonitor? = null
31
+ private var airplaneModeMonitor: AirplaneModeMonitor? = null
31
32
 
32
33
  private var locationCallback: ((LocationData) -> Unit)? = null
33
34
  private var motionCallback: ((Boolean) -> Unit)? = null
@@ -38,6 +39,7 @@ class NitroLocationTracking : HybridNitroLocationTrackingSpec() {
38
39
  private var providerStatusCallback: ((LocationProviderStatus, LocationProviderStatus) -> Unit)? = null
39
40
  private var permissionStatusCallback: ((PermissionStatus) -> Unit)? = null
40
41
  private var mockLocationCallback: ((Boolean) -> Unit)? = null
42
+ private var airplaneModeCallback: ((Boolean) -> Unit)? = null
41
43
 
42
44
  private var locationConfig: LocationConfig? = null
43
45
 
@@ -56,6 +58,7 @@ class NitroLocationTracking : HybridNitroLocationTrackingSpec() {
56
58
  providerStatusMonitor = ProviderStatusMonitor(context)
57
59
  permissionStatusMonitor = PermissionStatusMonitor(context)
58
60
  mockLocationMonitor = MockLocationMonitor(context)
61
+ airplaneModeMonitor = AirplaneModeMonitor(context)
59
62
  locationEngine?.dbWriter = dbWriter
60
63
  connectionManager.dbWriter = dbWriter
61
64
  Log.d(TAG, "Components initialized successfully")
@@ -364,6 +367,67 @@ class NitroLocationTracking : HybridNitroLocationTrackingSpec() {
364
367
  }
365
368
  }
366
369
 
370
+ override fun openLocationSettings(accuracy: AccuracyLevel, intervalMs: Double) {
371
+ val context = NitroModules.applicationContext ?: return
372
+ val activity = (context as? com.facebook.react.bridge.ReactContext)?.currentActivity
373
+
374
+ if (activity != null) {
375
+ val priority = when (accuracy) {
376
+ AccuracyLevel.BALANCED -> com.google.android.gms.location.Priority.PRIORITY_BALANCED_POWER_ACCURACY
377
+ AccuracyLevel.LOW -> com.google.android.gms.location.Priority.PRIORITY_LOW_POWER
378
+ else -> com.google.android.gms.location.Priority.PRIORITY_HIGH_ACCURACY
379
+ }
380
+ val interval = intervalMs.toLong()
381
+
382
+ val locationRequest = com.google.android.gms.location.LocationRequest.Builder(
383
+ priority, interval
384
+ ).build()
385
+ val builder = com.google.android.gms.location.LocationSettingsRequest.Builder()
386
+ .addLocationRequest(locationRequest)
387
+ .setAlwaysShow(true)
388
+
389
+ val client = com.google.android.gms.location.LocationServices.getSettingsClient(context)
390
+ val task = client.checkLocationSettings(builder.build())
391
+
392
+ task.addOnFailureListener { exception ->
393
+ if (exception is com.google.android.gms.common.api.ResolvableApiException) {
394
+ try {
395
+ exception.startResolutionForResult(activity, 9002) // arbitrary request code
396
+ } catch (e: Exception) {
397
+ openLocationSettingsFallback(context)
398
+ }
399
+ } else {
400
+ openLocationSettingsFallback(context)
401
+ }
402
+ }
403
+ } else {
404
+ openLocationSettingsFallback(context)
405
+ }
406
+ }
407
+
408
+ private fun openLocationSettingsFallback(context: android.content.Context) {
409
+ val intent = android.content.Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)
410
+ intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
411
+ try {
412
+ context.startActivity(intent)
413
+ } catch (e: Exception) {
414
+ Log.e(TAG, "Failed to open location settings: ${e.message}")
415
+ }
416
+ }
417
+
418
+ // === Device State Monitoring ===
419
+
420
+ override fun isAirplaneModeEnabled(): Boolean {
421
+ ensureInitialized()
422
+ return airplaneModeMonitor?.isAirplaneModeEnabled() ?: false
423
+ }
424
+
425
+ override fun onAirplaneModeChange(callback: (isEnabled: Boolean) -> Unit) {
426
+ airplaneModeCallback = callback
427
+ ensureInitialized()
428
+ airplaneModeMonitor?.setCallback(callback)
429
+ }
430
+
367
431
  // === Distance Utilities ===
368
432
 
369
433
  override fun getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double {
@@ -399,5 +463,6 @@ class NitroLocationTracking : HybridNitroLocationTrackingSpec() {
399
463
  providerStatusMonitor?.destroy()
400
464
  permissionStatusMonitor?.destroy()
401
465
  mockLocationMonitor?.destroy()
466
+ airplaneModeMonitor?.destroy()
402
467
  }
403
468
  }
@@ -0,0 +1,204 @@
1
+ #include "HybridNitroLocationComplexLogicsCalculation.hpp"
2
+ #include <cmath>
3
+ #include <algorithm>
4
+
5
+ namespace margelo::nitro::nitrolocationtracking {
6
+
7
+ // Mathematical constants
8
+ constexpr double PI = 3.14159265358979323846;
9
+ constexpr double EARTH_RADIUS_M = 6371000.0;
10
+
11
+ double HybridNitroLocationComplexLogicsCalculation::haversineDistance(double lat1, double lon1, double lat2, double lon2) {
12
+ double p = PI / 180.0;
13
+ double a = 0.5 - std::cos((lat2 - lat1) * p)/2.0 +
14
+ std::cos(lat1 * p) * std::cos(lat2 * p) *
15
+ (1.0 - std::cos((lon2 - lon1) * p))/2.0;
16
+
17
+ return 2.0 * EARTH_RADIUS_M * std::asin(std::sqrt(a));
18
+ }
19
+
20
+ TripMathStats HybridNitroLocationComplexLogicsCalculation::calculateTotalTripStats(const std::vector<LocationPoint>& points) {
21
+ TripMathStats stats = {0.0, 0.0, 0.0, 0.0};
22
+
23
+ if (points.size() < 2) return stats;
24
+
25
+ double totalDist = 0.0;
26
+ double maxSpeed = 0.0;
27
+ double totalTimeMs = points.back().timestamp - points.front().timestamp;
28
+
29
+ for (size_t i = 1; i < points.size(); ++i) {
30
+ const auto& p1 = points[i-1];
31
+ const auto& p2 = points[i];
32
+
33
+ double dist = haversineDistance(p1.latitude, p1.longitude, p2.latitude, p2.longitude);
34
+ totalDist += dist;
35
+
36
+ if (p2.speed > maxSpeed) {
37
+ maxSpeed = p2.speed;
38
+ }
39
+ }
40
+
41
+ stats.totalDistanceMeters = totalDist;
42
+ stats.elapsedTimeMs = totalTimeMs;
43
+
44
+ // Convert max speed m/s to km/h if it comes in m/s, assume it's m/s
45
+ stats.maxSpeedKmh = maxSpeed * 3.6;
46
+
47
+ if (totalTimeMs > 0) {
48
+ double avgSpeedMps = totalDist / (totalTimeMs / 1000.0);
49
+ stats.averageSpeedKmh = avgSpeedMps * 3.6;
50
+ }
51
+
52
+ return stats;
53
+ }
54
+
55
+ std::vector<LocationPoint> HybridNitroLocationComplexLogicsCalculation::filterAnomalousPoints(const std::vector<LocationPoint>& points, double maxSpeedLimitMs) {
56
+ std::vector<LocationPoint> filtered;
57
+ if (points.empty()) return filtered;
58
+
59
+ filtered.push_back(points.front());
60
+
61
+ for (size_t i = 1; i < points.size(); ++i) {
62
+ const auto& curr = points[i];
63
+ const auto& last = filtered.back();
64
+
65
+ double dist = haversineDistance(last.latitude, last.longitude, curr.latitude, curr.longitude);
66
+ double timeDiffSec = (curr.timestamp - last.timestamp) / 1000.0;
67
+
68
+ if (timeDiffSec <= 0) continue; // Invalid time
69
+
70
+ double calcSpeed = dist / timeDiffSec;
71
+
72
+ // If the calculated speed is ridiculously high (teleportation), ignore point
73
+ if (calcSpeed <= maxSpeedLimitMs) {
74
+ filtered.push_back(curr);
75
+ }
76
+ }
77
+
78
+ return filtered;
79
+ }
80
+
81
+ double HybridNitroLocationComplexLogicsCalculation::perpendicularDistance(const LocationPoint& pt, const LocationPoint& lineStart, const LocationPoint& lineEnd) {
82
+ double dx = lineEnd.longitude - lineStart.longitude;
83
+ double dy = lineEnd.latitude - lineStart.latitude;
84
+
85
+ double mag = std::sqrt(dx*dx + dy*dy);
86
+ if (mag > 0.0) {
87
+ dx /= mag;
88
+ dy /= mag;
89
+ }
90
+
91
+ double pvx = pt.longitude - lineStart.longitude;
92
+ double pvy = pt.latitude - lineStart.latitude;
93
+
94
+ double pvdot = dx * pvx + dy * pvy;
95
+
96
+ double ax = pvx - pvdot * dx;
97
+ double ay = pvy - pvdot * dy;
98
+
99
+ // Calculate distance in coordinates and roughly convert to meters using Haversine
100
+ double projLat = pt.latitude - ay;
101
+ double projLon = pt.longitude - ax;
102
+ return haversineDistance(pt.latitude, pt.longitude, projLat, projLon);
103
+ }
104
+
105
+ void HybridNitroLocationComplexLogicsCalculation::douglasPeucker(const std::vector<LocationPoint>& points, double tolerance, int firstIdx, int lastIdx, std::vector<int>& keepIndexes) {
106
+ if (lastIdx <= firstIdx + 1) return;
107
+
108
+ double maxDist = 0.0;
109
+ int index = firstIdx;
110
+
111
+ for (int i = firstIdx + 1; i < lastIdx; ++i) {
112
+ double dist = perpendicularDistance(points[i], points[firstIdx], points[lastIdx]);
113
+ if (dist > maxDist) {
114
+ index = i;
115
+ maxDist = dist;
116
+ }
117
+ }
118
+
119
+ if (maxDist > tolerance) {
120
+ keepIndexes.push_back(index);
121
+ douglasPeucker(points, tolerance, firstIdx, index, keepIndexes);
122
+ douglasPeucker(points, tolerance, index, lastIdx, keepIndexes);
123
+ }
124
+ }
125
+
126
+ std::vector<LocationPoint> HybridNitroLocationComplexLogicsCalculation::smoothPath(const std::vector<LocationPoint>& points, double toleranceMeters) {
127
+ if (points.size() < 3) return points;
128
+
129
+ std::vector<int> keepIndexes;
130
+ keepIndexes.push_back(0);
131
+ keepIndexes.push_back(points.size() - 1);
132
+
133
+ douglasPeucker(points, toleranceMeters, 0, points.size() - 1, keepIndexes);
134
+
135
+ std::sort(keepIndexes.begin(), keepIndexes.end());
136
+
137
+ std::vector<LocationPoint> smoothed;
138
+ for (int idx : keepIndexes) {
139
+ smoothed.push_back(points[idx]);
140
+ }
141
+
142
+ return smoothed;
143
+ }
144
+
145
+ double HybridNitroLocationComplexLogicsCalculation::calculateBearing(double lat1, double lon1, double lat2, double lon2) {
146
+ double p = PI / 180.0;
147
+ double dLon = (lon2 - lon1) * p;
148
+ double rLat1 = lat1 * p;
149
+ double rLat2 = lat2 * p;
150
+
151
+ double y = std::sin(dLon) * std::cos(rLat2);
152
+ double x = std::cos(rLat1) * std::sin(rLat2) -
153
+ std::sin(rLat1) * std::cos(rLat2) * std::cos(dLon);
154
+
155
+ double bearing = std::atan2(y, x) * (180.0 / PI);
156
+ return std::fmod((bearing + 360.0), 360.0);
157
+ }
158
+
159
+ std::string HybridNitroLocationComplexLogicsCalculation::encodeGeohash(double latitude, double longitude, double precisionRaw) {
160
+ static const char BASE32[] = "0123456789bcdefghjkmnpqrstuvwxyz";
161
+
162
+ int precision = static_cast<int>(precisionRaw);
163
+ if (precision < 1) precision = 1;
164
+ if (precision > 12) precision = 12;
165
+
166
+ bool is_even = true;
167
+ double lat[2] = {-90.0, 90.0};
168
+ double lon[2] = {-180.0, 180.0};
169
+ int bit = 0;
170
+ int ch = 0;
171
+ std::string geohash = "";
172
+
173
+ while (geohash.length() < precision) {
174
+ if (is_even) {
175
+ double mid = (lon[0] + lon[1]) / 2;
176
+ if (longitude > mid) {
177
+ ch |= (1 << (4 - bit));
178
+ lon[0] = mid;
179
+ } else {
180
+ lon[1] = mid;
181
+ }
182
+ } else {
183
+ double mid = (lat[0] + lat[1]) / 2;
184
+ if (latitude > mid) {
185
+ ch |= (1 << (4 - bit));
186
+ lat[0] = mid;
187
+ } else {
188
+ lat[1] = mid;
189
+ }
190
+ }
191
+
192
+ is_even = !is_even;
193
+ if (bit < 4) {
194
+ bit++;
195
+ } else {
196
+ geohash += BASE32[ch];
197
+ bit = 0;
198
+ ch = 0;
199
+ }
200
+ }
201
+ return geohash;
202
+ }
203
+
204
+ } // namespace margelo::nitro::nitrolocationtracking
@@ -0,0 +1,29 @@
1
+ #pragma once
2
+
3
+ #include "HybridNitroLocationComplexLogicsCalculationSpec.hpp"
4
+ #include <vector>
5
+
6
+ namespace margelo::nitro::nitrolocationtracking {
7
+
8
+ class HybridNitroLocationComplexLogicsCalculation : public HybridNitroLocationComplexLogicsCalculationSpec {
9
+ public:
10
+ HybridNitroLocationComplexLogicsCalculation() : HybridObject(TAG) {}
11
+
12
+ // Methods
13
+ TripMathStats calculateTotalTripStats(const std::vector<LocationPoint>& points) override;
14
+
15
+ std::vector<LocationPoint> filterAnomalousPoints(const std::vector<LocationPoint>& points, double maxSpeedLimitMs) override;
16
+
17
+ std::vector<LocationPoint> smoothPath(const std::vector<LocationPoint>& points, double toleranceMeters) override;
18
+
19
+ double calculateBearing(double lat1, double lon1, double lat2, double lon2) override;
20
+
21
+ std::string encodeGeohash(double latitude, double longitude, double precision) override;
22
+
23
+ private:
24
+ double haversineDistance(double lat1, double lon1, double lat2, double lon2);
25
+ double perpendicularDistance(const LocationPoint& pt, const LocationPoint& lineStart, const LocationPoint& lineEnd);
26
+ void douglasPeucker(const std::vector<LocationPoint>& points, double tolerance, int firstIdx, int lastIdx, std::vector<int>& keepIndexes);
27
+ };
28
+
29
+ } // namespace margelo::nitro::nitrolocationtracking
@@ -249,6 +249,27 @@ class NitroLocationTracking: HybridNitroLocationTrackingSpec {
249
249
  locationEngine.permissionStatusCallback = callback
250
250
  }
251
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
+
252
273
  // MARK: - Distance Utilities
253
274
 
254
275
  func getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double) throws -> Double {
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=NitroLocationComplexLogicsCalculation.nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["NitroLocationComplexLogicsCalculation.nitro.ts"],"mappings":"","ignoreList":[]}
@@ -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);
@@ -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;AA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AY,EAAE3B,WAAW,CAAC,MAAM;MAC9BG,mBAAmB,CAACwB,YAAY,CAAC,CAAC;MAClCP,WAAW,CAACM,OAAO,GAAG,KAAK;MAC3BV,aAAa,CAAC,KAAK,CAAC;IACtB,CAAC,EAAE,EAAE;EACP,CAAC;AACH;AAEA,OAAO,SAASa,iBAAiBA,CAACnB,MAAwB,EAAE;EAC1D,MAAM,CAACoB,eAAe,EAAEC,kBAAkB,CAAC,GAAGjC,QAAQ,CAEpD,cAAc,CAAC;EACjB,MAAM,CAACkC,WAAW,EAAEC,cAAc,CAAC,GAAGnC,QAAQ,CAAgB,IAAI,CAAC;EAEnEC,SAAS,CAAC,MAAM;IACdI,mBAAmB,CAAC+B,mBAAmB,CAACxB,MAAM,CAAC;IAC/CP,mBAAmB,CAACgC,uBAAuB,CAACJ,kBAAkB,CAAC;IAC/D5B,mBAAmB,CAACiC,SAAS,CAACH,cAAc,CAAC;IAC7C,OAAO,MAAM;MACX9B,mBAAmB,CAACkC,mBAAmB,CAAC,CAAC;IAC3C,CAAC;EACH,CAAC,EAAE,CAAC3B,MAAM,CAAC,CAAC;EAEZ,OAAO;IACLoB,eAAe;IACfE,WAAW;IACXM,OAAO,EAAEtC,WAAW,CAAC,MAAMG,mBAAmB,CAACoC,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC;IACtEC,UAAU,EAAExC,WAAW,CACrB,MAAMG,mBAAmB,CAACkC,mBAAmB,CAAC,CAAC,EAC/C,EACF,CAAC;IACDI,IAAI,EAAEzC,WAAW,CAAE0C,CAAS,IAAKvC,mBAAmB,CAACwC,WAAW,CAACD,CAAC,CAAC,EAAE,EAAE;EACzE,CAAC;AACH","ignoreList":[]}
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,gBAAgB,QAAQ,cAAW;AA0B9D,OAAO,SAASC,iBAAiBA,CAACC,MAAsB,EAAE;EACxD,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGf,QAAQ,CAAsB,IAAI,CAAC;EACnE,MAAM,CAACgB,QAAQ,EAAEC,WAAW,CAAC,GAAGjB,QAAQ,CAAC,KAAK,CAAC;EAC/C,MAAM,CAACkB,UAAU,EAAEC,aAAa,CAAC,GAAGnB,QAAQ,CAAC,KAAK,CAAC;;EAEnD;EACA,MAAMoB,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACT,MAAM,CAAC;;EAEzC;EACA,MAAMU,WAAW,GAAGpB,MAAM,CAAC,KAAK,CAAC;EAEjCF,SAAS,CAAC,MAAM;IACd,MAAMuB,MAAM,GAAGH,IAAI,CAACI,KAAK,CAACL,UAAU,CAAmB;IACvDf,mBAAmB,CAACqB,SAAS,CAACF,MAAM,CAAC;IACrCnB,mBAAmB,CAACsB,UAAU,CAACZ,WAAW,CAAC;IAC3CV,mBAAmB,CAACuB,cAAc,CAACX,WAAW,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B,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"}
@@ -101,6 +101,9 @@ export interface NitroLocationTracking extends HybridObject<{
101
101
  getLocationPermissionStatus(): PermissionStatus;
102
102
  requestLocationPermission(): Promise<PermissionStatus>;
103
103
  onPermissionStatusChange(callback: PermissionStatusCallback): void;
104
+ openLocationSettings(accuracy: AccuracyLevel, intervalMs: number): void;
105
+ isAirplaneModeEnabled(): boolean;
106
+ onAirplaneModeChange(callback: (isEnabled: boolean) => void): void;
104
107
  getDistanceBetween(lat1: number, lon1: number, lat2: number, lon2: number): number;
105
108
  getDistanceToGeofence(regionId: string): number;
106
109
  showLocalNotification(title: string, body: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"NitroLocationTracking.nitro.d.ts","sourceRoot":"","sources":["../../../src/Nitro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AC;IACjC,YAAY,IAAI,SAAS,CAAC;IAC1B,oBAAoB,IAAI,IAAI,CAAC;IAG7B,yBAAyB,IAAI,OAAO,CAAC;IACrC,sBAAsB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAG/D,2BAA2B,IAAI,gBAAgB,CAAC;IAChD,yBAAyB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACvD,wBAAwB,CAAC,QAAQ,EAAE,wBAAwB,GAAG,IAAI,CAAC;IACnE,oBAAoB,CAAC,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAGxE,qBAAqB,IAAI,OAAO,CAAC;IACjC,oBAAoB,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;IAGnE,kBAAkB,CAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,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
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;AAE/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,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc;;;;;;EAuCvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB;;;;;cAuBhC,MAAM;EAE/B"}
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"}
@@ -290,6 +290,19 @@ namespace margelo::nitro::nitrolocationtracking {
290
290
  static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_PermissionStatus::javaobject> /* callback */)>("onPermissionStatusChange_cxx");
291
291
  method(_javaPart, JFunc_void_PermissionStatus_cxx::fromCpp(callback));
292
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
+ }
293
306
  double JHybridNitroLocationTrackingSpec::getDistanceBetween(double lat1, double lon1, double lat2, double lon2) {
294
307
  static const auto method = javaClassStatic()->getMethod<double(double /* lat1 */, double /* lon1 */, double /* lat2 */, double /* lon2 */)>("getDistanceBetween");
295
308
  auto __result = method(_javaPart, lat1, lon1, lat2, lon2);
@@ -89,6 +89,9 @@ namespace margelo::nitro::nitrolocationtracking {
89
89
  PermissionStatus getLocationPermissionStatus() override;
90
90
  std::shared_ptr<Promise<PermissionStatus>> requestLocationPermission() override;
91
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;
92
95
  double getDistanceBetween(double lat1, double lon1, double lat2, double lon2) override;
93
96
  double getDistanceToGeofence(const std::string& regionId) override;
94
97
  void showLocalNotification(const std::string& title, const std::string& body) override;
@@ -227,6 +227,23 @@ abstract class HybridNitroLocationTrackingSpec: HybridObject() {
227
227
  return __result
228
228
  }
229
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
+
230
247
  @DoNotStrip
231
248
  @Keep
232
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
@@ -330,6 +330,26 @@ namespace margelo::nitro::nitrolocationtracking {
330
330
  std::rethrow_exception(__result.error());
331
331
  }
332
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
+ }
333
353
  inline double getDistanceBetween(double lat1, double lon1, double lat2, double lon2) override {
334
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));
335
355
  if (__result.hasError()) [[unlikely]] {
@@ -47,6 +47,9 @@ public protocol HybridNitroLocationTrackingSpec_protocol: HybridObject {
47
47
  func getLocationPermissionStatus() throws -> PermissionStatus
48
48
  func requestLocationPermission() throws -> Promise<PermissionStatus>
49
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
50
53
  func getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double) throws -> Double
51
54
  func getDistanceToGeofence(regionId: String) throws -> Double
52
55
  func showLocalNotification(title: String, body: String) throws -> Void
@@ -575,6 +575,45 @@ open class HybridNitroLocationTrackingSpec_cxx {
575
575
  }
576
576
  }
577
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
+
578
617
  @inline(__always)
579
618
  public final func getDistanceBetween(lat1: Double, lon1: Double, lat2: Double, lon2: Double) -> bridge.Result_double_ {
580
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
@@ -0,0 +1,72 @@
1
+ ///
2
+ /// HybridNitroLocationComplexLogicsCalculationSpec.hpp
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
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `TripMathStats` to properly resolve imports.
17
+ namespace margelo::nitro::nitrolocationtracking { struct TripMathStats; }
18
+ // Forward declaration of `LocationPoint` to properly resolve imports.
19
+ namespace margelo::nitro::nitrolocationtracking { struct LocationPoint; }
20
+
21
+ #include "TripMathStats.hpp"
22
+ #include "LocationPoint.hpp"
23
+ #include <vector>
24
+ #include <string>
25
+
26
+ namespace margelo::nitro::nitrolocationtracking {
27
+
28
+ using namespace margelo::nitro;
29
+
30
+ /**
31
+ * An abstract base class for `NitroLocationComplexLogicsCalculation`
32
+ * Inherit this class to create instances of `HybridNitroLocationComplexLogicsCalculationSpec` in C++.
33
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
34
+ * @example
35
+ * ```cpp
36
+ * class HybridNitroLocationComplexLogicsCalculation: public HybridNitroLocationComplexLogicsCalculationSpec {
37
+ * public:
38
+ * HybridNitroLocationComplexLogicsCalculation(...): HybridObject(TAG) { ... }
39
+ * // ...
40
+ * };
41
+ * ```
42
+ */
43
+ class HybridNitroLocationComplexLogicsCalculationSpec: public virtual HybridObject {
44
+ public:
45
+ // Constructor
46
+ explicit HybridNitroLocationComplexLogicsCalculationSpec(): HybridObject(TAG) { }
47
+
48
+ // Destructor
49
+ ~HybridNitroLocationComplexLogicsCalculationSpec() override = default;
50
+
51
+ public:
52
+ // Properties
53
+
54
+
55
+ public:
56
+ // Methods
57
+ virtual TripMathStats calculateTotalTripStats(const std::vector<LocationPoint>& points) = 0;
58
+ virtual std::vector<LocationPoint> filterAnomalousPoints(const std::vector<LocationPoint>& points, double maxSpeedLimitMs) = 0;
59
+ virtual std::vector<LocationPoint> smoothPath(const std::vector<LocationPoint>& points, double toleranceMeters) = 0;
60
+ virtual double calculateBearing(double lat1, double lon1, double lat2, double lon2) = 0;
61
+ virtual std::string encodeGeohash(double latitude, double longitude, double precision) = 0;
62
+
63
+ protected:
64
+ // Hybrid Setup
65
+ void loadHybridMethods() override;
66
+
67
+ protected:
68
+ // Tag for logging
69
+ static constexpr auto TAG = "NitroLocationComplexLogicsCalculation";
70
+ };
71
+
72
+ } // namespace margelo::nitro::nitrolocationtracking
@@ -48,6 +48,9 @@ namespace margelo::nitro::nitrolocationtracking {
48
48
  prototype.registerHybridMethod("getLocationPermissionStatus", &HybridNitroLocationTrackingSpec::getLocationPermissionStatus);
49
49
  prototype.registerHybridMethod("requestLocationPermission", &HybridNitroLocationTrackingSpec::requestLocationPermission);
50
50
  prototype.registerHybridMethod("onPermissionStatusChange", &HybridNitroLocationTrackingSpec::onPermissionStatusChange);
51
+ prototype.registerHybridMethod("openLocationSettings", &HybridNitroLocationTrackingSpec::openLocationSettings);
52
+ prototype.registerHybridMethod("isAirplaneModeEnabled", &HybridNitroLocationTrackingSpec::isAirplaneModeEnabled);
53
+ prototype.registerHybridMethod("onAirplaneModeChange", &HybridNitroLocationTrackingSpec::onAirplaneModeChange);
51
54
  prototype.registerHybridMethod("getDistanceBetween", &HybridNitroLocationTrackingSpec::getDistanceBetween);
52
55
  prototype.registerHybridMethod("getDistanceToGeofence", &HybridNitroLocationTrackingSpec::getDistanceToGeofence);
53
56
  prototype.registerHybridMethod("showLocalNotification", &HybridNitroLocationTrackingSpec::showLocalNotification);
@@ -35,6 +35,8 @@ namespace margelo::nitro::nitrolocationtracking { struct TripStats; }
35
35
  namespace margelo::nitro::nitrolocationtracking { enum class LocationProviderStatus; }
36
36
  // Forward declaration of `PermissionStatus` to properly resolve imports.
37
37
  namespace margelo::nitro::nitrolocationtracking { enum class PermissionStatus; }
38
+ // Forward declaration of `AccuracyLevel` to properly resolve imports.
39
+ namespace margelo::nitro::nitrolocationtracking { enum class AccuracyLevel; }
38
40
 
39
41
  #include "LocationConfig.hpp"
40
42
  #include "LocationData.hpp"
@@ -50,6 +52,7 @@ namespace margelo::nitro::nitrolocationtracking { enum class PermissionStatus; }
50
52
  #include "TripStats.hpp"
51
53
  #include "LocationProviderStatus.hpp"
52
54
  #include "PermissionStatus.hpp"
55
+ #include "AccuracyLevel.hpp"
53
56
 
54
57
  namespace margelo::nitro::nitrolocationtracking {
55
58
 
@@ -116,6 +119,9 @@ namespace margelo::nitro::nitrolocationtracking {
116
119
  virtual PermissionStatus getLocationPermissionStatus() = 0;
117
120
  virtual std::shared_ptr<Promise<PermissionStatus>> requestLocationPermission() = 0;
118
121
  virtual void onPermissionStatusChange(const std::function<void(PermissionStatus /* status */)>& callback) = 0;
122
+ virtual void openLocationSettings(AccuracyLevel accuracy, double intervalMs) = 0;
123
+ virtual bool isAirplaneModeEnabled() = 0;
124
+ virtual void onAirplaneModeChange(const std::function<void(bool /* isEnabled */)>& callback) = 0;
119
125
  virtual double getDistanceBetween(double lat1, double lon1, double lat2, double lon2) = 0;
120
126
  virtual double getDistanceToGeofence(const std::string& regionId) = 0;
121
127
  virtual void showLocalNotification(const std::string& title, const std::string& body) = 0;
@@ -0,0 +1,99 @@
1
+ ///
2
+ /// LocationPoint.hpp
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
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+
34
+
35
+ namespace margelo::nitro::nitrolocationtracking {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (LocationPoint).
39
+ */
40
+ struct LocationPoint final {
41
+ public:
42
+ double latitude SWIFT_PRIVATE;
43
+ double longitude SWIFT_PRIVATE;
44
+ double timestamp SWIFT_PRIVATE;
45
+ double speed SWIFT_PRIVATE;
46
+ double accuracy SWIFT_PRIVATE;
47
+
48
+ public:
49
+ LocationPoint() = default;
50
+ explicit LocationPoint(double latitude, double longitude, double timestamp, double speed, double accuracy): latitude(latitude), longitude(longitude), timestamp(timestamp), speed(speed), accuracy(accuracy) {}
51
+
52
+ public:
53
+ friend bool operator==(const LocationPoint& lhs, const LocationPoint& rhs) = default;
54
+ };
55
+
56
+ } // namespace margelo::nitro::nitrolocationtracking
57
+
58
+ namespace margelo::nitro {
59
+
60
+ // C++ LocationPoint <> JS LocationPoint (object)
61
+ template <>
62
+ struct JSIConverter<margelo::nitro::nitrolocationtracking::LocationPoint> final {
63
+ static inline margelo::nitro::nitrolocationtracking::LocationPoint fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
64
+ jsi::Object obj = arg.asObject(runtime);
65
+ return margelo::nitro::nitrolocationtracking::LocationPoint(
66
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "latitude"))),
67
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "longitude"))),
68
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestamp"))),
69
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed"))),
70
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accuracy")))
71
+ );
72
+ }
73
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrolocationtracking::LocationPoint& arg) {
74
+ jsi::Object obj(runtime);
75
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "latitude"), JSIConverter<double>::toJSI(runtime, arg.latitude));
76
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "longitude"), JSIConverter<double>::toJSI(runtime, arg.longitude));
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "timestamp"), JSIConverter<double>::toJSI(runtime, arg.timestamp));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "speed"), JSIConverter<double>::toJSI(runtime, arg.speed));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "accuracy"), JSIConverter<double>::toJSI(runtime, arg.accuracy));
80
+ return obj;
81
+ }
82
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
83
+ if (!value.isObject()) {
84
+ return false;
85
+ }
86
+ jsi::Object obj = value.getObject(runtime);
87
+ if (!nitro::isPlainObject(runtime, obj)) {
88
+ return false;
89
+ }
90
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "latitude")))) return false;
91
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "longitude")))) return false;
92
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestamp")))) return false;
93
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "speed")))) return false;
94
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accuracy")))) return false;
95
+ return true;
96
+ }
97
+ };
98
+
99
+ } // namespace margelo::nitro
@@ -0,0 +1,95 @@
1
+ ///
2
+ /// TripMathStats.hpp
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
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+
34
+
35
+ namespace margelo::nitro::nitrolocationtracking {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (TripMathStats).
39
+ */
40
+ struct TripMathStats final {
41
+ public:
42
+ double totalDistanceMeters SWIFT_PRIVATE;
43
+ double elapsedTimeMs SWIFT_PRIVATE;
44
+ double maxSpeedKmh SWIFT_PRIVATE;
45
+ double averageSpeedKmh SWIFT_PRIVATE;
46
+
47
+ public:
48
+ TripMathStats() = default;
49
+ explicit TripMathStats(double totalDistanceMeters, double elapsedTimeMs, double maxSpeedKmh, double averageSpeedKmh): totalDistanceMeters(totalDistanceMeters), elapsedTimeMs(elapsedTimeMs), maxSpeedKmh(maxSpeedKmh), averageSpeedKmh(averageSpeedKmh) {}
50
+
51
+ public:
52
+ friend bool operator==(const TripMathStats& lhs, const TripMathStats& rhs) = default;
53
+ };
54
+
55
+ } // namespace margelo::nitro::nitrolocationtracking
56
+
57
+ namespace margelo::nitro {
58
+
59
+ // C++ TripMathStats <> JS TripMathStats (object)
60
+ template <>
61
+ struct JSIConverter<margelo::nitro::nitrolocationtracking::TripMathStats> final {
62
+ static inline margelo::nitro::nitrolocationtracking::TripMathStats fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
63
+ jsi::Object obj = arg.asObject(runtime);
64
+ return margelo::nitro::nitrolocationtracking::TripMathStats(
65
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalDistanceMeters"))),
66
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "elapsedTimeMs"))),
67
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxSpeedKmh"))),
68
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "averageSpeedKmh")))
69
+ );
70
+ }
71
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrolocationtracking::TripMathStats& arg) {
72
+ jsi::Object obj(runtime);
73
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "totalDistanceMeters"), JSIConverter<double>::toJSI(runtime, arg.totalDistanceMeters));
74
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "elapsedTimeMs"), JSIConverter<double>::toJSI(runtime, arg.elapsedTimeMs));
75
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "maxSpeedKmh"), JSIConverter<double>::toJSI(runtime, arg.maxSpeedKmh));
76
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "averageSpeedKmh"), JSIConverter<double>::toJSI(runtime, arg.averageSpeedKmh));
77
+ return obj;
78
+ }
79
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
80
+ if (!value.isObject()) {
81
+ return false;
82
+ }
83
+ jsi::Object obj = value.getObject(runtime);
84
+ if (!nitro::isPlainObject(runtime, obj)) {
85
+ return false;
86
+ }
87
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "totalDistanceMeters")))) return false;
88
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "elapsedTimeMs")))) return false;
89
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxSpeedKmh")))) return false;
90
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "averageSpeedKmh")))) return false;
91
+ return true;
92
+ }
93
+ };
94
+
95
+ } // namespace margelo::nitro
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nitro-location-tracking",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "A React Native Nitro module for location tracking",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -0,0 +1,37 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+
3
+ export interface LocationPoint {
4
+ latitude: number;
5
+ longitude: number;
6
+ timestamp: number;
7
+ speed: number;
8
+ accuracy: number;
9
+ }
10
+
11
+ export interface TripMathStats {
12
+ totalDistanceMeters: number;
13
+ elapsedTimeMs: number;
14
+ maxSpeedKmh: number;
15
+ averageSpeedKmh: number;
16
+ }
17
+
18
+ export interface NitroLocationComplexLogicsCalculation
19
+ extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
20
+ calculateTotalTripStats(points: LocationPoint[]): TripMathStats;
21
+
22
+ filterAnomalousPoints(
23
+ points: LocationPoint[],
24
+ maxSpeedLimitMs: number
25
+ ): LocationPoint[];
26
+
27
+ smoothPath(points: LocationPoint[], toleranceMeters: number): LocationPoint[];
28
+
29
+ calculateBearing(
30
+ lat1: number,
31
+ lon1: number,
32
+ lat2: number,
33
+ lon2: number
34
+ ): number;
35
+
36
+ encodeGeohash(latitude: number, longitude: number, precision: number): string;
37
+ }
@@ -149,6 +149,11 @@ export interface NitroLocationTracking
149
149
  getLocationPermissionStatus(): PermissionStatus;
150
150
  requestLocationPermission(): Promise<PermissionStatus>;
151
151
  onPermissionStatusChange(callback: PermissionStatusCallback): void;
152
+ openLocationSettings(accuracy: AccuracyLevel, intervalMs: number): void;
153
+
154
+ // === Device State Monitoring ===
155
+ isAirplaneModeEnabled(): boolean;
156
+ onAirplaneModeChange(callback: (isEnabled: boolean) => void): void;
152
157
 
153
158
  // === Distance Utilities ===
154
159
  getDistanceBetween(
package/src/index.tsx CHANGED
@@ -12,11 +12,14 @@ const NitroLocationModule =
12
12
  'NitroLocationTracking'
13
13
  );
14
14
 
15
+ export const NitroLocationCalculations = NitroModules.createHybridObject<
16
+ import('./NitroLocationComplexLogicsCalculation.nitro').NitroLocationComplexLogicsCalculation
17
+ >('NitroLocationComplexLogicsCalculation');
18
+
15
19
  export default NitroLocationModule;
16
20
  export { requestLocationPermission } from './requestPermission';
17
21
  export { LocationSmoother } from './LocationSmoother';
18
22
  export { shortestRotation, calculateBearing } from './bearing';
19
- // export * from './db'
20
23
  export type {
21
24
  NitroLocationTracking,
22
25
  LocationData,
@@ -36,6 +39,12 @@ export type {
36
39
  MockLocationCallback,
37
40
  } from './NitroLocationTracking.nitro';
38
41
 
42
+ export type {
43
+ NitroLocationComplexLogicsCalculation,
44
+ LocationPoint,
45
+ TripMathStats,
46
+ } from './NitroLocationComplexLogicsCalculation.nitro';
47
+
39
48
  export function useDriverLocation(config: LocationConfig) {
40
49
  const [location, setLocation] = useState<LocationData | null>(null);
41
50
  const [isMoving, setIsMoving] = useState(false);