@mwater/visualization 5.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 (860) hide show
  1. package/.prettierrc +11 -0
  2. package/.storybook/config.js +7 -0
  3. package/.storybook/head.html +4 -0
  4. package/.storybook/webpack.config.js +15 -0
  5. package/.vscode/launch.json +40 -0
  6. package/LICENSE +21 -0
  7. package/README.md +19 -0
  8. package/build-demo.ts +54 -0
  9. package/lib/CheckboxComponent.d.ts +15 -0
  10. package/lib/CheckboxComponent.js +25 -0
  11. package/lib/ColorComponent.d.ts +24 -0
  12. package/lib/ColorComponent.js +77 -0
  13. package/lib/ColorSchemeFactory.d.ts +8 -0
  14. package/lib/ColorSchemeFactory.js +164 -0
  15. package/lib/CsvBuilder.d.ts +5 -0
  16. package/lib/CsvBuilder.js +63 -0
  17. package/lib/DateRangeComponent.d.ts +81 -0
  18. package/lib/DateRangeComponent.js +190 -0
  19. package/lib/FiltersDesignerComponent.d.ts +25 -0
  20. package/lib/FiltersDesignerComponent.js +38 -0
  21. package/lib/ImplicitFilterBuilder.d.ts +8 -0
  22. package/lib/ImplicitFilterBuilder.js +114 -0
  23. package/lib/JsonQLFilter.d.ts +7 -0
  24. package/lib/JsonQLFilter.js +2 -0
  25. package/lib/LocaleContextInjector.d.ts +14 -0
  26. package/lib/LocaleContextInjector.js +20 -0
  27. package/lib/MWaterAddRelatedFormComponent.d.ts +25 -0
  28. package/lib/MWaterAddRelatedFormComponent.js +155 -0
  29. package/lib/MWaterAddRelatedIndicatorComponent.d.ts +31 -0
  30. package/lib/MWaterAddRelatedIndicatorComponent.js +129 -0
  31. package/lib/MWaterAssetSystemsListComponent.d.ts +17 -0
  32. package/lib/MWaterAssetSystemsListComponent.js +78 -0
  33. package/lib/MWaterCompleteTableSelectComponent.d.ts +224 -0
  34. package/lib/MWaterCompleteTableSelectComponent.js +680 -0
  35. package/lib/MWaterContextComponent.d.ts +31 -0
  36. package/lib/MWaterContextComponent.js +111 -0
  37. package/lib/MWaterCustomTablesetListComponent.d.ts +17 -0
  38. package/lib/MWaterCustomTablesetListComponent.js +87 -0
  39. package/lib/MWaterGlobalFiltersComponent.d.ts +16 -0
  40. package/lib/MWaterGlobalFiltersComponent.js +103 -0
  41. package/lib/MWaterLoaderComponent.d.ts +42 -0
  42. package/lib/MWaterLoaderComponent.js +77 -0
  43. package/lib/MWaterMetricsTableListComponent.d.ts +17 -0
  44. package/lib/MWaterMetricsTableListComponent.js +79 -0
  45. package/lib/MWaterResponsesFilterComponent.d.ts +42 -0
  46. package/lib/MWaterResponsesFilterComponent.js +145 -0
  47. package/lib/MWaterTableSelectComponent.d.ts +36 -0
  48. package/lib/MWaterTableSelectComponent.js +206 -0
  49. package/lib/MenuItemComponent.d.ts +0 -0
  50. package/lib/MenuItemComponent.js +3 -0
  51. package/lib/PopoverComponent.d.ts +15 -0
  52. package/lib/PopoverComponent.js +49 -0
  53. package/lib/RadioButtonComponent.d.ts +16 -0
  54. package/lib/RadioButtonComponent.js +25 -0
  55. package/lib/TableSelectComponent.d.ts +21 -0
  56. package/lib/TableSelectComponent.js +68 -0
  57. package/lib/UIComponents.d.ts +85 -0
  58. package/lib/UIComponents.js +195 -0
  59. package/lib/UndoStack.d.ts +11 -0
  60. package/lib/UndoStack.js +51 -0
  61. package/lib/VerticalLayoutComponent.d.ts +21 -0
  62. package/lib/VerticalLayoutComponent.js +76 -0
  63. package/lib/WidgetScope.d.ts +13 -0
  64. package/lib/WidgetScope.js +2 -0
  65. package/lib/axes/Axis.d.ts +81 -0
  66. package/lib/axes/Axis.js +2 -0
  67. package/lib/axes/AxisBuilder.d.ts +66 -0
  68. package/lib/axes/AxisBuilder.js +1202 -0
  69. package/lib/axes/AxisColorEditorComponent.d.ts +39 -0
  70. package/lib/axes/AxisColorEditorComponent.js +133 -0
  71. package/lib/axes/AxisComponent.d.ts +65 -0
  72. package/lib/axes/AxisComponent.js +359 -0
  73. package/lib/axes/BinsComponent.d.ts +21 -0
  74. package/lib/axes/BinsComponent.js +96 -0
  75. package/lib/axes/CategoryMapComponent.d.ts +41 -0
  76. package/lib/axes/CategoryMapComponent.js +175 -0
  77. package/lib/axes/ColorPaletteCollectionComponent.d.ts +17 -0
  78. package/lib/axes/ColorPaletteCollectionComponent.js +130 -0
  79. package/lib/axes/RangesComponent.d.ts +35 -0
  80. package/lib/axes/RangesComponent.js +119 -0
  81. package/lib/componenttest.d.ts +1 -0
  82. package/lib/componenttest.js +47 -0
  83. package/lib/compressJson.d.ts +4 -0
  84. package/lib/compressJson.js +19 -0
  85. package/lib/dashboards/DashboardComponent.d.ts +115 -0
  86. package/lib/dashboards/DashboardComponent.js +297 -0
  87. package/lib/dashboards/DashboardDataSource.d.ts +9 -0
  88. package/lib/dashboards/DashboardDataSource.js +14 -0
  89. package/lib/dashboards/DashboardDesign.d.ts +45 -0
  90. package/lib/dashboards/DashboardDesign.js +2 -0
  91. package/lib/dashboards/DashboardUpgrader.d.ts +4 -0
  92. package/lib/dashboards/DashboardUpgrader.js +95 -0
  93. package/lib/dashboards/DashboardUtils.d.ts +7 -0
  94. package/lib/dashboards/DashboardUtils.js +69 -0
  95. package/lib/dashboards/DashboardViewComponent.d.ts +71 -0
  96. package/lib/dashboards/DashboardViewComponent.js +235 -0
  97. package/lib/dashboards/DirectDashboardDataSource.d.ts +31 -0
  98. package/lib/dashboards/DirectDashboardDataSource.js +62 -0
  99. package/lib/dashboards/LayoutOptionsComponent.d.ts +11 -0
  100. package/lib/dashboards/LayoutOptionsComponent.js +119 -0
  101. package/lib/dashboards/README.md +13 -0
  102. package/lib/dashboards/ServerDashboardDataSource.d.ts +96 -0
  103. package/lib/dashboards/ServerDashboardDataSource.js +383 -0
  104. package/lib/dashboards/SettingsModalComponent.d.ts +33 -0
  105. package/lib/dashboards/SettingsModalComponent.js +122 -0
  106. package/lib/dashboards/WidgetComponent.d.ts +53 -0
  107. package/lib/dashboards/WidgetComponent.js +66 -0
  108. package/lib/dashboards/layoutOptions.d.ts +19 -0
  109. package/lib/dashboards/layoutOptions.js +19 -0
  110. package/lib/datagrids/DatagridComponent.d.ts +122 -0
  111. package/lib/datagrids/DatagridComponent.js +285 -0
  112. package/lib/datagrids/DatagridDataSource.d.ts +9 -0
  113. package/lib/datagrids/DatagridDataSource.js +13 -0
  114. package/lib/datagrids/DatagridDesign.d.ts +75 -0
  115. package/lib/datagrids/DatagridDesign.js +2 -0
  116. package/lib/datagrids/DatagridDesignerComponent.d.ts +114 -0
  117. package/lib/datagrids/DatagridDesignerComponent.js +389 -0
  118. package/lib/datagrids/DatagridQueryBuilder.d.ts +68 -0
  119. package/lib/datagrids/DatagridQueryBuilder.js +540 -0
  120. package/lib/datagrids/DatagridUtils.d.ts +8 -0
  121. package/lib/datagrids/DatagridUtils.js +91 -0
  122. package/lib/datagrids/DatagridViewComponent.d.ts +86 -0
  123. package/lib/datagrids/DatagridViewComponent.js +321 -0
  124. package/lib/datagrids/DirectDatagridDataSource.d.ts +20 -0
  125. package/lib/datagrids/DirectDatagridDataSource.js +62 -0
  126. package/lib/datagrids/EditExprCellComponent.d.ts +77 -0
  127. package/lib/datagrids/EditExprCellComponent.js +212 -0
  128. package/lib/datagrids/ExprCellComponent.d.ts +34 -0
  129. package/lib/datagrids/ExprCellComponent.js +81 -0
  130. package/lib/datagrids/FindReplaceModalComponent.d.ts +52 -0
  131. package/lib/datagrids/FindReplaceModalComponent.js +248 -0
  132. package/lib/datagrids/LabeledExprGenerator.d.ts +40 -0
  133. package/lib/datagrids/LabeledExprGenerator.js +252 -0
  134. package/lib/datagrids/OrderBysDesignerComponent.d.ts +22 -0
  135. package/lib/datagrids/OrderBysDesignerComponent.js +67 -0
  136. package/lib/datagrids/README.md +3 -0
  137. package/lib/datagrids/ServerDatagridDataSource.d.ts +40 -0
  138. package/lib/datagrids/ServerDatagridDataSource.js +79 -0
  139. package/lib/demo.d.ts +1 -0
  140. package/lib/demo.js +4006 -0
  141. package/lib/demoBlocks.d.ts +1 -0
  142. package/lib/demoBlocks.js +112 -0
  143. package/lib/index.css +550 -0
  144. package/lib/index.d.ts +69 -0
  145. package/lib/index.js +156 -0
  146. package/lib/injectTableAlias.d.ts +2 -0
  147. package/lib/injectTableAlias.js +30 -0
  148. package/lib/languages.d.ts +9 -0
  149. package/lib/languages.js +926 -0
  150. package/lib/layout-styles.css +263 -0
  151. package/lib/layouts/DecoratedBlockComponent.d.ts +44 -0
  152. package/lib/layouts/DecoratedBlockComponent.js +96 -0
  153. package/lib/layouts/DragSourceComponent.d.ts +2 -0
  154. package/lib/layouts/DragSourceComponent.js +26 -0
  155. package/lib/layouts/LayoutManager.d.ts +50 -0
  156. package/lib/layouts/LayoutManager.js +41 -0
  157. package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +75 -0
  158. package/lib/layouts/blocks/BlocksDisplayComponent.js +336 -0
  159. package/lib/layouts/blocks/BlocksLayoutManager.d.ts +36 -0
  160. package/lib/layouts/blocks/BlocksLayoutManager.js +74 -0
  161. package/lib/layouts/blocks/ClipboardPaletteItemComponent.d.ts +9 -0
  162. package/lib/layouts/blocks/ClipboardPaletteItemComponent.js +59 -0
  163. package/lib/layouts/blocks/DraggableBlockComponent.d.ts +2 -0
  164. package/lib/layouts/blocks/DraggableBlockComponent.js +163 -0
  165. package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +31 -0
  166. package/lib/layouts/blocks/HorizontalBlockComponent.js +191 -0
  167. package/lib/layouts/blocks/PaletteItemComponent.d.ts +14 -0
  168. package/lib/layouts/blocks/PaletteItemComponent.js +15 -0
  169. package/lib/layouts/blocks/README.md +11 -0
  170. package/lib/layouts/blocks/blockUtils.d.ts +22 -0
  171. package/lib/layouts/blocks/blockUtils.js +155 -0
  172. package/lib/layouts/decorated-block.css +100 -0
  173. package/lib/layouts/grid/GridLayoutComponent.d.ts +23 -0
  174. package/lib/layouts/grid/GridLayoutComponent.js +49 -0
  175. package/lib/layouts/grid/GridLayoutManager.d.ts +29 -0
  176. package/lib/layouts/grid/GridLayoutManager.js +141 -0
  177. package/lib/layouts/grid/LegoLayoutEngine.d.ts +33 -0
  178. package/lib/layouts/grid/LegoLayoutEngine.js +129 -0
  179. package/lib/layouts/grid/PaletteItemComponent.d.ts +14 -0
  180. package/lib/layouts/grid/PaletteItemComponent.js +15 -0
  181. package/lib/layouts/grid/README.md +14 -0
  182. package/lib/layouts/grid/WidgetContainerComponent.d.ts +9 -0
  183. package/lib/layouts/grid/WidgetContainerComponent.js +333 -0
  184. package/lib/mWaterLoader.d.ts +26 -0
  185. package/lib/mWaterLoader.js +55 -0
  186. package/lib/mapdemo.d.ts +0 -0
  187. package/lib/mapdemo.js +115 -0
  188. package/lib/maps/AddLayerComponent.d.ts +22 -0
  189. package/lib/maps/AddLayerComponent.js +85 -0
  190. package/lib/maps/AdminScopeAndDetailLevelComponent.d.ts +19 -0
  191. package/lib/maps/AdminScopeAndDetailLevelComponent.js +59 -0
  192. package/lib/maps/BaseLayerDesignerComponent.d.ts +28 -0
  193. package/lib/maps/BaseLayerDesignerComponent.js +57 -0
  194. package/lib/maps/BingLayer.d.ts +1 -0
  195. package/lib/maps/BingLayer.js +151 -0
  196. package/lib/maps/BufferLayer.d.ts +51 -0
  197. package/lib/maps/BufferLayer.js +816 -0
  198. package/lib/maps/BufferLayerDesign.d.ts +37 -0
  199. package/lib/maps/BufferLayerDesign.js +2 -0
  200. package/lib/maps/BufferLayerDesignerComponent.d.ts +49 -0
  201. package/lib/maps/BufferLayerDesignerComponent.js +217 -0
  202. package/lib/maps/ChoroplethLayer.d.ts +74 -0
  203. package/lib/maps/ChoroplethLayer.js +1515 -0
  204. package/lib/maps/ChoroplethLayerDesign.d.ts +56 -0
  205. package/lib/maps/ChoroplethLayerDesign.js +2 -0
  206. package/lib/maps/ChoroplethLayerDesigner.d.ts +53 -0
  207. package/lib/maps/ChoroplethLayerDesigner.js +382 -0
  208. package/lib/maps/ClusterLayer.d.ts +38 -0
  209. package/lib/maps/ClusterLayer.js +746 -0
  210. package/lib/maps/ClusterLayerDesign.d.ts +22 -0
  211. package/lib/maps/ClusterLayerDesign.js +2 -0
  212. package/lib/maps/ClusterLayerDesignerComponent.d.ts +37 -0
  213. package/lib/maps/ClusterLayerDesignerComponent.js +110 -0
  214. package/lib/maps/DetailLevelSelectComponent.d.ts +122 -0
  215. package/lib/maps/DetailLevelSelectComponent.js +91 -0
  216. package/lib/maps/DirectMapDataSource.d.ts +68 -0
  217. package/lib/maps/DirectMapDataSource.js +265 -0
  218. package/lib/maps/EditHoverOver.d.ts +18 -0
  219. package/lib/maps/EditHoverOver.js +88 -0
  220. package/lib/maps/EditPopupComponent.d.ts +26 -0
  221. package/lib/maps/EditPopupComponent.js +75 -0
  222. package/lib/maps/Grid Functions.sql +167 -0
  223. package/lib/maps/GridLayer.d.ts +48 -0
  224. package/lib/maps/GridLayer.js +684 -0
  225. package/lib/maps/GridLayerDesign.d.ts +35 -0
  226. package/lib/maps/GridLayerDesign.js +2 -0
  227. package/lib/maps/GridLayerDesigner.d.ts +38 -0
  228. package/lib/maps/GridLayerDesigner.js +229 -0
  229. package/lib/maps/HoverContent.d.ts +13 -0
  230. package/lib/maps/HoverContent.js +92 -0
  231. package/lib/maps/HtmlUrlLegend.d.ts +16 -0
  232. package/lib/maps/HtmlUrlLegend.js +38 -0
  233. package/lib/maps/Layer.d.ts +164 -0
  234. package/lib/maps/Layer.js +193 -0
  235. package/lib/maps/LayerFactory.d.ts +5 -0
  236. package/lib/maps/LayerFactory.js +47 -0
  237. package/lib/maps/LayerLegendComponent.d.ts +23 -0
  238. package/lib/maps/LayerLegendComponent.js +68 -0
  239. package/lib/maps/LayerSwitcherComponent.d.ts +7 -0
  240. package/lib/maps/LayerSwitcherComponent.js +97 -0
  241. package/lib/maps/LeafletLoading.css +24 -0
  242. package/lib/maps/LeafletLoading.d.ts +42 -0
  243. package/lib/maps/LeafletLoading.js +318 -0
  244. package/lib/maps/LeafletMapComponent.d.ts +141 -0
  245. package/lib/maps/LeafletMapComponent.js +438 -0
  246. package/lib/maps/LegendComponent.d.ts +14 -0
  247. package/lib/maps/LegendComponent.js +74 -0
  248. package/lib/maps/LegendGroup.d.ts +24 -0
  249. package/lib/maps/LegendGroup.js +86 -0
  250. package/lib/maps/MWaterServerLayer.d.ts +40 -0
  251. package/lib/maps/MWaterServerLayer.js +101 -0
  252. package/lib/maps/MapBoundsCalculator.d.ts +16 -0
  253. package/lib/maps/MapBoundsCalculator.js +85 -0
  254. package/lib/maps/MapComponent.d.ts +98 -0
  255. package/lib/maps/MapComponent.js +186 -0
  256. package/lib/maps/MapControlComponent.d.ts +17 -0
  257. package/lib/maps/MapControlComponent.js +25 -0
  258. package/lib/maps/MapDataSource.d.ts +18 -0
  259. package/lib/maps/MapDataSource.js +2 -0
  260. package/lib/maps/MapDesign.d.ts +77 -0
  261. package/lib/maps/MapDesign.js +2 -0
  262. package/lib/maps/MapDesignerComponent.d.ts +39 -0
  263. package/lib/maps/MapDesignerComponent.js +215 -0
  264. package/lib/maps/MapFiltersDesignerComponent.d.ts +21 -0
  265. package/lib/maps/MapFiltersDesignerComponent.js +70 -0
  266. package/lib/maps/MapLayerDataSource.d.ts +22 -0
  267. package/lib/maps/MapLayerDataSource.js +2 -0
  268. package/lib/maps/MapLayerViewDesignerComponent.d.ts +87 -0
  269. package/lib/maps/MapLayerViewDesignerComponent.js +151 -0
  270. package/lib/maps/MapLayersDesignerComponent.d.ts +32 -0
  271. package/lib/maps/MapLayersDesignerComponent.js +98 -0
  272. package/lib/maps/MapUtils.d.ts +21 -0
  273. package/lib/maps/MapUtils.js +119 -0
  274. package/lib/maps/MapViewComponent.d.ts +38 -0
  275. package/lib/maps/MapViewComponent.js +20 -0
  276. package/lib/maps/Maptiler-logo.png +0 -0
  277. package/lib/maps/MarkerSymbolSelectComponent.d.ts +10 -0
  278. package/lib/maps/MarkerSymbolSelectComponent.js +28 -0
  279. package/lib/maps/MarkersLayer.d.ts +66 -0
  280. package/lib/maps/MarkersLayer.js +838 -0
  281. package/lib/maps/MarkersLayerDesign.d.ts +44 -0
  282. package/lib/maps/MarkersLayerDesign.js +2 -0
  283. package/lib/maps/MarkersLayerDesignerComponent.d.ts +56 -0
  284. package/lib/maps/MarkersLayerDesignerComponent.js +269 -0
  285. package/lib/maps/PopupFilterJoinsEditComponent.d.ts +30 -0
  286. package/lib/maps/PopupFilterJoinsEditComponent.js +75 -0
  287. package/lib/maps/PopupFilterJoinsUtils.d.ts +15 -0
  288. package/lib/maps/PopupFilterJoinsUtils.js +91 -0
  289. package/lib/maps/RasterMapViewComponent.d.ts +108 -0
  290. package/lib/maps/RasterMapViewComponent.js +283 -0
  291. package/lib/maps/RegionSelectComponent.d.ts +55 -0
  292. package/lib/maps/RegionSelectComponent.js +61 -0
  293. package/lib/maps/ScopeAndDetailLevelComponent.d.ts +21 -0
  294. package/lib/maps/ScopeAndDetailLevelComponent.js +76 -0
  295. package/lib/maps/ServerMapDataSource.d.ts +86 -0
  296. package/lib/maps/ServerMapDataSource.js +273 -0
  297. package/lib/maps/SwitchableTileUrlLayer.d.ts +53 -0
  298. package/lib/maps/SwitchableTileUrlLayer.js +69 -0
  299. package/lib/maps/SwitchableTileUrlLayerDesigner.d.ts +14 -0
  300. package/lib/maps/SwitchableTileUrlLayerDesigner.js +26 -0
  301. package/lib/maps/TileUrlLayer.d.ts +40 -0
  302. package/lib/maps/TileUrlLayer.js +96 -0
  303. package/lib/maps/UtfGridLayer.d.ts +1 -0
  304. package/lib/maps/UtfGridLayer.js +216 -0
  305. package/lib/maps/VectorMapViewComponent.css +21 -0
  306. package/lib/maps/VectorMapViewComponent.d.ts +44 -0
  307. package/lib/maps/VectorMapViewComponent.js +565 -0
  308. package/lib/maps/ZoomLevelsComponent.d.ts +15 -0
  309. package/lib/maps/ZoomLevelsComponent.js +37 -0
  310. package/lib/maps/mapSymbols.d.ts +6 -0
  311. package/lib/maps/mapSymbols.js +167 -0
  312. package/lib/maps/mapboxUtils.d.ts +6 -0
  313. package/lib/maps/mapboxUtils.js +60 -0
  314. package/lib/maps/maps.d.ts +36 -0
  315. package/lib/maps/maps.js +2 -0
  316. package/lib/maps/marker-icon-2x.png +0 -0
  317. package/lib/maps/marker-icon.png +0 -0
  318. package/lib/maps/marker-shadow.png +0 -0
  319. package/lib/maps/symbols/font-awesome/asterisk.png +0 -0
  320. package/lib/maps/symbols/font-awesome/ban.png +0 -0
  321. package/lib/maps/symbols/font-awesome/beer.png +0 -0
  322. package/lib/maps/symbols/font-awesome/bell.png +0 -0
  323. package/lib/maps/symbols/font-awesome/bolt.png +0 -0
  324. package/lib/maps/symbols/font-awesome/building.png +0 -0
  325. package/lib/maps/symbols/font-awesome/bullseye.png +0 -0
  326. package/lib/maps/symbols/font-awesome/bus.png +0 -0
  327. package/lib/maps/symbols/font-awesome/caret-up.png +0 -0
  328. package/lib/maps/symbols/font-awesome/certificate.png +0 -0
  329. package/lib/maps/symbols/font-awesome/check-circle.png +0 -0
  330. package/lib/maps/symbols/font-awesome/check.png +0 -0
  331. package/lib/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
  332. package/lib/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
  333. package/lib/maps/symbols/font-awesome/cloud.png +0 -0
  334. package/lib/maps/symbols/font-awesome/comment.png +0 -0
  335. package/lib/maps/symbols/font-awesome/crosshairs.png +0 -0
  336. package/lib/maps/symbols/font-awesome/dot-circle-o.png +0 -0
  337. package/lib/maps/symbols/font-awesome/exclamation-circle.png +0 -0
  338. package/lib/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
  339. package/lib/maps/symbols/font-awesome/female.png +0 -0
  340. package/lib/maps/symbols/font-awesome/file.png +0 -0
  341. package/lib/maps/symbols/font-awesome/flag.png +0 -0
  342. package/lib/maps/symbols/font-awesome/flask.png +0 -0
  343. package/lib/maps/symbols/font-awesome/h-square.png +0 -0
  344. package/lib/maps/symbols/font-awesome/home.png +0 -0
  345. package/lib/maps/symbols/font-awesome/info-circle.png +0 -0
  346. package/lib/maps/symbols/font-awesome/male.png +0 -0
  347. package/lib/maps/symbols/font-awesome/medkit.png +0 -0
  348. package/lib/maps/symbols/font-awesome/mobile.png +0 -0
  349. package/lib/maps/symbols/font-awesome/plus-circle.png +0 -0
  350. package/lib/maps/symbols/font-awesome/plus-square.png +0 -0
  351. package/lib/maps/symbols/font-awesome/plus.png +0 -0
  352. package/lib/maps/symbols/font-awesome/square.png +0 -0
  353. package/lib/maps/symbols/font-awesome/star.png +0 -0
  354. package/lib/maps/symbols/font-awesome/thumbs-down.png +0 -0
  355. package/lib/maps/symbols/font-awesome/thumbs-up.png +0 -0
  356. package/lib/maps/symbols/font-awesome/ticket.png +0 -0
  357. package/lib/maps/symbols/font-awesome/times-circle.png +0 -0
  358. package/lib/maps/symbols/font-awesome/times.png +0 -0
  359. package/lib/maps/symbols/font-awesome/tint.png +0 -0
  360. package/lib/maps/symbols/font-awesome/tree.png +0 -0
  361. package/lib/maps/symbols/font-awesome/university.png +0 -0
  362. package/lib/maps/symbols/font-awesome/usd.png +0 -0
  363. package/lib/maps/symbols/font-awesome/user.png +0 -0
  364. package/lib/maps/symbols/font-awesome/users.png +0 -0
  365. package/lib/maps/symbols/font-awesome/wheelchair.png +0 -0
  366. package/lib/maps/vectorMaps.d.ts +42 -0
  367. package/lib/maps/vectorMaps.js +331 -0
  368. package/lib/memoizedDebounce.d.ts +6 -0
  369. package/lib/memoizedDebounce.js +21 -0
  370. package/lib/quickfilter/DateExprComponent.d.ts +81 -0
  371. package/lib/quickfilter/DateExprComponent.js +197 -0
  372. package/lib/quickfilter/IdArrayQuickfilterComponent.d.ts +24 -0
  373. package/lib/quickfilter/IdArrayQuickfilterComponent.js +30 -0
  374. package/lib/quickfilter/Quickfilter.d.ts +21 -0
  375. package/lib/quickfilter/Quickfilter.js +2 -0
  376. package/lib/quickfilter/QuickfilterCompiler.d.ts +16 -0
  377. package/lib/quickfilter/QuickfilterCompiler.js +167 -0
  378. package/lib/quickfilter/QuickfilterUtils.d.ts +7 -0
  379. package/lib/quickfilter/QuickfilterUtils.js +106 -0
  380. package/lib/quickfilter/QuickfiltersComponent.d.ts +293 -0
  381. package/lib/quickfilter/QuickfiltersComponent.js +257 -0
  382. package/lib/quickfilter/QuickfiltersDataSource.d.ts +7 -0
  383. package/lib/quickfilter/QuickfiltersDataSource.js +2 -0
  384. package/lib/quickfilter/QuickfiltersDesignComponent.d.ts +46 -0
  385. package/lib/quickfilter/QuickfiltersDesignComponent.js +176 -0
  386. package/lib/quickfilter/README.md +8 -0
  387. package/lib/quickfilter/TextLiteralComponent.d.ts +216 -0
  388. package/lib/quickfilter/TextLiteralComponent.js +128 -0
  389. package/lib/richtext/ExprItemsHtmlConverter.d.ts +39 -0
  390. package/lib/richtext/ExprItemsHtmlConverter.js +118 -0
  391. package/lib/richtext/FontColorPaletteItem.d.ts +23 -0
  392. package/lib/richtext/FontColorPaletteItem.js +84 -0
  393. package/lib/richtext/FontSizePaletteItem.d.ts +29 -0
  394. package/lib/richtext/FontSizePaletteItem.js +70 -0
  395. package/lib/richtext/ItemsHtmlConverter.d.ts +31 -0
  396. package/lib/richtext/ItemsHtmlConverter.js +209 -0
  397. package/lib/richtext/README.md +3 -0
  398. package/lib/richtext/RichTextComponent.d.ts +84 -0
  399. package/lib/richtext/RichTextComponent.js +255 -0
  400. package/lib/valueFormatter.d.ts +16 -0
  401. package/lib/valueFormatter.js +93 -0
  402. package/lib/widgets/DirectWidgetDataSource.d.ts +43 -0
  403. package/lib/widgets/DirectWidgetDataSource.js +39 -0
  404. package/lib/widgets/DropdownWidgetComponent.d.ts +31 -0
  405. package/lib/widgets/DropdownWidgetComponent.js +41 -0
  406. package/lib/widgets/IFrameWidget.d.ts +16 -0
  407. package/lib/widgets/IFrameWidget.js +38 -0
  408. package/lib/widgets/IFrameWidgetComponent.d.ts +33 -0
  409. package/lib/widgets/IFrameWidgetComponent.js +101 -0
  410. package/lib/widgets/ImageUploaderComponent.d.ts +29 -0
  411. package/lib/widgets/ImageUploaderComponent.js +91 -0
  412. package/lib/widgets/ImageWidget.d.ts +49 -0
  413. package/lib/widgets/ImageWidget.js +112 -0
  414. package/lib/widgets/ImageWidgetComponent.d.ts +125 -0
  415. package/lib/widgets/ImageWidgetComponent.js +368 -0
  416. package/lib/widgets/ImagelistCarouselComponent.d.ts +29 -0
  417. package/lib/widgets/ImagelistCarouselComponent.js +64 -0
  418. package/lib/widgets/MapWidget.d.ts +55 -0
  419. package/lib/widgets/MapWidget.js +167 -0
  420. package/lib/widgets/MarkdownWidget.d.ts +53 -0
  421. package/lib/widgets/MarkdownWidget.js +134 -0
  422. package/lib/widgets/TOCWidget.d.ts +39 -0
  423. package/lib/widgets/TOCWidget.js +254 -0
  424. package/lib/widgets/Widget.d.ts +61 -0
  425. package/lib/widgets/Widget.js +33 -0
  426. package/lib/widgets/WidgetDataSource.d.ts +20 -0
  427. package/lib/widgets/WidgetDataSource.js +2 -0
  428. package/lib/widgets/WidgetFactory.d.ts +4 -0
  429. package/lib/widgets/WidgetFactory.js +40 -0
  430. package/lib/widgets/WidgetScoper.d.ts +9 -0
  431. package/lib/widgets/WidgetScoper.js +49 -0
  432. package/lib/widgets/WidgetScopesViewComponent.d.ts +26 -0
  433. package/lib/widgets/WidgetScopesViewComponent.js +36 -0
  434. package/lib/widgets/charts/Chart.d.ts +57 -0
  435. package/lib/widgets/charts/Chart.js +83 -0
  436. package/lib/widgets/charts/ChartViewComponent.d.ts +72 -0
  437. package/lib/widgets/charts/ChartViewComponent.js +120 -0
  438. package/lib/widgets/charts/ChartWidget.d.ts +87 -0
  439. package/lib/widgets/charts/ChartWidget.js +248 -0
  440. package/lib/widgets/charts/calendar/CalendarChart.d.ts +39 -0
  441. package/lib/widgets/charts/calendar/CalendarChart.js +175 -0
  442. package/lib/widgets/charts/calendar/CalendarChartDesignerComponent.d.ts +35 -0
  443. package/lib/widgets/charts/calendar/CalendarChartDesignerComponent.js +142 -0
  444. package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +56 -0
  445. package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +263 -0
  446. package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +21 -0
  447. package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +183 -0
  448. package/lib/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.d.ts +28 -0
  449. package/lib/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.js +105 -0
  450. package/lib/widgets/charts/imagemosaic/ImageMosaicChartViewComponent.d.ts +31 -0
  451. package/lib/widgets/charts/imagemosaic/ImageMosaicChartViewComponent.js +87 -0
  452. package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +20 -0
  453. package/lib/widgets/charts/imagemosaic/ImagePopupComponent.js +38 -0
  454. package/lib/widgets/charts/layered/LayeredChart.d.ts +28 -0
  455. package/lib/widgets/charts/layered/LayeredChart.js +324 -0
  456. package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +113 -0
  457. package/lib/widgets/charts/layered/LayeredChartCompiler.js +1092 -0
  458. package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +76 -0
  459. package/lib/widgets/charts/layered/LayeredChartDesign.js +2 -0
  460. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +80 -0
  461. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +317 -0
  462. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +72 -0
  463. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +329 -0
  464. package/lib/widgets/charts/layered/LayeredChartSvgFileSaver.d.ts +5 -0
  465. package/lib/widgets/charts/layered/LayeredChartSvgFileSaver.js +138 -0
  466. package/lib/widgets/charts/layered/LayeredChartUtils.d.ts +1 -0
  467. package/lib/widgets/charts/layered/LayeredChartUtils.js +25 -0
  468. package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +44 -0
  469. package/lib/widgets/charts/layered/LayeredChartViewComponent.js +406 -0
  470. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +115 -0
  471. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +235 -0
  472. package/lib/widgets/charts/pivot/PivotChart.d.ts +36 -0
  473. package/lib/widgets/charts/pivot/PivotChart.js +343 -0
  474. package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +88 -0
  475. package/lib/widgets/charts/pivot/PivotChartDesign.js +2 -0
  476. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +37 -0
  477. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +159 -0
  478. package/lib/widgets/charts/pivot/PivotChartLayout.d.ts +73 -0
  479. package/lib/widgets/charts/pivot/PivotChartLayout.js +2 -0
  480. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +37 -0
  481. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +676 -0
  482. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.d.ts +74 -0
  483. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +333 -0
  484. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +31 -0
  485. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +263 -0
  486. package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +12 -0
  487. package/lib/widgets/charts/pivot/PivotChartUtils.js +195 -0
  488. package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +84 -0
  489. package/lib/widgets/charts/pivot/PivotChartViewComponent.js +205 -0
  490. package/lib/widgets/charts/pivot/README.md +30 -0
  491. package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +96 -0
  492. package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +216 -0
  493. package/lib/widgets/charts/table/OrderingsComponent.d.ts +15 -0
  494. package/lib/widgets/charts/table/OrderingsComponent.js +66 -0
  495. package/lib/widgets/charts/table/TableChart.d.ts +57 -0
  496. package/lib/widgets/charts/table/TableChart.js +310 -0
  497. package/lib/widgets/charts/table/TableChartDesignerComponent.d.ts +48 -0
  498. package/lib/widgets/charts/table/TableChartDesignerComponent.js +291 -0
  499. package/lib/widgets/charts/table/TableChartViewComponent.d.ts +28 -0
  500. package/lib/widgets/charts/table/TableChartViewComponent.js +206 -0
  501. package/lib/widgets/text/ExprInsertModalComponent.d.ts +35 -0
  502. package/lib/widgets/text/ExprInsertModalComponent.js +51 -0
  503. package/lib/widgets/text/ExprItemEditorComponent.d.ts +34 -0
  504. package/lib/widgets/text/ExprItemEditorComponent.js +92 -0
  505. package/lib/widgets/text/ExprUpdateModalComponent.d.ts +33 -0
  506. package/lib/widgets/text/ExprUpdateModalComponent.js +47 -0
  507. package/lib/widgets/text/README.md +2 -0
  508. package/lib/widgets/text/TextComponent.d.ts +48 -0
  509. package/lib/widgets/text/TextComponent.js +109 -0
  510. package/lib/widgets/text/TextWidget.d.ts +29 -0
  511. package/lib/widgets/text/TextWidget.js +243 -0
  512. package/lib/widgets/text/TextWidgetComponent.d.ts +33 -0
  513. package/lib/widgets/text/TextWidgetComponent.js +88 -0
  514. package/lib/widgets/text/TextWidgetDesign.d.ts +6 -0
  515. package/lib/widgets/text/TextWidgetDesign.js +2 -0
  516. package/mocha.html +10 -0
  517. package/package.json +113 -0
  518. package/server.js +10 -0
  519. package/src/CheckboxComponent.ts +33 -0
  520. package/src/ColorComponent.ts +117 -0
  521. package/src/ColorSchemeFactory.ts +144 -0
  522. package/src/CsvBuilder.ts +65 -0
  523. package/src/DateRangeComponent.ts +279 -0
  524. package/src/FiltersDesignerComponent.ts +55 -0
  525. package/src/ImplicitFilterBuilder.ts +135 -0
  526. package/src/JsonQLFilter.ts +8 -0
  527. package/src/LocaleContextInjector.tsx +17 -0
  528. package/src/MWaterAddRelatedFormComponent.ts +213 -0
  529. package/src/MWaterAddRelatedIndicatorComponent.ts +205 -0
  530. package/src/MWaterAssetSystemsListComponent.tsx +114 -0
  531. package/src/MWaterCompleteTableSelectComponent.tsx +984 -0
  532. package/src/MWaterContextComponent.ts +144 -0
  533. package/src/MWaterCustomTablesetListComponent.tsx +141 -0
  534. package/src/MWaterGlobalFiltersComponent.ts +117 -0
  535. package/src/MWaterLoaderComponent.ts +118 -0
  536. package/src/MWaterMetricsTableListComponent.tsx +120 -0
  537. package/src/MWaterResponsesFilterComponent.ts +194 -0
  538. package/src/MWaterTableSelectComponent.ts +316 -0
  539. package/src/MenuItemComponent.ts +2 -0
  540. package/src/PopoverComponent.ts +59 -0
  541. package/src/RadioButtonComponent.ts +34 -0
  542. package/src/TableSelectComponent.ts +60 -0
  543. package/src/UIComponents.ts +289 -0
  544. package/src/UndoStack.ts +59 -0
  545. package/src/VerticalLayoutComponent.ts +108 -0
  546. package/src/WidgetScope.ts +17 -0
  547. package/src/axes/Axis.ts +89 -0
  548. package/src/axes/AxisBuilder.ts +1325 -0
  549. package/src/axes/AxisColorEditorComponent.ts +210 -0
  550. package/src/axes/AxisComponent.ts +449 -0
  551. package/src/axes/BinsComponent.tsx +169 -0
  552. package/src/axes/CategoryMapComponent.ts +278 -0
  553. package/src/axes/ColorPaletteCollectionComponent.ts +163 -0
  554. package/src/axes/RangesComponent.ts +234 -0
  555. package/src/color-mixer.d.ts +1 -0
  556. package/src/componenttest.ts +64 -0
  557. package/src/compressJson.ts +13 -0
  558. package/src/dashboards/DashboardComponent.ts +468 -0
  559. package/src/dashboards/DashboardDataSource.ts +15 -0
  560. package/src/dashboards/DashboardDesign.ts +57 -0
  561. package/src/dashboards/DashboardUpgrader.ts +103 -0
  562. package/src/dashboards/DashboardUtils.ts +82 -0
  563. package/src/dashboards/DashboardViewComponent.ts +304 -0
  564. package/src/dashboards/DirectDashboardDataSource.ts +69 -0
  565. package/src/dashboards/LayoutOptionsComponent.tsx +227 -0
  566. package/src/dashboards/README.md +13 -0
  567. package/src/dashboards/ServerDashboardDataSource.ts +520 -0
  568. package/src/dashboards/SettingsModalComponent.ts +169 -0
  569. package/src/dashboards/WidgetComponent.tsx +131 -0
  570. package/src/dashboards/layoutOptions.ts +40 -0
  571. package/src/datagrids/DatagridComponent.ts +430 -0
  572. package/src/datagrids/DatagridDataSource.ts +21 -0
  573. package/src/datagrids/DatagridDesign.ts +94 -0
  574. package/src/datagrids/DatagridDesignerComponent.tsx +585 -0
  575. package/src/datagrids/DatagridQueryBuilder.ts +722 -0
  576. package/src/datagrids/DatagridUtils.ts +74 -0
  577. package/src/datagrids/DatagridViewComponent.ts +460 -0
  578. package/src/datagrids/DirectDatagridDataSource.ts +57 -0
  579. package/src/datagrids/EditExprCellComponent.tsx +305 -0
  580. package/src/datagrids/ExprCellComponent.ts +104 -0
  581. package/src/datagrids/FindReplaceModalComponent.ts +354 -0
  582. package/src/datagrids/LabeledExprGenerator.ts +302 -0
  583. package/src/datagrids/OrderBysDesignerComponent.tsx +128 -0
  584. package/src/datagrids/README.md +3 -0
  585. package/src/datagrids/ServerDatagridDataSource.ts +119 -0
  586. package/src/datagrids/react-linkify.d.ts +1 -0
  587. package/src/demo.ts +4148 -0
  588. package/src/demoBlocks.ts +130 -0
  589. package/src/globals.d.ts +2 -0
  590. package/src/index.css +550 -0
  591. package/src/index.ts +112 -0
  592. package/src/injectTableAlias.ts +31 -0
  593. package/src/languages.ts +931 -0
  594. package/src/layout-styles.css +263 -0
  595. package/src/layouts/DecoratedBlockComponent.ts +167 -0
  596. package/src/layouts/DragSourceComponent.ts +35 -0
  597. package/src/layouts/LayoutManager.ts +86 -0
  598. package/src/layouts/blocks/BlocksDisplayComponent.ts +461 -0
  599. package/src/layouts/blocks/BlocksLayoutManager.ts +78 -0
  600. package/src/layouts/blocks/ClipboardPaletteItemComponent.ts +89 -0
  601. package/src/layouts/blocks/DraggableBlockComponent.ts +219 -0
  602. package/src/layouts/blocks/HorizontalBlockComponent.ts +288 -0
  603. package/src/layouts/blocks/PaletteItemComponent.ts +27 -0
  604. package/src/layouts/blocks/README.md +11 -0
  605. package/src/layouts/blocks/blockUtils.ts +207 -0
  606. package/src/layouts/decorated-block.css +100 -0
  607. package/src/layouts/grid/GridLayoutComponent.ts +67 -0
  608. package/src/layouts/grid/GridLayoutManager.ts +185 -0
  609. package/src/layouts/grid/LegoLayoutEngine.ts +142 -0
  610. package/src/layouts/grid/PaletteItemComponent.ts +28 -0
  611. package/src/layouts/grid/README.md +14 -0
  612. package/src/layouts/grid/WidgetContainerComponent.ts +420 -0
  613. package/src/mWaterLoader.ts +82 -0
  614. package/src/mapdemo.ts +127 -0
  615. package/src/maps/AddLayerComponent.ts +125 -0
  616. package/src/maps/AdminScopeAndDetailLevelComponent.ts +90 -0
  617. package/src/maps/BaseLayerDesignerComponent.ts +104 -0
  618. package/src/maps/BingLayer.ts +156 -0
  619. package/src/maps/BufferLayer.ts +927 -0
  620. package/src/maps/BufferLayerDesign.ts +48 -0
  621. package/src/maps/BufferLayerDesignerComponent.ts +311 -0
  622. package/src/maps/ChoroplethLayer.ts +1712 -0
  623. package/src/maps/ChoroplethLayerDesign.ts +73 -0
  624. package/src/maps/ChoroplethLayerDesigner.tsx +558 -0
  625. package/src/maps/ClusterLayer.ts +836 -0
  626. package/src/maps/ClusterLayerDesign.ts +29 -0
  627. package/src/maps/ClusterLayerDesignerComponent.ts +190 -0
  628. package/src/maps/DetailLevelSelectComponent.ts +119 -0
  629. package/src/maps/DirectMapDataSource.ts +386 -0
  630. package/src/maps/EditHoverOver.tsx +151 -0
  631. package/src/maps/EditPopupComponent.ts +121 -0
  632. package/src/maps/Grid Functions.sql +167 -0
  633. package/src/maps/GridLayer.ts +776 -0
  634. package/src/maps/GridLayerDesign.ts +53 -0
  635. package/src/maps/GridLayerDesigner.tsx +332 -0
  636. package/src/maps/HoverContent.tsx +96 -0
  637. package/src/maps/HtmlUrlLegend.tsx +44 -0
  638. package/src/maps/Layer.ts +338 -0
  639. package/src/maps/LayerFactory.ts +51 -0
  640. package/src/maps/LayerLegendComponent.ts +88 -0
  641. package/src/maps/LayerSwitcherComponent.tsx +91 -0
  642. package/src/maps/LeafletLoading.css +24 -0
  643. package/src/maps/LeafletLoading.ts +355 -0
  644. package/src/maps/LeafletMapComponent.tsx +587 -0
  645. package/src/maps/LegendComponent.tsx +101 -0
  646. package/src/maps/LegendGroup.ts +120 -0
  647. package/src/maps/MWaterServerLayer.ts +116 -0
  648. package/src/maps/MapBoundsCalculator.ts +88 -0
  649. package/src/maps/MapComponent.ts +312 -0
  650. package/src/maps/MapControlComponent.ts +46 -0
  651. package/src/maps/MapDataSource.ts +20 -0
  652. package/src/maps/MapDesign.ts +103 -0
  653. package/src/maps/MapDesignerComponent.ts +356 -0
  654. package/src/maps/MapFiltersDesignerComponent.ts +95 -0
  655. package/src/maps/MapLayerDataSource.ts +27 -0
  656. package/src/maps/MapLayerViewDesignerComponent.ts +243 -0
  657. package/src/maps/MapLayersDesignerComponent.ts +144 -0
  658. package/src/maps/MapUtils.ts +148 -0
  659. package/src/maps/MapViewComponent.tsx +62 -0
  660. package/src/maps/Maptiler-logo.png +0 -0
  661. package/src/maps/MarkerSymbolSelectComponent.ts +41 -0
  662. package/src/maps/MarkersLayer.ts +941 -0
  663. package/src/maps/MarkersLayerDesign.ts +56 -0
  664. package/src/maps/MarkersLayerDesignerComponent.ts +374 -0
  665. package/src/maps/PopupFilterJoinsEditComponent.ts +114 -0
  666. package/src/maps/PopupFilterJoinsUtils.ts +99 -0
  667. package/src/maps/RasterMapViewComponent.ts +382 -0
  668. package/src/maps/RegionSelectComponent.ts +80 -0
  669. package/src/maps/ScopeAndDetailLevelComponent.ts +82 -0
  670. package/src/maps/ServerMapDataSource.ts +399 -0
  671. package/src/maps/SwitchableTileUrlLayer.tsx +130 -0
  672. package/src/maps/SwitchableTileUrlLayerDesigner.tsx +60 -0
  673. package/src/maps/TileUrlLayer.tsx +142 -0
  674. package/src/maps/UtfGridLayer.ts +286 -0
  675. package/src/maps/VectorMapViewComponent.css +21 -0
  676. package/src/maps/VectorMapViewComponent.tsx +743 -0
  677. package/src/maps/ZoomLevelsComponent.ts +72 -0
  678. package/src/maps/mapSymbols.ts +162 -0
  679. package/src/maps/mapboxUtils.ts +61 -0
  680. package/src/maps/maps.ts +38 -0
  681. package/src/maps/marker-icon-2x.png +0 -0
  682. package/src/maps/marker-icon.png +0 -0
  683. package/src/maps/marker-shadow.png +0 -0
  684. package/src/maps/png.d.ts +1 -0
  685. package/src/maps/symbols/font-awesome/asterisk.png +0 -0
  686. package/src/maps/symbols/font-awesome/ban.png +0 -0
  687. package/src/maps/symbols/font-awesome/beer.png +0 -0
  688. package/src/maps/symbols/font-awesome/bell.png +0 -0
  689. package/src/maps/symbols/font-awesome/bolt.png +0 -0
  690. package/src/maps/symbols/font-awesome/building.png +0 -0
  691. package/src/maps/symbols/font-awesome/bullseye.png +0 -0
  692. package/src/maps/symbols/font-awesome/bus.png +0 -0
  693. package/src/maps/symbols/font-awesome/caret-up.png +0 -0
  694. package/src/maps/symbols/font-awesome/certificate.png +0 -0
  695. package/src/maps/symbols/font-awesome/check-circle.png +0 -0
  696. package/src/maps/symbols/font-awesome/check.png +0 -0
  697. package/src/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
  698. package/src/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
  699. package/src/maps/symbols/font-awesome/cloud.png +0 -0
  700. package/src/maps/symbols/font-awesome/comment.png +0 -0
  701. package/src/maps/symbols/font-awesome/crosshairs.png +0 -0
  702. package/src/maps/symbols/font-awesome/dot-circle-o.png +0 -0
  703. package/src/maps/symbols/font-awesome/exclamation-circle.png +0 -0
  704. package/src/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
  705. package/src/maps/symbols/font-awesome/female.png +0 -0
  706. package/src/maps/symbols/font-awesome/file.png +0 -0
  707. package/src/maps/symbols/font-awesome/flag.png +0 -0
  708. package/src/maps/symbols/font-awesome/flask.png +0 -0
  709. package/src/maps/symbols/font-awesome/h-square.png +0 -0
  710. package/src/maps/symbols/font-awesome/home.png +0 -0
  711. package/src/maps/symbols/font-awesome/info-circle.png +0 -0
  712. package/src/maps/symbols/font-awesome/male.png +0 -0
  713. package/src/maps/symbols/font-awesome/medkit.png +0 -0
  714. package/src/maps/symbols/font-awesome/mobile.png +0 -0
  715. package/src/maps/symbols/font-awesome/plus-circle.png +0 -0
  716. package/src/maps/symbols/font-awesome/plus-square.png +0 -0
  717. package/src/maps/symbols/font-awesome/plus.png +0 -0
  718. package/src/maps/symbols/font-awesome/square.png +0 -0
  719. package/src/maps/symbols/font-awesome/star.png +0 -0
  720. package/src/maps/symbols/font-awesome/thumbs-down.png +0 -0
  721. package/src/maps/symbols/font-awesome/thumbs-up.png +0 -0
  722. package/src/maps/symbols/font-awesome/ticket.png +0 -0
  723. package/src/maps/symbols/font-awesome/times-circle.png +0 -0
  724. package/src/maps/symbols/font-awesome/times.png +0 -0
  725. package/src/maps/symbols/font-awesome/tint.png +0 -0
  726. package/src/maps/symbols/font-awesome/tree.png +0 -0
  727. package/src/maps/symbols/font-awesome/university.png +0 -0
  728. package/src/maps/symbols/font-awesome/usd.png +0 -0
  729. package/src/maps/symbols/font-awesome/user.png +0 -0
  730. package/src/maps/symbols/font-awesome/users.png +0 -0
  731. package/src/maps/symbols/font-awesome/wheelchair.png +0 -0
  732. package/src/maps/vectorMaps.tsx +410 -0
  733. package/src/memoizedDebounce.tsx +32 -0
  734. package/src/quickfilter/DateExprComponent.ts +284 -0
  735. package/src/quickfilter/IdArrayQuickfilterComponent.ts +58 -0
  736. package/src/quickfilter/Quickfilter.ts +29 -0
  737. package/src/quickfilter/QuickfilterCompiler.ts +167 -0
  738. package/src/quickfilter/QuickfilterUtils.ts +123 -0
  739. package/src/quickfilter/QuickfiltersComponent.ts +416 -0
  740. package/src/quickfilter/QuickfiltersDataSource.ts +15 -0
  741. package/src/quickfilter/QuickfiltersDesignComponent.tsx +257 -0
  742. package/src/quickfilter/README.md +8 -0
  743. package/src/quickfilter/TextLiteralComponent.ts +161 -0
  744. package/src/quickfilter/react-onclickout.d.ts +1 -0
  745. package/src/richtext/ExprItemsHtmlConverter.ts +144 -0
  746. package/src/richtext/FontColorPaletteItem.ts +172 -0
  747. package/src/richtext/FontSizePaletteItem.ts +110 -0
  748. package/src/richtext/ItemsHtmlConverter.ts +246 -0
  749. package/src/richtext/README.md +3 -0
  750. package/src/richtext/RichTextComponent.tsx +390 -0
  751. package/src/richtext/react-float-affixed.d.ts +1 -0
  752. package/src/update-object.d.ts +1 -0
  753. package/src/valueFormatter.ts +110 -0
  754. package/src/widgets/DirectWidgetDataSource.ts +67 -0
  755. package/src/widgets/DropdownWidgetComponent.ts +78 -0
  756. package/src/widgets/IFrameWidget.ts +36 -0
  757. package/src/widgets/IFrameWidgetComponent.ts +116 -0
  758. package/src/widgets/ImageUploaderComponent.tsx +143 -0
  759. package/src/widgets/ImageWidget.ts +147 -0
  760. package/src/widgets/ImageWidgetComponent.ts +546 -0
  761. package/src/widgets/ImagelistCarouselComponent.ts +109 -0
  762. package/src/widgets/MapWidget.ts +219 -0
  763. package/src/widgets/MarkdownWidget.ts +201 -0
  764. package/src/widgets/TOCWidget.ts +326 -0
  765. package/src/widgets/Widget.ts +83 -0
  766. package/src/widgets/WidgetDataSource.ts +23 -0
  767. package/src/widgets/WidgetFactory.ts +37 -0
  768. package/src/widgets/WidgetScoper.ts +51 -0
  769. package/src/widgets/WidgetScopesViewComponent.ts +54 -0
  770. package/src/widgets/charts/Chart.ts +140 -0
  771. package/src/widgets/charts/ChartViewComponent.ts +209 -0
  772. package/src/widgets/charts/ChartWidget.ts +345 -0
  773. package/src/widgets/charts/calendar/CalendarChart.ts +227 -0
  774. package/src/widgets/charts/calendar/CalendarChartDesignerComponent.ts +187 -0
  775. package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +320 -0
  776. package/src/widgets/charts/calendar/d3-tip.d.ts +1 -0
  777. package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +213 -0
  778. package/src/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.ts +121 -0
  779. package/src/widgets/charts/imagemosaic/ImageMosaicChartViewComponent.ts +117 -0
  780. package/src/widgets/charts/imagemosaic/ImagePopupComponent.ts +51 -0
  781. package/src/widgets/charts/imagemosaic/react-lazy-load-image-component.d.ts +1 -0
  782. package/src/widgets/charts/layered/LayeredChart.ts +361 -0
  783. package/src/widgets/charts/layered/LayeredChartCompiler.ts +1299 -0
  784. package/src/widgets/charts/layered/LayeredChartDesign.ts +106 -0
  785. package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +523 -0
  786. package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +448 -0
  787. package/src/widgets/charts/layered/LayeredChartSvgFileSaver.ts +146 -0
  788. package/src/widgets/charts/layered/LayeredChartUtils.ts +24 -0
  789. package/src/widgets/charts/layered/LayeredChartViewComponent.ts +486 -0
  790. package/src/widgets/charts/layered/save-svg-as-png.d.ts +1 -0
  791. package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +338 -0
  792. package/src/widgets/charts/pivot/PivotChart.ts +377 -0
  793. package/src/widgets/charts/pivot/PivotChartDesign.ts +115 -0
  794. package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +240 -0
  795. package/src/widgets/charts/pivot/PivotChartLayout.ts +99 -0
  796. package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +779 -0
  797. package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +504 -0
  798. package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +273 -0
  799. package/src/widgets/charts/pivot/PivotChartUtils.ts +219 -0
  800. package/src/widgets/charts/pivot/PivotChartViewComponent.ts +276 -0
  801. package/src/widgets/charts/pivot/README.md +30 -0
  802. package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +353 -0
  803. package/src/widgets/charts/table/OrderingsComponent.tsx +119 -0
  804. package/src/widgets/charts/table/TableChart.ts +420 -0
  805. package/src/widgets/charts/table/TableChartDesignerComponent.ts +441 -0
  806. package/src/widgets/charts/table/TableChartViewComponent.ts +327 -0
  807. package/src/widgets/text/ExprInsertModalComponent.ts +77 -0
  808. package/src/widgets/text/ExprItemEditorComponent.tsx +164 -0
  809. package/src/widgets/text/ExprUpdateModalComponent.ts +70 -0
  810. package/src/widgets/text/README.md +2 -0
  811. package/src/widgets/text/TextComponent.tsx +151 -0
  812. package/src/widgets/text/TextWidget.ts +265 -0
  813. package/src/widgets/text/TextWidgetComponent.ts +120 -0
  814. package/src/widgets/text/TextWidgetDesign.ts +7 -0
  815. package/stories/UpdateableComponent.js +29 -0
  816. package/stories/consoles.js +202 -0
  817. package/stories/dashboards.js +217 -0
  818. package/stories/datagridDesign.js +114 -0
  819. package/stories/datagrids.js +69 -0
  820. package/stories/dates.js +80 -0
  821. package/stories/exprcomponent.js +43 -0
  822. package/stories/index.js +18 -0
  823. package/stories/leaflet.js +59 -0
  824. package/stories/maps.js +24 -0
  825. package/stories/pivotChart.js +235 -0
  826. package/test/AxisBuilderTests.ts +931 -0
  827. package/test/ChartWidgetTests.ts +85 -0
  828. package/test/ColorSchemeFactoryTests.ts +29 -0
  829. package/test/CsvBuilderTests.ts +22 -0
  830. package/test/DashboardUpgraderTests.ts +170 -0
  831. package/test/ImplicitFilterBuilderTests.ts +161 -0
  832. package/test/LayeredChartCompilerTests.ts +1067 -0
  833. package/test/LayeredChartTests.ts +88 -0
  834. package/test/LegoLayoutEngineTests.ts +69 -0
  835. package/test/MWaterGlobalFiltersComponentTests.ts +130 -0
  836. package/test/MWaterResponsesFilterComponentTests.ts +164 -0
  837. package/test/QuickfilterCompilerTests.ts +167 -0
  838. package/test/TestComponent.ts +49 -0
  839. package/test/UndoStackTests.ts +73 -0
  840. package/test/WidgetScoperTests.ts +35 -0
  841. package/test/blockUtilsTests.ts +290 -0
  842. package/test/canonical-json.d.ts +1 -0
  843. package/test/dashboards/DashboardUtilsTests.ts +131 -0
  844. package/test/datagrids/DatagridQueryBuilderTests.ts +445 -0
  845. package/test/datagrids/DatagridUtilsTests.ts +54 -0
  846. package/test/datagrids/LabeledExprGeneratorTests.ts +121 -0
  847. package/test/fixtures.ts +263 -0
  848. package/test/index.ts +2 -0
  849. package/test/maps/MapUtilsTests.ts +168 -0
  850. package/test/maps/PopupFilterJoinsUtilsTests.ts +105 -0
  851. package/test/richtext/ItemsHtmlConverterTests.ts +41 -0
  852. package/test/test_index.ts +4 -0
  853. package/test/widgets/TextWidgetTests.ts +42 -0
  854. package/test/widgets/charts/pivot/PivotChartLayoutBuilderTests.ts +817 -0
  855. package/test/widgets/charts/pivot/PivotChartQueryBuilderTests.ts +359 -0
  856. package/test/widgets/charts/pivot/PivotChartTests.ts +64 -0
  857. package/test/widgets/charts/pivot/PivotChartUtilsTests.ts +184 -0
  858. package/test/widgets/charts/table/TableChartTests.ts +253 -0
  859. package/tsconfig.build.json +26 -0
  860. package/types/utm.d.ts +10 -0
@@ -0,0 +1,1515 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const lodash_1 = __importDefault(require("lodash"));
30
+ const react_1 = __importDefault(require("react"));
31
+ const immer_1 = require("immer");
32
+ const Layer_1 = __importDefault(require("./Layer"));
33
+ const expressions_1 = require("@mwater/expressions");
34
+ const AxisBuilder_1 = __importDefault(require("../axes/AxisBuilder"));
35
+ const mapboxUtils_1 = require("./mapboxUtils");
36
+ const LayerLegendComponent_1 = __importDefault(require("./LayerLegendComponent"));
37
+ const PopupFilterJoinsUtils = __importStar(require("./PopupFilterJoinsUtils"));
38
+ const HoverContent_1 = __importDefault(require("./HoverContent"));
39
+ class ChoroplethLayer extends Layer_1.default {
40
+ /** Gets the type of layer definition */
41
+ getLayerDefinitionType() {
42
+ return "VectorTile";
43
+ }
44
+ getVectorTile(design, sourceId, schema, filters, opacity) {
45
+ // Verify that scopeLevel is an integer to prevent injection
46
+ if (design.scopeLevel != null && ![0, 1, 2, 3, 4, 5].includes(design.scopeLevel)) {
47
+ throw new Error("Invalid scope level");
48
+ }
49
+ // Verify that detailLevel is an integer to prevent injection
50
+ if (![0, 1, 2, 3, 4, 5].includes(design.detailLevel)) {
51
+ throw new Error("Invalid detail level");
52
+ }
53
+ if (design.regionMode === "plain") {
54
+ return this.createPlainVectorTile(design, sourceId, schema, filters, opacity);
55
+ }
56
+ else if (design.regionMode === "indirect" || !design.regionMode) {
57
+ return this.createIndirectVectorTile(design, sourceId, schema, filters, opacity);
58
+ }
59
+ else if (design.regionMode == "direct") {
60
+ return this.createDirectVectorTile(design, sourceId, schema, filters, opacity);
61
+ }
62
+ else {
63
+ throw new Error("NOT IMPLEMENTED");
64
+ }
65
+ }
66
+ createPlainVectorTile(design, sourceId, schema, filters, opacity) {
67
+ const regionsTable = design.regionsTable || "admin_regions";
68
+ // Expression of envelope from tile table
69
+ const envelopeExpr = {
70
+ type: "scalar",
71
+ expr: { type: "field", tableAlias: "tile", column: "envelope" },
72
+ from: { type: "table", table: "tile", alias: "tile" }
73
+ };
74
+ const envelopeWithMarginExpr = {
75
+ type: "scalar",
76
+ expr: { type: "field", tableAlias: "tile", column: "envelope_with_margin" },
77
+ from: { type: "table", table: "tile", alias: "tile" }
78
+ };
79
+ /*
80
+ Returns two source layers, "polygons" and "points". Points are used for labels.
81
+
82
+ polygons:
83
+ select name, ST_AsMVTGeom(shape_simplified, tile.envelope) as the_geom_webmercator from
84
+ admin_regions as regions, tile as tile
85
+ where regions.level0 = 242
86
+ and regions.level = 1
87
+ and shape && tile.envelope_with_margin
88
+
89
+ points:
90
+ select name, ST_AsMVTGeom(
91
+ (select ST_Centroid(polys.geom) from ST_Dump(shape_simplified) as polys order by ST_Area(polys.geom) desc limit 1)
92
+ , tile.envelope) as the_geom_webmercator from
93
+ admin_regions as regions, tile as tile
94
+ where regions.level0 = 242
95
+ and regions.level = 1
96
+ and shape && tile.envelope_with_margin
97
+
98
+ */
99
+ // Create where
100
+ const where = {
101
+ type: "op",
102
+ op: "and",
103
+ exprs: [
104
+ // Level to display
105
+ {
106
+ type: "op",
107
+ op: "=",
108
+ exprs: [{ type: "field", tableAlias: "regions", column: "level" }, design.detailLevel]
109
+ },
110
+ // Filter to tile
111
+ {
112
+ type: "op",
113
+ op: "&&",
114
+ exprs: [{ type: "field", tableAlias: "regions", column: "shape" }, envelopeWithMarginExpr]
115
+ }
116
+ ]
117
+ };
118
+ // Scope overall
119
+ if (design.scope) {
120
+ where.exprs.push({
121
+ type: "op",
122
+ op: "=",
123
+ exprs: [
124
+ { type: "field", tableAlias: "regions", column: `level${design.scopeLevel || 0}` },
125
+ { type: "literal", value: design.scope }
126
+ ]
127
+ });
128
+ }
129
+ // Add filters on regions to outer query
130
+ for (const filter of filters) {
131
+ if (filter.table == regionsTable) {
132
+ where.exprs.push((0, expressions_1.injectTableAlias)(filter.jsonql, "regions"));
133
+ }
134
+ }
135
+ const polygonsQuery = {
136
+ type: "query",
137
+ selects: [
138
+ { type: "select", expr: { type: "field", tableAlias: "regions", column: "_id" }, alias: "id" },
139
+ {
140
+ type: "select",
141
+ expr: {
142
+ type: "op",
143
+ op: "ST_AsMVTGeom",
144
+ exprs: [{ type: "field", tableAlias: "regions", column: "shape_simplified" }, envelopeExpr]
145
+ },
146
+ alias: "the_geom_webmercator"
147
+ },
148
+ { type: "select", expr: { type: "field", tableAlias: "regions", column: "name" }, alias: "name" }
149
+ ],
150
+ from: { type: "table", table: regionsTable, alias: "regions" },
151
+ where: where
152
+ };
153
+ const pointsQuery = {
154
+ type: "query",
155
+ selects: [
156
+ { type: "select", expr: { type: "field", tableAlias: "regions", column: "_id" }, alias: "id" },
157
+ {
158
+ type: "select",
159
+ expr: {
160
+ type: "op",
161
+ op: "ST_AsMVTGeom",
162
+ exprs: [
163
+ {
164
+ type: "scalar",
165
+ expr: {
166
+ type: "op",
167
+ op: "ST_Centroid",
168
+ exprs: [{ type: "field", tableAlias: "polys", column: "geom" }]
169
+ },
170
+ from: {
171
+ type: "subexpr",
172
+ expr: {
173
+ type: "op",
174
+ op: "ST_Dump",
175
+ exprs: [{ type: "field", tableAlias: "regions", column: "shape_simplified" }]
176
+ },
177
+ alias: "polys"
178
+ },
179
+ orderBy: [
180
+ {
181
+ expr: {
182
+ type: "op",
183
+ op: "ST_Area",
184
+ exprs: [{ type: "field", tableAlias: "polys", column: "geom" }]
185
+ },
186
+ direction: "desc"
187
+ }
188
+ ],
189
+ limit: 1
190
+ },
191
+ envelopeExpr
192
+ ]
193
+ },
194
+ alias: "the_geom_webmercator"
195
+ },
196
+ { type: "select", expr: { type: "field", tableAlias: "regions", column: "name" }, alias: "name" }
197
+ ],
198
+ from: { type: "table", table: regionsTable, alias: "regions" },
199
+ where: where
200
+ };
201
+ // Create layers
202
+ const mapLayers = [];
203
+ mapLayers.push({
204
+ id: `${sourceId}:polygon-fill`,
205
+ type: "fill",
206
+ source: sourceId,
207
+ "source-layer": "polygons",
208
+ paint: {
209
+ "fill-opacity": design.fillOpacity * design.fillOpacity * opacity,
210
+ "fill-color": design.color || "transparent",
211
+ "fill-outline-color": "transparent"
212
+ }
213
+ });
214
+ mapLayers.push({
215
+ id: `${sourceId}:polygon-line`,
216
+ type: "line",
217
+ source: sourceId,
218
+ "source-layer": "polygons",
219
+ paint: {
220
+ // Because of https://github.com/mapbox/mapbox-gl-js/issues/4090, line opacities < 1 create artifacts.
221
+ "line-color": design.borderColor || "#000",
222
+ "line-opacity": opacity,
223
+ "line-width": 1,
224
+ "line-blur": 1.5
225
+ }
226
+ });
227
+ if (design.displayNames) {
228
+ mapLayers.push({
229
+ id: `${sourceId}:labels`,
230
+ type: "symbol",
231
+ source: sourceId,
232
+ "source-layer": "points",
233
+ layout: {
234
+ "text-field": ["get", "name"],
235
+ "text-size": 10
236
+ },
237
+ paint: {
238
+ "text-color": "black",
239
+ "text-halo-color": "rgba(255, 255, 255, 0.5)",
240
+ "text-halo-width": 2,
241
+ "text-opacity": opacity
242
+ }
243
+ });
244
+ }
245
+ return {
246
+ ctes: [],
247
+ sourceLayers: [
248
+ { id: "polygons", jsonql: polygonsQuery },
249
+ { id: "points", jsonql: pointsQuery }
250
+ ],
251
+ mapLayers: mapLayers,
252
+ mapLayersHandleClicks: [`${sourceId}:polygon-fill`],
253
+ minZoom: design.minZoom,
254
+ maxZoom: design.maxZoom
255
+ };
256
+ }
257
+ createIndirectVectorTile(design, sourceId, schema, filters, opacity) {
258
+ const axisBuilder = new AxisBuilder_1.default({ schema });
259
+ const exprCompiler = new expressions_1.ExprCompiler(schema);
260
+ const regionsTable = design.regionsTable || "admin_regions";
261
+ // Expression of scale and envelope from tile table
262
+ const envelopeExpr = {
263
+ type: "scalar",
264
+ expr: { type: "field", tableAlias: "tile", column: "envelope" },
265
+ from: { type: "table", table: "tile", alias: "tile" }
266
+ };
267
+ /*
268
+ Returns two source layers, "polygons" and "points". Points are used for labels.
269
+
270
+ Has a CTE (regions) that is the core data that doesn't change by tile. e.g.:
271
+
272
+ select admin_regions.level1 as id,
273
+ count(innerquery.*) as color
274
+ from
275
+ admin_regions inner join
276
+ entities.water_point as innerquery
277
+ on innerquery.admin_region = admin_regions._id
278
+ where admin_regions.level0 = 242
279
+ group by 1
280
+
281
+ polygons:
282
+ select name, ST_AsMVTGeom(shape_simplified, tile.envelope) as the_geom_webmercator, regions.color from
283
+ admin_regions as regions2
284
+ left outer join regions as regions on regions.id = regions2._id
285
+ where regions2.level = 1 and regions2.level0 = 242
286
+
287
+ points:
288
+ select name, ST_AsMVTGeom(
289
+ (select ST_Centroid(polys.geom) from ST_Dump(shape_simplified) as polys order by ST_Area(polys.geom) desc limit 1), tile.envelope) as the_geom_webmercator, regions.color from
290
+ admin_regions as regions2
291
+ left outer join regions as regions on regions.id = regions2._id, tile as tile
292
+ where regions2.level = 1 and regions2.level0 = 242 and shape && tile.envelope_with_margin
293
+
294
+ */
295
+ const compiledAdminRegionExpr = exprCompiler.compileExpr({
296
+ expr: design.adminRegionExpr || null,
297
+ tableAlias: "innerquery"
298
+ });
299
+ // Create CTE query
300
+ const cteQuery = {
301
+ type: "query",
302
+ selects: [
303
+ {
304
+ type: "select",
305
+ expr: { type: "field", tableAlias: "regions", column: `level${design.detailLevel}` },
306
+ alias: "id"
307
+ }
308
+ ],
309
+ from: {
310
+ type: "join",
311
+ kind: "inner",
312
+ left: { type: "table", table: regionsTable, alias: "regions" },
313
+ right: exprCompiler.compileTable(design.table, "innerquery"),
314
+ on: {
315
+ type: "op",
316
+ op: "=",
317
+ exprs: [compiledAdminRegionExpr, { type: "field", tableAlias: "regions", column: "_id" }]
318
+ }
319
+ },
320
+ groupBy: [1]
321
+ };
322
+ // Add color select if color axis
323
+ if (design.axes.color) {
324
+ const colorExpr = axisBuilder.compileAxis({ axis: design.axes.color, tableAlias: "innerquery" });
325
+ cteQuery.selects.push({ type: "select", expr: colorExpr, alias: "color" });
326
+ }
327
+ // Add label select if color axis
328
+ if (design.axes.label) {
329
+ const labelExpr = axisBuilder.compileAxis({ axis: design.axes.label, tableAlias: "innerquery" });
330
+ cteQuery.selects.push({ type: "select", expr: labelExpr, alias: "label" });
331
+ }
332
+ let whereClauses = [];
333
+ if (design.scope) {
334
+ whereClauses.push({
335
+ type: "op",
336
+ op: "=",
337
+ exprs: [{ type: "field", tableAlias: "regions", column: `level${design.scopeLevel || 0}` }, design.scope]
338
+ });
339
+ }
340
+ // Then add filters
341
+ if (design.filter) {
342
+ whereClauses.push(exprCompiler.compileExpr({ expr: design.filter, tableAlias: "innerquery" }));
343
+ }
344
+ // Then add extra filters passed in, if relevant
345
+ const relevantFilters = lodash_1.default.where(filters, { table: design.table });
346
+ for (let filter of relevantFilters) {
347
+ whereClauses.push((0, expressions_1.injectTableAlias)(filter.jsonql, "innerquery"));
348
+ }
349
+ whereClauses = lodash_1.default.compact(whereClauses);
350
+ if (whereClauses.length > 0) {
351
+ cteQuery.where = { type: "op", op: "and", exprs: whereClauses };
352
+ }
353
+ // Create outer where clause
354
+ const outerWhere = {
355
+ type: "op",
356
+ op: "and",
357
+ exprs: [
358
+ // Level to display
359
+ {
360
+ type: "op",
361
+ op: "=",
362
+ exprs: [{ type: "field", tableAlias: "regions2", column: "level" }, design.detailLevel]
363
+ }
364
+ ]
365
+ };
366
+ // Scope overall
367
+ if (design.scope) {
368
+ outerWhere.exprs.push({
369
+ type: "op",
370
+ op: "=",
371
+ exprs: [
372
+ { type: "field", tableAlias: "regions2", column: `level${design.scopeLevel || 0}` },
373
+ { type: "literal", value: design.scope }
374
+ ]
375
+ });
376
+ }
377
+ // Add filters on regions to outer query
378
+ for (const filter of filters) {
379
+ if (filter.table == regionsTable) {
380
+ outerWhere.exprs.push((0, expressions_1.injectTableAlias)(filter.jsonql, "regions2"));
381
+ }
382
+ }
383
+ // Now create outer query
384
+ const polygonsQuery = {
385
+ type: "query",
386
+ selects: [
387
+ { type: "select", expr: { type: "field", tableAlias: "regions2", column: "_id" }, alias: "id" },
388
+ {
389
+ type: "select",
390
+ expr: {
391
+ type: "op",
392
+ op: "ST_AsMVTGeom",
393
+ exprs: [{ type: "field", tableAlias: "regions2", column: "shape_simplified" }, envelopeExpr]
394
+ },
395
+ alias: "the_geom_webmercator"
396
+ },
397
+ { type: "select", expr: { type: "field", tableAlias: "regions2", column: "name" }, alias: "name" }
398
+ ],
399
+ from: {
400
+ type: "join",
401
+ kind: "left",
402
+ left: { type: "table", table: regionsTable, alias: "regions2" },
403
+ right: { type: "table", table: "regions", alias: "regions" },
404
+ on: {
405
+ type: "op",
406
+ op: "=",
407
+ exprs: [
408
+ { type: "field", tableAlias: "regions", column: "id" },
409
+ { type: "field", tableAlias: "regions2", column: "_id" }
410
+ ]
411
+ }
412
+ },
413
+ where: outerWhere
414
+ };
415
+ const pointsQuery = {
416
+ type: "query",
417
+ selects: [
418
+ { type: "select", expr: { type: "field", tableAlias: "regions2", column: "_id" }, alias: "id" },
419
+ {
420
+ type: "select",
421
+ expr: {
422
+ type: "op",
423
+ op: "ST_AsMVTGeom",
424
+ exprs: [
425
+ {
426
+ type: "scalar",
427
+ expr: {
428
+ type: "op",
429
+ op: "ST_Centroid",
430
+ exprs: [{ type: "field", tableAlias: "polys", column: "geom" }]
431
+ },
432
+ from: {
433
+ type: "subexpr",
434
+ expr: {
435
+ type: "op",
436
+ op: "ST_Dump",
437
+ exprs: [{ type: "field", tableAlias: "regions2", column: "shape_simplified" }]
438
+ },
439
+ alias: "polys"
440
+ },
441
+ orderBy: [
442
+ {
443
+ expr: {
444
+ type: "op",
445
+ op: "ST_Area",
446
+ exprs: [{ type: "field", tableAlias: "polys", column: "geom" }]
447
+ },
448
+ direction: "desc"
449
+ }
450
+ ],
451
+ limit: 1
452
+ },
453
+ envelopeExpr
454
+ ]
455
+ },
456
+ alias: "the_geom_webmercator"
457
+ },
458
+ { type: "select", expr: { type: "field", tableAlias: "regions2", column: "name" }, alias: "name" }
459
+ ],
460
+ from: {
461
+ type: "join",
462
+ kind: "left",
463
+ left: { type: "table", table: regionsTable, alias: "regions2" },
464
+ right: { type: "table", table: "regions", alias: "regions" },
465
+ on: {
466
+ type: "op",
467
+ op: "=",
468
+ exprs: [
469
+ { type: "field", tableAlias: "regions", column: "id" },
470
+ { type: "field", tableAlias: "regions2", column: "_id" }
471
+ ]
472
+ }
473
+ },
474
+ where: outerWhere
475
+ };
476
+ // Bubble up color and label
477
+ if (design.axes.color) {
478
+ polygonsQuery.selects.push({
479
+ type: "select",
480
+ expr: { type: "field", tableAlias: "regions", column: "color" },
481
+ alias: "color"
482
+ });
483
+ pointsQuery.selects.push({
484
+ type: "select",
485
+ expr: { type: "field", tableAlias: "regions", column: "color" },
486
+ alias: "color"
487
+ });
488
+ }
489
+ // Add label select if color axis
490
+ if (design.axes.label) {
491
+ polygonsQuery.selects.push({
492
+ type: "select",
493
+ expr: { type: "field", tableAlias: "regions", column: "label" },
494
+ alias: "label"
495
+ });
496
+ pointsQuery.selects.push({
497
+ type: "select",
498
+ expr: { type: "field", tableAlias: "regions", column: "label" },
499
+ alias: "label"
500
+ });
501
+ }
502
+ // If color axes, add color conditions
503
+ const color = (0, mapboxUtils_1.compileColorMapToMapbox)(design.axes.color, design.color || "transparent");
504
+ // Create layers
505
+ const mapLayers = [];
506
+ mapLayers.push({
507
+ id: `${sourceId}:polygon-fill`,
508
+ type: "fill",
509
+ source: sourceId,
510
+ "source-layer": "polygons",
511
+ paint: {
512
+ "fill-opacity": design.fillOpacity * design.fillOpacity * opacity,
513
+ "fill-color": color,
514
+ "fill-outline-color": "transparent"
515
+ }
516
+ });
517
+ mapLayers.push({
518
+ id: `${sourceId}:polygon-line`,
519
+ type: "line",
520
+ source: sourceId,
521
+ "source-layer": "polygons",
522
+ paint: {
523
+ // Because of https://github.com/mapbox/mapbox-gl-js/issues/4090, line opacities < 1 create artifacts
524
+ "line-color": (0, mapboxUtils_1.compileColorToMapbox)(design.borderColor || "#000", design.axes.color?.excludedValues),
525
+ "line-opacity": opacity,
526
+ "line-width": 1,
527
+ "line-blur": 1.5
528
+ }
529
+ });
530
+ if (design.displayNames) {
531
+ mapLayers.push({
532
+ id: `${sourceId}:labels`,
533
+ type: "symbol",
534
+ source: sourceId,
535
+ "source-layer": "points",
536
+ layout: {
537
+ "text-field": design.axes.label ? ["get", "label"] : ["get", "name"],
538
+ "text-size": 10
539
+ },
540
+ paint: {
541
+ "text-color": (0, mapboxUtils_1.compileColorToMapbox)("black", design.axes.color?.excludedValues),
542
+ "text-halo-color": (0, mapboxUtils_1.compileColorToMapbox)("rgba(255, 255, 255, 0.5)", design.axes.color?.excludedValues),
543
+ "text-halo-width": 2,
544
+ "text-opacity": opacity
545
+ }
546
+ });
547
+ }
548
+ return {
549
+ ctes: [{ tableName: "regions", jsonql: cteQuery }],
550
+ sourceLayers: [
551
+ { id: "polygons", jsonql: polygonsQuery },
552
+ { id: "points", jsonql: pointsQuery }
553
+ ],
554
+ mapLayers: mapLayers,
555
+ mapLayersHandleClicks: [`${sourceId}:polygon-fill`],
556
+ minZoom: design.minZoom,
557
+ maxZoom: design.maxZoom
558
+ };
559
+ }
560
+ createDirectVectorTile(design, sourceId, schema, filters, opacity) {
561
+ const axisBuilder = new AxisBuilder_1.default({ schema });
562
+ const regionsTable = design.regionsTable || "admin_regions";
563
+ // Expression of scale and envelope from tile table
564
+ const envelopeExpr = {
565
+ type: "scalar",
566
+ expr: { type: "field", tableAlias: "tile", column: "envelope" },
567
+ from: { type: "table", table: "tile", alias: "tile" }
568
+ };
569
+ const envelopeWithMarginExpr = {
570
+ type: "scalar",
571
+ expr: { type: "field", tableAlias: "tile", column: "envelope_with_margin" },
572
+ from: { type: "table", table: "tile", alias: "tile" }
573
+ };
574
+ /*
575
+ Returns two source layers, "polygons" and "points". Points are used for labels.
576
+
577
+ polygons:
578
+ select name, ST_AsMVTGeom(shape_simplified, tile.envelope) as the_geom_webmercator from
579
+ admin_regions as regions, tile as tile
580
+ where regions.level0 = 242
581
+ and regions.level = 1
582
+ and shape && tile.envelope_with_margin
583
+
584
+ points:
585
+ select name, ST_AsMVTGeom(
586
+ (select ST_Centroid(polys.geom) from ST_Dump(shape_simplified) as polys order by ST_Area(polys.geom) desc limit 1)
587
+ , tile.envelope) as the_geom_webmercator from
588
+ admin_regions as regions, tile as tile
589
+ where regions.level0 = 242
590
+ and regions.level = 1
591
+ and shape && tile.envelope_with_margin
592
+
593
+ */
594
+ // Create where
595
+ const where = {
596
+ type: "op",
597
+ op: "and",
598
+ exprs: [
599
+ // Level to display
600
+ {
601
+ type: "op",
602
+ op: "=",
603
+ exprs: [{ type: "field", tableAlias: "regions", column: "level" }, design.detailLevel]
604
+ },
605
+ // Filter to tile
606
+ {
607
+ type: "op",
608
+ op: "&&",
609
+ exprs: [{ type: "field", tableAlias: "regions", column: "shape" }, envelopeWithMarginExpr]
610
+ }
611
+ ]
612
+ };
613
+ // Scope overall
614
+ if (design.scope) {
615
+ where.exprs.push({
616
+ type: "op",
617
+ op: "=",
618
+ exprs: [
619
+ { type: "field", tableAlias: "regions", column: `level${design.scopeLevel || 0}` },
620
+ { type: "literal", value: design.scope }
621
+ ]
622
+ });
623
+ }
624
+ // Add filters on regions to outer query
625
+ for (const filter of filters) {
626
+ if (filter.table == regionsTable) {
627
+ where.exprs.push((0, expressions_1.injectTableAlias)(filter.jsonql, "regions"));
628
+ }
629
+ }
630
+ const polygonsQuery = {
631
+ type: "query",
632
+ selects: [
633
+ { type: "select", expr: { type: "field", tableAlias: "regions", column: "_id" }, alias: "id" },
634
+ {
635
+ type: "select",
636
+ expr: {
637
+ type: "op",
638
+ op: "ST_AsMVTGeom",
639
+ exprs: [{ type: "field", tableAlias: "regions", column: "shape_simplified" }, envelopeExpr]
640
+ },
641
+ alias: "the_geom_webmercator"
642
+ },
643
+ { type: "select", expr: { type: "field", tableAlias: "regions", column: "name" }, alias: "name" }
644
+ ],
645
+ from: { type: "table", table: regionsTable, alias: "regions" },
646
+ where: where
647
+ };
648
+ const pointsQuery = {
649
+ type: "query",
650
+ selects: [
651
+ { type: "select", expr: { type: "field", tableAlias: "regions", column: "_id" }, alias: "id" },
652
+ {
653
+ type: "select",
654
+ expr: {
655
+ type: "op",
656
+ op: "ST_AsMVTGeom",
657
+ exprs: [
658
+ {
659
+ type: "scalar",
660
+ expr: {
661
+ type: "op",
662
+ op: "ST_Centroid",
663
+ exprs: [{ type: "field", tableAlias: "polys", column: "geom" }]
664
+ },
665
+ from: {
666
+ type: "subexpr",
667
+ expr: {
668
+ type: "op",
669
+ op: "ST_Dump",
670
+ exprs: [{ type: "field", tableAlias: "regions", column: "shape_simplified" }]
671
+ },
672
+ alias: "polys"
673
+ },
674
+ orderBy: [
675
+ {
676
+ expr: {
677
+ type: "op",
678
+ op: "ST_Area",
679
+ exprs: [{ type: "field", tableAlias: "polys", column: "geom" }]
680
+ },
681
+ direction: "desc"
682
+ }
683
+ ],
684
+ limit: 1
685
+ },
686
+ envelopeExpr
687
+ ]
688
+ },
689
+ alias: "the_geom_webmercator"
690
+ },
691
+ { type: "select", expr: { type: "field", tableAlias: "regions", column: "name" }, alias: "name" }
692
+ ],
693
+ from: { type: "table", table: regionsTable, alias: "regions" },
694
+ where: where
695
+ };
696
+ // Add color select
697
+ if (design.axes.color) {
698
+ const colorExpr = axisBuilder.compileAxis({ axis: design.axes.color, tableAlias: "regions" });
699
+ pointsQuery.selects.push({ type: "select", expr: colorExpr, alias: "color" });
700
+ polygonsQuery.selects.push({ type: "select", expr: colorExpr, alias: "color" });
701
+ }
702
+ // Add label select if color axis
703
+ if (design.axes.label) {
704
+ const labelExpr = axisBuilder.compileAxis({ axis: design.axes.label, tableAlias: "regions" });
705
+ pointsQuery.selects.push({ type: "select", expr: labelExpr, alias: "label" });
706
+ polygonsQuery.selects.push({ type: "select", expr: labelExpr, alias: "label" });
707
+ }
708
+ // If color axes, add color conditions
709
+ const color = (0, mapboxUtils_1.compileColorMapToMapbox)(design.axes.color, design.color || "transparent");
710
+ // Create layers
711
+ const mapLayers = [];
712
+ mapLayers.push({
713
+ id: `${sourceId}:polygon-fill`,
714
+ type: "fill",
715
+ source: sourceId,
716
+ "source-layer": "polygons",
717
+ paint: {
718
+ "fill-opacity": design.fillOpacity * design.fillOpacity * opacity,
719
+ "fill-color": color,
720
+ "fill-outline-color": "transparent"
721
+ }
722
+ });
723
+ mapLayers.push({
724
+ id: `${sourceId}:polygon-line`,
725
+ type: "line",
726
+ source: sourceId,
727
+ "source-layer": "polygons",
728
+ paint: {
729
+ // Because of https://github.com/mapbox/mapbox-gl-js/issues/4090, line opacities < 1 create artifacts.
730
+ "line-color": design.borderColor || "#000",
731
+ "line-opacity": opacity,
732
+ "line-width": 1,
733
+ "line-blur": 1.5
734
+ }
735
+ });
736
+ if (design.displayNames) {
737
+ mapLayers.push({
738
+ id: `${sourceId}:labels`,
739
+ type: "symbol",
740
+ source: sourceId,
741
+ "source-layer": "points",
742
+ layout: {
743
+ "text-field": ["get", "name"],
744
+ "text-size": 10
745
+ },
746
+ paint: {
747
+ "text-color": "black",
748
+ "text-halo-color": "rgba(255, 255, 255, 0.5)",
749
+ "text-halo-width": 2,
750
+ "text-opacity": opacity
751
+ }
752
+ });
753
+ }
754
+ return {
755
+ ctes: [],
756
+ sourceLayers: [
757
+ { id: "polygons", jsonql: polygonsQuery },
758
+ { id: "points", jsonql: pointsQuery }
759
+ ],
760
+ mapLayers: mapLayers,
761
+ mapLayersHandleClicks: [`${sourceId}:polygon-fill`],
762
+ minZoom: design.minZoom,
763
+ maxZoom: design.maxZoom
764
+ };
765
+ }
766
+ /** Gets the layer definition as JsonQL + CSS in format:
767
+ * {
768
+ * layers: array of { id: layer id, jsonql: jsonql that includes "the_webmercator_geom" as a column }
769
+ * css: carto css
770
+ * interactivity: (optional) { layer: id of layer, fields: array of field names }
771
+ * }
772
+ * arguments:
773
+ * design: design of layer
774
+ * schema: schema to use
775
+ * filters: array of filters to apply
776
+ */
777
+ getJsonQLCss(design, schema, filters) {
778
+ // Create design
779
+ const layerDef = {
780
+ layers: [{ id: "layer0", jsonql: this.createMapnikJsonQL(design, schema, filters) }],
781
+ css: this.createCss(design, schema, filters),
782
+ interactivity: {
783
+ layer: "layer0",
784
+ fields: ["id", "name"]
785
+ }
786
+ };
787
+ return layerDef;
788
+ }
789
+ createMapnikJsonQL(design, schema, filters) {
790
+ const axisBuilder = new AxisBuilder_1.default({ schema });
791
+ const exprCompiler = new expressions_1.ExprCompiler(schema);
792
+ // Verify that scopeLevel is an integer to prevent injection
793
+ if (design.scopeLevel != null && ![0, 1, 2, 3, 4, 5].includes(design.scopeLevel)) {
794
+ throw new Error("Invalid scope level");
795
+ }
796
+ // Verify that detailLevel is an integer to prevent injection
797
+ if (![0, 1, 2, 3, 4, 5].includes(design.detailLevel)) {
798
+ throw new Error("Invalid detail level");
799
+ }
800
+ const regionsTable = design.regionsTable || "admin_regions";
801
+ if (design.regionMode === "plain") {
802
+ /*
803
+ E.g:
804
+ select name, shape_simplified from
805
+ admin_regions as regions
806
+ where regions.level0 = 'eb3e12a2-de1e-49a9-8afd-966eb55d47eb'
807
+ and regions.level = 2
808
+ */
809
+ const query = {
810
+ type: "query",
811
+ selects: [
812
+ { type: "select", expr: { type: "field", tableAlias: "regions", column: "_id" }, alias: "id" },
813
+ {
814
+ type: "select",
815
+ expr: { type: "field", tableAlias: "regions", column: "shape_simplified" },
816
+ alias: "the_geom_webmercator"
817
+ },
818
+ { type: "select", expr: { type: "field", tableAlias: "regions", column: "name" }, alias: "name" }
819
+ ],
820
+ from: { type: "table", table: regionsTable, alias: "regions" },
821
+ where: {
822
+ type: "op",
823
+ op: "and",
824
+ exprs: [
825
+ // Level to display
826
+ {
827
+ type: "op",
828
+ op: "=",
829
+ exprs: [{ type: "field", tableAlias: "regions", column: "level" }, design.detailLevel]
830
+ }
831
+ ]
832
+ }
833
+ };
834
+ // Scope overall
835
+ if (design.scope) {
836
+ ;
837
+ query.where.exprs.push({
838
+ type: "op",
839
+ op: "=",
840
+ exprs: [
841
+ { type: "field", tableAlias: "regions", column: `level${design.scopeLevel || 0}` },
842
+ { type: "literal", value: design.scope }
843
+ ]
844
+ });
845
+ }
846
+ // Add filters on regions to outer query
847
+ for (const filter of filters) {
848
+ if (filter.table == regionsTable) {
849
+ ;
850
+ query.where.exprs.push((0, expressions_1.injectTableAlias)(filter.jsonql, "regions"));
851
+ }
852
+ }
853
+ return query;
854
+ }
855
+ if (design.regionMode === "indirect" || !design.regionMode) {
856
+ /*
857
+ E.g:
858
+ select name, shape_simplified, regions.color from
859
+ admin_regions as regions2
860
+ left outer join
861
+ (
862
+ select admin_regions.level2 as id,
863
+ count(innerquery.*) as color
864
+ from
865
+ admin_regions inner join
866
+ entities.water_point as innerquery
867
+ on innerquery.admin_region = admin_regions._id
868
+ where admin_regions.level0 = 'eb3e12a2-de1e-49a9-8afd-966eb55d47eb'
869
+ group by 1
870
+ ) as regions on regions.id = regions2._id
871
+ where regions2.level = 2 and regions2.level0 = 'eb3e12a2-de1e-49a9-8afd-966eb55d47eb'
872
+ */
873
+ const compiledAdminRegionExpr = exprCompiler.compileExpr({
874
+ expr: design.adminRegionExpr || null,
875
+ tableAlias: "innerquery"
876
+ });
877
+ // Create inner query
878
+ const innerQuery = {
879
+ type: "query",
880
+ selects: [
881
+ {
882
+ type: "select",
883
+ expr: { type: "field", tableAlias: "regions", column: `level${design.detailLevel}` },
884
+ alias: "id"
885
+ }
886
+ ],
887
+ from: {
888
+ type: "join",
889
+ kind: "inner",
890
+ left: { type: "table", table: regionsTable, alias: "regions" },
891
+ right: exprCompiler.compileTable(design.table, "innerquery"),
892
+ on: {
893
+ type: "op",
894
+ op: "=",
895
+ exprs: [compiledAdminRegionExpr, { type: "field", tableAlias: "regions", column: "_id" }]
896
+ }
897
+ },
898
+ groupBy: [1]
899
+ };
900
+ // Add color select if color axis
901
+ if (design.axes.color) {
902
+ const colorExpr = axisBuilder.compileAxis({ axis: design.axes.color, tableAlias: "innerquery" });
903
+ innerQuery.selects.push({ type: "select", expr: colorExpr, alias: "color" });
904
+ }
905
+ // Add label select if color axis
906
+ if (design.axes.label) {
907
+ const labelExpr = axisBuilder.compileAxis({ axis: design.axes.label, tableAlias: "innerquery" });
908
+ innerQuery.selects.push({ type: "select", expr: labelExpr, alias: "label" });
909
+ }
910
+ let whereClauses = [];
911
+ if (design.scope) {
912
+ whereClauses.push({
913
+ type: "op",
914
+ op: "=",
915
+ exprs: [{ type: "field", tableAlias: "regions", column: `level${design.scopeLevel || 0}` }, design.scope]
916
+ });
917
+ }
918
+ // Then add filters
919
+ if (design.filter) {
920
+ whereClauses.push(exprCompiler.compileExpr({ expr: design.filter, tableAlias: "innerquery" }));
921
+ }
922
+ // Then add extra filters passed in, if relevant
923
+ const relevantFilters = lodash_1.default.where(filters, { table: design.table });
924
+ for (let filter of relevantFilters) {
925
+ whereClauses.push((0, expressions_1.injectTableAlias)(filter.jsonql, "innerquery"));
926
+ }
927
+ whereClauses = lodash_1.default.compact(whereClauses);
928
+ if (whereClauses.length > 0) {
929
+ innerQuery.where = { type: "op", op: "and", exprs: whereClauses };
930
+ }
931
+ // Now create outer query
932
+ const query = {
933
+ type: "query",
934
+ selects: [
935
+ { type: "select", expr: { type: "field", tableAlias: "regions2", column: "_id" }, alias: "id" },
936
+ {
937
+ type: "select",
938
+ expr: { type: "field", tableAlias: "regions2", column: "shape_simplified" },
939
+ alias: "the_geom_webmercator"
940
+ },
941
+ { type: "select", expr: { type: "field", tableAlias: "regions2", column: "name" }, alias: "name" }
942
+ ],
943
+ from: {
944
+ type: "join",
945
+ kind: "left",
946
+ left: { type: "table", table: regionsTable, alias: "regions2" },
947
+ right: { type: "subquery", query: innerQuery, alias: "regions" },
948
+ on: {
949
+ type: "op",
950
+ op: "=",
951
+ exprs: [
952
+ { type: "field", tableAlias: "regions", column: "id" },
953
+ { type: "field", tableAlias: "regions2", column: "_id" }
954
+ ]
955
+ }
956
+ },
957
+ where: {
958
+ type: "op",
959
+ op: "and",
960
+ exprs: [
961
+ // Level to display
962
+ {
963
+ type: "op",
964
+ op: "=",
965
+ exprs: [{ type: "field", tableAlias: "regions2", column: "level" }, design.detailLevel]
966
+ }
967
+ ]
968
+ }
969
+ };
970
+ // Scope overall
971
+ if (design.scope) {
972
+ ;
973
+ query.where.exprs.push({
974
+ type: "op",
975
+ op: "=",
976
+ exprs: [
977
+ { type: "field", tableAlias: "regions2", column: `level${design.scopeLevel || 0}` },
978
+ { type: "literal", value: design.scope }
979
+ ]
980
+ });
981
+ }
982
+ // Add filters on regions to outer query
983
+ for (const filter of filters) {
984
+ if (filter.table == regionsTable) {
985
+ ;
986
+ query.where.exprs.push((0, expressions_1.injectTableAlias)(filter.jsonql, "regions2"));
987
+ }
988
+ }
989
+ // Bubble up color and label
990
+ if (design.axes.color) {
991
+ query.selects.push({
992
+ type: "select",
993
+ expr: { type: "field", tableAlias: "regions", column: "color" },
994
+ alias: "color"
995
+ });
996
+ }
997
+ // Add label select if color axis
998
+ if (design.axes.label) {
999
+ query.selects.push({
1000
+ type: "select",
1001
+ expr: { type: "field", tableAlias: "regions", column: "label" },
1002
+ alias: "label"
1003
+ });
1004
+ }
1005
+ return query;
1006
+ }
1007
+ if (design.regionMode === "direct") {
1008
+ /*
1009
+ E.g:
1010
+ select name, shape_simplified from
1011
+ admin_regions as regions
1012
+ where regions.level0 = 'eb3e12a2-de1e-49a9-8afd-966eb55d47eb'
1013
+ and regions.level = 2
1014
+ */
1015
+ const query = {
1016
+ type: "query",
1017
+ selects: [
1018
+ { type: "select", expr: { type: "field", tableAlias: "regions", column: "_id" }, alias: "id" },
1019
+ {
1020
+ type: "select",
1021
+ expr: { type: "field", tableAlias: "regions", column: "shape_simplified" },
1022
+ alias: "the_geom_webmercator"
1023
+ },
1024
+ { type: "select", expr: { type: "field", tableAlias: "regions", column: "name" }, alias: "name" }
1025
+ ],
1026
+ from: { type: "table", table: regionsTable, alias: "regions" },
1027
+ where: {
1028
+ type: "op",
1029
+ op: "and",
1030
+ exprs: [
1031
+ // Level to display
1032
+ {
1033
+ type: "op",
1034
+ op: "=",
1035
+ exprs: [{ type: "field", tableAlias: "regions", column: "level" }, design.detailLevel]
1036
+ }
1037
+ ]
1038
+ }
1039
+ };
1040
+ // Add color select
1041
+ if (design.axes.color) {
1042
+ const colorExpr = axisBuilder.compileAxis({ axis: design.axes.color, tableAlias: "regions" });
1043
+ query.selects.push({ type: "select", expr: colorExpr, alias: "color" });
1044
+ }
1045
+ // Add label select if color axis
1046
+ if (design.axes.label) {
1047
+ const labelExpr = axisBuilder.compileAxis({ axis: design.axes.label, tableAlias: "regions" });
1048
+ query.selects.push({ type: "select", expr: labelExpr, alias: "label" });
1049
+ }
1050
+ // Scope overall
1051
+ if (design.scope) {
1052
+ ;
1053
+ query.where.exprs.push({
1054
+ type: "op",
1055
+ op: "=",
1056
+ exprs: [
1057
+ { type: "field", tableAlias: "regions", column: `level${design.scopeLevel || 0}` },
1058
+ { type: "literal", value: design.scope }
1059
+ ]
1060
+ });
1061
+ }
1062
+ // Add filters on regions to outer query
1063
+ for (const filter of filters) {
1064
+ if (filter.table == regionsTable) {
1065
+ ;
1066
+ query.where.exprs.push((0, expressions_1.injectTableAlias)(filter.jsonql, "regions"));
1067
+ }
1068
+ }
1069
+ return query;
1070
+ }
1071
+ throw new Error(`Unsupported regionMode ${design.regionMode}`);
1072
+ }
1073
+ createCss(design, schema, filters) {
1074
+ let css = `\
1075
+ #layer0 {
1076
+ line-color: ${design.borderColor || "#000"};
1077
+ line-width: 1.5;
1078
+ line-opacity: 0.5;
1079
+ polygon-opacity: ` +
1080
+ design.fillOpacity * design.fillOpacity +
1081
+ `;
1082
+ polygon-fill: ` +
1083
+ (design.color || "transparent") +
1084
+ `;
1085
+ }
1086
+ \
1087
+ `;
1088
+ if (design.displayNames) {
1089
+ css += `\
1090
+ #layer0::labels {
1091
+ text-name: [name];
1092
+ text-face-name: 'Arial Regular';
1093
+ text-halo-radius: 2;
1094
+ text-halo-opacity: 0.5;
1095
+ text-halo-fill: #FFF;
1096
+ }\
1097
+ `;
1098
+ }
1099
+ // If color axes, add color conditions
1100
+ if (design.axes.color && design.axes.color.colorMap) {
1101
+ for (let item of design.axes.color.colorMap) {
1102
+ // If invisible
1103
+ if (lodash_1.default.includes(design.axes.color.excludedValues || [], item.value)) {
1104
+ css += `#layer0 [color=${JSON.stringify(item.value)}] { line-color: transparent; polygon-opacity: 0; polygon-fill: transparent; }\n`;
1105
+ if (design.displayNames) {
1106
+ css += `#layer0::labels [color=${JSON.stringify(item.value)}] { text-opacity: 0; text-halo-opacity: 0; }\n`;
1107
+ }
1108
+ }
1109
+ else {
1110
+ css += `#layer0 [color=${JSON.stringify(item.value)}] { polygon-fill: ${item.color}; }\n`;
1111
+ }
1112
+ }
1113
+ }
1114
+ return css;
1115
+ }
1116
+ /**
1117
+ * Called when the interactivity grid is clicked.
1118
+ * arguments:
1119
+ * ev: { data: interactivty data e.g. `{ id: 123 }` }
1120
+ * clickOptions:
1121
+ * design: design of layer
1122
+ * schema: schema to use
1123
+ * dataSource: data source to use
1124
+ * layerDataSource: layer data source
1125
+ * scopeData: current scope data if layer is scoping
1126
+ * filters: compiled filters to apply to the popup
1127
+ *
1128
+ * Returns:
1129
+ * null/undefined
1130
+ * or
1131
+ * {
1132
+ * scope: scope to apply ({ name, filter, data })
1133
+ * row: { tableId:, primaryKey: } # row that was selected
1134
+ * popup: React element to put into a popup
1135
+ */
1136
+ onGridClick(ev, clickOptions) {
1137
+ const regionsTable = clickOptions.design.regionsTable || "admin_regions";
1138
+ // Row only if mode is "plain" or "direct"
1139
+ if (clickOptions.design.regionMode == "plain" || clickOptions.design.regionMode == "direct") {
1140
+ if (ev.data && ev.data.id) {
1141
+ return {
1142
+ row: { tableId: regionsTable, primaryKey: ev.data.id }
1143
+ };
1144
+ }
1145
+ else {
1146
+ return null;
1147
+ }
1148
+ }
1149
+ // Ignore if indirect with no table
1150
+ if (!clickOptions.design.table) {
1151
+ return null;
1152
+ }
1153
+ // TODO abstract most to base class
1154
+ if (ev.data && ev.data.id) {
1155
+ const results = {
1156
+ row: { tableId: regionsTable, primaryKey: ev.data.id }
1157
+ };
1158
+ // Create filter for single row
1159
+ const { table } = clickOptions.design;
1160
+ // Compile adminRegionExpr
1161
+ const exprCompiler = new expressions_1.ExprCompiler(clickOptions.schema);
1162
+ const filterExpr = {
1163
+ type: "op",
1164
+ op: "within",
1165
+ table,
1166
+ exprs: [
1167
+ clickOptions.design.adminRegionExpr,
1168
+ { type: "literal", idTable: regionsTable, valueType: "id", value: ev.data.id }
1169
+ ]
1170
+ };
1171
+ const compiledFilterExpr = exprCompiler.compileExpr({ expr: filterExpr, tableAlias: "{alias}" });
1172
+ // Filter within
1173
+ const filter = {
1174
+ table,
1175
+ jsonql: compiledFilterExpr
1176
+ };
1177
+ if (ev.event.originalEvent.shiftKey) {
1178
+ // Scope to region, unless already scoped
1179
+ if (clickOptions.scopeData === ev.data.id) {
1180
+ results.scope = null;
1181
+ }
1182
+ else {
1183
+ results.scope = {
1184
+ name: ev.data.name,
1185
+ filter,
1186
+ filterExpr,
1187
+ data: ev.data.id
1188
+ };
1189
+ }
1190
+ }
1191
+ else if (clickOptions.design.popup) {
1192
+ // Create default popup filter joins
1193
+ const defaultPopupFilterJoins = {};
1194
+ if (clickOptions.design.adminRegionExpr) {
1195
+ defaultPopupFilterJoins[clickOptions.design.table] = clickOptions.design.adminRegionExpr;
1196
+ }
1197
+ // Create filter using popupFilterJoins
1198
+ const popupFilterJoins = clickOptions.design.popupFilterJoins || defaultPopupFilterJoins;
1199
+ const popupFilters = PopupFilterJoinsUtils.createPopupFilters(popupFilterJoins, clickOptions.schema, table, ev.data.id, true);
1200
+ // Add filter for admin region
1201
+ popupFilters.push({
1202
+ table: regionsTable,
1203
+ jsonql: {
1204
+ type: "op",
1205
+ op: "=",
1206
+ exprs: [
1207
+ { type: "field", tableAlias: "{alias}", column: "_id" },
1208
+ { type: "literal", value: ev.data.id }
1209
+ ]
1210
+ }
1211
+ });
1212
+ const BlocksLayoutManager = require("../layouts/blocks/BlocksLayoutManager").default;
1213
+ const WidgetFactory = require("../widgets/WidgetFactory").default;
1214
+ results.popup = new BlocksLayoutManager().renderLayout({
1215
+ items: clickOptions.design.popup.items,
1216
+ style: "popup",
1217
+ renderWidget: (options) => {
1218
+ const widget = WidgetFactory.createWidget(options.type);
1219
+ // Create filters for single row
1220
+ const filters = clickOptions.filters.concat(popupFilters);
1221
+ // Get data source for widget
1222
+ const widgetDataSource = clickOptions.layerDataSource.getPopupWidgetDataSource(clickOptions.design, options.id);
1223
+ return widget.createViewElement({
1224
+ schema: clickOptions.schema,
1225
+ dataSource: clickOptions.dataSource,
1226
+ widgetDataSource,
1227
+ design: options.design,
1228
+ scope: null,
1229
+ filters,
1230
+ onScopeChange: null,
1231
+ onDesignChange: null,
1232
+ width: options.width,
1233
+ height: options.height
1234
+ });
1235
+ }
1236
+ });
1237
+ }
1238
+ return results;
1239
+ }
1240
+ else {
1241
+ return null;
1242
+ }
1243
+ }
1244
+ // same as onGridClick but handles hover over
1245
+ onGridHoverOver(ev, hoverOptions) {
1246
+ const regionsTable = hoverOptions.design.regionsTable || "admin_regions";
1247
+ // Row only if mode is "plain" or "direct"
1248
+ if (hoverOptions.design.regionMode == "plain" || hoverOptions.design.regionMode == "direct") {
1249
+ if (!ev.data || !ev.data.id) {
1250
+ return null;
1251
+ }
1252
+ }
1253
+ // Ignore if indirect with no table
1254
+ if (!hoverOptions.design.table) {
1255
+ return null;
1256
+ }
1257
+ if (ev.data && ev.data.id) {
1258
+ const { table } = hoverOptions.design;
1259
+ const results = {};
1260
+ // Popup
1261
+ if (hoverOptions.design.hoverOver) {
1262
+ // Create default popup filter joins
1263
+ const defaultPopupFilterJoins = {};
1264
+ if (hoverOptions.design.adminRegionExpr) {
1265
+ defaultPopupFilterJoins[hoverOptions.design.table] = hoverOptions.design.adminRegionExpr;
1266
+ }
1267
+ // Create filter using popupFilterJoins
1268
+ const popupFilterJoins = hoverOptions.design.popupFilterJoins || defaultPopupFilterJoins;
1269
+ const popupFilters = PopupFilterJoinsUtils.createPopupFilters(popupFilterJoins, hoverOptions.schema, table, ev.data.id, true);
1270
+ results.hoverOver = react_1.default.createElement(HoverContent_1.default, {
1271
+ key: ev.data.id,
1272
+ schema: hoverOptions.schema,
1273
+ dataSource: hoverOptions.dataSource,
1274
+ design: hoverOptions.design,
1275
+ filters: popupFilters
1276
+ });
1277
+ }
1278
+ return results;
1279
+ }
1280
+ else {
1281
+ return null;
1282
+ }
1283
+ }
1284
+ // Gets the bounds of the layer as GeoJSON
1285
+ getBounds(design, schema, dataSource, filters, callback) {
1286
+ const regionsTable = design.regionsTable || "admin_regions";
1287
+ const appliedFilters = [];
1288
+ // If scoped, use that as filter
1289
+ if (design.scope) {
1290
+ appliedFilters.push({
1291
+ table: regionsTable,
1292
+ jsonql: {
1293
+ type: "op",
1294
+ op: "and",
1295
+ exprs: [
1296
+ {
1297
+ type: "op",
1298
+ op: "=",
1299
+ exprs: [{ type: "field", tableAlias: "{alias}", column: `level${design.scopeLevel}` }, design.scope]
1300
+ },
1301
+ {
1302
+ type: "op",
1303
+ op: "=",
1304
+ exprs: [{ type: "field", tableAlias: "{alias}", column: `level` }, design.detailLevel]
1305
+ }
1306
+ ]
1307
+ }
1308
+ });
1309
+ }
1310
+ // If regions table is filtered, use that as filter
1311
+ for (const filter of filters) {
1312
+ if (filter.table == regionsTable) {
1313
+ appliedFilters.push(filter);
1314
+ }
1315
+ }
1316
+ // Use shape_simplified for speed, as bounds are always approximate
1317
+ return this.getBoundsFromExpr(schema, dataSource, regionsTable, { type: "field", table: regionsTable, column: "shape_simplified" }, null, appliedFilters, callback);
1318
+ }
1319
+ // Get min and max zoom levels
1320
+ getMinZoom(design) {
1321
+ return design.minZoom;
1322
+ }
1323
+ getMaxZoom(design) {
1324
+ return design.maxZoom || 21;
1325
+ }
1326
+ // Get the legend to be optionally displayed on the map. Returns
1327
+ // a React element
1328
+ getLegend(design, schema, name, dataSource, locale, filters) {
1329
+ if (filters == null) {
1330
+ filters = [];
1331
+ }
1332
+ const _filters = filters.slice();
1333
+ if (design.filter != null) {
1334
+ const exprCompiler = new expressions_1.ExprCompiler(schema);
1335
+ const jsonql = exprCompiler.compileExpr({ expr: design.filter, tableAlias: "{alias}" });
1336
+ const table = design.filter.table;
1337
+ if (jsonql && table) {
1338
+ _filters.push({ table: table, jsonql });
1339
+ }
1340
+ }
1341
+ const axisBuilder = new AxisBuilder_1.default({ schema });
1342
+ const regionsTable = design.regionsTable || "admin_regions";
1343
+ const axisTable = design.regionMode === "direct" ? regionsTable : design.table;
1344
+ return react_1.default.createElement(LayerLegendComponent_1.default, {
1345
+ schema,
1346
+ name,
1347
+ filters: lodash_1.default.compact(_filters),
1348
+ axis: axisBuilder.cleanAxis({
1349
+ axis: design.axes.color || null,
1350
+ table: axisTable,
1351
+ types: ["enum", "text", "boolean", "date"],
1352
+ aggrNeed: design.regionMode == "indirect" ? "required" : "none"
1353
+ }) || undefined,
1354
+ defaultColor: design.color || undefined,
1355
+ locale
1356
+ });
1357
+ }
1358
+ // Get a list of table ids that can be filtered on
1359
+ getFilterableTables(design, schema) {
1360
+ const filterableTables = [];
1361
+ if (design.table) {
1362
+ filterableTables.push(design.table);
1363
+ }
1364
+ if (design.regionMode === "direct") {
1365
+ const regionsTable = design.regionsTable || "admin_regions";
1366
+ filterableTables.push(regionsTable);
1367
+ }
1368
+ return filterableTables;
1369
+ }
1370
+ /** True if layer can be edited */
1371
+ isEditable() {
1372
+ return true;
1373
+ }
1374
+ // Returns a cleaned design
1375
+ cleanDesign(design, schema) {
1376
+ const regionsTable = design.regionsTable || "admin_regions";
1377
+ const exprCleaner = new expressions_1.ExprCleaner(schema);
1378
+ const axisBuilder = new AxisBuilder_1.default({ schema });
1379
+ design = (0, immer_1.produce)(design, draft => {
1380
+ draft.axes = design.axes || {};
1381
+ // Default region mode
1382
+ if (!design.regionMode) {
1383
+ draft.regionMode = draft.axes.color ? "indirect" : "plain";
1384
+ }
1385
+ // Default color
1386
+ if (draft.regionMode === "plain") {
1387
+ draft.color = design.color || "#FFFFFF";
1388
+ }
1389
+ else {
1390
+ draft.color = "#FFFFFF";
1391
+ }
1392
+ if (draft.regionMode === "indirect" && design.table) {
1393
+ draft.adminRegionExpr = exprCleaner.cleanExpr(design.adminRegionExpr || null, {
1394
+ table: design.table,
1395
+ types: ["id"],
1396
+ idTable: regionsTable
1397
+ });
1398
+ }
1399
+ else {
1400
+ delete draft.adminRegionExpr;
1401
+ delete draft.table;
1402
+ }
1403
+ draft.fillOpacity = design.fillOpacity != null ? design.fillOpacity : 0.75;
1404
+ draft.displayNames = design.displayNames != null ? design.displayNames : true;
1405
+ // Clean the axes
1406
+ if (draft.regionMode === "indirect" && design.table) {
1407
+ draft.axes.color = axisBuilder.cleanAxis({
1408
+ axis: draft.axes.color ? (0, immer_1.original)(draft.axes.color) || null : null,
1409
+ table: design.table,
1410
+ types: ["enum", "text", "boolean", "date"],
1411
+ aggrNeed: "required"
1412
+ });
1413
+ draft.axes.label = axisBuilder.cleanAxis({
1414
+ axis: draft.axes.label ? (0, immer_1.original)(draft.axes.label) || null : null,
1415
+ table: design.table,
1416
+ types: ["text", "number"],
1417
+ aggrNeed: "required"
1418
+ });
1419
+ }
1420
+ else if (draft.regionMode === "plain" || (draft.regionMode === "indirect" && !design.table)) {
1421
+ delete draft.axes.color;
1422
+ delete draft.axes.label;
1423
+ }
1424
+ else if (draft.regionMode === "direct") {
1425
+ draft.axes.color = axisBuilder.cleanAxis({
1426
+ axis: draft.axes.color ? (0, immer_1.original)(draft.axes.color) || null : null,
1427
+ table: regionsTable,
1428
+ types: ["enum", "text", "boolean", "date"],
1429
+ aggrNeed: "none"
1430
+ });
1431
+ draft.axes.label = axisBuilder.cleanAxis({
1432
+ axis: draft.axes.label ? (0, immer_1.original)(draft.axes.label) || null : null,
1433
+ table: regionsTable,
1434
+ types: ["text", "number"],
1435
+ aggrNeed: "none"
1436
+ });
1437
+ }
1438
+ // Filter is only for indirect
1439
+ if (draft.regionMode === "indirect" && design.table) {
1440
+ draft.filter = exprCleaner.cleanExpr(design.filter || null, { table: design.table });
1441
+ }
1442
+ else {
1443
+ delete draft.filter;
1444
+ }
1445
+ if (design.detailLevel == null) {
1446
+ draft.detailLevel = 0;
1447
+ }
1448
+ });
1449
+ return design;
1450
+ }
1451
+ // Validates design. Null if ok, message otherwise
1452
+ validateDesign(design, schema) {
1453
+ let error;
1454
+ const exprUtils = new expressions_1.ExprUtils(schema);
1455
+ const axisBuilder = new AxisBuilder_1.default({ schema });
1456
+ const exprValidator = new expressions_1.ExprValidator(schema);
1457
+ if (design.regionMode === "indirect") {
1458
+ if (!design.table) {
1459
+ return "Missing table";
1460
+ }
1461
+ if (!design.adminRegionExpr || exprUtils.getExprType(design.adminRegionExpr) !== "id") {
1462
+ return "Missing admin region expr";
1463
+ }
1464
+ error = axisBuilder.validateAxis({ axis: design.axes.color || null });
1465
+ if (error) {
1466
+ return error;
1467
+ }
1468
+ error = axisBuilder.validateAxis({ axis: design.axes.label || null });
1469
+ if (error) {
1470
+ return error;
1471
+ }
1472
+ // Validate filter
1473
+ error = exprValidator.validateExpr(design.filter || null);
1474
+ if (error) {
1475
+ return error;
1476
+ }
1477
+ }
1478
+ else if (design.regionMode === "direct") {
1479
+ error = axisBuilder.validateAxis({ axis: design.axes.color || null });
1480
+ if (error) {
1481
+ return error;
1482
+ }
1483
+ error = axisBuilder.validateAxis({ axis: design.axes.label || null });
1484
+ if (error) {
1485
+ return error;
1486
+ }
1487
+ }
1488
+ if (design.detailLevel == null) {
1489
+ return "Missing detail level";
1490
+ }
1491
+ return null;
1492
+ }
1493
+ // Creates a design element with specified options
1494
+ // options:
1495
+ // design: design of layer
1496
+ // schema: schema to use
1497
+ // dataSource: data source to use
1498
+ // onDesignChange: function called when design changes
1499
+ // filters: array of filters
1500
+ createDesignerElement(options) {
1501
+ // Require here to prevent server require problems
1502
+ const ChoroplethLayerDesigner = require("./ChoroplethLayerDesigner").default;
1503
+ // Clean on way in and out
1504
+ return react_1.default.createElement(ChoroplethLayerDesigner, {
1505
+ schema: options.schema,
1506
+ dataSource: options.dataSource,
1507
+ design: this.cleanDesign(options.design, options.schema),
1508
+ filters: options.filters,
1509
+ onDesignChange: (design) => {
1510
+ return options.onDesignChange(this.cleanDesign(design, options.schema));
1511
+ }
1512
+ });
1513
+ }
1514
+ }
1515
+ exports.default = ChoroplethLayer;