react-native-map4d-services 0.1.0 → 1.0.0

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 (38) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +24 -24
  3. package/android/build.gradle +60 -59
  4. package/android/src/main/AndroidManifest.xml +4 -4
  5. package/android/src/main/java/com/reactnativemap4dservices/Map4dServicesModule.java +91 -34
  6. package/android/src/main/java/com/reactnativemap4dservices/Map4dServicesPackage.java +28 -28
  7. package/android/src/main/java/com/reactnativemap4dservices/SClient.java +45 -0
  8. package/android/src/main/java/com/reactnativemap4dservices/SConverter.java +166 -0
  9. package/android/src/main/java/com/reactnativemap4dservices/SJsonUtils.java +130 -0
  10. package/android/src/main/java/com/reactnativemap4dservices/SRequest.java +376 -0
  11. package/ios/Map4dServices.h +5 -5
  12. package/ios/Map4dServices.m +81 -81
  13. package/ios/RCTConvert+Services.h +33 -33
  14. package/ios/RCTConvert+Services.m +146 -146
  15. package/ios/SClient.h +23 -23
  16. package/ios/SClient.m +47 -47
  17. package/ios/SRequest.h +40 -40
  18. package/ios/SRequest.m +143 -143
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/module/index.js.map +1 -1
  21. package/lib/typescript/index.d.ts +111 -111
  22. package/package.json +150 -150
  23. package/react-native-map4d-services.podspec +20 -20
  24. package/src/index.tsx +174 -174
  25. package/android/.gradle/7.1.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  26. package/android/.gradle/7.1.1/dependencies-accessors/gc.properties +0 -0
  27. package/android/.gradle/7.1.1/executionHistory/executionHistory.lock +0 -0
  28. package/android/.gradle/7.1.1/fileChanges/last-build.bin +0 -0
  29. package/android/.gradle/7.1.1/fileHashes/fileHashes.lock +0 -0
  30. package/android/.gradle/7.1.1/gc.properties +0 -0
  31. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  32. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  33. package/android/.gradle/checksums/checksums.lock +0 -0
  34. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  35. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  36. package/android/.gradle/vcs-1/gc.properties +0 -0
  37. package/ios/.DS_Store +0 -0
  38. package/ios/Map4dServices.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
@@ -1,33 +1,33 @@
1
- //
2
- // RCTConvert+Services.h
3
- // react-native-map4d-services
4
- //
5
- // Created by Huy Dang on 26/01/2022.
6
- //
7
-
8
- #ifndef RCTConvert_Services_h
9
- #define RCTConvert_Services_h
10
-
11
- #import <React/RCTConvert.h>
12
- #import <Map4dServices/Map4dServices.h>
13
-
14
- @interface RCTConvert (Services)
15
-
16
- + (MFLocationComponent *)MFLocationComponent:(id)json;
17
-
18
- + (NSArray<MFLocationComponent *> *)MFLocationComponentArray:(id)json;
19
-
20
- + (MFViewboxComponent *)MFViewboxComponent:(id)json;
21
-
22
- + (MFRouteRestriction *)MFRouteRestriction:(id)json;
23
-
24
- + (MFTravelMode)MFTravelMode:(id)json;
25
-
26
- + (MFRouteWeighting)MFRouteWeighting:(id)json;
27
-
28
- + (MFLanguageResult)MFLanguageResult:(id)json;
29
-
30
- @end
31
-
32
-
33
- #endif /* RCTConvert_Services_h */
1
+ //
2
+ // RCTConvert+Services.h
3
+ // react-native-map4d-services
4
+ //
5
+ // Created by Huy Dang on 26/01/2022.
6
+ //
7
+
8
+ #ifndef RCTConvert_Services_h
9
+ #define RCTConvert_Services_h
10
+
11
+ #import <React/RCTConvert.h>
12
+ #import <Map4dServices/Map4dServices.h>
13
+
14
+ @interface RCTConvert (Services)
15
+
16
+ + (MFLocationComponent *)MFLocationComponent:(id)json;
17
+
18
+ + (NSArray<MFLocationComponent *> *)MFLocationComponentArray:(id)json;
19
+
20
+ + (MFViewboxComponent *)MFViewboxComponent:(id)json;
21
+
22
+ + (MFRouteRestriction *)MFRouteRestriction:(id)json;
23
+
24
+ + (MFTravelMode)MFTravelMode:(id)json;
25
+
26
+ + (MFRouteWeighting)MFRouteWeighting:(id)json;
27
+
28
+ + (MFLanguageResult)MFLanguageResult:(id)json;
29
+
30
+ @end
31
+
32
+
33
+ #endif /* RCTConvert_Services_h */
@@ -1,146 +1,146 @@
1
- //
2
- // RCTConvert+Services.m
3
- // react-native-map4d-services
4
- //
5
- // Created by Huy Dang on 26/01/2022.
6
- //
7
-
8
- #import <React/RCTConvert+CoreLocation.h>
9
- #import "RCTConvert+Services.h"
10
-
11
- @implementation RCTConvert (Services)
12
-
13
- + (MFLocationComponent *)MFLocationComponent:(id)json {
14
- if (json == nil) {
15
- return nil;
16
- }
17
- CLLocationCoordinate2D coordinate = [RCTConvert CLLocationCoordinate2D:json];
18
- return [[MFLocationComponent alloc] initWithCoordinate:coordinate alias:json[@"alias"]];
19
- }
20
-
21
- RCT_ARRAY_CONVERTER(MFLocationComponent);
22
-
23
- + (MFViewboxComponent *)MFViewboxComponent:(id)json {
24
- if (json == nil) {
25
- return nil;
26
- }
27
-
28
- MFLocationComponent *southwest = [RCTConvert MFLocationComponent:json[@"southwest"]];
29
- MFLocationComponent *northeast = [RCTConvert MFLocationComponent:json[@"northeast"]];
30
- return [[MFViewboxComponent alloc] initWithSouthwest:southwest.coordinate northeast:northeast.coordinate];
31
- }
32
-
33
- + (MFRouteRestriction *)MFRouteRestriction:(id)json {
34
- if (json == nil) {
35
- return nil;
36
- }
37
-
38
- MFLocationComponent *location = [RCTConvert MFLocationComponent:json[@"location"]];
39
- NSUInteger radius = json[@"radius"] != nil ? [RCTConvert NSUInteger:json[@"radius"]] : 0;
40
- MFViewboxComponent *viewbox = [RCTConvert MFViewboxComponent:json[@"viewbox"]];
41
- NSArray<MFLocationComponent *> *path = [RCTConvert MFLocationComponentArray:json[@"path"]];
42
- NSArray<NSString *> *types = [RCTConvert NSStringArray:json[@"types"]];
43
-
44
- MFRouteRestriction *result = nil;
45
- if (location != nil) {
46
- result = [[MFRouteRestriction alloc] initWithLocation:location radius:radius];
47
- }
48
- else if (viewbox != nil) {
49
- result = [[MFRouteRestriction alloc] initWithViewbox:viewbox];
50
- }
51
- else if (path != nil) {
52
- result = [[MFRouteRestriction alloc] initWithPath:path];
53
- }
54
-
55
- if (types != nil && types.count > 0) {
56
- if (result != nil) {
57
- for (NSUInteger i = 0; i < types.count; i++) {
58
- if ([RCTConvert isMFRouteType:types[i]]) {
59
- [result avoidRouteType:[RCTConvert MFRouteType:types[i]]];
60
- }
61
- }
62
- }
63
- else {
64
- result = [[MFRouteRestriction alloc] initWithRouteType:[RCTConvert MFRouteType:types[0]]];
65
- for (NSUInteger i = 1; i < types.count; i++) {
66
- if ([RCTConvert isMFRouteType:types[i]]) {
67
- [result avoidRouteType:[RCTConvert MFRouteType:types[i]]];
68
- }
69
- }
70
- }
71
- }
72
-
73
- return result;
74
-
75
- }
76
-
77
- + (MFTravelMode)MFTravelMode:(id)json {
78
- NSString *mode = [RCTConvert NSString:json];
79
- if ([@"motorcycle" isEqualToString:mode]) {
80
- return MFTravelModeMotorcycle;
81
- }
82
- else if ([@"foot" isEqualToString:mode]) {
83
- return MFTravelModeFoot;
84
- }
85
- else if ([@"bike" isEqualToString:mode]) {
86
- return MFTravelModeBike;
87
- }
88
- else {
89
- return MFTravelModeCar;
90
- }
91
- }
92
-
93
- + (MFRouteWeighting)MFRouteWeighting:(id)json {
94
- NSString *weighting = [RCTConvert NSString:json];
95
- if ([@"shortest" isEqualToString:weighting]) {
96
- return MFRouteWeightingShortest;
97
- }
98
- else if ([@"balance" isEqualToString:weighting]) {
99
- return MFRouteWeightingBalance;
100
- }
101
- else {
102
- return MFRouteWeightingFastest;
103
- }
104
- }
105
-
106
- + (MFLanguageResult)MFLanguageResult:(id)json {
107
- NSString *language = [RCTConvert NSString:json];
108
- if ([@"en" isEqualToString:language]) {
109
- return MFLanguageResultEnglish;
110
- }
111
- else {
112
- return MFLanguageResultVietnamese;
113
- }
114
- }
115
-
116
- + (BOOL)isMFRouteType:(NSString *)type {
117
- if ([@"motorway" isEqualToString:type] ||
118
- [@"trunk" isEqualToString:type] ||
119
- [@"ferry" isEqualToString:type] ||
120
- [@"bridge" isEqualToString:type] ||
121
- [@"tunnel" isEqualToString:type]) {
122
- return YES;
123
- }
124
- return NO;
125
- }
126
-
127
- + (MFRouteType)MFRouteType:(NSString *)type {
128
- if ([@"motorway" isEqualToString:type]) {
129
- return MFRouteTypeMotorway;
130
- }
131
- else if ([@"trunk" isEqualToString:type]) {
132
- return MFRouteTypeTrunk;
133
- }
134
- else if ([@"ferry" isEqualToString:type]) {
135
- return MFRouteTypeFerry;
136
- }
137
- else if ([@"bridge" isEqualToString:type]) {
138
- return MFRouteTypeBridge;
139
- }
140
- else if ([@"tunnel" isEqualToString:type]) {
141
- return MFRouteTypeTunnel;
142
- }
143
- return 0;
144
- }
145
-
146
- @end
1
+ //
2
+ // RCTConvert+Services.m
3
+ // react-native-map4d-services
4
+ //
5
+ // Created by Huy Dang on 26/01/2022.
6
+ //
7
+
8
+ #import <React/RCTConvert+CoreLocation.h>
9
+ #import "RCTConvert+Services.h"
10
+
11
+ @implementation RCTConvert (Services)
12
+
13
+ + (MFLocationComponent *)MFLocationComponent:(id)json {
14
+ if (json == nil) {
15
+ return nil;
16
+ }
17
+ CLLocationCoordinate2D coordinate = [RCTConvert CLLocationCoordinate2D:json];
18
+ return [[MFLocationComponent alloc] initWithCoordinate:coordinate alias:json[@"alias"]];
19
+ }
20
+
21
+ RCT_ARRAY_CONVERTER(MFLocationComponent);
22
+
23
+ + (MFViewboxComponent *)MFViewboxComponent:(id)json {
24
+ if (json == nil) {
25
+ return nil;
26
+ }
27
+
28
+ MFLocationComponent *southwest = [RCTConvert MFLocationComponent:json[@"southwest"]];
29
+ MFLocationComponent *northeast = [RCTConvert MFLocationComponent:json[@"northeast"]];
30
+ return [[MFViewboxComponent alloc] initWithSouthwest:southwest.coordinate northeast:northeast.coordinate];
31
+ }
32
+
33
+ + (MFRouteRestriction *)MFRouteRestriction:(id)json {
34
+ if (json == nil) {
35
+ return nil;
36
+ }
37
+
38
+ MFLocationComponent *location = [RCTConvert MFLocationComponent:json[@"location"]];
39
+ NSUInteger radius = json[@"radius"] != nil ? [RCTConvert NSUInteger:json[@"radius"]] : 0;
40
+ MFViewboxComponent *viewbox = [RCTConvert MFViewboxComponent:json[@"viewbox"]];
41
+ NSArray<MFLocationComponent *> *path = [RCTConvert MFLocationComponentArray:json[@"path"]];
42
+ NSArray<NSString *> *types = [RCTConvert NSStringArray:json[@"types"]];
43
+
44
+ MFRouteRestriction *result = nil;
45
+ if (location != nil) {
46
+ result = [[MFRouteRestriction alloc] initWithLocation:location radius:radius];
47
+ }
48
+ else if (viewbox != nil) {
49
+ result = [[MFRouteRestriction alloc] initWithViewbox:viewbox];
50
+ }
51
+ else if (path != nil) {
52
+ result = [[MFRouteRestriction alloc] initWithPath:path];
53
+ }
54
+
55
+ if (types != nil && types.count > 0) {
56
+ if (result != nil) {
57
+ for (NSUInteger i = 0; i < types.count; i++) {
58
+ if ([RCTConvert isMFRouteType:types[i]]) {
59
+ [result avoidRouteType:[RCTConvert MFRouteType:types[i]]];
60
+ }
61
+ }
62
+ }
63
+ else {
64
+ result = [[MFRouteRestriction alloc] initWithRouteType:[RCTConvert MFRouteType:types[0]]];
65
+ for (NSUInteger i = 1; i < types.count; i++) {
66
+ if ([RCTConvert isMFRouteType:types[i]]) {
67
+ [result avoidRouteType:[RCTConvert MFRouteType:types[i]]];
68
+ }
69
+ }
70
+ }
71
+ }
72
+
73
+ return result;
74
+
75
+ }
76
+
77
+ + (MFTravelMode)MFTravelMode:(id)json {
78
+ NSString *mode = [RCTConvert NSString:json];
79
+ if ([@"motorcycle" isEqualToString:mode]) {
80
+ return MFTravelModeMotorcycle;
81
+ }
82
+ else if ([@"foot" isEqualToString:mode]) {
83
+ return MFTravelModeFoot;
84
+ }
85
+ else if ([@"bike" isEqualToString:mode]) {
86
+ return MFTravelModeBike;
87
+ }
88
+ else {
89
+ return MFTravelModeCar;
90
+ }
91
+ }
92
+
93
+ + (MFRouteWeighting)MFRouteWeighting:(id)json {
94
+ NSString *weighting = [RCTConvert NSString:json];
95
+ if ([@"shortest" isEqualToString:weighting]) {
96
+ return MFRouteWeightingShortest;
97
+ }
98
+ else if ([@"balance" isEqualToString:weighting]) {
99
+ return MFRouteWeightingBalance;
100
+ }
101
+ else {
102
+ return MFRouteWeightingFastest;
103
+ }
104
+ }
105
+
106
+ + (MFLanguageResult)MFLanguageResult:(id)json {
107
+ NSString *language = [RCTConvert NSString:json];
108
+ if ([@"en" isEqualToString:language]) {
109
+ return MFLanguageResultEnglish;
110
+ }
111
+ else {
112
+ return MFLanguageResultVietnamese;
113
+ }
114
+ }
115
+
116
+ + (BOOL)isMFRouteType:(NSString *)type {
117
+ if ([@"motorway" isEqualToString:type] ||
118
+ [@"trunk" isEqualToString:type] ||
119
+ [@"ferry" isEqualToString:type] ||
120
+ [@"bridge" isEqualToString:type] ||
121
+ [@"tunnel" isEqualToString:type]) {
122
+ return YES;
123
+ }
124
+ return NO;
125
+ }
126
+
127
+ + (MFRouteType)MFRouteType:(NSString *)type {
128
+ if ([@"motorway" isEqualToString:type]) {
129
+ return MFRouteTypeMotorway;
130
+ }
131
+ else if ([@"trunk" isEqualToString:type]) {
132
+ return MFRouteTypeTrunk;
133
+ }
134
+ else if ([@"ferry" isEqualToString:type]) {
135
+ return MFRouteTypeFerry;
136
+ }
137
+ else if ([@"bridge" isEqualToString:type]) {
138
+ return MFRouteTypeBridge;
139
+ }
140
+ else if ([@"tunnel" isEqualToString:type]) {
141
+ return MFRouteTypeTunnel;
142
+ }
143
+ return 0;
144
+ }
145
+
146
+ @end
package/ios/SClient.h CHANGED
@@ -1,23 +1,23 @@
1
- //
2
- // SClient.h
3
- // react-native-map4d-services
4
- //
5
- // Created by Huy Dang on 26/01/2022.
6
- //
7
-
8
- #ifndef SClient_h
9
- #define SClient_h
10
-
11
- #import <React/RCTBridgeModule.h>
12
- #import <Map4dServices/Map4dServices.h>
13
-
14
- @interface SClient : NSObject
15
-
16
- + (void)fireRequest:(MFServiceRequest *)request
17
- resolve:(RCTPromiseResolveBlock)resolve
18
- reject:(RCTPromiseRejectBlock)reject;
19
-
20
- @end
21
-
22
-
23
- #endif /* SClient_h */
1
+ //
2
+ // SClient.h
3
+ // react-native-map4d-services
4
+ //
5
+ // Created by Huy Dang on 26/01/2022.
6
+ //
7
+
8
+ #ifndef SClient_h
9
+ #define SClient_h
10
+
11
+ #import <React/RCTBridgeModule.h>
12
+ #import <Map4dServices/Map4dServices.h>
13
+
14
+ @interface SClient : NSObject
15
+
16
+ + (void)fireRequest:(MFServiceRequest *)request
17
+ resolve:(RCTPromiseResolveBlock)resolve
18
+ reject:(RCTPromiseRejectBlock)reject;
19
+
20
+ @end
21
+
22
+
23
+ #endif /* SClient_h */
package/ios/SClient.m CHANGED
@@ -1,47 +1,47 @@
1
- //
2
- // SClient.m
3
- // react-native-map4d-services
4
- //
5
- // Created by Huy Dang on 26/01/2022.
6
- //
7
-
8
- #import "SClient.h"
9
-
10
- @implementation SClient
11
-
12
- static MFServices *_services = nil;
13
-
14
- + (MFServices *)services {
15
- if (_services == nil) {
16
- _services = [[MFServices alloc] init];
17
- }
18
- return _services;
19
- }
20
-
21
- + (void)fireRequest:(MFServiceRequest *)request
22
- resolve:(RCTPromiseResolveBlock)resolve
23
- reject:(RCTPromiseRejectBlock)reject {
24
- [SClient.services dataTaskWithRequest:request
25
- completionHandler:^(NSData * _Nullable data, id<MFServiceError> _Nullable error) {
26
- if (error != nil) {
27
- resolve(@{
28
- @"code": error.code,
29
- @"message": error.message
30
- });
31
- }
32
-
33
- NSError *parseError = nil;
34
- NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&parseError];
35
-
36
- if (parseError != nil) {
37
- resolve(@{
38
- @"code": [NSString stringWithFormat:@"%ld", parseError.code],
39
- @"message": parseError.localizedDescription
40
- });
41
- }
42
-
43
- resolve(dictionary);
44
- }];
45
- }
46
-
47
- @end
1
+ //
2
+ // SClient.m
3
+ // react-native-map4d-services
4
+ //
5
+ // Created by Huy Dang on 26/01/2022.
6
+ //
7
+
8
+ #import "SClient.h"
9
+
10
+ @implementation SClient
11
+
12
+ static MFServices *_services = nil;
13
+
14
+ + (MFServices *)services {
15
+ if (_services == nil) {
16
+ _services = [[MFServices alloc] init];
17
+ }
18
+ return _services;
19
+ }
20
+
21
+ + (void)fireRequest:(MFServiceRequest *)request
22
+ resolve:(RCTPromiseResolveBlock)resolve
23
+ reject:(RCTPromiseRejectBlock)reject {
24
+ [SClient.services dataTaskWithRequest:request
25
+ completionHandler:^(NSData * _Nullable data, id<MFServiceError> _Nullable error) {
26
+ if (error != nil) {
27
+ resolve(@{
28
+ @"code": error.code,
29
+ @"message": error.message
30
+ });
31
+ }
32
+
33
+ NSError *parseError = nil;
34
+ NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&parseError];
35
+
36
+ if (parseError != nil) {
37
+ resolve(@{
38
+ @"code": [NSString stringWithFormat:@"%ld", parseError.code],
39
+ @"message": parseError.localizedDescription
40
+ });
41
+ }
42
+
43
+ resolve(dictionary);
44
+ }];
45
+ }
46
+
47
+ @end
package/ios/SRequest.h CHANGED
@@ -1,40 +1,40 @@
1
- //
2
- // SRequest.h
3
- // react-native-map4d-services
4
- //
5
- // Created by Huy Dang on 26/01/2022.
6
- //
7
-
8
- #ifndef SRequest_h
9
- #define SRequest_h
10
-
11
- #import <Foundation/Foundation.h>
12
-
13
- @class MFServiceRequest;
14
-
15
- @interface SRequest : NSObject
16
-
17
- + (MFServiceRequest *)buildGeocodingRequestWithData:(NSDictionary *)data;
18
-
19
- + (MFServiceRequest *)buildPlaceDetailRequestWithId:(NSString *)placeId;
20
-
21
- + (MFServiceRequest *)buildTextSearchRequestWithData:(NSDictionary *)data;
22
-
23
- + (MFServiceRequest *)buildNearbySearchRequestWithData:(NSDictionary *)data;
24
-
25
- + (MFServiceRequest *)buildViewboxSearchRequestWithData:(NSDictionary *)data;
26
-
27
- + (MFServiceRequest *)buildSuggestionsRequestWithData:(NSDictionary *)data;
28
-
29
- + (MFServiceRequest *)buildDirectionsRequestWithData:(NSDictionary *)data;
30
-
31
- + (MFServiceRequest *)buildRouteETARequestWithData:(NSDictionary *)data;
32
-
33
- + (MFServiceRequest *)buildDistanceMatrixRequestWithData:(NSDictionary *)data;
34
-
35
- + (MFServiceRequest *)buildGraphRouteRequestWithData:(NSDictionary *)data;
36
-
37
- @end
38
-
39
-
40
- #endif /* SRequest_h */
1
+ //
2
+ // SRequest.h
3
+ // react-native-map4d-services
4
+ //
5
+ // Created by Huy Dang on 26/01/2022.
6
+ //
7
+
8
+ #ifndef SRequest_h
9
+ #define SRequest_h
10
+
11
+ #import <Foundation/Foundation.h>
12
+
13
+ @class MFServiceRequest;
14
+
15
+ @interface SRequest : NSObject
16
+
17
+ + (MFServiceRequest *)buildGeocodingRequestWithData:(NSDictionary *)data;
18
+
19
+ + (MFServiceRequest *)buildPlaceDetailRequestWithId:(NSString *)placeId;
20
+
21
+ + (MFServiceRequest *)buildTextSearchRequestWithData:(NSDictionary *)data;
22
+
23
+ + (MFServiceRequest *)buildNearbySearchRequestWithData:(NSDictionary *)data;
24
+
25
+ + (MFServiceRequest *)buildViewboxSearchRequestWithData:(NSDictionary *)data;
26
+
27
+ + (MFServiceRequest *)buildSuggestionsRequestWithData:(NSDictionary *)data;
28
+
29
+ + (MFServiceRequest *)buildDirectionsRequestWithData:(NSDictionary *)data;
30
+
31
+ + (MFServiceRequest *)buildRouteETARequestWithData:(NSDictionary *)data;
32
+
33
+ + (MFServiceRequest *)buildDistanceMatrixRequestWithData:(NSDictionary *)data;
34
+
35
+ + (MFServiceRequest *)buildGraphRouteRequestWithData:(NSDictionary *)data;
36
+
37
+ @end
38
+
39
+
40
+ #endif /* SRequest_h */