@situm/cordova 3.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.
- package/CHANGELOG.md +3 -0
- package/CHANGELOG_UNRELEASED.md +28 -0
- package/Jenkinsfile +84 -0
- package/LICENSE +21 -0
- package/README.md +472 -0
- package/azure/common-steps.yaml +5 -0
- package/azure-pipelines.yml +336 -0
- package/docs/JSDoc/MapView.html +300 -0
- package/docs/JSDoc/MapViewControllerImpl.html +299 -0
- package/docs/JSDoc/Situm.html +5257 -0
- package/docs/JSDoc/android_Interfaces.js.html +825 -0
- package/docs/JSDoc/android_situm.js.html +380 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.eot +0 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.svg +288 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.woff +0 -0
- package/docs/JSDoc/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/docs/JSDoc/global.html +7538 -0
- package/docs/JSDoc/img/toast-ui.png +0 -0
- package/docs/JSDoc/index.html +90 -0
- package/docs/JSDoc/map-view-controller.js.html +307 -0
- package/docs/JSDoc/map-view.js.html +172 -0
- package/docs/JSDoc/scripts/jquery.min.js +2 -0
- package/docs/JSDoc/scripts/linenumber.js +30 -0
- package/docs/JSDoc/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/JSDoc/scripts/prettify/lang-css.js +2 -0
- package/docs/JSDoc/scripts/prettify/prettify.js +28 -0
- package/docs/JSDoc/scripts/tui-doc.js +200 -0
- package/docs/JSDoc/styles/bootstrap.min.css +6 -0
- package/docs/JSDoc/styles/custom.css +23 -0
- package/docs/JSDoc/styles/prettify-jsdoc.css +111 -0
- package/docs/JSDoc/styles/prettify-tomorrow.css +132 -0
- package/docs/JSDoc/styles/tui-doc.css +485 -0
- package/docs/conf.json +28 -0
- package/docs/getting-started.md +298 -0
- package/docs/imagotype-SITUM-transparent-90.png +0 -0
- package/docs/static/styles/custom.css +23 -0
- package/package.json +60 -0
- package/plugin.xml +102 -0
- package/scripts/update_changelog.sh +22 -0
- package/src/android/app/build.gradle +51 -0
- package/src/android/app/proguard-rules.pro +21 -0
- package/src/android/app/src/main/AndroidManifest.xml +11 -0
- package/src/android/app/src/main/java/es/situm/plugin/DateUtils.java +15 -0
- package/src/android/app/src/main/java/es/situm/plugin/PluginHelper.java +919 -0
- package/src/android/app/src/main/java/es/situm/plugin/SitumMapper.java +968 -0
- package/src/android/app/src/main/java/es/situm/plugin/SitumPlugin.java +109 -0
- package/src/android/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
- package/src/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
- package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
- package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/src/android/app/src/main/res/values/colors.xml +6 -0
- package/src/android/app/src/main/res/values/strings.xml +3 -0
- package/src/android/app/src/main/res/values/styles.xml +11 -0
- package/src/android/app/src/test/java/es/situm/plugin/PluginHelperTest.java +27 -0
- package/src/android/app/src/test/java/es/situm/plugin/SitumMapperTest.java +1485 -0
- package/src/android/app/src/test/java/es/situm/plugin/angle/AngleCreator.java +46 -0
- package/src/android/app/src/test/java/es/situm/plugin/bounds/BoundsCreator.java +50 -0
- package/src/android/app/src/test/java/es/situm/plugin/building/BuildingCreator.java +76 -0
- package/src/android/app/src/test/java/es/situm/plugin/cartesianCoordinate/CartesianCoordinateCreator.java +31 -0
- package/src/android/app/src/test/java/es/situm/plugin/circle/CircleCreator.java +41 -0
- package/src/android/app/src/test/java/es/situm/plugin/coordinate/CoordinateCreator.java +32 -0
- package/src/android/app/src/test/java/es/situm/plugin/dimensions/DimensionsCreator.java +31 -0
- package/src/android/app/src/test/java/es/situm/plugin/directionsRequest/DirectionsRequestCreator.java +105 -0
- package/src/android/app/src/test/java/es/situm/plugin/event/EventCreator.java +108 -0
- package/src/android/app/src/test/java/es/situm/plugin/floor/FloorCreator.java +58 -0
- package/src/android/app/src/test/java/es/situm/plugin/indication/IndicationCreator.java +40 -0
- package/src/android/app/src/test/java/es/situm/plugin/location/LocationCreator.java +197 -0
- package/src/android/app/src/test/java/es/situm/plugin/locationRequest/LocationRequestCreator.java +45 -0
- package/src/android/app/src/test/java/es/situm/plugin/locationStatus/LocationStatusCreator.java +211 -0
- package/src/android/app/src/test/java/es/situm/plugin/navigationProgress/NavigationProgressCreator.java +154 -0
- package/src/android/app/src/test/java/es/situm/plugin/poi/PoiCreator.java +126 -0
- package/src/android/app/src/test/java/es/situm/plugin/poiCategory/PoiCategoryCreator.java +38 -0
- package/src/android/app/src/test/java/es/situm/plugin/point/PointCreator.java +200 -0
- package/src/android/app/src/test/java/es/situm/plugin/route/RouteCreator.java +142 -0
- package/src/android/app/src/test/java/es/situm/plugin/routeStep/RouteStepCreator.java +173 -0
- package/src/android/app/src/test/java/es/situm/plugin/situmConversionArea/SitumConversionAreaCreator.java +35 -0
- package/src/android/build.gradle +31 -0
- package/src/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/src/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/src/android/gradle.properties +16 -0
- package/src/android/gradlew +172 -0
- package/src/android/gradlew.bat +84 -0
- package/src/android/settings.gradle +3 -0
- package/src/android/situm.gradle +19 -0
- package/src/ios/Classes/Private/CDVDebug.h +25 -0
- package/src/ios/Classes/Private/CDVJSON_private.h +31 -0
- package/src/ios/Classes/Private/CDVJSON_private.m +99 -0
- package/src/ios/Classes/Private/CDVPlugin+Private.h +24 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVGestureHandler/CDVGestureHandler.h +26 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVGestureHandler/CDVGestureHandler.m +70 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVHandleOpenURL/CDVHandleOpenURL.h +27 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVHandleOpenURL/CDVHandleOpenURL.m +86 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.h +34 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.m +153 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVLocalStorage/CDVLocalStorage.h +50 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVLocalStorage/CDVLocalStorage.m +487 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVLogger/CDVLogger.h +26 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVLogger/CDVLogger.m +37 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.h +41 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m +399 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewEngine.h +27 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m +202 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.h +29 -0
- package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m +153 -0
- package/src/ios/Classes/Public/CDV.h +32 -0
- package/src/ios/Classes/Public/CDVAppDelegate.h +28 -0
- package/src/ios/Classes/Public/CDVAppDelegate.m +118 -0
- package/src/ios/Classes/Public/CDVAvailability.h +111 -0
- package/src/ios/Classes/Public/CDVAvailabilityDeprecated.h +26 -0
- package/src/ios/Classes/Public/CDVCommandDelegate.h +51 -0
- package/src/ios/Classes/Public/CDVCommandDelegateImpl.h +36 -0
- package/src/ios/Classes/Public/CDVCommandDelegateImpl.m +186 -0
- package/src/ios/Classes/Public/CDVCommandQueue.h +39 -0
- package/src/ios/Classes/Public/CDVCommandQueue.m +194 -0
- package/src/ios/Classes/Public/CDVConfigParser.h +30 -0
- package/src/ios/Classes/Public/CDVConfigParser.m +81 -0
- package/src/ios/Classes/Public/CDVInvokedUrlCommand.h +52 -0
- package/src/ios/Classes/Public/CDVInvokedUrlCommand.m +116 -0
- package/src/ios/Classes/Public/CDVPlugin+Resources.h +39 -0
- package/src/ios/Classes/Public/CDVPlugin+Resources.m +38 -0
- package/src/ios/Classes/Public/CDVPlugin.h +85 -0
- package/src/ios/Classes/Public/CDVPlugin.m +202 -0
- package/src/ios/Classes/Public/CDVPluginResult.h +66 -0
- package/src/ios/Classes/Public/CDVPluginResult.m +186 -0
- package/src/ios/Classes/Public/CDVScreenOrientationDelegate.h +33 -0
- package/src/ios/Classes/Public/CDVTimer.h +27 -0
- package/src/ios/Classes/Public/CDVTimer.m +123 -0
- package/src/ios/Classes/Public/CDVURLProtocol.h +27 -0
- package/src/ios/Classes/Public/CDVURLProtocol.m +113 -0
- package/src/ios/Classes/Public/CDVUserAgentUtil.h +27 -0
- package/src/ios/Classes/Public/CDVUserAgentUtil.m +124 -0
- package/src/ios/Classes/Public/CDVViewController.h +92 -0
- package/src/ios/Classes/Public/CDVViewController.m +821 -0
- package/src/ios/Classes/Public/CDVWebViewEngineProtocol.h +42 -0
- package/src/ios/Classes/Public/CDVWhitelist.h +34 -0
- package/src/ios/Classes/Public/CDVWhitelist.m +285 -0
- package/src/ios/Classes/Public/NSDictionary+CordovaPreferences.h +35 -0
- package/src/ios/Classes/Public/NSDictionary+CordovaPreferences.m +63 -0
- package/src/ios/Classes/Public/NSMutableArray+QueueAdditions.h +29 -0
- package/src/ios/Classes/Public/NSMutableArray+QueueAdditions.m +58 -0
- package/src/ios/Cordova/Cordova.h +51 -0
- package/src/ios/Cordova/Info.plist +24 -0
- package/src/ios/Podfile +5 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/project.pbxproj +1324 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/src/ios/SitumCordovaPlugin.xcodeproj/xcshareddata/xcschemes/CordovaLib.xcscheme +100 -0
- package/src/ios/SitumCordovaPlugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/src/ios/SitumCordovaPlugin_Prefix.pch +22 -0
- package/src/ios/VERSION +1 -0
- package/src/ios/cordova.js +2432 -0
- package/src/ios/situmcordovaplugin/AppDelegate.h +22 -0
- package/src/ios/situmcordovaplugin/AppDelegate.m +98 -0
- package/src/ios/situmcordovaplugin/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
- package/src/ios/situmcordovaplugin/Base.lproj/LaunchScreen.storyboard +25 -0
- package/src/ios/situmcordovaplugin/Base.lproj/Main.storyboard +24 -0
- package/src/ios/situmcordovaplugin/Constants.h +14 -0
- package/src/ios/situmcordovaplugin/Constants.m +14 -0
- package/src/ios/situmcordovaplugin/Info.plist +45 -0
- package/src/ios/situmcordovaplugin/SITUtils.h +7 -0
- package/src/ios/situmcordovaplugin/SITUtils.m +13 -0
- package/src/ios/situmcordovaplugin/SitumLocationWrapper.h +109 -0
- package/src/ios/situmcordovaplugin/SitumLocationWrapper.m +983 -0
- package/src/ios/situmcordovaplugin/SitumPlugin.h +41 -0
- package/src/ios/situmcordovaplugin/SitumPlugin.m +752 -0
- package/src/ios/situmcordovaplugin/ViewController.h +15 -0
- package/src/ios/situmcordovaplugin/ViewController.m +29 -0
- package/src/ios/situmcordovaplugin/main.m +16 -0
- package/src/ios/situmcordovaplugin/situmcordovaplugin.xcdatamodeld/.xccurrentversion +8 -0
- package/src/ios/situmcordovaplugin/situmcordovaplugin.xcdatamodeld/situmcordovaplugin.xcdatamodel/contents +4 -0
- package/src/ios/situmcordovaplugintests/AngleTests.m +53 -0
- package/src/ios/situmcordovaplugintests/BoundTests.m +51 -0
- package/src/ios/situmcordovaplugintests/BuildingTests.m +41 -0
- package/src/ios/situmcordovaplugintests/CartesianCoordinateTests.m +42 -0
- package/src/ios/situmcordovaplugintests/ConversionAreaTests.m +43 -0
- package/src/ios/situmcordovaplugintests/CoordinateTests.m +42 -0
- package/src/ios/situmcordovaplugintests/DimensionTests.m +43 -0
- package/src/ios/situmcordovaplugintests/EventTests.m +42 -0
- package/src/ios/situmcordovaplugintests/FloorTests.m +52 -0
- package/src/ios/situmcordovaplugintests/Info.plist +38 -0
- package/src/ios/situmcordovaplugintests/InputTests/DirectionsRequestTest.m +108 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputCartesianCoordinateTests.m +45 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputCoordinateTests.m +45 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputFloorTests.m +59 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputIndicationTests.m +45 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputLocationTests.m +163 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputPoiCategoryTests.m +46 -0
- package/src/ios/situmcordovaplugintests/InputTests/InputPointTests.m +137 -0
- package/src/ios/situmcordovaplugintests/InputTests/LocationRequestTest.m +79 -0
- package/src/ios/situmcordovaplugintests/LocationStatusTests.m +60 -0
- package/src/ios/situmcordovaplugintests/LocationTests.m +114 -0
- package/src/ios/situmcordovaplugintests/NavigationProgressTests.m +50 -0
- package/src/ios/situmcordovaplugintests/PoiCategoryIconTests.m +43 -0
- package/src/ios/situmcordovaplugintests/PoiCategoryTests.m +42 -0
- package/src/ios/situmcordovaplugintests/PoiTests.m +83 -0
- package/src/ios/situmcordovaplugintests/PointTests.m +107 -0
- package/src/ios/situmcordovaplugintests/RouteStepTests.m +78 -0
- package/src/ios/situmcordovaplugintests/RouteTests.m +42 -0
- package/src/ios/situmcordovaplugintests/SitumCreatorTests.h +91 -0
- package/src/ios/situmcordovaplugintests/SitumCreatorTests.m +928 -0
- package/src/ios/situmcordovaplugintests/TestingHelper.h +48 -0
- package/src/ios/situmcordovaplugintests/TestingHelper.m +342 -0
- package/src/ios/situmcordovaplugintests/indicationTests.m +43 -0
- package/tests/common-resources/angle/angle1.json +6 -0
- package/tests/common-resources/angle/angle2.json +6 -0
- package/tests/common-resources/bounds/bounds1.json +18 -0
- package/tests/common-resources/bounds/bounds2.json +18 -0
- package/tests/common-resources/building/building1.json +64 -0
- package/tests/common-resources/cartesianCoordinate/cartesianCoordinate1.json +4 -0
- package/tests/common-resources/circle/circle1.json +17 -0
- package/tests/common-resources/coordinate/coordinate1.json +4 -0
- package/tests/common-resources/dimensions/dimensions1.json +4 -0
- package/tests/common-resources/directionsRequest/directionsRequest1.json +166 -0
- package/tests/common-resources/directionsRequest/directionsRequest2.json +167 -0
- package/tests/common-resources/directionsRequest/directionsRequest3.json +166 -0
- package/tests/common-resources/directionsRequest/directionsRequest4.json +166 -0
- package/tests/common-resources/directionsRequest/directionsRequest5.json +167 -0
- package/tests/common-resources/directionsRequest/directionsRequest6.json +153 -0
- package/tests/common-resources/events/event1.json +66 -0
- package/tests/common-resources/floor/floor1.json +13 -0
- package/tests/common-resources/floor/floor2.json +13 -0
- package/tests/common-resources/indication/indication1.json +10 -0
- package/tests/common-resources/location/location1.json +48 -0
- package/tests/common-resources/location/location10.json +48 -0
- package/tests/common-resources/location/location2.json +48 -0
- package/tests/common-resources/location/location3.json +48 -0
- package/tests/common-resources/location/location4.json +48 -0
- package/tests/common-resources/location/location5.json +48 -0
- package/tests/common-resources/location/location6.json +48 -0
- package/tests/common-resources/location/location7.json +48 -0
- package/tests/common-resources/location/location8.json +48 -0
- package/tests/common-resources/location/location9.json +48 -0
- package/tests/common-resources/locationRequest/locationRequest1.json +6 -0
- package/tests/common-resources/locationRequest/locationRequest2.json +32 -0
- package/tests/common-resources/locationRequest/locationRequest3.json +33 -0
- package/tests/common-resources/locationRequest/locationRequest4.json +31 -0
- package/tests/common-resources/locationStatus/locationStatus1.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus10.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus11.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus12.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus13.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus2.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus3.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus4.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus5.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus6.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus7.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus8.json +4 -0
- package/tests/common-resources/locationStatus/locationStatus9.json +4 -0
- package/tests/common-resources/navigationProgress/navigationProgress1.json +77 -0
- package/tests/common-resources/navigationProgress/navigationProgress2.json +77 -0
- package/tests/common-resources/poi/poi1.json +35 -0
- package/tests/common-resources/poi/poi2.json +35 -0
- package/tests/common-resources/poi/poi3.json +35 -0
- package/tests/common-resources/poi/poi4.json +38 -0
- package/tests/common-resources/poi/poi5.json +35 -0
- package/tests/common-resources/poiCategory/poiCategory1.json +7 -0
- package/tests/common-resources/poiCategoryIcon/poiCategoryIcon1.json +1 -0
- package/tests/common-resources/poiCategoryIcon/poiCategoryIcon1.png +0 -0
- package/tests/common-resources/point/point1.json +14 -0
- package/tests/common-resources/point/point2.json +14 -0
- package/tests/common-resources/point/point3.json +14 -0
- package/tests/common-resources/point/point4.json +14 -0
- package/tests/common-resources/point/point5.json +14 -0
- package/tests/common-resources/point/point6.json +14 -0
- package/tests/common-resources/point/point7.json +14 -0
- package/tests/common-resources/point/point8.json +14 -0
- package/tests/common-resources/route/route1.json +530 -0
- package/tests/common-resources/routeStep/routeStep1.json +35 -0
- package/tests/common-resources/routeStep/routeStep2.json +35 -0
- package/tests/common-resources/routeStep/routeStep3.json +35 -0
- package/tests/common-resources/routeStep/routeStep4.json +35 -0
- package/tests/common-resources/routeStep/routeStep5.json +35 -0
- package/tests/common-resources/situmConversionArea/situmConversionArea1.json +19 -0
- package/tests/js/resources/fetchBuildings.json +176 -0
- package/tests/js/resources/fetchEventsFromBuilding.json +201 -0
- package/tests/js/resources/fetchFloorsFromBuilding.json +34 -0
- package/tests/js/resources/fetchIndoorPOIsFromBuilding.json +574 -0
- package/tests/js/resources/fetchMapFromFloor.json +3 -0
- package/tests/js/resources/fetchOutdoorPOIsFromBuilding.json +68 -0
- package/tests/js/resources/fetchPoiCategories.json +72 -0
- package/tests/js/resources/fetchPoiCategoryIconNormal.json +3 -0
- package/tests/js/resources/fetchPoiCategoryIconSelected.json +3 -0
- package/tests/js/resources/requestDirections.json +1167 -0
- package/tests/js/resources/startPositioning/0_starting.json +4 -0
- package/tests/js/resources/startPositioning/1_preparingPositioningModel.json +4 -0
- package/tests/js/resources/startPositioning/2_startingPositioning.json +4 -0
- package/tests/js/resources/startPositioning/3_calculating.json +4 -0
- package/tests/js/resources/startPositioning/4_position.json +48 -0
- package/tests/js/resources/startPositioning/5_position.json +48 -0
- package/tests/js/test.js +416 -0
- package/tests/scripts/clean_android_resources.sh +3 -0
- package/tests/scripts/clean_ios_resources.sh +3 -0
- package/tests/scripts/copy_android_resources.sh +3 -0
- package/tests/scripts/copy_ios_resources.sh +3 -0
- package/tests/scripts/self-destruct.sh +1 -0
- package/www/android/Interfaces.js +742 -0
- package/www/android/situm.js +296 -0
- package/www/ios/situm.js +99 -0
- package/www/map-view-controller.js +223 -0
- package/www/map-view.js +88 -0
|
@@ -0,0 +1,968 @@
|
|
|
1
|
+
package es.situm.plugin;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.graphics.Bitmap;
|
|
5
|
+
import android.util.Base64;
|
|
6
|
+
import android.util.Log;
|
|
7
|
+
|
|
8
|
+
import org.json.JSONArray;
|
|
9
|
+
import org.json.JSONException;
|
|
10
|
+
import org.json.JSONObject;
|
|
11
|
+
|
|
12
|
+
import java.io.ByteArrayOutputStream;
|
|
13
|
+
import java.text.DateFormat;
|
|
14
|
+
import java.text.ParseException;
|
|
15
|
+
import java.text.SimpleDateFormat;
|
|
16
|
+
import java.util.ArrayList;
|
|
17
|
+
import java.util.HashMap;
|
|
18
|
+
import java.util.Iterator;
|
|
19
|
+
import java.util.Collection;
|
|
20
|
+
import java.util.List;
|
|
21
|
+
import java.util.Locale;
|
|
22
|
+
import java.util.Map;
|
|
23
|
+
|
|
24
|
+
import es.situm.sdk.directions.DirectionsRequest;
|
|
25
|
+
import es.situm.sdk.location.LocationRequest;
|
|
26
|
+
import es.situm.sdk.location.LocationStatus;
|
|
27
|
+
import es.situm.sdk.location.OutdoorLocationOptions;
|
|
28
|
+
import es.situm.sdk.location.util.CoordinateConverter;
|
|
29
|
+
import es.situm.sdk.model.I18nString;
|
|
30
|
+
import es.situm.sdk.model.URL;
|
|
31
|
+
import es.situm.sdk.model.cartography.Building;
|
|
32
|
+
import es.situm.sdk.model.cartography.Circle;
|
|
33
|
+
import es.situm.sdk.model.cartography.Floor;
|
|
34
|
+
import es.situm.sdk.model.cartography.Poi;
|
|
35
|
+
import es.situm.sdk.model.cartography.PoiCategory;
|
|
36
|
+
import es.situm.sdk.model.cartography.Point;
|
|
37
|
+
import es.situm.sdk.model.cartography.Geofence;
|
|
38
|
+
import es.situm.sdk.model.cartography.BuildingInfo;
|
|
39
|
+
import es.situm.sdk.model.directions.Indication;
|
|
40
|
+
import es.situm.sdk.model.directions.Route;
|
|
41
|
+
import es.situm.sdk.model.directions.RouteSegment;
|
|
42
|
+
import es.situm.sdk.model.directions.RouteStep;
|
|
43
|
+
import es.situm.sdk.model.location.Angle;
|
|
44
|
+
import es.situm.sdk.model.location.BeaconFilter;
|
|
45
|
+
import es.situm.sdk.model.location.Bounds;
|
|
46
|
+
import es.situm.sdk.model.location.CartesianCoordinate;
|
|
47
|
+
import es.situm.sdk.model.location.Coordinate;
|
|
48
|
+
import es.situm.sdk.model.location.Dimensions;
|
|
49
|
+
import es.situm.sdk.model.location.Location;
|
|
50
|
+
import es.situm.sdk.model.location.Location.Quality;
|
|
51
|
+
import es.situm.sdk.model.navigation.NavigationProgress;
|
|
52
|
+
import es.situm.sdk.v1.Point2f;
|
|
53
|
+
import es.situm.sdk.v1.SitumConversionArea;
|
|
54
|
+
import es.situm.sdk.v1.SitumEvent;
|
|
55
|
+
import es.situm.sdk.realtime.RealTimeRequest;
|
|
56
|
+
import es.situm.sdk.model.realtime.RealTimeData;
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class SitumMapper {
|
|
60
|
+
|
|
61
|
+
public static final float MIN_SNR = 10;
|
|
62
|
+
public static final float MAX_SNR = 40;
|
|
63
|
+
|
|
64
|
+
public static final String ADDRESS = "address";
|
|
65
|
+
public static final String BOUNDS = "bounds";
|
|
66
|
+
public static final String BOUNDS_ROTATED = "boundsRotated";
|
|
67
|
+
public static final String CENTER = "center";
|
|
68
|
+
public static final String DIMENSIONS = "dimensions";
|
|
69
|
+
public static final String INFO_HTML = "infoHtml";
|
|
70
|
+
public static final String BUILDING_NAME = "name";
|
|
71
|
+
public static final String PICTURE_THUMB_URL = "pictureThumbUrl";
|
|
72
|
+
public static final String POI_NAME = "poiName";
|
|
73
|
+
public static final String POI_CATEGORY_NAME = "poiCategoryName";
|
|
74
|
+
public static final String POI_CATEGORY_CODE = "poiCategoryCode";
|
|
75
|
+
public static final String POI_CATEGORY = "category";
|
|
76
|
+
public static final String IS_PUBLIC = "public";
|
|
77
|
+
public static final String PICTURE_URL = "pictureUrl";
|
|
78
|
+
public static final String ROTATION = "rotation";
|
|
79
|
+
public static final String USER_IDENTIFIER = "userIdentifier";
|
|
80
|
+
|
|
81
|
+
public static final String ALTITUDE = "altitude";
|
|
82
|
+
public static final String BUILDING_IDENTIFIER = "buildingIdentifier";
|
|
83
|
+
public static final String FLOOR_IDENTIFIER = "floorIdentifier";
|
|
84
|
+
|
|
85
|
+
public static final String LEVEL = "level";
|
|
86
|
+
public static final String FLOOR = "floor";
|
|
87
|
+
public static final String MAP_URL = "mapUrl";
|
|
88
|
+
public static final String SCALE = "scale";
|
|
89
|
+
|
|
90
|
+
public static final String COORDINATE = "coordinate";
|
|
91
|
+
public static final String CARTESIAN_COORDINATE = "cartesianCoordinate";
|
|
92
|
+
public static final String CARTESIAN_BEARING = "cartesianBearing";
|
|
93
|
+
public static final String POSITION = "position";
|
|
94
|
+
public static final String IS_INDOOR = "isIndoor";
|
|
95
|
+
public static final String PROVIDER = "provider";
|
|
96
|
+
public static final String QUALITY = "quality";
|
|
97
|
+
public static final String IS_OUTDOOR = "isOutdoor";
|
|
98
|
+
public static final String DEVICE_ID = "deviceId";
|
|
99
|
+
|
|
100
|
+
public static final String RADIUS = "radius";
|
|
101
|
+
public static final String ACCURACY = "accuracy";
|
|
102
|
+
public static final String BEARING = "bearing";
|
|
103
|
+
public static final String TIMESTAMP = "timestamp";
|
|
104
|
+
public static final String LATITUDE = "latitude";
|
|
105
|
+
public static final String LONGITUDE = "longitude";
|
|
106
|
+
public static final String STATUS_NAME = "statusName";
|
|
107
|
+
public static final String STATUS_ORDINAL = "statusOrdinal";
|
|
108
|
+
|
|
109
|
+
public static final String HAS_BEARING = "hasBearing";
|
|
110
|
+
public static final String HAS_CARTESIAN_BEARING = "hasCartesianBearing";
|
|
111
|
+
public static final String BEARING_QUALITY = "bearingQuality";
|
|
112
|
+
|
|
113
|
+
public static final String NORTH_EAST = "northEast";
|
|
114
|
+
public static final String NORTH_WEST = "northWest";
|
|
115
|
+
public static final String SOUTH_EAST = "southEast";
|
|
116
|
+
public static final String SOUTH_WEST = "southWest";
|
|
117
|
+
|
|
118
|
+
public static final String DEGREES = "degrees";
|
|
119
|
+
public static final String DEGREES_CLOCKWISE = "degreesClockwise";
|
|
120
|
+
public static final String RADIANS_MINUS_PI_PI = "radiansMinusPiPi";
|
|
121
|
+
public static final String RADIANS = "radians";
|
|
122
|
+
|
|
123
|
+
public static final String WIDTH = "width";
|
|
124
|
+
public static final String HEIGHT = "height";
|
|
125
|
+
public static final String X = "x";
|
|
126
|
+
public static final String Y = "y";
|
|
127
|
+
public static final String ID = "id";
|
|
128
|
+
|
|
129
|
+
public static final String EDGES = "edges";
|
|
130
|
+
public static final String FIRST_STEP = "firstStep";
|
|
131
|
+
public static final String LAST_STEP = "lastStep";
|
|
132
|
+
public static final String INDICATIONS = "indications";
|
|
133
|
+
public static final String NODES = "nodes";
|
|
134
|
+
public static final String POINTS = "points";
|
|
135
|
+
public static final String FROM = "from";
|
|
136
|
+
public static final String TO = "TO";
|
|
137
|
+
public static final String STEPS = "steps";
|
|
138
|
+
public static final String SEGMENTS = "segments";
|
|
139
|
+
|
|
140
|
+
public static final String DISTANCE_TO_GOAL = "distanceToGoal";
|
|
141
|
+
public static final String DISTANCE = "distance";
|
|
142
|
+
public static final String DISTANCE_TO_NEXT_LEVEL = "distanceToNextLevel";
|
|
143
|
+
public static final String DISTANCE_TO_CLOSEST_POINT_IN_ROUTE = "distanceToClosestPointInRoute";
|
|
144
|
+
public static final String DISTANCE_TO_END_STEP = "distanceToEndStep";
|
|
145
|
+
public static final String INDICATION_TYPE = "indicationType";
|
|
146
|
+
public static final String CURRENT_INDICATION = "currentIndication";
|
|
147
|
+
public static final String NEXT_INDICATION = "nextIndication";
|
|
148
|
+
public static final String IS_FIRST = "isFirst";
|
|
149
|
+
public static final String IS_LAST = "isLast";
|
|
150
|
+
public static final String CLOSEST_POINT_IN_ROUTE = "closestPointInRoute";
|
|
151
|
+
public static final String STEP_IDX_DESTINATION = "stepIdxDestination";
|
|
152
|
+
public static final String STEP_IDX_ORIGIN = "stepIdxOrigin";
|
|
153
|
+
public static final String NEEDED_LEVEL_CHANGE = "neededLevelChange";
|
|
154
|
+
public static final String HUMAN_READABLE_MESSAGE = "humanReadableMessage";
|
|
155
|
+
public static final String ORIENTATION_TYPE = "orientationType";
|
|
156
|
+
public static final String ORIENTATION = "orientation";
|
|
157
|
+
public static final String ROUTE_STEP = "routeStep";
|
|
158
|
+
public static final String TIME_TO_END_STEP = "timeToEndStep";
|
|
159
|
+
public static final String TIME_TO_GOAL = "timeToGoal";
|
|
160
|
+
public static final String NEXT_LEVEL = "nextLevel";
|
|
161
|
+
|
|
162
|
+
public static final String CONVERSION_AREA = "conversionArea";
|
|
163
|
+
public static final String CONVERSION = "conversion";
|
|
164
|
+
public static final String TRIGGER = "trigger";
|
|
165
|
+
public static final String IDENTIFIER = "identifier";
|
|
166
|
+
public static final String CUSTOM_FIELDS = "customFields";
|
|
167
|
+
public static final String TOP_LEFT = "topLeft";
|
|
168
|
+
public static final String BOTTOM_LEFT = "bottomLeft";
|
|
169
|
+
public static final String TOP_RIGHT = "topRight";
|
|
170
|
+
public static final String BOTTOM_RIGHT = "bottomRight";
|
|
171
|
+
public static final String POI_CATEGORY_ICON_SELECTED = "icon_selected";
|
|
172
|
+
public static final String POI_CATEGORY_ICON_UNSELECTED = "icon_unselected";
|
|
173
|
+
|
|
174
|
+
public static final String INTERVAL = "interval";
|
|
175
|
+
public static final String INDOOR_PROVIDER = "indoorProvider";
|
|
176
|
+
public static final String USE_BLE = "useBle";
|
|
177
|
+
public static final String USE_WIFI = "useWifi";
|
|
178
|
+
public static final String MOTION_MODE = "motionMode";
|
|
179
|
+
public static final String USE_FOREGROUND_SERVICE = "useForegroundService";
|
|
180
|
+
public static final String USE_DEAD_RECKONING = "useDeadReckoning";
|
|
181
|
+
public static final String USE_GPS = "useGps";
|
|
182
|
+
public static final String USE_BAROMETER = "useBarometer";
|
|
183
|
+
public static final String AUTO_ENABLE_BLE = "autoEnableBleDuringPositioning";
|
|
184
|
+
|
|
185
|
+
public static final String OUTDOOR_LOCATION_OPTIONS = "outdoorLocationOptions";
|
|
186
|
+
public static final String USER_DEFINED_THRESHOLD = "userDefinedThreshold";
|
|
187
|
+
public static final String COMPUTE_INTERVAL = "computeInterval";
|
|
188
|
+
public static final String AVERAGE_SNR_THRESHOLD = "averageSnrThreshold";
|
|
189
|
+
|
|
190
|
+
public static final String BEACON_FILTERS = "beaconFilters";
|
|
191
|
+
public static final String UUID = "uuid";
|
|
192
|
+
|
|
193
|
+
public static final String SMALLEST_DISPLACEMENT = "smallestDisplacement";
|
|
194
|
+
public static final String REALTIME_UPDATE_INTERVAL = "realtimeUpdateInterval";
|
|
195
|
+
public static final String ACCESSIBLE = "accessible";
|
|
196
|
+
public static final String ACCESSIBLE_ROUTE = "accessibleRoute";
|
|
197
|
+
public static final String CACHE_AGE = "cacheAge";
|
|
198
|
+
|
|
199
|
+
public static final String DISTANCE_TO_IGNORE_FIRST_INDICATION = "distanceToIgnoreFirstIndication";
|
|
200
|
+
public static final String OUTSIDE_ROUTE_THRESHOLD = "outsideRouteThreshold";
|
|
201
|
+
public static final String DISTANCE_TO_GOAL_THRESHOLD = "distanceToGoalThreshold";
|
|
202
|
+
public static final String DISTANCE_TO_CHANGE_INDICATION_THRESHOLD = "distanceToChangeIndicationThreshold";
|
|
203
|
+
public static final String DISTANCE_TO_CHANGE_FLOOR_THRESHOLD = "distanceToChangeFloorThreshold";
|
|
204
|
+
public static final String INDICATIONS_INTERVAL = "indicationsInterval";
|
|
205
|
+
public static final String TIME_TO_FIRST_INDICATION = "timeToFirstIndication";
|
|
206
|
+
public static final String ROUND_INDICATION_STEP = "roundIndicationsStep";
|
|
207
|
+
public static final String TIME_TO_IGNORE_UNEXPECTED_FLOOR_CHANGES = "timeToIgnoreUnexpectedFloorChanges";
|
|
208
|
+
public static final String IGNORE_LOW_QUALITY_LOCATIONS = "ignoreLowQualityLocations";
|
|
209
|
+
|
|
210
|
+
public static final String CURRENT_STEP_INDEX = "currentStepIndex";
|
|
211
|
+
public static final String CLOSEST_LOCATION_IN_ROUTE = "closestLocationInRoute";
|
|
212
|
+
|
|
213
|
+
public static final String STARTING_ANGLE = "startingAngle";
|
|
214
|
+
public static final String MINIMIZE_FLOOR_CHANGES = "minimizeFloorChanges";
|
|
215
|
+
public static final String CREATED_AT = "createdAt";
|
|
216
|
+
public static final String UPDATED_AT = "updatedAt";
|
|
217
|
+
public static final String NAME = "name";
|
|
218
|
+
public static final String ACCESSIBILITY_MODE = "accessibilityMode";
|
|
219
|
+
public static final String POLYGON_POINTS = "polygonPoints";
|
|
220
|
+
public static final String CODE = "code";
|
|
221
|
+
public static final String BUILDING = "building";
|
|
222
|
+
public static final String FLOORS = "floors";
|
|
223
|
+
public static final String EVENTS = "events";
|
|
224
|
+
public static final String INDOOR_POIS = "indoorPOIs";
|
|
225
|
+
public static final String OUTDOOR_POIS = "outdoorPOIs";
|
|
226
|
+
public static final String LOCATIONS = "locations";
|
|
227
|
+
public static final String POLL_TIME = "pollTime";
|
|
228
|
+
|
|
229
|
+
public static final DateFormat dateFormat = DateUtils.dateFormat;
|
|
230
|
+
|
|
231
|
+
private static final String TAG = "PluginHelper";
|
|
232
|
+
|
|
233
|
+
static JSONObject buildingToJsonObject(Building building) throws JSONException {
|
|
234
|
+
JSONObject jo = new JSONObject();
|
|
235
|
+
jo.put(ADDRESS, building.getAddress());
|
|
236
|
+
jo.put(BOUNDS, boundsToJsonObject(building.getBounds()));
|
|
237
|
+
jo.put(BOUNDS_ROTATED, boundsToJsonObject(building.getBoundsRotated()));
|
|
238
|
+
jo.put(CENTER, coordinateToJsonObject(building.getCenter()));
|
|
239
|
+
jo.put(DIMENSIONS, dimensionsToJsonObject(building.getDimensions()));
|
|
240
|
+
jo.put(INFO_HTML, building.getInfoHtml());
|
|
241
|
+
jo.put(BUILDING_NAME, building.getName());
|
|
242
|
+
jo.put(PICTURE_THUMB_URL, building.getPictureThumbUrl().getValue());
|
|
243
|
+
jo.put(PICTURE_URL, building.getPictureUrl().getValue());
|
|
244
|
+
jo.put(ROTATION, building.getRotation().radians());
|
|
245
|
+
jo.put(USER_IDENTIFIER, building.getUserIdentifier());
|
|
246
|
+
jo.put(BUILDING_IDENTIFIER, building.getIdentifier());
|
|
247
|
+
jo.put(CUSTOM_FIELDS, mapStringToJsonObject(building.getCustomFields()));
|
|
248
|
+
jo.put(CREATED_AT, dateFormat.format(building.getCreatedAt()));
|
|
249
|
+
jo.put(UPDATED_AT, dateFormat.format(building.getUpdatedAt()));
|
|
250
|
+
return jo;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
static JSONObject mapStringToJsonObject(Map<String, String> mp) throws JSONException {
|
|
254
|
+
JSONObject jo = new JSONObject();
|
|
255
|
+
Iterator it = mp.entrySet().iterator();
|
|
256
|
+
while (it.hasNext()) {
|
|
257
|
+
Map.Entry<String, String> pairs = (Map.Entry<String, String>) it.next();
|
|
258
|
+
jo.put(pairs.getKey(), pairs.getValue());
|
|
259
|
+
}
|
|
260
|
+
return jo;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
static Map<String,String> jsonObjectToMapString(JSONObject jo) throws JSONException {
|
|
264
|
+
Map<String,String> map = new HashMap<String, String>();
|
|
265
|
+
int length = jo.length();
|
|
266
|
+
for(int i = 0; i<length; i++){
|
|
267
|
+
map.put(jo.names().get(i).toString(),jo.getString(jo.names().get(i).toString()));
|
|
268
|
+
}
|
|
269
|
+
return map;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
static Building buildingJsonObjectToBuilding(JSONObject jo) throws JSONException, ParseException {
|
|
273
|
+
Building building = null;
|
|
274
|
+
Coordinate center = new Coordinate(jo.getJSONObject(CENTER).getDouble(LATITUDE),
|
|
275
|
+
jo.getJSONObject(CENTER).getDouble(LONGITUDE));
|
|
276
|
+
Dimensions dimesnsions = new Dimensions(jo.getJSONObject(DIMENSIONS).getDouble(WIDTH),
|
|
277
|
+
jo.getJSONObject(DIMENSIONS).getDouble(HEIGHT));
|
|
278
|
+
building = new Building.Builder().identifier(jo.getString(BUILDING_IDENTIFIER)).address(jo.getString(ADDRESS))
|
|
279
|
+
.rotation(Angle.fromRadians(jo.getDouble(ROTATION)))
|
|
280
|
+
.updatedAt(dateFormat.parse(jo.getString(UPDATED_AT)))
|
|
281
|
+
.createdAt(dateFormat.parse(jo.getString(CREATED_AT)))
|
|
282
|
+
.customFields(jsonObjectToMapString(jo.getJSONObject(CUSTOM_FIELDS)))
|
|
283
|
+
.name(jo.getString(BUILDING_NAME)).userIdentifier(jo.getString(USER_IDENTIFIER)).center(center)
|
|
284
|
+
.dimensions(dimesnsions).infoHtml(jo.getString(INFO_HTML)).build();
|
|
285
|
+
return building;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
static JSONArray arrayFromFloors(Collection<Floor> floors) throws JSONException {
|
|
289
|
+
JSONArray jsonaFloors = new JSONArray();
|
|
290
|
+
|
|
291
|
+
for (Floor floor : floors) {
|
|
292
|
+
JSONObject jsonoFloor = SitumMapper.floorToJsonObject(floor);
|
|
293
|
+
jsonaFloors.put(jsonoFloor);
|
|
294
|
+
}
|
|
295
|
+
return jsonaFloors;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
static JSONArray arrayFromPois(Collection<Poi> pois) throws JSONException {
|
|
299
|
+
JSONArray jsonaPois = new JSONArray();
|
|
300
|
+
|
|
301
|
+
for (Poi poi : pois) {
|
|
302
|
+
JSONObject jsonoPoi = SitumMapper.poiToJsonObject(poi);
|
|
303
|
+
jsonaPois.put(jsonoPoi);
|
|
304
|
+
}
|
|
305
|
+
return jsonaPois;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
static JSONObject realtimeDataToJson(RealTimeData realtimeData) throws JSONException {
|
|
309
|
+
JSONObject jsonObject = new JSONObject();
|
|
310
|
+
|
|
311
|
+
JSONArray jarrayLocations = new JSONArray();
|
|
312
|
+
|
|
313
|
+
for (Location location : realtimeData.getLocations()) {
|
|
314
|
+
JSONObject jsonLocation = SitumMapper.locationToJsonObject(location);
|
|
315
|
+
jarrayLocations.put(jsonLocation);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
jsonObject.put(LOCATIONS, jarrayLocations);
|
|
319
|
+
|
|
320
|
+
return jsonObject;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
static JSONArray arrayFromEvents(Collection<SitumEvent> situmEvents) throws JSONException {
|
|
324
|
+
JSONArray array = new JSONArray();
|
|
325
|
+
for (SitumEvent situmEvent : situmEvents) {
|
|
326
|
+
JSONObject jsonoSitumEvent = situmEventToJsonObject(situmEvent);
|
|
327
|
+
array.put(jsonoSitumEvent);
|
|
328
|
+
}
|
|
329
|
+
return array;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Building Info
|
|
333
|
+
static JSONObject buildingInfoToJsonObject(BuildingInfo buildingInfo) throws JSONException {
|
|
334
|
+
JSONObject jo = new JSONObject();
|
|
335
|
+
|
|
336
|
+
// Parse Building
|
|
337
|
+
jo.put(BUILDING, buildingToJsonObject(buildingInfo.getBuilding()));
|
|
338
|
+
// Parse Floors
|
|
339
|
+
jo.put(FLOORS, arrayFromFloors(buildingInfo.getFloors()));
|
|
340
|
+
// Parse Indoor Pois
|
|
341
|
+
jo.put(INDOOR_POIS, arrayFromPois(buildingInfo.getIndoorPOIs()));
|
|
342
|
+
// Parse Outdoor Pois
|
|
343
|
+
jo.put(OUTDOOR_POIS, arrayFromPois(buildingInfo.getOutdoorPOIs()));
|
|
344
|
+
// Events
|
|
345
|
+
jo.put(EVENTS, arrayFromEvents(buildingInfo.getEvents()));
|
|
346
|
+
// fetch geofences
|
|
347
|
+
|
|
348
|
+
return jo;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Geofence
|
|
352
|
+
static JSONObject geofenceToJsonObject(Geofence geofence) throws JSONException {
|
|
353
|
+
JSONObject jo = new JSONObject();
|
|
354
|
+
jo.put(NAME, geofence.getName());
|
|
355
|
+
jo.put(CODE, geofence.getCode());
|
|
356
|
+
jo.put(INFO_HTML, geofence.getInfoHtml());
|
|
357
|
+
jo.put(BUILDING_IDENTIFIER, geofence.getBuildingIdentifier());
|
|
358
|
+
jo.put(FLOOR_IDENTIFIER, geofence.getFloorIdentifier());
|
|
359
|
+
|
|
360
|
+
// polygonPoints
|
|
361
|
+
jo.put(POLYGON_POINTS, jsonPointsFromPoints(geofence.getPolygonPoints()));
|
|
362
|
+
|
|
363
|
+
jo.put(IDENTIFIER, geofence.getIdentifier());
|
|
364
|
+
jo.put(CUSTOM_FIELDS, mapStringToJsonObject(geofence.getCustomFields()));
|
|
365
|
+
jo.put(CREATED_AT, dateFormat.format(geofence.getCreatedAt()));
|
|
366
|
+
jo.put(UPDATED_AT, dateFormat.format(geofence.getUpdatedAt()));
|
|
367
|
+
|
|
368
|
+
return jo;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
static JSONArray parseGeofencesToJsonArray(List<Geofence> geofences) throws JSONException {
|
|
372
|
+
JSONArray jsonaGeofences = new JSONArray();
|
|
373
|
+
for (Geofence geofence : geofences) {
|
|
374
|
+
JSONObject jsonoGeofence = geofenceToJsonObject(geofence);
|
|
375
|
+
jsonaGeofences.put(jsonoGeofence);
|
|
376
|
+
}
|
|
377
|
+
return jsonaGeofences;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
static JSONArray jsonPointsFromPoints(List<Point> points) throws JSONException {
|
|
381
|
+
JSONArray pointsJsonArray = new JSONArray();
|
|
382
|
+
for (Point point : points) {
|
|
383
|
+
pointsJsonArray.put(pointToJsonObject(point));
|
|
384
|
+
}
|
|
385
|
+
return pointsJsonArray;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Floor
|
|
389
|
+
|
|
390
|
+
static JSONObject floorToJsonObject(Floor floor) throws JSONException {
|
|
391
|
+
JSONObject jo = new JSONObject();
|
|
392
|
+
jo.put(ALTITUDE, floor.getAltitude());
|
|
393
|
+
jo.put(BUILDING_IDENTIFIER, floor.getBuildingIdentifier());
|
|
394
|
+
jo.put(LEVEL, floor.getLevel());
|
|
395
|
+
// Include floor here
|
|
396
|
+
jo.put(FLOOR, floor.getFloor());
|
|
397
|
+
jo.put(NAME, floor.getName());
|
|
398
|
+
jo.put(MAP_URL, floor.getMapUrl().getValue());
|
|
399
|
+
jo.put(SCALE, floor.getScale());
|
|
400
|
+
jo.put(FLOOR_IDENTIFIER, floor.getIdentifier());
|
|
401
|
+
jo.put(IDENTIFIER, floor.getIdentifier());
|
|
402
|
+
jo.put(CUSTOM_FIELDS, mapStringToJsonObject(floor.getCustomFields()));
|
|
403
|
+
jo.put(CREATED_AT, dateFormat.format(floor.getCreatedAt()));
|
|
404
|
+
jo.put(UPDATED_AT, dateFormat.format(floor.getUpdatedAt()));
|
|
405
|
+
return jo;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
static Floor floorJsonObjectToFloor(JSONObject jo) throws JSONException {
|
|
409
|
+
Floor floor = null;
|
|
410
|
+
floor = new Floor.Builder()
|
|
411
|
+
.buildingIdentifier(jo.getString(BUILDING_IDENTIFIER))
|
|
412
|
+
.altitude(jo.getDouble(ALTITUDE))
|
|
413
|
+
.customFields(jsonObjectToMapString(jo.getJSONObject(CUSTOM_FIELDS)))
|
|
414
|
+
.name(jo.getString(NAME))
|
|
415
|
+
.level(jo.getInt(LEVEL))
|
|
416
|
+
.floor(jo.getInt(FLOOR))
|
|
417
|
+
.name(jo.getString(NAME))
|
|
418
|
+
.mapUrl(new URL(jo.getString(MAP_URL)))
|
|
419
|
+
.scale(jo.getDouble(SCALE)).build();
|
|
420
|
+
|
|
421
|
+
return floor;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// Situm Events
|
|
425
|
+
|
|
426
|
+
static JSONObject situmEventToJsonObject(SitumEvent situmEvent) throws JSONException {
|
|
427
|
+
JSONObject jo = new JSONObject();
|
|
428
|
+
jo.put(BUILDING_IDENTIFIER, situmEvent.getBuildingId());
|
|
429
|
+
jo.put(IDENTIFIER, situmEvent.getId());
|
|
430
|
+
jo.put(FLOOR_IDENTIFIER, situmEvent.getFloor_id());
|
|
431
|
+
jo.put(INFO_HTML, situmEvent.getHtml());
|
|
432
|
+
jo.put(CONVERSION_AREA, conversionAreaToJsonObject(situmEvent.getConversionArea()));
|
|
433
|
+
jo.put(CUSTOM_FIELDS, mapStringToJsonObject(situmEvent.getCustomFields()));
|
|
434
|
+
jo.put(RADIUS, situmEvent.getRadius());
|
|
435
|
+
jo.put(NAME, situmEvent.getName());
|
|
436
|
+
jo.put(X, situmEvent.getX());
|
|
437
|
+
jo.put(Y, situmEvent.getY());
|
|
438
|
+
if (situmEvent.getConversion() != null) {
|
|
439
|
+
jo.put(CONVERSION, circleToJsonObject(situmEvent.getConversion()));
|
|
440
|
+
}
|
|
441
|
+
jo.put(TRIGGER, circleToJsonObject(situmEvent.getTrigger()));
|
|
442
|
+
|
|
443
|
+
return jo;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
static JSONObject circleToJsonObject(Circle circle) throws JSONException {
|
|
447
|
+
JSONObject jo = new JSONObject();
|
|
448
|
+
jo.put(CENTER, circle != null ? pointToJsonObject(circle.getCenter()) : null);
|
|
449
|
+
jo.put(RADIUS, circle != null ? circle.getRadius(): null);
|
|
450
|
+
return jo;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
static JSONObject conversionAreaToJsonObject(SitumConversionArea situmCA) throws JSONException {
|
|
454
|
+
JSONObject jo = new JSONObject();
|
|
455
|
+
jo.put(FLOOR_IDENTIFIER, situmCA.getFloor_id());
|
|
456
|
+
jo.put(TOP_LEFT, convertPoint2fToJsonObject(situmCA.getTopLeft()));
|
|
457
|
+
jo.put(TOP_RIGHT, convertPoint2fToJsonObject(situmCA.getTopRight()));
|
|
458
|
+
jo.put(BOTTOM_LEFT, convertPoint2fToJsonObject(situmCA.getBottomLeft()));
|
|
459
|
+
jo.put(BOTTOM_RIGHT, convertPoint2fToJsonObject(situmCA.getBottomRight()));
|
|
460
|
+
return jo;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
static JSONObject convertPoint2fToJsonObject(Point2f point) throws JSONException{
|
|
464
|
+
JSONObject jo = new JSONObject();
|
|
465
|
+
jo.put(X, point.getX());
|
|
466
|
+
jo.put(Y, point.getY());
|
|
467
|
+
return jo;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// POI
|
|
471
|
+
|
|
472
|
+
static JSONObject poiToJsonObject(Poi poi) throws JSONException {
|
|
473
|
+
JSONObject jo = new JSONObject();
|
|
474
|
+
jo.put(IDENTIFIER, poi.getIdentifier());
|
|
475
|
+
jo.put(BUILDING_IDENTIFIER, poi.getBuildingIdentifier());
|
|
476
|
+
jo.put(CARTESIAN_COORDINATE, cartesianCoordinateToJsonObject(poi.getCartesianCoordinate()));
|
|
477
|
+
jo.put(COORDINATE, coordinateToJsonObject(poi.getCoordinate()));
|
|
478
|
+
jo.put(FLOOR_IDENTIFIER, poi.getFloorIdentifier());
|
|
479
|
+
jo.put(POI_NAME, poi.getName());
|
|
480
|
+
jo.put(POSITION, pointToJsonObject(poi.getPosition()));
|
|
481
|
+
jo.put(IS_INDOOR, poi.isIndoor());
|
|
482
|
+
jo.put(IS_OUTDOOR, poi.isOutdoor());
|
|
483
|
+
jo.put(POI_CATEGORY, poi.getCategory().getCode());
|
|
484
|
+
jo.put(INFO_HTML, poi.getInfoHtml());
|
|
485
|
+
jo.put(CUSTOM_FIELDS, mapStringToJsonObject(poi.getCustomFields()));
|
|
486
|
+
jo.put(CREATED_AT, dateFormat.format(poi.getCreatedAt()));
|
|
487
|
+
jo.put(UPDATED_AT, dateFormat.format(poi.getUpdatedAt()));
|
|
488
|
+
return jo;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
static JSONObject poiCategoryToJsonObject(PoiCategory poiCategory) throws JSONException {
|
|
492
|
+
JSONObject jo = new JSONObject();
|
|
493
|
+
jo.put(POI_CATEGORY_CODE, poiCategory.getCode());
|
|
494
|
+
jo.put(POI_CATEGORY_NAME, poiCategory.getName());
|
|
495
|
+
jo.put(POI_CATEGORY_ICON_SELECTED, poiCategory.getSelectedIconUrl().getValue());
|
|
496
|
+
jo.put(POI_CATEGORY_ICON_UNSELECTED, poiCategory.getUnselectedIconUrl().getValue());
|
|
497
|
+
jo.put(IS_PUBLIC, poiCategory.isPublic());
|
|
498
|
+
return jo;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
static PoiCategory poiCategoryFromJsonObject(JSONObject jo) throws JSONException {
|
|
502
|
+
PoiCategory category = null;
|
|
503
|
+
category = new PoiCategory.Builder()
|
|
504
|
+
.code(jo.getString(POI_CATEGORY_CODE))
|
|
505
|
+
.name(new I18nString.Builder(jo.getString(POI_CATEGORY_NAME)).build())
|
|
506
|
+
.isPublic(jo.getBoolean(IS_PUBLIC))
|
|
507
|
+
.selectedIcon(new URL(jo.getString(POI_CATEGORY_ICON_SELECTED)))
|
|
508
|
+
.unselectedIcon(new URL(jo.getString(POI_CATEGORY_ICON_UNSELECTED)))
|
|
509
|
+
.build();
|
|
510
|
+
return category;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// Location
|
|
514
|
+
|
|
515
|
+
static JSONObject locationToJsonObject(Location location) throws JSONException {
|
|
516
|
+
JSONObject jo = new JSONObject();
|
|
517
|
+
jo.put(ACCURACY, location.getAccuracy());
|
|
518
|
+
jo.put(BEARING, angleToJsonObject(location.getBearing()));
|
|
519
|
+
jo.put(BEARING_QUALITY, location.getBearingQuality().toString());
|
|
520
|
+
jo.put(BUILDING_IDENTIFIER, location.getBuildingIdentifier());
|
|
521
|
+
jo.put(CARTESIAN_BEARING, angleToJsonObject(location.getCartesianBearing()));
|
|
522
|
+
jo.put(CARTESIAN_COORDINATE, cartesianCoordinateToJsonObject(location.getCartesianCoordinate()));
|
|
523
|
+
jo.put(COORDINATE, coordinateToJsonObject(location.getCoordinate()));
|
|
524
|
+
jo.put(FLOOR_IDENTIFIER, location.getFloorIdentifier());
|
|
525
|
+
jo.put(POSITION, pointToJsonObject(location.getPosition()));
|
|
526
|
+
jo.put(PROVIDER, location.getProvider());
|
|
527
|
+
jo.put(QUALITY, location.getQuality().toString());
|
|
528
|
+
jo.put(HAS_BEARING, location.hasBearing());
|
|
529
|
+
jo.put(TIMESTAMP, location.getTime());
|
|
530
|
+
jo.put(HAS_CARTESIAN_BEARING, location.hasCartesianBearing());
|
|
531
|
+
jo.put(IS_INDOOR, location.isIndoor());
|
|
532
|
+
jo.put(IS_OUTDOOR, location.isOutdoor());
|
|
533
|
+
jo.put(DEVICE_ID, location.getDeviceId());
|
|
534
|
+
return jo;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
static JSONObject locationStatusToJsonObject(LocationStatus locationStatus) throws JSONException {
|
|
538
|
+
JSONObject jo = new JSONObject();
|
|
539
|
+
jo.put(STATUS_NAME, locationStatus.name());
|
|
540
|
+
jo.put(STATUS_ORDINAL, locationStatus.ordinal());
|
|
541
|
+
return jo;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
static Point jsonPointToPoint(JSONObject jo) throws JSONException {
|
|
545
|
+
Point point = null;
|
|
546
|
+
|
|
547
|
+
Coordinate coordinate = coordinateJsonObjectToCoordinate(jo.getJSONObject(COORDINATE));
|
|
548
|
+
String buildingIdentifier = jo.getString(BUILDING_IDENTIFIER);
|
|
549
|
+
|
|
550
|
+
if (jo.getBoolean(IS_INDOOR) == true) {
|
|
551
|
+
point = new Point(buildingIdentifier, jo.getString(FLOOR_IDENTIFIER), coordinate,
|
|
552
|
+
cartesianCoordinateJsonObjectToCartesianCoordinate(jo.getJSONObject(CARTESIAN_COORDINATE)));
|
|
553
|
+
} else {
|
|
554
|
+
point = new Point(buildingIdentifier, coordinate);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
return point;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
static Location jsonLocationObjectToLocation(JSONObject jo) throws JSONException {
|
|
561
|
+
Location.Builder builder = new Location.Builder(jo.getLong(TIMESTAMP), jo.getString(PROVIDER),
|
|
562
|
+
jsonPointToPoint(jo.getJSONObject(POSITION)), (float) jo.getDouble(ACCURACY));
|
|
563
|
+
builder.deviceId(jo.getString(DEVICE_ID));
|
|
564
|
+
|
|
565
|
+
// Check if is indoor (insert cartesian bearing and other properties)
|
|
566
|
+
Angle bearingAngle = angleJSONObjectToAngle(jo.getJSONObject(BEARING));
|
|
567
|
+
Quality bearingQuality = qualityJSONObjectToQuality(jo.getString(BEARING_QUALITY));
|
|
568
|
+
|
|
569
|
+
if (jo.getBoolean(IS_INDOOR) == true) {
|
|
570
|
+
// Insert cartesian properties
|
|
571
|
+
builder.cartesianBearing(angleJSONObjectToAngle(jo.getJSONObject(CARTESIAN_BEARING)), bearingAngle,
|
|
572
|
+
bearingQuality);
|
|
573
|
+
} else {
|
|
574
|
+
builder.bearing(bearingAngle);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
builder.quality(qualityJSONObjectToQuality(jo.getString(QUALITY)));
|
|
578
|
+
|
|
579
|
+
return builder.build(); // Complete this
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
static Quality qualityJSONObjectToQuality(String quality) throws JSONException {
|
|
583
|
+
return (quality.equals("HIGH")) ? Quality.HIGH : Quality.LOW;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
static Angle angleJSONObjectToAngle(JSONObject jo) throws JSONException {
|
|
587
|
+
return Angle.fromDegrees(jo.getDouble(DEGREES));
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// Coordinate
|
|
591
|
+
|
|
592
|
+
static JSONObject coordinateToJsonObject(Coordinate coordinate) throws JSONException {
|
|
593
|
+
JSONObject jo = new JSONObject();
|
|
594
|
+
jo.put(LATITUDE, coordinate.getLatitude());
|
|
595
|
+
jo.put(LONGITUDE, coordinate.getLongitude());
|
|
596
|
+
return jo;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
static Coordinate coordinateJsonObjectToCoordinate(JSONObject jo) throws JSONException {
|
|
600
|
+
Coordinate coordinate = null;
|
|
601
|
+
coordinate = new Coordinate(jo.getDouble(LATITUDE), jo.getDouble(LONGITUDE));
|
|
602
|
+
return coordinate;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// Point
|
|
606
|
+
|
|
607
|
+
static JSONObject pointToJsonObject(Point point) throws JSONException {
|
|
608
|
+
JSONObject jo = new JSONObject();
|
|
609
|
+
jo.put(BUILDING_IDENTIFIER, point.getBuildingIdentifier());
|
|
610
|
+
jo.put(CARTESIAN_COORDINATE, cartesianCoordinateToJsonObject(point.getCartesianCoordinate()));
|
|
611
|
+
jo.put(COORDINATE, coordinateToJsonObject(point.getCoordinate()));
|
|
612
|
+
jo.put(FLOOR_IDENTIFIER, point.getFloorIdentifier());
|
|
613
|
+
jo.put(IS_INDOOR, point.isIndoor());
|
|
614
|
+
jo.put(IS_OUTDOOR, point.isOutdoor());
|
|
615
|
+
return jo;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
static Point pointJsonObjectToPoint(JSONObject jo, JSONObject joBuilding) throws JSONException, ParseException {
|
|
619
|
+
Building building = null;
|
|
620
|
+
Point point = null;
|
|
621
|
+
|
|
622
|
+
if (!jo.has(COORDINATE)) {
|
|
623
|
+
building = buildingJsonObjectToBuilding(joBuilding);
|
|
624
|
+
JSONObject joCartesianCoordinate = jo.getJSONObject(CARTESIAN_COORDINATE);
|
|
625
|
+
CartesianCoordinate cartesianCoordinate = cartesianCoordinateJsonObjectToCartesianCoordinate(
|
|
626
|
+
joCartesianCoordinate);
|
|
627
|
+
CoordinateConverter coordinateConverter = new CoordinateConverter(building.getDimensions(), building.getCenter(),
|
|
628
|
+
building.getRotation());
|
|
629
|
+
Coordinate coordinate = coordinateConverter.toCoordinate(cartesianCoordinate);
|
|
630
|
+
JSONObject joCoordinate = coordinateToJsonObject(coordinate);
|
|
631
|
+
jo.put(COORDINATE, joCoordinate);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
point = new Point(jo.getString(BUILDING_IDENTIFIER), jo.getString(FLOOR_IDENTIFIER),
|
|
635
|
+
coordinateJsonObjectToCoordinate(jo.getJSONObject(COORDINATE)),
|
|
636
|
+
cartesianCoordinateJsonObjectToCartesianCoordinate(jo.getJSONObject(CARTESIAN_COORDINATE)));
|
|
637
|
+
return point;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// CartesianCoordinate
|
|
641
|
+
|
|
642
|
+
static JSONObject cartesianCoordinateToJsonObject(CartesianCoordinate cartesianCoordinate) throws JSONException {
|
|
643
|
+
JSONObject jo = new JSONObject();
|
|
644
|
+
jo.put(X, cartesianCoordinate.getX());
|
|
645
|
+
jo.put(Y, cartesianCoordinate.getY());
|
|
646
|
+
return jo;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
static CartesianCoordinate cartesianCoordinateJsonObjectToCartesianCoordinate(JSONObject jo) throws JSONException {
|
|
650
|
+
CartesianCoordinate cartesianCoordinate = null;
|
|
651
|
+
cartesianCoordinate = new CartesianCoordinate(jo.getDouble(X), jo.getDouble(Y));
|
|
652
|
+
return cartesianCoordinate;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
// Dimensions
|
|
656
|
+
|
|
657
|
+
static JSONObject dimensionsToJsonObject(Dimensions dimensions) throws JSONException {
|
|
658
|
+
JSONObject jo = new JSONObject();
|
|
659
|
+
jo.put(WIDTH, dimensions.getWidth());
|
|
660
|
+
jo.put(HEIGHT, dimensions.getHeight());
|
|
661
|
+
return jo;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// Bounds
|
|
665
|
+
|
|
666
|
+
static JSONObject boundsToJsonObject(Bounds bounds) throws JSONException {
|
|
667
|
+
JSONObject jo = new JSONObject();
|
|
668
|
+
jo.put(NORTH_EAST, coordinateToJsonObject(bounds.getNorthEast()));
|
|
669
|
+
jo.put(NORTH_WEST, coordinateToJsonObject(bounds.getNorthWest()));
|
|
670
|
+
jo.put(SOUTH_EAST, coordinateToJsonObject(bounds.getSouthEast()));
|
|
671
|
+
jo.put(SOUTH_WEST, coordinateToJsonObject(bounds.getSouthWest()));
|
|
672
|
+
return jo;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// Angle
|
|
676
|
+
|
|
677
|
+
static JSONObject angleToJsonObject(Angle angle) throws JSONException {
|
|
678
|
+
JSONObject jo = new JSONObject();
|
|
679
|
+
jo.put(DEGREES, angle.degrees());
|
|
680
|
+
jo.put(DEGREES_CLOCKWISE, angle.degreesClockwise());
|
|
681
|
+
jo.put(RADIANS, angle.radians());
|
|
682
|
+
jo.put(RADIANS_MINUS_PI_PI, angle.radiansMinusPiPi());
|
|
683
|
+
return jo;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
// Route
|
|
687
|
+
|
|
688
|
+
static JSONObject routeToJsonObject(Route route) throws JSONException {
|
|
689
|
+
return routeToJsonObject(route, null);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
static JSONObject routeToJsonObject(Route route, Context context) throws JSONException {
|
|
693
|
+
return new JSONObject(route.toMap());
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// Indication
|
|
697
|
+
|
|
698
|
+
static Indication indicationJsonObjectToIndication(JSONObject jo) throws JSONException {
|
|
699
|
+
Indication indication = null;
|
|
700
|
+
indication = new Indication.Builder().setDistance(jo.getDouble(DISTANCE))
|
|
701
|
+
.setDistanceToNextLevel(jo.getInt(DISTANCE_TO_NEXT_LEVEL))
|
|
702
|
+
.setInstructionType(Indication.Action.valueOf(jo.getString(INDICATION_TYPE)))
|
|
703
|
+
.setOrientation(jo.getDouble(ORIENTATION))
|
|
704
|
+
.setOrientationType(Indication.Orientation.valueOf(jo.getString(ORIENTATION_TYPE)))
|
|
705
|
+
.setStepIdxDestination(jo.getInt(STEP_IDX_DESTINATION)).setStepIdxOrigin(jo.getInt(STEP_IDX_ORIGIN))
|
|
706
|
+
.setNextLevel(jo.getInt(NEXT_LEVEL)).build();
|
|
707
|
+
return indication;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// NavigationProgress
|
|
711
|
+
|
|
712
|
+
static JSONObject navigationProgressToJsonObject(NavigationProgress navigationProgress) throws JSONException {
|
|
713
|
+
return navigationProgressToJsonObject(navigationProgress, null);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
static JSONObject navigationProgressToJsonObject(NavigationProgress navigationProgress, Context context)
|
|
717
|
+
throws JSONException {
|
|
718
|
+
return new JSONObject(navigationProgress.toMap());
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// Utils
|
|
722
|
+
|
|
723
|
+
static JSONObject bitmapToString(Bitmap bitmap) throws JSONException {
|
|
724
|
+
JSONObject jo = new JSONObject();
|
|
725
|
+
String encodedImage;
|
|
726
|
+
ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
|
|
727
|
+
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOS);
|
|
728
|
+
encodedImage = Base64.encodeToString(byteArrayOS.toByteArray(), Base64.DEFAULT);
|
|
729
|
+
jo.put("data", encodedImage);
|
|
730
|
+
return jo;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
static RealTimeRequest jsonObjectRealtimeRequest(JSONObject object) throws JSONException, ParseException {
|
|
734
|
+
RealTimeRequest.Builder builder = new RealTimeRequest.Builder();
|
|
735
|
+
|
|
736
|
+
if (object.has(BUILDING)) {
|
|
737
|
+
builder.building(buildingJsonObjectToBuilding(object.getJSONObject(BUILDING)));
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
if (object.has(POLL_TIME)) {
|
|
741
|
+
Integer poll_interval = object.getInt(SitumMapper.POLL_TIME);
|
|
742
|
+
|
|
743
|
+
if (poll_interval != null) {
|
|
744
|
+
builder.pollTimeMs(poll_interval);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return builder.build();
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
static LocationRequest locationRequestJSONObjectToLocationRequest(JSONArray args) throws JSONException {
|
|
751
|
+
LocationRequest.Builder locationBuilder = new LocationRequest.Builder();
|
|
752
|
+
|
|
753
|
+
// Remote configuration, no params
|
|
754
|
+
if (args.length() == 0) {
|
|
755
|
+
return locationBuilder.build();
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
JSONObject jsonoBuilding = args.getJSONObject(0);
|
|
759
|
+
String sBuildingId;
|
|
760
|
+
if (jsonoBuilding.get(SitumMapper.BUILDING_IDENTIFIER) instanceof String) {
|
|
761
|
+
sBuildingId = jsonoBuilding.getString(SitumMapper.BUILDING_IDENTIFIER);
|
|
762
|
+
} else {
|
|
763
|
+
sBuildingId = String.format(Locale.getDefault(), "%d", jsonoBuilding.getInt(SitumMapper.BUILDING_IDENTIFIER));
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if (args.length() > 1) {
|
|
767
|
+
JSONObject request = args.getJSONObject(1);
|
|
768
|
+
if (request.has(SitumMapper.BUILDING_IDENTIFIER)) {
|
|
769
|
+
String buildingIdentifier;
|
|
770
|
+
if (request.get(SitumMapper.BUILDING_IDENTIFIER) instanceof String) {
|
|
771
|
+
buildingIdentifier = request.getString(SitumMapper.BUILDING_IDENTIFIER);
|
|
772
|
+
} else {
|
|
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
|
+
}
|
|
787
|
+
|
|
788
|
+
if (request.has(SitumMapper.INDOOR_PROVIDER)) {
|
|
789
|
+
String indoorProvider = request.getString(SitumMapper.INDOOR_PROVIDER);
|
|
790
|
+
if (indoorProvider != null && !indoorProvider.isEmpty()) {
|
|
791
|
+
if (indoorProvider.equals(LocationRequest.IndoorProvider.SUPPORT.name())) {
|
|
792
|
+
locationBuilder.indoorProvider(LocationRequest.IndoorProvider.SUPPORT);
|
|
793
|
+
} else {
|
|
794
|
+
locationBuilder.indoorProvider(LocationRequest.IndoorProvider.INPHONE);
|
|
795
|
+
}
|
|
796
|
+
Log.i(TAG, "indoorProvider: " + indoorProvider);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
if (request.has(SitumMapper.USE_BLE)) {
|
|
801
|
+
Boolean useBle = request.getBoolean(SitumMapper.USE_BLE);
|
|
802
|
+
locationBuilder.useBle(useBle);
|
|
803
|
+
Log.i(TAG, "useBle: " + useBle);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
if (request.has(SitumMapper.USE_WIFI)) {
|
|
807
|
+
Boolean useWifi = request.getBoolean(SitumMapper.USE_WIFI);
|
|
808
|
+
locationBuilder.useWifi(useWifi);
|
|
809
|
+
Log.i(TAG, "useWifi: " + useWifi);
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
if (request.has(SitumMapper.USE_GPS)) {
|
|
813
|
+
Boolean useGps = request.getBoolean(SitumMapper.USE_GPS);
|
|
814
|
+
locationBuilder.useGps(useGps);
|
|
815
|
+
Log.i(TAG, "useGps: " + useGps);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
if (request.has(SitumMapper.USE_BAROMETER)) {
|
|
819
|
+
Boolean useBarometer = request.getBoolean(SitumMapper.USE_BAROMETER);
|
|
820
|
+
locationBuilder.useBarometer(useBarometer);
|
|
821
|
+
Log.i(TAG, "useBarometer: " + useBarometer);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
if (request.has(SitumMapper.AUTO_ENABLE_BLE)) {
|
|
825
|
+
Boolean autoEnableBleDuringPositioning = request.getBoolean(SitumMapper.AUTO_ENABLE_BLE);
|
|
826
|
+
locationBuilder.autoEnableBleDuringPositioning(autoEnableBleDuringPositioning);
|
|
827
|
+
Log.i(TAG, "autoEnableBleDuringPositioning: " + autoEnableBleDuringPositioning);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
if (request.has(SitumMapper.MOTION_MODE)) {
|
|
831
|
+
String motionMode = request.getString(SitumMapper.MOTION_MODE);
|
|
832
|
+
if (motionMode != null) {
|
|
833
|
+
if (motionMode.equals(LocationRequest.MotionMode.BY_FOOT.name())) {
|
|
834
|
+
locationBuilder.motionMode(LocationRequest.MotionMode.BY_FOOT);
|
|
835
|
+
} else if (motionMode.equals(LocationRequest.MotionMode.BY_CAR.name())) {
|
|
836
|
+
locationBuilder.motionMode(LocationRequest.MotionMode.BY_CAR);
|
|
837
|
+
}
|
|
838
|
+
Log.i(TAG, "motionMode: " + motionMode);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
if (request.has(SitumMapper.USE_FOREGROUND_SERVICE)) {
|
|
843
|
+
Boolean useForegroundService = request.getBoolean(SitumMapper.USE_FOREGROUND_SERVICE);
|
|
844
|
+
locationBuilder.useForegroundService(useForegroundService);
|
|
845
|
+
Log.i(TAG, "useForegroundService: " + useForegroundService);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
if (request.has(SitumMapper.USE_DEAD_RECKONING)) {
|
|
849
|
+
Boolean useDeadReckoning = request.getBoolean(SitumMapper.USE_DEAD_RECKONING);
|
|
850
|
+
locationBuilder.useDeadReckoning(useDeadReckoning);
|
|
851
|
+
Log.i(TAG, "useDeadReckoning: " + useDeadReckoning);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
if (request.has(SitumMapper.OUTDOOR_LOCATION_OPTIONS)) {
|
|
855
|
+
JSONObject outdoorLocationOptions = request.getJSONObject(SitumMapper.OUTDOOR_LOCATION_OPTIONS);
|
|
856
|
+
if (outdoorLocationOptions != null) {
|
|
857
|
+
locationBuilder.outdoorLocationOptions(buildOutdoorLocationOptions(outdoorLocationOptions));
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
if (request.has(SitumMapper.BEACON_FILTERS)) {
|
|
862
|
+
JSONArray beaconFilters = request.getJSONArray(SitumMapper.BEACON_FILTERS);
|
|
863
|
+
List<BeaconFilter> filtersList = new ArrayList<BeaconFilter>();
|
|
864
|
+
for (int i = 0; i < beaconFilters.length(); i++) {
|
|
865
|
+
JSONObject beaconFilter = beaconFilters.getJSONObject(i);
|
|
866
|
+
if (beaconFilter.has(SitumMapper.UUID)) {
|
|
867
|
+
String uuid = beaconFilter.getString(SitumMapper.UUID);
|
|
868
|
+
if (uuid != null && !uuid.isEmpty()) {
|
|
869
|
+
BeaconFilter.Builder builder = new BeaconFilter.Builder().uuid(uuid);
|
|
870
|
+
filtersList.add(builder.build());
|
|
871
|
+
Log.i(TAG, "beaconFilter: " + uuid);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
locationBuilder.addBeaconFilters(filtersList);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
if (request.has(SitumMapper.SMALLEST_DISPLACEMENT)) {
|
|
880
|
+
Float smallestDisplacement = new Float(request.getDouble(SitumMapper.SMALLEST_DISPLACEMENT));
|
|
881
|
+
if (smallestDisplacement != null && smallestDisplacement > 0) {
|
|
882
|
+
locationBuilder.smallestDisplacement(smallestDisplacement);
|
|
883
|
+
Log.i(TAG, "smallestDisplacement: " + smallestDisplacement);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
if (request.has(SitumMapper.REALTIME_UPDATE_INTERVAL) &&
|
|
888
|
+
request.get(SitumMapper.REALTIME_UPDATE_INTERVAL) instanceof String) {
|
|
889
|
+
String realtimeUpdateInterval = request.getString(SitumMapper.REALTIME_UPDATE_INTERVAL);
|
|
890
|
+
if (realtimeUpdateInterval != null) {
|
|
891
|
+
if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.REALTIME.name())) {
|
|
892
|
+
locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.REALTIME);
|
|
893
|
+
} else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.FAST.name())) {
|
|
894
|
+
locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.FAST);
|
|
895
|
+
} else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.NORMAL.name())) {
|
|
896
|
+
locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.NORMAL);
|
|
897
|
+
} else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.SLOW.name())) {
|
|
898
|
+
locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.SLOW);
|
|
899
|
+
} else if (realtimeUpdateInterval.equals(LocationRequest.RealtimeUpdateInterval.BATTERY_SAVER.name())) {
|
|
900
|
+
locationBuilder.realtimeUpdateInterval(LocationRequest.RealtimeUpdateInterval.BATTERY_SAVER);
|
|
901
|
+
}
|
|
902
|
+
Log.i(TAG, "realtimeUpdateInterval: " + realtimeUpdateInterval);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
} else {
|
|
906
|
+
locationBuilder.buildingIdentifier(sBuildingId);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
return locationBuilder.build();
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
static OutdoorLocationOptions buildOutdoorLocationOptions(JSONObject outdoorLocationOptions) throws JSONException{
|
|
913
|
+
OutdoorLocationOptions.Builder optionsBuilder = new OutdoorLocationOptions.Builder();
|
|
914
|
+
|
|
915
|
+
if (outdoorLocationOptions.has(SitumMapper.USER_DEFINED_THRESHOLD)) {
|
|
916
|
+
Boolean userDefinedThreshold = outdoorLocationOptions.getBoolean(SitumMapper.USER_DEFINED_THRESHOLD);
|
|
917
|
+
optionsBuilder.userDefinedThreshold(userDefinedThreshold);
|
|
918
|
+
Log.i(TAG, "userDefinedThreshold: " + userDefinedThreshold);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
if (outdoorLocationOptions.has(SitumMapper.COMPUTE_INTERVAL)) {
|
|
922
|
+
Integer computeInterval = outdoorLocationOptions.getInt(SitumMapper.COMPUTE_INTERVAL);
|
|
923
|
+
if (computeInterval != null && computeInterval >= 1) {
|
|
924
|
+
optionsBuilder.computeInterval(computeInterval);
|
|
925
|
+
Log.i(TAG, "computeInterval: " + computeInterval);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
if (outdoorLocationOptions.has(SitumMapper.AVERAGE_SNR_THRESHOLD));
|
|
930
|
+
Float averageSnrThreshold = new Float(outdoorLocationOptions.getDouble(SitumMapper.AVERAGE_SNR_THRESHOLD));
|
|
931
|
+
if (averageSnrThreshold != null && averageSnrThreshold >= MIN_SNR && averageSnrThreshold <= MAX_SNR) {
|
|
932
|
+
optionsBuilder.averageSnrThreshold(averageSnrThreshold);
|
|
933
|
+
Log.i(TAG, "averageSnrThreshold: " + averageSnrThreshold);
|
|
934
|
+
}
|
|
935
|
+
return optionsBuilder.build();
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
static DirectionsRequest jsonObjectToDirectionsRequest(JSONObject joBuilding, JSONObject joFrom,
|
|
939
|
+
JSONObject joTo, JSONObject joOptions) throws JSONException, ParseException {
|
|
940
|
+
Point from = SitumMapper.pointJsonObjectToPoint(joFrom, joBuilding);
|
|
941
|
+
Point to = SitumMapper.pointJsonObjectToPoint(joTo, joBuilding);
|
|
942
|
+
DirectionsRequest.AccessibilityMode accessibilityMode = DirectionsRequest.AccessibilityMode.CHOOSE_SHORTEST;
|
|
943
|
+
Boolean minimizeFloorChanges = false;
|
|
944
|
+
double startingAngle = 0.0;
|
|
945
|
+
|
|
946
|
+
if ( joOptions != null) {
|
|
947
|
+
if (joOptions.has(SitumMapper.ACCESSIBILITY_MODE)) {
|
|
948
|
+
String mode = joOptions.getString(SitumMapper.ACCESSIBILITY_MODE);
|
|
949
|
+
if (mode.equals(DirectionsRequest.AccessibilityMode.ONLY_ACCESSIBLE.name())) {
|
|
950
|
+
accessibilityMode = DirectionsRequest.AccessibilityMode.ONLY_ACCESSIBLE;
|
|
951
|
+
} else if (mode.equals(DirectionsRequest.AccessibilityMode.ONLY_NOT_ACCESSIBLE_FLOOR_CHANGES.name())) {
|
|
952
|
+
accessibilityMode = DirectionsRequest.AccessibilityMode.ONLY_NOT_ACCESSIBLE_FLOOR_CHANGES;
|
|
953
|
+
}
|
|
954
|
+
} else if (joOptions.has(SitumMapper.ACCESSIBLE) && joOptions.getBoolean(SitumMapper.ACCESSIBLE)) {
|
|
955
|
+
accessibilityMode = DirectionsRequest.AccessibilityMode.ONLY_ACCESSIBLE;
|
|
956
|
+
} else if (joOptions.has(SitumMapper.ACCESSIBLE_ROUTE) && joOptions.getBoolean(SitumMapper.ACCESSIBLE_ROUTE)) {
|
|
957
|
+
accessibilityMode = DirectionsRequest.AccessibilityMode.ONLY_ACCESSIBLE;
|
|
958
|
+
}
|
|
959
|
+
if (joOptions.has(SitumMapper.STARTING_ANGLE)) {
|
|
960
|
+
startingAngle = joOptions.getDouble(SitumMapper.STARTING_ANGLE);
|
|
961
|
+
}
|
|
962
|
+
if (joOptions.has(SitumMapper.MINIMIZE_FLOOR_CHANGES)) {
|
|
963
|
+
minimizeFloorChanges = joOptions.getBoolean(SitumMapper.MINIMIZE_FLOOR_CHANGES);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
return new DirectionsRequest.Builder().from(from, Angle.fromDegrees(startingAngle)).to(to).accessibilityMode(accessibilityMode).minimizeFloorChanges(minimizeFloorChanges).build();
|
|
967
|
+
}
|
|
968
|
+
}
|