@kalisio/kdk 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nyc_output/02a7a308-a8d7-4cc6-8e61-6066a0055a96.json +1 -0
- package/.nyc_output/1900d596-5e87-433a-8fd6-fb7f7ded35ec.json +1 -0
- package/.nyc_output/{058fc679-d60a-4501-ac04-71171e5200b8.json → 27401f21-8ccf-42fa-8230-4232189d86b3.json} +0 -0
- package/.nyc_output/{8b1830fa-932e-4a61-9837-4a5b18f83ea9.json → 52278ef5-c337-4724-97be-e2e4416847c5.json} +0 -0
- package/.nyc_output/{afd2d144-3570-4858-b94a-b523dbd023dd.json → 5dd49b8a-4c84-42f9-a3d5-712247a84775.json} +0 -0
- package/.nyc_output/612b4859-9645-45c1-a41e-1fae420518c4.json +1 -0
- package/.nyc_output/bab87fe9-d99a-4759-99e6-3fc4622eeca0.json +1 -0
- package/.nyc_output/processinfo/02a7a308-a8d7-4cc6-8e61-6066a0055a96.json +1 -0
- package/.nyc_output/processinfo/1900d596-5e87-433a-8fd6-fb7f7ded35ec.json +1 -0
- package/.nyc_output/processinfo/27401f21-8ccf-42fa-8230-4232189d86b3.json +1 -0
- package/.nyc_output/processinfo/52278ef5-c337-4724-97be-e2e4416847c5.json +1 -0
- package/.nyc_output/processinfo/5dd49b8a-4c84-42f9-a3d5-712247a84775.json +1 -0
- package/.nyc_output/processinfo/612b4859-9645-45c1-a41e-1fae420518c4.json +1 -0
- package/.nyc_output/processinfo/bab87fe9-d99a-4759-99e6-3fc4622eeca0.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/.travis.test.sh +1 -1
- package/CHANGELOG.md +107 -11
- package/coverage/core/api/application.js.html +323 -245
- package/coverage/core/api/authentication.js.html +1 -1
- package/coverage/core/api/db.js.html +108 -108
- package/coverage/core/api/hooks/hooks.account.js.html +1 -1
- package/coverage/core/api/hooks/hooks.authentication.js.html +1 -1
- package/coverage/core/api/hooks/hooks.authorisations.js.html +21 -6
- package/coverage/core/api/hooks/hooks.devices.js.html +1 -1
- package/coverage/core/api/hooks/hooks.groups.js.html +1 -1
- package/coverage/core/api/hooks/hooks.logger.js.html +1 -1
- package/coverage/core/api/hooks/hooks.model.js.html +1 -1
- package/coverage/core/api/hooks/hooks.organisations.js.html +1 -1
- package/coverage/core/api/hooks/hooks.pusher.js.html +1 -1
- package/coverage/core/api/hooks/hooks.query.js.html +114 -48
- 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.tags.js.html +1 -1
- package/coverage/core/api/hooks/hooks.users.js.html +1 -1
- package/coverage/core/api/hooks/index.html +12 -12
- package/coverage/core/api/hooks/index.js.html +1 -1
- package/coverage/core/api/index.html +34 -34
- package/coverage/core/api/index.js.html +26 -26
- package/coverage/core/api/marshall.js.html +1 -1
- package/coverage/core/api/models/groups.model.mongodb.js.html +1 -1
- package/coverage/core/api/models/index.html +1 -1
- package/coverage/core/api/models/organisations.model.mongodb.js.html +1 -1
- 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/oauth2-handler.js.html +1 -1
- package/coverage/core/api/oauth2-verifier.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 +1 -1
- package/coverage/core/api/services/account/index.html +1 -1
- package/coverage/core/api/services/authorisations/authorisations.hooks.js.html +1 -1
- package/coverage/core/api/services/authorisations/authorisations.service.js.html +31 -7
- package/coverage/core/api/services/authorisations/index.html +9 -9
- package/coverage/core/api/services/databases/databases.hooks.js.html +1 -1
- package/coverage/core/api/services/databases/databases.service.js.html +1 -1
- package/coverage/core/api/services/databases/index.html +1 -1
- package/coverage/core/api/services/devices/devices.hooks.js.html +1 -1
- package/coverage/core/api/services/devices/devices.service.js.html +1 -1
- package/coverage/core/api/services/devices/index.html +1 -1
- 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/index.html +11 -11
- package/coverage/core/api/services/index.js.html +66 -66
- 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/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 +1 -1
- package/coverage/core/api/services/pusher/index.html +1 -1
- package/coverage/core/api/services/pusher/pusher.channels.js.html +1 -1
- package/coverage/core/api/services/pusher/pusher.hooks.js.html +1 -1
- package/coverage/core/api/services/pusher/pusher.service.js.html +1 -1
- package/coverage/core/api/services/storage/index.html +1 -1
- package/coverage/core/api/services/storage/storage.hooks.js.html +1 -1
- 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 +1 -1
- package/coverage/core/api/services/users/users.hooks.js.html +1 -1
- package/coverage/core/common/errors.js.html +1 -1
- package/coverage/core/common/index.html +7 -7
- package/coverage/core/common/index.js.html +1 -1
- package/coverage/core/common/permissions.js.html +81 -51
- package/coverage/index.html +39 -39
- package/coverage/lcov-report/core/api/application.js.html +323 -245
- package/coverage/lcov-report/core/api/authentication.js.html +1 -1
- package/coverage/lcov-report/core/api/db.js.html +108 -108
- package/coverage/lcov-report/core/api/hooks/hooks.account.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.authentication.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.authorisations.js.html +21 -6
- package/coverage/lcov-report/core/api/hooks/hooks.devices.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.groups.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.logger.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.model.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.organisations.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.pusher.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.query.js.html +114 -48
- 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.tags.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/hooks.users.js.html +1 -1
- package/coverage/lcov-report/core/api/hooks/index.html +12 -12
- package/coverage/lcov-report/core/api/hooks/index.js.html +1 -1
- package/coverage/lcov-report/core/api/index.html +34 -34
- package/coverage/lcov-report/core/api/index.js.html +26 -26
- package/coverage/lcov-report/core/api/marshall.js.html +1 -1
- package/coverage/lcov-report/core/api/models/groups.model.mongodb.js.html +1 -1
- package/coverage/lcov-report/core/api/models/index.html +1 -1
- package/coverage/lcov-report/core/api/models/organisations.model.mongodb.js.html +1 -1
- 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/oauth2-handler.js.html +1 -1
- package/coverage/lcov-report/core/api/oauth2-verifier.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 +1 -1
- package/coverage/lcov-report/core/api/services/account/index.html +1 -1
- 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 +31 -7
- package/coverage/lcov-report/core/api/services/authorisations/index.html +9 -9
- package/coverage/lcov-report/core/api/services/databases/databases.hooks.js.html +1 -1
- package/coverage/lcov-report/core/api/services/databases/databases.service.js.html +1 -1
- package/coverage/lcov-report/core/api/services/databases/index.html +1 -1
- package/coverage/lcov-report/core/api/services/devices/devices.hooks.js.html +1 -1
- package/coverage/lcov-report/core/api/services/devices/devices.service.js.html +1 -1
- package/coverage/lcov-report/core/api/services/devices/index.html +1 -1
- 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/index.html +11 -11
- package/coverage/lcov-report/core/api/services/index.js.html +66 -66
- 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/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 +1 -1
- package/coverage/lcov-report/core/api/services/pusher/index.html +1 -1
- package/coverage/lcov-report/core/api/services/pusher/pusher.channels.js.html +1 -1
- package/coverage/lcov-report/core/api/services/pusher/pusher.hooks.js.html +1 -1
- package/coverage/lcov-report/core/api/services/pusher/pusher.service.js.html +1 -1
- package/coverage/lcov-report/core/api/services/storage/index.html +1 -1
- package/coverage/lcov-report/core/api/services/storage/storage.hooks.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/core/api/services/users/users.hooks.js.html +1 -1
- package/coverage/lcov-report/core/common/errors.js.html +1 -1
- package/coverage/lcov-report/core/common/index.html +7 -7
- package/coverage/lcov-report/core/common/index.js.html +1 -1
- package/coverage/lcov-report/core/common/permissions.js.html +81 -51
- package/coverage/lcov-report/index.html +39 -39
- package/coverage/lcov-report/map/api/hooks/hooks.catalog.js.html +1 -1
- package/coverage/lcov-report/map/api/hooks/hooks.query.js.html +1 -1
- package/coverage/lcov-report/map/api/hooks/index.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/map/api/models/features.model.mongodb.js.html +14 -5
- package/coverage/lcov-report/map/api/models/index.html +7 -7
- 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 +1 -1
- package/coverage/lcov-report/map/api/services/catalog/index.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/map/api/services/features/index.html +1 -1
- package/coverage/lcov-report/map/api/services/geocoder/geocoder.hooks.js.html +1 -1
- package/coverage/lcov-report/map/api/services/geocoder/geocoder.service.js.html +1 -1
- package/coverage/lcov-report/map/api/services/geocoder/index.html +1 -1
- package/coverage/lcov-report/map/api/services/index.html +1 -1
- package/coverage/lcov-report/map/api/services/index.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/map/common/grid.js.html +1 -1
- package/coverage/lcov-report/map/common/index.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/map/common/time-based-grid-source.js.html +1 -1
- package/coverage/lcov-report/map/common/tms-utils.js.html +1 -1
- package/coverage/lcov-report/map/common/wcs-grid-source.js.html +1 -1
- package/coverage/lcov-report/map/common/wcs-utils.js.html +1 -1
- package/coverage/lcov-report/map/common/weacast-grid-source.js.html +1 -1
- package/coverage/lcov-report/map/common/wfs-utils.js.html +1 -1
- package/coverage/lcov-report/map/common/wms-utils.js.html +1 -1
- package/coverage/lcov-report/map/common/wmts-utils.js.html +1 -1
- package/coverage/lcov.info +948 -769
- package/coverage/map/api/hooks/hooks.catalog.js.html +1 -1
- package/coverage/map/api/hooks/hooks.query.js.html +1 -1
- package/coverage/map/api/hooks/index.html +1 -1
- 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 +1 -1
- package/coverage/map/api/models/features.model.mongodb.js.html +14 -5
- package/coverage/map/api/models/index.html +7 -7
- 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 +1 -1
- package/coverage/map/api/services/catalog/index.html +1 -1
- 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 +1 -1
- package/coverage/map/api/services/features/index.html +1 -1
- package/coverage/map/api/services/geocoder/geocoder.hooks.js.html +1 -1
- package/coverage/map/api/services/geocoder/geocoder.service.js.html +1 -1
- package/coverage/map/api/services/geocoder/index.html +1 -1
- package/coverage/map/api/services/index.html +1 -1
- package/coverage/map/api/services/index.js.html +1 -1
- 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 +1 -1
- package/coverage/map/common/grid.js.html +1 -1
- package/coverage/map/common/index.html +1 -1
- 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 +1 -1
- package/coverage/map/common/time-based-grid-source.js.html +1 -1
- package/coverage/map/common/tms-utils.js.html +1 -1
- package/coverage/map/common/wcs-grid-source.js.html +1 -1
- package/coverage/map/common/wcs-utils.js.html +1 -1
- package/coverage/map/common/weacast-grid-source.js.html +1 -1
- package/coverage/map/common/wfs-utils.js.html +1 -1
- package/coverage/map/common/wms-utils.js.html +1 -1
- package/coverage/map/common/wmts-utils.js.html +1 -1
- package/extras/tours/map/catalog-panel.js +61 -10
- package/extras/tours/map/create-view.js +25 -0
- package/extras/tours/map/fab.js +10 -1
- package/extras/tours/map/navigation-bar.js +56 -10
- package/lib/core/api/application.js +44 -10
- package/lib/core/api/application.js.map +1 -1
- package/lib/core/api/hooks/hooks.authorisations.js +8 -1
- package/lib/core/api/hooks/hooks.authorisations.js.map +1 -1
- package/lib/core/api/hooks/hooks.query.js +135 -100
- package/lib/core/api/hooks/hooks.query.js.map +1 -1
- package/lib/core/api/services/authorisations/authorisations.service.js +13 -1
- package/lib/core/api/services/authorisations/authorisations.service.js.map +1 -1
- package/lib/core/api/services/pusher/pusher.service.js +40 -16
- package/lib/core/api/services/pusher/pusher.service.js.map +1 -1
- package/lib/core/client/components/chart/KChart.vue +115 -0
- package/lib/core/client/components/chart/KStatsChart.vue +76 -0
- package/lib/core/client/components/chart/index.js +20 -0
- package/lib/core/client/components/chart/index.js.map +1 -0
- package/lib/core/client/components/collection/KColumn.vue +29 -28
- package/lib/core/client/components/collection/KFilter.vue +103 -72
- package/lib/core/client/components/collection/KHistoryEntry.vue +1 -1
- package/lib/core/client/components/collection/KItem.vue +4 -4
- package/lib/core/client/components/editor/KModalEditor.vue +3 -4
- package/lib/core/client/components/editor/KSettingsEditor.vue +6 -2
- package/lib/core/client/components/form/KChipsField.vue +4 -4
- package/lib/core/client/components/form/KFileField.vue +13 -6
- package/lib/core/client/components/form/KRoleField.vue +5 -2
- package/lib/core/client/components/form/KTextField.vue +12 -2
- package/lib/core/client/components/form/KUnitField.vue +57 -0
- package/lib/core/client/components/form/KUrlField.vue +1 -1
- package/lib/core/client/components/form/KView.vue +1 -1
- package/lib/core/client/components/frame/KAction.vue +41 -7
- package/lib/core/client/components/frame/KBlock.vue +7 -7
- package/lib/core/client/components/frame/KContent.vue +1 -1
- package/lib/core/client/components/frame/KModal.vue +66 -20
- package/lib/core/client/components/frame/KOpener.vue +1 -1
- package/lib/core/client/components/frame/KPanel.vue +8 -7
- package/lib/core/client/components/frame/KPopupAction.vue +6 -0
- package/lib/core/client/components/frame/KScreen.vue +1 -1
- package/lib/core/client/components/frame/KScrollArea.vue +65 -0
- package/lib/core/client/components/frame/KStamp.vue +4 -2
- package/lib/core/client/components/frame/index.js +6 -6
- package/lib/core/client/components/frame/index.js.map +1 -1
- package/lib/core/client/components/input/KColorChooser.vue +3 -5
- package/lib/core/client/components/input/KIconChooser.vue +41 -40
- package/lib/core/client/components/input/KPalette.vue +1 -1
- package/lib/core/client/components/input/index.js +14 -4
- package/lib/core/client/components/input/index.js.map +1 -1
- package/lib/core/client/components/layout/KAbout.vue +47 -49
- package/lib/core/client/components/layout/KFab.vue +1 -1
- package/lib/core/client/components/layout/KLayout.vue +10 -2
- package/lib/core/client/components/layout/KPage.vue +19 -18
- package/lib/core/client/components/layout/KTour.vue +5 -3
- package/lib/core/client/components/layout/KWindow.vue +211 -59
- package/lib/core/client/components/media/KMediaBrowser.vue +6 -6
- package/lib/core/client/components/menu/KMenu.vue +13 -5
- package/lib/core/client/components/menu/KRadialFab.vue +22 -24
- package/lib/core/client/components/menu/KRadialFabItem.vue +17 -18
- package/lib/core/client/components/team/KAddMember.vue +1 -1
- package/lib/core/client/components/team/KChangeRole.vue +11 -14
- package/lib/core/client/components/team/KGroupCard.vue +12 -5
- package/lib/core/client/components/team/KJoinGroup.vue +22 -22
- package/lib/core/client/components/team/KMemberCard.vue +19 -4
- package/lib/core/client/components/time/KAbsoluteTimeRange.vue +190 -0
- package/lib/core/client/components/time/KRelativeTimeRanges.vue +192 -0
- package/lib/core/client/components/time/index.js +20 -0
- package/lib/core/client/components/time/index.js.map +1 -0
- package/lib/core/client/components/viewer/KModalViewer.vue +10 -9
- package/lib/core/client/i18n/core_en.json +99 -17
- package/lib/core/client/i18n/core_fr.json +94 -18
- package/lib/core/client/index.js +16 -3
- package/lib/core/client/index.js.map +1 -1
- package/lib/core/client/mixins/mixin.base-collection.js +11 -1
- package/lib/core/client/mixins/mixin.base-collection.js.map +1 -1
- package/lib/core/client/mixins/mixin.base-widget.js +26 -12
- package/lib/core/client/mixins/mixin.base-widget.js.map +1 -1
- package/lib/core/client/reader.js +46 -15
- package/lib/core/client/reader.js.map +1 -1
- package/lib/core/client/readers/reader.csv.js +33 -22
- package/lib/core/client/readers/reader.csv.js.map +1 -1
- package/lib/core/client/readers/reader.json.js +31 -20
- package/lib/core/client/readers/reader.json.js.map +1 -1
- package/lib/core/client/services/index.js +16 -4
- package/lib/core/client/services/index.js.map +1 -1
- package/lib/core/client/services/local-settings.service.js +10 -4
- package/lib/core/client/services/local-settings.service.js.map +1 -1
- package/lib/core/client/time.js +29 -18
- package/lib/core/client/time.js.map +1 -1
- package/lib/core/client/units.js +207 -0
- package/lib/core/client/units.js.map +1 -0
- package/lib/core/client/utils.js +11 -0
- package/lib/core/client/utils.js.map +1 -1
- package/lib/core/common/permissions.js +44 -34
- package/lib/core/common/permissions.js.map +1 -1
- package/lib/core/common/schemas/settings.update.json +86 -4
- package/lib/map/api/hooks/hooks.catalog.js +20 -0
- package/lib/map/api/hooks/hooks.catalog.js.map +1 -1
- package/lib/map/api/models/catalog.model.mongodb.js +6 -1
- package/lib/map/api/models/catalog.model.mongodb.js.map +1 -1
- package/lib/map/api/models/features.model.mongodb.js +8 -0
- package/lib/map/api/models/features.model.mongodb.js.map +1 -1
- package/lib/map/api/services/catalog/catalog.hooks.js +3 -1
- package/lib/map/api/services/catalog/catalog.hooks.js.map +1 -1
- package/lib/map/client/components/KCaptureToolbar.vue +2 -7
- package/lib/map/client/components/KColorLegend.vue +38 -25
- package/lib/map/client/components/KFeaturesChart.vue +84 -114
- package/lib/map/client/components/KFeaturesFilter.vue +37 -38
- package/lib/map/client/components/KFeaturesTable.vue +15 -16
- package/lib/map/client/components/KLayerStyleEditor.vue +1 -1
- package/lib/map/client/components/KLayerStyleForm.vue +123 -51
- package/lib/map/client/components/KLevelSlider.vue +30 -29
- package/lib/map/client/components/KLocationMap.vue +2 -2
- package/lib/map/client/components/KMeasureTool.vue +49 -28
- package/lib/map/client/components/KPositionIndicator.vue +4 -4
- package/lib/map/client/components/KTimeline.vue +30 -35
- package/lib/map/client/components/KTimezoneMap.vue +156 -0
- package/lib/map/client/components/KUrlLegend.vue +11 -10
- package/lib/map/client/components/catalog/KAddLayer.vue +3 -2
- package/lib/map/client/components/catalog/KBaseLayersSelector.vue +1 -1
- package/lib/map/client/components/catalog/KCatalogLayersPanel.vue +56 -0
- package/lib/map/client/components/catalog/KCreateView.vue +91 -0
- package/lib/map/client/components/catalog/KLayerCategories.vue +5 -3
- package/lib/map/client/components/catalog/{KCatalog.vue → KLayersPanel.vue} +23 -22
- package/lib/map/client/components/catalog/KLayersSelector.vue +3 -3
- package/lib/map/client/components/catalog/KUserLayersPanel.vue +40 -0
- package/lib/map/client/components/catalog/KViewSelector.vue +46 -0
- package/lib/map/client/components/catalog/KViewsPanel.vue +110 -0
- package/lib/map/client/components/catalog/KWeatherLayersSelector.vue +5 -14
- package/lib/map/client/components/form/KTimezoneField.vue +135 -0
- package/lib/map/client/components/widget/KElevationProfile.vue +488 -0
- package/lib/map/client/components/widget/KInformationBox.vue +53 -37
- package/lib/map/client/components/widget/KMapillaryViewer.vue +26 -16
- package/lib/map/client/components/widget/KTimeSeries.vue +283 -358
- package/lib/map/client/i18n/map_en.json +73 -56
- package/lib/map/client/i18n/map_fr.json +75 -58
- package/lib/map/client/init.js +4 -3
- package/lib/map/client/init.js.map +1 -1
- package/lib/map/client/leaflet/GradientPath.js +40 -19
- package/lib/map/client/leaflet/GradientPath.js.map +1 -1
- package/lib/map/client/leaflet/TiledFeatureLayer.js +527 -93
- package/lib/map/client/leaflet/TiledFeatureLayer.js.map +1 -1
- package/lib/map/client/leaflet/TiledMeshLayer.js +58 -35
- package/lib/map/client/leaflet/TiledMeshLayer.js.map +1 -1
- package/lib/map/client/leaflet/utils.js +44 -3
- package/lib/map/client/leaflet/utils.js.map +1 -1
- package/lib/map/client/mixins/globe/mixin.base-globe.js +16 -1
- package/lib/map/client/mixins/globe/mixin.base-globe.js.map +1 -1
- package/lib/map/client/mixins/globe/mixin.file-layers.js +12 -2
- package/lib/map/client/mixins/globe/mixin.file-layers.js.map +1 -1
- package/lib/map/client/mixins/globe/mixin.geojson-layers.js +23 -27
- package/lib/map/client/mixins/globe/mixin.geojson-layers.js.map +1 -1
- package/lib/map/client/mixins/globe/mixin.popup.js +7 -3
- package/lib/map/client/mixins/globe/mixin.popup.js.map +1 -1
- package/lib/map/client/mixins/globe/mixin.style.js +8 -4
- package/lib/map/client/mixins/globe/mixin.style.js.map +1 -1
- package/lib/map/client/mixins/globe/mixin.tooltip.js +7 -3
- package/lib/map/client/mixins/globe/mixin.tooltip.js.map +1 -1
- package/lib/map/client/mixins/index.js +23 -18
- package/lib/map/client/mixins/index.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.base-map.js +32 -8
- package/lib/map/client/mixins/map/mixin.base-map.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.edit-layers.js +8 -4
- package/lib/map/client/mixins/map/mixin.edit-layers.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.file-layers.js +13 -5
- package/lib/map/client/mixins/map/mixin.file-layers.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.geojson-layers.js +65 -14
- package/lib/map/client/mixins/map/mixin.geojson-layers.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.heatmap-layers.js +6 -1
- package/lib/map/client/mixins/map/mixin.heatmap-layers.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.popup.js +4 -2
- package/lib/map/client/mixins/map/mixin.popup.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.style.js +9 -5
- package/lib/map/client/mixins/map/mixin.style.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.tiled-mesh-layers.js +4 -11
- package/lib/map/client/mixins/map/mixin.tiled-mesh-layers.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.tiled-wind-layers.js +0 -11
- package/lib/map/client/mixins/map/mixin.tiled-wind-layers.js.map +1 -1
- package/lib/map/client/mixins/map/mixin.tooltip.js +4 -2
- package/lib/map/client/mixins/map/mixin.tooltip.js.map +1 -1
- package/lib/map/client/mixins/mixin.activity.js +150 -150
- package/lib/map/client/mixins/mixin.activity.js.map +1 -1
- package/lib/map/client/mixins/mixin.catalog-panel.js +36 -0
- package/lib/map/client/mixins/mixin.catalog-panel.js.map +1 -0
- package/lib/map/client/mixins/mixin.feature-selection.js +17 -8
- package/lib/map/client/mixins/mixin.feature-selection.js.map +1 -1
- package/lib/map/client/mixins/mixin.feature-service.js +36 -16
- package/lib/map/client/mixins/mixin.feature-service.js.map +1 -1
- package/lib/map/client/mixins/mixin.infobox.js +1 -1
- package/lib/map/client/mixins/mixin.infobox.js.map +1 -1
- package/lib/map/client/mixins/mixin.levels.js +26 -12
- package/lib/map/client/mixins/mixin.levels.js.map +1 -1
- package/lib/map/client/mixins/mixin.style.js +1 -0
- package/lib/map/client/mixins/mixin.style.js.map +1 -1
- package/lib/map/client/mixins/mixin.weacast.js +22 -28
- package/lib/map/client/mixins/mixin.weacast.js.map +1 -1
- package/lib/map/client/pixi-utils.js +8 -177
- package/lib/map/client/pixi-utils.js.map +1 -1
- package/lib/map/client/readers/index.js +12 -0
- package/lib/map/client/readers/index.js.map +1 -1
- package/lib/map/client/readers/reader.geojson.js +62 -34
- package/lib/map/client/readers/reader.geojson.js.map +1 -1
- package/lib/map/client/readers/reader.gpx.js +32 -21
- package/lib/map/client/readers/reader.gpx.js.map +1 -1
- package/lib/map/client/readers/reader.kml.js +32 -21
- package/lib/map/client/readers/reader.kml.js.map +1 -1
- package/lib/map/client/readers/reader.shp.js +116 -0
- package/lib/map/client/readers/reader.shp.js.map +1 -0
- package/lib/map/client/utils.js +1 -8
- package/lib/map/client/utils.js.map +1 -1
- package/lib/map/common/grid.js +131 -0
- package/lib/map/common/grid.js.map +1 -1
- package/lib/map/common/index.js +22 -11
- package/lib/map/common/index.js.map +1 -1
- package/lib/map/common/meteo-model-grid-source.js +5 -2
- package/lib/map/common/meteo-model-grid-source.js.map +1 -1
- package/lib/map/common/time-based-grid-source.js +5 -2
- package/lib/map/common/time-based-grid-source.js.map +1 -1
- package/lib/test/client/core/account.js +1 -1
- package/lib/test/client/core/account.js.map +1 -1
- package/lib/test/client/core/collection.js +31 -13
- package/lib/test/client/core/collection.js.map +1 -1
- package/lib/test/client/core/layout.js +137 -49
- package/lib/test/client/core/layout.js.map +1 -1
- package/lib/test/client/core/screens.js +1 -1
- package/lib/test/client/core/screens.js.map +1 -1
- package/lib/test/client/core/utils.js +89 -22
- package/lib/test/client/core/utils.js.map +1 -1
- package/lib/test/client/map/catalog.js +134 -41
- package/lib/test/client/map/catalog.js.map +1 -1
- package/lib/test/client/map/controls.js +7 -4
- package/lib/test/client/map/controls.js.map +1 -1
- package/lib/test/client/map/index.js +12 -0
- package/lib/test/client/map/index.js.map +1 -1
- package/lib/test/client/map/utils.js +67 -0
- package/lib/test/client/map/utils.js.map +1 -0
- package/package.json +5 -6
- package/.nyc_output/2226bcce-9d22-4dad-b9fa-46564b5565c7.json +0 -1
- package/.nyc_output/6dc4b140-1a8a-4d69-b91c-89c557883d6e.json +0 -1
- package/.nyc_output/processinfo/058fc679-d60a-4501-ac04-71171e5200b8.json +0 -1
- package/.nyc_output/processinfo/2226bcce-9d22-4dad-b9fa-46564b5565c7.json +0 -1
- package/.nyc_output/processinfo/6dc4b140-1a8a-4d69-b91c-89c557883d6e.json +0 -1
- package/.nyc_output/processinfo/8b1830fa-932e-4a61-9837-4a5b18f83ea9.json +0 -1
- package/.nyc_output/processinfo/afd2d144-3570-4858-b94a-b523dbd023dd.json +0 -1
- package/extras/tours/map/favorite-views.js +0 -53
- package/lib/core/client/components/frame/KChart.vue +0 -60
- package/lib/core/client/components/input/KCodeInput.vue +0 -50
- package/lib/core/client/components/input/KTimeRangeChooser.vue +0 -109
- package/lib/core/client/components/time/KTimeRange.vue +0 -144
- package/lib/map/client/components/KFavoriteViews.vue +0 -217
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../map/client/leaflet/TiledFeatureLayer.js"],"names":["TiledFeatureLayer","L","GridLayer","extend","initialize","options","prototype","call","on","event","onTileUnload","featureRefCount","Map","getFeatureKey","feature","id","_","get","layer","featureSource","setup","activity","onAdd","map","clear","onRemove","createTile","coords","tile","document","createElement","tileSize","getTileSize","bounds","_tileCoordsToBounds","baseQuery","south","getSouth","north","getNorth","west","getWest","east","getEast","style","outline","innerHTML","y","x","toFixed","promises","probeService","push","getProbeFeatures","merge","Promise","all","then","data","tileUnloaded","probes","features","length","updateLayer","name","filter","key","find","probe","index","refCount","undefined","set","catch","error","remove","delete","collection","redraw","_map","_removeAllTiles"],"mappings":";;;;;;;AAAA;;;;AACA;;;;AACA;;AACA;;;;AAEA,MAAMA,oBAAoBC,kBAAEC,SAAF,CAAYC,MAAZ,CAAmB;AAC3CC,aAAYC,OAAZ,EAAqB;AACnBJ,sBAAEC,SA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AAK3D,eAAL,CAAqBM,GAArB,CAAyBiD,GAAzB,CAAf;AACAI,iBAAWA,WAAW,CAAtB;AACA,UAAIA,aAAa,CAAjB,EAAoB;AAClB,aAAK3D,eAAL,CAAqBiE,MAArB,CAA4BV,GAA5B;AACAS,eAAOvB,IAAP,CAAYtC,OAAZ;AACD,OAHD,MAGO;AACL,aAAKH,eAAL,CAAqB6D,GAArB,CAAyBN,GAAzB,EAA8BI,QAA9B;AACD;AACF,KAVD;;AAYA,QAAIK,OAAOb,MAAX,EAAmB;AACjB,YAAMe,aAAa,gCAAkBF,MAAlB,CAAnB;AACA,WAAKtD,QAAL,CAAc0C,WAAd,CAA0B,KAAK7C,KAAL,CAAW8C,IAArC,EAA2Ca,UAA3C,EAAuD,IAAvD;AACD;AACF,GA1I0C;;AA4I3CC,WAAU;AACR;AACA,QAAI,KAAKC,IAAT,EAAe,KAAKC,eAAL;AACf;AACA,SAAKrE,eAAL,CAAqBa,KAArB;AACA;AACAvB,sBAAEC,SAAF,CAAYI,SAAZ,CAAsBwE,MAAtB,CAA6BvE,IAA7B,CAAkC,IAAlC;AACD;AAnJ0C,CAAnB,CAA1B;;QAsJSP,iB,GAAAA,iB","file":"TiledFeatureLayer.js","sourcesContent":["import L from 'leaflet'\r\nimport _ from 'lodash'\r\nimport { featureEach } from '@turf/meta'\r\nimport { featureCollection } from '@turf/helpers'\r\n\r\nconst TiledFeatureLayer = L.GridLayer.extend({\r\n initialize (options) {\r\n L.GridLayer.prototype.initialize.call(this, options)\r\n\r\n this.on('tileunload', (event) => { this.onTileUnload(event) })\r\n\r\n this.featureRefCount = new Map()\r\n this.getFeatureKey = (feature) => {\r\n const id = _.get(this.layer, 'featureId', '_id')\r\n return _.get(feature, 'properties.' + id, _.get(feature, id))\r\n }\r\n\r\n this.featureSource = options.featureSource\r\n },\r\n\r\n setup (activity, layer) {\r\n this.activity = activity\r\n this.layer = layer\r\n },\r\n\r\n onAdd (map) {\r\n this.featureRefCount.clear()\r\n L.GridLayer.prototype.onAdd.call(this, map)\r\n },\r\n\r\n onRemove (map) {\r\n this.featureRefCount.clear()\r\n L.GridLayer.prototype.onRemove.call(this, map)\r\n },\r\n\r\n createTile (coords) {\r\n const tile = document.createElement('div')\r\n const tileSize = this.getTileSize()\r\n const bounds = this._tileCoordsToBounds(coords)\r\n const baseQuery = {\r\n south: bounds.getSouth(),\r\n north: bounds.getNorth(),\r\n west: bounds.getWest(),\r\n east: bounds.getEast()\r\n }\r\n if (_.get(this.options, 'debug.showTileInfos')) {\r\n tile.style.outline = '1px solid green'\r\n tile.innerHTML = `leaflet tile is ${tileSize.y} x ${tileSize.x} pixels</br>\r\n covering ${bounds.getSouth().toFixed(2)}, ${bounds.getNorth().toFixed(2)},\r\n ${bounds.getWest().toFixed(2)}, ${bounds.getEast().toFixed(2)}</br>`\r\n }\r\n // Using async/await seems to cause problems in Leaflet, we use promises instead\r\n const promises = []\r\n // Request probes first if any\r\n if (this.layer.probeService) {\r\n promises.push(this.activity.getProbeFeatures(_.merge({ baseQuery }, this.layer)))\r\n }\r\n promises.push(this.featureSource(baseQuery))\r\n Promise.all(promises).then(data => {\r\n if (tile.tileUnloaded) {\r\n // tile was unloaded before fetch completed\r\n if (_.get(this.options, 'debug.showTileInfos')) {\r\n tile.innerHTML += 'Data discarded as tile has been unloaded'\r\n }\r\n return\r\n }\r\n\r\n if (this.layer.probeService) {\r\n tile.probes = (data[0].features.length ? data[0] : null)\r\n // Can't have measures without probes\r\n if (!tile.probes) tile.features = null\r\n else tile.features = (data[1].features.length ? data[1] : null)\r\n } else {\r\n tile.features = (data[0].features.length ? data[0] : null)\r\n }\r\n\r\n if (tile.probes || tile.features) {\r\n if (tile.probes) {\r\n this.activity.updateLayer(this.layer.name, tile.probes)\r\n }\r\n if (tile.features) {\r\n // If probe are given we should have a perfect match with measures\r\n // Filter any measure without a corresponding probe\r\n if (tile.probes) {\r\n tile.features.features = tile.features.features.filter(feature => {\r\n const key = this.getFeatureKey(feature)\r\n return _.find(tile.probes.features, probe => key === this.getFeatureKey(probe))\r\n })\r\n }\r\n this.activity.updateLayer(this.layer.name, tile.features)\r\n }\r\n // ref each feature\r\n // TODO: we could only add features with refcount = 1\r\n // but in case of probes we need to find corresponding features\r\n featureEach(tile.probes || tile.features, (feature, index) => {\r\n const key = this.getFeatureKey(feature)\r\n let refCount = this.featureRefCount.get(key)\r\n refCount = refCount === undefined ? 1 : refCount + 1\r\n this.featureRefCount.set(key, refCount)\r\n })\r\n\r\n if (_.get(this.options, 'debug.showTileInfos')) {\r\n if (tile.probes) tile.innerHTML += `fetched ${tile.probes.features.length} probes</br>`\r\n if (tile.features) tile.innerHTML += `fetched ${tile.features.features.length} features`\r\n }\r\n } else {\r\n if (_.get(this.options, 'debug.showTileInfos')) {\r\n tile.innerHTML += 'No data fetched'\r\n }\r\n }\r\n }).catch(error => {\r\n throw error\r\n })\r\n\r\n return tile\r\n },\r\n\r\n onTileUnload (event) {\r\n // flag tile as unloaded (useful when tile hasn't loaded completely yet)\r\n event.tile.tileUnloaded = true\r\n\r\n const probes = event.tile.probes\r\n const features = event.tile.features\r\n if (!probes && !features) return\r\n\r\n const remove = []\r\n // unref each feature, those with refCount = 0 => we can remove\r\n featureEach(probes || features, (feature, index) => {\r\n const key = this.getFeatureKey(feature)\r\n let refCount = this.featureRefCount.get(key)\r\n refCount = refCount - 1\r\n if (refCount === 0) {\r\n this.featureRefCount.delete(key)\r\n remove.push(feature)\r\n } else {\r\n this.featureRefCount.set(key, refCount)\r\n }\r\n })\r\n\r\n if (remove.length) {\r\n const collection = featureCollection(remove)\r\n this.activity.updateLayer(this.layer.name, collection, true)\r\n }\r\n },\r\n\r\n redraw () {\r\n // remove tiles manually first\r\n if (this._map) this._removeAllTiles()\r\n // clear feature ref counts since there's no tile anymore\r\n this.featureRefCount.clear()\r\n // request grid layer redraw\r\n L.GridLayer.prototype.redraw.call(this)\r\n }\r\n})\r\n\r\nexport { TiledFeatureLayer }\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../map/client/leaflet/TiledFeatureLayer.js"],"names":["TiledFeatureLayer","L","GridLayer","extend","initialize","options","enableDebug","_","get","prototype","call","on","event","onTileUnload","userIsDragging","userIsZooming","pendingStationUpdates","getFeatureKey","feature","id","layer","featureSource","flyingTiles","Map","modifiedTiles","Set","allFeatures","setup","activity","onAdd","map","zoomStartLevel","zoomEndLevel","_map","getZoom","clear","onRemove","getEvents","events","onDragStart","dragstart","onDragEnd","dragend","onZoomStart","zoomstart","onZoomEnd","zoomend","probeService","minFeatureZoom","getMinZoom","maxFeatureZoom","getMaxZoom","collection","internalFeature","values","push","cloneDeep","geojson","updateLayer","name","length","known","has","createTile","coords","key","tile","undefined","div","document","createElement","bbox","_tileCoordsToBounds","featuresRequest","featuresChildren","features","measuresRequest","measuresChildren","unload","set","style","outline","innerHTML","add","mergeRequests","tiles","requests","sortedTiles","sort","a","b","x","y","z","vrequests","forEach","newRequest","r","maxy","miny","v","h","maxx","minx","concat","minp","point","maxp","bounds","query","south","getSouth","north","getNorth","west","getWest","east","getEast","numTilesR","logger","debug","_update","center","tilesToRemove","tilesWithFeaturesRequest","tilesWithMeasuresRequest","tileWithMeasures","parentTileCoords","parentTile","featureId","intersects","refCount","featureRequests","promise","getProbeFeatures","merge","baseQuery","then","data","allTiles","flat","addCollection","unknownFeature","turfBbox","corner1","latLng","corner2","latLngBounds","size","catch","err","delete","measureRequests","stationPromises","Promise","all","flaggedStations","properties","measureRequestIssued","updateStations","okMeasures","removeCollection","redraw","Array","from","feat"],"mappings":";;;;;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,oBAAoBC,kBAAEC,SAAF,CAAYC,MAAZ,CAAmB;AAC3CC,aAAYC,OAAZ,EAAqB;AACnB,SAAKC,WAAL,GAAmBC,iBAAEC,GAAF,CAAMH,OAAN,EAAe,aAAf,EAA8B,KAA9B,CAAnB;AACA;AACAJ,sBAAEC,SAAF,CAAYO,SAAZ,CAAs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AA3B,GAAoC,CAApC;;AAEA;AACA3D,sBAAEC,SAAF,CAAYO,SAAZ,CAAsByJ,MAAtB,CAA6BxJ,IAA7B,CAAkC,IAAlC;AACD;AAljB0C,CAAnB,CAA1B;;QAqjBSV,iB,GAAAA,iB","file":"TiledFeatureLayer.js","sourcesContent":["import L from 'leaflet'\r\nimport _ from 'lodash'\r\nimport logger from 'loglevel'\r\nimport bbox from '@turf/bbox'\r\nimport { featureEach } from '@turf/meta'\r\nimport { featureCollection } from '@turf/helpers'\r\nimport { tile2key, getParentTileInTileSet } from './utils'\r\n\r\nconst TiledFeatureLayer = L.GridLayer.extend({\r\n initialize (options) {\r\n this.enableDebug = _.get(options, 'enableDebug', false)\r\n // this.enableDebug = true\r\n L.GridLayer.prototype.initialize.call(this, options)\r\n\r\n this.on('tileunload', (event) => { this.onTileUnload(event) })\r\n\r\n this.userIsDragging = false\r\n this.userIsZooming = false\r\n this.pendingStationUpdates = []\r\n\r\n this.getFeatureKey = (feature) => {\r\n const id = _.get(this.layer, 'featureId', '_id')\r\n return _.get(feature, 'properties.' + id, _.get(feature, id))\r\n }\r\n\r\n this.featureSource = options.featureSource\r\n\r\n this.flyingTiles = new Map()\r\n this.modifiedTiles = new Set()\r\n this.allFeatures = new Map()\r\n },\r\n\r\n setup (activity, layer) {\r\n this.activity = activity\r\n this.layer = layer\r\n },\r\n\r\n onAdd (map) {\r\n this.userIsDragging = false\r\n this.userIsZooming = false\r\n this.pendingStationUpdates = []\r\n\r\n this.zoomStartLevel = this.zoomEndLevel = this._map.getZoom()\r\n\r\n this.flyingTiles.clear()\r\n this.modifiedTiles.clear()\r\n this.allFeatures.clear()\r\n\r\n L.GridLayer.prototype.onAdd.call(this, map)\r\n },\r\n\r\n onRemove (map) {\r\n this.flyingTiles.clear()\r\n this.modifiedTiles.clear()\r\n this.allFeatures.clear()\r\n\r\n L.GridLayer.prototype.onRemove.call(this, map)\r\n },\r\n\r\n getEvents () {\r\n const events = L.GridLayer.prototype.getEvents.call(this)\r\n\r\n // dragstart sets userIsDragging flag\r\n const onDragStart = events.dragstart\r\n events.dragstart = (event) => {\r\n this.userIsDragging = true\r\n if (onDragStart) onDragStart.call(this, event)\r\n }\r\n\r\n // dragstart clears userIsDragging flag\r\n const onDragEnd = events.dragend\r\n events.dragend = (event) => {\r\n this.userIsDragging = false\r\n if (onDragEnd) onDragEnd.call(this, event)\r\n }\r\n\r\n // zoomstart records zoomStartLevel\r\n const onZoomStart = events.zoomstart\r\n events.zoomstart = (event) => {\r\n if (onZoomStart) onZoomStart.call(this, event)\r\n this.zoomStartLevel = this._map.getZoom()\r\n this.userIsZooming = true\r\n }\r\n\r\n // zoomend records zoomEndLevel\r\n const onZoomEnd = events.zoomend\r\n events.zoomend = (event) => {\r\n if (onZoomEnd) onZoomEnd.call(this, event)\r\n this.zoomEndLevel = this._map.getZoom()\r\n this.userIsZooming = false\r\n\r\n // Handle stations with measures, we may reset the stations to their\r\n // 'station state' when crossing the minFeatureZoom/maxFeatureZoom values\r\n // We also delay stations updates to prevent them from happening during a zoom animation\r\n if (this.layer.probeService) {\r\n const minFeatureZoom = _.get(this.options, 'minFeatureZoom', this._map.getMinZoom())\r\n const maxFeatureZoom = _.get(this.options, 'maxFeatureZoom', this._map.getMaxZoom())\r\n if ((this.zoomStartLevel >= minFeatureZoom && this.zoomEndLevel < minFeatureZoom) ||\r\n (this.zoomStartLevel <= maxFeatureZoom && this.zoomEndLevel > maxFeatureZoom)) {\r\n // We crossed minFeatureZoom/maxFeatureZoom => reset to station state\r\n let collection = []\r\n for (const internalFeature of this.allFeatures.values()) {\r\n collection.push(_.cloneDeep(internalFeature.geojson))\r\n }\r\n collection = featureCollection(collection)\r\n this.activity.updateLayer(this.layer.name, collection, true)\r\n this.activity.updateLayer(this.layer.name, collection)\r\n } else if (this.pendingStationUpdates.length) {\r\n // Otherwise apply pending station updates\r\n for (const collection of this.pendingStationUpdates) {\r\n // But before, make sure we still know the stations\r\n const known = []\r\n featureEach(collection, (feature) => {\r\n if (this.allFeatures.has(this.getFeatureKey(feature)))\r\n known.push(feature)\r\n })\r\n this.activity.updateLayer(this.layer.name, featureCollection(known))\r\n }\r\n }\r\n this.pendingStationUpdates.length = 0\r\n }\r\n }\r\n\r\n return events\r\n },\r\n\r\n createTile (coords) {\r\n const key = tile2key(coords)\r\n let tile = this.flyingTiles.get(key)\r\n if (tile === undefined) {\r\n tile = {\r\n div: document.createElement('div'),\r\n coords: coords,\r\n bbox: this._tileCoordsToBounds(coords),\r\n featuresRequest: null,\r\n featuresChildren: [],\r\n features: [],\r\n measuresRequest: null,\r\n measuresChildren: [],\r\n unload: false\r\n }\r\n\r\n this.flyingTiles.set(key, tile)\r\n\r\n if (this.enableDebug) {\r\n tile.div.style.outline = '1px solid orange'\r\n tile.div.innerHTML = ''\r\n }\r\n } else {\r\n tile.unload = false\r\n if (this.enableDebug) tile.div.innerHTML += '</br>createTile: found in flying tiles'\r\n }\r\n\r\n this.modifiedTiles.add(key)\r\n\r\n return tile.div\r\n },\r\n\r\n onTileUnload (event) {\r\n const key = tile2key(event.coords)\r\n const tile = this.flyingTiles.get(key)\r\n if (tile) tile.unload = true\r\n this.modifiedTiles.add(key)\r\n\r\n if (this.enableDebug && tile) tile.div.innerHTML += '</br>unload scheduled'\r\n },\r\n\r\n mergeRequests (tiles) {\r\n const requests = []\r\n\r\n // Try to merge tiles vertically, then horizontally\r\n const sortedTiles = tiles.sort((a, b) => {\r\n if (a.coords.x === b.coords.x) {\r\n return a.coords.y < b.coords.y ? -1 : a.coords.y !== b.coords.y ? 1 : 0\r\n }\r\n return a.coords.x < b.coords.x ? -1 : 1\r\n })\r\n\r\n if (sortedTiles.length) {\r\n const z = sortedTiles[0].coords.z\r\n const vrequests = []\r\n sortedTiles.forEach((tile) => {\r\n let newRequest = true\r\n if (vrequests.length) {\r\n const r = vrequests[vrequests.length - 1]\r\n if (tile.coords.x === r.x) {\r\n if (tile.coords.y === r.maxy + 1) {\r\n r.tiles.push(tile)\r\n r.maxy = tile.coords.y\r\n newRequest = false\r\n }\r\n }\r\n }\r\n if (newRequest) {\r\n vrequests.push({\r\n x: tile.coords.x,\r\n miny: tile.coords.y,\r\n maxy: tile.coords.y,\r\n tiles: [tile]\r\n })\r\n }\r\n })\r\n\r\n // Now try to merge horizontally adjacent vertical requests\r\n vrequests.forEach((v) => {\r\n let newRequest = true\r\n if (requests.length) {\r\n const h = requests[requests.length - 1]\r\n if (v.miny === h.miny && v.maxy === h.maxy && v.x === h.maxx + 1) {\r\n h.tiles.push(...v.tiles)\r\n h.maxx = v.x\r\n newRequest = false\r\n }\r\n }\r\n if (newRequest) {\r\n requests.push({\r\n minx: v.x,\r\n maxx: v.x,\r\n miny: v.miny,\r\n maxy: v.maxy,\r\n tiles: [].concat(v.tiles)\r\n })\r\n }\r\n })\r\n\r\n // Compute final query\r\n requests.forEach((r) => {\r\n const minp = L.point(r.minx, r.miny); const maxp = L.point(r.maxx, r.maxy)\r\n minp.z = maxp.z = z\r\n const bounds = this._tileCoordsToBounds(minp)\r\n bounds.extend(this._tileCoordsToBounds(maxp))\r\n r.query = {\r\n south: bounds.getSouth(),\r\n north: bounds.getNorth(),\r\n west: bounds.getWest(),\r\n east: bounds.getEast()\r\n }\r\n })\r\n\r\n if (this.enableDebug) {\r\n let numTilesR = 0\r\n requests.forEach((r) => { numTilesR += r.tiles.length })\r\n if (numTilesR !== tiles.length) {\r\n logger.debug('TiledFeatureLayer: less requested tiles than expected !')\r\n }\r\n }\r\n }\r\n\r\n /* One request per tile\r\n tiles.forEach((tile) => {\r\n const r = {\r\n tiles: [tile],\r\n query: {\r\n south: tile.bbox.getSouth(),\r\n north: tile.bbox.getNorth(),\r\n west: tile.bbox.getWest(),\r\n east: tile.bbox.getEast()\r\n }\r\n }\r\n requests.push(r)\r\n })\r\n */\r\n\r\n if (this.enableDebug && tiles.length) {\r\n logger.debug(`TiledFeatureLayer: ${tiles.length} requests reduced to ${requests.length}`)\r\n }\r\n\r\n return requests\r\n },\r\n\r\n _update (center) {\r\n L.GridLayer.prototype._update.call(this)\r\n\r\n // No update while dragging\r\n if (this.userIsDragging) return\r\n\r\n const tilesToRemove = []\r\n const tilesWithFeaturesRequest = []\r\n const tilesWithMeasuresRequest = []\r\n\r\n const minFeatureZoom = _.get(this.options, 'minFeatureZoom', this._map.getMinZoom())\r\n const maxFeatureZoom = _.get(this.options, 'maxFeatureZoom', this._map.getMaxZoom())\r\n\r\n // Loop through tiles to consider\r\n // - either tile is flagged for unload => work on its feature once the pending request is over\r\n // - either tile is flagged for load\r\n // in this case, we check if there's a parent tile from which we can read data\r\n // if not, we'll have to issue a request to the featureSource\r\n this.modifiedTiles.forEach((key) => {\r\n const tile = this.flyingTiles.get(key)\r\n\r\n // This can happen when a tile has been removed from flyingTiles\r\n // because the associated request failed\r\n if (tile === undefined) return\r\n\r\n if (tile.unload) {\r\n // Wait for request to end before removing associated tile data since\r\n // a child tile may wait on that request\r\n if (tile.featuresRequest === null && tile.measuresRequest === null) tilesToRemove.push(tile)\r\n } else {\r\n // Is this a tile with measures ?\r\n const tileWithMeasures = this.layer.probeService && (tile.coords.z >= minFeatureZoom) && (tile.coords.z <= maxFeatureZoom)\r\n\r\n if (this.enableDebug) {\r\n tile.div.innerHTML += '</br>features'\r\n if (tileWithMeasures) tile.div.innerHTML += ' + measures'\r\n }\r\n\r\n const parentTileCoords = getParentTileInTileSet(this.flyingTiles, tile.coords)\r\n if (parentTileCoords === undefined) {\r\n // No known parent tile, we'll have to request data\r\n tilesWithFeaturesRequest.push(tile)\r\n if (tileWithMeasures) tilesWithMeasuresRequest.push(tile)\r\n if (this.enableDebug) tile.div.innerHTML += '</br>need request(s)'\r\n } else {\r\n const parentTile = this.flyingTiles.get(tile2key(parentTileCoords))\r\n\r\n if (parentTile.featuresRequest === null) {\r\n // Parent tile has already loaded the features, fetch from there\r\n parentTile.features.forEach((featureId) => {\r\n const feature = this.allFeatures.get(featureId)\r\n if (tile.bbox.intersects(feature.bbox)) {\r\n feature.refCount += 1\r\n tile.features.push(featureId)\r\n }\r\n })\r\n\r\n if (this.enableDebug) {\r\n tile.div.style.outline = '1px solid green'\r\n tile.div.innerHTML += `</br>found ${tile.features.length} features in parent tile`\r\n }\r\n } else {\r\n // Otherwise, link to pending parent tile request\r\n parentTile.featuresChildren.push(tile)\r\n tile.featuresRequest = parentTile.featuresRequest\r\n\r\n if (this.enableDebug) tile.div.innerHTML += '</br>pending parent features request'\r\n }\r\n\r\n // Special case for probes: the parent tile may be at the level where only probes are loaded\r\n // and it's still missing the measures, schedule measure load now\r\n if (tileWithMeasures) {\r\n if (parentTile.measuresRequest !== null) {\r\n parentTile.measuresChildren.push(tile)\r\n tile.measuresRequest = parentTile.measuresRequest\r\n\r\n if (this.enableDebug) tile.div.innerHTML += '</br>pending parent measures request'\r\n } else if (parentTileCoords.z < minFeatureZoom) {\r\n tilesWithMeasuresRequest.push(tile)\r\n\r\n if (this.enableDebug) tile.div.innerHTML += '</br>need measures request'\r\n }\r\n }\r\n }\r\n }\r\n })\r\n\r\n this.modifiedTiles.clear()\r\n\r\n // We have to issue request(s) for tiles with no features. Requests can span over\r\n // multiple tiles due to merge step\r\n // Once requests are done, dispatch loaded features amongst associated tiles. A top level tile\r\n // may have children tiles too, these will get updated also.\r\n const featureRequests = this.mergeRequests(tilesWithFeaturesRequest)\r\n featureRequests.forEach((r) => {\r\n const promise = this.layer.probeService\r\n ? this.activity.getProbeFeatures(_.merge({ baseQuery: r.query }, this.layer))\r\n : this.featureSource(r.query)\r\n r.tiles.forEach((tile) => {\r\n tile.featuresRequest = promise\r\n\r\n if (this.enableDebug) tile.div.innerHTML += '</br>features request issued'\r\n })\r\n\r\n promise.then((data) => {\r\n // Gather all associated tiles, taking children tiles into account\r\n const allTiles = [r.tiles]\r\n r.tiles.forEach((tile) => { if (tile.featuresChildren.length) allTiles.push(tile.featuresChildren) })\r\n const tiles = allTiles.flat()\r\n\r\n const addCollection = []\r\n data.features.forEach((feature) => {\r\n const featureId = this.getFeatureKey(feature)\r\n let internalFeature = this.allFeatures.get(featureId)\r\n const unknownFeature = internalFeature === undefined\r\n if (unknownFeature) {\r\n // Feature we don't know, gather infos about it\r\n const turfBbox = bbox(feature)\r\n const corner1 = L.latLng(turfBbox[1], turfBbox[0])\r\n const corner2 = L.latLng(turfBbox[3], turfBbox[2])\r\n internalFeature = { geojson: feature, refCount: 0, bbox: L.latLngBounds(corner1, corner2) }\r\n }\r\n // Dispatch feature amongst associated tiles\r\n tiles.forEach((tile) => {\r\n if (tile.bbox.intersects(internalFeature.bbox)) {\r\n internalFeature.refCount += 1\r\n tile.features.push(featureId)\r\n }\r\n })\r\n // Tiles may be outside request bbox when bbox is big because of\r\n // underlying service projection (refCount would stay 0)\r\n if (internalFeature.refCount > 0) {\r\n if (unknownFeature) {\r\n addCollection.push(_.cloneDeep(feature))\r\n this.allFeatures.set(featureId, internalFeature)\r\n }\r\n }\r\n })\r\n if (addCollection.length) {\r\n const collection = featureCollection(addCollection)\r\n this.activity.updateLayer(this.layer.name, collection)\r\n }\r\n\r\n // Notify tiles their request is done\r\n tiles.forEach((tile) => {\r\n tile.featuresRequest = null\r\n tile.featuresChildren = []\r\n // When a tile was scheduled for removal, add it to the list of tiles to consider\r\n if (tile.unload) this.modifiedTiles.add(tile2key(tile.coords))\r\n\r\n if (this.enableDebug) {\r\n tile.div.style.outline = '1px solid green'\r\n tile.div.innerHTML += `</br>features request success: ${data.features.length} total, ${tile.features.length} for tile`\r\n }\r\n })\r\n\r\n if (this.enableDebug) logger.debug(`TiledFeatureLayer: allFeatures is ${this.allFeatures.size} long`)\r\n }).catch((err) => {\r\n // Gather all associated tiles, taking children tiles into account\r\n const allTiles = [r.tiles]\r\n r.tiles.forEach((tile) => { if (tile.featuresChildren.length) allTiles.push(tile.featuresChildren) })\r\n const tiles = allTiles.flat()\r\n\r\n // Failed tiles are removed from flyingTiles\r\n tiles.forEach((tile) => {\r\n this.flyingTiles.delete(tile2key(tile.coords))\r\n\r\n if (this.enableDebug) {\r\n tile.div.style.outline = '1px solid red'\r\n tile.div.innerHTML += `</br>features request failed: ${err}`\r\n }\r\n })\r\n\r\n if (this.enableDebug) logger.debug(`TiledFeatureLayer: allFeatures is ${this.allFeatures.size} long`)\r\n })\r\n })\r\n\r\n // Handle tiles where we need to fetch measures\r\n const measureRequests = this.mergeRequests(tilesWithMeasuresRequest)\r\n measureRequests.forEach((r) => {\r\n const promise = this.featureSource(r.query)\r\n const stationPromises = []\r\n r.tiles.forEach((tile) => {\r\n tile.measuresRequest = promise\r\n if (tile.featuresRequest) stationPromises.push(tile.featuresRequest)\r\n\r\n if (this.enableDebug) tile.div.innerHTML += '</br>measures request issued'\r\n })\r\n\r\n // When stations are fetched, we flag them with a 'measureRequestIssued' property that we\r\n // may use in dynamic styling\r\n Promise.all(stationPromises).then(() => {\r\n const flaggedStations = []\r\n r.tiles.forEach((tile) => {\r\n tile.features.forEach((id) => {\r\n const internalFeature = this.allFeatures.get(id)\r\n if (internalFeature) {\r\n const feature = _.cloneDeep(internalFeature.geojson)\r\n feature.properties.measureRequestIssued = true\r\n flaggedStations.push(feature)\r\n }\r\n })\r\n })\r\n if (flaggedStations.length) this.updateStations(featureCollection(flaggedStations))\r\n })\r\n\r\n promise.then((data) => {\r\n // Gather all associated tiles, taking children tiles into account\r\n const allTiles = [r.tiles]\r\n r.tiles.forEach((tile) => { if (tile.measuresChildren.length) allTiles.push(tile.measuresChildren) })\r\n const tiles = allTiles.flat()\r\n\r\n const stationPromises = []\r\n tiles.forEach((tile) => {\r\n tile.measuresRequest = null\r\n tile.measuresChildren = []\r\n // We want to push measures _after_ we pushed the stations\r\n if (tile.featuresRequest) stationPromises.push(tile.featuresRequest)\r\n\r\n if (this.enableDebug) tile.div.innerHTML += `</br>measures request success: ${data.features.length} total`\r\n })\r\n\r\n Promise.all(stationPromises).then(() => {\r\n // Make sure we know the stations those measures refer to\r\n const okMeasures = []\r\n featureEach(data, (feature) => {\r\n const id = this.getFeatureKey(feature)\r\n if (this.allFeatures.has(id)) okMeasures.push(feature)\r\n })\r\n if (okMeasures.length) this.updateStations(featureCollection(okMeasures))\r\n })\r\n }).catch((err) => {\r\n const allTiles = [r.tiles]\r\n r.tiles.forEach((tile) => { if (tile.measuresChildren.length) allTiles.push(tile.measuresChildren) })\r\n const tiles = allTiles.flat()\r\n\r\n tiles.forEach((tile) => {\r\n if (this.enableDebug) {\r\n tile.div.style.outline = '1px solid red'\r\n tile.div.innerHTML += `</br>measures request failed: ${err}`\r\n }\r\n })\r\n })\r\n })\r\n\r\n // Now handle tiles to remove\r\n const removeCollection = []\r\n tilesToRemove.forEach((tile) => {\r\n tile.features.forEach((featureId) => {\r\n const feature = this.allFeatures.get(featureId)\r\n if (feature.refCount === 1) {\r\n removeCollection.push(feature.geojson)\r\n this.allFeatures.delete(featureId)\r\n } else {\r\n feature.refCount -= 1\r\n }\r\n })\r\n this.flyingTiles.delete(tile2key(tile.coords))\r\n })\r\n if (removeCollection.length) this.activity.updateLayer(this.layer.name, featureCollection(removeCollection), true)\r\n\r\n if (this.enableDebug) {\r\n logger.debug(`TiledFeatureLayer: flyingTiles is ${this.flyingTiles.size} long`)\r\n logger.debug(`TiledFeatureLayer: allFeatures is ${this.allFeatures.size} long`)\r\n\r\n if (this.flyingTiles.size === 0 && this.allFeatures.size !== 0) {\r\n logger.debug(`TileFeatureLayer: no more flyingTiles but ${this.allFeatures.size} remaining features !`)\r\n this.allFeatures.forEach((feature) => {\r\n logger.debug(`TileFeatureLayer: ${this.getFeatureKey(feature.geojson)}: refCount ${feature.refCount}`)\r\n })\r\n }\r\n }\r\n },\r\n\r\n updateStations (geojson) {\r\n // When user is zooming, wait for the end of the zoom animation to update\r\n // stations. If we don't do that the features seem to 'slide' during the zoom\r\n // animation between their screen space position at the different zoom levels\r\n if (this.userIsZooming) {\r\n this.pendingStationUpdates.push(geojson)\r\n } else {\r\n const minFeatureZoom = _.get(this.options, 'minFeatureZoom', this._map.getMinZoom())\r\n const maxFeatureZoom = _.get(this.options, 'maxFeatureZoom', this._map.getMaxZoom())\r\n if (this.zoomEndLevel >= minFeatureZoom && this.zoomEndLevel <= maxFeatureZoom) { this.activity.updateLayer(this.layer.name, geojson) }\r\n }\r\n },\r\n\r\n redraw () {\r\n // clear underlying geojson layer\r\n const allFeatures = Array.from(this.allFeatures.values(), (feat) => feat.geojson)\r\n this.activity.updateLayer(this.layer.name, featureCollection(allFeatures), true)\r\n\r\n this.flyingTiles.clear()\r\n this.modifiedTiles.clear()\r\n this.allFeatures.clear()\r\n\r\n this.pendingStationUpdates.length = 0\r\n\r\n // request grid layer redraw\r\n L.GridLayer.prototype.redraw.call(this)\r\n }\r\n})\r\n\r\nexport { TiledFeatureLayer }\r\n"]}
|
|
@@ -41,7 +41,9 @@ const TiledMeshLayer = _leaflet2.default.GridLayer.extend({
|
|
|
41
41
|
this.conf.render = {
|
|
42
42
|
cutOver: options.cutOver,
|
|
43
43
|
cutUnder: options.cutUnder,
|
|
44
|
-
pixelColorMapping: options.pixelColorMapping
|
|
44
|
+
pixelColorMapping: options.pixelColorMapping,
|
|
45
|
+
showWireframe: options.showWireframe,
|
|
46
|
+
enableCulling: _lodash2.default.get(options, 'enableCulling', true)
|
|
45
47
|
// keep debug options
|
|
46
48
|
};this.conf.debug = {
|
|
47
49
|
showTileInfos: options.showTileInfos,
|
|
@@ -60,13 +62,13 @@ const TiledMeshLayer = _leaflet2.default.GridLayer.extend({
|
|
|
60
62
|
} });
|
|
61
63
|
this.layerUniforms = new PIXI.UniformGroup({ in_layerAlpha: options.opacity, in_zoomLevel: 1.0 });
|
|
62
64
|
this.pixiState = new PIXI.State();
|
|
63
|
-
this.pixiState.culling =
|
|
65
|
+
this.pixiState.culling = this.conf.render.enableCulling;
|
|
64
66
|
this.pixiState.blendMode = PIXI.BLEND_MODES.SCREEN;
|
|
65
67
|
|
|
66
68
|
// setup layer global uniforms (as opposed to tile specific uniforms)
|
|
67
69
|
this.cutValueUniform = null;
|
|
68
70
|
if (options.cutOver) {
|
|
69
|
-
this.layerUniforms.uniforms.
|
|
71
|
+
this.layerUniforms.uniforms.in_cutOver = 0.0;
|
|
70
72
|
if (options.cutOver === 'levels') {
|
|
71
73
|
this.cutValueUniform = 'in_cutOver';
|
|
72
74
|
} else {
|
|
@@ -74,7 +76,7 @@ const TiledMeshLayer = _leaflet2.default.GridLayer.extend({
|
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
if (options.cutUnder) {
|
|
77
|
-
this.layerUniforms.uniforms.
|
|
79
|
+
this.layerUniforms.uniforms.in_cutUnder = 0.0;
|
|
78
80
|
if (options.cutUnder === 'levels') {
|
|
79
81
|
this.cutValueUniform = 'in_cutUnder';
|
|
80
82
|
} else {
|
|
@@ -147,22 +149,15 @@ const TiledMeshLayer = _leaflet2.default.GridLayer.extend({
|
|
|
147
149
|
|
|
148
150
|
if (grid) {
|
|
149
151
|
if (grid.hasData()) {
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
const minlon = grid.getLon(iminlon);
|
|
155
|
-
const maxlat = grid.getLat(imaxlat);
|
|
156
|
-
const maxlon = grid.getLon(imaxlon);
|
|
157
|
-
|
|
158
|
-
// build mesh
|
|
159
|
-
const raw = new _pixiUtils.RawValueHook('in_layerValue');
|
|
160
|
-
const geometry = (0, _pixiUtils.buildPixiMeshFromGrid)(grid, [raw], iminlat, iminlon, imaxlat, imaxlon);
|
|
152
|
+
const { coords, minLat, minLon, deltaLat, deltaLon } = grid.genCoordsBuffer();
|
|
153
|
+
const values = grid.genValuesBuffer();
|
|
154
|
+
const indexes = grid.genMeshIndexBuffer();
|
|
155
|
+
const geometry = new PIXI.Geometry().addAttribute('in_layerCoord', coords, 2, false, PIXI.TYPES.HALF_FLOAT_VERTEX).addAttribute('in_layerValue', values, 1, false, PIXI.TYPES.FLOAT).addIndex(indexes);
|
|
161
156
|
|
|
162
157
|
// compute tile specific uniforms
|
|
163
158
|
const uniforms = {
|
|
164
159
|
in_layerBounds: Float32Array.from(reqBBox),
|
|
165
|
-
in_layerOffsetScale: Float32Array.of(
|
|
160
|
+
in_layerOffsetScale: Float32Array.of(minLat, minLon, deltaLat, deltaLon),
|
|
166
161
|
layerUniforms: this.layerUniforms
|
|
167
162
|
};
|
|
168
163
|
if (grid.nodata !== undefined) {
|
|
@@ -173,19 +168,22 @@ const TiledMeshLayer = _leaflet2.default.GridLayer.extend({
|
|
|
173
168
|
const mode = this.conf.debug.meshAsPoints ? PIXI.DRAW_MODES.POINTS : PIXI.DRAW_MODES.TRIANGLE_STRIP;
|
|
174
169
|
tile.mesh = new PIXI.Mesh(geometry, shader, this.pixiState, mode);
|
|
175
170
|
|
|
171
|
+
if (this.conf.render.showWireframe) {
|
|
172
|
+
const wireframeGeometry = new PIXI.Geometry().addAttribute('in_layerCoord', geometry.getBuffer('in_layerCoord'), 2, false, PIXI.TYPES.HALF_FLOAT_VERTEX).addIndex(grid.genWireframeIndexBuffer());
|
|
173
|
+
const wireframeShader = new PIXI.Shader(this.wireframeProgram, uniforms);
|
|
174
|
+
tile.wireframe = new PIXI.Mesh(wireframeGeometry, wireframeShader, this.pixiState, PIXI.DRAW_MODES.LINE_STRIP);
|
|
175
|
+
}
|
|
176
|
+
|
|
176
177
|
if (this.conf.debug.showTileInfos) {
|
|
177
|
-
const dims = grid.getDimensions();
|
|
178
|
-
const res = grid.getResolution();
|
|
179
178
|
tile.innerHTML = `leaflet tile is ${tileSize.y} x ${tileSize.x} pixels</br>
|
|
180
179
|
covering ${reqBBox[0].toPrecision(6)},${reqBBox[1].toPrecision(6)} to ${reqBBox[2].toPrecision(6)},${reqBBox[3].toPrecision(6)}</br>
|
|
181
180
|
req res: ${resolution[0].toPrecision(4)} ${resolution[1].toPrecision(4)}</br>
|
|
182
|
-
|
|
183
|
-
fetched grid is ${dims[0]} x ${dims[1]}, slimmed down to ${1 + imaxlat - iminlat} x ${1 + imaxlon - iminlon} points`;
|
|
181
|
+
mesh is made of ${values.length} points`;
|
|
184
182
|
tile.style.outline = '1px solid green';
|
|
185
183
|
}
|
|
186
184
|
} else if (this.conf.debug.showTileInfos) {
|
|
187
185
|
tile.style.outline = '1px solid red';
|
|
188
|
-
tile.innerHTML = 'no data here (grid
|
|
186
|
+
tile.innerHTML = 'no data here (grid maybe full of nodata)!';
|
|
189
187
|
}
|
|
190
188
|
} else if (this.conf.debug.showTileInfos) {
|
|
191
189
|
tile.style.outline = '1px solid red';
|
|
@@ -195,7 +193,6 @@ const TiledMeshLayer = _leaflet2.default.GridLayer.extend({
|
|
|
195
193
|
done(null, tile);
|
|
196
194
|
}).catch(err => {
|
|
197
195
|
done(err, tile);
|
|
198
|
-
throw err;
|
|
199
196
|
});
|
|
200
197
|
|
|
201
198
|
return tile;
|
|
@@ -209,6 +206,14 @@ const TiledMeshLayer = _leaflet2.default.GridLayer.extend({
|
|
|
209
206
|
mesh.zoomLevel = event.coords.z;
|
|
210
207
|
mesh.visible = mesh.zoomLevel === this._map.getZoom();
|
|
211
208
|
this.pixiRoot.addChild(mesh);
|
|
209
|
+
|
|
210
|
+
if (this.conf.render.showWireframe) {
|
|
211
|
+
const wireframe = event.tile.wireframe;
|
|
212
|
+
wireframe.zoomLevel = mesh.zoomLevel;
|
|
213
|
+
wireframe.visible = mesh.visible;
|
|
214
|
+
this.pixiRoot.addChild(wireframe);
|
|
215
|
+
}
|
|
216
|
+
|
|
212
217
|
if (mesh.visible) {
|
|
213
218
|
this.pixiLayer.redraw();
|
|
214
219
|
}
|
|
@@ -224,6 +229,13 @@ const TiledMeshLayer = _leaflet2.default.GridLayer.extend({
|
|
|
224
229
|
if (event.tile.mesh) {
|
|
225
230
|
// remove and destroy tile mesh
|
|
226
231
|
this.pixiRoot.removeChild(event.tile.mesh);
|
|
232
|
+
|
|
233
|
+
if (this.conf.render.showWireframe) {
|
|
234
|
+
this.pixiRoot.removeChild(event.tile.wireframe);
|
|
235
|
+
event.tile.wireframe.destroy();
|
|
236
|
+
event.tile.wireframe = null;
|
|
237
|
+
}
|
|
238
|
+
|
|
227
239
|
if (event.tile.mesh.visible) {
|
|
228
240
|
this.pixiLayer.redraw();
|
|
229
241
|
}
|
|
@@ -239,8 +251,8 @@ const TiledMeshLayer = _leaflet2.default.GridLayer.extend({
|
|
|
239
251
|
// and zoom level 'n+1' are being loaded on top of them
|
|
240
252
|
// when alpha blending is used, this is annoying
|
|
241
253
|
const zoomLevel = this._map.getZoom();
|
|
242
|
-
for (const
|
|
243
|
-
if (
|
|
254
|
+
for (const child of this.pixiRoot.children) {
|
|
255
|
+
if (child.zoomLevel === zoomLevel) child.visible = false;
|
|
244
256
|
}
|
|
245
257
|
},
|
|
246
258
|
|
|
@@ -251,8 +263,8 @@ const TiledMeshLayer = _leaflet2.default.GridLayer.extend({
|
|
|
251
263
|
// this is important when quickly zoomin in and out
|
|
252
264
|
// because some meshes may not have been evicted yet
|
|
253
265
|
const zoomLevel = this._map.getZoom();
|
|
254
|
-
for (const
|
|
255
|
-
if (
|
|
266
|
+
for (const child of this.pixiRoot.children) {
|
|
267
|
+
if (child.zoomLevel === zoomLevel) child.visible = true;
|
|
256
268
|
}
|
|
257
269
|
this.pixiLayer.redraw();
|
|
258
270
|
},
|
|
@@ -318,19 +330,20 @@ const TiledMeshLayer = _leaflet2.default.GridLayer.extend({
|
|
|
318
330
|
const features = [
|
|
319
331
|
// feature projecting layer position
|
|
320
332
|
{
|
|
321
|
-
name: '
|
|
322
|
-
varyings: ['vec2
|
|
333
|
+
name: 'layerCoord',
|
|
334
|
+
varyings: ['vec2 frg_layerCoord'],
|
|
323
335
|
vertex: {
|
|
324
|
-
attributes: ['vec2
|
|
336
|
+
attributes: ['vec2 in_layerCoord'],
|
|
325
337
|
uniforms: ['mat3 translationMatrix', 'mat3 projectionMatrix', 'float in_zoomLevel', 'vec4 in_layerOffsetScale'],
|
|
326
338
|
functions: [_pixiUtils.WEBGL_FUNCTIONS.latLonToWebMercator, _pixiUtils.WEBGL_FUNCTIONS.unpack2],
|
|
327
|
-
code: `
|
|
328
|
-
vec2 projected = latLonToWebMercator(vec3(
|
|
329
|
-
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(projected, 1.0)).xy, 0.0, 1.0)
|
|
339
|
+
code: ` frg_layerCoord = unpack2(in_layerCoord, in_layerOffsetScale);
|
|
340
|
+
vec2 projected = latLonToWebMercator(vec3(frg_layerCoord, in_zoomLevel));
|
|
341
|
+
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(projected, 1.0)).xy, 0.0, 1.0);
|
|
342
|
+
${this.conf.debug.meshAsPoints ? 'gl_PointSize = 10.0;' : ''}`
|
|
330
343
|
},
|
|
331
344
|
fragment: {
|
|
332
345
|
uniforms: ['vec4 in_layerBounds'],
|
|
333
|
-
code: ` bvec4 outside = bvec4(lessThan(
|
|
346
|
+
code: ` bvec4 outside = bvec4(lessThan(frg_layerCoord, in_layerBounds.xy), greaterThan(frg_layerCoord, in_layerBounds.zw));
|
|
334
347
|
if (any(outside)) discard;`
|
|
335
348
|
}
|
|
336
349
|
},
|
|
@@ -421,14 +434,24 @@ const TiledMeshLayer = _leaflet2.default.GridLayer.extend({
|
|
|
421
434
|
name: 'tail',
|
|
422
435
|
fragment: {
|
|
423
436
|
uniforms: ['float in_layerAlpha'],
|
|
424
|
-
code:
|
|
425
|
-
gl_FragColor.a = in_layerAlpha;`
|
|
437
|
+
code: ' outColor = vec4(color.rgb * in_layerAlpha, in_layerAlpha);'
|
|
426
438
|
}
|
|
427
439
|
});
|
|
428
440
|
|
|
429
441
|
const [vtxCode, frgCode] = (0, _pixiUtils.buildShaderCode)(features);
|
|
430
442
|
this.program = new PIXI.Program(vtxCode, frgCode);
|
|
431
443
|
|
|
444
|
+
if (this.conf.render.showWireframe) {
|
|
445
|
+
const [vtxWireframe, frgWireframe] = (0, _pixiUtils.buildShaderCode)([features[0], {
|
|
446
|
+
name: 'tail',
|
|
447
|
+
fragment: {
|
|
448
|
+
uniforms: ['float in_layerAlpha'],
|
|
449
|
+
code: ' outColor = vec4(0.0, 0.0, 0.0, in_layerAlpha);'
|
|
450
|
+
}
|
|
451
|
+
}]);
|
|
452
|
+
this.wireframeProgram = new PIXI.Program(vtxWireframe, frgWireframe);
|
|
453
|
+
}
|
|
454
|
+
|
|
432
455
|
if (this.conf.debug.showShader) {
|
|
433
456
|
console.log('Generated vertex shader:');
|
|
434
457
|
console.log(vtxCode);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../map/client/leaflet/TiledMeshLayer.js"],"names":["PIXI","TiledMeshLayer","L","GridLayer","extend","initialize","options","gridSource","conf","chromajs","render","cutOver","cutUnder","pixelColorMapping","debug","showTileInfos","meshAsPoints","showShader","resolutionScale","_","get","prototype","call","pixiRoot","Container","pixiLayer","pixiOverlay","utils","renderPixiLayer","destroyInteractionManager","shouldRedrawOnMove","layerUniforms","UniformGroup","in_layerAlpha","opacity","in_zoomLevel","pixiState","State","culling","blendMode","BLEND_MODES","SCREEN","cutValueUniform","uniforms","in_cutOver","in_cutUnder","on","event","onTileLoad","onTileUnload","onDataChangedCallback","onDataChanged","bind","onAdd","map","addLayer","_initialZoom","zoomStartCallback","onZoomStart","zoomEndCallback","onZoomEnd","onRemove","off","removeLayer","createTile","coords","done","tile","document","createElement","bounds","_tileCoordsToBounds","reqBBox","getSouth","getWest","getNorth","getEast","tileSize","getTileSize","resolution","y","x","fetchController","AbortController","fetch","signal","then","grid","hasData","iminlat","iminlon","imaxlat","imaxlon","getBestFit","minlat","getLat","minlon","getLon","maxlat","maxlon","raw","RawValueHook","geometry","in_layerBounds","Float32Array","from","in_layerOffsetScale","of","nodata","undefined","in_nodata","shader","Shader","program","mode","DRAW_MODES","POINTS","TRIANGLE_STRIP","mesh","Mesh","dims","getDimensions","res","getResolution","innerHTML","toPrecision","style","outline","catch","err","zoomLevel","z","visible","_map","getZoom","addChild","redraw","abort","removeChild","destroy","children","bbox","getBBox","c1","latLng","c2","latLngBounds","updateColorMap","updateShader","colorMap","fire","colorMapShaderCode","domain","classes","getDataBounds","invert","colors","scale","chroma","glcolors","c","gl","slice","reverse","console","error","features","name","varyings","vertex","attributes","functions","WEBGL_FUNCTIONS","latLonToWebMercator","unpack2","code","fragment","push","supportsNoData","vtxCode","frgCode","Program","log","renderer","getRenderer","setLevel","value","_resetView","setTime","time","setModel","model","getBounds","wrapLatLngBounds"],"mappings":";;;;;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;IAAYA,I;;AACZ;;AACA;;AAEA;;;;;;AAEA,MAAMC,iBAAiBC,kBAAEC,SAAF,CAAYC,MAAZ,CAAmB;AACxCC,aAAYC,OAAZ,EAAqBC,UAArB,EAAiC;AAC/B,SAAKC,IAAL,GAAY,EAAZ;;AAEA;AACA,SAAKA,IAAL,CAAUC,QAAV,GAAqBH,QAAQG,QAA7B;AACA;AACA,SAAKD,IAAL,CAAUE,MAAV,GAAmB;AACjBC,eAASL,QAAQK,OADA;AAEjBC,gBAAUN,QAAQM,QAFD;AAGjBC,yBAAmBP,QAAQO;AAE7B;AALmB,KAAnB,CAMA,KAAKL,IAAL,CAAUM,KAAV,GAAkB;AAChBC,qBAAeT,QAAQS,aADP;AAEhBC,oBAAcV,QAAQU,YAFN;AAGhBC,kBAAYX,QAAQW;AAHJ,KAAlB;AAKA,SAAKT,IAAL,CAAUU,eAAV,GAA4BC,iBAAEC,GAAF,CAAMd,OAAN,EAAe,iBAAf,EAAkC,CAAC,GAAD,EAAM,GAAN,CAAlC,CAA5B;;AAEA;AACAJ,sBAAEC,SAAF,CAAYkB,SAAZ,CAAsBhB,UAAtB,CAAiCiB,IAAjC,CAAsC,IAAtC,EAA4ChB,OAA5C;;AAEA;AACA,SAAKiB,QAAL,GAAgB,IAAIvB,KAAKwB,SAAT,EAAhB;AACA,SAAKC,SAAL,GAAiBvB,kBAAEwB,WAAF,CACfC,SAAS,KAAKC,eAAL,CAAqBD,KAArB,CADM,EAEf,KAAKJ,QAFU,EAGf,EAAEM,2BAA2B,IAA7B,EAAmCC,oBAAoB,YAAY;AAAE,eAAO,IAAP;AAAa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AAKpL,UAAL,CAAgBqL,OAAhB,CAAwBC,IAAxB;AACD;AACF,GA/auC;;AAibxCC,WAAUC,KAAV,EAAiB;AACf,QAAI,OAAO,KAAKxL,UAAL,CAAgBuL,QAAvB,KAAoC,UAAxC,EAAoD;AAClD,WAAKH,UAAL;AACA,WAAKpL,UAAL,CAAgBuL,QAAhB,CAAyBC,KAAzB;AACD;AACF,GAtbuC;;AAwbxCC,cAAa;AACX,UAAM1H,SAAS,KAAKhE,OAAL,CAAagE,MAAb,GAAsB,KAAKhE,OAAL,CAAagE,MAAnC,GAA4CpE,kBAAEgJ,YAAF,CAAehJ,kBAAE8I,MAAF,CAAS,CAAC,EAAV,EAAc,CAAC,GAAf,CAAf,EAAoC9I,kBAAE8I,MAAF,CAAS,EAAT,EAAa,GAAb,CAApC,CAA3D;AACA,WAAO,KAAKX,IAAL,GAAY,KAAKA,IAAL,CAAU4D,gBAAV,CAA2B3H,MAA3B,CAAZ,GAAiDA,MAAxD;AACD;AA3buC,CAAnB,CAAvB;;QA8bSrE,c,GAAAA,c","file":"TiledMeshLayer.js","sourcesContent":["import _ from 'lodash'\r\nimport L from 'leaflet'\r\nimport chroma from 'chroma-js'\r\nimport * as PIXI from 'pixi.js'\r\nimport 'leaflet-pixi-overlay'\r\nimport 'abort-controller/polyfill'\r\n\r\nimport { RawValueHook, buildPixiMeshFromGrid, buildColorMapShaderCodeFromClasses, buildColorMapShaderCodeFromDomain, buildShaderCode, WEBGL_FUNCTIONS } from '../pixi-utils'\r\n\r\nconst TiledMeshLayer = L.GridLayer.extend({\r\n initialize (options, gridSource) {\r\n this.conf = {}\r\n\r\n // keep color scale options\r\n this.conf.chromajs = options.chromajs\r\n // keep rendering options\r\n this.conf.render = {\r\n cutOver: options.cutOver,\r\n cutUnder: options.cutUnder,\r\n pixelColorMapping: options.pixelColorMapping\r\n }\r\n // keep debug options\r\n this.conf.debug = {\r\n showTileInfos: options.showTileInfos,\r\n meshAsPoints: options.meshAsPoints,\r\n showShader: options.showShader\r\n }\r\n this.conf.resolutionScale = _.get(options, 'resolutionScale', [1.0, 1.0])\r\n\r\n // initialize grid layer\r\n L.GridLayer.prototype.initialize.call(this, options)\r\n\r\n // setup pixi objects\r\n this.pixiRoot = new PIXI.Container()\r\n this.pixiLayer = L.pixiOverlay(\r\n utils => this.renderPixiLayer(utils),\r\n this.pixiRoot,\r\n { destroyInteractionManager: true, shouldRedrawOnMove: function () { return true } })\r\n this.layerUniforms = new PIXI.UniformGroup({ in_layerAlpha: options.opacity, in_zoomLevel: 1.0 })\r\n this.pixiState = new PIXI.State()\r\n this.pixiState.culling = true\r\n this.pixiState.blendMode = PIXI.BLEND_MODES.SCREEN\r\n\r\n // setup layer global uniforms (as opposed to tile specific uniforms)\r\n this.cutValueUniform = null\r\n if (options.cutOver) {\r\n this.layerUniforms.uniforms.cutOver = 0.0\r\n if (options.cutOver === 'levels') {\r\n this.cutValueUniform = 'in_cutOver'\r\n } else {\r\n this.layerUniforms.uniforms.in_cutOver = options.cutOver\r\n }\r\n }\r\n if (options.cutUnder) {\r\n this.layerUniforms.uniforms.cutUnder = 0.0\r\n if (options.cutUnder === 'levels') {\r\n this.cutValueUniform = 'in_cutUnder'\r\n } else {\r\n this.layerUniforms.uniforms.in_cutUnder = options.cutUnder\r\n }\r\n }\r\n\r\n // register event callbacks\r\n this.on('tileload', (event) => { this.onTileLoad(event) })\r\n this.on('tileunload', (event) => { this.onTileUnload(event) })\r\n\r\n this.gridSource = gridSource\r\n // keep ref on callback to be able to remove it\r\n this.onDataChangedCallback = this.onDataChanged.bind(this)\r\n this.gridSource.on('data-changed', this.onDataChangedCallback)\r\n },\r\n\r\n onAdd (map) {\r\n map.addLayer(this.pixiLayer)\r\n\r\n // This gets computed by pixi layer when it gets added to a map.\r\n // This uniform is supposed to reflect the visualization zoom level\r\n // to correctly project from wgs84 to web mercator in the shader\r\n // BUT since pixi already handles zoom with the container's scale matrix\r\n // we use the constant zoom level that was defined when the pixi layer\r\n // was added to the map.\r\n this.layerUniforms.uniforms.in_zoomLevel = this.pixiLayer._initialZoom\r\n\r\n // be notified when zoom starts\r\n // keep a ref on bound objects to be able to remove them later\r\n this.zoomStartCallback = this.onZoomStart.bind(this)\r\n this.zoomEndCallback = this.onZoomEnd.bind(this)\r\n map.on('zoomstart', this.zoomStartCallback)\r\n map.on('zoomend', this.zoomEndCallback)\r\n\r\n L.GridLayer.prototype.onAdd.call(this, map)\r\n },\r\n\r\n onRemove (map) {\r\n // remove map listeners\r\n map.off('zoomstart', this.zoomStartCallback)\r\n map.off('zoomend', this.zoomEndCallback)\r\n this.zoomStartCallback = null\r\n this.zoomEndCallback = null\r\n\r\n map.removeLayer(this.pixiLayer)\r\n\r\n L.GridLayer.prototype.onRemove.call(this, map)\r\n },\r\n\r\n createTile (coords, done) {\r\n const tile = document.createElement('div')\r\n\r\n // bbox we'll request to the grid source\r\n const bounds = this._tileCoordsToBounds(coords)\r\n const reqBBox = [bounds.getSouth(), bounds.getWest(), bounds.getNorth(), bounds.getEast()]\r\n // compute an ideal resolution for grid sources that care\r\n const tileSize = this.getTileSize()\r\n const resolution = [\r\n this.conf.resolutionScale[0] * ((reqBBox[2] - reqBBox[0]) / (tileSize.y - 1)),\r\n this.conf.resolutionScale[1] * ((reqBBox[3] - reqBBox[1]) / (tileSize.x - 1))\r\n ]\r\n tile.fetchController = new AbortController()\r\n\r\n // request data\r\n this.gridSource.fetch(tile.fetchController.signal, reqBBox, resolution)\r\n .then(grid => {\r\n // fetch ended, can't abort anymore\r\n tile.fetchController = null\r\n\r\n if (grid) {\r\n if (grid.hasData()) {\r\n // grid may be much larger than request, try to squeeze it\r\n const [iminlat, iminlon, imaxlat, imaxlon] = grid.getBestFit(reqBBox)\r\n\r\n const minlat = grid.getLat(iminlat)\r\n const minlon = grid.getLon(iminlon)\r\n const maxlat = grid.getLat(imaxlat)\r\n const maxlon = grid.getLon(imaxlon)\r\n\r\n // build mesh\r\n const raw = new RawValueHook('in_layerValue')\r\n const geometry = buildPixiMeshFromGrid(grid, [raw], iminlat, iminlon, imaxlat, imaxlon)\r\n\r\n // compute tile specific uniforms\r\n const uniforms = {\r\n in_layerBounds: Float32Array.from(reqBBox),\r\n in_layerOffsetScale: Float32Array.of(minlat, minlon, maxlat - minlat, maxlon - minlon),\r\n layerUniforms: this.layerUniforms\r\n }\r\n if (grid.nodata !== undefined) {\r\n uniforms.in_nodata = grid.nodata\r\n }\r\n\r\n const shader = new PIXI.Shader(this.program, uniforms)\r\n const mode = this.conf.debug.meshAsPoints ? PIXI.DRAW_MODES.POINTS : PIXI.DRAW_MODES.TRIANGLE_STRIP\r\n tile.mesh = new PIXI.Mesh(geometry, shader, this.pixiState, mode)\r\n\r\n if (this.conf.debug.showTileInfos) {\r\n const dims = grid.getDimensions()\r\n const res = grid.getResolution()\r\n tile.innerHTML =\r\n `leaflet tile is ${tileSize.y} x ${tileSize.x} pixels</br>\r\n covering ${reqBBox[0].toPrecision(6)},${reqBBox[1].toPrecision(6)} to ${reqBBox[2].toPrecision(6)},${reqBBox[3].toPrecision(6)}</br>\r\n req res: ${resolution[0].toPrecision(4)} ${resolution[1].toPrecision(4)}</br>\r\n got res: ${res[0].toPrecision(4)} ${res[1].toPrecision(4)}</br>\r\n fetched grid is ${dims[0]} x ${dims[1]}, slimmed down to ${1 + imaxlat - iminlat} x ${1 + imaxlon - iminlon} points`\r\n tile.style.outline = '1px solid green'\r\n }\r\n } else if (this.conf.debug.showTileInfos) {\r\n tile.style.outline = '1px solid red'\r\n tile.innerHTML = 'no data here (grid was full of nodata)!'\r\n }\r\n } else if (this.conf.debug.showTileInfos) {\r\n tile.style.outline = '1px solid red'\r\n tile.innerHTML = 'no data here (grid source returned null grid)!'\r\n }\r\n\r\n done(null, tile)\r\n })\r\n .catch(err => {\r\n done(err, tile)\r\n throw err\r\n })\r\n\r\n return tile\r\n },\r\n\r\n onTileLoad (event) {\r\n // tile loaded\r\n const mesh = event.tile.mesh\r\n if (!mesh) return\r\n\r\n mesh.zoomLevel = event.coords.z\r\n mesh.visible = (mesh.zoomLevel === this._map.getZoom())\r\n this.pixiRoot.addChild(mesh)\r\n if (mesh.visible) {\r\n this.pixiLayer.redraw()\r\n }\r\n },\r\n\r\n onTileUnload (event) {\r\n // tile unloaded\r\n if (event.tile.fetchController) {\r\n // fetch controller still present, abort fetching underlying data\r\n event.tile.fetchController.abort()\r\n event.tile.fetchController = null\r\n }\r\n if (event.tile.mesh) {\r\n // remove and destroy tile mesh\r\n this.pixiRoot.removeChild(event.tile.mesh)\r\n if (event.tile.mesh.visible) {\r\n this.pixiLayer.redraw()\r\n }\r\n event.tile.mesh.destroy()\r\n event.tile.mesh = null\r\n }\r\n },\r\n\r\n onZoomStart (event) {\r\n // hide meshes from current zoom level\r\n // this prevents visual weirdness when zooming where\r\n // zoom level 'n' tiles are still visible\r\n // and zoom level 'n+1' are being loaded on top of them\r\n // when alpha blending is used, this is annoying\r\n const zoomLevel = this._map.getZoom()\r\n for (const mesh of this.pixiRoot.children) {\r\n if (mesh.zoomLevel === zoomLevel) mesh.visible = false\r\n }\r\n },\r\n\r\n onZoomEnd (event) {\r\n // show meshes at current zoom level\r\n // this restores visibility for meshes that may have been hidden\r\n // on zoomstart event\r\n // this is important when quickly zoomin in and out\r\n // because some meshes may not have been evicted yet\r\n const zoomLevel = this._map.getZoom()\r\n for (const mesh of this.pixiRoot.children) {\r\n if (mesh.zoomLevel === zoomLevel) mesh.visible = true\r\n }\r\n this.pixiLayer.redraw()\r\n },\r\n\r\n onDataChanged () {\r\n const bbox = this.gridSource.getBBox()\r\n if (bbox) {\r\n // allow grid layer to only request tiles located in those bounds\r\n const c1 = L.latLng(bbox[0], bbox[1])\r\n const c2 = L.latLng(bbox[2], bbox[3])\r\n this.options.bounds = L.latLngBounds(c1, c2)\r\n }\r\n\r\n // eventually, update color map\r\n this.updateColorMap()\r\n // eventually, update shader\r\n this.updateShader()\r\n\r\n // clear tiles and request again\r\n this.redraw()\r\n\r\n // play nice with color legend component\r\n if (this.colorMap) {\r\n this.fire('data')\r\n this.hasData = true\r\n }\r\n },\r\n\r\n updateColorMap () {\r\n // create color map using domain or classes\r\n // domain and classes can be specified from options\r\n // if not, domain can be gathered from grid source\r\n this.colorMap = null\r\n this.colorMapShaderCode = null\r\n\r\n let domain = null\r\n const classes = _.get(this.conf, 'chromajs.classes', null)\r\n if (!classes) {\r\n domain = _.get(this.conf, 'chromajs.domain', null)\r\n if (!domain) {\r\n domain = this.gridSource.getDataBounds()\r\n }\r\n }\r\n\r\n const invert = _.get(this.conf, 'chromajs.invertScale', false)\r\n const colors = _.get(this.conf, 'chromajs.scale', null)\r\n const scale = chroma.scale(colors)\r\n // translate to glsl style colors for shader code\r\n const glcolors = scale.colors().map(c => chroma(c).gl())\r\n\r\n if (domain) {\r\n this.colorMap = chroma.scale(colors).domain(invert ? domain.slice().reverse() : domain)\r\n this.colorMapShaderCode = buildColorMapShaderCodeFromDomain(domain, glcolors, invert)\r\n } else if (classes) {\r\n this.colorMap = chroma.scale(colors).classes(invert ? classes.slice().reverse() : classes)\r\n this.colorMapShaderCode = buildColorMapShaderCodeFromClasses(classes, glcolors, invert)\r\n } else {\r\n console.error(\"Couldn't find any domain or classes to build color map!\")\r\n }\r\n },\r\n\r\n updateShader () {\r\n const features = [\r\n // feature projecting layer position\r\n {\r\n name: 'layerPosition',\r\n varyings: ['vec2 frg_layerPosition'],\r\n vertex: {\r\n attributes: ['vec2 in_layerPosition'],\r\n uniforms: ['mat3 translationMatrix', 'mat3 projectionMatrix', 'float in_zoomLevel', 'vec4 in_layerOffsetScale'],\r\n functions: [WEBGL_FUNCTIONS.latLonToWebMercator, WEBGL_FUNCTIONS.unpack2],\r\n code: ` frg_layerPosition = unpack2(in_layerPosition, in_layerOffsetScale);\r\n vec2 projected = latLonToWebMercator(vec3(frg_layerPosition, in_zoomLevel));\r\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(projected, 1.0)).xy, 0.0, 1.0);`\r\n },\r\n fragment: {\r\n uniforms: ['vec4 in_layerBounds'],\r\n code: ` bvec4 outside = bvec4(lessThan(frg_layerPosition, in_layerBounds.xy), greaterThan(frg_layerPosition, in_layerBounds.zw));\r\n if (any(outside)) discard;`\r\n }\r\n },\r\n // feature defining layer's scalar value\r\n {\r\n name: 'layerValue',\r\n varyings: ['float frg_layerValue'],\r\n vertex: {\r\n attributes: ['float in_layerValue'],\r\n code: ' frg_layerValue = in_layerValue;'\r\n }\r\n }\r\n ]\r\n\r\n // feature discarding fragments when scalar value is > threshold\r\n if (this.conf.render.cutOver) {\r\n features.push({\r\n name: 'cutOver',\r\n fragment: {\r\n uniforms: ['float in_cutOver'],\r\n code: ' if (frg_layerValue > in_cutOver) discard;'\r\n }\r\n })\r\n }\r\n // feature discarding fragments when scalar value is < threshold\r\n if (this.conf.render.cutUnder) {\r\n features.push({\r\n name: 'cutUnder',\r\n fragment: {\r\n uniforms: ['float in_cutUnder'],\r\n code: ' if (frg_layerValue < in_cutUnder) discard;'\r\n }\r\n })\r\n }\r\n // feature discarding fragments when scalar value is nodata\r\n if (this.gridSource.supportsNoData()) {\r\n features.push({\r\n name: 'nodata',\r\n varyings: ['float frg_validValue'],\r\n vertex: {\r\n uniforms: ['float in_nodata'],\r\n code: ' frg_validValue = (in_layerValue == in_nodata ? 0.0 : 1.0);'\r\n },\r\n fragment: {\r\n code: ' if (frg_validValue != 1.0) discard;'\r\n }\r\n })\r\n }\r\n // feature performing color mapping ...\r\n if (this.colorMapShaderCode) {\r\n if (this.conf.render.pixelColorMapping) {\r\n // ... per fragment\r\n features.push({\r\n name: 'colormap',\r\n fragment: {\r\n functions: [this.colorMapShaderCode],\r\n code: ' vec4 color = ColorMap(frg_layerValue);'\r\n }\r\n })\r\n } else {\r\n // ... or per vertex\r\n features.push({\r\n name: 'colormap',\r\n varyings: ['vec4 frg_color'],\r\n vertex: {\r\n functions: [this.colorMapShaderCode],\r\n code: ' frg_color = ColorMap(frg_layerValue);'\r\n },\r\n fragment: {\r\n code: ' vec4 color = frg_color;'\r\n }\r\n })\r\n }\r\n } else {\r\n // .. no color map code provided, issue unique color\r\n features.push({\r\n name: 'colormap',\r\n varyings: ['vec4 frg_color'],\r\n vertex: {\r\n code: ' frg_color = vec4(1.0, 0.521, 0.105, 1.1);'\r\n },\r\n fragment: {\r\n code: ' vec4 color = frg_color;'\r\n }\r\n })\r\n }\r\n // feature computing final fragment color\r\n features.push({\r\n name: 'tail',\r\n fragment: {\r\n uniforms: ['float in_layerAlpha'],\r\n code: ` gl_FragColor.rgb = color.rgb * in_layerAlpha;\r\n gl_FragColor.a = in_layerAlpha;`\r\n }\r\n })\r\n\r\n const [vtxCode, frgCode] = buildShaderCode(features)\r\n this.program = new PIXI.Program(vtxCode, frgCode)\r\n\r\n if (this.conf.debug.showShader) {\r\n console.log('Generated vertex shader:')\r\n console.log(vtxCode)\r\n console.log('Generated fragment shader:')\r\n console.log(frgCode)\r\n }\r\n },\r\n\r\n renderPixiLayer (utils) {\r\n const renderer = utils.getRenderer()\r\n renderer.render(this.pixiRoot)\r\n },\r\n\r\n setLevel (value) {\r\n if (this.cutValueUniform) {\r\n this.layerUniforms.uniforms[this.cutValueUniform] = value\r\n this.pixiLayer.redraw()\r\n } else if (typeof this.gridSource.setLevel === 'function') {\r\n this._resetView()\r\n this.gridSource.setLevel(value)\r\n }\r\n },\r\n\r\n setTime (time) {\r\n if (typeof this.gridSource.setTime === 'function') {\r\n this._resetView()\r\n this.gridSource.setTime(time)\r\n }\r\n },\r\n\r\n setModel (model) {\r\n if (typeof this.gridSource.setModel === 'function') {\r\n this._resetView()\r\n this.gridSource.setModel(model)\r\n }\r\n },\r\n\r\n getBounds () {\r\n const bounds = this.options.bounds ? this.options.bounds : L.latLngBounds(L.latLng(-90, -180), L.latLng(90, 180))\r\n return this._map ? this._map.wrapLatLngBounds(bounds) : bounds\r\n }\r\n})\r\n\r\nexport { TiledMeshLayer }\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../map/client/leaflet/TiledMeshLayer.js"],"names":["PIXI","TiledMeshLayer","L","GridLayer","extend","initialize","options","gridSource","conf","chromajs","render","cutOver","cutUnder","pixelColorMapping","showWireframe","enableCulling","_","get","debug","showTileInfos","meshAsPoints","showShader","resolutionScale","prototype","call","pixiRoot","Container","pixiLayer","pixiOverlay","utils","renderPixiLayer","destroyInteractionManager","shouldRedrawOnMove","layerUniforms","UniformGroup","in_layerAlpha","opacity","in_zoomLevel","pixiState","State","culling","blendMode","BLEND_MODES","SCREEN","cutValueUniform","uniforms","in_cutOver","in_cutUnder","on","event","onTileLoad","onTileUnload","onDataChangedCallback","onDataChanged","bind","onAdd","map","addLayer","_initialZoom","zoomStartCallback","onZoomStart","zoomEndCallback","onZoomEnd","onRemove","off","removeLayer","createTile","coords","done","tile","document","createElement","bounds","_tileCoordsToBounds","reqBBox","getSouth","getWest","getNorth","getEast","tileSize","getTileSize","resolution","y","x","fetchController","AbortController","fetch","signal","then","grid","hasData","minLat","minLon","deltaLat","deltaLon","genCoordsBuffer","values","genValuesBuffer","indexes","genMeshIndexBuffer","geometry","Geometry","addAttribute","TYPES","HALF_FLOAT_VERTEX","FLOAT","addIndex","in_layerBounds","Float32Array","from","in_layerOffsetScale","of","nodata","undefined","in_nodata","shader","Shader","program","mode","DRAW_MODES","POINTS","TRIANGLE_STRIP","mesh","Mesh","wireframeGeometry","getBuffer","genWireframeIndexBuffer","wireframeShader","wireframeProgram","wireframe","LINE_STRIP","innerHTML","toPrecision","length","style","outline","catch","err","zoomLevel","z","visible","_map","getZoom","addChild","redraw","abort","removeChild","destroy","child","children","bbox","getBBox","c1","latLng","c2","latLngBounds","updateColorMap","updateShader","colorMap","fire","colorMapShaderCode","domain","classes","getDataBounds","invert","colors","scale","chroma","glcolors","c","gl","slice","reverse","console","error","features","name","varyings","vertex","attributes","functions","WEBGL_FUNCTIONS","latLonToWebMercator","unpack2","code","fragment","push","supportsNoData","vtxCode","frgCode","Program","vtxWireframe","frgWireframe","log","renderer","getRenderer","setLevel","value","_resetView","setTime","time","setModel","model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AKH,UAAL;AACA,WAAK/L,UAAL,CAAgBkM,QAAhB,CAAyBC,KAAzB;AACD;AACF,GAlduC;;AAodxCC,cAAa;AACX,UAAMnI,SAAS,KAAKlE,OAAL,CAAakE,MAAb,GAAsB,KAAKlE,OAAL,CAAakE,MAAnC,GAA4CtE,kBAAEyJ,YAAF,CAAezJ,kBAAEuJ,MAAF,CAAS,CAAC,EAAV,EAAc,CAAC,GAAf,CAAf,EAAoCvJ,kBAAEuJ,MAAF,CAAS,EAAT,EAAa,GAAb,CAApC,CAA3D;AACA,WAAO,KAAKZ,IAAL,GAAY,KAAKA,IAAL,CAAU+D,gBAAV,CAA2BpI,MAA3B,CAAZ,GAAiDA,MAAxD;AACD;AAvduC,CAAnB,CAAvB;;QA0dSvE,c,GAAAA,c","file":"TiledMeshLayer.js","sourcesContent":["import _ from 'lodash'\r\nimport L from 'leaflet'\r\nimport chroma from 'chroma-js'\r\nimport * as PIXI from 'pixi.js'\r\nimport 'leaflet-pixi-overlay'\r\nimport 'abort-controller/polyfill'\r\n\r\nimport { buildColorMapShaderCodeFromClasses, buildColorMapShaderCodeFromDomain, buildShaderCode, WEBGL_FUNCTIONS } from '../pixi-utils'\r\n\r\nconst TiledMeshLayer = L.GridLayer.extend({\r\n initialize (options, gridSource) {\r\n this.conf = {}\r\n\r\n // keep color scale options\r\n this.conf.chromajs = options.chromajs\r\n // keep rendering options\r\n this.conf.render = {\r\n cutOver: options.cutOver,\r\n cutUnder: options.cutUnder,\r\n pixelColorMapping: options.pixelColorMapping,\r\n showWireframe: options.showWireframe,\r\n enableCulling: _.get(options, 'enableCulling', true)\r\n }\r\n // keep debug options\r\n this.conf.debug = {\r\n showTileInfos: options.showTileInfos,\r\n meshAsPoints: options.meshAsPoints,\r\n showShader: options.showShader\r\n }\r\n this.conf.resolutionScale = _.get(options, 'resolutionScale', [1.0, 1.0])\r\n\r\n // initialize grid layer\r\n L.GridLayer.prototype.initialize.call(this, options)\r\n\r\n // setup pixi objects\r\n this.pixiRoot = new PIXI.Container()\r\n this.pixiLayer = L.pixiOverlay(\r\n utils => this.renderPixiLayer(utils),\r\n this.pixiRoot,\r\n { destroyInteractionManager: true, shouldRedrawOnMove: function () { return true } })\r\n this.layerUniforms = new PIXI.UniformGroup({ in_layerAlpha: options.opacity, in_zoomLevel: 1.0 })\r\n this.pixiState = new PIXI.State()\r\n this.pixiState.culling = this.conf.render.enableCulling\r\n this.pixiState.blendMode = PIXI.BLEND_MODES.SCREEN\r\n\r\n // setup layer global uniforms (as opposed to tile specific uniforms)\r\n this.cutValueUniform = null\r\n if (options.cutOver) {\r\n this.layerUniforms.uniforms.in_cutOver = 0.0\r\n if (options.cutOver === 'levels') {\r\n this.cutValueUniform = 'in_cutOver'\r\n } else {\r\n this.layerUniforms.uniforms.in_cutOver = options.cutOver\r\n }\r\n }\r\n if (options.cutUnder) {\r\n this.layerUniforms.uniforms.in_cutUnder = 0.0\r\n if (options.cutUnder === 'levels') {\r\n this.cutValueUniform = 'in_cutUnder'\r\n } else {\r\n this.layerUniforms.uniforms.in_cutUnder = options.cutUnder\r\n }\r\n }\r\n\r\n // register event callbacks\r\n this.on('tileload', (event) => { this.onTileLoad(event) })\r\n this.on('tileunload', (event) => { this.onTileUnload(event) })\r\n\r\n this.gridSource = gridSource\r\n // keep ref on callback to be able to remove it\r\n this.onDataChangedCallback = this.onDataChanged.bind(this)\r\n this.gridSource.on('data-changed', this.onDataChangedCallback)\r\n },\r\n\r\n onAdd (map) {\r\n map.addLayer(this.pixiLayer)\r\n\r\n // This gets computed by pixi layer when it gets added to a map.\r\n // This uniform is supposed to reflect the visualization zoom level\r\n // to correctly project from wgs84 to web mercator in the shader\r\n // BUT since pixi already handles zoom with the container's scale matrix\r\n // we use the constant zoom level that was defined when the pixi layer\r\n // was added to the map.\r\n this.layerUniforms.uniforms.in_zoomLevel = this.pixiLayer._initialZoom\r\n\r\n // be notified when zoom starts\r\n // keep a ref on bound objects to be able to remove them later\r\n this.zoomStartCallback = this.onZoomStart.bind(this)\r\n this.zoomEndCallback = this.onZoomEnd.bind(this)\r\n map.on('zoomstart', this.zoomStartCallback)\r\n map.on('zoomend', this.zoomEndCallback)\r\n\r\n L.GridLayer.prototype.onAdd.call(this, map)\r\n },\r\n\r\n onRemove (map) {\r\n // remove map listeners\r\n map.off('zoomstart', this.zoomStartCallback)\r\n map.off('zoomend', this.zoomEndCallback)\r\n this.zoomStartCallback = null\r\n this.zoomEndCallback = null\r\n\r\n map.removeLayer(this.pixiLayer)\r\n\r\n L.GridLayer.prototype.onRemove.call(this, map)\r\n },\r\n\r\n createTile (coords, done) {\r\n const tile = document.createElement('div')\r\n\r\n // bbox we'll request to the grid source\r\n const bounds = this._tileCoordsToBounds(coords)\r\n const reqBBox = [bounds.getSouth(), bounds.getWest(), bounds.getNorth(), bounds.getEast()]\r\n // compute an ideal resolution for grid sources that care\r\n const tileSize = this.getTileSize()\r\n const resolution = [\r\n this.conf.resolutionScale[0] * ((reqBBox[2] - reqBBox[0]) / (tileSize.y - 1)),\r\n this.conf.resolutionScale[1] * ((reqBBox[3] - reqBBox[1]) / (tileSize.x - 1))\r\n ]\r\n tile.fetchController = new AbortController()\r\n\r\n // request data\r\n this.gridSource.fetch(tile.fetchController.signal, reqBBox, resolution)\r\n .then(grid => {\r\n // fetch ended, can't abort anymore\r\n tile.fetchController = null\r\n\r\n if (grid) {\r\n if (grid.hasData()) {\r\n const { coords, minLat, minLon, deltaLat, deltaLon } = grid.genCoordsBuffer()\r\n const values = grid.genValuesBuffer()\r\n const indexes = grid.genMeshIndexBuffer()\r\n const geometry = new PIXI.Geometry()\r\n .addAttribute('in_layerCoord', coords, 2, false, PIXI.TYPES.HALF_FLOAT_VERTEX)\r\n .addAttribute('in_layerValue', values, 1, false, PIXI.TYPES.FLOAT)\r\n .addIndex(indexes)\r\n\r\n // compute tile specific uniforms\r\n const uniforms = {\r\n in_layerBounds: Float32Array.from(reqBBox),\r\n in_layerOffsetScale: Float32Array.of(minLat, minLon, deltaLat, deltaLon),\r\n layerUniforms: this.layerUniforms\r\n }\r\n if (grid.nodata !== undefined) {\r\n uniforms.in_nodata = grid.nodata\r\n }\r\n\r\n const shader = new PIXI.Shader(this.program, uniforms)\r\n const mode = this.conf.debug.meshAsPoints ? PIXI.DRAW_MODES.POINTS : PIXI.DRAW_MODES.TRIANGLE_STRIP\r\n tile.mesh = new PIXI.Mesh(geometry, shader, this.pixiState, mode)\r\n\r\n if (this.conf.render.showWireframe) {\r\n const wireframeGeometry = new PIXI.Geometry()\r\n .addAttribute('in_layerCoord', geometry.getBuffer('in_layerCoord'), 2, false, PIXI.TYPES.HALF_FLOAT_VERTEX)\r\n .addIndex(grid.genWireframeIndexBuffer())\r\n const wireframeShader = new PIXI.Shader(this.wireframeProgram, uniforms)\r\n tile.wireframe = new PIXI.Mesh(wireframeGeometry, wireframeShader, this.pixiState, PIXI.DRAW_MODES.LINE_STRIP)\r\n }\r\n\r\n if (this.conf.debug.showTileInfos) {\r\n tile.innerHTML =\r\n `leaflet tile is ${tileSize.y} x ${tileSize.x} pixels</br>\r\n covering ${reqBBox[0].toPrecision(6)},${reqBBox[1].toPrecision(6)} to ${reqBBox[2].toPrecision(6)},${reqBBox[3].toPrecision(6)}</br>\r\n req res: ${resolution[0].toPrecision(4)} ${resolution[1].toPrecision(4)}</br>\r\n mesh is made of ${values.length} points`\r\n tile.style.outline = '1px solid green'\r\n }\r\n } else if (this.conf.debug.showTileInfos) {\r\n tile.style.outline = '1px solid red'\r\n tile.innerHTML = 'no data here (grid maybe full of nodata)!'\r\n }\r\n } else if (this.conf.debug.showTileInfos) {\r\n tile.style.outline = '1px solid red'\r\n tile.innerHTML = 'no data here (grid source returned null grid)!'\r\n }\r\n\r\n done(null, tile)\r\n })\r\n .catch(err => {\r\n done(err, tile)\r\n })\r\n\r\n return tile\r\n },\r\n\r\n onTileLoad (event) {\r\n // tile loaded\r\n const mesh = event.tile.mesh\r\n if (!mesh) return\r\n\r\n mesh.zoomLevel = event.coords.z\r\n mesh.visible = (mesh.zoomLevel === this._map.getZoom())\r\n this.pixiRoot.addChild(mesh)\r\n\r\n if (this.conf.render.showWireframe) {\r\n const wireframe = event.tile.wireframe\r\n wireframe.zoomLevel = mesh.zoomLevel\r\n wireframe.visible = mesh.visible\r\n this.pixiRoot.addChild(wireframe)\r\n }\r\n\r\n if (mesh.visible) {\r\n this.pixiLayer.redraw()\r\n }\r\n },\r\n\r\n onTileUnload (event) {\r\n // tile unloaded\r\n if (event.tile.fetchController) {\r\n // fetch controller still present, abort fetching underlying data\r\n event.tile.fetchController.abort()\r\n event.tile.fetchController = null\r\n }\r\n if (event.tile.mesh) {\r\n // remove and destroy tile mesh\r\n this.pixiRoot.removeChild(event.tile.mesh)\r\n\r\n if (this.conf.render.showWireframe) {\r\n this.pixiRoot.removeChild(event.tile.wireframe)\r\n event.tile.wireframe.destroy()\r\n event.tile.wireframe = null\r\n }\r\n\r\n if (event.tile.mesh.visible) {\r\n this.pixiLayer.redraw()\r\n }\r\n event.tile.mesh.destroy()\r\n event.tile.mesh = null\r\n }\r\n },\r\n\r\n onZoomStart (event) {\r\n // hide meshes from current zoom level\r\n // this prevents visual weirdness when zooming where\r\n // zoom level 'n' tiles are still visible\r\n // and zoom level 'n+1' are being loaded on top of them\r\n // when alpha blending is used, this is annoying\r\n const zoomLevel = this._map.getZoom()\r\n for (const child of this.pixiRoot.children) {\r\n if (child.zoomLevel === zoomLevel) child.visible = false\r\n }\r\n },\r\n\r\n onZoomEnd (event) {\r\n // show meshes at current zoom level\r\n // this restores visibility for meshes that may have been hidden\r\n // on zoomstart event\r\n // this is important when quickly zoomin in and out\r\n // because some meshes may not have been evicted yet\r\n const zoomLevel = this._map.getZoom()\r\n for (const child of this.pixiRoot.children) {\r\n if (child.zoomLevel === zoomLevel) child.visible = true\r\n }\r\n this.pixiLayer.redraw()\r\n },\r\n\r\n onDataChanged () {\r\n const bbox = this.gridSource.getBBox()\r\n if (bbox) {\r\n // allow grid layer to only request tiles located in those bounds\r\n const c1 = L.latLng(bbox[0], bbox[1])\r\n const c2 = L.latLng(bbox[2], bbox[3])\r\n this.options.bounds = L.latLngBounds(c1, c2)\r\n }\r\n\r\n // eventually, update color map\r\n this.updateColorMap()\r\n // eventually, update shader\r\n this.updateShader()\r\n\r\n // clear tiles and request again\r\n this.redraw()\r\n\r\n // play nice with color legend component\r\n if (this.colorMap) {\r\n this.fire('data')\r\n this.hasData = true\r\n }\r\n },\r\n\r\n updateColorMap () {\r\n // create color map using domain or classes\r\n // domain and classes can be specified from options\r\n // if not, domain can be gathered from grid source\r\n this.colorMap = null\r\n this.colorMapShaderCode = null\r\n\r\n let domain = null\r\n const classes = _.get(this.conf, 'chromajs.classes', null)\r\n if (!classes) {\r\n domain = _.get(this.conf, 'chromajs.domain', null)\r\n if (!domain) {\r\n domain = this.gridSource.getDataBounds()\r\n }\r\n }\r\n\r\n const invert = _.get(this.conf, 'chromajs.invertScale', false)\r\n const colors = _.get(this.conf, 'chromajs.scale', null)\r\n const scale = chroma.scale(colors)\r\n // translate to glsl style colors for shader code\r\n const glcolors = scale.colors().map(c => chroma(c).gl())\r\n\r\n if (domain) {\r\n this.colorMap = chroma.scale(colors).domain(invert ? domain.slice().reverse() : domain)\r\n this.colorMapShaderCode = buildColorMapShaderCodeFromDomain(domain, glcolors, invert)\r\n } else if (classes) {\r\n this.colorMap = chroma.scale(colors).classes(invert ? classes.slice().reverse() : classes)\r\n this.colorMapShaderCode = buildColorMapShaderCodeFromClasses(classes, glcolors, invert)\r\n } else {\r\n console.error(\"Couldn't find any domain or classes to build color map!\")\r\n }\r\n },\r\n\r\n updateShader () {\r\n const features = [\r\n // feature projecting layer position\r\n {\r\n name: 'layerCoord',\r\n varyings: ['vec2 frg_layerCoord'],\r\n vertex: {\r\n attributes: ['vec2 in_layerCoord'],\r\n uniforms: ['mat3 translationMatrix', 'mat3 projectionMatrix', 'float in_zoomLevel', 'vec4 in_layerOffsetScale'],\r\n functions: [WEBGL_FUNCTIONS.latLonToWebMercator, WEBGL_FUNCTIONS.unpack2],\r\n code: ` frg_layerCoord = unpack2(in_layerCoord, in_layerOffsetScale);\r\n vec2 projected = latLonToWebMercator(vec3(frg_layerCoord, in_zoomLevel));\r\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(projected, 1.0)).xy, 0.0, 1.0);\r\n ${this.conf.debug.meshAsPoints ? 'gl_PointSize = 10.0;' : ''}`\r\n },\r\n fragment: {\r\n uniforms: ['vec4 in_layerBounds'],\r\n code: ` bvec4 outside = bvec4(lessThan(frg_layerCoord, in_layerBounds.xy), greaterThan(frg_layerCoord, in_layerBounds.zw));\r\n if (any(outside)) discard;`\r\n }\r\n },\r\n // feature defining layer's scalar value\r\n {\r\n name: 'layerValue',\r\n varyings: ['float frg_layerValue'],\r\n vertex: {\r\n attributes: ['float in_layerValue'],\r\n code: ' frg_layerValue = in_layerValue;'\r\n }\r\n }\r\n ]\r\n\r\n // feature discarding fragments when scalar value is > threshold\r\n if (this.conf.render.cutOver) {\r\n features.push({\r\n name: 'cutOver',\r\n fragment: {\r\n uniforms: ['float in_cutOver'],\r\n code: ' if (frg_layerValue > in_cutOver) discard;'\r\n }\r\n })\r\n }\r\n // feature discarding fragments when scalar value is < threshold\r\n if (this.conf.render.cutUnder) {\r\n features.push({\r\n name: 'cutUnder',\r\n fragment: {\r\n uniforms: ['float in_cutUnder'],\r\n code: ' if (frg_layerValue < in_cutUnder) discard;'\r\n }\r\n })\r\n }\r\n // feature discarding fragments when scalar value is nodata\r\n if (this.gridSource.supportsNoData()) {\r\n features.push({\r\n name: 'nodata',\r\n varyings: ['float frg_validValue'],\r\n vertex: {\r\n uniforms: ['float in_nodata'],\r\n code: ' frg_validValue = (in_layerValue == in_nodata ? 0.0 : 1.0);'\r\n },\r\n fragment: {\r\n code: ' if (frg_validValue != 1.0) discard;'\r\n }\r\n })\r\n }\r\n // feature performing color mapping ...\r\n if (this.colorMapShaderCode) {\r\n if (this.conf.render.pixelColorMapping) {\r\n // ... per fragment\r\n features.push({\r\n name: 'colormap',\r\n fragment: {\r\n functions: [this.colorMapShaderCode],\r\n code: ' vec4 color = ColorMap(frg_layerValue);'\r\n }\r\n })\r\n } else {\r\n // ... or per vertex\r\n features.push({\r\n name: 'colormap',\r\n varyings: ['vec4 frg_color'],\r\n vertex: {\r\n functions: [this.colorMapShaderCode],\r\n code: ' frg_color = ColorMap(frg_layerValue);'\r\n },\r\n fragment: {\r\n code: ' vec4 color = frg_color;'\r\n }\r\n })\r\n }\r\n } else {\r\n // .. no color map code provided, issue unique color\r\n features.push({\r\n name: 'colormap',\r\n varyings: ['vec4 frg_color'],\r\n vertex: {\r\n code: ' frg_color = vec4(1.0, 0.521, 0.105, 1.1);'\r\n },\r\n fragment: {\r\n code: ' vec4 color = frg_color;'\r\n }\r\n })\r\n }\r\n // feature computing final fragment color\r\n features.push({\r\n name: 'tail',\r\n fragment: {\r\n uniforms: ['float in_layerAlpha'],\r\n code: ' outColor = vec4(color.rgb * in_layerAlpha, in_layerAlpha);'\r\n }\r\n })\r\n\r\n const [vtxCode, frgCode] = buildShaderCode(features)\r\n this.program = new PIXI.Program(vtxCode, frgCode)\r\n\r\n if (this.conf.render.showWireframe) {\r\n const [vtxWireframe, frgWireframe] = buildShaderCode([features[0], {\r\n name: 'tail',\r\n fragment: {\r\n uniforms: ['float in_layerAlpha'],\r\n code: ' outColor = vec4(0.0, 0.0, 0.0, in_layerAlpha);'\r\n }\r\n }])\r\n this.wireframeProgram = new PIXI.Program(vtxWireframe, frgWireframe)\r\n }\r\n\r\n if (this.conf.debug.showShader) {\r\n console.log('Generated vertex shader:')\r\n console.log(vtxCode)\r\n console.log('Generated fragment shader:')\r\n console.log(frgCode)\r\n }\r\n },\r\n\r\n renderPixiLayer (utils) {\r\n const renderer = utils.getRenderer()\r\n renderer.render(this.pixiRoot)\r\n },\r\n\r\n setLevel (value) {\r\n if (this.cutValueUniform) {\r\n this.layerUniforms.uniforms[this.cutValueUniform] = value\r\n this.pixiLayer.redraw()\r\n } else if (typeof this.gridSource.setLevel === 'function') {\r\n this._resetView()\r\n this.gridSource.setLevel(value)\r\n }\r\n },\r\n\r\n setTime (time) {\r\n if (typeof this.gridSource.setTime === 'function') {\r\n this._resetView()\r\n this.gridSource.setTime(time)\r\n }\r\n },\r\n\r\n setModel (model) {\r\n if (typeof this.gridSource.setModel === 'function') {\r\n this._resetView()\r\n this.gridSource.setModel(model)\r\n }\r\n },\r\n\r\n getBounds () {\r\n const bounds = this.options.bounds ? this.options.bounds : L.latLngBounds(L.latLng(-90, -180), L.latLng(90, 180))\r\n return this._map ? this._map.wrapLatLngBounds(bounds) : bounds\r\n }\r\n})\r\n\r\nexport { TiledMeshLayer }\r\n"]}
|
|
@@ -8,13 +8,19 @@ exports.bindLeafletEvents = bindLeafletEvents;
|
|
|
8
8
|
exports.unbindLeafletEvents = unbindLeafletEvents;
|
|
9
9
|
exports.getHtmlTable = getHtmlTable;
|
|
10
10
|
exports.tile2key = tile2key;
|
|
11
|
+
exports.key2tile = key2tile;
|
|
11
12
|
exports.tileSetContainsParent = tileSetContainsParent;
|
|
13
|
+
exports.getParentTileInTileSet = getParentTileInTileSet;
|
|
12
14
|
exports.computeIdealMaxNativeZoom = computeIdealMaxNativeZoom;
|
|
13
15
|
|
|
14
16
|
var _lodash = require('lodash');
|
|
15
17
|
|
|
16
18
|
var _lodash2 = _interopRequireDefault(_lodash);
|
|
17
19
|
|
|
20
|
+
var _leaflet = require('leaflet');
|
|
21
|
+
|
|
22
|
+
var _leaflet2 = _interopRequireDefault(_leaflet);
|
|
23
|
+
|
|
18
24
|
var _client = require('../../../core/client');
|
|
19
25
|
|
|
20
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -106,6 +112,20 @@ function tile2key(coords) {
|
|
|
106
112
|
return coords.x * 536870912 + coords.y * 32 + coords.z;
|
|
107
113
|
}
|
|
108
114
|
|
|
115
|
+
function key2tile(key) {
|
|
116
|
+
// JS Number.MAX_SAFE_INTEGER = 2^53 - 1, so 53 bits available
|
|
117
|
+
// put z value on 5 bits (0 - 32)
|
|
118
|
+
// put y value on 24 bits (0 - 16777216)
|
|
119
|
+
// put x value on 24 bits (0 - 16777216)
|
|
120
|
+
// shift y by 5 bits (* 32)
|
|
121
|
+
// shift x by 5+24 bits (* 536870912)
|
|
122
|
+
const x = Math.floor(key / 536870912);
|
|
123
|
+
const y = Math.floor((key - x * 536870912) / 32);
|
|
124
|
+
const p = _leaflet2.default.point(x, y);
|
|
125
|
+
p.z = key - (x * 536870912 + y * 32);
|
|
126
|
+
return p;
|
|
127
|
+
}
|
|
128
|
+
|
|
109
129
|
function tileSetContainsParent(tileset, coords) {
|
|
110
130
|
const triplet = {
|
|
111
131
|
x: coords.x,
|
|
@@ -115,9 +135,7 @@ function tileSetContainsParent(tileset, coords) {
|
|
|
115
135
|
|
|
116
136
|
while (triplet.z > 1) {
|
|
117
137
|
const tilekey = tile2key(triplet);
|
|
118
|
-
if (tileset.has(tilekey))
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
138
|
+
if (tileset.has(tilekey)) return true;
|
|
121
139
|
|
|
122
140
|
triplet.x = Math.floor(triplet.x / 2);
|
|
123
141
|
triplet.y = Math.floor(triplet.y / 2);
|
|
@@ -127,6 +145,29 @@ function tileSetContainsParent(tileset, coords) {
|
|
|
127
145
|
return false;
|
|
128
146
|
}
|
|
129
147
|
|
|
148
|
+
function getParentTileInTileSet(tileset, coords) {
|
|
149
|
+
const triplet = {
|
|
150
|
+
x: coords.x,
|
|
151
|
+
y: coords.y,
|
|
152
|
+
z: coords.z
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
triplet.x = Math.floor(triplet.x / 2);
|
|
156
|
+
triplet.y = Math.floor(triplet.y / 2);
|
|
157
|
+
triplet.z -= 1;
|
|
158
|
+
|
|
159
|
+
while (triplet.z > 1) {
|
|
160
|
+
const tilekey = tile2key(triplet);
|
|
161
|
+
if (tileset.has(tilekey)) return triplet;
|
|
162
|
+
|
|
163
|
+
triplet.x = Math.floor(triplet.x / 2);
|
|
164
|
+
triplet.y = Math.floor(triplet.y / 2);
|
|
165
|
+
triplet.z -= 1;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
|
|
130
171
|
function computeIdealMaxNativeZoom(gridLayer, dataSetBounds, dataSetTileSize) {
|
|
131
172
|
// compute optimal maxNativeZoom value to ensure
|
|
132
173
|
// the smallest leaflet tile will approximately match a dataset tile
|