@mwater/visualization 5.5.0 → 5.6.1

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 (275) hide show
  1. package/lib/ColorComponent.js +2 -2
  2. package/lib/MWaterContextComponent.d.ts +1 -1
  3. package/lib/MWaterGlobalFiltersComponent.d.ts +2 -2
  4. package/lib/MWaterGlobalFiltersComponent.js +11 -20
  5. package/lib/MWaterLoaderComponent.d.ts +4 -13
  6. package/lib/MWaterLoaderComponent.js +2 -11
  7. package/lib/TranslationsTabComponent.d.ts +34 -0
  8. package/lib/TranslationsTabComponent.js +256 -0
  9. package/lib/UndoStack.d.ts +2 -1
  10. package/lib/UndoStack.js +12 -6
  11. package/lib/dashboards/DashboardComponent.js +6 -5
  12. package/lib/dashboards/DashboardDesign.d.ts +1 -1
  13. package/lib/dashboards/ServerDashboardDataSource.d.ts +0 -1
  14. package/lib/dashboards/ServerDashboardDataSource.js +0 -25
  15. package/lib/dashboards/SettingsModalComponent.js +9 -233
  16. package/lib/datagrids/DatagridComponent.js +27 -2
  17. package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -3
  18. package/lib/datagrids/DatagridDesignerComponent.js +108 -120
  19. package/lib/datagrids/DatagridViewComponent.js +33 -6
  20. package/lib/datagrids/OrderBysDesignerComponent.d.ts +7 -7
  21. package/lib/datagrids/OrderBysDesignerComponent.js +19 -28
  22. package/lib/index.css +45 -2
  23. package/lib/index.d.ts +5 -5
  24. package/lib/index.js +2 -3
  25. package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +8 -1
  26. package/lib/layouts/blocks/BlocksDisplayComponent.js +46 -4
  27. package/lib/maps/BufferLayer.d.ts +0 -13
  28. package/lib/maps/BufferLayer.js +24 -237
  29. package/lib/maps/BufferLayerDesign.d.ts +1 -1
  30. package/lib/maps/BufferLayerDesignerComponent.d.ts +1 -1
  31. package/lib/maps/BufferLayerDesignerComponent.js +2 -7
  32. package/lib/maps/ChoroplethLayer.d.ts +1 -16
  33. package/lib/maps/ChoroplethLayer.js +25 -358
  34. package/lib/maps/ChoroplethLayerDesign.d.ts +5 -2
  35. package/lib/maps/ChoroplethLayerDesigner.d.ts +10 -32
  36. package/lib/maps/ChoroplethLayerDesigner.js +58 -89
  37. package/lib/maps/ClusterLayer.d.ts +0 -9
  38. package/lib/maps/ClusterLayer.js +0 -250
  39. package/lib/maps/DirectMapDataSource.js +1 -48
  40. package/lib/maps/EditHoverOver.d.ts +4 -3
  41. package/lib/maps/EditHoverOver.js +3 -3
  42. package/lib/maps/GridLayer.d.ts +0 -15
  43. package/lib/maps/GridLayer.js +0 -212
  44. package/lib/maps/HoverContent.js +1 -1
  45. package/lib/maps/Layer.d.ts +1 -26
  46. package/lib/maps/Layer.js +0 -13
  47. package/lib/maps/LeafletMapComponent.js +10 -19
  48. package/lib/maps/MapComponent.d.ts +19 -35
  49. package/lib/maps/MapComponent.js +135 -77
  50. package/lib/maps/MapControlComponent.d.ts +4 -5
  51. package/lib/maps/MapControlComponent.js +5 -12
  52. package/lib/maps/MapDesign.d.ts +8 -0
  53. package/lib/maps/MapDesignerComponent.d.ts +2 -0
  54. package/lib/maps/MapDesignerComponent.js +7 -2
  55. package/lib/maps/MapLayerDataSource.d.ts +0 -4
  56. package/lib/maps/MapLayerViewDesignerComponent.d.ts +3 -1
  57. package/lib/maps/MapLayerViewDesignerComponent.js +5 -1
  58. package/lib/maps/MapLayersDesignerComponent.d.ts +2 -0
  59. package/lib/maps/MapLayersDesignerComponent.js +2 -1
  60. package/lib/maps/MapTranslationsTab.d.ts +15 -0
  61. package/lib/maps/MapTranslationsTab.js +47 -0
  62. package/lib/maps/MapUtils.d.ts +11 -0
  63. package/lib/maps/MapUtils.js +57 -1
  64. package/lib/maps/MapViewComponent.d.ts +1 -1
  65. package/lib/maps/MapViewComponent.js +1 -8
  66. package/lib/maps/MarkersLayer.d.ts +1 -14
  67. package/lib/maps/MarkersLayer.js +89 -254
  68. package/lib/maps/MarkersLayerDesign.d.ts +5 -1
  69. package/lib/maps/MarkersLayerDesignerComponent.d.ts +32 -57
  70. package/lib/maps/MarkersLayerDesignerComponent.js +158 -134
  71. package/lib/maps/ServerMapDataSource.d.ts +0 -1
  72. package/lib/maps/ServerMapDataSource.js +0 -25
  73. package/lib/maps/SwitchableTileUrlLayer.d.ts +0 -2
  74. package/lib/maps/SwitchableTileUrlLayer.js +0 -9
  75. package/lib/maps/TileUrlLayer.d.ts +0 -1
  76. package/lib/maps/TileUrlLayer.js +0 -5
  77. package/lib/maps/VectorMapViewComponent.js +13 -10
  78. package/lib/maps/symbols/font-awesome/asterisk.png +0 -0
  79. package/lib/maps/symbols/font-awesome/ban.png +0 -0
  80. package/lib/maps/symbols/font-awesome/beer.png +0 -0
  81. package/lib/maps/symbols/font-awesome/bell.png +0 -0
  82. package/lib/maps/symbols/font-awesome/bolt.png +0 -0
  83. package/lib/maps/symbols/font-awesome/building.png +0 -0
  84. package/lib/maps/symbols/font-awesome/bullseye.png +0 -0
  85. package/lib/maps/symbols/font-awesome/bus.png +0 -0
  86. package/lib/maps/symbols/font-awesome/caret-up.png +0 -0
  87. package/lib/maps/symbols/font-awesome/certificate.png +0 -0
  88. package/lib/maps/symbols/font-awesome/check-circle.png +0 -0
  89. package/lib/maps/symbols/font-awesome/check.png +0 -0
  90. package/lib/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
  91. package/lib/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
  92. package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
  93. package/lib/maps/symbols/font-awesome/cloud.png +0 -0
  94. package/lib/maps/symbols/font-awesome/comment.png +0 -0
  95. package/lib/maps/symbols/font-awesome/crosshairs.png +0 -0
  96. package/lib/maps/symbols/font-awesome/dot-circle-o.png +0 -0
  97. package/lib/maps/symbols/font-awesome/exclamation-circle.png +0 -0
  98. package/lib/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
  99. package/lib/maps/symbols/font-awesome/female.png +0 -0
  100. package/lib/maps/symbols/font-awesome/file.png +0 -0
  101. package/lib/maps/symbols/font-awesome/flag.png +0 -0
  102. package/lib/maps/symbols/font-awesome/flask.png +0 -0
  103. package/lib/maps/symbols/font-awesome/h-square.png +0 -0
  104. package/lib/maps/symbols/font-awesome/home.png +0 -0
  105. package/lib/maps/symbols/font-awesome/info-circle.png +0 -0
  106. package/lib/maps/symbols/font-awesome/male.png +0 -0
  107. package/lib/maps/symbols/font-awesome/medkit.png +0 -0
  108. package/lib/maps/symbols/font-awesome/mobile.png +0 -0
  109. package/lib/maps/symbols/font-awesome/plus-circle.png +0 -0
  110. package/lib/maps/symbols/font-awesome/plus-square.png +0 -0
  111. package/lib/maps/symbols/font-awesome/plus.png +0 -0
  112. package/lib/maps/symbols/font-awesome/square.png +0 -0
  113. package/lib/maps/symbols/font-awesome/star.png +0 -0
  114. package/lib/maps/symbols/font-awesome/thumbs-down.png +0 -0
  115. package/lib/maps/symbols/font-awesome/thumbs-up.png +0 -0
  116. package/lib/maps/symbols/font-awesome/ticket.png +0 -0
  117. package/lib/maps/symbols/font-awesome/times-circle.png +0 -0
  118. package/lib/maps/symbols/font-awesome/times.png +0 -0
  119. package/lib/maps/symbols/font-awesome/tint.png +0 -0
  120. package/lib/maps/symbols/font-awesome/tree.png +0 -0
  121. package/lib/maps/symbols/font-awesome/university.png +0 -0
  122. package/lib/maps/symbols/font-awesome/usd.png +0 -0
  123. package/lib/maps/symbols/font-awesome/user.png +0 -0
  124. package/lib/maps/symbols/font-awesome/users.png +0 -0
  125. package/lib/maps/symbols/font-awesome/wheelchair.png +0 -0
  126. package/lib/maps/symbols/sdf-ize.sh +93 -0
  127. package/lib/maps/vectorMaps.d.ts +6 -6
  128. package/lib/maps/vectorMaps.js +33 -45
  129. package/lib/mwater_table_selection/IndicatorsListComponent.d.ts +4 -2
  130. package/lib/mwater_table_selection/IndicatorsListComponent.js +103 -34
  131. package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.d.ts +18 -0
  132. package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.js +80 -0
  133. package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.d.ts +26 -0
  134. package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.js +237 -51
  135. package/lib/mwater_table_selection/MWaterTableSelectComponent.d.ts +2 -2
  136. package/lib/mwater_table_selection/MWaterTableSelectComponent.js +9 -4
  137. package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.d.ts +19 -0
  138. package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.js +111 -0
  139. package/lib/quickfilter/QuickfiltersComponent.d.ts +3 -102
  140. package/lib/quickfilter/QuickfiltersComponent.js +53 -110
  141. package/lib/quickfilter/TextLiteralComponent.d.ts +23 -47
  142. package/lib/quickfilter/TextLiteralComponent.js +85 -82
  143. package/lib/widgets/MapWidget.js +6 -3
  144. package/lib/widgets/text/ExprItemEditorComponent.d.ts +3 -8
  145. package/lib/widgets/text/ExprItemEditorComponent.js +36 -33
  146. package/lib/widgets/text/ExprUpdateModalComponent.d.ts +1 -0
  147. package/package.json +3 -4
  148. package/src/ColorComponent.tsx +2 -2
  149. package/src/MWaterContextComponent.tsx +1 -1
  150. package/src/{MWaterGlobalFiltersComponent.ts → MWaterGlobalFiltersComponent.tsx} +32 -33
  151. package/src/{MWaterLoaderComponent.ts → MWaterLoaderComponent.tsx} +17 -18
  152. package/src/TranslationsTabComponent.tsx +429 -0
  153. package/src/UndoStack.ts +14 -6
  154. package/src/dashboards/DashboardComponent.tsx +6 -5
  155. package/src/dashboards/DashboardDesign.ts +1 -1
  156. package/src/dashboards/ServerDashboardDataSource.ts +0 -31
  157. package/src/dashboards/SettingsModalComponent.tsx +27 -383
  158. package/src/datagrids/DatagridComponent.tsx +36 -2
  159. package/src/datagrids/DatagridDesignerComponent.tsx +241 -229
  160. package/src/datagrids/DatagridViewComponent.tsx +44 -7
  161. package/src/datagrids/OrderBysDesignerComponent.tsx +61 -70
  162. package/src/index.css +45 -2
  163. package/src/index.ts +5 -11
  164. package/src/layouts/blocks/BlocksDisplayComponent.tsx +60 -5
  165. package/src/maps/BufferLayer.ts +30 -263
  166. package/src/maps/BufferLayerDesign.ts +1 -1
  167. package/src/maps/BufferLayerDesignerComponent.tsx +2 -7
  168. package/src/maps/ChoroplethLayer.ts +30 -394
  169. package/src/maps/ChoroplethLayerDesign.ts +5 -2
  170. package/src/maps/ChoroplethLayerDesigner.tsx +169 -165
  171. package/src/maps/ClusterLayer.ts +0 -274
  172. package/src/maps/DirectMapDataSource.ts +2 -61
  173. package/src/maps/EditHoverOver.tsx +9 -5
  174. package/src/maps/GridLayer.ts +0 -224
  175. package/src/maps/HoverContent.tsx +1 -1
  176. package/src/maps/Layer.ts +1 -35
  177. package/src/maps/LeafletMapComponent.tsx +10 -19
  178. package/src/maps/MapComponent.tsx +448 -0
  179. package/src/maps/MapControlComponent.tsx +41 -0
  180. package/src/maps/MapDesign.ts +6 -0
  181. package/src/maps/MapDesignerComponent.tsx +18 -1
  182. package/src/maps/MapLayerDataSource.ts +0 -5
  183. package/src/maps/MapLayerViewDesignerComponent.ts +9 -2
  184. package/src/maps/MapLayersDesignerComponent.ts +4 -1
  185. package/src/maps/MapTranslationsTab.tsx +53 -0
  186. package/src/maps/MapUtils.ts +61 -1
  187. package/src/maps/MapViewComponent.tsx +2 -8
  188. package/src/maps/MarkersLayer.ts +101 -275
  189. package/src/maps/MarkersLayerDesign.ts +7 -1
  190. package/src/maps/MarkersLayerDesignerComponent.tsx +436 -0
  191. package/src/maps/ServerMapDataSource.ts +0 -31
  192. package/src/maps/SwitchableTileUrlLayer.tsx +0 -11
  193. package/src/maps/TileUrlLayer.tsx +0 -6
  194. package/src/maps/VectorMapViewComponent.tsx +15 -15
  195. package/src/maps/symbols/font-awesome/asterisk.png +0 -0
  196. package/src/maps/symbols/font-awesome/ban.png +0 -0
  197. package/src/maps/symbols/font-awesome/beer.png +0 -0
  198. package/src/maps/symbols/font-awesome/bell.png +0 -0
  199. package/src/maps/symbols/font-awesome/bolt.png +0 -0
  200. package/src/maps/symbols/font-awesome/building.png +0 -0
  201. package/src/maps/symbols/font-awesome/bullseye.png +0 -0
  202. package/src/maps/symbols/font-awesome/bus.png +0 -0
  203. package/src/maps/symbols/font-awesome/caret-up.png +0 -0
  204. package/src/maps/symbols/font-awesome/certificate.png +0 -0
  205. package/src/maps/symbols/font-awesome/check-circle.png +0 -0
  206. package/src/maps/symbols/font-awesome/check.png +0 -0
  207. package/src/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
  208. package/src/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
  209. package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
  210. package/src/maps/symbols/font-awesome/cloud.png +0 -0
  211. package/src/maps/symbols/font-awesome/comment.png +0 -0
  212. package/src/maps/symbols/font-awesome/crosshairs.png +0 -0
  213. package/src/maps/symbols/font-awesome/dot-circle-o.png +0 -0
  214. package/src/maps/symbols/font-awesome/exclamation-circle.png +0 -0
  215. package/src/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
  216. package/src/maps/symbols/font-awesome/female.png +0 -0
  217. package/src/maps/symbols/font-awesome/file.png +0 -0
  218. package/src/maps/symbols/font-awesome/flag.png +0 -0
  219. package/src/maps/symbols/font-awesome/flask.png +0 -0
  220. package/src/maps/symbols/font-awesome/h-square.png +0 -0
  221. package/src/maps/symbols/font-awesome/home.png +0 -0
  222. package/src/maps/symbols/font-awesome/info-circle.png +0 -0
  223. package/src/maps/symbols/font-awesome/male.png +0 -0
  224. package/src/maps/symbols/font-awesome/medkit.png +0 -0
  225. package/src/maps/symbols/font-awesome/mobile.png +0 -0
  226. package/src/maps/symbols/font-awesome/plus-circle.png +0 -0
  227. package/src/maps/symbols/font-awesome/plus-square.png +0 -0
  228. package/src/maps/symbols/font-awesome/plus.png +0 -0
  229. package/src/maps/symbols/font-awesome/square.png +0 -0
  230. package/src/maps/symbols/font-awesome/star.png +0 -0
  231. package/src/maps/symbols/font-awesome/thumbs-down.png +0 -0
  232. package/src/maps/symbols/font-awesome/thumbs-up.png +0 -0
  233. package/src/maps/symbols/font-awesome/ticket.png +0 -0
  234. package/src/maps/symbols/font-awesome/times-circle.png +0 -0
  235. package/src/maps/symbols/font-awesome/times.png +0 -0
  236. package/src/maps/symbols/font-awesome/tint.png +0 -0
  237. package/src/maps/symbols/font-awesome/tree.png +0 -0
  238. package/src/maps/symbols/font-awesome/university.png +0 -0
  239. package/src/maps/symbols/font-awesome/usd.png +0 -0
  240. package/src/maps/symbols/font-awesome/user.png +0 -0
  241. package/src/maps/symbols/font-awesome/users.png +0 -0
  242. package/src/maps/symbols/font-awesome/wheelchair.png +0 -0
  243. package/src/maps/symbols/sdf-ize.sh +93 -0
  244. package/src/maps/vectorMaps.tsx +32 -53
  245. package/src/mwater_table_selection/IndicatorsListComponent.tsx +165 -37
  246. package/src/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.tsx +111 -0
  247. package/src/mwater_table_selection/MWaterCompleteTableSelectComponent.tsx +373 -37
  248. package/src/mwater_table_selection/MWaterTableSelectComponent.tsx +12 -8
  249. package/src/mwater_table_selection/MWaterWorkflowsSelectComponent.tsx +159 -0
  250. package/src/quickfilter/{QuickfiltersComponent.ts → QuickfiltersComponent.tsx} +165 -158
  251. package/src/quickfilter/TextLiteralComponent.tsx +197 -0
  252. package/src/widgets/MapWidget.tsx +11 -1
  253. package/src/widgets/text/ExprItemEditorComponent.tsx +83 -77
  254. package/src/widgets/text/ExprUpdateModalComponent.tsx +1 -0
  255. package/test/UndoStackTests.ts +52 -1
  256. package/.storybook/config.js +0 -7
  257. package/.storybook/head.html +0 -3
  258. package/.storybook/webpack.config.js +0 -15
  259. package/src/maps/BingLayer.ts +0 -146
  260. package/src/maps/MapComponent.ts +0 -312
  261. package/src/maps/MapControlComponent.ts +0 -46
  262. package/src/maps/MarkersLayerDesignerComponent.ts +0 -374
  263. package/src/maps/RasterMapViewComponent.ts +0 -345
  264. package/src/quickfilter/TextLiteralComponent.ts +0 -165
  265. package/stories/UpdateableComponent.js +0 -29
  266. package/stories/consoles.js +0 -202
  267. package/stories/dashboards.js +0 -217
  268. package/stories/datagridDesign.js +0 -114
  269. package/stories/datagrids.js +0 -69
  270. package/stories/dates.js +0 -80
  271. package/stories/exprcomponent.js +0 -43
  272. package/stories/index.js +0 -18
  273. package/stories/leaflet.js +0 -59
  274. package/stories/maps.js +0 -24
  275. package/stories/pivotChart.js +0 -235
@@ -305,280 +305,6 @@ export default class ClusterLayer extends Layer<ClusterLayerDesign> {
305
305
  return query
306
306
  }
307
307
 
308
- // Gets the layer definition as JsonQL + CSS in format:
309
- // {
310
- // layers: array of { id: layer id, jsonql: jsonql that includes "the_webmercator_geom" as a column }
311
- // css: carto css
312
- // interactivity: (optional) { layer: id of layer, fields: array of field names }
313
- // }
314
- // arguments:
315
- // design: design of layer
316
- // schema: schema to use
317
- // filters: array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to put in table alias
318
- getJsonQLCss(design: ClusterLayerDesign, schema: Schema, filters: JsonQLFilter[]) {
319
- // Create design
320
- const layerDef = {
321
- layers: [{ id: "layer0", jsonql: this.createMapnikJsonQL(design, schema, filters) }],
322
- css: this.createCss(design, schema)
323
- // interactivity: {
324
- // layer: "layer0"
325
- // fields: ["id"]
326
- // }
327
- }
328
-
329
- return layerDef
330
- }
331
-
332
- createMapnikJsonQL(design: ClusterLayerDesign, schema: Schema, filters: JsonQLFilter[]): JsonQLQuery {
333
- const axisBuilder = new AxisBuilder({ schema })
334
- const exprCompiler = new ExprCompiler(schema)
335
-
336
- /*
337
- Query:
338
- Works by first snapping to grid and then clustering the clusters with slower DBSCAN method
339
-
340
- select
341
- ST_Centroid(ST_Collect(center)) as the_geom_webmercator,
342
- sum(cnt) as cnt,
343
- log(sum(cnt)) * 6 + 14 as size from
344
- (
345
- select
346
- ST_ClusterDBSCAN(center, (!pixel_width!*30 + !pixel_height!*30)/2, 1) over () as clust,
347
- sub1.center as center,
348
- cnt as cnt
349
- from
350
- (
351
- select
352
- count(*) as cnt,
353
- ST_Centroid(ST_Collect(<geometry axis>)) as center,
354
- round(ST_XMin(<geometry axis>) / (!pixel_width!*40)) as gridx,
355
- round(ST_YMin(<geometry axis>) / (!pixel_width!*40)) as gridy,
356
- from <table> as main
357
- where <geometry axis> && !bbox!
358
- and <geometry axis> is not null
359
- and <other filters>
360
- group by 3, 4
361
- ) as sub1
362
- ) as sub2
363
- group by sub2.clust
364
-
365
- */
366
-
367
- // Compile geometry axis
368
- let geometryExpr = axisBuilder.compileAxis({ axis: design.axes.geometry!, tableAlias: "main" })
369
-
370
- // ST_Centroid(ST_Collect(<geometry axis>))
371
- let centerExpr: JsonQLExpr = {
372
- type: "op",
373
- op: "ST_Centroid",
374
- exprs: [
375
- {
376
- type: "op",
377
- op: "ST_Collect",
378
- exprs: [geometryExpr]
379
- }
380
- ]
381
- }
382
-
383
- const gridXExpr: JsonQLExpr = {
384
- type: "op",
385
- op: "round",
386
- exprs: [
387
- {
388
- type: "op",
389
- op: "/",
390
- exprs: [
391
- { type: "op", op: "ST_XMin", exprs: [geometryExpr] },
392
- { type: "op", op: "*", exprs: [{ type: "token", token: "!pixel_width!" }, 40] }
393
- ]
394
- }
395
- ]
396
- }
397
-
398
- const gridYExpr: JsonQLExpr = {
399
- type: "op",
400
- op: "round",
401
- exprs: [
402
- {
403
- type: "op",
404
- op: "/",
405
- exprs: [
406
- { type: "op", op: "ST_YMin", exprs: [geometryExpr] },
407
- { type: "op", op: "*", exprs: [{ type: "token", token: "!pixel_height!" }, 5] }
408
- ]
409
- }
410
- ]
411
- }
412
-
413
- // Create inner query
414
- const innerQuery: JsonQLQuery = {
415
- type: "query",
416
- selects: [
417
- { type: "select", expr: { type: "op", op: "count", exprs: [] }, alias: "cnt" },
418
- { type: "select", expr: centerExpr, alias: "center" },
419
- { type: "select", expr: gridXExpr, alias: "gridx" },
420
- { type: "select", expr: gridYExpr, alias: "gridy" }
421
- ],
422
- from: exprCompiler.compileTable(design.table, "main"),
423
- groupBy: [3, 4]
424
- }
425
-
426
- // Create filters. First ensure geometry and limit to bounding box
427
- let whereClauses: JsonQLExpr[] = [
428
- {
429
- type: "op",
430
- op: "&&",
431
- exprs: [geometryExpr, { type: "token", token: "!bbox!" }]
432
- }
433
- ]
434
-
435
- // Then add filters baked into layer
436
- if (design.filter) {
437
- whereClauses.push(exprCompiler.compileExpr({ expr: design.filter || null, tableAlias: "main" }))
438
- }
439
-
440
- // Then add extra filters passed in, if relevant
441
- // Get relevant filters
442
- const relevantFilters = _.where(filters, { table: design.table })
443
- for (let filter of relevantFilters) {
444
- whereClauses.push(injectTableAlias(filter.jsonql, "main"))
445
- }
446
-
447
- whereClauses = _.compact(whereClauses)
448
-
449
- // Wrap if multiple
450
- if (whereClauses.length > 1) {
451
- innerQuery.where = { type: "op", op: "and", exprs: whereClauses }
452
- } else {
453
- innerQuery.where = whereClauses[0]
454
- }
455
-
456
- // Create next level
457
- // select
458
- // ST_ClusterDBSCAN(center, (!pixel_width!*30 + !pixel_height!*30)/2, 1) over () as clust,
459
- // sub1.center as center,
460
- // cnt as cnt from () as innerquery
461
- const clustExpr: JsonQLExpr = {
462
- type: "op",
463
- op: "ST_ClusterDBSCAN",
464
- exprs: [
465
- { type: "field", tableAlias: "innerquery", column: "center" },
466
- {
467
- type: "op",
468
- op: "/",
469
- exprs: [
470
- {
471
- type: "op",
472
- op: "+",
473
- exprs: [
474
- { type: "op", op: "*", exprs: [{ type: "token", token: "!pixel_width!" }, 30] },
475
- { type: "op", op: "*", exprs: [{ type: "token", token: "!pixel_height!" }, 30] }
476
- ]
477
- },
478
- 2
479
- ]
480
- },
481
- 1
482
- ],
483
- over: {}
484
- }
485
-
486
- const inner2Query: JsonQLQuery = {
487
- type: "query",
488
- selects: [
489
- { type: "select", expr: clustExpr, alias: "clust" },
490
- { type: "select", expr: { type: "field", tableAlias: "innerquery", column: "center" }, alias: "center" },
491
- { type: "select", expr: { type: "field", tableAlias: "innerquery", column: "cnt" }, alias: "cnt" }
492
- ],
493
- from: { type: "subquery", query: innerQuery, alias: "innerquery" }
494
- }
495
-
496
- // Create final level
497
- // ST_Centroid(ST_Collect(center)) as the_geom_webmercator,
498
- // sum(cnt) as cnt,
499
- // log(sum(cnt)) * 6 + 14 as size from
500
-
501
- // ST_Centroid(ST_Collect(center))
502
- centerExpr = {
503
- type: "op",
504
- op: "ST_Centroid",
505
- exprs: [
506
- {
507
- type: "op",
508
- op: "ST_Collect",
509
- exprs: [{ type: "field", tableAlias: "inner2query", column: "center" }]
510
- }
511
- ]
512
- }
513
-
514
- const cntExpr: JsonQLExpr = {
515
- type: "op",
516
- op: "sum",
517
- exprs: [{ type: "field", tableAlias: "inner2query", column: "cnt" }]
518
- }
519
-
520
- const sizeExpr: JsonQLExpr = {
521
- type: "op",
522
- op: "+",
523
- exprs: [{ type: "op", op: "*", exprs: [{ type: "op", op: "log", exprs: [cntExpr] }, 6] }, 14]
524
- }
525
-
526
- const query: JsonQLQuery = {
527
- type: "query",
528
- selects: [
529
- { type: "select", expr: centerExpr, alias: "the_geom_webmercator" },
530
- { type: "select", expr: cntExpr, alias: "cnt" },
531
- { type: "select", expr: sizeExpr, alias: "size" }
532
- ],
533
- from: { type: "subquery", query: inner2Query, alias: "inner2query" },
534
- groupBy: [{ type: "field", tableAlias: "inner2query", column: "clust" }]
535
- }
536
-
537
- return query
538
- }
539
-
540
- createCss(design: ClusterLayerDesign, schema: Schema) {
541
- const css =
542
- `\
543
- #layer0 [cnt>1] {
544
- marker-width: [size];
545
- marker-line-color: white;
546
- marker-line-width: 4;
547
- marker-line-opacity: 0.6;
548
- marker-placement: point;
549
- marker-type: ellipse;
550
- marker-allow-overlap: true;
551
- marker-fill: ` +
552
- (design.fillColor || "#337ab7") +
553
- `;
554
- }
555
-
556
- #layer0::l1 [cnt>1] {
557
- text-name: [cnt];
558
- text-face-name: 'Arial Bold';
559
- text-allow-overlap: true;
560
- text-fill: ` +
561
- (design.textColor || "white") +
562
- `;
563
- }
564
-
565
- #layer0 [cnt=1] {
566
- marker-width: 10;
567
- marker-line-color: white;
568
- marker-line-width: 2;
569
- marker-line-opacity: 0.6;
570
- marker-placement: point;
571
- marker-type: ellipse;
572
- marker-allow-overlap: true;
573
- marker-fill: ` +
574
- (design.fillColor || "#337ab7") +
575
- `;
576
- }\
577
- `
578
-
579
- return css
580
- }
581
-
582
308
  // # Called when the interactivity grid is clicked.
583
309
  // # arguments:
584
310
  // # ev: { data: interactivty data e.g. `{ id: 123 }` }
@@ -8,7 +8,7 @@ import MapBoundsCalculator from "./MapBoundsCalculator"
8
8
  import { MapDesign, MapLayerView } from "./MapDesign"
9
9
  import { MapDataSource } from "./MapDataSource"
10
10
  import DirectWidgetDataSource from "../widgets/DirectWidgetDataSource"
11
- import { JsonQLCssLayerDefinition, VectorTileCTE, VectorTileDef, VectorTileSourceLayer } from "./Layer"
11
+ import { VectorTileCTE, VectorTileDef, VectorTileSourceLayer } from "./Layer"
12
12
  import compressJson from "../compressJson"
13
13
  import querystring from "querystring"
14
14
  import { MapLayerDataSource } from "./MapLayerDataSource"
@@ -282,32 +282,7 @@ class DirectLayerDataSource implements MapLayerDataSource {
282
282
  return (layer as TileUrlLayer).getTileUrl(design, filters)
283
283
  }
284
284
 
285
- // Get JsonQLCss
286
- const jsonqlCss = layer.getJsonQLCss(design, this.options.schema, filters)
287
-
288
- return this.createUrl("png", jsonqlCss)
289
- }
290
-
291
- // Get the url for the interactivity tiles with the specified filters applied
292
- // Called with (design, filters) where design is the design of the layer and filters are filters to apply. Returns URL
293
- getUtfGridUrl(design: any, filters: JsonQLFilter[]) {
294
- // Create layer
295
- const layer = LayerFactory.createLayer(this.options.layerView.type)
296
-
297
- // Handle special cases
298
- if (this.options.layerView.type === "MWaterServer") {
299
- return this.createLegacyUrl(design, "grid.json", filters)
300
- }
301
-
302
- // If layer has tiles url directly available
303
- if (layer.getLayerDefinitionType() === "TileUrl") {
304
- return layer.getUtfGridUrl(design, filters)
305
- }
306
-
307
- // Get JsonQLCss
308
- const jsonqlCss = layer.getJsonQLCss(design, this.options.schema, filters)
309
-
310
- return this.createUrl("grid.json", jsonqlCss)
285
+ throw new Error("Layer type not supported: " + this.options.layerView.type)
311
286
  }
312
287
 
313
288
  // Gets widget data source for a popup widget
@@ -331,45 +306,11 @@ class DirectLayerDataSource implements MapLayerDataSource {
331
306
  })
332
307
  }
333
308
 
334
- // Create query string
335
- createUrl(extension: string, jsonqlCss: JsonQLCssLayerDefinition) {
336
- const query: any = {
337
- type: "jsonql",
338
- design: compressJson(jsonqlCss)
339
- }
340
-
341
- if (this.options.client) {
342
- query.client = this.options.client
343
- }
344
-
345
- // Make URL change when cache expired
346
- const cacheExpiry = this.options.dataSource.getCacheExpiry()
347
- if (cacheExpiry) {
348
- query.cacheExpiry = cacheExpiry
349
- }
350
-
351
- let url = `${this.options.apiUrl}maps/tiles/{z}/{x}/{y}.${extension}?` + querystring.stringify(query)
352
-
353
- // Add subdomains: {s} will be substituted with "a", "b" or "c" in leaflet for api.mwater.co only.
354
- // Used to speed queries
355
- if (url.match(/^https:\/\/api\.mwater\.co\//)) {
356
- url = url.replace(/^https:\/\/api\.mwater\.co\//, "https://{s}-api.mwater.co/")
357
- }
358
-
359
- return url
360
- }
361
-
362
309
  // Create query string
363
310
  createLegacyUrl(design: any, extension: string, filters: JsonQLFilter[]) {
364
311
  let where
365
312
  let url = `${this.options.apiUrl}maps/tiles/{z}/{x}/{y}.${extension}?type=${design.type}&radius=1000`
366
313
 
367
- // Add subdomains: {s} will be substituted with "a", "b" or "c" in leaflet for api.mwater.co only.
368
- // Used to speed queries
369
- if (url.match(/^https:\/\/api\.mwater\.co\//)) {
370
- url = url.replace(/^https:\/\/api\.mwater\.co\//, "https://{s}-api.mwater.co/")
371
- }
372
-
373
314
  if (this.options.client) {
374
315
  url += `&client=${this.options.client}`
375
316
  }
@@ -1,5 +1,5 @@
1
1
  import { omit } from "lodash"
2
- import { DataSource, Expr, ExprUtils, Schema } from "@mwater/expressions"
2
+ import { AggrStatus, DataSource, Expr, ExprUtils, Schema } from "@mwater/expressions"
3
3
  import { ExprComponent } from "@mwater/expressions-ui"
4
4
  import React, { useState } from "react"
5
5
  import ActionCancelModalComponent from "@mwater/react-library/lib/ActionCancelModalComponent"
@@ -22,9 +22,12 @@ export interface EditHoverOverProps {
22
22
  /** Table of the row that join is to. Usually same as table except for choropleth maps */
23
23
  idTable: string
24
24
  defaultPopupFilterJoins: any
25
+
26
+ /** Aggr statuses to allow in hover over expressions */
27
+ aggrStatuses: AggrStatus[]
25
28
  }
26
29
 
27
- function EditHoverOver(props: EditHoverOverProps) {
30
+ export function EditHoverOver(props: EditHoverOverProps) {
28
31
  const { schema, dataSource, design, onDesignChange, table } = props
29
32
  const [editing, setEditing] = useState(false)
30
33
  const [draftItems, setDraftItems] = useState<HoverOverItem[] | undefined>(undefined)
@@ -103,6 +106,7 @@ function EditHoverOver(props: EditHoverOverProps) {
103
106
  onItemChange={handleItemChange}
104
107
  onItemDelete={handleItemDelete}
105
108
  item={item}
109
+ aggrStatuses={props.aggrStatuses}
106
110
  />
107
111
  ))}
108
112
  </tbody>
@@ -129,6 +133,8 @@ interface HoverOverItemEditorProps {
129
133
  onItemChange: (item: HoverOverItem) => void
130
134
  onItemDelete: (item: HoverOverItem) => void
131
135
  table: string
136
+ /** Aggr statuses to allow in hover over expressions */
137
+ aggrStatuses: AggrStatus[]
132
138
  }
133
139
 
134
140
  function HoverOverItemEditor(props: HoverOverItemEditorProps) {
@@ -173,7 +179,7 @@ function HoverOverItemEditor(props: HoverOverItemEditorProps) {
173
179
  types={["text", "number", "enum", "boolean", "date", "datetime", "id"]}
174
180
  onChange={expr => onItemChange({ ...item, value: expr })}
175
181
  value={item.value ?? null}
176
- aggrStatuses={["individual", "literal", "aggregate"]}
182
+ aggrStatuses={props.aggrStatuses}
177
183
  />
178
184
  </td>
179
185
  <td className="align-middle" style={{ width: "1%", whiteSpace: "nowrap" }}>
@@ -187,5 +193,3 @@ function HoverOverItemEditor(props: HoverOverItemEditorProps) {
187
193
  </tr>
188
194
  )
189
195
  }
190
-
191
- export default EditHoverOver
@@ -254,230 +254,6 @@ export default class GridLayer extends Layer<GridLayerDesign> {
254
254
  return query
255
255
  }
256
256
 
257
- /** Gets the layer definition as JsonQL + CSS in format:
258
- * {
259
- * layers: array of { id: layer id, jsonql: jsonql that includes "the_webmercator_geom" as a column }
260
- * css: carto css
261
- * interactivity: (optional) { layer: id of layer, fields: array of field names }
262
- * }
263
- * arguments:
264
- * design: design of layer
265
- * schema: schema to use
266
- * filters: array of filters to apply
267
- */
268
- getJsonQLCss(design: GridLayerDesign, schema: Schema, filters: JsonQLFilter[]): LayerDefinition {
269
- // Create design
270
- const layerDef = {
271
- layers: [{ id: "layer0", jsonql: this.createMapnikJsonQL(design, schema, filters) }],
272
- css: this.createCss(design, schema, filters),
273
- interactivity: {
274
- layer: "layer0",
275
- fields: ["id", "name"]
276
- }
277
- }
278
-
279
- return layerDef
280
- }
281
-
282
- createMapnikJsonQL(design: GridLayerDesign, schema: Schema, filters: JsonQLFilter[]): JsonQLQuery {
283
- const axisBuilder = new AxisBuilder({ schema })
284
- const exprCompiler = new ExprCompiler(schema)
285
-
286
- /* Compile to a query like this:
287
- select mwater_hex_make(grid.q, grid.r, !pixel_width!*SIZE) as the_geom_webmercator, data.color as color from
288
- mwater_hex_grid(!bbox!, !pixel_width!*SIZE) as grid
289
- left outer join
290
- (select qr.q as q, qr.r as r, COLOREXPR as color from TABLE as innerquery
291
- inner join mwater_hex_xy_to_qr(st_xmin(innerquery.LOCATIONEXPR), st_ymin(innerquery.LOCATIONEXPR), !pixel_width!*10) as qr
292
- on true
293
- where innerquery.LOCATIONEXPR && ST_Expand(!bbox!, SIZE)
294
- group by 1, 2) as data
295
- on data.q = grid.q and data.r = grid.r
296
- */
297
- const compiledGeometryExpr = exprCompiler.compileExpr({ expr: design.geometryExpr, tableAlias: "innerquery" })
298
- const colorExpr = axisBuilder.compileAxis({ axis: design.colorAxis, tableAlias: "innerquery" })
299
- let compiledSizeExpr: JsonQLExpr
300
-
301
- if (design.shape == "hex") {
302
- // Hex needs distance from center to points
303
- compiledSizeExpr =
304
- design.sizeUnits == "pixels"
305
- ? { type: "op", op: "*", exprs: [{ type: "token", token: "!pixel_width!" }, design.size! / 1.73205] }
306
- : { type: "literal", value: design.size! / 1.73205 }
307
- } else if (design.shape == "square") {
308
- // Square needs distance from center to center
309
- compiledSizeExpr =
310
- design.sizeUnits == "pixels"
311
- ? { type: "op", op: "*", exprs: [{ type: "token", token: "!pixel_width!" }, design.size!] }
312
- : { type: "literal", value: design.size! }
313
- } else {
314
- throw new Error("Unknown shape")
315
- }
316
-
317
- // Create inner query
318
- const innerQuery: JsonQLQuery = {
319
- type: "query",
320
- selects: [
321
- { type: "select", expr: { type: "field", tableAlias: "qr", column: "q" }, alias: "q" },
322
- { type: "select", expr: { type: "field", tableAlias: "qr", column: "r" }, alias: "r" },
323
- { type: "select", expr: colorExpr, alias: "color" }
324
- ],
325
- from: {
326
- type: "join",
327
- kind: "inner",
328
- left: { type: "table", table: design.table!, alias: "innerquery" },
329
- right: {
330
- type: "subexpr",
331
- expr: {
332
- type: "op",
333
- op: `mwater_${design.shape}_xy_to_qr`,
334
- exprs: [
335
- { type: "op", op: "ST_XMin", exprs: [compiledGeometryExpr] },
336
- { type: "op", op: "ST_YMin", exprs: [compiledGeometryExpr] },
337
- compiledSizeExpr
338
- ]
339
- },
340
- alias: "qr"
341
- },
342
- on: { type: "literal", value: true }
343
- },
344
- groupBy: [1, 2]
345
- }
346
-
347
- // Filter by bounding box
348
- let whereClauses: JsonQLExpr[] = [
349
- {
350
- type: "op",
351
- op: "&&",
352
- exprs: [
353
- compiledGeometryExpr,
354
- { type: "op", op: "ST_Expand", exprs: [{ type: "token", token: "!bbox!" }, compiledSizeExpr] }
355
- ]
356
- }
357
- ]
358
-
359
- // Then add filters
360
- if (design.filter) {
361
- whereClauses.push(exprCompiler.compileExpr({ expr: design.filter, tableAlias: "innerquery" }))
362
- }
363
-
364
- // Then add extra filters passed in, if relevant
365
- const relevantFilters = _.where(filters, { table: design.table })
366
- for (let filter of relevantFilters) {
367
- whereClauses.push(injectTableAlias(filter.jsonql, "innerquery"))
368
- }
369
-
370
- whereClauses = _.compact(whereClauses)
371
- if (whereClauses.length > 0) {
372
- innerQuery.where = { type: "op", op: "and", exprs: whereClauses }
373
- }
374
-
375
- // Now create outer query
376
- const query: JsonQLQuery = {
377
- type: "query",
378
- selects: [
379
- {
380
- type: "select",
381
- expr: {
382
- type: "op",
383
- op: `mwater_${design.shape}_make`,
384
- exprs: [
385
- { type: "field", tableAlias: "grid", column: "q" },
386
- { type: "field", tableAlias: "grid", column: "r" },
387
- compiledSizeExpr
388
- ]
389
- },
390
- alias: "the_geom_webmercator"
391
- },
392
- { type: "select", expr: { type: "field", tableAlias: "data", column: "color" }, alias: "color" }
393
- ],
394
- from: {
395
- type: "join",
396
- kind: "left",
397
- left: {
398
- type: "subexpr",
399
- expr: {
400
- type: "op",
401
- op: `mwater_${design.shape}_grid`,
402
- exprs: [{ type: "token", token: "!bbox!" }, compiledSizeExpr]
403
- },
404
- alias: "grid"
405
- },
406
- right: { type: "subquery", query: innerQuery, alias: "data" },
407
- // on data.q = grid.q and data.r = grid.r
408
- on: {
409
- type: "op",
410
- op: "and",
411
- exprs: [
412
- {
413
- type: "op",
414
- op: "=",
415
- exprs: [
416
- { type: "field", tableAlias: "data", column: "q" },
417
- { type: "field", tableAlias: "grid", column: "q" }
418
- ]
419
- },
420
- {
421
- type: "op",
422
- op: "=",
423
- exprs: [
424
- { type: "field", tableAlias: "data", column: "r" },
425
- { type: "field", tableAlias: "grid", column: "r" }
426
- ]
427
- }
428
- ]
429
- }
430
- }
431
- }
432
-
433
- return query
434
- }
435
-
436
- createCss(design: GridLayerDesign, schema: Schema, filters: JsonQLFilter[]): string {
437
- let css =
438
- `
439
- #layer0 {
440
- polygon-opacity: ` +
441
- design.fillOpacity +
442
- `;
443
- ` +
444
- (design.borderStyle == "color"
445
- ? `line-opacity: ` + (1 - (1 - design.fillOpacity!) / 2) + `; `
446
- : `line-width: 0;`) +
447
- `
448
- polygon-fill: transparent;
449
- }
450
- \
451
- `
452
- if (!design.colorAxis) {
453
- throw new Error("Color axis not set")
454
- }
455
- // If color axes, add color conditions
456
- if (design.colorAxis.colorMap) {
457
- for (let item of design.colorAxis.colorMap) {
458
- // If invisible
459
- if (design.colorAxis.excludedValues && _.any(design.colorAxis.excludedValues, (ev) => ev === item.value)) {
460
- css += `#layer0 [color=${JSON.stringify(item.value)}] {
461
- line-color: transparent;
462
- line-opacity: 0;
463
- polygon-opacity: 0;
464
- polygon-fill: transparent;
465
- }\n`
466
- } else {
467
- css +=
468
- `#layer0 [color=${JSON.stringify(item.value)}] {
469
- ` +
470
- (design.borderStyle == "color" ? `line-color: ${item.color};` : "") +
471
- `
472
- polygon-fill: ${item.color};
473
- }\n`
474
- }
475
- }
476
- }
477
-
478
- return css
479
- }
480
-
481
257
  // TODO
482
258
  // /**
483
259
  // * Called when the interactivity grid is clicked.
@@ -57,7 +57,7 @@ const HoverContent = (props: HoverContentProps) => {
57
57
  }
58
58
 
59
59
  return (
60
- <div className="_mviz-map-hover-content">
60
+ <div className="mwater-visualization-map-hover-content">
61
61
  {props.items.map((item: HoverOverItem) => {
62
62
  let value = values[item.id]
63
63