Skip to content

Commit 8004eea

Browse files
committed
chore: upgrading
1 parent b94055c commit 8004eea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+5259
-3504
lines changed

packages/ui-carto/platforms/android/java/com/akylas/carto/additions/AKRoutingServiceAdditions.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ enum RoutingAction {
4343
static final String TAG = "AKRoutingServiceAdditions";
4444
static Handler mainHandler = null;
4545

46-
public static void calculateRoute (final RoutingService service, final RoutingRequest request, final String profile, final RoutingServiceRouteCallback callback ) {
46+
public static void calculateRoute (final RoutingService service, final RoutingRequest request, final String profile, final Boolean stringify, final RoutingServiceRouteCallback callback) {
4747
Thread thread = new Thread(new Runnable() {
4848
@Override
4949
public void run() {
@@ -60,28 +60,29 @@ public void run() {
6060
mainHandler.post(new Runnable() {
6161
@Override
6262
public void run() {
63-
callback.onRoutingResult(e, null);
63+
callback.onRoutingResult(e, null, null);
6464
}
6565
});
6666
} else {
67-
callback.onRoutingResult(e, null);
67+
callback.onRoutingResult(e, null, null);
6868
}
6969
return;
7070
}
7171

7272
final RoutingResult fRa = result;
73+
final String fStrResult = stringify ? stringifyRoutingResult(result) : null;
7374
if (AKMapView.RUN_ON_MAIN_THREAD) {
7475
if (mainHandler == null) {
7576
mainHandler = new Handler(android.os.Looper.getMainLooper());
7677
}
7778
mainHandler.post(new Runnable() {
7879
@Override
7980
public void run() {
80-
callback.onRoutingResult(null, fRa);
81+
callback.onRoutingResult(null, fRa, fStrResult);
8182
}
8283
});
8384
} else {
84-
callback.onRoutingResult(null, fRa);
85+
callback.onRoutingResult(null, fRa, fStrResult);
8586
}
8687

8788
}

packages/ui-carto/platforms/android/java/com/akylas/carto/additions/RoutingServiceRouteCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
import com.carto.routing.RoutingResult;
44

55
public interface RoutingServiceRouteCallback {
6-
void onRoutingResult(Exception e, RoutingResult result);
6+
void onRoutingResult(Exception e, RoutingResult result, String strResult);
77
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// AKFeatureCollectionSearchService.swift
3+
// demosvelte
4+
//
5+
// Created by Martin Guillon on 14/02/2024.
6+
// Copyright © 2024 NativeScript. All rights reserved.
7+
//
8+
import CartoMobileSDK
9+
10+
@objc(AKFeatureCollectionSearchService)
11+
@objcMembers
12+
class AKFeatureCollectionSearchService: NTFeatureCollectionSearchService {
13+
14+
func findFeaturesCallback(_ request: NTSearchRequest!, _ callback: @escaping (_ features: NTFeatureCollection?) -> Void) {
15+
DispatchQueue.global(qos: .background).async {
16+
let result = self.findFeatures(request)
17+
if (AKMapView.RUN_ON_MAIN_THREAD) {
18+
DispatchQueue.main.async() {
19+
callback(result)
20+
}
21+
} else {
22+
callback(result)
23+
}
24+
}
25+
}
26+
}
27+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// AKGeocodingServiceAdditions.swift
3+
// demosvelte
4+
//
5+
// Created by Martin Guillon on 14/02/2024.
6+
// Copyright © 2024 NativeScript. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import CartoMobileSDK
11+
12+
@objc(AKGeocodingServiceAdditions)
13+
@objcMembers
14+
class AKGeocodingServiceAdditions: NSObject {
15+
static var runOnMainThread = AKMapView.RUN_ON_MAIN_THREAD
16+
static func calculateAddress (_ service: NTGeocodingService, _ request: NTGeocodingRequest, _ callback: @escaping (_ result: NTGeocodingResultVector?) -> Void) {
17+
DispatchQueue.global(qos: .background).async {
18+
let result = service.calculateAddresses(request)
19+
if (runOnMainThread) {
20+
DispatchQueue.main.async() {
21+
callback(result)
22+
}
23+
} else {
24+
callback(result)
25+
}
26+
}
27+
}
28+
29+
static func calculateAddressReverse (_ service: NTReverseGeocodingService, _ request: NTReverseGeocodingRequest, _ callback: @escaping (_ result: NTGeocodingResultVector?) -> Void) {
30+
DispatchQueue.global(qos: .background).async {
31+
let result = service.calculateAddresses(request)
32+
if (AKMapView.RUN_ON_MAIN_THREAD) {
33+
DispatchQueue.main.async() {
34+
callback(result)
35+
}
36+
} else {
37+
callback(result)
38+
}
39+
}
40+
}
41+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// AKHillshadeRasterTileLayer.swift
3+
// demosvelte
4+
//
5+
// Created by Martin Guillon on 14/02/2024.
6+
// Copyright © 2024 NativeScript. All rights reserved.
7+
//
8+
9+
import CartoMobileSDK
10+
11+
@objc(AKHillshadeRasterTileLayer)
12+
@objcMembers
13+
class AKHillshadeRasterTileLayer: NTHillshadeRasterTileLayer {
14+
var runOnMainThread = AKMapView.RUN_ON_MAIN_THREAD
15+
16+
func getElevation(_ pos: NTMapPos, callback: @escaping (_ elevation: Double)-> Void) {
17+
DispatchQueue.global(qos: .background).async {
18+
let result = self.getElevation(pos)
19+
if (self.runOnMainThread) {
20+
DispatchQueue.main.async() {
21+
callback(result)
22+
}
23+
} else {
24+
callback(result)
25+
}
26+
}
27+
}
28+
func getElevations(_ pos: NTMapPosVector, callback: @escaping (_ elevations: NTDoubleVector?)-> Void) {
29+
DispatchQueue.global(qos: .background).async {
30+
let result = self.getElevations(pos)
31+
if (self.runOnMainThread) {
32+
DispatchQueue.main.async() {
33+
callback(result)
34+
}
35+
} else {
36+
callback(result)
37+
}
38+
}
39+
}
40+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import CartoMobileSDK
2+
3+
@objc(AKMapEventListener)
4+
public protocol AKMapEventListener: AnyObject {
5+
6+
7+
/**
8+
* Listener method that gets called at the end of the rendering process when the
9+
* map view needs no further refreshing.
10+
* Note that there can still be background processes (tile loading) that may change
11+
* the map view but these may take long time.
12+
* This method is called from GL renderer thread, not from main thread.
13+
*/
14+
func onMapIdle();
15+
/**
16+
* Listener method that gets called when the map is panned, rotated, tilted or zoomed.
17+
* The callback is used for both UI events and map changes resulting from API calls.
18+
* It is recommended to use onMapInteraction callback instead of onMapMoved, if possible.
19+
* Doing any calls to update MapView state from this method is potentially dangerous and may
20+
* result in deadlocks or crashes.
21+
* The thread this method is called from may vary.
22+
*/
23+
func onMapMoved(_ userAction: Bool);
24+
/**
25+
* Listener method that gets called when map is in 'stable' state - map animations have finished,
26+
* user has lifted fingers from the screen. This method is similar to onMapIdle, but is called less
27+
* frequently and takes account touch state.
28+
* The thread this method is called from may vary.
29+
*/
30+
func onMapStable(_ userAction: Bool);
31+
/**
32+
* Listener method that gets called when user has interacted with the map. The callback
33+
* includes info about interaction type (panning, zooming, etc).
34+
* @param mapInteractionInfo A container that provides information about the interaction.
35+
*/
36+
func onMapInteraction(_ mapInteractionInfo: NTMapInteractionInfo, _ userAction: Bool);
37+
/**
38+
* Listener method that gets called when a click is performed on an empty area of the map.
39+
* This method will NOT be called from the main thread.
40+
* @param mapClickInfo A container that provides information about the click.
41+
*/
42+
func onMapClicked( _ mapClickInfo: NTMapClickInfo);
43+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
2+
import CartoMobileSDK
3+
4+
@objc(AKMapView)
5+
@objcMembers
6+
class AKMapView: NTMapView {
7+
static var RUN_ON_MAIN_THREAD = true
8+
var listener: AKMapEventListener? = nil
9+
var userAction: Bool = false
10+
11+
class MapEventListener : NTMapEventListener {
12+
unowned var parent: AKMapView? = nil
13+
init(_ parent: AKMapView) {
14+
super.init()
15+
self.parent = parent
16+
}
17+
override init!(cptr: UnsafeMutableRawPointer!, swigOwnCObject ownCObject: Bool) {
18+
super.init(cptr: cptr, swigOwnCObject: ownCObject)
19+
}
20+
21+
22+
override func onMapIdle() {
23+
if (!AKMapView.RUN_ON_MAIN_THREAD) {
24+
parent!.listener?.onMapIdle()
25+
} else {
26+
DispatchQueue.main.async() {
27+
self.parent!.listener?.onMapIdle()
28+
}
29+
}
30+
}
31+
override func onMapStable() {
32+
if (!AKMapView.RUN_ON_MAIN_THREAD) {
33+
parent!.listener?.onMapStable(parent!.userAction)
34+
} else {
35+
DispatchQueue.main.async() {
36+
self.parent!.listener?.onMapStable(self.parent!.userAction)
37+
}
38+
}
39+
parent!.userAction = false;
40+
}
41+
override func onMapMoved() {
42+
if (!AKMapView.RUN_ON_MAIN_THREAD) {
43+
parent!.listener?.onMapMoved(parent!.userAction)
44+
} else {
45+
DispatchQueue.main.async() {
46+
self.parent!.listener?.onMapMoved(self.parent!.userAction)
47+
}
48+
}
49+
}
50+
override func onMapClicked(_ mapClickInfo: NTMapClickInfo!) {
51+
if (!AKMapView.RUN_ON_MAIN_THREAD) {
52+
parent!.listener?.onMapClicked(mapClickInfo)
53+
} else {
54+
DispatchQueue.main.async() {
55+
self.parent!.listener?.onMapClicked(mapClickInfo)
56+
}
57+
}
58+
}
59+
override func onMapInteraction(_ mapInteractionInfo: NTMapInteractionInfo!) {
60+
if (!AKMapView.RUN_ON_MAIN_THREAD) {
61+
parent!.listener?.onMapInteraction(mapInteractionInfo, self.parent!.userAction)
62+
} else {
63+
DispatchQueue.main.async() {
64+
self.parent!.listener?.onMapInteraction(mapInteractionInfo, self.parent!.userAction)
65+
}
66+
}
67+
}
68+
}
69+
70+
var _mapEventListener: MapEventListener?
71+
72+
override init!(frame: CGRect) {
73+
super.init(frame: frame)
74+
self._mapEventListener = MapEventListener(self)
75+
}
76+
override init!() {
77+
super.init()
78+
self._mapEventListener = MapEventListener(self)
79+
}
80+
required init!(coder aDecoder: NSCoder!) {
81+
super.init(coder: aDecoder)
82+
self._mapEventListener = MapEventListener(self)
83+
}
84+
85+
static func setRunOnMainThread(value: Bool) {
86+
RUN_ON_MAIN_THREAD = value;
87+
}
88+
89+
func setAKMapEventListener(_ listener: AKMapEventListener!) {
90+
self.listener = listener
91+
if (listener != nil) {
92+
super.setMapEventListener(_mapEventListener)
93+
} else {
94+
super.setMapEventListener(nil)
95+
}
96+
}
97+
98+
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
99+
super.touchesBegan(touches, with: event)
100+
self.userAction = false
101+
}
102+
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
103+
super.touchesMoved(touches, with: event)
104+
self.userAction = true
105+
}
106+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#import <CartoMobileSDK/CartoMobileSDK.h>
2+
3+
@interface AKRasterTileEventListener : NTRasterTileEventListener
4+
5+
@property (nonatomic, assign) BOOL runOnMainThread;
6+
7+
- (BOOL)onRasterTileClickedThreaded:(NTRasterTileClickInfo *)clickInfo;
8+
9+
@end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#import "AKRasterTileEventListener.h"
2+
3+
@implementation AKRasterTileEventListener
4+
@synthesize runOnMainThread;
5+
- (BOOL)onRasterTileClickedThreaded:(NTRasterTileClickInfo *)clickInfo{
6+
return FALSE;
7+
}
8+
9+
-(id)init {
10+
if (self = [super init]) {
11+
self.runOnMainThread = true;
12+
}
13+
return self;
14+
}
15+
16+
- (BOOL)onRasterTileClicked:(NTRasterTileClickInfo *)clickInfo {
17+
if (self.runOnMainThread) {
18+
__block BOOL result = NO;
19+
dispatch_sync(dispatch_get_main_queue(), ^{
20+
result = [self onRasterTileClickedThreaded:clickInfo];
21+
});
22+
return result;
23+
} else {
24+
return [self onRasterTileClickedThreaded:clickInfo];
25+
}
26+
}
27+
28+
@end
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// AKFeatureCollectionSearchService.swift
3+
// demosvelte
4+
//
5+
// Created by Martin Guillon on 14/02/2024.
6+
// Copyright © 2024 NativeScript. All rights reserved.
7+
//
8+
import CartoMobileSDK
9+
10+
@objc(AKRasterTileEventListener)
11+
@objcMembers
12+
class AKRasterTileEventListener: NTRasterTileEventListener {
13+
14+
var runOnMainThread = AKMapView.RUN_ON_MAIN_THREAD
15+
func onRasterTileClickedThreaded(_ clickInfo: NTRasterTileClickInfo!) -> Bool {
16+
return false;
17+
}
18+
override func onRasterTileClicked(_ clickInfo: NTRasterTileClickInfo!) -> Bool {
19+
if (runOnMainThread) {
20+
var result = false;
21+
DispatchQueue.main.sync() {
22+
result = onRasterTileClickedThreaded(clickInfo)
23+
}
24+
return result
25+
} else {
26+
return onRasterTileClickedThreaded(clickInfo)
27+
}
28+
}
29+
}
30+
31+

0 commit comments

Comments
 (0)