@kalisio/kdk 2.4.0 → 2.5.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/core/api/application.js +12 -12
- package/core/api/authentication.js +51 -7
- package/core/api/hooks/hooks.authentication.js +1 -59
- package/core/api/hooks/hooks.authorisations.js +8 -102
- package/core/api/hooks/hooks.model.js +4 -0
- package/core/api/hooks/hooks.push.js +18 -14
- package/core/api/hooks/hooks.users.js +0 -91
- package/core/api/hooks/index.js +0 -2
- package/core/api/services/account/account.service.js +1 -1
- package/core/api/services/authorisations/authorisations.service.js +28 -29
- package/core/api/services/index.js +38 -50
- package/core/api/services/messages/messages.hooks.js +4 -3
- package/core/api/services/users/users.service.js +5 -0
- package/core/client/api.js +182 -71
- package/core/client/broadcaster.js +20 -0
- package/core/client/capabilities.js +17 -7
- package/core/client/components/KActivity.vue +29 -34
- package/core/client/components/KAvatar.vue +0 -6
- package/core/client/components/KChip.vue +142 -39
- package/core/client/components/KContent.vue +13 -32
- package/core/client/components/KDialog.vue +29 -8
- package/core/client/components/KEditor.vue +120 -0
- package/core/client/components/KFollower.vue +75 -0
- package/core/client/components/KLogo.vue +2 -3
- package/core/client/components/KModal.vue +30 -10
- package/core/client/components/KSponsor.vue +1 -1
- package/core/client/components/KTextArea.vue +2 -5
- package/core/client/components/account/KDeleteAccountManager.vue +1 -1
- package/core/client/components/account/KProfile.vue +52 -14
- package/core/client/components/account/KSubscription.vue +19 -9
- package/core/client/components/account/KSubscriptionsManager.vue +10 -11
- package/core/client/components/action/KAction.vue +44 -24
- package/core/client/components/action/KBugReportAction.vue +4 -5
- package/core/client/components/action/KToggleStickyVisibility.vue +41 -0
- package/core/client/components/action/KToggleWidgetVisibility.vue +41 -0
- package/core/client/components/app/KPlatform.vue +122 -35
- package/core/client/components/app/KRequestProgressBar.vue +59 -0
- package/core/client/components/app/KSettings.vue +13 -2
- package/core/client/components/app/KTour.vue +2 -2
- package/core/client/components/chart/KTimeSeriesChart.vue +11 -3
- package/core/client/components/collection/KCard.vue +27 -33
- package/core/client/components/collection/KCardSection.vue +3 -23
- package/core/client/components/collection/KColumn.vue +0 -5
- package/core/client/components/collection/KDescriptionCardSection.vue +10 -5
- package/core/client/components/collection/KFilterView.vue +15 -0
- package/core/client/components/collection/KGrid.vue +4 -9
- package/core/client/components/collection/KHistory.vue +0 -5
- package/core/client/components/collection/KHistoryEntry.vue +0 -2
- package/core/client/components/collection/KItem.vue +1 -2
- package/core/client/components/collection/KSearchFilterControl.vue +139 -0
- package/core/client/components/collection/KTable.vue +1 -4
- package/core/client/components/collection/KTagsFilterControl.vue +70 -0
- package/core/client/components/collection/KTagsFilterView.vue +61 -0
- package/core/client/components/collection/KTimeFilterControl.vue +40 -0
- package/core/client/components/collection/KTimeFilterView.vue +106 -0
- package/core/client/components/collection/KTimeLine.vue +18 -11
- package/core/client/components/document/KBrowser.vue +283 -0
- package/core/client/components/document/KCsv.vue +52 -0
- package/core/client/components/document/KDocument.vue +19 -5
- package/core/client/components/document/KImage.vue +50 -19
- package/core/client/components/document/KMarkdown.vue +10 -2
- package/core/client/components/document/KUploader.vue +126 -0
- package/core/client/components/document/KVideo.vue +39 -0
- package/core/client/components/form/KDateField.vue +70 -0
- package/core/client/components/form/KDateTimeRangeField.vue +6 -17
- package/core/client/components/form/KDatetimeField.vue +6 -13
- package/core/client/components/form/KForm.vue +8 -8
- package/core/client/components/form/KOptionsField.vue +2 -0
- package/core/client/components/form/KResolutionField.vue +54 -52
- package/core/client/components/form/KSelectField.vue +27 -13
- package/core/client/components/form/KTextareaField.vue +23 -5
- package/core/client/components/graphics/KIcon.vue +64 -0
- package/core/client/components/index.js +1 -3
- package/core/client/components/input/KColorPicker.vue +70 -0
- package/core/client/components/input/KIconPicker.vue +188 -0
- package/core/client/components/input/KShapePicker.vue +81 -0
- package/core/client/components/input/index.js +7 -1
- package/core/client/components/layout/KFab.vue +1 -1
- package/core/client/components/layout/KLayout.vue +14 -2
- package/core/client/components/layout/KOpener.vue +9 -11
- package/core/client/components/layout/KPage.vue +31 -17
- package/core/client/components/layout/KWindow.vue +34 -18
- package/core/client/components/menu/KMenu.vue +52 -36
- package/core/client/components/menu/KSubMenu.vue +105 -0
- package/core/client/components/messages/KMessageCard.vue +207 -0
- package/core/client/components/messages/KMessageComposer.vue +199 -0
- package/core/client/components/messages/KMessagesTimeLine.vue +137 -0
- package/core/client/components/messages/index.js +7 -0
- package/core/client/components/screen/KErrorScreen.vue +2 -3
- package/core/client/components/screen/KLogoutScreen.vue +3 -1
- package/core/client/components/screen/KOAuthLoginScreen.vue +15 -0
- package/core/client/components/screen/KOAuthLogoutScreen.vue +33 -0
- package/core/client/components/screen/KUnauthorizedScreen.vue +16 -0
- package/core/client/components/time/KAbsoluteTimeRange.vue +7 -14
- package/core/client/components/time/KDate.vue +56 -26
- package/core/client/components/time/KDateTime.vue +93 -37
- package/core/client/components/time/KDateTimeRange.vue +197 -52
- package/core/client/components/time/KTime.vue +56 -26
- package/core/client/composables/activity.js +40 -30
- package/core/client/composables/{counter.js → collection-counter.js} +2 -4
- package/core/client/composables/collection-filter.js +111 -0
- package/core/client/composables/collection-timerange.js +56 -0
- package/core/client/composables/collection.js +13 -11
- package/core/client/composables/context.js +92 -0
- package/core/client/composables/errors.js +83 -0
- package/core/client/composables/index.js +5 -1
- package/core/client/composables/layout.js +14 -11
- package/core/client/composables/messages.js +4 -4
- package/core/client/composables/pwa.js +20 -27
- package/core/client/composables/schema.js +1 -1
- package/core/client/composables/screen.js +21 -9
- package/core/client/composables/selection.js +16 -4
- package/core/client/composables/session.js +13 -7
- package/core/client/composables/store.js +2 -1
- package/core/client/context.js +38 -0
- package/core/client/directives/v-hover.js +7 -4
- package/core/client/document.js +43 -15
- package/core/client/events.js +2 -2
- package/core/client/exporter.js +5 -4
- package/core/client/filter.js +1 -8
- package/core/client/guards.js +3 -3
- package/core/client/hooks/hooks.logger.js +1 -1
- package/core/client/hooks/hooks.offline.js +32 -0
- package/core/client/hooks/index.js +2 -1
- package/core/client/i18n/core_en.json +95 -268
- package/core/client/i18n/core_fr.json +181 -353
- package/core/client/index.js +22 -8
- package/core/client/layout.js +64 -25
- package/core/client/local-cache.js +67 -0
- package/core/client/local-storage.js +6 -2
- package/core/client/mixins/index.js +0 -1
- package/core/client/mixins/mixin.base-activity.js +22 -10
- package/core/client/mixins/mixin.base-editor.js +1 -1
- package/core/client/mixins/mixin.base-field.js +10 -1
- package/core/client/mixins/mixin.base-item.js +14 -11
- package/core/client/mixins/mixin.service.js +1 -5
- package/core/client/platform.js +44 -0
- package/core/client/readers/reader.blob.js +3 -3
- package/core/client/readers/reader.csv.js +2 -2
- package/core/client/readers/reader.json.js +2 -2
- package/core/client/services/index.js +7 -11
- package/core/client/storage.js +43 -8
- package/core/client/template-context.js +14 -14
- package/core/client/time.js +3 -3
- package/core/client/units.js +7 -4
- package/core/client/utils/index.js +6 -5
- package/core/client/utils/utils.collection.js +71 -0
- package/core/client/utils/utils.colors.js +29 -8
- package/core/client/utils/utils.content.js +14 -14
- package/core/client/utils/utils.files.js +17 -0
- package/core/client/utils/utils.items.js +4 -0
- package/core/client/utils/utils.math.js +18 -1
- package/core/client/utils/utils.push.js +22 -13
- package/core/client/utils/utils.screen.js +6 -2
- package/core/client/utils/utils.services.js +42 -0
- package/core/client/utils/utils.session.js +48 -12
- package/core/client/utils/utils.shapes.js +15 -11
- package/core/common/permissions.js +3 -108
- package/core/common/schemas/messages.update.json +16 -0
- package/core/common/schemas/settings.update.json +27 -8
- package/core/common/utils.js +2 -0
- package/core/common/utils.offline.js +38 -0
- package/coverage/core/api/application.js.html +296 -296
- package/coverage/core/api/authentication.js.html +206 -74
- package/coverage/core/api/db.js.html +61 -61
- package/coverage/core/api/hooks/hooks.authentication.js.html +15 -189
- package/coverage/core/api/hooks/hooks.authorisations.js.html +180 -462
- package/coverage/core/api/hooks/hooks.groups.js.html +1 -1
- package/coverage/core/api/hooks/hooks.logger.js.html +16 -16
- package/coverage/core/api/hooks/hooks.model.js.html +69 -57
- package/coverage/core/api/hooks/hooks.organisations.js.html +1 -1
- package/coverage/core/api/hooks/hooks.push.js.html +58 -46
- package/coverage/core/api/hooks/hooks.query.js.html +142 -142
- package/coverage/core/api/hooks/hooks.schemas.js.html +1 -1
- package/coverage/core/api/hooks/hooks.service.js.html +1 -1
- package/coverage/core/api/hooks/hooks.storage.js.html +1 -1
- package/coverage/core/api/hooks/hooks.users.js.html +54 -327
- package/coverage/core/api/hooks/index.html +64 -94
- package/coverage/core/api/hooks/index.js.html +4 -10
- package/coverage/core/api/index.html +41 -56
- package/coverage/core/api/index.js.html +1 -1
- package/coverage/core/api/marshall.js.html +9 -9
- package/coverage/core/api/models/groups.model.mongodb.js.html +1 -1
- package/coverage/core/api/models/index.html +13 -58
- package/coverage/core/api/models/messages.model.mongodb.js.html +35 -35
- package/coverage/core/api/models/organisations.model.mongodb.js.html +3 -3
- package/coverage/core/api/models/tags.model.mongodb.js.html +1 -1
- package/coverage/core/api/models/users.model.mongodb.js.html +1 -1
- package/coverage/core/api/services/account/account.hooks.js.html +1 -1
- package/coverage/core/api/services/account/account.service.js.html +67 -67
- package/coverage/core/api/services/account/index.html +16 -16
- package/coverage/core/api/services/authorisations/authorisations.hooks.js.html +1 -1
- package/coverage/core/api/services/authorisations/authorisations.service.js.html +141 -144
- package/coverage/core/api/services/authorisations/index.html +19 -19
- package/coverage/core/api/services/databases/databases.hooks.js.html +82 -82
- package/coverage/core/api/services/databases/databases.service.js.html +20 -20
- package/coverage/core/api/services/databases/index.html +32 -32
- package/coverage/core/api/services/groups/groups.hooks.js.html +1 -1
- package/coverage/core/api/services/groups/index.html +1 -1
- package/coverage/core/api/services/import-export/import-export.hooks.js.html +1 -1
- package/coverage/core/api/services/import-export/import-export.service.js.html +1 -1
- package/coverage/core/api/services/import-export/index.html +1 -1
- package/coverage/core/api/services/index.html +21 -21
- package/coverage/core/api/services/index.js.html +118 -154
- package/coverage/core/api/services/mailer/index.html +1 -1
- package/coverage/core/api/services/mailer/mailer.hooks.js.html +1 -1
- package/coverage/core/api/services/mailer/mailer.service.js.html +1 -1
- package/coverage/core/api/services/messages/index.html +21 -21
- package/coverage/core/api/services/messages/messages.hooks.js.html +89 -86
- package/coverage/core/api/services/organisations/index.html +1 -1
- package/coverage/core/api/services/organisations/organisations.hooks.js.html +1 -1
- package/coverage/core/api/services/organisations/organisations.service.js.html +23 -23
- package/coverage/core/api/services/push/index.html +1 -1
- package/coverage/core/api/services/push/push.hooks.js.html +1 -1
- package/coverage/core/api/services/push/push.service.js.html +1 -1
- package/coverage/core/api/services/storage/index.html +5 -5
- package/coverage/core/api/services/storage/storage.hooks.js.html +1 -1
- package/coverage/core/api/services/storage/storage.service.js.html +27 -27
- package/coverage/core/api/services/tags/index.html +1 -1
- package/coverage/core/api/services/tags/tags.hooks.js.html +1 -1
- package/coverage/core/api/services/users/index.html +23 -8
- package/coverage/core/api/services/users/users.hooks.js.html +1 -1
- package/coverage/core/api/services/users/users.service.js.html +100 -0
- package/coverage/core/api/utils.js.html +1 -1
- package/coverage/core/common/errors.js.html +1 -1
- package/coverage/core/common/index.html +42 -27
- package/coverage/core/common/index.js.html +1 -1
- package/coverage/core/common/permissions.js.html +195 -510
- package/coverage/core/common/schema.js.html +1 -1
- package/coverage/core/common/utils.js.html +12 -6
- package/coverage/core/common/utils.offline.js.html +199 -0
- package/coverage/index.html +142 -172
- package/coverage/lcov-report/core/api/application.js.html +296 -296
- package/coverage/lcov-report/core/api/authentication.js.html +206 -74
- package/coverage/lcov-report/core/api/db.js.html +61 -61
- package/coverage/lcov-report/core/api/hooks/hooks.authentication.js.html +15 -189
- package/coverage/lcov-report/core/api/hooks/hooks.authorisations.js.html +180 -462
- package/coverage/lcov-report/core/api/hooks/hooks.groups.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.logger.js.html +16 -16
- package/coverage/lcov-report/core/api/hooks/hooks.model.js.html +69 -57
- package/coverage/lcov-report/core/api/hooks/hooks.organisations.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.push.js.html +58 -46
- package/coverage/lcov-report/core/api/hooks/hooks.query.js.html +142 -142
- package/coverage/lcov-report/core/api/hooks/hooks.schemas.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.service.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.storage.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.users.js.html +54 -327
- package/coverage/lcov-report/core/api/hooks/index.html +64 -94
- package/coverage/lcov-report/core/api/hooks/index.js.html +4 -10
- package/coverage/lcov-report/core/api/index.html +41 -56
- package/coverage/lcov-report/core/api/index.js.html +1 -1
- package/coverage/lcov-report/core/api/marshall.js.html +9 -9
- package/coverage/lcov-report/core/api/models/groups.model.mongodb.js.html +1 -1
- package/coverage/lcov-report/core/api/models/index.html +13 -58
- package/coverage/lcov-report/core/api/models/messages.model.mongodb.js.html +35 -35
- package/coverage/lcov-report/core/api/models/organisations.model.mongodb.js.html +3 -3
- package/coverage/lcov-report/core/api/models/tags.model.mongodb.js.html +1 -1
- package/coverage/lcov-report/core/api/models/users.model.mongodb.js.html +1 -1
- package/coverage/lcov-report/core/api/services/account/account.hooks.js.html +1 -1
- package/coverage/lcov-report/core/api/services/account/account.service.js.html +67 -67
- package/coverage/lcov-report/core/api/services/account/index.html +16 -16
- package/coverage/lcov-report/core/api/services/authorisations/authorisations.hooks.js.html +1 -1
- package/coverage/lcov-report/core/api/services/authorisations/authorisations.service.js.html +141 -144
- package/coverage/lcov-report/core/api/services/authorisations/index.html +19 -19
- package/coverage/lcov-report/core/api/services/databases/databases.hooks.js.html +82 -82
- package/coverage/lcov-report/core/api/services/databases/databases.service.js.html +20 -20
- package/coverage/lcov-report/core/api/services/databases/index.html +32 -32
- package/coverage/lcov-report/core/api/services/groups/groups.hooks.js.html +1 -1
- package/coverage/lcov-report/core/api/services/groups/index.html +1 -1
- package/coverage/lcov-report/core/api/services/import-export/import-export.hooks.js.html +1 -1
- package/coverage/lcov-report/core/api/services/import-export/import-export.service.js.html +1 -1
- package/coverage/lcov-report/core/api/services/import-export/index.html +1 -1
- package/coverage/lcov-report/core/api/services/index.html +21 -21
- package/coverage/lcov-report/core/api/services/index.js.html +118 -154
- package/coverage/lcov-report/core/api/services/mailer/index.html +1 -1
- package/coverage/lcov-report/core/api/services/mailer/mailer.hooks.js.html +1 -1
- package/coverage/lcov-report/core/api/services/mailer/mailer.service.js.html +1 -1
- package/coverage/lcov-report/core/api/services/messages/index.html +21 -21
- package/coverage/lcov-report/core/api/services/messages/messages.hooks.js.html +89 -86
- package/coverage/lcov-report/core/api/services/organisations/index.html +1 -1
- package/coverage/lcov-report/core/api/services/organisations/organisations.hooks.js.html +1 -1
- package/coverage/lcov-report/core/api/services/organisations/organisations.service.js.html +23 -23
- package/coverage/lcov-report/core/api/services/push/index.html +1 -1
- package/coverage/lcov-report/core/api/services/push/push.hooks.js.html +1 -1
- package/coverage/lcov-report/core/api/services/push/push.service.js.html +1 -1
- package/coverage/lcov-report/core/api/services/storage/index.html +5 -5
- package/coverage/lcov-report/core/api/services/storage/storage.hooks.js.html +1 -1
- package/coverage/lcov-report/core/api/services/storage/storage.service.js.html +27 -27
- package/coverage/lcov-report/core/api/services/tags/index.html +1 -1
- package/coverage/lcov-report/core/api/services/tags/tags.hooks.js.html +1 -1
- package/coverage/lcov-report/core/api/services/users/index.html +23 -8
- package/coverage/lcov-report/core/api/services/users/users.hooks.js.html +1 -1
- package/coverage/lcov-report/core/api/services/users/users.service.js.html +100 -0
- package/coverage/lcov-report/core/api/utils.js.html +1 -1
- package/coverage/lcov-report/core/common/errors.js.html +1 -1
- package/coverage/lcov-report/core/common/index.html +42 -27
- package/coverage/lcov-report/core/common/index.js.html +1 -1
- package/coverage/lcov-report/core/common/permissions.js.html +195 -510
- package/coverage/lcov-report/core/common/schema.js.html +1 -1
- package/coverage/lcov-report/core/common/utils.js.html +12 -6
- package/coverage/lcov-report/core/common/utils.offline.js.html +199 -0
- package/coverage/lcov-report/index.html +142 -172
- package/coverage/lcov-report/map/api/hooks/hooks.catalog.js.html +125 -29
- package/coverage/lcov-report/map/api/hooks/hooks.features.js.html +1 -1
- package/coverage/lcov-report/map/api/hooks/hooks.query.js.html +20 -44
- package/coverage/lcov-report/map/api/hooks/index.html +7 -7
- package/coverage/lcov-report/map/api/hooks/index.js.html +1 -1
- package/coverage/lcov-report/map/api/index.html +1 -1
- package/coverage/lcov-report/map/api/index.js.html +1 -1
- package/coverage/lcov-report/map/api/marshall.js.html +1 -1
- package/coverage/lcov-report/map/api/models/alerts.model.mongodb.js.html +1 -1
- package/coverage/lcov-report/map/api/models/catalog.model.mongodb.js.html +49 -7
- package/coverage/lcov-report/map/api/models/features.model.mongodb.js.html +1 -1
- package/coverage/lcov-report/map/api/models/index.html +22 -7
- package/coverage/lcov-report/map/api/models/projects.model.mongodb.js.html +1 -1
- package/coverage/lcov-report/map/api/models/styles.model.mongodb.js.html +112 -0
- package/coverage/lcov-report/map/api/services/alerts/alerts.hooks.js.html +1 -1
- package/coverage/lcov-report/map/api/services/alerts/alerts.service.js.html +1 -1
- package/coverage/lcov-report/map/api/services/alerts/index.html +1 -1
- package/coverage/lcov-report/map/api/services/catalog/catalog.hooks.js.html +29 -11
- package/coverage/lcov-report/map/api/services/catalog/index.html +5 -5
- package/coverage/lcov-report/map/api/services/daptiles/daptiles.service.js.html +1 -1
- package/coverage/lcov-report/map/api/services/daptiles/index.html +1 -1
- package/coverage/lcov-report/map/api/services/features/features.hooks.js.html +78 -9
- package/coverage/lcov-report/map/api/services/features/features.service.js.html +307 -4
- package/coverage/lcov-report/map/api/services/features/index.html +7 -7
- package/coverage/lcov-report/map/api/services/index.html +5 -5
- package/coverage/lcov-report/map/api/services/index.js.html +287 -50
- package/coverage/lcov-report/map/api/services/projects/index.html +1 -1
- package/coverage/lcov-report/map/api/services/projects/projects.hooks.js.html +1 -1
- package/coverage/lcov-report/map/api/services/styles/index.html +116 -0
- package/coverage/lcov-report/map/api/services/styles/styles.hooks.js.html +196 -0
- package/coverage/lcov-report/map/common/dynamic-grid-source.js.html +1 -1
- package/coverage/lcov-report/map/common/errors.js.html +1 -1
- package/coverage/lcov-report/map/common/geotiff-grid-source.js.html +8 -5
- package/coverage/lcov-report/map/common/grid.js.html +1 -1
- package/coverage/lcov-report/map/common/index.html +7 -7
- package/coverage/lcov-report/map/common/index.js.html +1 -1
- package/coverage/lcov-report/map/common/meteo-model-grid-source.js.html +1 -1
- package/coverage/lcov-report/map/common/moment-utils.js.html +1 -1
- package/coverage/lcov-report/map/common/opendap-grid-source.js.html +1 -1
- package/coverage/lcov-report/map/common/opendap-utils.js.html +1 -1
- package/coverage/lcov-report/map/common/permissions.js.html +10 -4
- package/coverage/lcov-report/map/common/time-based-grid-source.js.html +1 -1
- package/coverage/lcov-report/map/common/tms-utils.js.html +6 -6
- package/coverage/lcov-report/map/common/wcs-grid-source.js.html +3 -3
- package/coverage/lcov-report/map/common/wcs-utils.js.html +9 -9
- package/coverage/lcov-report/map/common/weacast-grid-source.js.html +1 -1
- package/coverage/lcov-report/map/common/wfs-utils.js.html +11 -11
- package/coverage/lcov-report/map/common/wms-utils.js.html +8 -8
- package/coverage/lcov-report/map/common/wmts-utils.js.html +7 -7
- package/coverage/lcov.info +2581 -3278
- package/coverage/map/api/hooks/hooks.catalog.js.html +125 -29
- package/coverage/map/api/hooks/hooks.features.js.html +1 -1
- package/coverage/map/api/hooks/hooks.query.js.html +20 -44
- package/coverage/map/api/hooks/index.html +7 -7
- package/coverage/map/api/hooks/index.js.html +1 -1
- package/coverage/map/api/index.html +1 -1
- package/coverage/map/api/index.js.html +1 -1
- package/coverage/map/api/marshall.js.html +1 -1
- package/coverage/map/api/models/alerts.model.mongodb.js.html +1 -1
- package/coverage/map/api/models/catalog.model.mongodb.js.html +49 -7
- package/coverage/map/api/models/features.model.mongodb.js.html +1 -1
- package/coverage/map/api/models/index.html +22 -7
- package/coverage/map/api/models/projects.model.mongodb.js.html +1 -1
- package/coverage/map/api/models/styles.model.mongodb.js.html +112 -0
- package/coverage/map/api/services/alerts/alerts.hooks.js.html +1 -1
- package/coverage/map/api/services/alerts/alerts.service.js.html +1 -1
- package/coverage/map/api/services/alerts/index.html +1 -1
- package/coverage/map/api/services/catalog/catalog.hooks.js.html +29 -11
- package/coverage/map/api/services/catalog/index.html +5 -5
- package/coverage/map/api/services/daptiles/daptiles.service.js.html +1 -1
- package/coverage/map/api/services/daptiles/index.html +1 -1
- package/coverage/map/api/services/features/features.hooks.js.html +78 -9
- package/coverage/map/api/services/features/features.service.js.html +307 -4
- package/coverage/map/api/services/features/index.html +7 -7
- package/coverage/map/api/services/index.html +5 -5
- package/coverage/map/api/services/index.js.html +287 -50
- package/coverage/map/api/services/projects/index.html +1 -1
- package/coverage/map/api/services/projects/projects.hooks.js.html +1 -1
- package/coverage/map/api/services/styles/index.html +116 -0
- package/coverage/map/api/services/styles/styles.hooks.js.html +196 -0
- package/coverage/map/common/dynamic-grid-source.js.html +1 -1
- package/coverage/map/common/errors.js.html +1 -1
- package/coverage/map/common/geotiff-grid-source.js.html +8 -5
- package/coverage/map/common/grid.js.html +1 -1
- package/coverage/map/common/index.html +7 -7
- package/coverage/map/common/index.js.html +1 -1
- package/coverage/map/common/meteo-model-grid-source.js.html +1 -1
- package/coverage/map/common/moment-utils.js.html +1 -1
- package/coverage/map/common/opendap-grid-source.js.html +1 -1
- package/coverage/map/common/opendap-utils.js.html +1 -1
- package/coverage/map/common/permissions.js.html +10 -4
- package/coverage/map/common/time-based-grid-source.js.html +1 -1
- package/coverage/map/common/tms-utils.js.html +6 -6
- package/coverage/map/common/wcs-grid-source.js.html +3 -3
- package/coverage/map/common/wcs-utils.js.html +9 -9
- package/coverage/map/common/weacast-grid-source.js.html +1 -1
- package/coverage/map/common/wfs-utils.js.html +11 -11
- package/coverage/map/common/wms-utils.js.html +8 -8
- package/coverage/map/common/wmts-utils.js.html +7 -7
- package/coverage/tmp/coverage-323534-1747828879483-0.json +1 -0
- package/coverage/tmp/coverage-323546-1747828879453-0.json +1 -0
- package/coverage/tmp/coverage-323557-1747828879439-0.json +1 -0
- package/coverage/tmp/coverage-323569-1747828879416-0.json +1 -0
- package/coverage/tmp/coverage-323576-1747828879390-0.json +1 -0
- package/extras/configs/helpers.js +78 -0
- package/extras/configs/panes.left.js +118 -0
- package/extras/configs/panes.top.js +222 -0
- package/extras/configs/stickies.js +57 -0
- package/extras/configs/widgets.left.js +23 -0
- package/extras/configs/widgets.top.js +73 -0
- package/extras/css/core.variables.scss +8 -0
- package/extras/images/north.svg +3 -0
- package/extras/tours/map/side-nav.js +3 -3
- package/map/api/hooks/hooks.catalog.js +56 -23
- package/map/api/hooks/hooks.query.js +16 -24
- package/map/api/models/catalog.model.mongodb.js +16 -2
- package/{core/api/models/groups.model.mongodb.js → map/api/models/styles.model.mongodb.js} +2 -1
- package/map/api/services/catalog/catalog.hooks.js +13 -7
- package/map/api/services/features/features.hooks.js +28 -5
- package/map/api/services/features/features.service.js +101 -0
- package/map/api/services/index.js +125 -46
- package/map/api/services/styles/styles.hooks.js +37 -0
- package/map/client/cesium/utils/index.js +1 -0
- package/map/client/cesium/utils/utils.cesium.js +397 -0
- package/map/client/cesium/utils/utils.features.js +8 -0
- package/map/client/cesium/utils/utils.geojson.js +59 -0
- package/map/client/cesium/utils/utils.style.js +134 -17
- package/map/client/components/KEditLayerData.vue +17 -79
- package/map/client/components/KFeatureEditor.vue +2 -7
- package/map/client/components/KFeaturesChart.vue +2 -6
- package/map/client/components/KFeaturesFilterEditor.vue +300 -0
- package/map/client/components/KFeaturesFilterManager.vue +196 -0
- package/map/client/components/KFeaturesTable.vue +0 -5
- package/map/client/components/KFilterCondition.vue +303 -0
- package/map/client/components/KLayerEditionToolbar.vue +4 -3
- package/map/client/components/KLayerEditor.vue +451 -36
- package/map/client/components/KMeasureTool.vue +36 -9
- package/map/client/components/KProjectMenu.vue +14 -8
- package/map/client/components/catalog/KAddLayer.vue +0 -4
- package/map/client/components/catalog/KBaseLayersSelector.vue +42 -46
- package/map/client/components/catalog/KConnectLayer.vue +295 -291
- package/map/client/components/catalog/KCreateLayer.vue +141 -146
- package/map/client/components/catalog/KCreateOfflineView.vue +100 -0
- package/map/client/components/catalog/KCreateView.vue +2 -8
- package/map/client/components/catalog/KFilteredLayerItem.vue +72 -25
- package/map/client/components/catalog/KImportLayer.vue +121 -129
- package/map/client/components/catalog/KLayerItem.vue +44 -32
- package/map/client/components/catalog/KLayersPanel.vue +45 -17
- package/map/client/components/catalog/KLayersSelector.vue +51 -50
- package/map/client/components/catalog/KProjectManager.vue +4 -8
- package/map/client/components/catalog/KProjectSelector.vue +33 -2
- package/map/client/components/catalog/KProjectsPanel.vue +84 -106
- package/map/client/components/catalog/KSelectLayers.vue +56 -69
- package/map/client/components/catalog/KSelectViews.vue +56 -69
- package/map/client/components/catalog/KViewSelector.vue +32 -2
- package/map/client/components/catalog/KViewsPanel.vue +178 -110
- package/map/client/components/catalog/KWeatherLayersSelector.vue +77 -85
- package/map/client/components/form/KLocationField.vue +21 -2
- package/map/client/components/form/KOwsLayerField.vue +1 -1
- package/map/client/components/form/KOwsServiceField.vue +102 -63
- package/map/client/components/form/KSelectLayersField.vue +1 -1
- package/map/client/components/form/KSelectViewsField.vue +1 -1
- package/map/client/components/form/KTimezoneField.vue +0 -1
- package/map/client/components/legend/KLegend.vue +4 -4
- package/map/client/components/location/KLocationCardSection.vue +16 -0
- package/map/client/components/location/KLocationMap.vue +3 -2
- package/map/client/components/location/KLocationSearch.vue +46 -8
- package/map/client/components/location/KLocationTimeLineCard.vue +25 -3
- package/map/client/components/location/KLocationTip.vue +57 -10
- package/map/client/components/selection/KFeaturesSelection.vue +71 -0
- package/map/client/components/selection/KSelectedLayerFeatures.vue +343 -0
- package/map/client/components/{KAttribution.vue → stickies/KAttribution.vue} +39 -33
- package/map/client/components/stickies/KLevelSlider.vue +114 -0
- package/map/client/components/stickies/KNorthArrow.vue +26 -0
- package/map/client/components/stickies/KPosition.vue +103 -0
- package/map/client/components/stickies/KTarget.vue +34 -0
- package/map/client/components/styles/KLayerStyleAction.vue +58 -0
- package/map/client/components/styles/KStyleEditor.vue +273 -0
- package/map/client/components/styles/KStyleEditorSection.vue +79 -0
- package/map/client/components/styles/KStyleManager.vue +183 -0
- package/map/client/components/styles/KStylePreview.vue +64 -0
- package/map/client/components/styles/KStylePreviewItem.vue +68 -0
- package/map/client/components/styles/KStylePropertiesGroup.vue +76 -0
- package/map/client/components/styles/KStyleProperty.vue +136 -0
- package/map/client/components/styles/KStyleTip.vue +118 -0
- package/map/client/components/tools/KGeolocateTool.vue +3 -2
- package/map/client/components/tools/KSearchTool.vue +34 -6
- package/map/client/components/widget/KMapillaryViewer.vue +1 -1
- package/map/client/components/widget/KStackableTimeSeries.vue +8 -5
- package/map/client/composables/activity.js +29 -43
- package/map/client/composables/catalog.js +1 -1
- package/map/client/composables/highlight.js +117 -57
- package/map/client/composables/location.js +33 -14
- package/map/client/composables/project.js +9 -10
- package/map/client/composables/selection.js +136 -23
- package/map/client/geocoder.js +104 -0
- package/map/client/geolocation.js +1 -1
- package/map/client/globe.js +3 -0
- package/map/client/hooks/hooks.offline.js +95 -0
- package/map/client/hooks/index.js +1 -0
- package/map/client/i18n/map_en.json +159 -94
- package/map/client/i18n/map_fr.json +186 -127
- package/map/client/index.js +3 -0
- package/map/client/init.js +44 -8
- package/map/client/leaflet/BoxSelection.js +2 -2
- package/map/client/leaflet/GradientPath.js +84 -4
- package/map/client/leaflet/TiledFeatureLayer.js +2 -3
- package/map/client/leaflet/WindBarb.js +323 -0
- package/map/client/leaflet/utils/index.js +1 -0
- package/map/client/leaflet/utils/utils.events.js +8 -3
- package/map/client/leaflet/utils/utils.geojson.js +221 -0
- package/map/client/leaflet/utils/utils.style.js +10 -9
- package/map/client/map.js +3 -0
- package/map/client/mixins/globe/mixin.base-globe.js +151 -19
- package/map/client/mixins/globe/mixin.geojson-layers.js +208 -86
- package/map/client/mixins/globe/mixin.popup.js +3 -2
- package/map/client/mixins/globe/mixin.style.js +3 -1
- package/map/client/mixins/globe/mixin.tooltip.js +3 -2
- package/map/client/mixins/map/index.js +1 -3
- package/map/client/mixins/map/mixin.base-map.js +267 -79
- package/map/client/mixins/map/mixin.canvas-layers.js +44 -10
- package/map/client/mixins/map/mixin.edit-layers.js +142 -57
- package/map/client/mixins/map/mixin.geojson-layers.js +129 -205
- package/map/client/mixins/map/mixin.pmtiles-layers.js +24 -11
- package/map/client/mixins/map/mixin.tiled-mesh-layers.js +1 -2
- package/map/client/mixins/map/mixin.tiled-wind-layers.js +2 -1
- package/map/client/mixins/mixin.activity.js +61 -41
- package/map/client/mixins/mixin.context.js +19 -14
- package/map/client/mixins/mixin.feature-selection.js +0 -1
- package/map/client/mixins/mixin.feature-service.js +41 -59
- package/map/client/mixins/mixin.weacast.js +1 -1
- package/map/client/navigator.js +38 -0
- package/map/client/pixi-utils.js +1 -1
- package/map/client/planets.js +1 -1
- package/map/client/readers/reader.kml.js +57 -1
- package/map/client/utils/index.js +1 -0
- package/map/client/utils/utils.capture.js +10 -7
- package/map/client/utils/utils.catalog.js +2 -2
- package/map/client/utils/utils.features.js +193 -39
- package/map/client/utils/utils.js +8 -19
- package/map/client/utils/utils.layers.js +381 -4
- package/map/client/utils/utils.location.js +39 -74
- package/map/client/utils/utils.offline.js +89 -0
- package/map/client/utils/utils.style.js +133 -80
- package/map/client/utils/utils.time-series.js +99 -25
- package/map/common/geotiff-grid-source.js +2 -1
- package/map/common/permissions.js +2 -0
- package/map/common/schemas/capture.create.json +4 -4
- package/map/common/schemas/catalog.update.json +18 -2
- package/map/common/schemas/projects.create.json +2 -2
- package/map/common/schemas/projects.update.json +2 -2
- package/map/common/tms-utils.js +5 -5
- package/map/common/wcs-grid-source.js +2 -2
- package/map/common/wcs-utils.js +8 -8
- package/map/common/wfs-utils.js +10 -10
- package/map/common/wms-utils.js +7 -7
- package/map/common/wmts-utils.js +6 -6
- package/package.json +7 -4
- package/test/api/core/account.test.js +0 -72
- package/test/api/core/authentication.test.js +184 -0
- package/test/api/core/config/default.cjs +1 -3
- package/test/api/core/index.test.js +33 -96
- package/test/api/core/offline.test.js +55 -0
- package/test/api/core/push.test.js +3 -3
- package/test/api/core/{test-log-2024-06-06.log → test-log-2025-02-05.log} +3 -3
- package/test/api/core/{test-log-2024-11-15.log → test-log-2025-05-21.log} +1 -9
- package/test/api/map/alerts.test.js +1 -1
- package/test/api/map/config/default.cjs +2 -1
- package/test/api/map/data/vigicrues.observations.Q.json +47042 -0
- package/test/api/map/index.test.js +113 -9
- package/test/api/map/style.test.js +62 -0
- package/test/client/core/layout.js +2 -2
- package/test/client/core/runner.js +1 -1
- package/test/client/core/utils.js +52 -0
- package/test/client/map/catalog.js +1 -0
- package/core/api/hooks/hooks.groups.js +0 -48
- package/core/api/hooks/hooks.organisations.js +0 -152
- package/core/api/models/organisations.model.mongodb.js +0 -3
- package/core/api/models/tags.model.mongodb.js +0 -10
- package/core/api/services/groups/groups.hooks.js +0 -31
- package/core/api/services/organisations/organisations.hooks.js +0 -31
- package/core/api/services/organisations/organisations.service.js +0 -86
- package/core/api/services/tags/tags.hooks.js +0 -31
- package/core/api/utils.js +0 -11
- package/core/client/components/KChipsPane.vue +0 -103
- package/core/client/components/document/index.js +0 -9
- package/core/client/components/team/KAddMember.vue +0 -378
- package/core/client/components/team/KAddTag.vue +0 -121
- package/core/client/components/team/KChangeRole.vue +0 -118
- package/core/client/components/team/KGroupCard.vue +0 -110
- package/core/client/components/team/KGroupsActivity.vue +0 -78
- package/core/client/components/team/KJoinGroup.vue +0 -132
- package/core/client/components/team/KMemberCard.vue +0 -328
- package/core/client/components/team/KMemberFilter.vue +0 -49
- package/core/client/components/team/KMembersActivity.vue +0 -136
- package/core/client/components/team/KOrganisationsActivity.vue +0 -51
- package/core/client/components/team/KTagCard.vue +0 -72
- package/core/client/components/team/KTagsActivity.vue +0 -73
- package/core/client/components/team/index.js +0 -9
- package/core/client/mixins/mixin.base-context.js +0 -54
- package/core/client/utils/utils.platform.js +0 -12
- package/core/common/schemas/groups.create.json +0 -28
- package/core/common/schemas/groups.update.json +0 -28
- package/core/common/schemas/organisations.create.json +0 -28
- package/core/common/schemas/organisations.update.json +0 -49
- package/core/common/schemas/tags.create.json +0 -35
- package/core/common/schemas/tags.update.json +0 -35
- package/coverage/tmp/coverage-280506-1731704745613-0.json +0 -1
- package/coverage/tmp/coverage-280518-1731704745599-0.json +0 -1
- package/coverage/tmp/coverage-280529-1731704745588-0.json +0 -1
- package/coverage/tmp/coverage-280541-1731704745574-0.json +0 -1
- package/coverage/tmp/coverage-280548-1731704745545-0.json +0 -1
- package/map/client/components/KFeaturesFilter.vue +0 -259
- package/map/client/components/KLayerStyleEditor.vue +0 -118
- package/map/client/components/KLayerStyleForm.vue +0 -740
- package/map/client/components/KLevelSlider.vue +0 -100
- package/map/client/components/KNorth.vue +0 -31
- package/map/client/components/KPositionIndicator.vue +0 -83
- package/map/client/components/catalog/KCreateProject.vue +0 -100
- package/map/client/mixins/map/mixin.forecast-layers.js +0 -81
- package/map/client/mixins/map/mixin.georaster-layers.js +0 -107
- package/test/api/core/team.test.js +0 -670
- package/test/api/core/test-log-2023-12-19.log +0 -7
- package/test/api/core/test-log-2024-01-04.log +0 -14
- package/test/api/core/test-log-2024-05-14.log +0 -6
- package/test/api/core/test-log-2024-06-26.log +0 -25
- package/test/api/core/test-log-2024-06-28.log +0 -2
- package/test/api/core/test-log-2024-07-09.log +0 -0
- package/test/api/core/test-log-2024-08-13.log +0 -69
- package/test/api/core/test-log-2024-10-28.log +0 -53
- package/test/api/core/test-log-2024-11-05.log +0 -30
- package/test/api/map/test-log-2023-11-24.log +0 -121
- package/test/api/map/test-log-2023-12-12.log +0 -29
- package/test/api/map/test-log-2023-12-13.log +0 -5
- package/test/api/map/test-log-2024-01-04.log +0 -2
- package/test/api/map/test-log-2024-01-11.log +0 -1
- package/test/api/map/test-log-2024-01-25.log +0 -19
- package/test/api/map/test-log-2024-06-06.log +0 -39
- package/test/api/map/test-log-2024-08-13.log +0 -13
- package/test/api/map/test-log-2024-08-20.log +0 -55
- package/test/api/map/test-log-2024-09-09.log +0 -92
- package/test/api/map/test-log-2024-10-28.log +0 -11
- /package/extras/{logos → images}/kalisio.png +0 -0
- /package/extras/{icons → images}/target.svg +0 -0
- /package/test/api/map/data/{vigicrues.observations.json → vigicrues.observations.H.json} +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
2
|
import { ref } from 'vue'
|
|
3
|
-
import { Store,
|
|
3
|
+
import { Store, Context, i18n } from '../../../core.client.js'
|
|
4
4
|
import { Geolocation } from '../geolocation.js'
|
|
5
|
+
import { Geocoder } from '../geocoder.js'
|
|
5
6
|
import { useCurrentActivity } from './activity.js'
|
|
6
|
-
import {
|
|
7
|
+
import { filterGeocoders } from '../utils/utils.location.js'
|
|
7
8
|
|
|
8
9
|
export function useLocation () {
|
|
9
10
|
const { getActivityProject } = useCurrentActivity({ selection: false, probe: false })
|
|
@@ -11,49 +12,67 @@ export function useLocation () {
|
|
|
11
12
|
// Data
|
|
12
13
|
const availableGeocoders = ref([])
|
|
13
14
|
const selectedGeocoders = ref([])
|
|
15
|
+
const selectedViewbox = ref([])
|
|
14
16
|
|
|
15
17
|
// Functions
|
|
16
18
|
// Input geocoders if given should be like { source: xxx, selected: true }
|
|
17
19
|
async function setGeocoders (geocoders) {
|
|
18
|
-
const project = getActivityProject()
|
|
19
|
-
const planet = (project ? project.getPlanetApi().getConfig() : api.getConfig())
|
|
20
20
|
if (_.isNull(geocoders)) {
|
|
21
21
|
// clear the geocoders
|
|
22
22
|
availableGeocoders.value = []
|
|
23
23
|
selectedGeocoders.value = []
|
|
24
24
|
} else {
|
|
25
25
|
// check the capabilities to list the geocoders
|
|
26
|
-
let allGeocoders = await
|
|
27
|
-
allGeocoders = filterGeocoders(allGeocoders,
|
|
26
|
+
let allGeocoders = await Geocoder.getForwardCapabilities()
|
|
27
|
+
allGeocoders = filterGeocoders(allGeocoders, getActivityProject())
|
|
28
28
|
if (_.isEmpty(geocoders)) {
|
|
29
29
|
availableGeocoders.value = _.map(allGeocoders, geocoder => {
|
|
30
30
|
return { value: geocoder, label: i18n.tie(`Geocoders.${geocoder}`) }
|
|
31
31
|
})
|
|
32
32
|
selectedGeocoders.value = allGeocoders
|
|
33
33
|
} else {
|
|
34
|
-
availableGeocoders.value = geocoders
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
availableGeocoders.value = _.reduce(geocoders, (reducedGeocoders, geocoder) => {
|
|
35
|
+
const source = _.replace(geocoder.source, /^services:.*\//g, `services:${Context.getId()}/`)
|
|
36
|
+
const label = _.replace(geocoder.source, /^services:.*\//g, `services:*/`)
|
|
37
|
+
if (allGeocoders.includes(source)) {
|
|
38
|
+
reducedGeocoders.push({ value: source, label: i18n.tie(`Geocoders.${label}`), selected: geocoder.selected })
|
|
39
|
+
}
|
|
40
|
+
return reducedGeocoders
|
|
41
|
+
}, [])
|
|
42
|
+
selectedGeocoders.value = _.reduce(availableGeocoders.value, (reducedGeocoders, geocoder) => {
|
|
43
|
+
if (geocoder.selected) reducedGeocoders.push(geocoder.value)
|
|
44
|
+
return reducedGeocoders
|
|
45
|
+
}, [])
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
}
|
|
49
|
+
// Input viewbox if given should be like [lon1,lat1,lon2,lat2]
|
|
50
|
+
async function setViewbox (viewbox) {
|
|
51
|
+
if (_.isNull(viewbox)) {
|
|
52
|
+
selectedViewbox.value = []
|
|
53
|
+
} else {
|
|
54
|
+
selectedViewbox.value = viewbox
|
|
55
|
+
}
|
|
56
|
+
}
|
|
41
57
|
async function geolocate () {
|
|
42
58
|
await Geolocation.update()
|
|
43
59
|
const error = Store.get('geolocation.error')
|
|
44
60
|
if (error) return
|
|
45
61
|
return Store.get('geolocation.location')
|
|
46
62
|
}
|
|
47
|
-
async function search (pattern) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
async function search (pattern, limit = 25) {
|
|
64
|
+
return Geocoder.queryForward(pattern, {
|
|
65
|
+
geocoders: selectedGeocoders.value,
|
|
66
|
+
viewbox: selectedViewbox.value,
|
|
67
|
+
limit
|
|
68
|
+
})
|
|
51
69
|
}
|
|
52
70
|
// Expose
|
|
53
71
|
return {
|
|
54
72
|
availableGeocoders,
|
|
55
73
|
selectedGeocoders,
|
|
56
74
|
setGeocoders,
|
|
75
|
+
setViewbox,
|
|
57
76
|
geolocate,
|
|
58
77
|
search
|
|
59
78
|
}
|
|
@@ -2,6 +2,7 @@ import _ from 'lodash'
|
|
|
2
2
|
import { ref, computed, watch, onBeforeMount, onBeforeUnmount } from 'vue'
|
|
3
3
|
import { useRoute, useRouter } from 'vue-router'
|
|
4
4
|
import { api } from '../../../core.client.js'
|
|
5
|
+
import { listenToServiceEvents, unlistenToServiceEvents } from '../../../core/client/utils/index.js'
|
|
5
6
|
import { useCurrentActivity } from '../composables/activity.js'
|
|
6
7
|
import { getCatalogProjectQuery } from '../utils/utils.project.js'
|
|
7
8
|
|
|
@@ -12,7 +13,7 @@ export function useProject (options = {}) {
|
|
|
12
13
|
// Set if project should be extracted from route
|
|
13
14
|
// otherwise it should be loaded manually
|
|
14
15
|
route: true,
|
|
15
|
-
// Default to global service
|
|
16
|
+
// Default to contextual or global service depending on store
|
|
16
17
|
context: '',
|
|
17
18
|
// Default to target activity
|
|
18
19
|
updateActivity: true,
|
|
@@ -25,6 +26,7 @@ export function useProject (options = {}) {
|
|
|
25
26
|
const router = useRouter()
|
|
26
27
|
const projectId = ref(null)
|
|
27
28
|
const project = ref(null)
|
|
29
|
+
let serviceEventListeners
|
|
28
30
|
|
|
29
31
|
// Computed
|
|
30
32
|
const projectQuery = computed(() => {
|
|
@@ -95,19 +97,16 @@ export function useProject (options = {}) {
|
|
|
95
97
|
|
|
96
98
|
onBeforeMount(() => {
|
|
97
99
|
refreshProjectId()
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
serviceEventListeners = listenToServiceEvents(options.planetApi.getService('projects', options.context), {
|
|
101
|
+
patched: onProjectUpdated,
|
|
102
|
+
updated: onProjectUpdated,
|
|
103
|
+
removed: onProjectRemoved
|
|
104
|
+
})
|
|
103
105
|
})
|
|
104
106
|
|
|
105
107
|
// Cleanup
|
|
106
108
|
onBeforeUnmount(() => {
|
|
107
|
-
|
|
108
|
-
projectsService.off('patched', onProjectUpdated)
|
|
109
|
-
projectsService.off('updated', onProjectUpdated)
|
|
110
|
-
projectsService.off('removed', onProjectRemoved)
|
|
109
|
+
unlistenToServiceEvents(serviceEventListeners)
|
|
111
110
|
})
|
|
112
111
|
|
|
113
112
|
return {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
|
+
import config from 'config'
|
|
2
3
|
import L from 'leaflet'
|
|
3
4
|
import sift from 'sift'
|
|
4
5
|
import centroid from '@turf/centroid'
|
|
@@ -8,11 +9,19 @@ import intersects from '@turf/boolean-intersects'
|
|
|
8
9
|
import { featureEach } from '@turf/meta'
|
|
9
10
|
import { unref } from 'vue'
|
|
10
11
|
import * as composables from '../../../core/client/composables/index.js'
|
|
11
|
-
import
|
|
12
|
+
import * as utils from '../utils.js'
|
|
13
|
+
import { convertPolygonStyleToLeafletPath } from '../leaflet/utils/index.js'
|
|
12
14
|
|
|
13
15
|
export function useSelection (name, options = {}) {
|
|
16
|
+
// Data
|
|
17
|
+
let layerServiceEventListeners = {}
|
|
18
|
+
// Retrieve core selection
|
|
19
|
+
const selection = composables.useSelection(name, options)
|
|
20
|
+
// Selection store, as we store options inside check if already initialized
|
|
21
|
+
const { get, has, set } = composables.useStore(`selections.${name}`)
|
|
22
|
+
|
|
14
23
|
// Set default options
|
|
15
|
-
options = Object.assign({
|
|
24
|
+
options = get('options', Object.assign({
|
|
16
25
|
// Specific selection item comparator
|
|
17
26
|
matches: (item1) => (item2) => {
|
|
18
27
|
const layer1 = _.get(item1, 'layer.name')
|
|
@@ -22,8 +31,8 @@ export function useSelection (name, options = {}) {
|
|
|
22
31
|
if (layer1 !== layer2) return false
|
|
23
32
|
// Then compare features
|
|
24
33
|
if (item1.feature && item2.feature) {
|
|
25
|
-
const id1 = getFeatureId(item1.feature, item1.layer)
|
|
26
|
-
const id2 = getFeatureId(item2.feature, item2.layer)
|
|
34
|
+
const id1 = utils.getFeatureId(item1.feature, item1.layer)
|
|
35
|
+
const id2 = utils.getFeatureId(item2.feature, item2.layer)
|
|
27
36
|
return id1 === id2
|
|
28
37
|
} else {
|
|
29
38
|
// If only one has a feature then it cannot be the same
|
|
@@ -42,37 +51,70 @@ export function useSelection (name, options = {}) {
|
|
|
42
51
|
multiple: 'ctrlKey',
|
|
43
52
|
// Buffer selection width (10px)
|
|
44
53
|
buffer: 10,
|
|
54
|
+
showBuffer: false,
|
|
55
|
+
showBufferDelay: 250,
|
|
45
56
|
boxSelection: true,
|
|
46
57
|
clusterSelection: false
|
|
47
|
-
}, options)
|
|
48
|
-
//
|
|
49
|
-
|
|
58
|
+
}, options))
|
|
59
|
+
// Track options in store if not already done
|
|
60
|
+
if (!has('options')) set('options', options)
|
|
50
61
|
// Retrieve activity
|
|
51
62
|
const { kActivity } = composables.useCurrentActivity()
|
|
52
63
|
// Avoid using .value everywhere
|
|
53
64
|
let activity = unref(kActivity)
|
|
54
65
|
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
// functions
|
|
66
|
+
// Functions
|
|
58
67
|
function setCurrentActivity (newActivity) {
|
|
59
68
|
// Avoid multiple updates
|
|
60
69
|
if (activity === newActivity) return
|
|
61
70
|
// Remove listeners on previous activity and set it on new one
|
|
62
71
|
if (activity && activity.$engineEvents) {
|
|
72
|
+
unlistenToFeaturesServiceEventsForLayers()
|
|
73
|
+
selection.setSelectionEnabled()
|
|
74
|
+
selection.clearSelection()
|
|
63
75
|
activity.$engineEvents.off('click', onClicked)
|
|
64
76
|
if (options.boxSelection) activity.$engineEvents.off('boxselectionend', onBoxSelection)
|
|
65
77
|
if (options.clusterSelection) activity.$engineEvents.off('spiderfied', onClusterSelection)
|
|
78
|
+
activity.$engineEvents.off('layer-added', listenToFeaturesServiceEventsForLayer)
|
|
79
|
+
activity.$engineEvents.off('layer-removed', unlistenToFeaturesServiceEventsForLayer)
|
|
66
80
|
activity.$engineEvents.off('layer-hidden', onSelectedLayerHidden)
|
|
67
81
|
}
|
|
68
82
|
activity = newActivity
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (options.
|
|
73
|
-
|
|
83
|
+
if (activity && activity.$engineEvents) {
|
|
84
|
+
listenToFeaturesServiceEventsForLayers()
|
|
85
|
+
activity.$engineEvents.on('click', onClicked)
|
|
86
|
+
if (options.boxSelection) activity.$engineEvents.on('boxselectionend', onBoxSelection)
|
|
87
|
+
if (options.clusterSelection) activity.$engineEvents.on('spiderfied', onClusterSelection)
|
|
88
|
+
activity.$engineEvents.on('layer-added', listenToFeaturesServiceEventsForLayer)
|
|
89
|
+
activity.$engineEvents.on('layer-removed', unlistenToFeaturesServiceEventsForLayer)
|
|
90
|
+
activity.$engineEvents.on('layer-hidden', onSelectedLayerHidden)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function setBoxSelectionEnabled (enabled) {
|
|
94
|
+
if (options.boxSelection === enabled) return
|
|
95
|
+
options.boxSelection = enabled
|
|
96
|
+
if (!activity) return
|
|
97
|
+
if (enabled) {
|
|
98
|
+
activity.$engineEvents.on('boxselectionend', onBoxSelection)
|
|
99
|
+
activity.map.boxSelection.enable()
|
|
100
|
+
} else {
|
|
101
|
+
activity.$engineEvents.off('boxselectionend', onBoxSelection)
|
|
102
|
+
activity.map.boxSelection.disable()
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function setClusterSelectionEnabled (enabled) {
|
|
106
|
+
if (options.clusterSelection === enabled) return
|
|
107
|
+
options.clusterSelection = enabled
|
|
108
|
+
if (!activity) return
|
|
109
|
+
if (enabled) {
|
|
110
|
+
activity.$engineEvents.on('spiderfied', onClusterSelection)
|
|
111
|
+
} else {
|
|
112
|
+
activity.$engineEvents.off('spiderfied', onClusterSelection)
|
|
74
113
|
}
|
|
75
114
|
}
|
|
115
|
+
function setBufferWidth (width) {
|
|
116
|
+
options.buffer = width
|
|
117
|
+
}
|
|
76
118
|
// Single selection will rely on the lastly selected item only
|
|
77
119
|
function hasSelectedFeature () {
|
|
78
120
|
return selection.hasSelectedItem() && selection.getSelectedItem().feature
|
|
@@ -80,32 +122,51 @@ export function useSelection (name, options = {}) {
|
|
|
80
122
|
function getSelectedFeature () {
|
|
81
123
|
return selection.getSelectedItem().feature
|
|
82
124
|
}
|
|
125
|
+
function getSelectedFeatures () {
|
|
126
|
+
return selection.getSelectedItems().filter(item => item.feature).map(item => item.feature)
|
|
127
|
+
}
|
|
83
128
|
function getSelectedFeatureCollection () {
|
|
84
129
|
return { type: 'FeatureCollection', features: selection.getSelectedItems().filter(item => item.feature).map(item => item.feature) }
|
|
85
130
|
}
|
|
131
|
+
function getSelectedFeaturesByLayer () {
|
|
132
|
+
const featuresByLayer = {}
|
|
133
|
+
const items = selection.getSelectedItems().filter(item => item.feature && item.layer)
|
|
134
|
+
items.forEach(item => {
|
|
135
|
+
const key = item.layer._id || item.layer.name
|
|
136
|
+
if (!featuresByLayer[key]) featuresByLayer[key] = { layer: item.layer, features: [] }
|
|
137
|
+
featuresByLayer[key].features.push(item.feature)
|
|
138
|
+
})
|
|
139
|
+
return _.values(featuresByLayer)
|
|
140
|
+
}
|
|
86
141
|
function hasSelectedLayer () {
|
|
87
142
|
return selection.hasSelectedItem() && selection.getSelectedItem().layer
|
|
88
143
|
}
|
|
89
144
|
function getSelectedLayer () {
|
|
90
145
|
return selection.getSelectedItem().layer
|
|
91
146
|
}
|
|
147
|
+
function getSelectedLayers () {
|
|
148
|
+
return selection.getSelectedItem().filter(item => item.layer).map(item => item.layer)
|
|
149
|
+
}
|
|
92
150
|
function hasSelectedLocation () {
|
|
93
151
|
return selection.hasSelectedItem() && selection.getSelectedItem().location
|
|
94
152
|
}
|
|
95
153
|
function getSelectedLocation () {
|
|
96
154
|
return selection.getSelectedItem().location
|
|
97
155
|
}
|
|
98
|
-
function
|
|
156
|
+
function findSelectedFeature (feature, layer) {
|
|
99
157
|
const items = selection.getSelectedItems()
|
|
100
158
|
for (let i = 0; i < items.length; i++) {
|
|
101
159
|
const item = items[i]
|
|
102
160
|
if (item.feature && item.layer && (item.layer.name === layer.name)) {
|
|
103
|
-
const selectedId = getFeatureId(item.feature, item.layer)
|
|
104
|
-
const featureId = getFeatureId(feature, layer)
|
|
105
|
-
if (featureId === selectedId) return
|
|
161
|
+
const selectedId = utils.getFeatureId(item.feature, item.layer)
|
|
162
|
+
const featureId = utils.getFeatureId(feature, layer)
|
|
163
|
+
if (featureId === selectedId) return item
|
|
106
164
|
}
|
|
107
165
|
}
|
|
108
|
-
return
|
|
166
|
+
return null
|
|
167
|
+
}
|
|
168
|
+
function isFeatureSelected (feature, layer) {
|
|
169
|
+
return findSelectedFeature(feature, layer) !== null
|
|
109
170
|
}
|
|
110
171
|
function getWidgetForSelection () {
|
|
111
172
|
let widget
|
|
@@ -194,6 +255,8 @@ export function useSelection (name, options = {}) {
|
|
|
194
255
|
|
|
195
256
|
let lastClickedPosition, lastBoxSelectionPosition
|
|
196
257
|
function onClicked (layer, event) {
|
|
258
|
+
if (!selection.isSelectionEnabled()) return
|
|
259
|
+
|
|
197
260
|
// FIXME: For some layers, eg based on path, we get a first click with the layer as target
|
|
198
261
|
// then a second click with the map as target, we need to filter the later for selection
|
|
199
262
|
// Similarly we get a click when performing a box selection
|
|
@@ -216,6 +279,11 @@ export function useSelection (name, options = {}) {
|
|
|
216
279
|
// Retrieve the location
|
|
217
280
|
const location = _.get(event, 'latlng')
|
|
218
281
|
if (selection.getSelectionMode() === 'buffer') {
|
|
282
|
+
if (activity.is2D() && options.showBuffer) {
|
|
283
|
+
const highlightStyle = _.get(config, `engines.${activity.engine}.style.selection.polygon`, {})
|
|
284
|
+
const marker = L.circleMarker(location, Object.assign({ radius: options.buffer }, convertPolygonStyleToLeafletPath(highlightStyle))).addTo(activity.map)
|
|
285
|
+
setTimeout(() => marker.removeFrom(activity.map), options.showBufferDelay)
|
|
286
|
+
}
|
|
219
287
|
const center = activity.getCenter()
|
|
220
288
|
// https://wiki.openstreetmap.org/wiki/Zoom_levels
|
|
221
289
|
const metresPerPixel = 40075016.686 * Math.abs(Math.cos(location.lat * Math.PI / 180)) / Math.pow(2, center.zoomLevel + 8)
|
|
@@ -249,7 +317,9 @@ export function useSelection (name, options = {}) {
|
|
|
249
317
|
else handleSelection(items, clearSelection)
|
|
250
318
|
}
|
|
251
319
|
function onBoxSelection (map, event) {
|
|
252
|
-
|
|
320
|
+
if (!selection.isSelectionEnabled()) return
|
|
321
|
+
|
|
322
|
+
lastBoxSelectionPosition = _.get(event, 'containerPoint')
|
|
253
323
|
const { bounds } = event
|
|
254
324
|
let items = getIntersectedItems(bboxPolygon([
|
|
255
325
|
bounds.getWest(), bounds.getSouth(), bounds.getEast(), bounds.getNorth()
|
|
@@ -263,6 +333,8 @@ export function useSelection (name, options = {}) {
|
|
|
263
333
|
else handleSelection(items, true)
|
|
264
334
|
}
|
|
265
335
|
function onClusterSelection (layer, event) {
|
|
336
|
+
if (!selection.isSelectionEnabled()) return
|
|
337
|
+
|
|
266
338
|
// Not relevent in this case
|
|
267
339
|
if (selection.isSingleSelectionMode()) return
|
|
268
340
|
const items = _.get(event, 'markers', []).map(marker => {
|
|
@@ -282,19 +354,60 @@ export function useSelection (name, options = {}) {
|
|
|
282
354
|
const hiddenFeatures = selection.getSelectedItems().filter(item => layer.name === _.get(item, 'layer.name'))
|
|
283
355
|
hiddenFeatures.forEach((item) => selection.unselectItem(item))
|
|
284
356
|
}
|
|
357
|
+
function listenToFeaturesServiceEventsForLayer (layer) {
|
|
358
|
+
const listeners = utils.listenToFeaturesServiceEventsForLayer(layer, {
|
|
359
|
+
all: onFeatureUpdated, removed: onFeatureRemoved
|
|
360
|
+
}, layerServiceEventListeners[layer._id])
|
|
361
|
+
if (listeners) layerServiceEventListeners[layer._id] = listeners
|
|
362
|
+
}
|
|
363
|
+
function unlistenToFeaturesServiceEventsForLayer (layer) {
|
|
364
|
+
utils.unlistenToFeaturesServiceEventsForLayer(layer, layerServiceEventListeners[layer._id])
|
|
365
|
+
delete layerServiceEventListeners[layer._id]
|
|
366
|
+
}
|
|
367
|
+
function listenToFeaturesServiceEventsForLayers () {
|
|
368
|
+
layerServiceEventListeners = {}
|
|
369
|
+
_.forEach(activity.getLayers(), listenToFeaturesServiceEventsForLayer)
|
|
370
|
+
}
|
|
371
|
+
function unlistenToFeaturesServiceEventsForLayers () {
|
|
372
|
+
_.forOwn(layerServiceEventListeners, unlistenToFeaturesServiceEventsForLayer)
|
|
373
|
+
layerServiceEventListeners = {}
|
|
374
|
+
}
|
|
375
|
+
function onFeatureUpdated (feature, layer) {
|
|
376
|
+
// Find related layer, either directly given in feature if coming from user-defined features service
|
|
377
|
+
// otherwise bound to the listener for features services attached to a built-in layer
|
|
378
|
+
if (!layer && feature.layer) layer = activity.getLayerById(feature.layer)
|
|
379
|
+
if (!layer) return
|
|
380
|
+
const item = findSelectedFeature(feature, layer)
|
|
381
|
+
if (item) Object.assign(item.feature, feature)
|
|
382
|
+
}
|
|
383
|
+
function onFeatureRemoved (feature, layer) {
|
|
384
|
+
// Find related layer, either directly given in feature if coming from user-defined features service
|
|
385
|
+
// otherwise bound to the listener for features services attached to a built-in layer
|
|
386
|
+
if (!layer && feature.layer) layer = activity.getLayerById(feature.layer)
|
|
387
|
+
if (!layer) return
|
|
388
|
+
const item = findSelectedFeature(feature, layer)
|
|
389
|
+
if (item) selection.unselectItem(item)
|
|
390
|
+
}
|
|
285
391
|
|
|
286
|
-
//
|
|
392
|
+
// Expose
|
|
287
393
|
return {
|
|
288
394
|
...selection,
|
|
395
|
+
getSelectionOptions: () => get('options'),
|
|
289
396
|
setCurrentActivity,
|
|
290
397
|
hasSelectedFeature,
|
|
291
398
|
getSelectedFeature,
|
|
399
|
+
getSelectedFeatures,
|
|
292
400
|
getSelectedFeatureCollection,
|
|
401
|
+
getSelectedFeaturesByLayer,
|
|
293
402
|
hasSelectedLayer,
|
|
294
403
|
getSelectedLayer,
|
|
404
|
+
getSelectedLayers,
|
|
295
405
|
hasSelectedLocation,
|
|
296
406
|
getSelectedLocation,
|
|
297
407
|
getWidgetForSelection,
|
|
298
|
-
centerOnSelection
|
|
408
|
+
centerOnSelection,
|
|
409
|
+
setBoxSelectionEnabled,
|
|
410
|
+
setClusterSelectionEnabled,
|
|
411
|
+
setBufferWidth
|
|
299
412
|
}
|
|
300
413
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import logger from 'loglevel'
|
|
3
|
+
import config from 'config'
|
|
4
|
+
import { Store, api, i18n, Events } from '../../core/client/index.js'
|
|
5
|
+
import { parseCoordinates } from './utils/index.js'
|
|
6
|
+
import { formatUserCoordinates, formatForwardGeocodingResult } from './utils/utils.location.js'
|
|
7
|
+
import { Planets } from './planets.js'
|
|
8
|
+
|
|
9
|
+
export const Geocoder = {
|
|
10
|
+
initialize () {
|
|
11
|
+
// Sets the available apps
|
|
12
|
+
Store.set('geocoder', _.defaultsDeep(config.geocoder, {
|
|
13
|
+
planet: undefined,
|
|
14
|
+
path: 'geocoder'
|
|
15
|
+
}))
|
|
16
|
+
logger.debug('[KDK] Geocoder initialized with configuration:', Store.get('geocoder'))
|
|
17
|
+
},
|
|
18
|
+
getApiConfig () {
|
|
19
|
+
const planet = Store.get('geocoder.planet')
|
|
20
|
+
if (planet) return Planets.get(planet).getConfig()
|
|
21
|
+
return api.getConfig()
|
|
22
|
+
},
|
|
23
|
+
getApiPath () {
|
|
24
|
+
return Store.get('geocoder.path')
|
|
25
|
+
},
|
|
26
|
+
async query (path, query = '') {
|
|
27
|
+
// retrieve required data
|
|
28
|
+
const apiConfig = this.getApiConfig()
|
|
29
|
+
if (!_.has(apiConfig, 'gateway')) {
|
|
30
|
+
logger.error('[KDK] Invalid Geocoder configuration: missing \'gateway\' property')
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
if (!_.has(apiConfig, 'gatewayJwt')) {
|
|
34
|
+
logger.error('[KDK] Invalid Geocoder configuration: missing \'gatewayJwt\' property')
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
const endpoint = `${apiConfig.gateway}/${this.getApiPath()}`
|
|
38
|
+
const jwt = await api.get('storage').getItem(apiConfig.gatewayJwt)
|
|
39
|
+
// setup the query url
|
|
40
|
+
let url = `${endpoint}/${path}`
|
|
41
|
+
if (query) url += `?${query}`
|
|
42
|
+
// query the service
|
|
43
|
+
const response = await fetch(url, { headers: { Authorization: `Bearer ${jwt}` } })
|
|
44
|
+
return response.json()
|
|
45
|
+
},
|
|
46
|
+
async getForwardCapabilities () {
|
|
47
|
+
let response
|
|
48
|
+
try {
|
|
49
|
+
response = await this.query('capabilities/forward')
|
|
50
|
+
if (response.i18n) i18n.registerTranslation(response.i18n)
|
|
51
|
+
} catch (error) {
|
|
52
|
+
Events.emit('error', { message: i18n.t('errors.NETWORK_ERROR') })
|
|
53
|
+
}
|
|
54
|
+
return _.get(response, 'geocoders', [])
|
|
55
|
+
},
|
|
56
|
+
async getReverseCapabilities () {
|
|
57
|
+
let response
|
|
58
|
+
try {
|
|
59
|
+
response = await this.query('capabilities/reverse')
|
|
60
|
+
if (response.i18n) i18n.registerTranslation(response.i18n)
|
|
61
|
+
} catch (error) {
|
|
62
|
+
Events.emit('error', { message: i18n.t('errors.NETWORK_ERROR') })
|
|
63
|
+
}
|
|
64
|
+
return _.get(response, 'geocoders', [])
|
|
65
|
+
},
|
|
66
|
+
async queryForward (pattern, options = {}) {
|
|
67
|
+
const locations = []
|
|
68
|
+
// Try to parse lat/long coordinates
|
|
69
|
+
const coordinates = parseCoordinates(pattern)
|
|
70
|
+
if (coordinates) {
|
|
71
|
+
locations.push({
|
|
72
|
+
type: 'Feature',
|
|
73
|
+
geometry: {
|
|
74
|
+
type: 'Point',
|
|
75
|
+
coordinates: [coordinates.longitude, coordinates.latitude]
|
|
76
|
+
},
|
|
77
|
+
properties: {
|
|
78
|
+
name: formatUserCoordinates(coordinates.latitude, coordinates.longitude, Store.get('locationFormat', 'FFf'))
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
} else {
|
|
82
|
+
let filter = ''
|
|
83
|
+
// Take into account optional geocoders
|
|
84
|
+
if (!_.isEmpty(options.geocoders)) {
|
|
85
|
+
filter += '&sources=*(' + options.geocoders.join('|') + ')'
|
|
86
|
+
}
|
|
87
|
+
// Take into account optional viewbo
|
|
88
|
+
if (!_.isEmpty(options.viewbox)) {
|
|
89
|
+
filter += '&viewbox=' + options.viewbox.join(',')
|
|
90
|
+
}
|
|
91
|
+
// Define the limit
|
|
92
|
+
filter += '&limit=' + (options.limit || 20)
|
|
93
|
+
const results = await this.query('forward', `q=${pattern}${filter}`)
|
|
94
|
+
results.forEach(result => {
|
|
95
|
+
locations.push(
|
|
96
|
+
Object.assign(
|
|
97
|
+
_.pick(result, ['type', 'geometry']),
|
|
98
|
+
{ properties: { name: formatForwardGeocodingResult(result), source: result.geokoder.source } }))
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
return locations
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
}
|
|
@@ -56,7 +56,7 @@ export const Geolocation = {
|
|
|
56
56
|
try {
|
|
57
57
|
location = await this.refresh()
|
|
58
58
|
Store.patch('geolocation', { location, error: undefined })
|
|
59
|
-
logger.debug('[KDK]
|
|
59
|
+
logger.debug('[KDK] Geolocation updated:', location)
|
|
60
60
|
} catch (error) {
|
|
61
61
|
const code = error.code
|
|
62
62
|
const geolocationError = new errors.KGeolocationError()
|
package/map/client/globe.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as commonMixins from './mixins/index.js'
|
|
2
2
|
import * as globeMixins from './mixins/globe/index.js'
|
|
3
|
+
import * as hooks from './hooks/index.js'
|
|
3
4
|
import * as utils from './utils.globe.js'
|
|
4
5
|
import init from './init.js'
|
|
5
6
|
|
|
@@ -7,6 +8,8 @@ const mixins = Object.assign({}, commonMixins, { globe: globeMixins })
|
|
|
7
8
|
|
|
8
9
|
export * from './geolocation.js'
|
|
9
10
|
export * from './planets.js'
|
|
11
|
+
export * from './navigator.js'
|
|
12
|
+
export { hooks }
|
|
10
13
|
export { utils }
|
|
11
14
|
export { mixins }
|
|
12
15
|
export * from '../common/index.js'
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import logger from 'loglevel'
|
|
3
|
+
import booleanIntersects from '@turf/boolean-intersects'
|
|
4
|
+
import { polygon } from '@turf/helpers'
|
|
5
|
+
|
|
6
|
+
export function removeServerSideParameters(context) {
|
|
7
|
+
const params = context.params
|
|
8
|
+
if (_.has(params, 'query.east')) {
|
|
9
|
+
_.set(params, 'east', _.get(params, 'query.east'))
|
|
10
|
+
_.unset(params, 'query.east')
|
|
11
|
+
}
|
|
12
|
+
if (_.has(params, 'query.west')) {
|
|
13
|
+
_.set(params, 'west', _.get(params, 'query.west'))
|
|
14
|
+
_.unset(params, 'query.west')
|
|
15
|
+
}
|
|
16
|
+
if (_.has(params, 'query.north')) {
|
|
17
|
+
_.set(params, 'north', _.get(params, 'query.north'))
|
|
18
|
+
_.unset(params, 'query.north')
|
|
19
|
+
}
|
|
20
|
+
if (_.has(params, 'query.south')) {
|
|
21
|
+
_.set(params, 'south', _.get(params, 'query.south'))
|
|
22
|
+
_.unset(params, 'query.south')
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function updateReferenceCount(service, id, increment) {
|
|
27
|
+
const feature = await service._get(id)
|
|
28
|
+
const count = _.get(feature, 'referenceCount', 0) + increment
|
|
29
|
+
const data = await service._patch(id, { referenceCount: count })
|
|
30
|
+
return data
|
|
31
|
+
}
|
|
32
|
+
export async function referenceCountCreateHook(context) {
|
|
33
|
+
const service = context.service
|
|
34
|
+
const features = (Array.isArray(context.data) ? context.data : [context.data])
|
|
35
|
+
for (let i = 0; i < features.length; i++) {
|
|
36
|
+
const feature = features[i]
|
|
37
|
+
try {
|
|
38
|
+
// This will raise if feature does not exist
|
|
39
|
+
await updateReferenceCount(service, feature._id, +1)
|
|
40
|
+
} catch (error) {
|
|
41
|
+
feature.referenceCount = 1
|
|
42
|
+
await service._create(feature)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
context.result = context.data
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function referenceCountRemoveHook(context) {
|
|
49
|
+
const service = context.service
|
|
50
|
+
// By ID or by query ?
|
|
51
|
+
if (!context.id) {
|
|
52
|
+
context.result = await service._find(Object.assign(context.params, { paginate: false }))
|
|
53
|
+
for (let i = 0; i < context.result.length; i++) {
|
|
54
|
+
const feature = context.result[i]
|
|
55
|
+
try {
|
|
56
|
+
const { referenceCount } = await updateReferenceCount(service, feature._id, -1)
|
|
57
|
+
// Skip removing if still used
|
|
58
|
+
if (referenceCount <= 0) await service._remove(feature._id)
|
|
59
|
+
} catch (error) {
|
|
60
|
+
logger.debug('[KDK] reference count update failed: ', error)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
const feature = await updateReferenceCount(service, context.id, -1)
|
|
65
|
+
// Skip removing if still used
|
|
66
|
+
if (feature.referenceCount <= 0) await service._remove(context.id)
|
|
67
|
+
context.result = feature
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function geoJsonPaginationHook(context) {
|
|
72
|
+
const result = context.result
|
|
73
|
+
const features = result.data
|
|
74
|
+
if (_.get(features, '[0].type') !== 'Feature') return
|
|
75
|
+
context.result = Object.assign({
|
|
76
|
+
type: 'FeatureCollection',
|
|
77
|
+
features: result.data
|
|
78
|
+
}, _.pick(result, ['total', 'skip', 'limit']))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export async function intersectBBoxHook(context) {
|
|
82
|
+
const params = context.params
|
|
83
|
+
if (!_.has(params, 'east') || !_.has(params, 'west') || !_.has(params, 'north') || !_.has(params, 'south')) return context
|
|
84
|
+
const service = context.service
|
|
85
|
+
const query = await service._find(_.omit(params, ['east', 'west', 'north', 'south']))
|
|
86
|
+
const features = query.data
|
|
87
|
+
const bbox = polygon([[[params.east, params.south], [params.west, params.south], [params.west, params.north], [params.east, params.north], [params.east, params.south]]])
|
|
88
|
+
let result = []
|
|
89
|
+
for (let feature of features) {
|
|
90
|
+
if (booleanIntersects(bbox, feature)) {
|
|
91
|
+
result.push(feature)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
_.set(context, 'result.data', result)
|
|
95
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hooks.offline.js'
|