@situm/cordova 3.3.14 → 3.4.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.
- package/CHANGELOG_UNRELEASED.md +0 -5
- package/docs/JSDoc/{android_Interfaces.js.html → Interfaces.js.html} +14 -20
- package/docs/JSDoc/MapView.html +2 -2
- package/docs/JSDoc/MapViewController.html +2 -2
- package/docs/JSDoc/Situm.html +770 -55
- package/docs/JSDoc/global.html +547 -221
- package/docs/JSDoc/index.html +2 -2
- package/docs/JSDoc/map-view-controller.js.html +2 -2
- package/docs/JSDoc/map-view.js.html +3 -3
- package/docs/JSDoc/{android_situm.js.html → situm.js.html} +133 -14
- package/docs/conf.json +1 -1
- package/example/ios/App/App/Info.plist +2 -0
- package/package.json +2 -2
- package/plugin.xml +12 -7
- package/src/android/app/src/main/java/es/situm/plugin/SitumMapper.java +112 -131
- package/src/android/app/src/test/java/es/situm/plugin/SitumMapperTest.java +0 -40
- package/src/android/situm.gradle +0 -1
- package/src/ios/situmcordovaplugin/SitumLocationWrapper.m +18 -41
- package/src/ios/situmcordovaplugin/SitumPlugin.m +4 -3
- package/www/{android/Interfaces.js → Interfaces.js} +11 -17
- package/www/common-utils.js +36 -0
- package/www/{android/situm.js → situm.js} +130 -11
- package/www/ios/situm.js +0 -99
|
@@ -755,159 +755,140 @@ static JSONObject buildingInfoToJsonObject(BuildingInfo buildingInfo) throws JSO
|
|
|
755
755
|
return locationBuilder.build();
|
|
756
756
|
}
|
|
757
757
|
|
|
758
|
-
JSONObject
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
sBuildingId = String.format(Locale.getDefault(), "%d", jsonoBuilding.getInt(SitumMapper.BUILDING_IDENTIFIER));
|
|
758
|
+
JSONObject request = args.getJSONObject(0);
|
|
759
|
+
if (request.has(SitumMapper.BUILDING_IDENTIFIER)) {
|
|
760
|
+
String buildingIdentifier = String.valueOf(request.get(SitumMapper.BUILDING_IDENTIFIER));
|
|
761
|
+
locationBuilder.buildingIdentifier(buildingIdentifier);
|
|
762
|
+
Log.i(TAG, "buildingIdentifier: " + buildingIdentifier);
|
|
764
763
|
}
|
|
765
764
|
|
|
766
|
-
if (
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
buildingIdentifier = String.format(Locale.getDefault(), "%d", jsonoBuilding.getInt(SitumMapper.BUILDING_IDENTIFIER));
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
locationBuilder.buildingIdentifier(buildingIdentifier);
|
|
777
|
-
Log.i(TAG, "buildingIdentifier: " + buildingIdentifier);
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
if (request.has(SitumMapper.INTERVAL)) {
|
|
781
|
-
Integer interval = request.getInt(SitumMapper.INTERVAL);
|
|
782
|
-
if (interval != null) {
|
|
783
|
-
locationBuilder.interval(interval);
|
|
784
|
-
Log.i(TAG, "interval: " + interval);
|
|
785
|
-
}
|
|
786
|
-
}
|
|
765
|
+
if (request.has(SitumMapper.INTERVAL)) {
|
|
766
|
+
Integer interval = request.getInt(SitumMapper.INTERVAL);
|
|
767
|
+
if (interval != null) {
|
|
768
|
+
locationBuilder.interval(interval);
|
|
769
|
+
Log.i(TAG, "interval: " + interval);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
787
772
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
}
|
|
796
|
-
Log.i(TAG, "indoorProvider: " + indoorProvider);
|
|
797
|
-
}
|
|
773
|
+
if (request.has(SitumMapper.INDOOR_PROVIDER)) {
|
|
774
|
+
String indoorProvider = request.getString(SitumMapper.INDOOR_PROVIDER);
|
|
775
|
+
if (indoorProvider != null && !indoorProvider.isEmpty()) {
|
|
776
|
+
if (indoorProvider.equals(LocationRequest.IndoorProvider.SUPPORT.name())) {
|
|
777
|
+
locationBuilder.indoorProvider(LocationRequest.IndoorProvider.SUPPORT);
|
|
778
|
+
} else {
|
|
779
|
+
locationBuilder.indoorProvider(LocationRequest.IndoorProvider.INPHONE);
|
|
798
780
|
}
|
|
781
|
+
Log.i(TAG, "indoorProvider: " + indoorProvider);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
799
784
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
785
|
+
if (request.has(SitumMapper.USE_BLE)) {
|
|
786
|
+
Boolean useBle = request.getBoolean(SitumMapper.USE_BLE);
|
|
787
|
+
locationBuilder.useBle(useBle);
|
|
788
|
+
Log.i(TAG, "useBle: " + useBle);
|
|
789
|
+
}
|
|
805
790
|
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
791
|
+
if (request.has(SitumMapper.USE_WIFI)) {
|
|
792
|
+
Boolean useWifi = request.getBoolean(SitumMapper.USE_WIFI);
|
|
793
|
+
locationBuilder.useWifi(useWifi);
|
|
794
|
+
Log.i(TAG, "useWifi: " + useWifi);
|
|
795
|
+
}
|
|
811
796
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
797
|
+
if (request.has(SitumMapper.USE_GPS)) {
|
|
798
|
+
Boolean useGps = request.getBoolean(SitumMapper.USE_GPS);
|
|
799
|
+
locationBuilder.useGps(useGps);
|
|
800
|
+
Log.i(TAG, "useGps: " + useGps);
|
|
801
|
+
}
|
|
817
802
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
803
|
+
if (request.has(SitumMapper.USE_BAROMETER)) {
|
|
804
|
+
Boolean useBarometer = request.getBoolean(SitumMapper.USE_BAROMETER);
|
|
805
|
+
locationBuilder.useBarometer(useBarometer);
|
|
806
|
+
Log.i(TAG, "useBarometer: " + useBarometer);
|
|
807
|
+
}
|
|
823
808
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
809
|
+
if (request.has(SitumMapper.AUTO_ENABLE_BLE)) {
|
|
810
|
+
Boolean autoEnableBleDuringPositioning = request.getBoolean(SitumMapper.AUTO_ENABLE_BLE);
|
|
811
|
+
locationBuilder.autoEnableBleDuringPositioning(autoEnableBleDuringPositioning);
|
|
812
|
+
Log.i(TAG, "autoEnableBleDuringPositioning: " + autoEnableBleDuringPositioning);
|
|
813
|
+
}
|
|
829
814
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
}
|
|
838
|
-
Log.i(TAG, "motionMode: " + motionMode);
|
|
839
|
-
}
|
|
815
|
+
if (request.has(SitumMapper.MOTION_MODE)) {
|
|
816
|
+
String motionMode = request.getString(SitumMapper.MOTION_MODE);
|
|
817
|
+
if (motionMode != null) {
|
|
818
|
+
if (motionMode.equals(LocationRequest.MotionMode.BY_FOOT.name())) {
|
|
819
|
+
locationBuilder.motionMode(LocationRequest.MotionMode.BY_FOOT);
|
|
820
|
+
} else if (motionMode.equals(LocationRequest.MotionMode.BY_CAR.name())) {
|
|
821
|
+
locationBuilder.motionMode(LocationRequest.MotionMode.BY_CAR);
|
|
840
822
|
}
|
|
823
|
+
Log.i(TAG, "motionMode: " + motionMode);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
841
826
|
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
827
|
+
if (request.has(SitumMapper.USE_FOREGROUND_SERVICE)) {
|
|
828
|
+
Boolean useForegroundService = request.getBoolean(SitumMapper.USE_FOREGROUND_SERVICE);
|
|
829
|
+
locationBuilder.useForegroundService(useForegroundService);
|
|
830
|
+
Log.i(TAG, "useForegroundService: " + useForegroundService);
|
|
831
|
+
}
|
|
847
832
|
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
833
|
+
if (request.has(SitumMapper.USE_DEAD_RECKONING)) {
|
|
834
|
+
Boolean useDeadReckoning = request.getBoolean(SitumMapper.USE_DEAD_RECKONING);
|
|
835
|
+
locationBuilder.useDeadReckoning(useDeadReckoning);
|
|
836
|
+
Log.i(TAG, "useDeadReckoning: " + useDeadReckoning);
|
|
837
|
+
}
|
|
853
838
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
839
|
+
if (request.has(SitumMapper.OUTDOOR_LOCATION_OPTIONS)) {
|
|
840
|
+
JSONObject outdoorLocationOptions = request.getJSONObject(SitumMapper.OUTDOOR_LOCATION_OPTIONS);
|
|
841
|
+
if (outdoorLocationOptions != null) {
|
|
842
|
+
locationBuilder.outdoorLocationOptions(buildOutdoorLocationOptions(outdoorLocationOptions));
|
|
843
|
+
}
|
|
844
|
+
}
|
|
860
845
|
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
locationBuilder.addBeaconFilters(filtersList);
|
|
846
|
+
if (request.has(SitumMapper.BEACON_FILTERS)) {
|
|
847
|
+
JSONArray beaconFilters = request.getJSONArray(SitumMapper.BEACON_FILTERS);
|
|
848
|
+
List<BeaconFilter> filtersList = new ArrayList<BeaconFilter>();
|
|
849
|
+
for (int i = 0; i < beaconFilters.length(); i++) {
|
|
850
|
+
JSONObject beaconFilter = beaconFilters.getJSONObject(i);
|
|
851
|
+
if (beaconFilter.has(SitumMapper.UUID)) {
|
|
852
|
+
String uuid = beaconFilter.getString(SitumMapper.UUID);
|
|
853
|
+
if (uuid != null && !uuid.isEmpty()) {
|
|
854
|
+
BeaconFilter.Builder builder = new BeaconFilter.Builder().uuid(uuid);
|
|
855
|
+
filtersList.add(builder.build());
|
|
856
|
+
Log.i(TAG, "beaconFilter: " + uuid);
|
|
857
|
+
}
|
|
877
858
|
}
|
|
859
|
+
}
|
|
860
|
+
locationBuilder.addBeaconFilters(filtersList);
|
|
861
|
+
}
|
|
878
862
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
863
|
+
if (request.has(SitumMapper.SMALLEST_DISPLACEMENT)) {
|
|
864
|
+
Float smallestDisplacement = new Float(request.getDouble(SitumMapper.SMALLEST_DISPLACEMENT));
|
|
865
|
+
if (smallestDisplacement != null && smallestDisplacement > 0) {
|
|
866
|
+
locationBuilder.smallestDisplacement(smallestDisplacement);
|
|
867
|
+
Log.i(TAG, "smallestDisplacement: " + smallestDisplacement);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
886
870
|
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
}
|
|
902
|
-
Log.i(TAG, "realtimeUpdateInterval: " + realtimeUpdateInterval);
|
|
903
|
-
}
|
|
871
|
+
if (request.has(SitumMapper.REALTIME_UPDATE_INTERVAL) &&
|
|
872
|
+
request.get(SitumMapper.REALTIME_UPDATE_INTERVAL) instanceof String) {
|
|
873
|
+
String realtimeUpdateInterval = request.getString(SitumMapper.REALTIME_UPDATE_INTERVAL);
|
|
874
|
+
if (realtimeUpdateInterval != null) {
|
|
875
|
+
if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.REALTIME.name())) {
|
|
876
|
+
locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.REALTIME);
|
|
877
|
+
} else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.FAST.name())) {
|
|
878
|
+
locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.FAST);
|
|
879
|
+
} else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.NORMAL.name())) {
|
|
880
|
+
locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.NORMAL);
|
|
881
|
+
} else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.SLOW.name())) {
|
|
882
|
+
locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.SLOW);
|
|
883
|
+
} else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.BATTERY_SAVER.name())) {
|
|
884
|
+
locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.BATTERY_SAVER);
|
|
904
885
|
}
|
|
905
|
-
|
|
906
|
-
|
|
886
|
+
Log.i(TAG, "realtimeUpdateInterval: " + realtimeUpdateInterval);
|
|
887
|
+
}
|
|
907
888
|
}
|
|
908
889
|
|
|
909
890
|
return locationBuilder.build();
|
|
910
|
-
}
|
|
891
|
+
}
|
|
911
892
|
|
|
912
893
|
static OutdoorLocationOptions buildOutdoorLocationOptions(JSONObject outdoorLocationOptions) throws JSONException{
|
|
913
894
|
OutdoorLocationOptions.Builder optionsBuilder = new OutdoorLocationOptions.Builder();
|
|
@@ -471,18 +471,6 @@ public class SitumMapperTest {
|
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
|
|
474
|
-
@Test
|
|
475
|
-
public void indicationJSONObjectTest() {
|
|
476
|
-
try {
|
|
477
|
-
Indication indication = indicationCreator.createIndication();
|
|
478
|
-
JSONObject indicationJSONObject = SitumMapper.indicationToJsonObject(indication);
|
|
479
|
-
JSONObject indication1 = indicationCreator.getIndication1();
|
|
480
|
-
testIndication(indicationJSONObject, indication1);
|
|
481
|
-
} catch (JSONException e) {
|
|
482
|
-
System.err.println(e.getMessage());
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
474
|
@Test
|
|
487
475
|
public void locationTest1() {
|
|
488
476
|
try {
|
|
@@ -837,34 +825,6 @@ public class SitumMapperTest {
|
|
|
837
825
|
}
|
|
838
826
|
}
|
|
839
827
|
|
|
840
|
-
@Test
|
|
841
|
-
public void routeStepJSONObjectTest(){
|
|
842
|
-
try{
|
|
843
|
-
RouteStep routeStepWithCoordinate = routeStepCreator.createRouteStepWithCoordinate();
|
|
844
|
-
JSONObject routeStepWithCoordinateJSONObject = SitumMapper.routeStepToJsonObject(routeStepWithCoordinate);
|
|
845
|
-
JSONObject routeStep1 = routeStepCreator.getRouteStep1();
|
|
846
|
-
testRouteStep(routeStepWithCoordinateJSONObject, routeStep1);
|
|
847
|
-
RouteStep routeStepWithCoordinateAndBuildingId = routeStepCreator.createRouteStepWithCoordinateAndBuildingId();
|
|
848
|
-
JSONObject routeStepWithCoordinateAndBuildingIdJSONObject = SitumMapper.routeStepToJsonObject(routeStepWithCoordinateAndBuildingId);
|
|
849
|
-
JSONObject routeStep2 = routeStepCreator.getRouteStep2();
|
|
850
|
-
testRouteStep(routeStepWithCoordinateAndBuildingIdJSONObject, routeStep2);
|
|
851
|
-
RouteStep routeStepWithCoordinateBuildingIdAndFloor = routeStepCreator.createRouteStepWithCoordinateBuildingIdAndFloor();
|
|
852
|
-
JSONObject routeStepWithCoordinateBuildingIdAndFloorJSONObject = SitumMapper.routeStepToJsonObject(routeStepWithCoordinateBuildingIdAndFloor);
|
|
853
|
-
JSONObject routeStep3 = routeStepCreator.getRouteStep3();
|
|
854
|
-
testRouteStep(routeStepWithCoordinateBuildingIdAndFloorJSONObject, routeStep3);
|
|
855
|
-
RouteStep routeStepWithBuildingWithAngleFromDegree = routeStepCreator.createRouteStepWithBuildingWithAngleFromDegree();
|
|
856
|
-
JSONObject routeStepWithBuildingWithAngleFromDegreeJSONObject = SitumMapper.routeStepToJsonObject(routeStepWithBuildingWithAngleFromDegree);
|
|
857
|
-
JSONObject routeStep4 = routeStepCreator.getRouteStep4();
|
|
858
|
-
testRouteStep(routeStepWithBuildingWithAngleFromDegreeJSONObject, routeStep4);
|
|
859
|
-
RouteStep routeStepWithBuildingWithAngleFromRadians = routeStepCreator.createRouteStepWithBuildingWithAngleFromRadians();
|
|
860
|
-
JSONObject routeStepWithBuildingWithAngleFromRadiansJSONObject = SitumMapper.routeStepToJsonObject(routeStepWithBuildingWithAngleFromRadians);
|
|
861
|
-
JSONObject routeStep5 = routeStepCreator.getRouteStep5();
|
|
862
|
-
testRouteStep(routeStepWithBuildingWithAngleFromRadiansJSONObject, routeStep5);
|
|
863
|
-
}catch(JSONException e){
|
|
864
|
-
System.err.println(e.getMessage());
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
|
|
868
828
|
@Test
|
|
869
829
|
public void pointTest1() {
|
|
870
830
|
try{
|
package/src/android/situm.gradle
CHANGED
|
@@ -234,9 +234,7 @@ static SitumLocationWrapper *singletonSitumLocationWrapperObj;
|
|
|
234
234
|
return jo;
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
|
|
238
237
|
- (SITLocationRequest *) jsonObjectToLocationRequest: (NSArray *) json {
|
|
239
|
-
NSDictionary *buildingJO;
|
|
240
238
|
NSNumber *useDeadReckoning = nil;
|
|
241
239
|
NSNumber *useGps = nil;
|
|
242
240
|
NSString *buildingId;
|
|
@@ -245,11 +243,10 @@ static SitumLocationWrapper *singletonSitumLocationWrapperObj;
|
|
|
245
243
|
NSNumber *smallestDisplacement = nil;
|
|
246
244
|
NSNumber *useBarometer = nil;
|
|
247
245
|
SITRealtimeUpdateInterval realtimeInterval = 0;
|
|
248
|
-
|
|
246
|
+
|
|
249
247
|
// Check use of remote configuration
|
|
250
248
|
if ([json isKindOfClass:[NSDictionary class]]) {
|
|
251
249
|
NSDictionary *params = (NSDictionary *)json;
|
|
252
|
-
|
|
253
250
|
if ([params allKeys].count == 0) {
|
|
254
251
|
return nil;
|
|
255
252
|
}
|
|
@@ -258,38 +255,17 @@ static SitumLocationWrapper *singletonSitumLocationWrapperObj;
|
|
|
258
255
|
return nil;
|
|
259
256
|
}
|
|
260
257
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
buildingId = [NSString stringWithFormat:@"%@", requestJO[@"buildingIdentifier"]];
|
|
272
|
-
useDeadReckoning = [requestJO objectForKey: @"useDeadReckoning"];
|
|
273
|
-
useGps = [requestJO objectForKey: @"useGps"];
|
|
274
|
-
realtimeUpdateInterval = requestJO[@"realtimeUpdateInterval"];
|
|
275
|
-
interval = requestJO[@"interval"];
|
|
276
|
-
smallestDisplacement = requestJO[@"smallestDisplacement"];
|
|
277
|
-
useBarometer = [requestJO objectForKey: @"useBarometer"];
|
|
278
|
-
}
|
|
279
|
-
} else {
|
|
280
|
-
buildingJO = (NSDictionary*)json[0];
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (buildingId == nil) {
|
|
284
|
-
buildingId = [buildingJO valueForKey:@"identifier"];
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
if (buildingId == nil) {
|
|
288
|
-
buildingId = [NSString stringWithFormat:@"%@", [buildingJO valueForKey:@"buildingIdentifier"]];
|
|
289
|
-
}
|
|
290
|
-
|
|
258
|
+
|
|
259
|
+
NSDictionary *requestJO = (NSDictionary*)[json objectAtIndex:0];
|
|
260
|
+
buildingId = [NSString stringWithFormat:@"%@", requestJO[@"buildingIdentifier"]];
|
|
261
|
+
useDeadReckoning = [requestJO objectForKey: @"useDeadReckoning"];
|
|
262
|
+
useGps = [requestJO objectForKey: @"useGps"];
|
|
263
|
+
realtimeUpdateInterval = requestJO[@"realtimeUpdateInterval"];
|
|
264
|
+
interval = requestJO[@"interval"];
|
|
265
|
+
smallestDisplacement = requestJO[@"smallestDisplacement"];
|
|
266
|
+
useBarometer = [requestJO objectForKey: @"useBarometer"];
|
|
267
|
+
|
|
291
268
|
if (realtimeUpdateInterval != nil && [realtimeUpdateInterval isKindOfClass: [NSString class]]) {
|
|
292
|
-
|
|
293
269
|
if ([realtimeUpdateInterval isEqualToString:@"REALTIME"]) {
|
|
294
270
|
realtimeInterval = kSITUpdateIntervalRealtime;
|
|
295
271
|
} else if ([realtimeUpdateInterval isEqualToString:@"FAST"]) {
|
|
@@ -302,18 +278,19 @@ static SitumLocationWrapper *singletonSitumLocationWrapperObj;
|
|
|
302
278
|
realtimeInterval = kSITUpdateIntervalBatterySaver;
|
|
303
279
|
}
|
|
304
280
|
}
|
|
305
|
-
|
|
281
|
+
|
|
306
282
|
SITLocationRequest *locationRequest = [[SITLocationRequest alloc] initWithBuildingId:buildingId];
|
|
283
|
+
|
|
307
284
|
if (useDeadReckoning != nil) {
|
|
308
285
|
[locationRequest setUseDeadReckoning:[useDeadReckoning boolValue]];
|
|
309
|
-
|
|
310
286
|
}
|
|
287
|
+
|
|
311
288
|
if(useGps != nil) {
|
|
312
289
|
[locationRequest setUseGps:[useGps boolValue]];
|
|
313
290
|
}
|
|
314
|
-
|
|
291
|
+
|
|
315
292
|
if(interval != nil) {
|
|
316
|
-
|
|
293
|
+
[locationRequest setInterval:[interval intValue]];
|
|
317
294
|
}
|
|
318
295
|
|
|
319
296
|
if (smallestDisplacement != nil) {
|
|
@@ -321,11 +298,11 @@ static SitumLocationWrapper *singletonSitumLocationWrapperObj;
|
|
|
321
298
|
}
|
|
322
299
|
|
|
323
300
|
if(useBarometer != nil) {
|
|
324
|
-
|
|
301
|
+
[locationRequest setUseBarometer: [useBarometer boolValue]];
|
|
325
302
|
}
|
|
326
303
|
|
|
327
304
|
if (realtimeInterval != 0) {
|
|
328
|
-
[locationRequest
|
|
305
|
+
[locationRequest setRealtimeUpdateInterval:realtimeInterval];
|
|
329
306
|
}
|
|
330
307
|
return locationRequest;
|
|
331
308
|
}
|
|
@@ -462,9 +462,10 @@ static NSString *DEFAULT_SITUM_LOG = @"SitumSDK >>: ";
|
|
|
462
462
|
}
|
|
463
463
|
|
|
464
464
|
- (void)stopPositioning:(CDVInvokedUrlCommand *)command {
|
|
465
|
-
locationCallbackId = command.callbackId;
|
|
466
465
|
[[SITLocationManager sharedInstance] removeUpdates];
|
|
467
466
|
[[SITLocationManager sharedInstance] removeDelegate:self];
|
|
467
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
468
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
468
469
|
}
|
|
469
470
|
|
|
470
471
|
- (void)onEnterGeofences:(CDVInvokedUrlCommand *)command {
|
|
@@ -581,7 +582,7 @@ static NSString *DEFAULT_SITUM_LOG = @"SitumSDK >>: ";
|
|
|
581
582
|
|
|
582
583
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Navigation updated"];
|
|
583
584
|
pluginResult.keepCallback = [NSNumber numberWithBool:true];
|
|
584
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:
|
|
585
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
585
586
|
}
|
|
586
587
|
|
|
587
588
|
- (void) removeNavigationUpdates:(CDVInvokedUrlCommand *)command {
|
|
@@ -592,7 +593,7 @@ static NSString *DEFAULT_SITUM_LOG = @"SitumSDK >>: ";
|
|
|
592
593
|
NSMutableDictionary *obj = [[NSMutableDictionary alloc] init];
|
|
593
594
|
[[SITCommunicationManager sharedManager] clearCache];
|
|
594
595
|
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:obj.copy];
|
|
595
|
-
[self.commandDelegate sendPluginResult:pluginResult callbackId:
|
|
596
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
596
597
|
}
|
|
597
598
|
|
|
598
599
|
// Realtime
|
|
@@ -553,7 +553,7 @@ module.exports = SitumConversionArea
|
|
|
553
553
|
|
|
554
554
|
/**
|
|
555
555
|
* @name
|
|
556
|
-
*
|
|
556
|
+
* LocationRequest
|
|
557
557
|
* @description
|
|
558
558
|
* A data object that contains parameters for the location service, LocationManager.
|
|
559
559
|
* @property {number} buildingIdentifier - Identifier of the building on which the positioning will be started
|
|
@@ -567,13 +567,12 @@ module.exports = SitumConversionArea
|
|
|
567
567
|
* @property {boolean} useForegroundService - Defines whether or not to activate the {@link http://developers.situm.es/pages/android/using_situm_sdk_background.html foreground service}
|
|
568
568
|
* @property {boolean} useDeadReckoning - Defines whether ot not to use dead reckoning to get fast position updates using only the inertial sensors, between the server position updates.
|
|
569
569
|
* @property {OutdoorLocationOptions} outdoorLocationOptions - Outdoor location options. Only used in an indoor/outdoor request
|
|
570
|
-
* @property {BeaconFilter[]} beaconFilters - Beacon filters to be handled during scan time, otherwise only Situm beacons will be scanned. Can be invoked multiple times to add as much beacon filters as you want
|
|
570
|
+
* @property {BeaconFilter[]} beaconFilters - Beacon filters to be handled during scan time, otherwise only Situm beacons will be scanned. Can be invoked multiple times to add as much beacon filters as you want.
|
|
571
571
|
* @property {number} smallestDisplacement - Default smallest displacement to nofiy location updates
|
|
572
572
|
* @property {string} realtimeUpdateInterval - Default interval to send locations to the Realtime. Possible values are REALTIME, FAST, NORMAL, SLOW and BATTERY_SAVER
|
|
573
573
|
* @property {boolean} autoEnableBleDuringPositioning - Set if the BLE should be re-enabled during positioning if the ble is used. Android only
|
|
574
574
|
*/
|
|
575
|
-
|
|
576
|
-
var LocationOptions = {
|
|
575
|
+
var LocationRequest = {
|
|
577
576
|
buildingIdentifier,
|
|
578
577
|
interval,
|
|
579
578
|
indoorProvider,
|
|
@@ -587,27 +586,22 @@ var LocationOptions = {
|
|
|
587
586
|
outdoorLocationOptions,
|
|
588
587
|
beaconFilters,
|
|
589
588
|
smallestDisplacement,
|
|
590
|
-
realtimeUpdateInterval
|
|
591
|
-
|
|
589
|
+
realtimeUpdateInterval,
|
|
590
|
+
autoEnableBleDuringPositioning,
|
|
591
|
+
};
|
|
592
592
|
|
|
593
|
-
module.exports =
|
|
593
|
+
module.exports = LocationRequest;
|
|
594
594
|
|
|
595
595
|
/**
|
|
596
596
|
* @name
|
|
597
|
-
*
|
|
597
|
+
* LocationOptions
|
|
598
598
|
* @description
|
|
599
599
|
* A data object that contains parameters for the location service, LocationManager.
|
|
600
|
-
* @
|
|
601
|
-
* @property {Building} building 0 - Building on which the positioning will be started
|
|
602
|
-
* @property {LocationOptions} locationOptions 1 - Location options.
|
|
600
|
+
* @deprecated Use {@link LocationRequest} instead.
|
|
603
601
|
*/
|
|
602
|
+
var LocationOptions = LocationRequest;
|
|
604
603
|
|
|
605
|
-
|
|
606
|
-
building,
|
|
607
|
-
locationOptions
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
module.exports = LocationRequest
|
|
604
|
+
module.exports = LocationOptions
|
|
611
605
|
|
|
612
606
|
/**
|
|
613
607
|
* @name
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
/**
|
|
3
|
+
* Takes the different input types from requestLocationUpdates (and startPositioning) and standarizes the response.
|
|
4
|
+
* This function aims to maintain compatibility with older versions of this plugin.
|
|
5
|
+
* @param {any} input
|
|
6
|
+
* @returns A single item array containing the LocationRequest, ready to be sent to native platforms.
|
|
7
|
+
*/
|
|
8
|
+
standarizeRequest: function(input) {
|
|
9
|
+
let response;
|
|
10
|
+
if (!input) {
|
|
11
|
+
// If it is null or undefined, pass an empty location request.
|
|
12
|
+
response = {};
|
|
13
|
+
} else if (Array.isArray(input) && input.length > 0) {
|
|
14
|
+
// If it is an array:
|
|
15
|
+
if (input.every(item => typeof item === 'object')){
|
|
16
|
+
// It may contain objects (legacy API: Building + LocationOptions).
|
|
17
|
+
// Then merge all of them into a single object.
|
|
18
|
+
response = Object.assign({}, ...input);
|
|
19
|
+
} else if (typeof input[0] === 'string' || typeof input[0] === 'number') {
|
|
20
|
+
// It may contain a building identifier + a set of LocationOptions.
|
|
21
|
+
// Assign the building identifier and merge.
|
|
22
|
+
input[0] = {buildingIdentifier: input[0]};
|
|
23
|
+
response = Object.assign({}, ...input);
|
|
24
|
+
}
|
|
25
|
+
} else if (typeof input === 'string' || typeof input === 'number') {
|
|
26
|
+
// The input itself may be a single building identifier.
|
|
27
|
+
response = {buildingIdentifier: input};
|
|
28
|
+
} else {
|
|
29
|
+
// If the input is an object (or any other case), return the object itself. Delegate the
|
|
30
|
+
// error checks to the platform's mapper.
|
|
31
|
+
response = input;
|
|
32
|
+
}
|
|
33
|
+
// Cordova platforms wait for a JSONArray:
|
|
34
|
+
return [response];
|
|
35
|
+
}
|
|
36
|
+
}
|