@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.
- package/.travis.test.sh +42 -10
- package/README.md +2 -2
- package/core/api/application.js +7 -2
- package/core/api/authentication.js +17 -1
- package/core/api/db.js +7 -2
- package/core/api/hooks/hooks.authentication.js +4 -2
- package/core/api/hooks/hooks.authorisations.js +12 -2
- package/core/api/hooks/hooks.model.js +5 -5
- package/core/api/hooks/hooks.organisations.js +0 -4
- package/core/api/services/account/account.hooks.js +10 -6
- package/core/api/services/account/account.service.js +1 -1
- package/{map/api/services/geocoder/geocoder.hooks.js → core/api/services/import-export/import-export.hooks.js} +7 -5
- package/core/api/services/import-export/import-export.service.js +11 -0
- package/core/api/services/index.js +13 -1
- package/core/api/services/users/users.hooks.js +2 -3
- package/core/client/api.js +16 -14
- package/core/client/capabilities.js +6 -2
- package/core/client/components/KContent.vue +11 -1
- package/core/client/components/KDialog.vue +17 -15
- package/core/client/components/KModal.vue +1 -1
- package/core/client/components/KSponsor.vue +1 -1
- package/core/client/components/KTextArea.vue +5 -1
- package/core/client/components/app/KAbout.vue +1 -2
- package/core/client/components/app/KWelcome.vue +3 -5
- package/core/client/components/chart/KTimeSeriesChart.vue +24 -37
- package/core/client/components/collection/KColumn.vue +20 -17
- package/core/client/components/editor/KModalEditor.vue +0 -2
- package/core/client/components/form/KChipsField.vue +12 -2
- package/core/client/components/form/KColorField.vue +12 -2
- package/core/client/components/form/KColorScaleField.vue +12 -2
- package/core/client/components/form/KDateTimeRangeField.vue +12 -2
- package/core/client/components/form/KDatetimeField.vue +12 -2
- package/core/client/components/form/KEmailField.vue +12 -2
- package/core/client/components/form/KFileField.vue +12 -2
- package/core/client/components/form/KForm.vue +47 -9
- package/core/client/components/form/KIconField.vue +12 -2
- package/core/client/components/form/KItemField.vue +25 -4
- package/core/client/components/form/KNumberField.vue +12 -2
- package/core/client/components/form/KOptionsField.vue +12 -2
- package/core/client/components/form/KPasswordField.vue +12 -2
- package/core/client/components/form/KPhoneField.vue +13 -3
- package/core/client/components/form/KPropertyItemField.vue +12 -2
- package/core/client/components/form/KResolutionField.vue +126 -0
- package/core/client/components/form/KRoleField.vue +12 -2
- package/core/client/components/form/KSelectField.vue +14 -4
- package/core/client/components/form/KTextField.vue +12 -2
- package/core/client/components/form/KTextareaField.vue +13 -3
- package/core/client/components/form/KToggleField.vue +12 -2
- package/core/client/components/form/KTokenField.vue +12 -2
- package/core/client/components/form/KUnitField.vue +12 -2
- package/core/client/components/form/KUrlField.vue +12 -2
- package/core/client/components/input/KIconChooser.vue +10 -12
- package/core/client/components/input/KPalette.vue +2 -1
- package/core/client/components/layout/KPage.vue +5 -4
- package/core/client/components/layout/KWindow.vue +10 -10
- package/core/client/components/media/KColorScale.vue +25 -19
- package/core/client/components/media/KImageViewer.vue +57 -33
- package/core/client/components/media/KShape.vue +14 -103
- package/core/client/components/screen/KRegisterScreen.vue +0 -1
- package/core/client/components/screen/KScreenFooter.vue +0 -18
- package/core/client/components/team/KAddMember.vue +16 -22
- package/core/client/components/team/KGroupsActivity.vue +14 -0
- package/core/client/components/team/KMembersActivity.vue +12 -0
- package/core/client/components/team/KTagsActivity.vue +14 -0
- package/core/client/components/time/KDateTime.vue +23 -7
- package/core/client/components/time/KTimeControl.vue +142 -0
- package/core/client/components/tool/KExportTool.vue +57 -0
- package/core/client/composables/collection.js +0 -1
- package/core/client/composables/pwa.js +0 -1
- package/core/client/composables/schema.js +1 -1
- package/core/client/composables/session.js +30 -6
- package/core/client/exporter.js +147 -0
- package/core/client/i18n/core_en.json +91 -23
- package/core/client/i18n/core_fr.json +92 -23
- package/core/client/index.js +3 -0
- package/core/client/layout.js +34 -14
- package/core/client/local-storage.js +8 -6
- package/core/client/mixins/index.js +0 -1
- package/core/client/mixins/mixin.base-field.js +24 -2
- package/core/client/mixins/mixin.object-proxy.js +0 -1
- package/core/client/search.js +2 -1
- package/core/client/services/index.js +2 -1
- package/core/client/services/local-settings.service.js +4 -4
- package/core/client/theme.js +3 -3
- package/core/client/time.js +4 -0
- package/core/client/units.js +150 -5
- package/core/client/utils/index.js +13 -6
- package/core/client/utils/utils.account.js +1 -1
- package/core/client/utils/utils.colors.js +43 -0
- package/core/client/utils/utils.platform.js +0 -1
- package/core/client/utils/utils.pwa.js +14 -14
- package/core/client/utils/utils.session.js +1 -1
- package/core/client/utils/utils.shapes.js +270 -0
- package/core/client/utils/utils.time.js +37 -0
- package/core/common/permissions.js +3 -0
- package/core/common/schemas/settings.update.json +50 -29
- package/extras/css/core.variables.scss +3 -1
- package/extras/icons/wind-speed-0.svg +8 -0
- package/extras/icons/wind-speed-10.svg +8 -0
- package/extras/icons/wind-speed-100.svg +12 -0
- package/extras/icons/wind-speed-105.svg +13 -0
- package/extras/icons/wind-speed-15.svg +9 -0
- package/extras/icons/wind-speed-20.svg +9 -0
- package/extras/icons/wind-speed-25.svg +10 -0
- package/extras/icons/wind-speed-30.svg +10 -0
- package/extras/icons/wind-speed-35.svg +11 -0
- package/extras/icons/wind-speed-40.svg +11 -0
- package/extras/icons/wind-speed-45.svg +12 -0
- package/extras/icons/wind-speed-5.svg +9 -0
- package/extras/icons/wind-speed-50.svg +9 -0
- package/extras/icons/wind-speed-55.svg +10 -0
- package/extras/icons/wind-speed-60.svg +10 -0
- package/extras/icons/wind-speed-65.svg +11 -0
- package/extras/icons/wind-speed-70.svg +11 -0
- package/extras/icons/wind-speed-75.svg +12 -0
- package/extras/icons/wind-speed-80.svg +12 -0
- package/extras/icons/wind-speed-85.svg +13 -0
- package/extras/icons/wind-speed-90.svg +13 -0
- package/extras/icons/wind-speed-95.svg +14 -0
- package/extras/tours/map/navigation-bar.js +17 -15
- package/extras/tours/map/timeline.js +33 -33
- package/map/api/config/categories.cjs +4 -1
- package/map/api/hooks/hooks.catalog.js +39 -0
- package/map/api/hooks/hooks.features.js +23 -3
- package/map/api/hooks/hooks.query.js +65 -21
- package/map/api/models/projects.model.mongodb.js +8 -0
- package/map/api/services/catalog/catalog.hooks.js +5 -3
- package/map/api/services/features/features.hooks.js +18 -6
- package/map/api/services/index.js +22 -6
- package/map/api/services/projects/projects.hooks.js +118 -0
- package/map/client/capture.js +16 -0
- package/map/client/cesium/utils/index.js +4 -0
- package/map/client/cesium/utils/utils.events.js +30 -0
- package/map/client/cesium/utils/utils.features.js +8 -0
- package/map/client/cesium/utils/utils.popup.js +17 -0
- package/map/client/cesium/utils/utils.style.js +137 -0
- package/map/client/components/KCapture.vue +50 -0
- package/map/client/components/KCaptureTextArea.vue +53 -0
- package/map/client/components/KCompass.vue +2 -2
- package/map/client/components/KFeaturesChart.vue +1 -1
- package/map/client/components/KFeaturesFilter.vue +2 -2
- package/map/client/components/KLayerStyleForm.vue +288 -454
- package/map/client/components/KLevelSlider.vue +1 -1
- package/map/client/components/KNorth.vue +31 -0
- package/map/client/components/KProjectMenu.vue +88 -0
- package/map/client/components/KTimezoneMap.vue +36 -24
- package/map/client/components/catalog/KAddLayer.vue +3 -4
- package/map/client/components/catalog/KConnectLayer.vue +20 -4
- package/map/client/components/catalog/KCreateLayer.vue +1 -2
- package/map/client/components/catalog/KCreateProject.vue +100 -0
- package/map/client/components/catalog/KCreateView.vue +25 -2
- package/map/client/components/catalog/KLayersPanel.vue +24 -27
- package/map/client/components/catalog/KLayersSelector.vue +1 -1
- package/map/client/components/catalog/KProjectEditor.vue +91 -0
- package/map/client/components/catalog/KProjectManager.vue +60 -0
- package/map/client/components/catalog/KProjectSelector.vue +38 -0
- package/map/client/components/catalog/KProjectsPanel.vue +153 -0
- package/map/client/components/catalog/KSelectLayers.vue +96 -0
- package/map/client/components/catalog/KSelectViews.vue +96 -0
- package/map/client/components/catalog/KViewsPanel.vue +66 -30
- package/map/client/components/form/KDirectionField.vue +24 -5
- package/map/client/components/form/KLayerCategoryField.vue +12 -2
- package/map/client/components/form/KLocationField.vue +20 -5
- package/map/client/components/form/KOwsLayerField.vue +12 -2
- package/map/client/components/form/KOwsServiceField.vue +12 -2
- package/map/client/components/form/KSelectLayersField.vue +159 -0
- package/map/client/components/form/KSelectViewsField.vue +121 -0
- package/map/client/components/form/KTimezoneField.vue +24 -17
- package/map/client/components/legend/KColorScaleLegend.vue +6 -2
- package/map/client/components/legend/KLayerLegend.vue +71 -0
- package/map/client/components/legend/KLegend.vue +54 -51
- package/map/client/components/legend/KLegendRenderer.vue +5 -3
- package/map/client/components/legend/KSymbolsLegend.vue +12 -10
- package/map/client/components/legend/KVariablesLegend.vue +78 -0
- package/map/client/components/location/KGeocodersFilter.vue +2 -4
- package/map/client/components/location/KLocationCardSection.vue +8 -4
- package/map/client/components/location/KLocationMap.vue +48 -17
- package/map/client/components/location/KLocationSearch.vue +13 -3
- package/map/client/components/tools/KSearchTool.vue +17 -12
- package/map/client/components/widget/KElevationProfile.vue +16 -19
- package/map/client/components/widget/KMapillaryViewer.vue +21 -22
- package/map/client/components/widget/KTimeSeries.vue +35 -29
- package/map/client/composables/activity.js +15 -2
- package/map/client/composables/catalog.js +81 -0
- package/map/client/composables/highlight.js +45 -30
- package/map/client/composables/index.js +2 -0
- package/map/client/composables/location.js +25 -18
- package/map/client/composables/probe.js +4 -1
- package/map/client/composables/project.js +122 -0
- package/map/client/composables/weather.js +3 -3
- package/map/client/geolocation.js +1 -1
- package/map/client/globe.js +2 -0
- package/map/client/i18n/map_en.json +127 -76
- package/map/client/i18n/map_fr.json +128 -72
- package/map/client/index.js +3 -0
- package/map/client/init.js +17 -0
- package/map/client/leaflet/GSMaPLayer.js +16 -17
- package/map/client/leaflet/ShapeMarker.js +51 -0
- package/map/client/leaflet/TiledFeatureLayer.js +39 -9
- package/map/client/leaflet/TiledMeshLayer.js +13 -15
- package/map/client/leaflet/TiledWindLayer.js +6 -10
- package/map/client/leaflet/utils/index.js +4 -0
- package/map/client/leaflet/utils/utils.events.js +41 -0
- package/map/client/leaflet/utils/utils.popup.js +21 -0
- package/map/client/leaflet/utils/utils.style.js +195 -0
- package/map/client/leaflet/utils/utils.tiles.js +87 -0
- package/map/client/map.js +2 -0
- package/map/client/mixins/globe/mixin.base-globe.js +39 -18
- package/map/client/mixins/globe/mixin.geojson-layers.js +139 -69
- package/map/client/mixins/globe/mixin.popup.js +2 -1
- package/map/client/mixins/globe/mixin.style.js +6 -4
- package/map/client/mixins/globe/mixin.tooltip.js +8 -3
- package/map/client/mixins/map/mixin.base-map.js +53 -28
- package/map/client/mixins/map/mixin.edit-layers.js +15 -15
- package/map/client/mixins/map/mixin.forecast-layers.js +3 -1
- package/map/client/mixins/map/mixin.geojson-layers.js +60 -20
- package/map/client/mixins/map/mixin.georaster-layers.js +4 -11
- package/map/client/mixins/map/mixin.heatmap-layers.js +1 -1
- package/map/client/mixins/map/mixin.popup.js +2 -1
- package/map/client/mixins/map/mixin.style.js +4 -67
- package/map/client/mixins/map/mixin.tiled-mesh-layers.js +2 -1
- package/map/client/mixins/map/mixin.tiled-wind-layers.js +4 -2
- package/map/client/mixins/map/mixin.tooltip.js +2 -1
- package/map/client/mixins/mixin.activity.js +71 -192
- package/map/client/mixins/mixin.catalog-panel.js +6 -6
- package/map/client/mixins/mixin.context.js +12 -9
- package/map/client/mixins/mixin.feature-service.js +29 -300
- package/map/client/mixins/mixin.weacast.js +11 -17
- package/map/client/pixi-utils.js +1 -1
- package/map/client/planets.js +66 -0
- package/map/client/utils/index.js +6 -0
- package/map/client/utils/utils.capture.js +176 -0
- package/map/client/utils/utils.catalog.js +166 -0
- package/map/client/utils/utils.features.js +364 -0
- package/map/client/utils/utils.js +0 -151
- package/map/client/utils/utils.layers.js +175 -0
- package/map/client/utils/utils.location.js +91 -23
- package/map/client/utils/utils.project.js +8 -0
- package/map/client/utils/utils.schema.js +0 -1
- package/map/client/utils/utils.style.js +309 -0
- package/map/client/utils.all.js +2 -2
- package/map/client/utils.globe.js +1 -1
- package/map/client/utils.map.js +1 -1
- package/map/common/permissions.js +2 -0
- package/map/common/schemas/capture.create.json +132 -0
- package/map/common/schemas/projects.create.json +52 -0
- package/map/common/schemas/projects.update.json +52 -0
- package/map/common/wms-utils.js +8 -3
- package/package.json +6 -5
- package/test/api/core/account.test.js +20 -0
- package/test/api/core/config/default.cjs +16 -3
- package/test/api/core/import-export.test.js +86 -0
- package/test/api/core/test-log-2024-01-04.log +14 -0
- package/test/api/map/catalog.test.js +164 -0
- package/test/api/map/index.test.js +25 -61
- package/test/api/map/test-log-2024-01-04.log +2 -0
- package/test/api/map/test-log-2024-01-11.log +1 -0
- package/test/api/map/test-log-2024-01-25.log +19 -0
- package/test/client/core/layout.js +24 -5
- package/test/client/core/utils.js +7 -0
- package/test/client/map/catalog.js +78 -1
- package/test/client/map/time.js +2 -1
- package/core/client/components/screen/KEndpointScreen.vue +0 -80
- package/core/client/mixins/mixin.account.js +0 -61
- package/extras/icons/kdk.png +0 -0
- package/map/api/services/geocoder/geocoder.service.js +0 -79
- package/map/client/cesium/utils.js +0 -133
- package/map/client/components/KCaptureToolbar.vue +0 -155
- package/map/client/components/KColorLegend.vue +0 -349
- package/map/client/components/KTimeline.vue +0 -293
- package/map/client/components/KUrlLegend.vue +0 -122
- 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
|
|
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 {
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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 {
|
|
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 =
|
|
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
|
|
100
|
-
if (
|
|
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
|
|
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('
|
|
61
|
-
this.registerStyle('
|
|
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
|
|
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
|
-
|
|
21
|
-
const
|
|
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) {
|