@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.
Files changed (313) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/CHANGELOG_UNRELEASED.md +28 -0
  3. package/Jenkinsfile +84 -0
  4. package/LICENSE +21 -0
  5. package/README.md +472 -0
  6. package/azure/common-steps.yaml +5 -0
  7. package/azure-pipelines.yml +336 -0
  8. package/docs/JSDoc/MapView.html +300 -0
  9. package/docs/JSDoc/MapViewControllerImpl.html +299 -0
  10. package/docs/JSDoc/Situm.html +5257 -0
  11. package/docs/JSDoc/android_Interfaces.js.html +825 -0
  12. package/docs/JSDoc/android_situm.js.html +380 -0
  13. package/docs/JSDoc/fonts/glyphicons-halflings-regular.eot +0 -0
  14. package/docs/JSDoc/fonts/glyphicons-halflings-regular.svg +288 -0
  15. package/docs/JSDoc/fonts/glyphicons-halflings-regular.ttf +0 -0
  16. package/docs/JSDoc/fonts/glyphicons-halflings-regular.woff +0 -0
  17. package/docs/JSDoc/fonts/glyphicons-halflings-regular.woff2 +0 -0
  18. package/docs/JSDoc/global.html +7538 -0
  19. package/docs/JSDoc/img/toast-ui.png +0 -0
  20. package/docs/JSDoc/index.html +90 -0
  21. package/docs/JSDoc/map-view-controller.js.html +307 -0
  22. package/docs/JSDoc/map-view.js.html +172 -0
  23. package/docs/JSDoc/scripts/jquery.min.js +2 -0
  24. package/docs/JSDoc/scripts/linenumber.js +30 -0
  25. package/docs/JSDoc/scripts/prettify/Apache-License-2.0.txt +202 -0
  26. package/docs/JSDoc/scripts/prettify/lang-css.js +2 -0
  27. package/docs/JSDoc/scripts/prettify/prettify.js +28 -0
  28. package/docs/JSDoc/scripts/tui-doc.js +200 -0
  29. package/docs/JSDoc/styles/bootstrap.min.css +6 -0
  30. package/docs/JSDoc/styles/custom.css +23 -0
  31. package/docs/JSDoc/styles/prettify-jsdoc.css +111 -0
  32. package/docs/JSDoc/styles/prettify-tomorrow.css +132 -0
  33. package/docs/JSDoc/styles/tui-doc.css +485 -0
  34. package/docs/conf.json +28 -0
  35. package/docs/getting-started.md +298 -0
  36. package/docs/imagotype-SITUM-transparent-90.png +0 -0
  37. package/docs/static/styles/custom.css +23 -0
  38. package/package.json +60 -0
  39. package/plugin.xml +102 -0
  40. package/scripts/update_changelog.sh +22 -0
  41. package/src/android/app/build.gradle +51 -0
  42. package/src/android/app/proguard-rules.pro +21 -0
  43. package/src/android/app/src/main/AndroidManifest.xml +11 -0
  44. package/src/android/app/src/main/java/es/situm/plugin/DateUtils.java +15 -0
  45. package/src/android/app/src/main/java/es/situm/plugin/PluginHelper.java +919 -0
  46. package/src/android/app/src/main/java/es/situm/plugin/SitumMapper.java +968 -0
  47. package/src/android/app/src/main/java/es/situm/plugin/SitumPlugin.java +109 -0
  48. package/src/android/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
  49. package/src/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
  50. package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
  51. package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
  52. package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  53. package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  54. package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  55. package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  56. package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  57. package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  58. package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  59. package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  60. package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  61. package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  62. package/src/android/app/src/main/res/values/colors.xml +6 -0
  63. package/src/android/app/src/main/res/values/strings.xml +3 -0
  64. package/src/android/app/src/main/res/values/styles.xml +11 -0
  65. package/src/android/app/src/test/java/es/situm/plugin/PluginHelperTest.java +27 -0
  66. package/src/android/app/src/test/java/es/situm/plugin/SitumMapperTest.java +1485 -0
  67. package/src/android/app/src/test/java/es/situm/plugin/angle/AngleCreator.java +46 -0
  68. package/src/android/app/src/test/java/es/situm/plugin/bounds/BoundsCreator.java +50 -0
  69. package/src/android/app/src/test/java/es/situm/plugin/building/BuildingCreator.java +76 -0
  70. package/src/android/app/src/test/java/es/situm/plugin/cartesianCoordinate/CartesianCoordinateCreator.java +31 -0
  71. package/src/android/app/src/test/java/es/situm/plugin/circle/CircleCreator.java +41 -0
  72. package/src/android/app/src/test/java/es/situm/plugin/coordinate/CoordinateCreator.java +32 -0
  73. package/src/android/app/src/test/java/es/situm/plugin/dimensions/DimensionsCreator.java +31 -0
  74. package/src/android/app/src/test/java/es/situm/plugin/directionsRequest/DirectionsRequestCreator.java +105 -0
  75. package/src/android/app/src/test/java/es/situm/plugin/event/EventCreator.java +108 -0
  76. package/src/android/app/src/test/java/es/situm/plugin/floor/FloorCreator.java +58 -0
  77. package/src/android/app/src/test/java/es/situm/plugin/indication/IndicationCreator.java +40 -0
  78. package/src/android/app/src/test/java/es/situm/plugin/location/LocationCreator.java +197 -0
  79. package/src/android/app/src/test/java/es/situm/plugin/locationRequest/LocationRequestCreator.java +45 -0
  80. package/src/android/app/src/test/java/es/situm/plugin/locationStatus/LocationStatusCreator.java +211 -0
  81. package/src/android/app/src/test/java/es/situm/plugin/navigationProgress/NavigationProgressCreator.java +154 -0
  82. package/src/android/app/src/test/java/es/situm/plugin/poi/PoiCreator.java +126 -0
  83. package/src/android/app/src/test/java/es/situm/plugin/poiCategory/PoiCategoryCreator.java +38 -0
  84. package/src/android/app/src/test/java/es/situm/plugin/point/PointCreator.java +200 -0
  85. package/src/android/app/src/test/java/es/situm/plugin/route/RouteCreator.java +142 -0
  86. package/src/android/app/src/test/java/es/situm/plugin/routeStep/RouteStepCreator.java +173 -0
  87. package/src/android/app/src/test/java/es/situm/plugin/situmConversionArea/SitumConversionAreaCreator.java +35 -0
  88. package/src/android/build.gradle +31 -0
  89. package/src/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  90. package/src/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  91. package/src/android/gradle.properties +16 -0
  92. package/src/android/gradlew +172 -0
  93. package/src/android/gradlew.bat +84 -0
  94. package/src/android/settings.gradle +3 -0
  95. package/src/android/situm.gradle +19 -0
  96. package/src/ios/Classes/Private/CDVDebug.h +25 -0
  97. package/src/ios/Classes/Private/CDVJSON_private.h +31 -0
  98. package/src/ios/Classes/Private/CDVJSON_private.m +99 -0
  99. package/src/ios/Classes/Private/CDVPlugin+Private.h +24 -0
  100. package/src/ios/Classes/Private/CDVPlugins/CDVGestureHandler/CDVGestureHandler.h +26 -0
  101. package/src/ios/Classes/Private/CDVPlugins/CDVGestureHandler/CDVGestureHandler.m +70 -0
  102. package/src/ios/Classes/Private/CDVPlugins/CDVHandleOpenURL/CDVHandleOpenURL.h +27 -0
  103. package/src/ios/Classes/Private/CDVPlugins/CDVHandleOpenURL/CDVHandleOpenURL.m +86 -0
  104. package/src/ios/Classes/Private/CDVPlugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.h +34 -0
  105. package/src/ios/Classes/Private/CDVPlugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.m +153 -0
  106. package/src/ios/Classes/Private/CDVPlugins/CDVLocalStorage/CDVLocalStorage.h +50 -0
  107. package/src/ios/Classes/Private/CDVPlugins/CDVLocalStorage/CDVLocalStorage.m +487 -0
  108. package/src/ios/Classes/Private/CDVPlugins/CDVLogger/CDVLogger.h +26 -0
  109. package/src/ios/Classes/Private/CDVPlugins/CDVLogger/CDVLogger.m +37 -0
  110. package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.h +41 -0
  111. package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m +399 -0
  112. package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewEngine.h +27 -0
  113. package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m +202 -0
  114. package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.h +29 -0
  115. package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m +153 -0
  116. package/src/ios/Classes/Public/CDV.h +32 -0
  117. package/src/ios/Classes/Public/CDVAppDelegate.h +28 -0
  118. package/src/ios/Classes/Public/CDVAppDelegate.m +118 -0
  119. package/src/ios/Classes/Public/CDVAvailability.h +111 -0
  120. package/src/ios/Classes/Public/CDVAvailabilityDeprecated.h +26 -0
  121. package/src/ios/Classes/Public/CDVCommandDelegate.h +51 -0
  122. package/src/ios/Classes/Public/CDVCommandDelegateImpl.h +36 -0
  123. package/src/ios/Classes/Public/CDVCommandDelegateImpl.m +186 -0
  124. package/src/ios/Classes/Public/CDVCommandQueue.h +39 -0
  125. package/src/ios/Classes/Public/CDVCommandQueue.m +194 -0
  126. package/src/ios/Classes/Public/CDVConfigParser.h +30 -0
  127. package/src/ios/Classes/Public/CDVConfigParser.m +81 -0
  128. package/src/ios/Classes/Public/CDVInvokedUrlCommand.h +52 -0
  129. package/src/ios/Classes/Public/CDVInvokedUrlCommand.m +116 -0
  130. package/src/ios/Classes/Public/CDVPlugin+Resources.h +39 -0
  131. package/src/ios/Classes/Public/CDVPlugin+Resources.m +38 -0
  132. package/src/ios/Classes/Public/CDVPlugin.h +85 -0
  133. package/src/ios/Classes/Public/CDVPlugin.m +202 -0
  134. package/src/ios/Classes/Public/CDVPluginResult.h +66 -0
  135. package/src/ios/Classes/Public/CDVPluginResult.m +186 -0
  136. package/src/ios/Classes/Public/CDVScreenOrientationDelegate.h +33 -0
  137. package/src/ios/Classes/Public/CDVTimer.h +27 -0
  138. package/src/ios/Classes/Public/CDVTimer.m +123 -0
  139. package/src/ios/Classes/Public/CDVURLProtocol.h +27 -0
  140. package/src/ios/Classes/Public/CDVURLProtocol.m +113 -0
  141. package/src/ios/Classes/Public/CDVUserAgentUtil.h +27 -0
  142. package/src/ios/Classes/Public/CDVUserAgentUtil.m +124 -0
  143. package/src/ios/Classes/Public/CDVViewController.h +92 -0
  144. package/src/ios/Classes/Public/CDVViewController.m +821 -0
  145. package/src/ios/Classes/Public/CDVWebViewEngineProtocol.h +42 -0
  146. package/src/ios/Classes/Public/CDVWhitelist.h +34 -0
  147. package/src/ios/Classes/Public/CDVWhitelist.m +285 -0
  148. package/src/ios/Classes/Public/NSDictionary+CordovaPreferences.h +35 -0
  149. package/src/ios/Classes/Public/NSDictionary+CordovaPreferences.m +63 -0
  150. package/src/ios/Classes/Public/NSMutableArray+QueueAdditions.h +29 -0
  151. package/src/ios/Classes/Public/NSMutableArray+QueueAdditions.m +58 -0
  152. package/src/ios/Cordova/Cordova.h +51 -0
  153. package/src/ios/Cordova/Info.plist +24 -0
  154. package/src/ios/Podfile +5 -0
  155. package/src/ios/SitumCordovaPlugin.xcodeproj/project.pbxproj +1324 -0
  156. package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  157. package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  158. package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
  159. package/src/ios/SitumCordovaPlugin.xcodeproj/xcshareddata/xcschemes/CordovaLib.xcscheme +100 -0
  160. package/src/ios/SitumCordovaPlugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  161. package/src/ios/SitumCordovaPlugin_Prefix.pch +22 -0
  162. package/src/ios/VERSION +1 -0
  163. package/src/ios/cordova.js +2432 -0
  164. package/src/ios/situmcordovaplugin/AppDelegate.h +22 -0
  165. package/src/ios/situmcordovaplugin/AppDelegate.m +98 -0
  166. package/src/ios/situmcordovaplugin/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
  167. package/src/ios/situmcordovaplugin/Base.lproj/LaunchScreen.storyboard +25 -0
  168. package/src/ios/situmcordovaplugin/Base.lproj/Main.storyboard +24 -0
  169. package/src/ios/situmcordovaplugin/Constants.h +14 -0
  170. package/src/ios/situmcordovaplugin/Constants.m +14 -0
  171. package/src/ios/situmcordovaplugin/Info.plist +45 -0
  172. package/src/ios/situmcordovaplugin/SITUtils.h +7 -0
  173. package/src/ios/situmcordovaplugin/SITUtils.m +13 -0
  174. package/src/ios/situmcordovaplugin/SitumLocationWrapper.h +109 -0
  175. package/src/ios/situmcordovaplugin/SitumLocationWrapper.m +983 -0
  176. package/src/ios/situmcordovaplugin/SitumPlugin.h +41 -0
  177. package/src/ios/situmcordovaplugin/SitumPlugin.m +752 -0
  178. package/src/ios/situmcordovaplugin/ViewController.h +15 -0
  179. package/src/ios/situmcordovaplugin/ViewController.m +29 -0
  180. package/src/ios/situmcordovaplugin/main.m +16 -0
  181. package/src/ios/situmcordovaplugin/situmcordovaplugin.xcdatamodeld/.xccurrentversion +8 -0
  182. package/src/ios/situmcordovaplugin/situmcordovaplugin.xcdatamodeld/situmcordovaplugin.xcdatamodel/contents +4 -0
  183. package/src/ios/situmcordovaplugintests/AngleTests.m +53 -0
  184. package/src/ios/situmcordovaplugintests/BoundTests.m +51 -0
  185. package/src/ios/situmcordovaplugintests/BuildingTests.m +41 -0
  186. package/src/ios/situmcordovaplugintests/CartesianCoordinateTests.m +42 -0
  187. package/src/ios/situmcordovaplugintests/ConversionAreaTests.m +43 -0
  188. package/src/ios/situmcordovaplugintests/CoordinateTests.m +42 -0
  189. package/src/ios/situmcordovaplugintests/DimensionTests.m +43 -0
  190. package/src/ios/situmcordovaplugintests/EventTests.m +42 -0
  191. package/src/ios/situmcordovaplugintests/FloorTests.m +52 -0
  192. package/src/ios/situmcordovaplugintests/Info.plist +38 -0
  193. package/src/ios/situmcordovaplugintests/InputTests/DirectionsRequestTest.m +108 -0
  194. package/src/ios/situmcordovaplugintests/InputTests/InputCartesianCoordinateTests.m +45 -0
  195. package/src/ios/situmcordovaplugintests/InputTests/InputCoordinateTests.m +45 -0
  196. package/src/ios/situmcordovaplugintests/InputTests/InputFloorTests.m +59 -0
  197. package/src/ios/situmcordovaplugintests/InputTests/InputIndicationTests.m +45 -0
  198. package/src/ios/situmcordovaplugintests/InputTests/InputLocationTests.m +163 -0
  199. package/src/ios/situmcordovaplugintests/InputTests/InputPoiCategoryTests.m +46 -0
  200. package/src/ios/situmcordovaplugintests/InputTests/InputPointTests.m +137 -0
  201. package/src/ios/situmcordovaplugintests/InputTests/LocationRequestTest.m +79 -0
  202. package/src/ios/situmcordovaplugintests/LocationStatusTests.m +60 -0
  203. package/src/ios/situmcordovaplugintests/LocationTests.m +114 -0
  204. package/src/ios/situmcordovaplugintests/NavigationProgressTests.m +50 -0
  205. package/src/ios/situmcordovaplugintests/PoiCategoryIconTests.m +43 -0
  206. package/src/ios/situmcordovaplugintests/PoiCategoryTests.m +42 -0
  207. package/src/ios/situmcordovaplugintests/PoiTests.m +83 -0
  208. package/src/ios/situmcordovaplugintests/PointTests.m +107 -0
  209. package/src/ios/situmcordovaplugintests/RouteStepTests.m +78 -0
  210. package/src/ios/situmcordovaplugintests/RouteTests.m +42 -0
  211. package/src/ios/situmcordovaplugintests/SitumCreatorTests.h +91 -0
  212. package/src/ios/situmcordovaplugintests/SitumCreatorTests.m +928 -0
  213. package/src/ios/situmcordovaplugintests/TestingHelper.h +48 -0
  214. package/src/ios/situmcordovaplugintests/TestingHelper.m +342 -0
  215. package/src/ios/situmcordovaplugintests/indicationTests.m +43 -0
  216. package/tests/common-resources/angle/angle1.json +6 -0
  217. package/tests/common-resources/angle/angle2.json +6 -0
  218. package/tests/common-resources/bounds/bounds1.json +18 -0
  219. package/tests/common-resources/bounds/bounds2.json +18 -0
  220. package/tests/common-resources/building/building1.json +64 -0
  221. package/tests/common-resources/cartesianCoordinate/cartesianCoordinate1.json +4 -0
  222. package/tests/common-resources/circle/circle1.json +17 -0
  223. package/tests/common-resources/coordinate/coordinate1.json +4 -0
  224. package/tests/common-resources/dimensions/dimensions1.json +4 -0
  225. package/tests/common-resources/directionsRequest/directionsRequest1.json +166 -0
  226. package/tests/common-resources/directionsRequest/directionsRequest2.json +167 -0
  227. package/tests/common-resources/directionsRequest/directionsRequest3.json +166 -0
  228. package/tests/common-resources/directionsRequest/directionsRequest4.json +166 -0
  229. package/tests/common-resources/directionsRequest/directionsRequest5.json +167 -0
  230. package/tests/common-resources/directionsRequest/directionsRequest6.json +153 -0
  231. package/tests/common-resources/events/event1.json +66 -0
  232. package/tests/common-resources/floor/floor1.json +13 -0
  233. package/tests/common-resources/floor/floor2.json +13 -0
  234. package/tests/common-resources/indication/indication1.json +10 -0
  235. package/tests/common-resources/location/location1.json +48 -0
  236. package/tests/common-resources/location/location10.json +48 -0
  237. package/tests/common-resources/location/location2.json +48 -0
  238. package/tests/common-resources/location/location3.json +48 -0
  239. package/tests/common-resources/location/location4.json +48 -0
  240. package/tests/common-resources/location/location5.json +48 -0
  241. package/tests/common-resources/location/location6.json +48 -0
  242. package/tests/common-resources/location/location7.json +48 -0
  243. package/tests/common-resources/location/location8.json +48 -0
  244. package/tests/common-resources/location/location9.json +48 -0
  245. package/tests/common-resources/locationRequest/locationRequest1.json +6 -0
  246. package/tests/common-resources/locationRequest/locationRequest2.json +32 -0
  247. package/tests/common-resources/locationRequest/locationRequest3.json +33 -0
  248. package/tests/common-resources/locationRequest/locationRequest4.json +31 -0
  249. package/tests/common-resources/locationStatus/locationStatus1.json +4 -0
  250. package/tests/common-resources/locationStatus/locationStatus10.json +4 -0
  251. package/tests/common-resources/locationStatus/locationStatus11.json +4 -0
  252. package/tests/common-resources/locationStatus/locationStatus12.json +4 -0
  253. package/tests/common-resources/locationStatus/locationStatus13.json +4 -0
  254. package/tests/common-resources/locationStatus/locationStatus2.json +4 -0
  255. package/tests/common-resources/locationStatus/locationStatus3.json +4 -0
  256. package/tests/common-resources/locationStatus/locationStatus4.json +4 -0
  257. package/tests/common-resources/locationStatus/locationStatus5.json +4 -0
  258. package/tests/common-resources/locationStatus/locationStatus6.json +4 -0
  259. package/tests/common-resources/locationStatus/locationStatus7.json +4 -0
  260. package/tests/common-resources/locationStatus/locationStatus8.json +4 -0
  261. package/tests/common-resources/locationStatus/locationStatus9.json +4 -0
  262. package/tests/common-resources/navigationProgress/navigationProgress1.json +77 -0
  263. package/tests/common-resources/navigationProgress/navigationProgress2.json +77 -0
  264. package/tests/common-resources/poi/poi1.json +35 -0
  265. package/tests/common-resources/poi/poi2.json +35 -0
  266. package/tests/common-resources/poi/poi3.json +35 -0
  267. package/tests/common-resources/poi/poi4.json +38 -0
  268. package/tests/common-resources/poi/poi5.json +35 -0
  269. package/tests/common-resources/poiCategory/poiCategory1.json +7 -0
  270. package/tests/common-resources/poiCategoryIcon/poiCategoryIcon1.json +1 -0
  271. package/tests/common-resources/poiCategoryIcon/poiCategoryIcon1.png +0 -0
  272. package/tests/common-resources/point/point1.json +14 -0
  273. package/tests/common-resources/point/point2.json +14 -0
  274. package/tests/common-resources/point/point3.json +14 -0
  275. package/tests/common-resources/point/point4.json +14 -0
  276. package/tests/common-resources/point/point5.json +14 -0
  277. package/tests/common-resources/point/point6.json +14 -0
  278. package/tests/common-resources/point/point7.json +14 -0
  279. package/tests/common-resources/point/point8.json +14 -0
  280. package/tests/common-resources/route/route1.json +530 -0
  281. package/tests/common-resources/routeStep/routeStep1.json +35 -0
  282. package/tests/common-resources/routeStep/routeStep2.json +35 -0
  283. package/tests/common-resources/routeStep/routeStep3.json +35 -0
  284. package/tests/common-resources/routeStep/routeStep4.json +35 -0
  285. package/tests/common-resources/routeStep/routeStep5.json +35 -0
  286. package/tests/common-resources/situmConversionArea/situmConversionArea1.json +19 -0
  287. package/tests/js/resources/fetchBuildings.json +176 -0
  288. package/tests/js/resources/fetchEventsFromBuilding.json +201 -0
  289. package/tests/js/resources/fetchFloorsFromBuilding.json +34 -0
  290. package/tests/js/resources/fetchIndoorPOIsFromBuilding.json +574 -0
  291. package/tests/js/resources/fetchMapFromFloor.json +3 -0
  292. package/tests/js/resources/fetchOutdoorPOIsFromBuilding.json +68 -0
  293. package/tests/js/resources/fetchPoiCategories.json +72 -0
  294. package/tests/js/resources/fetchPoiCategoryIconNormal.json +3 -0
  295. package/tests/js/resources/fetchPoiCategoryIconSelected.json +3 -0
  296. package/tests/js/resources/requestDirections.json +1167 -0
  297. package/tests/js/resources/startPositioning/0_starting.json +4 -0
  298. package/tests/js/resources/startPositioning/1_preparingPositioningModel.json +4 -0
  299. package/tests/js/resources/startPositioning/2_startingPositioning.json +4 -0
  300. package/tests/js/resources/startPositioning/3_calculating.json +4 -0
  301. package/tests/js/resources/startPositioning/4_position.json +48 -0
  302. package/tests/js/resources/startPositioning/5_position.json +48 -0
  303. package/tests/js/test.js +416 -0
  304. package/tests/scripts/clean_android_resources.sh +3 -0
  305. package/tests/scripts/clean_ios_resources.sh +3 -0
  306. package/tests/scripts/copy_android_resources.sh +3 -0
  307. package/tests/scripts/copy_ios_resources.sh +3 -0
  308. package/tests/scripts/self-destruct.sh +1 -0
  309. package/www/android/Interfaces.js +742 -0
  310. package/www/android/situm.js +296 -0
  311. package/www/ios/situm.js +99 -0
  312. package/www/map-view-controller.js +223 -0
  313. package/www/map-view.js +88 -0
@@ -0,0 +1,983 @@
1
+ #import "SitumLocationWrapper.h"
2
+ #import "Constants.h"
3
+
4
+ NSString* emptyStrCheck(NSString *str) {
5
+ if (!str || str == nil) {
6
+ return @"";
7
+ }
8
+ return str;
9
+ }
10
+
11
+ NSString* orientationTypeToString(kSITIndicationOrientation orientation) {
12
+ NSString *type = @"";
13
+ switch (orientation) {
14
+ case kSITInvalidOrientation:
15
+ type = @"INVALID_ORIENTATION";
16
+ break;
17
+ case kSITStraight:
18
+ type = @"STRAIGHT";
19
+ break;
20
+ case kSITVeerRight:
21
+ type = @"VEER_RIGHT";
22
+ break;
23
+ case kSITRight:
24
+ type = @"RIGHT";
25
+ break;
26
+ case kSITSharpRight:
27
+ type = @"SHARP_RIGHT";
28
+ break;
29
+ case kSITVeerLeft:
30
+ type = @"VEER_LEFT";
31
+ break;
32
+ case kSITLeft:
33
+ type = @"LEFT";
34
+ break;
35
+ case kSITSharpLeft:
36
+ type = @"SHARP_LEFT";
37
+ break;
38
+ case kSITBackward:
39
+ type = @"BACKWARD";
40
+ break;
41
+
42
+ default:
43
+ break;
44
+ }
45
+ return type;
46
+ }
47
+
48
+ kSITIndicationOrientation stringToOrientationType(NSString *orientation) {
49
+ kSITIndicationOrientation type = kSITInvalidOrientation;
50
+ if ([orientation isEqualToString:@"INVALID_ORIENTATION"]) {
51
+ type = kSITInvalidOrientation;
52
+ } else if ([orientation isEqualToString:@"STRAIGHT"]) {
53
+ type = kSITStraight;
54
+ } else if ([orientation isEqualToString:@"VEER_RIGHT"]) {
55
+ type = kSITVeerRight;
56
+ } else if ([orientation isEqualToString:@"RIGHT"]) {
57
+ type = kSITRight;
58
+ } else if ([orientation isEqualToString:@"SHARP_RIGHT"]) {
59
+ type = kSITSharpRight;
60
+ } else if ([orientation isEqualToString:@"VEER_LEFT"]) {
61
+ type = kSITVeerLeft;
62
+ } else if ([orientation isEqualToString:@"LEFT"]) {
63
+ type = kSITLeft;
64
+ } else if ([orientation isEqualToString:@"SHARP_LEFT"]) {
65
+ type = kSITSharpLeft;
66
+ } else if ([orientation isEqualToString:@"BACKWARD"]) {
67
+ type = kSITBackward;
68
+ }
69
+ return type;
70
+ }
71
+
72
+ // indicationType
73
+
74
+ NSString* indicationTypeToString(kSITIndicationActions action) {
75
+ NSString *type = @"";
76
+ switch (action) {
77
+ case kSITInvalidAction:
78
+ type = @"INVALID_ACTION";
79
+ break;
80
+ case kSITTurn:
81
+ type = @"TURN";
82
+ break;
83
+ case kSITGoAhead:
84
+ type = @"GO_AHEAD";
85
+ break;
86
+ case kSITChangeFloor:
87
+ type = @"CHANGE_FLOOR";
88
+ break;
89
+ case kSITEnd:
90
+ type = @"END";
91
+ break;
92
+ case kSITCalculating:
93
+ type = @"CALCULATING";
94
+ break;
95
+ default:
96
+ break;
97
+ }
98
+ return type;
99
+ }
100
+
101
+ kSITIndicationActions stringToIndicationType(NSString* action) {
102
+ kSITIndicationActions type = kSITInvalidAction;
103
+ if ([action isEqualToString:@"INVALID_ACTION"]) {
104
+ type = kSITInvalidAction;
105
+ } else if ([action isEqualToString:@"TURN"]) {
106
+ type = kSITTurn;
107
+ } else if ([action isEqualToString:@"GO_AHEAD"]) {
108
+ type = kSITGoAhead;
109
+ } else if ([action isEqualToString:@"CHANGE_FLOOR"]) {
110
+ type = kSITChangeFloor;
111
+ } else if ([action isEqualToString:@"END"]) {
112
+ type = kSITEnd;
113
+ }
114
+ return type;
115
+ }
116
+
117
+ // locationState
118
+
119
+ SITLocationState stringToLocationState(NSString* state){
120
+ SITLocationState type = kSITLocationStopped;
121
+ if ([state isEqualToString:@"STOPPED"]) {
122
+ type = kSITLocationStopped;
123
+ } else if ([state isEqualToString:@"CALCULATING"]) {
124
+ type = kSITLocationCalculating;
125
+ } else if ([state isEqualToString:@"USER_NOT_IN_BUILDING"]) {
126
+ type = kSITLocationUserNotInBuilding;
127
+ } else if ([state isEqualToString:@"STARTING"]) {
128
+ type = kSITLocationStarted;
129
+ }
130
+ return type;
131
+ }
132
+
133
+ static SitumLocationWrapper *singletonSitumLocationWrapperObj;
134
+
135
+ @implementation SitumLocationWrapper
136
+
137
+ + (SitumLocationWrapper *)shared {
138
+ static dispatch_once_t onceToken;
139
+ dispatch_once(&onceToken, ^{
140
+ singletonSitumLocationWrapperObj = [[SitumLocationWrapper alloc] init];
141
+ });
142
+ return singletonSitumLocationWrapperObj;
143
+ }
144
+
145
+ //Building
146
+
147
+ - (NSDictionary *) buildingToJsonObject:(SITBuilding *) building {
148
+
149
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
150
+ [jo setObject:emptyStrCheck(building.address) forKey:@"address"];
151
+ [jo setObject:[self boundsToJsonObject:building.bounds] forKey:@"bounds"];
152
+ [jo setObject:[self boundsToJsonObject:building.rotatedBounds] forKey:@"boundsRotated"];
153
+ [jo setObject:[self dimensionsToJsonObject:building.dimensions] forKey:@"dimensions"];
154
+ [jo setObject:[self coordinateToJsonObject:building.center] forKey:@"center"];
155
+ [jo setObject:emptyStrCheck(building.name) forKey:@"name"];
156
+ [jo setObject:emptyStrCheck(building.infoHTML) forKey:@"infoHtml"];
157
+ [jo setObject:emptyStrCheck(building.pictureThumbURL.direction) forKey:@"pictureThumbUrl"];
158
+ [jo setObject:emptyStrCheck(building.pictureURL.direction) forKey:@"pictureUrl"];
159
+ // [jo setObject:building.rotation forKey:@"rotation"];
160
+ [jo setObject:[NSNumber numberWithFloat:[building.rotation degrees]] forKey:@"rotationDegrees"];
161
+ [jo setObject:[NSNumber numberWithFloat:[building.rotation radians]] forKey:@"rotationRadians"];
162
+ [jo setObject:[NSNumber numberWithFloat:[building.rotation radians]] forKey:@"rotation"];
163
+ [jo setObject:emptyStrCheck(building.userIdentifier) forKey:@"userIdentifier"];
164
+ [jo setObject:emptyStrCheck(building.identifier) forKey:@"identifier"];
165
+ [jo setObject:emptyStrCheck(building.identifier) forKey:@"buildingIdentifier"];
166
+
167
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
168
+ [dateFormatter setDateFormat:kDateFormat];
169
+
170
+ [jo setObject:emptyStrCheck([dateFormatter stringFromDate:building.createdAt])
171
+ forKey:@"createdAt"];
172
+
173
+ [jo setObject:emptyStrCheck([dateFormatter stringFromDate:building.updatedAt])
174
+ forKey:@"updatedAt"];
175
+
176
+ if (building.customFields) {
177
+ [jo setObject:building.customFields forKey:@"customFields"];
178
+ }
179
+
180
+ return jo.copy;
181
+ }
182
+
183
+ - (NSArray *)floorsToJsonArray:(NSArray *)floors
184
+ {
185
+ NSMutableArray *ja = [[NSMutableArray alloc] init];
186
+ for (SITFloor *obj in floors) {
187
+ NSDictionary *floorJson = [self floorToJsonObject:obj];
188
+
189
+ [ja addObject:floorJson];
190
+ }
191
+ return ja;
192
+ }
193
+
194
+ - (NSArray *)poisToJsonArray:(NSArray *)array
195
+ {
196
+ NSMutableArray *ja = [[NSMutableArray alloc] init];
197
+ for (SITPOI *obj in array) {
198
+ NSDictionary *json = [self poiToJsonObject:obj];
199
+
200
+ [ja addObject:json];
201
+ }
202
+ return ja;
203
+ }
204
+
205
+ - (NSArray *)eventsToJsonArray:(NSArray *)array
206
+ {
207
+ NSMutableArray *ja = [[NSMutableArray alloc] init];
208
+ for (SITEvent *obj in array) {
209
+ NSDictionary *json = [self eventToJsonObject:obj];
210
+
211
+ [ja addObject:json];
212
+ }
213
+ return ja;
214
+ }
215
+
216
+
217
+ // Building Info
218
+ - (NSDictionary *) buildingInfoToJsonObject:(SITBuildingInfo *)buildingInfo
219
+ {
220
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
221
+
222
+ // Building
223
+ [jo setObject:[self buildingToJsonObject:buildingInfo.building] forKey:@"building"];
224
+ // Floors
225
+ [jo setObject:[self floorsToJsonArray:buildingInfo.floors] forKey:@"floors"];
226
+ // Indoor Pois
227
+ [jo setObject:[self poisToJsonArray:buildingInfo.indoorPois] forKey:@"indoorPois"];
228
+ // Outdoor Pois
229
+ [jo setObject:[self poisToJsonArray:buildingInfo.outdoorPois] forKey:@"outdoorPois"];
230
+ // Events
231
+ [jo setObject:[self eventsToJsonArray:buildingInfo.events] forKey:@"events"];
232
+ // Geofences?
233
+
234
+ return jo;
235
+ }
236
+
237
+
238
+ - (SITLocationRequest *) jsonObjectToLocationRequest: (NSArray *) json {
239
+ NSDictionary *buildingJO;
240
+ NSNumber *useDeadReckoning = nil;
241
+ NSNumber *useGps = nil;
242
+ NSString *buildingId;
243
+ NSString *realtimeUpdateInterval;
244
+ NSNumber *interval = nil;
245
+ NSNumber *smallestDisplacement = nil;
246
+ NSNumber *useBarometer = nil;
247
+ SITRealtimeUpdateInterval realtimeInterval = 0;
248
+
249
+ // Check use of remote configuration
250
+ if ([json isKindOfClass:[NSDictionary class]]) {
251
+ NSDictionary *params = (NSDictionary *)json;
252
+
253
+ if ([params allKeys].count == 0) {
254
+ return nil;
255
+ }
256
+ } else if ([json isKindOfClass:[NSArray class]]) {
257
+ if (json.count == 0) {
258
+ return nil;
259
+ }
260
+ }
261
+
262
+ //The following if-else is necessary in order to mantain compatibility
263
+ //with the startPositioning[building] method.
264
+ //If params is an array, then it contains both a building and a locationRequest
265
+ //If params is a dictionary, then it should only contain a building
266
+
267
+ if ([json isKindOfClass:[NSArray class]]) {
268
+ buildingJO = (NSDictionary*)[json objectAtIndex:0];
269
+ if (json.count > 1) {
270
+ NSDictionary *requestJO = (NSDictionary*)[json objectAtIndex:1];
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
+
291
+ if (realtimeUpdateInterval != nil && [realtimeUpdateInterval isKindOfClass: [NSString class]]) {
292
+
293
+ if ([realtimeUpdateInterval isEqualToString:@"REALTIME"]) {
294
+ realtimeInterval = kSITUpdateIntervalRealtime;
295
+ } else if ([realtimeUpdateInterval isEqualToString:@"FAST"]) {
296
+ realtimeInterval = kSITUpdateIntervalFast;
297
+ } else if ([realtimeUpdateInterval isEqualToString:@"NORMAL"]) {
298
+ realtimeInterval = kSITUpdateIntervalNormal;
299
+ } else if ([realtimeUpdateInterval isEqualToString:@"SLOW"]) {
300
+ realtimeInterval = kSITUpdateIntervalSlow;
301
+ } else if ([realtimeUpdateInterval isEqualToString:@"BATTERY_SAVER"]) {
302
+ realtimeInterval = kSITUpdateIntervalBatterySaver;
303
+ }
304
+ }
305
+
306
+ SITLocationRequest *locationRequest = [[SITLocationRequest alloc] initWithBuildingId:buildingId];
307
+ if (useDeadReckoning != nil) {
308
+ [locationRequest setUseDeadReckoning:[useDeadReckoning boolValue]];
309
+
310
+ }
311
+ if(useGps != nil) {
312
+ [locationRequest setUseGps:[useGps boolValue]];
313
+ }
314
+
315
+ if(interval != nil) {
316
+ [locationRequest setInterval:[interval intValue]];
317
+ }
318
+
319
+ if (smallestDisplacement != nil) {
320
+ [locationRequest setSmallestDisplacement:[smallestDisplacement floatValue]];
321
+ }
322
+
323
+ if(useBarometer != nil) {
324
+ [locationRequest setUseBarometer: [useBarometer boolValue]];
325
+ }
326
+
327
+ if (realtimeInterval != 0) {
328
+ [locationRequest setUpdateInterval:realtimeInterval];
329
+ }
330
+ return locationRequest;
331
+ }
332
+
333
+ - (NSString*) locationStateToString:(SITLocationState) state {
334
+ NSString *type = @"";
335
+ switch (state) {
336
+ case kSITLocationStopped:
337
+ type = @"STOPPED";
338
+ break;
339
+ case kSITLocationCalculating:
340
+ type = @"CALCULATING";
341
+ break;
342
+ case kSITLocationUserNotInBuilding:
343
+ type = @"USER_NOT_IN_BUILDING";
344
+ break;
345
+ case kSITLocationStarted:
346
+ type = @"STARTING";
347
+ break;
348
+
349
+ default:
350
+ break;
351
+ }
352
+ return type;
353
+ }
354
+
355
+ - (NSDictionary *) locationStateToJsonObject:(SITLocationState) state {
356
+
357
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
358
+ [jo setValue: [self locationStateToString:state] forKey: @"statusName"];
359
+ NSNumber *status = [NSNumber numberWithInt:state];
360
+ [jo setValue: status forKey: @"statusOrdinal"];
361
+ return jo;
362
+ }
363
+
364
+ //deprecated method
365
+
366
+ - (NSDictionary *) buildingIndoorToJsonObject:(SITIndoorBuilding *) building __deprecated{
367
+
368
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
369
+ [jo setObject:emptyStrCheck(building.address) forKey:@"address"];
370
+ [jo setObject:[self boundsToJsonObject:building.bounds] forKey:@"bounds"];
371
+ [jo setObject:[self boundsToJsonObject:building.boundsRotated] forKey:@"boundsRotated"];
372
+ [jo setObject:[self coordinateToJsonObject:building.coordinate] forKey:@"center"];
373
+ // [jo setObject:[self dimensionsToJsonObject:building.dimensions] forKey:@"dimensions"];
374
+ [jo setObject:emptyStrCheck(building.name) forKey:@"name"];
375
+ [jo setObject:emptyStrCheck(building.picture_thumb_url) forKey:@"pictureThumbUrl"];
376
+ [jo setObject:emptyStrCheck(building.picture_url) forKey:@"pictureUrl"];
377
+ [jo setObject:building.rotation forKey:@"rotation"];
378
+ //TODO check
379
+ //[jo setObject:emptyStrCheck(building.user_identifier) forKey:@"userIdentifier"];
380
+ [jo setObject:emptyStrCheck([NSString stringWithFormat:@"%@", building.identifier]) forKey:@"identifier"];
381
+
382
+ // if (building.customFields) {
383
+ // [jo setObject:building.customFields forKey:@"customFields"];
384
+ // }
385
+
386
+ return jo.copy;
387
+ }
388
+
389
+
390
+ // Geofence
391
+ - (NSDictionary *)geofenceToJsonObject:(SITGeofence *)geofence {
392
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
393
+
394
+ // Complete implementation
395
+ [jo setObject:emptyStrCheck(geofence.identifier) forKey:@"identifier"];
396
+ [jo setObject:emptyStrCheck(geofence.buildingIdentifier) forKey:@"buildingIdentifier"];
397
+ [jo setObject:emptyStrCheck(geofence.floorIdentifier) forKey:@"floorIdentifier"];
398
+
399
+ [jo setObject:emptyStrCheck(geofence.name) forKey:@"name"];
400
+
401
+ // Polygon Points
402
+ [jo setObject:[self pointsToJsonArray:geofence.polygonPoints] forKey:@"polygonPoints"];
403
+
404
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
405
+ [dateFormatter setDateFormat:kDateFormat];
406
+
407
+ [jo setObject:emptyStrCheck([dateFormatter stringFromDate:geofence.createdAt])
408
+ forKey:@"createdAt"];
409
+
410
+ [jo setObject:emptyStrCheck([dateFormatter stringFromDate:geofence.updatedAt])
411
+ forKey:@"updatedAt"];
412
+
413
+ if (geofence.customFields) {
414
+ [jo setObject:geofence.customFields forKey:@"customFields"];
415
+ } else {
416
+ [jo setObject:[NSDictionary new] forKey:@"customFields"];
417
+ }
418
+ [jo setObject:emptyStrCheck(geofence.infoHtml) forKey:@"infoHtml"];
419
+
420
+
421
+
422
+ return jo;
423
+ }
424
+
425
+ //Floor
426
+
427
+ - (NSDictionary *) floorToJsonObject:(SITFloor *) floor {
428
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
429
+ //TODO review added altitude key
430
+ [jo setObject:[NSNumber numberWithDouble:floor.altitude] forKey:@"altitude"];
431
+ [jo setObject:emptyStrCheck([NSString stringWithFormat:@"%@", floor.buildingIdentifier]) forKey:@"buildingIdentifier"];
432
+ [jo setObject:[NSNumber numberWithInteger: floor.level] forKey:@"level"];
433
+ [jo setObject:[NSNumber numberWithInteger: floor.floor] forKey:@"floor"];
434
+ [jo setObject:floor.mapURL.direction forKey:@"mapUrl"];
435
+ [jo setObject:[NSNumber numberWithDouble:floor.scale] forKey:@"scale"];
436
+ [jo setObject:[NSString stringWithFormat:@"%@", floor.identifier] forKey:@"floorIdentifier"];
437
+ [jo setObject:emptyStrCheck(floor.identifier) forKey:@"identifier"];
438
+ [jo setObject:emptyStrCheck(floor.name) forKey:@"name"];
439
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
440
+ [dateFormatter setDateFormat:kDateFormat];
441
+
442
+ [jo setObject:emptyStrCheck([dateFormatter stringFromDate:floor.createdAt])
443
+ forKey:@"createdAt"];
444
+
445
+ [jo setObject:emptyStrCheck([dateFormatter stringFromDate:floor.updatedAt])
446
+ forKey:@"updatedAt"];
447
+
448
+ return jo.copy;
449
+ }
450
+
451
+ - (SITFloor *) jsonObjectToFloor:(NSDictionary *) nsFloor {
452
+ SITFloor *floor = [[SITFloor alloc] init];
453
+
454
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
455
+ [dateFormatter setDateFormat:kDateFormat];
456
+
457
+ floor.createdAt = [dateFormatter dateFromString:nsFloor[@"createdAt"]];
458
+
459
+ floor.updatedAt = [dateFormatter dateFromString:nsFloor[@"updatedAt"]];
460
+
461
+ floor.scale = [[nsFloor objectForKey:@"scale"] doubleValue];
462
+ floor.mapURL = [[SITURL alloc] initWithDirection:[nsFloor objectForKey:@"mapUrl"]];;
463
+ floor.level = [[nsFloor objectForKey:@"level"] intValue];
464
+ floor.floor = [[nsFloor objectForKey:@"floor"] intValue];
465
+ floor.identifier = [nsFloor objectForKey:@"floorIdentifier"];
466
+ floor.name = [nsFloor objectForKey:@"name"];
467
+ floor.buildingIdentifier = [nsFloor objectForKey:@"buildingIdentifier"];
468
+ floor.altitude = [nsFloor[@"altitude"] doubleValue];
469
+ return floor;
470
+ }
471
+
472
+ //Event
473
+
474
+ - (NSDictionary *) eventToJsonObject:(SITEvent *) event {
475
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
476
+ jo[@"identifier"] = event.identifier;
477
+ jo[@"buildingIdentifier"] = event.project_identifier;
478
+ jo[@"floorIdentifier"] = event.trigger.center.floorIdentifier;
479
+ jo[@"infoHtml"] = event.info;
480
+ jo[@"name"] = event.name;
481
+ jo[@"radius"] = event.trigger.radius;
482
+ jo[@"x"] = @(event.trigger.center.cartesianCoordinate.x);
483
+ jo[@"y"] = @(event.trigger.center.cartesianCoordinate.y);
484
+
485
+ jo[@"trigger"] = [self circleAreaToJsonObject:event.trigger];
486
+ if (event.conversion != nil) {
487
+ jo[@"conversion"] = [self circleAreaToJsonObject:event.conversion];
488
+ }
489
+
490
+ jo[@"conversionArea"] = [self conversionAreaToJsonObject:event.conversionArea];
491
+ jo[@"customFields"] = event.customFields != nil ? event.customFields : [NSDictionary new];
492
+
493
+ return jo.copy;
494
+ }
495
+
496
+ //Category
497
+
498
+ //Floor
499
+
500
+ - (NSDictionary *) poiCategoryToJsonObject:(SITPOICategory *) category {
501
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
502
+ [jo setObject:[NSString stringWithFormat:@"%@", category.identifier] forKey:@"identifier"];
503
+ [jo setObject:[NSNumber numberWithBool:category.isPublic] forKey:@"public"];
504
+ [jo setObject:[NSString stringWithFormat:@"%@", category.code] forKey:@"poiCategoryCode"];
505
+ [jo setObject:[NSString stringWithFormat:@"%@", [category.name value]] forKey:@"poiCategoryName"];
506
+ [jo setObject:category.iconURL.direction forKey:@"icon_deselected"];
507
+ [jo setObject:category.selectedIconURL.direction forKey:@"icon_selected"];
508
+ return jo.copy;
509
+ }
510
+
511
+ - (SITPOICategory *) poiCategoryFromJsonObject:(NSDictionary *) jo {
512
+ SITPOICategory *category = [[SITPOICategory alloc] init];
513
+ category.name = [[SITMultilanguageString alloc] initWithValue:[jo objectForKey:@"poiCategoryName"] defaultLocale:[NSLocale currentLocale]];
514
+ category.code = [jo objectForKey:@"poiCategoryCode"];
515
+ category.isPublic = [jo objectForKey:@"public"];
516
+ category.selectedIconURL = [[SITURL alloc] initWithDirection:[jo objectForKey:@"icon_selected"]];
517
+ if([jo objectForKey:@"icon_unselected"]) {
518
+ category.iconURL = [[SITURL alloc] initWithDirection:[jo objectForKey:@"icon_unselected"]];
519
+ } else {
520
+ category.iconURL = [[SITURL alloc] initWithDirection:[jo objectForKey:@"icon_deselected"]];
521
+ }
522
+ return category;
523
+ }
524
+
525
+ - (NSDictionary *)bitmapToJsonObject:(UIImage *)icon {
526
+ NSString *base64 = [UIImagePNGRepresentation(icon) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
527
+ NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
528
+ [dict setObject:base64 forKey:@"data"];
529
+ return dict;
530
+ }
531
+
532
+ // POI
533
+
534
+ - (NSDictionary *) poiToJsonObject:(SITPOI *) poi {
535
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
536
+ [jo setObject:emptyStrCheck(poi.identifier) forKey:@"identifier"];
537
+ [jo setObject:emptyStrCheck(poi.buildingIdentifier) forKey:@"buildingIdentifier"];
538
+ [jo setObject:[self cartesianCoordinateToJsonObject:poi.position.cartesianCoordinate] forKey:@"cartesianCoordinate"];
539
+ [jo setObject:[self coordinateToJsonObject:poi.position.coordinate] forKey:@"coordinate"];
540
+ [jo setObject:emptyStrCheck(poi.position.floorIdentifier) forKey:@"floorIdentifier"];
541
+ [jo setObject:emptyStrCheck(poi.name) forKey:@"poiName"];
542
+ [jo setObject:[self pointToJsonObject:poi.position] forKey:@"position"];
543
+ [jo setObject:[NSNumber numberWithBool:poi.position.isIndoor] forKey:@"isIndoor"];
544
+ [jo setObject:[NSNumber numberWithBool:poi.position.isOutdoor] forKey:@"isOutdoor"];
545
+ [jo setObject: poi.category.code forKey:@"category"];
546
+
547
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
548
+ [dateFormatter setDateFormat:kDateFormat];
549
+
550
+ [jo setObject:emptyStrCheck([dateFormatter stringFromDate:poi.createdAt])
551
+ forKey:@"createdAt"];
552
+
553
+ [jo setObject:emptyStrCheck([dateFormatter stringFromDate:poi.updatedAt])
554
+ forKey:@"updatedAt"];
555
+
556
+ if (poi.customFields) {
557
+ [jo setObject:poi.customFields forKey:@"customFields"];
558
+ } else {
559
+ [jo setObject:[NSDictionary new] forKey:@"customFields"];
560
+ }
561
+ [jo setObject:emptyStrCheck(poi.infoHTML) forKey:@"infoHtml"];
562
+ return jo.copy;
563
+ }
564
+
565
+ // Location
566
+
567
+ - (NSDictionary *) locationToJsonObject:(SITLocation *) location {
568
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
569
+ [jo setObject:[NSNumber numberWithFloat:location.accuracy] forKey:@"accuracy"];
570
+ [jo setObject:[self angleToJsonObject:location.bearing] forKey:@"bearing"];
571
+ [jo setObject:[self qualityStringFromQuality:location.bearingQuality] forKey:@"bearingQuality"];
572
+ [jo setObject:emptyStrCheck(location.position.buildingIdentifier) forKey:@"buildingIdentifier"];
573
+ [jo setObject:[self angleToJsonObject:location.cartesianBearing] forKey:@"cartesianBearing"];
574
+ [jo setObject:[self cartesianCoordinateToJsonObject:location.position.cartesianCoordinate] forKey:@"cartesianCoordinate"];
575
+ [jo setObject:[self coordinateToJsonObject:location.position.coordinate] forKey:@"coordinate"];
576
+ [jo setObject:emptyStrCheck(location.position.floorIdentifier) forKey:@"floorIdentifier"];
577
+ [jo setObject:[self pointToJsonObject:location.position] forKey:@"position"];
578
+ [jo setObject:emptyStrCheck(location.provider) forKey:@"provider"];
579
+ [jo setObject:[self qualityStringFromQuality:location.quality] forKey:@"quality"];
580
+ [jo setObject:[NSNumber numberWithBool:location.hasBearing] forKey:@"hasBearing"];
581
+ [jo setObject:[NSNumber numberWithDouble:location.timestamp] forKey:@"timestamp"];
582
+ [jo setObject:[NSNumber numberWithBool:location.position.isIndoor] forKey:@"isIndoor"];
583
+ [jo setObject:[NSNumber numberWithBool:location.position.isOutdoor] forKey:@"isOutdoor"];
584
+ [jo setObject:emptyStrCheck(location.deviceId) forKey:@"deviceId"];
585
+ [jo setValue:@"locationChanged" forKey:@"type"];
586
+ return jo.copy;
587
+ }
588
+
589
+ - (NSString *)qualityStringFromQuality:(kSITQualityValues)quality {
590
+ return quality == kSITHigh ? @"HIGH":@"LOW";
591
+ }
592
+
593
+ - (SITLocation *) locationJsonObjectToLocation:(NSDictionary *) jo {
594
+ NSTimeInterval timestamp = [(NSNumber*)[jo valueForKey:@"timestamp"] doubleValue];
595
+ SITPoint *position;
596
+ // TODO: the map-viewer is not wrapping the position info into a position object.
597
+ if ([jo objectForKey:@"position"] != nil) {
598
+ position = [self pointJsonObjectToPoint:[jo objectForKey:@"position"]];
599
+ } else {
600
+ position = [self pointJsonObjectToPoint:jo];
601
+ }
602
+
603
+ float bearing = [[[jo objectForKey:@"bearing"] valueForKey:@"degrees"] floatValue];
604
+ float cartesianBearing = [[[jo objectForKey:@"cartesianBearing"] valueForKey:@"radians"] floatValue];
605
+
606
+ kSITQualityValues quality = [(NSString*)[jo valueForKey: @"quality"] isEqualToString: @"HIGH"] ? kSITHigh : kSITLow;
607
+ kSITQualityValues bearingQuality = [(NSString*)[jo valueForKey: @"bearingQuality"] isEqualToString: @"HIGH"] ? kSITHigh : kSITLow;
608
+
609
+ float accuracy = [(NSNumber*)[jo objectForKey:@"accuracy"] floatValue];
610
+
611
+ SITLocation *location = [[SITLocation alloc] initWithTimestamp:timestamp position:position bearing:bearing cartesianBearing:cartesianBearing quality:quality accuracy:accuracy provider:[jo objectForKey:@"provider"]];
612
+ location.bearingQuality = bearingQuality;
613
+ return location;
614
+ }
615
+
616
+ - (NSDictionary *) coordinateToJsonObject:(CLLocationCoordinate2D) coordinate {
617
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
618
+ [jo setObject:[NSNumber numberWithDouble:coordinate.latitude] forKey:@"latitude"];
619
+ [jo setObject:[NSNumber numberWithDouble:coordinate.longitude] forKey:@"longitude"];
620
+ return jo.copy;
621
+ }
622
+
623
+ // Coordinate
624
+
625
+ - (NSDictionary *) indoorPointToJsonObject:(SITIndoorPoint *) iPoint {
626
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
627
+
628
+ if (iPoint == nil) {
629
+ iPoint = [SITIndoorPoint new];
630
+ iPoint.x = @(0);
631
+ iPoint.y = @(0);
632
+ }
633
+ jo[@"x"] = iPoint.x;
634
+ jo[@"y"] = iPoint.y;
635
+ return jo.copy;
636
+ }
637
+
638
+ - (CLLocationCoordinate2D) coordinateJsonObjectToCoordinate:(NSDictionary *) jo {
639
+ CLLocationDegrees latitude = [(NSNumber*)[jo objectForKey:@"latitude"] doubleValue];
640
+ CLLocationDegrees longitude = [(NSNumber*)[jo objectForKey:@"longitude"] doubleValue];
641
+
642
+ CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(latitude, longitude);
643
+ return coordinate;
644
+ }
645
+
646
+
647
+ // Point
648
+ - (NSArray *) pointsToJsonArray:(NSArray<SITPoint *> *)points {
649
+ NSMutableArray *pointsJO = [[NSMutableArray alloc]init];
650
+ for(SITPoint* point in points) {
651
+ [pointsJO addObject: [self pointToJsonObject: point]];
652
+ }
653
+ return pointsJO;
654
+ }
655
+
656
+ - (NSDictionary *) pointToJsonObject:(SITPoint *) point {
657
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
658
+ [jo setObject:emptyStrCheck(point.buildingIdentifier) forKey:@"buildingIdentifier"];
659
+ [jo setObject:[self cartesianCoordinateToJsonObject:point.cartesianCoordinate] forKey:@"cartesianCoordinate"];
660
+ [jo setObject:[self coordinateToJsonObject:point.coordinate] forKey:@"coordinate"];
661
+ [jo setObject:emptyStrCheck(point.floorIdentifier) forKey:@"floorIdentifier"];
662
+ [jo setObject:[NSNumber numberWithBool:point.isIndoor] forKey:@"isIndoor"];
663
+ [jo setObject:[NSNumber numberWithBool:point.isOutdoor] forKey:@"isOutdoor"];
664
+ return jo.copy;
665
+
666
+ }
667
+
668
+ - (SITPoint *) pointJsonObjectToPoint:(NSDictionary *) jo {
669
+ SITPoint *point = nil;
670
+ BOOL isOutdoor = [(NSNumber*)jo[@"isOutdoor"] boolValue];
671
+ if(isOutdoor) {
672
+ point = [[SITPoint alloc] initWithCoordinate: [self coordinateJsonObjectToCoordinate:[jo objectForKey:@"coordinate"]]
673
+ buildingIdentifier: [jo valueForKey:@"buildingIdentifier"]];
674
+ } else {
675
+ point = [[SITPoint alloc] initWithCoordinate:[self coordinateJsonObjectToCoordinate:[jo objectForKey:@"coordinate"]] buildingIdentifier:[jo valueForKey:@"buildingIdentifier"] floorIdentifier:[jo valueForKey:@"floorIdentifier"] cartesianCoordinate:[self cartesianCoordinateJsonObjectToCartesianCoordinate:[jo objectForKey:@"cartesianCoordinate"]]];
676
+ }
677
+ return point;
678
+ }
679
+
680
+ // CartesianCoordinate
681
+
682
+ - (NSDictionary *) cartesianCoordinateToJsonObject:(SITCartesianCoordinate *) cartesianCoordinate {
683
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
684
+ [jo setObject:[NSNumber numberWithDouble:cartesianCoordinate.x] forKey:@"x"];
685
+ [jo setObject:[NSNumber numberWithDouble:cartesianCoordinate.y] forKey:@"y"];
686
+ return jo.copy;
687
+
688
+ }
689
+
690
+ - (SITCartesianCoordinate *) cartesianCoordinateJsonObjectToCartesianCoordinate:(NSDictionary *) jo {
691
+ SITCartesianCoordinate *cartesianCoordinate = [[SITCartesianCoordinate alloc] initWithX:[[jo valueForKey:@"x"] doubleValue] y:[[jo valueForKey:@"y"] doubleValue]];
692
+ return cartesianCoordinate;
693
+ }
694
+
695
+ - (SITDirectionsRequest *) jsonObjectToDirectionsRequest: (NSArray *) json {
696
+ NSDictionary* fromLocation = (NSDictionary*)[json objectAtIndex:1];
697
+ NSDictionary* toPOI = (NSDictionary*)[json objectAtIndex:2];
698
+ NSDictionary* options = (NSDictionary*)[json objectAtIndex:3];
699
+
700
+ SITLocation *location = [SitumLocationWrapper.shared locationJsonObjectToLocation:fromLocation];
701
+ SITPoint *endPoint;
702
+ // TODO: the map-viewer is not wrapping the position info into a position object.
703
+ if ([toPOI objectForKey:@"position"] != nil) {
704
+ endPoint = [SitumLocationWrapper.shared pointJsonObjectToPoint:[toPOI objectForKey:@"position"]];
705
+ } else {
706
+ endPoint = [SitumLocationWrapper.shared pointJsonObjectToPoint:toPOI];
707
+ }
708
+
709
+ SITDirectionsRequest *directionsRequest = [[SITDirectionsRequest alloc] initWithLocation: location withDestination: endPoint];
710
+
711
+ NSNumber *accessible;
712
+ BOOL minimizeFloorChanges = false;
713
+ NSString *accessibilityModeValue = nil;
714
+ if(options) {
715
+ accessible = (NSNumber*)[options valueForKey: @"accessible"];
716
+ if (accessible == nil) {
717
+ accessible = (NSNumber*)[options valueForKey: @"accessibleRoute"];
718
+ }
719
+ accessibilityModeValue = options[@"accessibilityMode"];
720
+ minimizeFloorChanges = [(NSNumber*)[options valueForKey: @"minimizeFloorChanges"] boolValue];
721
+ }
722
+
723
+ if (accessibilityModeValue != nil) {
724
+ SITAccessibilityMode accessibilityMode;
725
+ if ([accessibilityModeValue isEqualToString:@"CHOOSE_SHORTEST"]) {
726
+ accessibilityMode = kSITChooseShortest;
727
+ } else if ([accessibilityModeValue isEqualToString:@"ONLY_NOT_ACCESSIBLE_FLOOR_CHANGES"]) {
728
+ accessibilityMode = kSITOnlyNotAccessibleFloorChanges;
729
+ } else {
730
+ accessibilityMode = kSITOnlyAccessible;
731
+ }
732
+ [directionsRequest setAccessibility:accessibilityMode];
733
+ } else if (accessible != nil) {
734
+
735
+ [directionsRequest setAccessible: [accessible boolValue]];
736
+ }
737
+
738
+ [directionsRequest setMinimizeFloorChanges: minimizeFloorChanges];
739
+ return directionsRequest;
740
+ }
741
+
742
+
743
+ // Dimensions
744
+
745
+ - (NSDictionary *) dimensionsToJsonObject:(SITDimensions *) dimensions {
746
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
747
+ [jo setObject:[NSNumber numberWithDouble:dimensions.width] forKey:@"width"];
748
+ [jo setObject:[NSNumber numberWithDouble:dimensions.height] forKey:@"height"];
749
+ return jo.copy;
750
+ }
751
+
752
+ // Bounds
753
+
754
+ - (NSDictionary *) boundsToJsonObject:(SITBounds) bounds {
755
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
756
+ [jo setObject:[self coordinateToJsonObject:bounds.northEast] forKey:@"northEast"];
757
+ [jo setObject:[self coordinateToJsonObject:bounds.northWest] forKey:@"northWest"];
758
+ [jo setObject:[self coordinateToJsonObject:bounds.southEast] forKey:@"southEast"];
759
+ [jo setObject:[self coordinateToJsonObject:bounds.southWest] forKey:@"southWest"];
760
+ return jo.copy;
761
+ }
762
+
763
+ - (NSDictionary *) circleAreaToJsonObject:(SITCircularArea *) ca {
764
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
765
+
766
+ jo[@"center"] = ca != nil ? [self pointToJsonObject:ca.center] : nil;
767
+ jo[@"radius"] = ca != nil ? ca.radius : nil;
768
+
769
+ return jo.copy;
770
+ }
771
+
772
+ - (NSDictionary *) conversionAreaToJsonObject:(SITRectangularArea *) ca {
773
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
774
+
775
+ if (ca == nil) {
776
+ ca = [SITRectangularArea new];
777
+ }
778
+
779
+ jo[@"topLeft"] = [self indoorPointToJsonObject:ca.topLeft];
780
+ jo[@"topRight"] = [self indoorPointToJsonObject:ca.topRight];
781
+ jo[@"bottomRight"] = [self indoorPointToJsonObject:ca.bottomRight];
782
+ jo[@"bottomLeft"] = [self indoorPointToJsonObject:ca.bottomLeft];
783
+ jo[@"floorIdentifier"] = ca.center.level_identifier != nil ? ca.center.level_identifier : @(0);
784
+
785
+ return jo.copy;
786
+ }
787
+
788
+
789
+ // Angle
790
+
791
+ - (NSDictionary *) angleToJsonObject:(SITAngle *) angle {
792
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
793
+ [jo setObject:[NSNumber numberWithDouble:angle.degrees] forKey:@"degrees"];
794
+ [jo setObject:[NSNumber numberWithDouble:angle.radians] forKey:@"radians"];
795
+ [jo setObject:[NSNumber numberWithDouble:angle.degressClockwise] forKey:@"degressClockwise"];
796
+ [jo setObject:[NSNumber numberWithDouble:angle.degressClockwise] forKey:@"degreesClockwise"];
797
+ [jo setObject:[NSNumber numberWithDouble:angle.radiansMinusPiPi] forKey:@"radiansMinusPiPi"];
798
+ return jo.copy;
799
+ }
800
+
801
+ // Route
802
+
803
+ - (NSDictionary *) routeToJsonObject:(SITRoute *) route {
804
+
805
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
806
+
807
+ NSMutableArray *stepsJsonArray = [[NSMutableArray alloc] init];
808
+ for (SITRouteStep *routeStep in route.routeSteps) {
809
+ [stepsJsonArray addObject:[self routeStepToJsonObject:routeStep]];
810
+ }
811
+
812
+ NSMutableArray *pointsJsonArray = [[NSMutableArray alloc] init];
813
+ for(SITPoint* point in route.points) {
814
+ [pointsJsonArray addObject:[self pointToJsonObject: point]];
815
+ }
816
+
817
+ NSMutableArray *indicationsJsonArray = [[NSMutableArray alloc] init];
818
+ for (SITIndication *indication in route.indications) {
819
+ [indicationsJsonArray addObject:[self indicationToJsonObject:indication]];
820
+ }
821
+
822
+ NSMutableArray* segmentsJsonArray = [NSMutableArray new];
823
+ for(SITRouteSegment* segment in route.segments) {
824
+ [segmentsJsonArray addObject: [self routeSegmentToJsonObject: segment]];
825
+ }
826
+
827
+ [jo setObject: [self pointToJsonObject:route.origin] forKey:@"from"];
828
+ [jo setObject: [self pointToJsonObject:route.destination] forKey:@"to"];
829
+ [jo setObject: stepsJsonArray.copy forKey:@"steps"];
830
+ [jo setObject: pointsJsonArray.copy forKey:@"points"];
831
+ [jo setObject: indicationsJsonArray.copy forKey:@"indications"];
832
+ [jo setObject: segmentsJsonArray.copy forKey: @"segments"];
833
+
834
+ if (route.routeSteps.count == 0) return jo; // No steps on the route
835
+
836
+
837
+ [jo setObject:stepsJsonArray.copy forKey:@"edges"];
838
+ [jo setObject:stepsJsonArray.firstObject forKey:@"firstStep"];
839
+ [jo setObject:stepsJsonArray.lastObject forKey:@"lastStep"];
840
+ [jo setObject:pointsJsonArray forKey:@"nodes"];
841
+
842
+ return jo.copy;
843
+ }
844
+
845
+ // RouteSegment
846
+
847
+ - (NSDictionary*) routeSegmentToJsonObject: (SITRouteSegment*) segment {
848
+
849
+ NSMutableDictionary* jo = [NSMutableDictionary new];
850
+ [jo setObject: segment.floorIdentifier forKey: @"floorIdentifier"];
851
+ NSMutableArray* pointsJO = [NSMutableArray new];
852
+ for(SITPoint* point in segment.points) {
853
+ [pointsJO addObject: [self pointToJsonObject: point]];
854
+ }
855
+ [jo setObject: pointsJO forKey: @"points"];
856
+
857
+ return [jo copy];
858
+ }
859
+
860
+ //RouteStep
861
+
862
+ - (NSDictionary *) routeStepToJsonObject:(SITRouteStep *) routeStep {
863
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
864
+ [jo setObject:[NSNumber numberWithDouble:routeStep.stepDistance] forKey:@"distance"];
865
+ [jo setObject:[NSNumber numberWithDouble:routeStep.distanceToGoal] forKey:@"distanceToGoal"];
866
+ [jo setObject:[self pointToJsonObject:routeStep.from] forKey:@"from"];
867
+ [jo setObject:[NSNumber numberWithInteger:routeStep.nextStepIndex] forKey:@"nextStepIndex"];
868
+ [jo setObject:[self pointToJsonObject:routeStep.to] forKey:@"to"];
869
+ [jo setObject:[self pointToJsonObject:routeStep.to] forKey:@"TO"];
870
+ [jo setObject:[NSNumber numberWithInteger:routeStep.index] forKey:@"id"];
871
+ [jo setObject:[NSNumber numberWithBool:routeStep.isFirst] forKey:@"isFirst"];
872
+ [jo setObject:[NSNumber numberWithBool:routeStep.isLast] forKey:@"isLast"];
873
+ return jo.copy;
874
+ }
875
+
876
+ - (SITRouteStep *) routeStepJsonObjectToRouteStep:(NSDictionary *) jo {
877
+ SITPoint *fromPoint = (SITPoint*)[jo objectForKey:@"from"];
878
+ SITPoint *toPoint = (SITPoint*)[jo objectForKey:@"to"];
879
+
880
+ SITRouteStep *routeStep = [[SITRouteStep alloc] initWithIndex:[(NSNumber*)[jo valueForKey:@"id"] integerValue] from:fromPoint to:toPoint isFirst:[(NSNumber*)[jo valueForKey:@"isFirst"] boolValue] isLast:[(NSNumber*)[jo valueForKey:@"isLast"] boolValue] nextStepIndex:[(NSNumber*)[jo valueForKey:@"nextStepIndex"] integerValue] stepDistance:[(NSNumber*)[jo valueForKey:@"distance"] doubleValue] distanceToGoal:[(NSNumber*)[jo valueForKey:@"distanceToGoal"] doubleValue]];
881
+
882
+ return routeStep;
883
+ }
884
+
885
+ // Indication
886
+
887
+ - (NSDictionary *) indicationToJsonObject:(SITIndication *) indication {
888
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
889
+ [jo setObject:[NSNumber numberWithDouble:indication.horizontalDistance] forKey:@"distance"];
890
+ [jo setObject:[NSNumber numberWithFloat:indication.verticalDistance] forKey:@"distanceToNextLevel"];
891
+ [jo setObject:indicationTypeToString(indication.action) forKey:@"indicationType"];
892
+ [jo setObject:[NSNumber numberWithFloat:indication.orientationChange] forKey:@"orientation"];
893
+ [jo setObject:orientationTypeToString(indication.orientation) forKey:@"orientationType"];
894
+ [jo setObject:[NSNumber numberWithInteger:indication.destinationStepIndex] forKey:@"stepIdxDestination"];
895
+ [jo setObject:[NSNumber numberWithInteger:indication.originStepIndex] forKey:@"stepIdxOrigin"];
896
+ [jo setObject:[NSNumber numberWithBool:indication.needLevelChange] forKey:@"neededLevelChange"];
897
+ [jo setObject:[indication humanReadableMessage] forKey:@"humanReadableMessage"];
898
+ if (indication.nextLevel == nil) {
899
+ NSLog(@"Next level is nil");
900
+ } else {
901
+ [jo setObject:indication.nextLevel forKey:@"nextLevel"];
902
+ }
903
+ return jo.copy;
904
+ }
905
+
906
+ - (SITIndication *) indicationJsonObjectToIndication:(NSDictionary *) jo {
907
+ NSInteger stepIdxOrigin = [(NSNumber*)[jo valueForKey:@"stepIdxOrigin"] integerValue];
908
+ NSInteger stepIdxDestination = [(NSNumber*)[jo valueForKey:@"stepIdxDestination"] integerValue];
909
+ float horizontalDistance = [(NSNumber*)[jo valueForKey:@"distance"] floatValue];
910
+ float orientationChange = [(NSNumber*)[jo valueForKey:@"orientation"] floatValue];
911
+ float verticalDistance = [(NSNumber*)[jo valueForKey:@"distanceToNextLevel"] floatValue];
912
+ NSNumber* nextLevel = (NSNumber*)[jo valueForKey:@"nextLevel"];
913
+ kSITIndicationActions action = stringToIndicationType([jo valueForKey:@"indicationType"]);
914
+ kSITIndicationOrientation orientation = stringToOrientationType([jo valueForKey:@"orientationType"]);
915
+
916
+ SITIndication *indication = [[SITIndication alloc] initWithOriginStepIndex:stepIdxOrigin destinationStepIndex:stepIdxDestination action:action horizontalDistance:horizontalDistance orientation:orientation orientationChange:orientationChange verticalDistance:verticalDistance nextLevel:nextLevel];
917
+
918
+ return indication;
919
+ }
920
+
921
+ // NavigationProgress
922
+
923
+ - (NSDictionary *) navigationProgressToJsonObject:(SITNavigationProgress *) navigationProgress {
924
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
925
+
926
+ NSMutableArray *pointsJsonArray = [[NSMutableArray alloc] init];
927
+ for(SITPoint* point in navigationProgress.points) {
928
+ [pointsJsonArray addObject:[self pointToJsonObject: point]];
929
+ }
930
+
931
+ NSMutableArray* segmentsJsonArray = [NSMutableArray new];
932
+ for(SITRouteSegment* segment in navigationProgress.segments) {
933
+ [segmentsJsonArray addObject: [self routeSegmentToJsonObject: segment]];
934
+ }
935
+
936
+ [jo setObject: pointsJsonArray forKey: @"points"];
937
+ [jo setObject: segmentsJsonArray forKey: @"segments"];
938
+ [jo setObject:[self pointToJsonObject:navigationProgress.closestPointToRoute] forKey:@"closestPointInRoute"];
939
+ [jo setObject:[NSNumber numberWithFloat:navigationProgress.distanceToClosestPointInRoute] forKey:@"distanceToClosestPointInRoute"];
940
+ [jo setObject:[self indicationToJsonObject:navigationProgress.currentIndication] forKey:@"currentIndication"];
941
+ [jo setObject:[self indicationToJsonObject:navigationProgress.nextIndication] forKey:@"nextIndication"];
942
+ [jo setObject:[NSNumber numberWithInteger:navigationProgress.currentStepIndex] forKey:@"currentStepIndex"];
943
+ [jo setObject:[NSNumber numberWithFloat:navigationProgress.distanceToGoal] forKey:@"distanceToGoal"];
944
+ [jo setObject:[NSNumber numberWithFloat:navigationProgress.distanceToEndStep] forKey:@"distanceToEndStep"];
945
+ [jo setObject:[NSNumber numberWithFloat:navigationProgress.timeToEndStep] forKey:@"timeToEndStep"];
946
+ [jo setObject:[NSNumber numberWithFloat:navigationProgress.timeToGoal] forKey:@"timeToGoal"];
947
+ [jo setObject:[self routeStepToJsonObject:navigationProgress.routeStep] forKey:@"routeStep"];
948
+ [jo setObject:[self locationToJsonObject:navigationProgress.closestLocationInRoute] forKey:@"closestLocationInRoute"];
949
+ return jo.copy;
950
+ }
951
+
952
+ // check nil string
953
+
954
+ // Realtime
955
+ - (SITRealTimeRequest *)realtimeRequestFromJson:(NSDictionary *)jo
956
+ {
957
+ SITRealTimeRequest *request = [[SITRealTimeRequest alloc] init];
958
+
959
+ NSDictionary *buildingJO = [jo valueForKey:@"building"];
960
+
961
+
962
+ request.buildingIdentifier = [buildingJO valueForKey:@"identifier"];
963
+ request.updateInterval = [[jo valueForKey:@"pollTime"] integerValue];
964
+
965
+ return request;
966
+ }
967
+
968
+ - (NSDictionary *)jsonFromRealtimeData:(SITRealTimeData *)realtimeData
969
+ {
970
+ NSMutableDictionary *jo = [[NSMutableDictionary alloc] init];
971
+
972
+ NSMutableArray *locations = [[NSMutableArray alloc]init];
973
+
974
+ for (SITLocation *location in realtimeData.locations) {
975
+ [locations addObject:[self locationToJsonObject:location]];
976
+ }
977
+
978
+ [jo setObject:locations forKey:@"locations"];
979
+
980
+ return jo;
981
+ }
982
+
983
+ @end