qwc2 2025.10.13 → 2025.10.15

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 (241) hide show
  1. package/actions/display.js +30 -1
  2. package/actions/editing.js +22 -1
  3. package/actions/layerinfo.js +13 -1
  4. package/actions/layers.js +213 -3
  5. package/actions/localConfig.js +58 -1
  6. package/actions/locale.js +21 -1
  7. package/actions/locate.js +26 -1
  8. package/actions/logging.js +10 -1
  9. package/actions/map.js +105 -2
  10. package/actions/measurement.js +12 -1
  11. package/actions/processNotifications.js +37 -1
  12. package/actions/redlining.js +18 -1
  13. package/actions/redliningPick.js +12 -1
  14. package/actions/search.js +12 -1
  15. package/actions/serviceinfo.js +12 -1
  16. package/actions/task.js +55 -3
  17. package/actions/theme.js +339 -19
  18. package/actions/windows.js +164 -5
  19. package/components/AppMenu.js +435 -3
  20. package/components/AttributeForm.js +928 -32
  21. package/components/AttributeTableWidget.js +1105 -13
  22. package/components/AutoEditForm.js +189 -3
  23. package/components/CoordinateDisplayer.js +78 -2
  24. package/components/EditComboField.js +190 -6
  25. package/components/EditUploadField.js +315 -3
  26. package/components/ExportSelection.js +203 -2
  27. package/components/FullscreenSwitcher.js +90 -3
  28. package/components/Icon.js +81 -2
  29. package/components/IdentifyViewer.js +1161 -6
  30. package/components/ImportLayer.js +718 -20
  31. package/components/LayerInfoWindow.js +145 -2
  32. package/components/LinkFeatureForm.js +246 -5
  33. package/components/MapButton.js +88 -2
  34. package/components/MapSelection.js +287 -8
  35. package/components/MessageBar.js +68 -2
  36. package/components/NumericInputWindow.js +359 -2
  37. package/components/PickFeature.js +266 -2
  38. package/components/PluginsContainer.js +227 -8
  39. package/components/PrintSelection.js +620 -49
  40. package/components/ProcessNotifications.js +104 -2
  41. package/components/QtDesignerForm.js +1137 -18
  42. package/components/ResizeableWindow.js +591 -8
  43. package/components/SearchBox.js +1307 -20
  44. package/components/ServiceInfoWindow.js +107 -2
  45. package/components/SideBar.js +204 -4
  46. package/components/StandardApp.js +381 -20
  47. package/components/Swipeable.js +15 -1
  48. package/components/TaskBar.js +85 -2
  49. package/components/ThemeLayersListWindow.js +216 -4
  50. package/components/ThemeList.js +381 -7
  51. package/components/Toolbar.js +106 -2
  52. package/components/WindowManager.js +178 -2
  53. package/components/map/OlLayer.js +257 -6
  54. package/components/map/OlMap.js +405 -5
  55. package/components/map/layers/BingLayer.js +31 -2
  56. package/components/map/layers/GoogleLayer.js +222 -19
  57. package/components/map/layers/GraticuleLayer.js +21 -1
  58. package/components/map/layers/ImageLayer.js +15 -1
  59. package/components/map/layers/MVTLayer.js +52 -2
  60. package/components/map/layers/OSMLayer.js +24 -2
  61. package/components/map/layers/OverlayLayer.js +55 -3
  62. package/components/map/layers/VectorLayer.js +173 -8
  63. package/components/map/layers/WFSLayer.js +220 -6
  64. package/components/map/layers/WMSLayer.js +180 -6
  65. package/components/map/layers/WMTSLayer.js +67 -3
  66. package/components/map/layers/XYZLayer.js +24 -2
  67. package/components/map/layers/index.js +28 -1
  68. package/components/map3d/EditDataset3D.js +190 -3
  69. package/components/map3d/HeightProfile3D.js +402 -3
  70. package/components/map3d/ImportObjects3D.js +162 -2
  71. package/components/map3d/Map3D.js +1304 -38
  72. package/components/map3d/MapControls3D.js +392 -7
  73. package/components/map3d/SearchField3D.js +183 -11
  74. package/components/map3d/View3DSwitcher.js +98 -2
  75. package/components/map3d/drawtool/CreateTool3D.js +174 -4
  76. package/components/map3d/drawtool/EditTool3D.js +590 -6
  77. package/components/map3d/drawtool/NumericInput3D.js +336 -4
  78. package/components/map3d/layers/GeoTIFFLayer3D.js +15 -1
  79. package/components/map3d/layers/VectorLayer3D.js +53 -2
  80. package/components/map3d/layers/WFSLayer3D.js +109 -3
  81. package/components/map3d/layers/WMSLayer3D.js +70 -2
  82. package/components/map3d/layers/WMTSLayer3D.js +27 -3
  83. package/components/map3d/layers/index.js +14 -1
  84. package/components/map3d/utils/FirstPersonControls3D.js +423 -16
  85. package/components/map3d/utils/MiscUtils3D.js +221 -13
  86. package/components/map3d/utils/OrbitControls3D.js +176 -5
  87. package/components/map3d/utils/Tiles3DStyle.js +238 -9
  88. package/components/share/ShareLink.js +54 -2
  89. package/components/share/ShareQRCode.js +62 -2
  90. package/components/share/ShareSocials.js +125 -3
  91. package/components/timeline/FixedTimeline.js +236 -5
  92. package/components/timeline/InfiniteTimeline.js +347 -8
  93. package/components/timeline/TimelineFeaturesSlider.js +439 -5
  94. package/components/widgets/AccordeonWidget.js +96 -2
  95. package/components/widgets/ButtonBar.js +124 -2
  96. package/components/widgets/ColorButton.js +201 -3
  97. package/components/widgets/ComboBox.js +166 -2
  98. package/components/widgets/CopyButton.js +110 -2
  99. package/components/widgets/DateTimeInput.js +100 -3
  100. package/components/widgets/EditableSelect.js +230 -3
  101. package/components/widgets/FileSelector.js +128 -4
  102. package/components/widgets/Input.js +124 -2
  103. package/components/widgets/InputContainer.js +96 -2
  104. package/components/widgets/LayerCatalogWidget.js +219 -3
  105. package/components/widgets/MenuButton.js +157 -1
  106. package/components/widgets/ModalDialog.js +64 -2
  107. package/components/widgets/NavBar.js +119 -2
  108. package/components/widgets/NumberInput.js +226 -4
  109. package/components/widgets/PopupMenu.js +72 -1
  110. package/components/widgets/Primitives.js +6 -1
  111. package/components/widgets/ReCaptchaWidget.js +55 -1
  112. package/components/widgets/SearchWidget.js +255 -2
  113. package/components/widgets/Spinner.js +44 -2
  114. package/components/widgets/SuggestionInput.js +77 -2
  115. package/components/widgets/TextInput.js +308 -2
  116. package/components/widgets/ToggleSwitch.js +85 -2
  117. package/components/widgets/VectorLayerPicker.js +85 -3
  118. package/libs/openlayers.js +225 -5
  119. package/package.json +1 -1
  120. package/plugins/API.js +358 -15
  121. package/plugins/AttributeTable.js +109 -3
  122. package/plugins/Authentication.js +130 -5
  123. package/plugins/BackgroundSwitcher.js +218 -4
  124. package/plugins/Bookmark.js +289 -3
  125. package/plugins/BottomBar.js +298 -4
  126. package/plugins/CookiePopup.js +67 -3
  127. package/plugins/Cyclomedia.js +442 -5
  128. package/plugins/Editing.js +497 -9
  129. package/plugins/FeatureForm.js +366 -4
  130. package/plugins/FeatureSearch.js +458 -3
  131. package/plugins/GeometryDigitizer.js +664 -7
  132. package/plugins/HeightProfile.js +768 -15
  133. package/plugins/Help.js +102 -3
  134. package/plugins/HomeButton.js +80 -3
  135. package/plugins/Identify.js +543 -5
  136. package/plugins/LayerCatalog.js +215 -4
  137. package/plugins/LayerTree.js +1194 -6
  138. package/plugins/LocateButton.js +94 -3
  139. package/plugins/Map.js +320 -16
  140. package/plugins/MapCompare.js +94 -3
  141. package/plugins/MapCopyright.js +127 -5
  142. package/plugins/MapExport.js +613 -20
  143. package/plugins/MapFilter.js +868 -12
  144. package/plugins/MapInfoTooltip.js +277 -3
  145. package/plugins/MapLegend.js +253 -4
  146. package/plugins/MapTip.js +290 -4
  147. package/plugins/Measure.js +220 -4
  148. package/plugins/NewsPopup.js +137 -3
  149. package/plugins/OverviewMap.js +167 -7
  150. package/plugins/Panoramax.js +340 -2
  151. package/plugins/Portal.js +199 -4
  152. package/plugins/Print.js +1231 -15
  153. package/plugins/Redlining.js +750 -6
  154. package/plugins/Reports.js +332 -3
  155. package/plugins/Routing.js +1278 -15
  156. package/plugins/ScratchDrawing.js +173 -5
  157. package/plugins/Settings.js +241 -4
  158. package/plugins/Share.js +198 -3
  159. package/plugins/StartupMarker.js +84 -4
  160. package/plugins/TaskButton.js +88 -3
  161. package/plugins/ThemeSwitcher.js +164 -4
  162. package/plugins/TimeManager.js +971 -10
  163. package/plugins/TopBar.js +300 -7
  164. package/plugins/TourGuide.js +213 -2
  165. package/plugins/ValueTool.js +419 -4
  166. package/plugins/View3D.js +519 -14
  167. package/plugins/ZoomButtons.js +165 -3
  168. package/plugins/map/EditingSupport.js +199 -7
  169. package/plugins/map/LocateSupport.js +260 -4
  170. package/plugins/map/MeasurementSupport.js +216 -8
  171. package/plugins/map/RedliningPickSupport.js +201 -7
  172. package/plugins/map/RedliningSupport.js +726 -17
  173. package/plugins/map/SnapInteraction.js +101 -1
  174. package/plugins/map/SnapSupport.js +210 -2
  175. package/plugins/map/SnappingSupport.js +356 -17
  176. package/plugins/map3d/BackgroundSwitcher3D.js +44 -3
  177. package/plugins/map3d/BottomBar3D.js +118 -3
  178. package/plugins/map3d/Compare3D.js +422 -8
  179. package/plugins/map3d/Draw3D.js +353 -6
  180. package/plugins/map3d/ExportObjects3D.js +393 -18
  181. package/plugins/map3d/HideObjects3D.js +313 -12
  182. package/plugins/map3d/Identify3D.js +283 -12
  183. package/plugins/map3d/LayerTree3D.js +323 -3
  184. package/plugins/map3d/MapCopyright3D.js +128 -5
  185. package/plugins/map3d/MapExport3D.js +590 -10
  186. package/plugins/map3d/MapLight3D.js +553 -6
  187. package/plugins/map3d/Measure3D.js +571 -20
  188. package/plugins/map3d/OverviewMap3D.js +169 -3
  189. package/plugins/map3d/Settings3D.js +73 -3
  190. package/plugins/map3d/TopBar3D.js +207 -9
  191. package/plugins/redlining/RedliningBufferSupport.js +206 -3
  192. package/reducers/display.js +34 -2
  193. package/reducers/editing.js +68 -3
  194. package/reducers/index.js +9 -1
  195. package/reducers/layerinfo.js +26 -2
  196. package/reducers/layers.js +456 -9
  197. package/reducers/localConfig.js +122 -2
  198. package/reducers/locale.js +38 -2
  199. package/reducers/locate.js +40 -2
  200. package/reducers/map.js +176 -5
  201. package/reducers/measurement.js +42 -2
  202. package/reducers/processNotifications.js +49 -2
  203. package/reducers/redlining.js +50 -2
  204. package/reducers/redliningPick.js +27 -2
  205. package/reducers/search.js +20 -1
  206. package/reducers/serviceinfo.js +25 -2
  207. package/reducers/task.js +45 -2
  208. package/reducers/theme.js +51 -2
  209. package/reducers/windows.js +203 -2
  210. package/scripts/dist.sh +1 -1
  211. package/scripts/gen-plugin-docs.js +152 -2
  212. package/scripts/makeIconkit.js +85 -6
  213. package/scripts/themesConfig.js +742 -40
  214. package/scripts/updateTranslations.js +251 -10
  215. package/selectors/searchproviders.js +44 -2
  216. package/stores/StandardStore.js +42 -2
  217. package/utils/ConfigUtils.js +84 -3
  218. package/utils/CoordinatesUtils.js +234 -23
  219. package/utils/DxfUtils.js +237 -11
  220. package/utils/EditingInterface.js +421 -87
  221. package/utils/EditingUtils.js +357 -13
  222. package/utils/ElevationInterface.js +83 -22
  223. package/utils/FeatureStyles.js +429 -5
  224. package/utils/IdentifyUtils.js +443 -7
  225. package/utils/ImageEditor.js +79 -9
  226. package/utils/LayerUtils.js +1516 -50
  227. package/utils/LocaleUtils.js +117 -7
  228. package/utils/MapUtils.js +241 -59
  229. package/utils/MeasureUtils.js +323 -2
  230. package/utils/MiscUtils.js +189 -11
  231. package/utils/PermaLinkUtils.js +429 -6
  232. package/utils/PluginStore.js +27 -1
  233. package/utils/ResourceRegistry.js +15 -1
  234. package/utils/RoutingInterface.js +307 -7
  235. package/utils/SearchProviders.js +722 -19
  236. package/utils/ServiceLayerUtils.js +669 -14
  237. package/utils/Signal.js +32 -2
  238. package/utils/ThemeUtils.js +341 -7
  239. package/utils/VectorLayerUtils.js +589 -15
  240. package/utils/expr_grammar/grammar.js +2239 -2
  241. package/utils/expr_grammar/test.js +65 -3
@@ -1,12 +1,312 @@
1
- function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}/**
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
5
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
6
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
7
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
8
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ /**
2
14
  * Copyright 2024 Sourcepole AG
3
15
  * All rights reserved.
4
16
  *
5
17
  * This source code is licensed under the BSD-style license found in the
6
18
  * LICENSE file in the root directory of this source tree.
7
- */import axios from"axios";import{v4 as uuidv4}from"uuid";import ConfigUtils from"./ConfigUtils";import LocaleUtils from"./LocaleUtils";import VectorLayerUtils from"./VectorLayerUtils";var ValhallaSession={reqId:null,pending:0,result:null,clear:function clear(){ValhallaSession.reqId=null;ValhallaSession.pending=0;ValhallaSession.result=null}};function decodeShape(str){var precision=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var index=0;var lat=0;var lng=0;var coordinates=[];var shift=0;var result=0;var _byte=null;var latitudeChange;var longitudeChange;var factor=Math.pow(10,precision||6);// Coordinates have variable length when encoded, so just keep
8
- // track of whether we've hit the end of the string. In each
9
- // loop iteration, a single coordinate is decoded.
10
- while(index<str.length){// Reset shift, result, and byte
11
- _byte=null;shift=0;result=0;do{_byte=str.charCodeAt(index++)-63;result|=(_byte&31)<<shift;shift+=5}while(_byte>=32);latitudeChange=result&1?~(result>>1):result>>1;shift=result=0;do{_byte=str.charCodeAt(index++)-63;result|=(_byte&31)<<shift;shift+=5}while(_byte>=32);longitudeChange=result&1?~(result>>1):result>>1;lat+=latitudeChange;lng+=longitudeChange;coordinates.push([lng/factor,lat/factor])}return coordinates}function getValhallaParams(costing,locations,options,extraOptions){var costingOptions={};if(costing==="auto"){costingOptions.auto={top_speed:options.maxSpeed,shortest:options.method==="shortest",use_ferry:options.useFerries?1:0,use_tolls:options.useTollways?1:0,use_highways:options.useHighways?1:0}}else if(costing==="heavyvehicle"){costing="truck";costingOptions.truck={top_speed:options.maxSpeed,shortest:options.method==="shortest",use_ferry:options.useFerries?1:0,use_tolls:options.useTollways?1:0,use_highways:options.useHighways?1:0}}else if(costing==="transit"){costing="multimodal";var timepointMap={now:0,leaveat:1,arriveat:2};extraOptions.date_time={value:options.time.slice(0,16),type:timepointMap[options.timepoint]}}else if(costing==="bicycle"){costingOptions.bicycle={cycling_speed:options.maxSpeed,shortest:options.method==="shortest",use_ferry:options.useFerries?1:0}}else if(costing==="pedestrian"){costingOptions.pedestrian={walking_speed:options.maxSpeed,shortest:options.method==="shortest",use_ferry:options.useFerries?1:0}}var payload=_objectSpread({costing:costing,costing_options:costingOptions,exclude_polygons:options.exclude_polygons||[],locations:locations.map(function(loc){return{lon:loc[0],lat:loc[1]}}),directions_options:{units:"kilometers",language:LocaleUtils.lang()}},extraOptions);return{json:JSON.stringify(payload)}}function computeRoute(costing,locations,options,callback){var extraOptions={id:"valhalla_directions"};var params=getValhallaParams(costing,locations,options,extraOptions);var serviceUrl=ConfigUtils.getConfigProp("routingServiceUrl").replace(/\/$/,"");var endpoint=options.optimized_route?"optimized_route":"route";axios.get(serviceUrl+"/"+endpoint,{params:params}).then(function(response){if(!response.data||!response.data.trip){callback(false,{errorMsgId:LocaleUtils.trmsg("routing.computefailed")});return}var trip=response.data.trip;if(trip.status!==0){callback(false,response.data.trip.status_message)}// https://valhalla.github.io/valhalla/api/turn-by-turn/api-reference/
12
- var travelTypeMap={car:{icon:"routing-car",color:[0,0,255,1]},tractor_trailer:{icon:"routing-truck",color:[0,0,255,1]},foot:{icon:"routing-walking",color:[127,127,255,1]},road:{icon:"routing-bicycle",color:[0,127,0,1]},tram:{icon:"routing-tram",color:[255,0,0,1]},metro:{icon:"routing-tram",color:[255,0,0,1]},rail:{icon:"routing-train",color:[255,0,0,1]},bus:{icon:"routing-bus",color:[255,0,0,1]},ferry:{icon:"routing-ship",color:[0,0,200,1]},cable_car:{icon:"routing-cablecar",color:[255,0,0,1]},gondola:{icon:"routing-cablecar",color:[255,0,0,1]},funicular:{icon:"routing-cablecar",color:[255,0,0,1]}};var result={legs:trip.legs.map(function(leg){return{coordinates:decodeShape(leg.shape),time:leg.summary.time,length:leg.summary.length*1000,maneuvers:leg.maneuvers.map(function(entry){return{instruction:entry.instruction,post_instruction:entry.verbal_post_transition_instruction,geom_indices:[entry.begin_shape_index,entry.end_shape_index],icon:(travelTypeMap[entry.travel_type]||{}).icon||"routing",color:(travelTypeMap[entry.travel_type]||{}).color||"#0000FF",time:entry.time,length:entry.length*1000}})}}),locations:trip.locations.map(function(location){return{lat:location.lat,lon:location.lon,orig_idx:location.original_index}}),summary:{bounds:[trip.summary.min_lon,trip.summary.min_lat,trip.summary.max_lon,trip.summary.max_lat],time:trip.summary.time,length:trip.summary.length*1000}};callback(true,result)})["catch"](function(e){var error=((e.response||{}).data||{}).error;var data={};if(error){data.error=error}else{data.errorMsgId=LocaleUtils.trmsg("routing.computefailed")}callback(false,data)})}function computeIsochrone(costing,locations,contourOptions,options,callback){var extraOptions={contours:contourOptions.intervals.map(function(entry){return _defineProperty({},contourOptions.mode,entry)}),id:"valhalla_isochrone"};var serviceUrl=ConfigUtils.getConfigProp("routingServiceUrl").replace(/\/$/,"");var reqId=uuidv4();ValhallaSession.reqId=reqId;ValhallaSession.pending=locations.length;locations.forEach(function(location){var params=getValhallaParams(costing,[location],options,extraOptions);axios.get(serviceUrl+"/isochrone",{params:params}).then(function(response){if(reqId!==ValhallaSession.reqId){return}if(!response.data||!response.data.features){ValhallaSession.clear();callback(false,{errorMsgId:LocaleUtils.trmsg("routing.computefailed")});return}ValhallaSession.pending-=1;if(!ValhallaSession.result){ValhallaSession.result=response.data}else{var _ValhallaSession$resu;(_ValhallaSession$resu=ValhallaSession.result.features).push.apply(_ValhallaSession$resu,_toConsumableArray(response.data.features))}if(ValhallaSession.pending===0){var areas=ValhallaSession.result.features.map(function(feature){return feature.geometry.coordinates});callback(true,{areas:areas,bounds:VectorLayerUtils.computeFeatureBBox(ValhallaSession.result)});ValhallaSession.clear()}})["catch"](function(e){ValhallaSession.clear();var error=((e.response||{}).data||{}).error;var data={};if(error){data.error=error}else{data.errorMsgId=LocaleUtils.trmsg("routing.computefailed")}callback(false,data)})})}export default{computeRoute:computeRoute,computeIsochrone:computeIsochrone};
19
+ */
20
+
21
+ import axios from 'axios';
22
+ import { v4 as uuidv4 } from 'uuid';
23
+ import ConfigUtils from './ConfigUtils';
24
+ import LocaleUtils from './LocaleUtils';
25
+ import VectorLayerUtils from './VectorLayerUtils';
26
+ var ValhallaSession = {
27
+ reqId: null,
28
+ pending: 0,
29
+ result: null,
30
+ clear: function clear() {
31
+ ValhallaSession.reqId = null;
32
+ ValhallaSession.pending = 0;
33
+ ValhallaSession.result = null;
34
+ }
35
+ };
36
+ function decodeShape(str) {
37
+ var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
38
+ var index = 0;
39
+ var lat = 0;
40
+ var lng = 0;
41
+ var coordinates = [];
42
+ var shift = 0;
43
+ var result = 0;
44
+ var _byte = null;
45
+ var latitudeChange;
46
+ var longitudeChange;
47
+ var factor = Math.pow(10, precision || 6);
48
+
49
+ // Coordinates have variable length when encoded, so just keep
50
+ // track of whether we've hit the end of the string. In each
51
+ // loop iteration, a single coordinate is decoded.
52
+ while (index < str.length) {
53
+ // Reset shift, result, and byte
54
+ _byte = null;
55
+ shift = 0;
56
+ result = 0;
57
+ do {
58
+ _byte = str.charCodeAt(index++) - 63;
59
+ result |= (_byte & 0x1f) << shift;
60
+ shift += 5;
61
+ } while (_byte >= 0x20);
62
+ latitudeChange = result & 1 ? ~(result >> 1) : result >> 1;
63
+ shift = result = 0;
64
+ do {
65
+ _byte = str.charCodeAt(index++) - 63;
66
+ result |= (_byte & 0x1f) << shift;
67
+ shift += 5;
68
+ } while (_byte >= 0x20);
69
+ longitudeChange = result & 1 ? ~(result >> 1) : result >> 1;
70
+ lat += latitudeChange;
71
+ lng += longitudeChange;
72
+ coordinates.push([lng / factor, lat / factor]);
73
+ }
74
+ return coordinates;
75
+ }
76
+ function getValhallaParams(costing, locations, options, extraOptions) {
77
+ var costingOptions = {};
78
+ if (costing === 'auto') {
79
+ costingOptions.auto = {
80
+ top_speed: options.maxSpeed,
81
+ shortest: options.method === 'shortest',
82
+ use_ferry: options.useFerries ? 1 : 0,
83
+ use_tolls: options.useTollways ? 1 : 0,
84
+ use_highways: options.useHighways ? 1 : 0
85
+ };
86
+ } else if (costing === 'heavyvehicle') {
87
+ costing = 'truck';
88
+ costingOptions.truck = {
89
+ top_speed: options.maxSpeed,
90
+ shortest: options.method === 'shortest',
91
+ use_ferry: options.useFerries ? 1 : 0,
92
+ use_tolls: options.useTollways ? 1 : 0,
93
+ use_highways: options.useHighways ? 1 : 0
94
+ };
95
+ } else if (costing === 'transit') {
96
+ costing = 'multimodal';
97
+ var timepointMap = {
98
+ now: 0,
99
+ leaveat: 1,
100
+ arriveat: 2
101
+ };
102
+ extraOptions.date_time = {
103
+ value: options.time.slice(0, 16),
104
+ type: timepointMap[options.timepoint]
105
+ };
106
+ } else if (costing === 'bicycle') {
107
+ costingOptions.bicycle = {
108
+ cycling_speed: options.maxSpeed,
109
+ shortest: options.method === 'shortest',
110
+ use_ferry: options.useFerries ? 1 : 0
111
+ };
112
+ } else if (costing === 'pedestrian') {
113
+ costingOptions.pedestrian = {
114
+ walking_speed: options.maxSpeed,
115
+ shortest: options.method === 'shortest',
116
+ use_ferry: options.useFerries ? 1 : 0
117
+ };
118
+ }
119
+ var payload = _objectSpread({
120
+ costing: costing,
121
+ costing_options: costingOptions,
122
+ exclude_polygons: options.exclude_polygons || [],
123
+ locations: locations.map(function (loc) {
124
+ return {
125
+ lon: loc[0],
126
+ lat: loc[1]
127
+ };
128
+ }),
129
+ directions_options: {
130
+ units: "kilometers",
131
+ language: LocaleUtils.lang()
132
+ }
133
+ }, extraOptions);
134
+ return {
135
+ json: JSON.stringify(payload)
136
+ };
137
+ }
138
+ function computeRoute(costing, locations, options, callback) {
139
+ var extraOptions = {
140
+ id: "valhalla_directions"
141
+ };
142
+ var params = getValhallaParams(costing, locations, options, extraOptions);
143
+ var serviceUrl = ConfigUtils.getConfigProp("routingServiceUrl").replace(/\/$/, '');
144
+ var endpoint = options.optimized_route ? 'optimized_route' : 'route';
145
+ axios.get(serviceUrl + '/' + endpoint, {
146
+ params: params
147
+ }).then(function (response) {
148
+ if (!response.data || !response.data.trip) {
149
+ callback(false, {
150
+ errorMsgId: LocaleUtils.trmsg("routing.computefailed")
151
+ });
152
+ return;
153
+ }
154
+ var trip = response.data.trip;
155
+ if (trip.status !== 0) {
156
+ callback(false, response.data.trip.status_message);
157
+ }
158
+ // https://valhalla.github.io/valhalla/api/turn-by-turn/api-reference/
159
+ var travelTypeMap = {
160
+ car: {
161
+ icon: "routing-car",
162
+ color: [0, 0, 255, 1]
163
+ },
164
+ tractor_trailer: {
165
+ icon: "routing-truck",
166
+ color: [0, 0, 255, 1]
167
+ },
168
+ foot: {
169
+ icon: "routing-walking",
170
+ color: [127, 127, 255, 1]
171
+ },
172
+ road: {
173
+ icon: "routing-bicycle",
174
+ color: [0, 127, 0, 1]
175
+ },
176
+ tram: {
177
+ icon: "routing-tram",
178
+ color: [255, 0, 0, 1]
179
+ },
180
+ metro: {
181
+ icon: "routing-tram",
182
+ color: [255, 0, 0, 1]
183
+ },
184
+ rail: {
185
+ icon: "routing-train",
186
+ color: [255, 0, 0, 1]
187
+ },
188
+ bus: {
189
+ icon: "routing-bus",
190
+ color: [255, 0, 0, 1]
191
+ },
192
+ ferry: {
193
+ icon: "routing-ship",
194
+ color: [0, 0, 200, 1]
195
+ },
196
+ cable_car: {
197
+ icon: "routing-cablecar",
198
+ color: [255, 0, 0, 1]
199
+ },
200
+ gondola: {
201
+ icon: "routing-cablecar",
202
+ color: [255, 0, 0, 1]
203
+ },
204
+ funicular: {
205
+ icon: "routing-cablecar",
206
+ color: [255, 0, 0, 1]
207
+ }
208
+ };
209
+ var result = {
210
+ legs: trip.legs.map(function (leg) {
211
+ return {
212
+ coordinates: decodeShape(leg.shape),
213
+ time: leg.summary.time,
214
+ length: leg.summary.length * 1000,
215
+ maneuvers: leg.maneuvers.map(function (entry) {
216
+ return {
217
+ instruction: entry.instruction,
218
+ post_instruction: entry.verbal_post_transition_instruction,
219
+ geom_indices: [entry.begin_shape_index, entry.end_shape_index],
220
+ icon: (travelTypeMap[entry.travel_type] || {}).icon || "routing",
221
+ color: (travelTypeMap[entry.travel_type] || {}).color || "#0000FF",
222
+ time: entry.time,
223
+ length: entry.length * 1000
224
+ };
225
+ })
226
+ };
227
+ }),
228
+ locations: trip.locations.map(function (location) {
229
+ return {
230
+ lat: location.lat,
231
+ lon: location.lon,
232
+ orig_idx: location.original_index
233
+ };
234
+ }),
235
+ summary: {
236
+ bounds: [trip.summary.min_lon, trip.summary.min_lat, trip.summary.max_lon, trip.summary.max_lat],
237
+ time: trip.summary.time,
238
+ length: trip.summary.length * 1000
239
+ }
240
+ };
241
+ callback(true, result);
242
+ })["catch"](function (e) {
243
+ var error = ((e.response || {}).data || {}).error;
244
+ var data = {};
245
+ if (error) {
246
+ data.error = error;
247
+ } else {
248
+ data.errorMsgId = LocaleUtils.trmsg("routing.computefailed");
249
+ }
250
+ callback(false, data);
251
+ });
252
+ }
253
+ function computeIsochrone(costing, locations, contourOptions, options, callback) {
254
+ var extraOptions = {
255
+ contours: contourOptions.intervals.map(function (entry) {
256
+ return _defineProperty({}, contourOptions.mode, entry);
257
+ }),
258
+ id: "valhalla_isochrone"
259
+ };
260
+ var serviceUrl = ConfigUtils.getConfigProp("routingServiceUrl").replace(/\/$/, '');
261
+ var reqId = uuidv4();
262
+ ValhallaSession.reqId = reqId;
263
+ ValhallaSession.pending = locations.length;
264
+ locations.forEach(function (location) {
265
+ var params = getValhallaParams(costing, [location], options, extraOptions);
266
+ axios.get(serviceUrl + '/isochrone', {
267
+ params: params
268
+ }).then(function (response) {
269
+ if (reqId !== ValhallaSession.reqId) {
270
+ return;
271
+ }
272
+ if (!response.data || !response.data.features) {
273
+ ValhallaSession.clear();
274
+ callback(false, {
275
+ errorMsgId: LocaleUtils.trmsg("routing.computefailed")
276
+ });
277
+ return;
278
+ }
279
+ ValhallaSession.pending -= 1;
280
+ if (!ValhallaSession.result) {
281
+ ValhallaSession.result = response.data;
282
+ } else {
283
+ var _ValhallaSession$resu;
284
+ (_ValhallaSession$resu = ValhallaSession.result.features).push.apply(_ValhallaSession$resu, _toConsumableArray(response.data.features));
285
+ }
286
+ if (ValhallaSession.pending === 0) {
287
+ var areas = ValhallaSession.result.features.map(function (feature) {
288
+ return feature.geometry.coordinates;
289
+ });
290
+ callback(true, {
291
+ areas: areas,
292
+ bounds: VectorLayerUtils.computeFeatureBBox(ValhallaSession.result)
293
+ });
294
+ ValhallaSession.clear();
295
+ }
296
+ })["catch"](function (e) {
297
+ ValhallaSession.clear();
298
+ var error = ((e.response || {}).data || {}).error;
299
+ var data = {};
300
+ if (error) {
301
+ data.error = error;
302
+ } else {
303
+ data.errorMsgId = LocaleUtils.trmsg("routing.computefailed");
304
+ }
305
+ callback(false, data);
306
+ });
307
+ });
308
+ }
309
+ export default {
310
+ computeRoute: computeRoute,
311
+ computeIsochrone: computeIsochrone
312
+ };