@kalisio/kdk 2.1.9 → 2.2.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 (272) hide show
  1. package/.travis.test.sh +42 -10
  2. package/README.md +2 -2
  3. package/core/api/application.js +7 -2
  4. package/core/api/authentication.js +17 -1
  5. package/core/api/db.js +7 -2
  6. package/core/api/hooks/hooks.authentication.js +4 -2
  7. package/core/api/hooks/hooks.authorisations.js +12 -2
  8. package/core/api/hooks/hooks.model.js +5 -5
  9. package/core/api/hooks/hooks.organisations.js +0 -4
  10. package/core/api/services/account/account.hooks.js +10 -6
  11. package/core/api/services/account/account.service.js +1 -1
  12. package/{map/api/services/geocoder/geocoder.hooks.js → core/api/services/import-export/import-export.hooks.js} +7 -5
  13. package/core/api/services/import-export/import-export.service.js +11 -0
  14. package/core/api/services/index.js +13 -1
  15. package/core/api/services/users/users.hooks.js +2 -3
  16. package/core/client/api.js +16 -14
  17. package/core/client/capabilities.js +6 -2
  18. package/core/client/components/KContent.vue +11 -1
  19. package/core/client/components/KDialog.vue +17 -15
  20. package/core/client/components/KModal.vue +1 -1
  21. package/core/client/components/KSponsor.vue +1 -1
  22. package/core/client/components/KTextArea.vue +5 -1
  23. package/core/client/components/app/KAbout.vue +1 -2
  24. package/core/client/components/app/KWelcome.vue +3 -5
  25. package/core/client/components/chart/KTimeSeriesChart.vue +24 -37
  26. package/core/client/components/collection/KColumn.vue +20 -17
  27. package/core/client/components/editor/KModalEditor.vue +0 -2
  28. package/core/client/components/form/KChipsField.vue +12 -2
  29. package/core/client/components/form/KColorField.vue +12 -2
  30. package/core/client/components/form/KColorScaleField.vue +12 -2
  31. package/core/client/components/form/KDateTimeRangeField.vue +12 -2
  32. package/core/client/components/form/KDatetimeField.vue +12 -2
  33. package/core/client/components/form/KEmailField.vue +12 -2
  34. package/core/client/components/form/KFileField.vue +12 -2
  35. package/core/client/components/form/KForm.vue +47 -9
  36. package/core/client/components/form/KIconField.vue +12 -2
  37. package/core/client/components/form/KItemField.vue +25 -4
  38. package/core/client/components/form/KNumberField.vue +12 -2
  39. package/core/client/components/form/KOptionsField.vue +12 -2
  40. package/core/client/components/form/KPasswordField.vue +12 -2
  41. package/core/client/components/form/KPhoneField.vue +13 -3
  42. package/core/client/components/form/KPropertyItemField.vue +12 -2
  43. package/core/client/components/form/KResolutionField.vue +126 -0
  44. package/core/client/components/form/KRoleField.vue +12 -2
  45. package/core/client/components/form/KSelectField.vue +14 -4
  46. package/core/client/components/form/KTextField.vue +12 -2
  47. package/core/client/components/form/KTextareaField.vue +13 -3
  48. package/core/client/components/form/KToggleField.vue +12 -2
  49. package/core/client/components/form/KTokenField.vue +12 -2
  50. package/core/client/components/form/KUnitField.vue +12 -2
  51. package/core/client/components/form/KUrlField.vue +12 -2
  52. package/core/client/components/input/KIconChooser.vue +10 -12
  53. package/core/client/components/input/KPalette.vue +2 -1
  54. package/core/client/components/layout/KPage.vue +5 -4
  55. package/core/client/components/layout/KWindow.vue +10 -10
  56. package/core/client/components/media/KColorScale.vue +25 -19
  57. package/core/client/components/media/KImageViewer.vue +57 -33
  58. package/core/client/components/media/KShape.vue +14 -103
  59. package/core/client/components/screen/KRegisterScreen.vue +0 -1
  60. package/core/client/components/screen/KScreenFooter.vue +0 -18
  61. package/core/client/components/team/KAddMember.vue +16 -22
  62. package/core/client/components/team/KGroupsActivity.vue +14 -0
  63. package/core/client/components/team/KMembersActivity.vue +12 -0
  64. package/core/client/components/team/KTagsActivity.vue +14 -0
  65. package/core/client/components/time/KDateTime.vue +23 -7
  66. package/core/client/components/time/KTimeControl.vue +142 -0
  67. package/core/client/components/tool/KExportTool.vue +57 -0
  68. package/core/client/composables/collection.js +0 -1
  69. package/core/client/composables/pwa.js +0 -1
  70. package/core/client/composables/schema.js +1 -1
  71. package/core/client/composables/session.js +30 -6
  72. package/core/client/exporter.js +147 -0
  73. package/core/client/i18n/core_en.json +91 -23
  74. package/core/client/i18n/core_fr.json +92 -23
  75. package/core/client/index.js +3 -0
  76. package/core/client/layout.js +34 -14
  77. package/core/client/local-storage.js +8 -6
  78. package/core/client/mixins/index.js +0 -1
  79. package/core/client/mixins/mixin.base-field.js +24 -2
  80. package/core/client/mixins/mixin.object-proxy.js +0 -1
  81. package/core/client/search.js +2 -1
  82. package/core/client/services/index.js +2 -1
  83. package/core/client/services/local-settings.service.js +4 -4
  84. package/core/client/theme.js +3 -3
  85. package/core/client/time.js +4 -0
  86. package/core/client/units.js +150 -5
  87. package/core/client/utils/index.js +13 -6
  88. package/core/client/utils/utils.account.js +1 -1
  89. package/core/client/utils/utils.colors.js +43 -0
  90. package/core/client/utils/utils.platform.js +0 -1
  91. package/core/client/utils/utils.pwa.js +14 -14
  92. package/core/client/utils/utils.session.js +1 -1
  93. package/core/client/utils/utils.shapes.js +270 -0
  94. package/core/client/utils/utils.time.js +37 -0
  95. package/core/common/permissions.js +3 -0
  96. package/core/common/schemas/settings.update.json +50 -29
  97. package/extras/css/core.variables.scss +3 -1
  98. package/extras/icons/wind-speed-0.svg +8 -0
  99. package/extras/icons/wind-speed-10.svg +8 -0
  100. package/extras/icons/wind-speed-100.svg +12 -0
  101. package/extras/icons/wind-speed-105.svg +13 -0
  102. package/extras/icons/wind-speed-15.svg +9 -0
  103. package/extras/icons/wind-speed-20.svg +9 -0
  104. package/extras/icons/wind-speed-25.svg +10 -0
  105. package/extras/icons/wind-speed-30.svg +10 -0
  106. package/extras/icons/wind-speed-35.svg +11 -0
  107. package/extras/icons/wind-speed-40.svg +11 -0
  108. package/extras/icons/wind-speed-45.svg +12 -0
  109. package/extras/icons/wind-speed-5.svg +9 -0
  110. package/extras/icons/wind-speed-50.svg +9 -0
  111. package/extras/icons/wind-speed-55.svg +10 -0
  112. package/extras/icons/wind-speed-60.svg +10 -0
  113. package/extras/icons/wind-speed-65.svg +11 -0
  114. package/extras/icons/wind-speed-70.svg +11 -0
  115. package/extras/icons/wind-speed-75.svg +12 -0
  116. package/extras/icons/wind-speed-80.svg +12 -0
  117. package/extras/icons/wind-speed-85.svg +13 -0
  118. package/extras/icons/wind-speed-90.svg +13 -0
  119. package/extras/icons/wind-speed-95.svg +14 -0
  120. package/extras/tours/map/navigation-bar.js +17 -15
  121. package/extras/tours/map/timeline.js +33 -33
  122. package/map/api/config/categories.cjs +4 -1
  123. package/map/api/hooks/hooks.catalog.js +39 -0
  124. package/map/api/hooks/hooks.features.js +23 -3
  125. package/map/api/hooks/hooks.query.js +65 -21
  126. package/map/api/models/projects.model.mongodb.js +8 -0
  127. package/map/api/services/catalog/catalog.hooks.js +5 -3
  128. package/map/api/services/features/features.hooks.js +18 -6
  129. package/map/api/services/index.js +22 -6
  130. package/map/api/services/projects/projects.hooks.js +118 -0
  131. package/map/client/capture.js +16 -0
  132. package/map/client/cesium/utils/index.js +4 -0
  133. package/map/client/cesium/utils/utils.events.js +30 -0
  134. package/map/client/cesium/utils/utils.features.js +8 -0
  135. package/map/client/cesium/utils/utils.popup.js +17 -0
  136. package/map/client/cesium/utils/utils.style.js +137 -0
  137. package/map/client/components/KCapture.vue +50 -0
  138. package/map/client/components/KCaptureTextArea.vue +53 -0
  139. package/map/client/components/KCompass.vue +2 -2
  140. package/map/client/components/KFeaturesChart.vue +1 -1
  141. package/map/client/components/KFeaturesFilter.vue +2 -2
  142. package/map/client/components/KLayerStyleForm.vue +288 -454
  143. package/map/client/components/KLevelSlider.vue +1 -1
  144. package/map/client/components/KNorth.vue +31 -0
  145. package/map/client/components/KProjectMenu.vue +88 -0
  146. package/map/client/components/KTimezoneMap.vue +36 -24
  147. package/map/client/components/catalog/KAddLayer.vue +3 -4
  148. package/map/client/components/catalog/KConnectLayer.vue +20 -4
  149. package/map/client/components/catalog/KCreateLayer.vue +1 -2
  150. package/map/client/components/catalog/KCreateProject.vue +100 -0
  151. package/map/client/components/catalog/KCreateView.vue +25 -2
  152. package/map/client/components/catalog/KLayersPanel.vue +24 -27
  153. package/map/client/components/catalog/KLayersSelector.vue +1 -1
  154. package/map/client/components/catalog/KProjectEditor.vue +91 -0
  155. package/map/client/components/catalog/KProjectManager.vue +60 -0
  156. package/map/client/components/catalog/KProjectSelector.vue +38 -0
  157. package/map/client/components/catalog/KProjectsPanel.vue +153 -0
  158. package/map/client/components/catalog/KSelectLayers.vue +96 -0
  159. package/map/client/components/catalog/KSelectViews.vue +96 -0
  160. package/map/client/components/catalog/KViewsPanel.vue +66 -30
  161. package/map/client/components/form/KDirectionField.vue +24 -5
  162. package/map/client/components/form/KLayerCategoryField.vue +12 -2
  163. package/map/client/components/form/KLocationField.vue +20 -5
  164. package/map/client/components/form/KOwsLayerField.vue +12 -2
  165. package/map/client/components/form/KOwsServiceField.vue +12 -2
  166. package/map/client/components/form/KSelectLayersField.vue +159 -0
  167. package/map/client/components/form/KSelectViewsField.vue +121 -0
  168. package/map/client/components/form/KTimezoneField.vue +24 -17
  169. package/map/client/components/legend/KColorScaleLegend.vue +6 -2
  170. package/map/client/components/legend/KLayerLegend.vue +71 -0
  171. package/map/client/components/legend/KLegend.vue +54 -51
  172. package/map/client/components/legend/KLegendRenderer.vue +5 -3
  173. package/map/client/components/legend/KSymbolsLegend.vue +12 -10
  174. package/map/client/components/legend/KVariablesLegend.vue +78 -0
  175. package/map/client/components/location/KGeocodersFilter.vue +2 -4
  176. package/map/client/components/location/KLocationCardSection.vue +8 -4
  177. package/map/client/components/location/KLocationMap.vue +48 -17
  178. package/map/client/components/location/KLocationSearch.vue +13 -3
  179. package/map/client/components/tools/KSearchTool.vue +17 -12
  180. package/map/client/components/widget/KElevationProfile.vue +16 -19
  181. package/map/client/components/widget/KMapillaryViewer.vue +21 -22
  182. package/map/client/components/widget/KTimeSeries.vue +35 -29
  183. package/map/client/composables/activity.js +15 -2
  184. package/map/client/composables/catalog.js +81 -0
  185. package/map/client/composables/highlight.js +45 -30
  186. package/map/client/composables/index.js +2 -0
  187. package/map/client/composables/location.js +25 -18
  188. package/map/client/composables/probe.js +4 -1
  189. package/map/client/composables/project.js +122 -0
  190. package/map/client/composables/weather.js +3 -3
  191. package/map/client/geolocation.js +1 -1
  192. package/map/client/globe.js +2 -0
  193. package/map/client/i18n/map_en.json +127 -76
  194. package/map/client/i18n/map_fr.json +128 -72
  195. package/map/client/index.js +3 -0
  196. package/map/client/init.js +17 -0
  197. package/map/client/leaflet/GSMaPLayer.js +16 -17
  198. package/map/client/leaflet/ShapeMarker.js +51 -0
  199. package/map/client/leaflet/TiledFeatureLayer.js +39 -9
  200. package/map/client/leaflet/TiledMeshLayer.js +13 -15
  201. package/map/client/leaflet/TiledWindLayer.js +6 -10
  202. package/map/client/leaflet/utils/index.js +4 -0
  203. package/map/client/leaflet/utils/utils.events.js +41 -0
  204. package/map/client/leaflet/utils/utils.popup.js +21 -0
  205. package/map/client/leaflet/utils/utils.style.js +195 -0
  206. package/map/client/leaflet/utils/utils.tiles.js +87 -0
  207. package/map/client/map.js +2 -0
  208. package/map/client/mixins/globe/mixin.base-globe.js +39 -18
  209. package/map/client/mixins/globe/mixin.geojson-layers.js +139 -69
  210. package/map/client/mixins/globe/mixin.popup.js +2 -1
  211. package/map/client/mixins/globe/mixin.style.js +6 -4
  212. package/map/client/mixins/globe/mixin.tooltip.js +8 -3
  213. package/map/client/mixins/map/mixin.base-map.js +53 -28
  214. package/map/client/mixins/map/mixin.edit-layers.js +15 -15
  215. package/map/client/mixins/map/mixin.forecast-layers.js +3 -1
  216. package/map/client/mixins/map/mixin.geojson-layers.js +60 -20
  217. package/map/client/mixins/map/mixin.georaster-layers.js +4 -11
  218. package/map/client/mixins/map/mixin.heatmap-layers.js +1 -1
  219. package/map/client/mixins/map/mixin.popup.js +2 -1
  220. package/map/client/mixins/map/mixin.style.js +4 -67
  221. package/map/client/mixins/map/mixin.tiled-mesh-layers.js +2 -1
  222. package/map/client/mixins/map/mixin.tiled-wind-layers.js +4 -2
  223. package/map/client/mixins/map/mixin.tooltip.js +2 -1
  224. package/map/client/mixins/mixin.activity.js +71 -192
  225. package/map/client/mixins/mixin.catalog-panel.js +6 -6
  226. package/map/client/mixins/mixin.context.js +12 -9
  227. package/map/client/mixins/mixin.feature-service.js +29 -300
  228. package/map/client/mixins/mixin.weacast.js +11 -17
  229. package/map/client/pixi-utils.js +1 -1
  230. package/map/client/planets.js +66 -0
  231. package/map/client/utils/index.js +6 -0
  232. package/map/client/utils/utils.capture.js +176 -0
  233. package/map/client/utils/utils.catalog.js +166 -0
  234. package/map/client/utils/utils.features.js +364 -0
  235. package/map/client/utils/utils.js +0 -151
  236. package/map/client/utils/utils.layers.js +175 -0
  237. package/map/client/utils/utils.location.js +91 -23
  238. package/map/client/utils/utils.project.js +8 -0
  239. package/map/client/utils/utils.schema.js +0 -1
  240. package/map/client/utils/utils.style.js +309 -0
  241. package/map/client/utils.all.js +2 -2
  242. package/map/client/utils.globe.js +1 -1
  243. package/map/client/utils.map.js +1 -1
  244. package/map/common/permissions.js +2 -0
  245. package/map/common/schemas/capture.create.json +132 -0
  246. package/map/common/schemas/projects.create.json +52 -0
  247. package/map/common/schemas/projects.update.json +52 -0
  248. package/map/common/wms-utils.js +8 -3
  249. package/package.json +6 -5
  250. package/test/api/core/account.test.js +20 -0
  251. package/test/api/core/config/default.cjs +16 -3
  252. package/test/api/core/import-export.test.js +86 -0
  253. package/test/api/core/test-log-2024-01-04.log +14 -0
  254. package/test/api/map/catalog.test.js +164 -0
  255. package/test/api/map/index.test.js +25 -61
  256. package/test/api/map/test-log-2024-01-04.log +2 -0
  257. package/test/api/map/test-log-2024-01-11.log +1 -0
  258. package/test/api/map/test-log-2024-01-25.log +19 -0
  259. package/test/client/core/layout.js +24 -5
  260. package/test/client/core/utils.js +7 -0
  261. package/test/client/map/catalog.js +78 -1
  262. package/test/client/map/time.js +2 -1
  263. package/core/client/components/screen/KEndpointScreen.vue +0 -80
  264. package/core/client/mixins/mixin.account.js +0 -61
  265. package/extras/icons/kdk.png +0 -0
  266. package/map/api/services/geocoder/geocoder.service.js +0 -79
  267. package/map/client/cesium/utils.js +0 -133
  268. package/map/client/components/KCaptureToolbar.vue +0 -155
  269. package/map/client/components/KColorLegend.vue +0 -349
  270. package/map/client/components/KTimeline.vue +0 -293
  271. package/map/client/components/KUrlLegend.vue +0 -122
  272. package/map/client/leaflet/utils.js +0 -246
@@ -3,11 +3,14 @@ import _ from 'lodash'
3
3
  import sift from 'sift'
4
4
  import logger from 'loglevel'
5
5
  import 'leaflet-realtime'
6
- import { Time } from '../../../../core/client/time.js'
6
+ import { Time, utils as kdkCoreUtils } from '../../../../core.client.js'
7
7
  import { GradientPath } from '../../leaflet/GradientPath.js'
8
8
  import { MaskLayer } from '../../leaflet/MaskLayer.js'
9
9
  import { TiledFeatureLayer } from '../../leaflet/TiledFeatureLayer.js'
10
- import { fetchGeoJson, LeafletEvents, bindLeafletEvents, unbindLeafletEvents, getFeatureId } from '../../utils.map.js'
10
+ import {
11
+ fetchGeoJson, LeafletEvents, bindLeafletEvents, unbindLeafletEvents, getFeatureId, isInMemoryLayer, getFeatureStyleType,
12
+ convertSimpleStyleToPointStyle, convertSimpleStyleToLineStyle, convertSimpleStyleToPolygonStyle, createMarkerFromPointStyle
13
+ } from '../../utils.map.js'
11
14
  import * as wfs from '../../../common/wfs-utils.js'
12
15
 
13
16
  // Override default remove handler for leaflet-realtime due to
@@ -79,6 +82,11 @@ export const geojsonLayers = {
79
82
  leafletOptions.updateFeature = function (feature, oldLayer) {
80
83
  // A new feature is coming, create it
81
84
  if (!oldLayer) return
85
+ const staticGeometry = _.get(leafletOptions, 'staticGeometry', false)
86
+ // Keep track of previous geometry if we don't want to update it
87
+ // Indeed, styling might depend on it
88
+ if (staticGeometry) feature.geometry = _.get(oldLayer, 'feature.geometry')
89
+
82
90
  // An existing one is found, simply update styling, properties, etc.
83
91
  leafletOptions.onEachFeature(feature, oldLayer)
84
92
  if (oldLayer.setStyle) {
@@ -92,9 +100,8 @@ export const geojsonLayers = {
92
100
  oldLayer.setStyle(leafletOptions.style(feature))
93
101
  }
94
102
  }
95
- // We want to restore values that were there till now but are missing
96
- // from the input feature.
97
- // Deep for time and runtime
103
+ // We want to restore values that were there till now but are missing from the input feature.
104
+ // Deep for time and runtime that might contain objects with variables
98
105
  _.defaultsDeep(feature, _.pick(oldLayer.feature, ['time', 'runTime']))
99
106
  // _NOT_ deep for properties, otherwise it'll merge array and object properties between the two
100
107
  const oldProps = _.get(oldLayer.feature, 'properties')
@@ -107,8 +114,7 @@ export const geojsonLayers = {
107
114
  // oldLayer.setIcon(_.get(leafletOptions.pointToLayer(feature, oldLayer.getLatLng()), 'options.icon'))
108
115
  return
109
116
  }
110
- // And coordinates if not static
111
- const staticGeometry = _.get(leafletOptions, 'staticGeometry', false)
117
+ // Now update coordinates if not static geometry
112
118
  if (staticGeometry) return oldLayer
113
119
  // The feature is changing its geometry type, recreate it
114
120
  const oldType = _.get(oldLayer, 'feature.geometry.type')
@@ -145,6 +151,9 @@ export const geojsonLayers = {
145
151
  }
146
152
  // Check for feature service layers
147
153
  if (options.service) {
154
+ // FIXME: need to retrieve original layer options as here we get processed options by the underlying engine
155
+ // and eg filtering depends on changing the state of the layer definition object at run time
156
+ options = this.getLayerByName(options.name)
148
157
  // We perform manual update
149
158
  _.set(leafletOptions, 'start', false)
150
159
  // Tell realtime plugin how to update/load data
@@ -158,9 +167,6 @@ export const geojsonLayers = {
158
167
  leafletOptions.removeMissing = !options.probeService
159
168
  let initialized = !options.probeService // If no probe reference, nothing to be initialized
160
169
  _.set(leafletOptions, 'source', async (successCallback, errorCallback) => {
161
- // FIXME: need to retrieve original layer options as here we get processed options by the underlying engine
162
- // and eg filtering depends on changing the state of the layer definition object at run time
163
- options = this.getLayerByName(options.name)
164
170
  // If the probe location is given by another service use it on initialization
165
171
  if (!initialized) {
166
172
  try {
@@ -261,6 +267,13 @@ export const geojsonLayers = {
261
267
  leafletOptions.panes = [pane]
262
268
  leafletOptions.pane = options.name
263
269
  leafletOptions.shadowPane = options.name
270
+ // Make pane available to styles as well as eg shape markers are created from here
271
+ for (const type in ['point', 'line', 'polygon']) {
272
+ if (_.has(leafletOptions, `style.${type}`)) {
273
+ _.set(leafletOptions, `style.${type}.pane`, options.name)
274
+ _.set(leafletOptions, `style.${type}.shadowPane`, options.name)
275
+ }
276
+ }
264
277
  }
265
278
  // If not explicitely disable use defaults for clustering
266
279
  if (!_.has(leafletOptions, 'cluster') && _.get(this, 'activityOptions.engine.cluster')) {
@@ -294,15 +307,32 @@ export const geojsonLayers = {
294
307
  if (tooltipTemplate) {
295
308
  leafletOptions.tooltip.compiler = _.template(tooltipTemplate)
296
309
  }
310
+ // Optimize styling by creating color scales up-front
311
+ const variables = _.get(options, 'variables', [])
312
+ variables.forEach(variable => {
313
+ if (_.has(variable, 'chromajs')) {
314
+ variable.colorScale = kdkCoreUtils.buildColorScale(_.get(variable, 'chromajs'))
315
+ }
316
+ })
317
+ // Convert and store the style
318
+ if (leafletOptions.style) {
319
+ leafletOptions.layerPointStyle = _.get(leafletOptions.style, 'point')
320
+ leafletOptions.layerLineStyle = _.get(leafletOptions.style, 'line')
321
+ leafletOptions.layerPolygonStyle = _.get(leafletOptions.style, 'polygon')
322
+ } else {
323
+ leafletOptions.layerPointStyle = convertSimpleStyleToPointStyle(leafletOptions)
324
+ leafletOptions.layerLineStyle = convertSimpleStyleToLineStyle(leafletOptions)
325
+ leafletOptions.layerPolygonStyle = convertSimpleStyleToPolygonStyle(leafletOptions)
326
+ }
297
327
  // Merge generic GeoJson options and layer options
298
328
  const geoJsonOptions = this.getGeoJsonOptions(options)
299
329
  Object.keys(geoJsonOptions).forEach(key => {
300
- // If layer provided do not override
301
- if (!_.has(leafletOptions, key)) _.set(leafletOptions, key, _.get(geoJsonOptions, key))
330
+ // If layer provided do not override execpt for the style
331
+ // Indeed the style property must be overriden to install the Leaflet function style
332
+ if (!_.has(leafletOptions, key) || (key === 'style')) _.set(leafletOptions, key, _.get(geoJsonOptions, key))
302
333
  })
303
- leafletOptions.layerStyle = this.convertFromSimpleStyleSpec(leafletOptions)
334
+ // Create the layer*/
304
335
  let layer = this.createLeafletLayer(options)
305
-
306
336
  // Specific case of realtime layer where the underlying container also need to be added to map
307
337
  if (leafletOptions.realtime) {
308
338
  // Build associated tile layer and bind required events
@@ -377,13 +407,22 @@ export const geojsonLayers = {
377
407
  bindLeafletEvents(layer, LeafletEvents.Feature, this, options)
378
408
  },
379
409
  style: (feature) => {
380
- return this.generateStyle('featureStyle', feature, options)
410
+ const styleType = getFeatureStyleType(feature)
411
+ if (!styleType) {
412
+ logger.warn(`[KDK] cannot get a style type from the feature of geometry type ${feature.geometry.type}`)
413
+ return
414
+ }
415
+ return this.generateStyle(styleType, feature, options, _.get(this, 'activityOptions.engine'))
381
416
  },
382
417
  pointToLayer: (feature, latlng) => {
383
- return this.generateStyle('markerStyle', feature, latlng, options)
418
+ const style = this.generateStyle('point', feature, options, _.get(this, 'activityOptions.engine'))
419
+ if (!style) {
420
+ logger.warn('[KDK] cannot generate point style from a feature')
421
+ return
422
+ }
423
+ return createMarkerFromPointStyle(latlng, style)
384
424
  }
385
425
  }
386
-
387
426
  return geojsonOptions
388
427
  },
389
428
  updateLayer (name, geoJson, options = {}) {
@@ -424,7 +463,8 @@ export const geojsonLayers = {
424
463
  } else if (geoJson) {
425
464
  if (typeof layer._onNewData === 'function') layer._onNewData(removeMissing, geoJson)
426
465
  } else { // Fetch new data or update in place
427
- if (typeof layer.update === 'function') layer.update()
466
+ if (layer.tiledLayer) layer.tiledLayer.redraw()
467
+ else if (typeof layer.update === 'function') layer.update()
428
468
  else if (typeof layer._onNewData === 'function') layer._onNewData(removeMissing, this.toGeoJson(name))
429
469
  }
430
470
 
@@ -432,7 +472,7 @@ export const geojsonLayers = {
432
472
  // these layers will be destroyed when hidden. We need to be able to restore
433
473
  // them when they get shown again
434
474
  const baseLayer = this.getLayerByName(name)
435
- if (this.isInMemoryLayer(baseLayer)) {
475
+ if (isInMemoryLayer(baseLayer)) {
436
476
  const geojson = layer.toGeoJSON(false)
437
477
  this.geojsonCache[name] = geojson
438
478
  }
@@ -518,7 +558,7 @@ export const geojsonLayers = {
518
558
  // Check if we have cached geojson data for this layer
519
559
  const cachedGeojson = this.geojsonCache[layer.name]
520
560
  if (cachedGeojson) {
521
- if (this.isInMemoryLayer(layer)) {
561
+ if (isInMemoryLayer(layer)) {
522
562
  // Restore geojson data for in-memory layers that was hidden
523
563
  this.updateLayer(layer.name, cachedGeojson)
524
564
  } else {
@@ -2,10 +2,9 @@ import _ from 'lodash'
2
2
  import L from 'leaflet'
3
3
  import parseGeoraster from 'georaster'
4
4
  import moment from 'moment'
5
- import chroma from 'chroma-js'
6
5
  import { GridRenderer } from '@weacast/leaflet'
7
6
  import { Grid } from '@weacast/core/client.js'
8
- import { buildColorMap } from '../../utils.js'
7
+ import { utils as kdkCoreUtils } from '../../../../core.client.js'
9
8
 
10
9
  const GeorasterLayer = L.Layer.extend({
11
10
 
@@ -32,13 +31,7 @@ const GeorasterLayer = L.Layer.extend({
32
31
  return
33
32
  }
34
33
  // Setup the colormap
35
- this.colorMap = buildColorMap(this)
36
- const scale = this.scale ? this.scale : ''
37
- if (this.classes) {
38
- this.colorMap = chroma.scale(scale).classes(this.classes)
39
- } else if (this.domain) {
40
- this.colorMap = chroma.scale(scale).domain(this.domain)
41
- }
34
+ this.colorMap = kdkCoreUtils.buildColorScale(this)
42
35
 
43
36
  // Setup the grid
44
37
  const grid = new Grid({
@@ -96,8 +89,8 @@ export const georasterLayers = {
96
89
  if (leafletOptions.type !== 'georaster') return
97
90
 
98
91
  // Copy options
99
- const colorMap = _.get(options, 'variables[0].chromajs', null)
100
- if (colorMap) Object.assign(leafletOptions, colorMap)
92
+ const colorScale = _.get(options, 'variables[0].chromajs', null)
93
+ if (colorScale) Object.assign(leafletOptions, colorScale)
101
94
  const band = _.get(options, 'variables[0].band', 0)
102
95
  Object.assign(leafletOptions, { band })
103
96
  const nodata = _.get(options, 'variables[0].nodata', null)
@@ -4,7 +4,7 @@ import sift from 'sift'
4
4
  import centroid from '@turf/centroid'
5
5
  import HeatmapOverlay from 'leaflet-heatmap'
6
6
  import { Time } from '../../../../core/client/time.js'
7
- import { fetchGeoJson } from '../../utils.js'
7
+ import { fetchGeoJson } from '../../utils/utils.features.js'
8
8
 
9
9
  export const heatmapLayers = {
10
10
  methods: {
@@ -1,5 +1,6 @@
1
1
  import L from 'leaflet'
2
2
  import _ from 'lodash'
3
+ import moment from 'moment'
3
4
  import { Time, Units } from '../../../../core/client/index.js'
4
5
  import { getHtmlTable } from '../../utils.map.js'
5
6
 
@@ -22,7 +23,7 @@ export const popup = {
22
23
  if (!html) {
23
24
  if (popupStyle.template) {
24
25
  const compiler = popupStyle.compiler
25
- html = compiler({ properties, feature, $t: this.$t, Units, Time })
26
+ html = compiler({ properties, feature, $t: this.$t, Units, Time, moment })
26
27
  } else if (popupStyle.pick) {
27
28
  properties = _.pick(properties, popupStyle.pick)
28
29
  } else if (popupStyle.omit) {
@@ -1,73 +1,10 @@
1
- import L from 'leaflet'
2
1
  import _ from 'lodash'
3
- import chroma from 'chroma-js'
4
- import { createLeafletMarkerFromStyle, convertToLeafletFromSimpleStyleSpec, LeafletStyleMappings } from '../../utils.map.js'
2
+ import { getDefaultPointStyle, getDefaultLineStyle, getDefaultPolygonStyle } from '../../utils.map.js'
5
3
 
6
4
  export const style = {
7
- methods: {
8
- // Alias to ease development
9
- createMarkerFromStyle (latlng, markerStyle, feature) {
10
- return createLeafletMarkerFromStyle(latlng, markerStyle, feature)
11
- },
12
- // Alias to ease development
13
- convertFromSimpleStyleSpec (style, inPlace) {
14
- return convertToLeafletFromSimpleStyleSpec(style, inPlace)
15
- },
16
- getDefaultMarker (feature, latlng, options) {
17
- const properties = feature.properties
18
- const leafletOptions = options.leaflet || options
19
- const style = Object.assign({},
20
- _.get(this, 'activityOptions.engine.pointStyle'),
21
- leafletOptions.layerStyle,
22
- this.convertFromSimpleStyleSpec(feature.style || feature.properties))
23
-
24
- // We allow to template style properties according to feature,
25
- // because it can be slow you have to specify a subset of properties
26
- if (leafletOptions.template) {
27
- leafletOptions.template.forEach(entry => {
28
- // Perform templating, set using simple spec mapping first then raw if property not found
29
- _.set(style, _.get(LeafletStyleMappings, entry.property, entry.property), entry.compiler({ properties, feature, chroma }))
30
- })
31
- }
32
- // We manage panes for z-index, so we need to forward it to marker options (only if not already defined)
33
- if (leafletOptions.pane && !style.pane) style.pane = leafletOptions.pane
34
- if (leafletOptions.shadowPane && !style.shadowPane) style.shadowPane = leafletOptions.shadowPane
35
- return (latlng ? this.createMarkerFromStyle(latlng, style) : style)
36
- },
37
- getDefaultStyle (feature, options) {
38
- const properties = feature.properties
39
- const leafletOptions = options.leaflet || options
40
- const style = Object.assign({},
41
- _.get(this, 'activityOptions.engine.featureStyle'),
42
- leafletOptions.layerStyle,
43
- this.convertFromSimpleStyleSpec(feature.style || feature.properties))
44
-
45
- // We allow to template style properties according to feature,
46
- // because it can be slow you have to specify a subset of properties
47
- if (leafletOptions.template) {
48
- leafletOptions.template.forEach(entry => {
49
- // Perform templating, set using simple spec mapping first then raw if property not found
50
- _.set(style, _.get(LeafletStyleMappings, entry.property, entry.property), entry.compiler({ properties, feature, chroma }))
51
- })
52
- }
53
- // We manage panes for z-index, so we need to forward it to marker options (only if not already defined)
54
- if (leafletOptions.pane && !style.pane) style.pane = leafletOptions.pane
55
- if (leafletOptions.shadowPane && !style.shadowPane) style.shadowPane = leafletOptions.shadowPane
56
- return style
57
- }
58
- },
59
5
  created () {
60
- this.registerStyle('markerStyle', this.getDefaultMarker)
61
- this.registerStyle('featureStyle', this.getDefaultStyle)
62
- },
63
- // Need to be done after created as the activity mixin initializes options in it
64
- beforeMount () {
65
- // Perform required conversion for default feature styling
66
- if (_.has(this, 'activityOptions.engine.featureStyle')) {
67
- this.convertFromSimpleStyleSpec(_.get(this, 'activityOptions.engine.featureStyle'), 'update-in-place')
68
- }
69
- if (_.has(this, 'activityOptions.engine.pointStyle')) {
70
- this.convertFromSimpleStyleSpec(_.get(this, 'activityOptions.engine.pointStyle'), 'update-in-place')
71
- }
6
+ this.registerStyle('point', getDefaultPointStyle)
7
+ this.registerStyle('line', getDefaultLineStyle)
8
+ this.registerStyle('polygon', getDefaultPolygonStyle)
72
9
  }
73
10
  }
@@ -19,7 +19,8 @@ export const tiledMeshLayers = {
19
19
 
20
20
  // Build grid source
21
21
  const [gridKey, gridConf] = extractGridSourceConfig(options)
22
- const gridSource = makeGridSource(gridKey, { weacastApi: this.weacastApi, apiToken })
22
+ const weacastApi = (typeof options.getPlanetApi === 'function' ? options.getPlanetApi() : this.getWeacastApi())
23
+ const gridSource = makeGridSource(gridKey, { weacastApi, apiToken })
23
24
  gridSource.setup(gridConf)
24
25
  if (gridSource.updateCtx) {
25
26
  // define variables for source's dynamic properties
@@ -17,8 +17,10 @@ export const tiledWindLayers = {
17
17
 
18
18
  // Build u & v grid sources
19
19
  const [gridKey, gridConf] = extractGridSourceConfig(options)
20
- const uSource = makeGridSource(gridKey, { weacastApi: this.weacastApi })
21
- const vSource = makeGridSource(gridKey, { weacastApi: this.weacastApi })
20
+ // Check API to be used in case the layer is coming from a remote "planet"
21
+ const weacastApi = (typeof options.getPlanetApi === 'function' ? options.getPlanetApi() : this.getWeacastApi())
22
+ const uSource = makeGridSource(gridKey, { weacastApi })
23
+ const vSource = makeGridSource(gridKey, { weacastApi })
22
24
  uSource.setup(gridConf)
23
25
  vSource.setup(gridConf)
24
26
  if (uSource.updateCtx) {
@@ -1,5 +1,6 @@
1
1
  import _ from 'lodash'
2
2
  import L from 'leaflet'
3
+ import moment from 'moment'
3
4
  import { Time, Units } from '../../../../core/client/index.js'
4
5
 
5
6
  export const tooltip = {
@@ -30,7 +31,7 @@ export const tooltip = {
30
31
  if (html && (typeof html.toString === 'function')) html = html.toString()
31
32
  } else if (tooltipStyle.template) {
32
33
  const compiler = tooltipStyle.compiler
33
- html = compiler({ properties, feature, $t: this.$t, Units, Time })
34
+ html = compiler({ properties, feature, $t: this.$t, Units, Time, moment })
34
35
  }
35
36
  }
36
37
  if (html) {