qwc2 2025.10.13 → 2025.10.14

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 +763 -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,29 +1,240 @@
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 2015 GeoSolutions Sas
3
15
  * Copyright 2016-2024 Sourcepole AG
4
16
  * All rights reserved.
5
17
  *
6
18
  * This source code is licensed under the BSD-style license found in the
7
19
  * LICENSE file in the root directory of this source tree.
8
- */import ol from"openlayers";import Proj4js from"proj4";import ConfigUtils from"./ConfigUtils";import LocaleUtils from"./LocaleUtils";var crsLabels={"EPSG:4326":"WGS 84","EPSG:3857":"WGS 84 / Pseudo Mercator"};var commonEsriWktLookup={"EPSG:4326":"GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]","EPSG:3857":"PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0.0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0]]"};var CoordinatesUtils={setCrsLabels:function setCrsLabels(labels){Object.assign(crsLabels,labels)},getAvailableCRS:function getAvailableCRS(){var crsList={};for(var a in Proj4js.defs){if(Object.prototype.hasOwnProperty.call(Proj4js.defs,a)){crsList[a]={label:crsLabels[a]||a}}}return crsList},getUnits:function getUnits(projection){var proj=ol.proj.get(projection);return proj.getUnits()||"degrees"},getPrecision:function getPrecision(projection){var _precisions$projectio;var precisions=ConfigUtils.getConfigProp("projections").reduce(function(res,entry){var _entry$precision;return _objectSpread(_objectSpread({},res),{},_defineProperty({},entry.code,(_entry$precision=entry.precision)!==null&&_entry$precision!==void 0?_entry$precision:0))},{});return(_precisions$projectio=precisions[projection])!==null&&_precisions$projectio!==void 0?_precisions$projectio:CoordinatesUtils.getUnits(projection)==="degrees"?4:0},getProjectionConfig:function getProjectionConfig(projection){var _config$projection;var config=ConfigUtils.getConfigProp("projections").reduce(function(res,entry){var _entry$format,_entry$addDirection,_entry$swapLonLat;res[entry.code]={format:(_entry$format=entry.format)!==null&&_entry$format!==void 0?_entry$format:"decimal",addDirection:(_entry$addDirection=entry.addDirection)!==null&&_entry$addDirection!==void 0?_entry$addDirection:"none",swapLonLat:(_entry$swapLonLat=entry.swapLonLat)!==null&&_entry$swapLonLat!==void 0?_entry$swapLonLat:false};return res},{});return(_config$projection=config[projection])!==null&&_config$projection!==void 0?_config$projection:{format:"decimal",addDirection:"none",swapLonLat:false}},getAxisOrder:function getAxisOrder(projection){var axis=ol.proj.get(projection).getAxisOrientation();return axis||"enu"},reproject:function reproject(point,source,dest){if(source===dest){return _toConsumableArray(point)}if(source&&dest){var transformed=null;try{transformed=ol.proj.transform(point,source,dest)}catch(e){transformed=[0,0]}return transformed}return null},/**
9
- * Reprojects a bounding box.
10
- *
11
- * @param bbox {array} [minx, miny, maxx, maxy]
12
- * @param source {string} SRS of the given bbox
13
- * @param dest {string} SRS of the returned bbox
14
- *
15
- * @return {array} [minx, miny, maxx, maxy]
16
- */reprojectBbox:function reprojectBbox(bbox,source,dest){if(source===dest){return _toConsumableArray(bbox)}var sw=CoordinatesUtils.reproject([bbox[0],bbox[1]],source,dest);var ne=CoordinatesUtils.reproject([bbox[2],bbox[3]],source,dest);return[].concat(_toConsumableArray(sw),_toConsumableArray(ne))},calculateAzimuth:function calculateAzimuth(p1,p2,pj){var p1proj=CoordinatesUtils.reproject(p1,pj,"EPSG:4326");var p2proj=CoordinatesUtils.reproject(p2,pj,"EPSG:4326");var lon1=p1proj[0]*Math.PI/180;var lat1=p1proj[1]*Math.PI/180;var lon2=p2proj[0]*Math.PI/180;var lat2=p2proj[1]*Math.PI/180;var dLon=lon2-lon1;var y=Math.sin(dLon)*Math.cos(lat2);var x=Math.cos(lat1)*Math.sin(lat2)-Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);var azimuth=(Math.atan2(y,x)*180/Math.PI+360)%360;return azimuth},/**
17
- * Extend an extent given another one
18
- *
19
- * @param extent1 {array} [minx, miny, maxx, maxy]
20
- * @param extent2 {array} [minx, miny, maxx, maxy]
21
- *
22
- * @return {array} [minx, miny, maxx, maxy]
23
- */extendExtent:function extendExtent(extent1,extent2){return[Math.min(extent1[0],extent2[0]),Math.min(extent1[1],extent2[1]),Math.max(extent1[2],extent2[2]),Math.max(extent1[3],extent2[3])]},/**
24
- * Check extent validity
25
- *
26
- * @param extent {array} [minx, miny, maxx, maxy]
27
- *
28
- * @return {bool}
29
- */isValidExtent:function isValidExtent(extent){return extent.length===4&&!(extent.indexOf(Infinity)!==-1||extent.indexOf(-Infinity)!==-1||extent.indexOf(NaN)!==-1||extent[0]>=extent[2]||extent[1]>=extent[3])},fromOgcUrnCrs:function fromOgcUrnCrs(crsStr){if(crsStr.endsWith(":CRS84")){return"EPSG:4326"}var parts=crsStr.split(":");return"EPSG:"+parts.slice(-1)},toOgcUrnCrs:function toOgcUrnCrs(crsStr){var parts=crsStr.split(":");return"urn:ogc:def:crs:"+parts[0]+"::"+parts[1]},getEsriWktFromCrs:function getEsriWktFromCrs(crsStr){var epsgCode=crsStr.startsWith("EPSG:")?crsStr:CoordinatesUtils.fromOgcUrnCrs(crsStr);var projections=ConfigUtils.getConfigProp("projections")||[];var configProjection=projections.find(function(proj){return proj.code===epsgCode});if(configProjection&&configProjection.esriWkt){return configProjection.esriWkt}if(commonEsriWktLookup[epsgCode]){return commonEsriWktLookup[epsgCode]}console.warn("No ESRI WKT definition found for ".concat(epsgCode,". Shapefile export may not include projection information. Consider adding an 'esriWkt' property to the projection in config.json."));return null},getFormattedCoordinate:function getFormattedCoordinate(coo,srcCrs){var _options$decimals;var dstCrs=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var options=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var units=CoordinatesUtils.getUnits(dstCrs!==null&&dstCrs!==void 0?dstCrs:srcCrs);var decimals=(_options$decimals=options.decimals)!==null&&_options$decimals!==void 0?_options$decimals:CoordinatesUtils.getPrecision(dstCrs!==null&&dstCrs!==void 0?dstCrs:srcCrs);var _ref=function(){var config=CoordinatesUtils.getProjectionConfig(dstCrs!==null&&dstCrs!==void 0?dstCrs:srcCrs);return{format:units!=="degrees"?"decimal":config.format,addDirection:config.addDirection,swapLonLat:config.swapLonLat}}(),format=_ref.format,addDirection=_ref.addDirection,swapLonLat=_ref.swapLonLat;if(srcCrs&&dstCrs&&srcCrs!==dstCrs){coo=CoordinatesUtils.reproject(coo,srcCrs,dstCrs)}if(swapLonLat){coo=[coo[1],coo[0]]}var toDMS=function toDMS(coord){var deg=Math.floor(Math.abs(coord));var minFull=(Math.abs(coord)-deg)*60;var min=Math.floor(minFull);var sec=((minFull-min)*60).toFixed(decimals);return"".concat(deg,"\xB0 ").concat(min,"' ").concat(sec,"\"")};var toDM=function toDM(coord){var deg=Math.floor(Math.abs(coord));var min=((Math.abs(coord)-deg)*60).toFixed(decimals);return"".concat(deg,"\xB0 ").concat(min,"'")};var formatCoordinate=function formatCoordinate(value,isLat){var direction="";if(addDirection!=="none"){if(isLat){direction=value>=0?"N":"S"}else{direction=value>=0?"E":"W"}}var formatted;switch(format){case"dms":formatted=toDMS(value,decimals);break;case"dm":formatted=toDM(value,decimals);break;default:formatted=LocaleUtils.toLocaleFixed(Math.abs(value),decimals)}if(addDirection==="prefix"){return"".concat(direction).concat(formatted)}else if(addDirection==="suffix"){return"".concat(formatted).concat(direction)}return formatted};return coo.map(function(coord,idx){return formatCoordinate(coord,swapLonLat?idx===0:idx===1)}).join(", ")}};export default CoordinatesUtils;
20
+ */
21
+ import ol from 'openlayers';
22
+ import Proj4js from 'proj4';
23
+ import ConfigUtils from './ConfigUtils';
24
+ import LocaleUtils from './LocaleUtils';
25
+ var crsLabels = {
26
+ "EPSG:4326": "WGS 84",
27
+ "EPSG:3857": "WGS 84 / Pseudo Mercator"
28
+ };
29
+ var commonEsriWktLookup = {
30
+ "EPSG:4326": 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]',
31
+ "EPSG:3857": 'PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]'
32
+ };
33
+ var CoordinatesUtils = {
34
+ setCrsLabels: function setCrsLabels(labels) {
35
+ Object.assign(crsLabels, labels);
36
+ },
37
+ getAvailableCRS: function getAvailableCRS() {
38
+ var crsList = {};
39
+ for (var a in Proj4js.defs) {
40
+ if (Object.prototype.hasOwnProperty.call(Proj4js.defs, a)) {
41
+ crsList[a] = {
42
+ label: crsLabels[a] || a
43
+ };
44
+ }
45
+ }
46
+ return crsList;
47
+ },
48
+ getUnits: function getUnits(projection) {
49
+ var proj = ol.proj.get(projection);
50
+ return proj.getUnits() || 'degrees';
51
+ },
52
+ getPrecision: function getPrecision(projection) {
53
+ var _precisions$projectio;
54
+ var precisions = ConfigUtils.getConfigProp("projections").reduce(function (res, entry) {
55
+ var _entry$precision;
56
+ return _objectSpread(_objectSpread({}, res), {}, _defineProperty({}, entry.code, (_entry$precision = entry.precision) !== null && _entry$precision !== void 0 ? _entry$precision : 0));
57
+ }, {});
58
+ return (_precisions$projectio = precisions[projection]) !== null && _precisions$projectio !== void 0 ? _precisions$projectio : CoordinatesUtils.getUnits(projection) === 'degrees' ? 4 : 0;
59
+ },
60
+ getProjectionConfig: function getProjectionConfig(projection) {
61
+ var _config$projection;
62
+ var config = ConfigUtils.getConfigProp("projections").reduce(function (res, entry) {
63
+ var _entry$format, _entry$addDirection, _entry$swapLonLat;
64
+ res[entry.code] = {
65
+ format: (_entry$format = entry.format) !== null && _entry$format !== void 0 ? _entry$format : 'decimal',
66
+ addDirection: (_entry$addDirection = entry.addDirection) !== null && _entry$addDirection !== void 0 ? _entry$addDirection : 'none',
67
+ swapLonLat: (_entry$swapLonLat = entry.swapLonLat) !== null && _entry$swapLonLat !== void 0 ? _entry$swapLonLat : false
68
+ };
69
+ return res;
70
+ }, {});
71
+ return (_config$projection = config[projection]) !== null && _config$projection !== void 0 ? _config$projection : {
72
+ format: 'decimal',
73
+ addDirection: 'none',
74
+ swapLonLat: false
75
+ };
76
+ },
77
+ getAxisOrder: function getAxisOrder(projection) {
78
+ var axis = ol.proj.get(projection).getAxisOrientation();
79
+ return axis || 'enu';
80
+ },
81
+ reproject: function reproject(point, source, dest) {
82
+ if (source === dest) {
83
+ return _toConsumableArray(point);
84
+ }
85
+ if (source && dest) {
86
+ var transformed = null;
87
+ try {
88
+ transformed = ol.proj.transform(point, source, dest);
89
+ } catch (e) {
90
+ transformed = [0, 0];
91
+ }
92
+ return transformed;
93
+ }
94
+ return null;
95
+ },
96
+ /**
97
+ * Reprojects a bounding box.
98
+ *
99
+ * @param bbox {array} [minx, miny, maxx, maxy]
100
+ * @param source {string} SRS of the given bbox
101
+ * @param dest {string} SRS of the returned bbox
102
+ *
103
+ * @return {array} [minx, miny, maxx, maxy]
104
+ */
105
+ reprojectBbox: function reprojectBbox(bbox, source, dest) {
106
+ if (source === dest) {
107
+ return _toConsumableArray(bbox);
108
+ }
109
+ var sw = CoordinatesUtils.reproject([bbox[0], bbox[1]], source, dest);
110
+ var ne = CoordinatesUtils.reproject([bbox[2], bbox[3]], source, dest);
111
+ return [].concat(_toConsumableArray(sw), _toConsumableArray(ne));
112
+ },
113
+ calculateAzimuth: function calculateAzimuth(p1, p2, pj) {
114
+ var p1proj = CoordinatesUtils.reproject(p1, pj, 'EPSG:4326');
115
+ var p2proj = CoordinatesUtils.reproject(p2, pj, 'EPSG:4326');
116
+ var lon1 = p1proj[0] * Math.PI / 180.0;
117
+ var lat1 = p1proj[1] * Math.PI / 180.0;
118
+ var lon2 = p2proj[0] * Math.PI / 180.0;
119
+ var lat2 = p2proj[1] * Math.PI / 180.0;
120
+ var dLon = lon2 - lon1;
121
+ var y = Math.sin(dLon) * Math.cos(lat2);
122
+ var x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);
123
+ var azimuth = (Math.atan2(y, x) * 180.0 / Math.PI + 360) % 360;
124
+ return azimuth;
125
+ },
126
+ /**
127
+ * Extend an extent given another one
128
+ *
129
+ * @param extent1 {array} [minx, miny, maxx, maxy]
130
+ * @param extent2 {array} [minx, miny, maxx, maxy]
131
+ *
132
+ * @return {array} [minx, miny, maxx, maxy]
133
+ */
134
+ extendExtent: function extendExtent(extent1, extent2) {
135
+ return [Math.min(extent1[0], extent2[0]), Math.min(extent1[1], extent2[1]), Math.max(extent1[2], extent2[2]), Math.max(extent1[3], extent2[3])];
136
+ },
137
+ /**
138
+ * Check extent validity
139
+ *
140
+ * @param extent {array} [minx, miny, maxx, maxy]
141
+ *
142
+ * @return {bool}
143
+ */
144
+ isValidExtent: function isValidExtent(extent) {
145
+ return extent.length === 4 && !(extent.indexOf(Infinity) !== -1 || extent.indexOf(-Infinity) !== -1 || extent.indexOf(NaN) !== -1 || extent[0] >= extent[2] || extent[1] >= extent[3]);
146
+ },
147
+ fromOgcUrnCrs: function fromOgcUrnCrs(crsStr) {
148
+ if (crsStr.endsWith(":CRS84")) {
149
+ return "EPSG:4326";
150
+ }
151
+ var parts = crsStr.split(":");
152
+ return "EPSG:" + parts.slice(-1);
153
+ },
154
+ toOgcUrnCrs: function toOgcUrnCrs(crsStr) {
155
+ var parts = crsStr.split(":");
156
+ return "urn:ogc:def:crs:" + parts[0] + "::" + parts[1];
157
+ },
158
+ getEsriWktFromCrs: function getEsriWktFromCrs(crsStr) {
159
+ var epsgCode = crsStr.startsWith("EPSG:") ? crsStr : CoordinatesUtils.fromOgcUrnCrs(crsStr);
160
+ var projections = ConfigUtils.getConfigProp("projections") || [];
161
+ var configProjection = projections.find(function (proj) {
162
+ return proj.code === epsgCode;
163
+ });
164
+ if (configProjection && configProjection.esriWkt) {
165
+ return configProjection.esriWkt;
166
+ }
167
+ if (commonEsriWktLookup[epsgCode]) {
168
+ return commonEsriWktLookup[epsgCode];
169
+ }
170
+ console.warn("No ESRI WKT definition found for ".concat(epsgCode, ". Shapefile export may not include projection information. Consider adding an 'esriWkt' property to the projection in config.json."));
171
+ return null;
172
+ },
173
+ getFormattedCoordinate: function getFormattedCoordinate(coo, srcCrs) {
174
+ var _options$decimals;
175
+ var dstCrs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
176
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
177
+ var units = CoordinatesUtils.getUnits(dstCrs !== null && dstCrs !== void 0 ? dstCrs : srcCrs);
178
+ var decimals = (_options$decimals = options.decimals) !== null && _options$decimals !== void 0 ? _options$decimals : CoordinatesUtils.getPrecision(dstCrs !== null && dstCrs !== void 0 ? dstCrs : srcCrs);
179
+ var _ref = function () {
180
+ var config = CoordinatesUtils.getProjectionConfig(dstCrs !== null && dstCrs !== void 0 ? dstCrs : srcCrs);
181
+ return {
182
+ format: units !== 'degrees' ? 'decimal' : config.format,
183
+ addDirection: config.addDirection,
184
+ swapLonLat: config.swapLonLat
185
+ };
186
+ }(),
187
+ format = _ref.format,
188
+ addDirection = _ref.addDirection,
189
+ swapLonLat = _ref.swapLonLat;
190
+ if (srcCrs && dstCrs && srcCrs !== dstCrs) {
191
+ coo = CoordinatesUtils.reproject(coo, srcCrs, dstCrs);
192
+ }
193
+ if (swapLonLat) {
194
+ coo = [coo[1], coo[0]];
195
+ }
196
+ var toDMS = function toDMS(coord) {
197
+ var deg = Math.floor(Math.abs(coord));
198
+ var minFull = (Math.abs(coord) - deg) * 60;
199
+ var min = Math.floor(minFull);
200
+ var sec = ((minFull - min) * 60).toFixed(decimals);
201
+ return "".concat(deg, "\xB0 ").concat(min, "' ").concat(sec, "\"");
202
+ };
203
+ var toDM = function toDM(coord) {
204
+ var deg = Math.floor(Math.abs(coord));
205
+ var min = ((Math.abs(coord) - deg) * 60).toFixed(decimals);
206
+ return "".concat(deg, "\xB0 ").concat(min, "'");
207
+ };
208
+ var formatCoordinate = function formatCoordinate(value, isLat) {
209
+ var direction = '';
210
+ if (addDirection !== 'none') {
211
+ if (isLat) {
212
+ direction = value >= 0 ? 'N' : 'S';
213
+ } else {
214
+ direction = value >= 0 ? 'E' : 'W';
215
+ }
216
+ }
217
+ var formatted;
218
+ switch (format) {
219
+ case 'dms':
220
+ formatted = toDMS(value, decimals);
221
+ break;
222
+ case 'dm':
223
+ formatted = toDM(value, decimals);
224
+ break;
225
+ default:
226
+ formatted = LocaleUtils.toLocaleFixed(Math.abs(value), decimals);
227
+ }
228
+ if (addDirection === 'prefix') {
229
+ return "".concat(direction).concat(formatted);
230
+ } else if (addDirection === 'suffix') {
231
+ return "".concat(formatted).concat(direction);
232
+ }
233
+ return formatted;
234
+ };
235
+ return coo.map(function (coord, idx) {
236
+ return formatCoordinate(coord, swapLonLat ? idx === 0 : idx === 1);
237
+ }).join(", ");
238
+ }
239
+ };
240
+ export default CoordinatesUtils;
package/utils/DxfUtils.js CHANGED
@@ -1,16 +1,242 @@
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 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 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ 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); }
7
+ /**
2
8
  * Copyright 2025 Sourcepole AG
3
9
  * All rights reserved.
4
10
  *
5
11
  * This source code is licensed under the BSD-style license found in the
6
12
  * LICENSE file in the root directory of this source tree.
7
- */var END_MARKERS={SECTION:"ENDSEC",TABLE:"ENDTAB",BLOCK:"ENDBLK"};export function explodeDxf(text){var tuples=text.replace(/\s+$/,"").split(/\r\n|\r|\n/g).flatMap(function(_,i,a){return i%2?[]:[a.slice(i,i+2).map(function(x){return x.trim()})]});var maxHandle=100;// Value in QGIS
8
- var _explode=function explode(pairs){var _toplevelTuples$find;var toplevelTuples=[];var sectionTuples;var marker;var expectEndMarker;var children=pairs.reduce(function(acc,tuple){if(tuple[0]==="5"&&tuple[1]!=="9999999"){maxHandle=Math.max(parseInt(tuple[1],16),maxHandle)}if(tuple[0]==="0"){if(expectEndMarker&&tuple[1]===expectEndMarker){acc.push(_objectSpread({type:marker},_explode(sectionTuples)));sectionTuples=undefined;marker=undefined;expectEndMarker=undefined}else if(expectEndMarker&&tuple[1]!==expectEndMarker){sectionTuples.push(tuple)}else if(!expectEndMarker){if(sectionTuples){acc.push(_objectSpread({type:marker},_explode(sectionTuples)))}sectionTuples=[];marker=tuple[1];expectEndMarker=END_MARKERS[marker]}}else if(sectionTuples){sectionTuples.push(tuple)}else if(acc.length>0){acc[acc.length-1].tailValues.push(tuple)}else{toplevelTuples.push(tuple)}return acc},[]);if(marker&&sectionTuples&&!expectEndMarker){children.push(_objectSpread({type:marker},_explode(sectionTuples)))}var name=(_toplevelTuples$find=toplevelTuples.find(function(tuple){return tuple[0]==="2"}))===null||_toplevelTuples$find===void 0?void 0:_toplevelTuples$find[1];return{name:name,values:toplevelTuples,children:children,tailValues:[]}};var result=_explode(tuples);result.maxHandle=maxHandle;return result}export function implodeDxf(exploded){var output="";var handleSeed=100;var dumpValues=function dumpValues(values){return values.forEach(function(tuple){if(tuple[0]==="5"&&parseInt(tuple[0],16)>=100){output+="5\n".concat((handleSeed++).toString(16),"\n")}else{output+="".concat(tuple[0],"\n").concat(tuple[1],"\n")}})};var _implode=function implode(data){dumpValues(data.values);data.children.forEach(function(child){output+="0\n".concat(child.type,"\n");_implode(child);if(END_MARKERS[child.type]){output+="0\n".concat(END_MARKERS[child.type],"\n")}dumpValues(child.tailValues)})};_implode(exploded);return output}export function mergeDxf(documents){var _mergedBlockRecords$c,_mergedBlockRecords$c2,_mergedBlockRecords$c3;// Merge blockRecords, Blocks, Layers and Entities of dxf documents
9
- var mergedEntities=documents[0].children.find(function(child){return child.type==="SECTION"&&child.name==="ENTITIES"});var mergedLayers=documents[0].children.find(function(child){return child.type==="SECTION"&&child.name==="TABLES"}).children.find(function(child){return child.type==="TABLE"&&child.name==="LAYER"});var mergedBlockRecords=documents[0].children.find(function(child){return child.type==="SECTION"&&child.name==="TABLES"}).children.find(function(child){return child.type==="TABLE"&&child.name==="BLOCK_RECORD"});var mergedBlocks=documents[0].children.find(function(child){return child.type==="SECTION"&&child.name==="BLOCKS"});// Reference the common block handles of the first document in subsequent documents
10
- var commonBlockHandles={"*Model_Space":(_mergedBlockRecords$c=mergedBlockRecords.children.find(function(br){return br.name==="*Model_Space"}))===null||_mergedBlockRecords$c===void 0||(_mergedBlockRecords$c=_mergedBlockRecords$c.values)===null||_mergedBlockRecords$c===void 0||(_mergedBlockRecords$c=_mergedBlockRecords$c.find(function(t){return t[0]==="5"}))===null||_mergedBlockRecords$c===void 0?void 0:_mergedBlockRecords$c[1],"*Paper_Space":(_mergedBlockRecords$c2=mergedBlockRecords.children.find(function(br){return br.name==="*Paper_Space"}))===null||_mergedBlockRecords$c2===void 0||(_mergedBlockRecords$c2=_mergedBlockRecords$c2.values)===null||_mergedBlockRecords$c2===void 0||(_mergedBlockRecords$c2=_mergedBlockRecords$c2.find(function(t){return t[0]==="5"}))===null||_mergedBlockRecords$c2===void 0?void 0:_mergedBlockRecords$c2[1],"*Paper_Space0":(_mergedBlockRecords$c3=mergedBlockRecords.children.find(function(br){return br.name==="*Paper_Space0"}))===null||_mergedBlockRecords$c3===void 0||(_mergedBlockRecords$c3=_mergedBlockRecords$c3.values)===null||_mergedBlockRecords$c3===void 0||(_mergedBlockRecords$c3=_mergedBlockRecords$c3.find(function(t){return t[0]==="5"}))===null||_mergedBlockRecords$c3===void 0?void 0:_mergedBlockRecords$c3[1]};var maxHandle=documents[0].maxHandle;documents.slice(1).forEach(function(document){// Get items to merge
11
- var entities=document.children.find(function(child){return child.type==="SECTION"&&child.name==="ENTITIES"});var layers=document.children.find(function(child){return child.type==="SECTION"&&child.name==="TABLES"}).children.find(function(child){return child.type==="TABLE"&&child.name==="LAYER"});var blockRecords=document.children.find(function(child){return child.type==="SECTION"&&child.name==="TABLES"}).children.find(function(child){return child.type==="TABLE"&&child.name==="BLOCK_RECORD"});var blocks=document.children.find(function(child){return child.type==="SECTION"&&child.name==="BLOCKS"});var handleMapping={};// Merge items, adjusting handles as necessary to avoid conflicting handles
12
- blockRecords.children.forEach(function(blockRecord){var handleTuple=blockRecord.values.find(function(tuple){return tuple[0]==="5"});if(["*Model_Space","*Paper_Space","*Paper_Space0"].includes(blockRecord.name)){handleMapping[handleTuple[1]]=commonBlockHandles[blockRecord.name]}else{var newHandle=(++maxHandle).toString(16);handleMapping[handleTuple[1]]=newHandle;handleTuple[1]=newHandle;mergedBlockRecords.children.push(blockRecord)}});blocks.children.forEach(function(block){// Note: Don't merge common blocks
13
- if(!["*Model_Space","*Paper_Space","*Paper_Space0"].includes(block.name)){var handleRefTuple=block.values.find(function(tuple){return tuple[0]==="330"});if(handleRefTuple){handleRefTuple[1]=handleMapping[handleRefTuple[1]]}block.values.find(function(tuple){return tuple[0]==="5"})[1]=(++maxHandle).toString(16);mergedBlocks.children.push(block)}});layers.children.forEach(function(layer){// Note: Don't merge dummy layer 0
14
- if(layer.name!=="0"){layer.values.find(function(tuple){return tuple[0]==="5"})[1]=(++maxHandle).toString(16);mergedLayers.children.push(layer)}});entities.children.forEach(function(entity){var handleRefTuple=entity.values.find(function(tuple){return tuple[0]==="330"});if(handleRefTuple){handleRefTuple[1]=handleMapping[handleRefTuple[1]]}var handleTuple=entity.values.find(function(tuple){return tuple[0]==="5"});var newHandle=(++maxHandle).toString(16);handleMapping[handleTuple[1]]=newHandle;handleTuple[1]=newHandle;// VERTEX, SEQEND
15
- entity.children.forEach(function(child){child.values.find(function(tuple){return tuple[0]==="5"})[1]=(++maxHandle).toString(16);var childHandleRefTuple=child.values.find(function(tuple){return tuple[0]==="330"});if(childHandleRefTuple){childHandleRefTuple[1]=handleMapping[childHandleRefTuple[1]]}});mergedEntities.children.push(entity)})});// Update layer count
16
- mergedLayers.values.find(function(tuple){return tuple[0]==="70"})[1]=String(mergedLayers.children.length);return documents[0]}
13
+ */
14
+
15
+ var END_MARKERS = {
16
+ SECTION: 'ENDSEC',
17
+ TABLE: 'ENDTAB',
18
+ BLOCK: 'ENDBLK'
19
+ };
20
+ export function explodeDxf(text) {
21
+ var tuples = text.replace(/\s+$/, '').split(/\r\n|\r|\n/g).flatMap(function (_, i, a) {
22
+ return i % 2 ? [] : [a.slice(i, i + 2).map(function (x) {
23
+ return x.trim();
24
+ })];
25
+ });
26
+ var maxHandle = 100; // Value in QGIS
27
+
28
+ var _explode = function explode(pairs) {
29
+ var _toplevelTuples$find;
30
+ var toplevelTuples = [];
31
+ var sectionTuples;
32
+ var marker;
33
+ var expectEndMarker;
34
+ var children = pairs.reduce(function (acc, tuple) {
35
+ if (tuple[0] === '5' && tuple[1] !== '9999999') {
36
+ maxHandle = Math.max(parseInt(tuple[1], 16), maxHandle);
37
+ }
38
+ if (tuple[0] === '0') {
39
+ if (expectEndMarker && tuple[1] === expectEndMarker) {
40
+ acc.push(_objectSpread({
41
+ type: marker
42
+ }, _explode(sectionTuples)));
43
+ sectionTuples = undefined;
44
+ marker = undefined;
45
+ expectEndMarker = undefined;
46
+ } else if (expectEndMarker && tuple[1] !== expectEndMarker) {
47
+ sectionTuples.push(tuple);
48
+ } else if (!expectEndMarker) {
49
+ if (sectionTuples) {
50
+ acc.push(_objectSpread({
51
+ type: marker
52
+ }, _explode(sectionTuples)));
53
+ }
54
+ sectionTuples = [];
55
+ marker = tuple[1];
56
+ expectEndMarker = END_MARKERS[marker];
57
+ }
58
+ } else if (sectionTuples) {
59
+ sectionTuples.push(tuple);
60
+ } else if (acc.length > 0) {
61
+ acc[acc.length - 1].tailValues.push(tuple);
62
+ } else {
63
+ toplevelTuples.push(tuple);
64
+ }
65
+ return acc;
66
+ }, []);
67
+ if (marker && sectionTuples && !expectEndMarker) {
68
+ children.push(_objectSpread({
69
+ type: marker
70
+ }, _explode(sectionTuples)));
71
+ }
72
+ var name = (_toplevelTuples$find = toplevelTuples.find(function (tuple) {
73
+ return tuple[0] === '2';
74
+ })) === null || _toplevelTuples$find === void 0 ? void 0 : _toplevelTuples$find[1];
75
+ return {
76
+ name: name,
77
+ values: toplevelTuples,
78
+ children: children,
79
+ tailValues: []
80
+ };
81
+ };
82
+ var result = _explode(tuples);
83
+ result.maxHandle = maxHandle;
84
+ return result;
85
+ }
86
+ export function implodeDxf(exploded) {
87
+ var output = "";
88
+ var handleSeed = 100;
89
+ var dumpValues = function dumpValues(values) {
90
+ return values.forEach(function (tuple) {
91
+ if (tuple[0] === '5' && parseInt(tuple[0], 16) >= 100) {
92
+ output += "5\n".concat((handleSeed++).toString(16), "\n");
93
+ } else {
94
+ output += "".concat(tuple[0], "\n").concat(tuple[1], "\n");
95
+ }
96
+ });
97
+ };
98
+ var _implode = function implode(data) {
99
+ dumpValues(data.values);
100
+ data.children.forEach(function (child) {
101
+ output += "0\n".concat(child.type, "\n");
102
+ _implode(child);
103
+ if (END_MARKERS[child.type]) {
104
+ output += "0\n".concat(END_MARKERS[child.type], "\n");
105
+ }
106
+ dumpValues(child.tailValues);
107
+ });
108
+ };
109
+ _implode(exploded);
110
+ return output;
111
+ }
112
+ export function mergeDxf(documents) {
113
+ var _mergedBlockRecords$c, _mergedBlockRecords$c2, _mergedBlockRecords$c3;
114
+ // Merge blockRecords, Blocks, Layers and Entities of dxf documents
115
+ var mergedEntities = documents[0].children.find(function (child) {
116
+ return child.type === 'SECTION' && child.name === 'ENTITIES';
117
+ });
118
+ var mergedLayers = documents[0].children.find(function (child) {
119
+ return child.type === 'SECTION' && child.name === 'TABLES';
120
+ }).children.find(function (child) {
121
+ return child.type === 'TABLE' && child.name === 'LAYER';
122
+ });
123
+ var mergedBlockRecords = documents[0].children.find(function (child) {
124
+ return child.type === 'SECTION' && child.name === 'TABLES';
125
+ }).children.find(function (child) {
126
+ return child.type === 'TABLE' && child.name === 'BLOCK_RECORD';
127
+ });
128
+ var mergedBlocks = documents[0].children.find(function (child) {
129
+ return child.type === 'SECTION' && child.name === 'BLOCKS';
130
+ });
131
+ // Reference the common block handles of the first document in subsequent documents
132
+ var commonBlockHandles = {
133
+ "*Model_Space": (_mergedBlockRecords$c = mergedBlockRecords.children.find(function (br) {
134
+ return br.name === "*Model_Space";
135
+ })) === null || _mergedBlockRecords$c === void 0 || (_mergedBlockRecords$c = _mergedBlockRecords$c.values) === null || _mergedBlockRecords$c === void 0 || (_mergedBlockRecords$c = _mergedBlockRecords$c.find(function (t) {
136
+ return t[0] === "5";
137
+ })) === null || _mergedBlockRecords$c === void 0 ? void 0 : _mergedBlockRecords$c[1],
138
+ "*Paper_Space": (_mergedBlockRecords$c2 = mergedBlockRecords.children.find(function (br) {
139
+ return br.name === "*Paper_Space";
140
+ })) === null || _mergedBlockRecords$c2 === void 0 || (_mergedBlockRecords$c2 = _mergedBlockRecords$c2.values) === null || _mergedBlockRecords$c2 === void 0 || (_mergedBlockRecords$c2 = _mergedBlockRecords$c2.find(function (t) {
141
+ return t[0] === "5";
142
+ })) === null || _mergedBlockRecords$c2 === void 0 ? void 0 : _mergedBlockRecords$c2[1],
143
+ "*Paper_Space0": (_mergedBlockRecords$c3 = mergedBlockRecords.children.find(function (br) {
144
+ return br.name === "*Paper_Space0";
145
+ })) === null || _mergedBlockRecords$c3 === void 0 || (_mergedBlockRecords$c3 = _mergedBlockRecords$c3.values) === null || _mergedBlockRecords$c3 === void 0 || (_mergedBlockRecords$c3 = _mergedBlockRecords$c3.find(function (t) {
146
+ return t[0] === "5";
147
+ })) === null || _mergedBlockRecords$c3 === void 0 ? void 0 : _mergedBlockRecords$c3[1]
148
+ };
149
+ var maxHandle = documents[0].maxHandle;
150
+ documents.slice(1).forEach(function (document) {
151
+ // Get items to merge
152
+ var entities = document.children.find(function (child) {
153
+ return child.type === 'SECTION' && child.name === 'ENTITIES';
154
+ });
155
+ var layers = document.children.find(function (child) {
156
+ return child.type === 'SECTION' && child.name === 'TABLES';
157
+ }).children.find(function (child) {
158
+ return child.type === 'TABLE' && child.name === 'LAYER';
159
+ });
160
+ var blockRecords = document.children.find(function (child) {
161
+ return child.type === 'SECTION' && child.name === 'TABLES';
162
+ }).children.find(function (child) {
163
+ return child.type === 'TABLE' && child.name === 'BLOCK_RECORD';
164
+ });
165
+ var blocks = document.children.find(function (child) {
166
+ return child.type === 'SECTION' && child.name === 'BLOCKS';
167
+ });
168
+ var handleMapping = {};
169
+
170
+ // Merge items, adjusting handles as necessary to avoid conflicting handles
171
+ blockRecords.children.forEach(function (blockRecord) {
172
+ var handleTuple = blockRecord.values.find(function (tuple) {
173
+ return tuple[0] === "5";
174
+ });
175
+ if (["*Model_Space", "*Paper_Space", "*Paper_Space0"].includes(blockRecord.name)) {
176
+ handleMapping[handleTuple[1]] = commonBlockHandles[blockRecord.name];
177
+ } else {
178
+ var newHandle = (++maxHandle).toString(16);
179
+ handleMapping[handleTuple[1]] = newHandle;
180
+ handleTuple[1] = newHandle;
181
+ mergedBlockRecords.children.push(blockRecord);
182
+ }
183
+ });
184
+ blocks.children.forEach(function (block) {
185
+ // Note: Don't merge common blocks
186
+ if (!["*Model_Space", "*Paper_Space", "*Paper_Space0"].includes(block.name)) {
187
+ var handleRefTuple = block.values.find(function (tuple) {
188
+ return tuple[0] === "330";
189
+ });
190
+ if (handleRefTuple) {
191
+ handleRefTuple[1] = handleMapping[handleRefTuple[1]];
192
+ }
193
+ block.values.find(function (tuple) {
194
+ return tuple[0] === "5";
195
+ })[1] = (++maxHandle).toString(16);
196
+ mergedBlocks.children.push(block);
197
+ }
198
+ });
199
+ layers.children.forEach(function (layer) {
200
+ // Note: Don't merge dummy layer 0
201
+ if (layer.name !== '0') {
202
+ layer.values.find(function (tuple) {
203
+ return tuple[0] === "5";
204
+ })[1] = (++maxHandle).toString(16);
205
+ mergedLayers.children.push(layer);
206
+ }
207
+ });
208
+ entities.children.forEach(function (entity) {
209
+ var handleRefTuple = entity.values.find(function (tuple) {
210
+ return tuple[0] === "330";
211
+ });
212
+ if (handleRefTuple) {
213
+ handleRefTuple[1] = handleMapping[handleRefTuple[1]];
214
+ }
215
+ var handleTuple = entity.values.find(function (tuple) {
216
+ return tuple[0] === "5";
217
+ });
218
+ var newHandle = (++maxHandle).toString(16);
219
+ handleMapping[handleTuple[1]] = newHandle;
220
+ handleTuple[1] = newHandle;
221
+ // VERTEX, SEQEND
222
+ entity.children.forEach(function (child) {
223
+ child.values.find(function (tuple) {
224
+ return tuple[0] === "5";
225
+ })[1] = (++maxHandle).toString(16);
226
+ var childHandleRefTuple = child.values.find(function (tuple) {
227
+ return tuple[0] === "330";
228
+ });
229
+ if (childHandleRefTuple) {
230
+ childHandleRefTuple[1] = handleMapping[childHandleRefTuple[1]];
231
+ }
232
+ });
233
+ mergedEntities.children.push(entity);
234
+ });
235
+ });
236
+
237
+ // Update layer count
238
+ mergedLayers.values.find(function (tuple) {
239
+ return tuple[0] === "70";
240
+ })[1] = String(mergedLayers.children.length);
241
+ return documents[0];
242
+ }