ogm-viewer 0.3.0 → 0.4.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/dist/cjs/{index-CVTUnaNg.js → index-mu9UK_Fb.js} +66 -3
- package/dist/cjs/{lerc-TQEssgMv.js → lerc-CT61sKYw.js} +7 -7
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{ogm-image.ogm-map.ogm-menubar.ogm-metadata.ogm-settings.ogm-sidebar.ogm-viewer-ifPxRNEo.js → ogm-attributes.ogm-image.ogm-map.ogm-menubar.ogm-metadata.ogm-previews.ogm-settings.ogm-sidebar.ogm-viewer-DKxSOrMP.js} +13640 -7139
- package/dist/cjs/ogm-attributes_9.cjs.entry.js +16 -0
- package/dist/cjs/ogm-viewer.cjs.js +2 -2
- package/dist/collection/assets/webawesome/styles/color/palettes/base.css +44 -0
- package/dist/collection/assets/webawesome/styles/color/palettes/bright.css +145 -0
- package/dist/collection/assets/webawesome/styles/color/palettes/default.css +146 -0
- package/dist/collection/assets/webawesome/styles/color/palettes/shoelace.css +146 -0
- package/dist/collection/assets/webawesome/styles/color/variants/brand.css +162 -0
- package/dist/collection/assets/webawesome/styles/color/variants/danger.css +162 -0
- package/dist/collection/assets/webawesome/styles/color/variants/neutral.css +162 -0
- package/dist/collection/assets/webawesome/styles/color/variants/success.css +162 -0
- package/dist/collection/assets/webawesome/styles/color/variants/warning.css +162 -0
- package/dist/collection/assets/webawesome/styles/color/variants.css +5 -0
- package/dist/collection/assets/webawesome/styles/component/form-control.styles.d.ts +2 -0
- package/dist/collection/assets/webawesome/styles/component/form-control.styles.ts +43 -0
- package/dist/collection/assets/webawesome/styles/component/host.styles.d.ts +2 -0
- package/dist/collection/assets/webawesome/styles/component/host.styles.ts +18 -0
- package/dist/collection/assets/webawesome/styles/component/segmented-field.styles.d.ts +19 -0
- package/dist/collection/assets/webawesome/styles/component/segmented-field.styles.ts +92 -0
- package/dist/collection/assets/webawesome/styles/component/size.styles.d.ts +2 -0
- package/dist/collection/assets/webawesome/styles/component/size.styles.ts +26 -0
- package/dist/collection/assets/webawesome/styles/component/variants.styles.d.ts +2 -0
- package/dist/collection/assets/webawesome/styles/component/variants.styles.ts +69 -0
- package/dist/collection/assets/webawesome/styles/component/visually-hidden.styles.d.ts +2 -0
- package/dist/collection/assets/webawesome/styles/component/visually-hidden.styles.ts +19 -0
- package/dist/collection/assets/webawesome/styles/layers.css +21 -0
- package/dist/collection/assets/webawesome/styles/native.css +1439 -0
- package/dist/collection/assets/webawesome/styles/themes/awesome.css +614 -0
- package/dist/collection/assets/webawesome/styles/themes/default.css +373 -0
- package/dist/collection/assets/webawesome/styles/themes/shoelace.css +648 -0
- package/dist/collection/assets/webawesome/styles/utilities/align-items.css +44 -0
- package/dist/collection/assets/webawesome/styles/utilities/border-radius.css +20 -0
- package/dist/collection/assets/webawesome/styles/utilities/flex-wrap.css +16 -0
- package/dist/collection/assets/webawesome/styles/utilities/fouce.css +17 -0
- package/dist/collection/assets/webawesome/styles/utilities/gap.css +56 -0
- package/dist/collection/assets/webawesome/styles/utilities/justify-content.css +32 -0
- package/dist/collection/assets/webawesome/styles/utilities/layout.css +159 -0
- package/dist/collection/assets/webawesome/styles/utilities/placeholder.css +9 -0
- package/dist/collection/assets/webawesome/styles/utilities/prose.css +161 -0
- package/dist/collection/assets/webawesome/styles/utilities/scroll-lock.css +20 -0
- package/dist/collection/assets/webawesome/styles/utilities/size.css +21 -0
- package/dist/collection/assets/webawesome/styles/utilities/text.css +262 -0
- package/dist/collection/assets/webawesome/styles/utilities/variants.css +62 -0
- package/dist/collection/assets/webawesome/styles/utilities/visually-hidden.css +17 -0
- package/dist/collection/assets/webawesome/styles/utilities.css +17 -0
- package/dist/collection/assets/webawesome/styles/webawesome.css +11 -0
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/ogm-attributes/ogm-attributes.css +68 -0
- package/dist/collection/components/ogm-attributes/ogm-attributes.js +112 -0
- package/dist/collection/components/ogm-image/ogm-image.css +1 -1
- package/dist/collection/components/ogm-image/ogm-image.js +16 -18
- package/dist/collection/components/ogm-map/ogm-map.css +10 -5
- package/dist/collection/components/ogm-map/ogm-map.js +170 -86
- package/dist/collection/components/ogm-menubar/ogm-menubar.css +16 -14
- package/dist/collection/components/ogm-menubar/ogm-menubar.js +3 -5
- package/dist/collection/components/ogm-menubar/ogm-menubar.test.js +7 -3
- package/dist/collection/components/ogm-metadata/ogm-metadata.css +6 -492
- package/dist/collection/components/ogm-metadata/ogm-metadata.js +3 -5
- package/dist/collection/components/ogm-metadata/ogm-metadata.test.js +1 -1
- package/dist/collection/components/ogm-previews/ogm-previews.css +44 -0
- package/dist/collection/components/ogm-previews/ogm-previews.js +172 -0
- package/dist/collection/components/ogm-settings/ogm-settings.js +7 -9
- package/dist/collection/components/ogm-sidebar/ogm-sidebar.css +50 -503
- package/dist/collection/components/ogm-sidebar/ogm-sidebar.js +8 -12
- package/dist/collection/components/ogm-viewer/ogm-viewer.css +4 -974
- package/dist/collection/components/ogm-viewer/ogm-viewer.js +41 -25
- package/dist/collection/lib/previewers/cog-deck.js +14 -9
- package/dist/collection/lib/previewers/cog.js +3 -3
- package/dist/collection/lib/previewers/geojson.js +3 -2
- package/dist/collection/lib/previewers/maplibre.js +9 -15
- package/dist/collection/lib/previewers/pmtiles-raster.js +1 -1
- package/dist/collection/lib/previewers/pmtiles-vector.js +7 -1
- package/dist/collection/lib/previewers/raster.js +1 -1
- package/dist/collection/lib/previewers/vector.js +65 -30
- package/dist/collection/lib/previewers/wms.js +1 -1
- package/dist/collection/lib/record.js +1 -1
- package/dist/collection/lib/record.test.js +1 -1
- package/dist/collection/lib/references.js +0 -65
- package/dist/collection/lib/references.test.js +0 -150
- package/dist/collection/lib/sources/cog.js +5 -2
- package/dist/collection/lib/sources/geojson.js +7 -1
- package/dist/collection/lib/sources/iiif-manifest.js +55 -0
- package/dist/collection/lib/sources/iiif-manifest.test.js +110 -0
- package/dist/collection/lib/sources/iiif.js +11 -0
- package/dist/collection/lib/sources/maplibre.js +8 -0
- package/dist/collection/lib/sources/openindexmap.js +3 -0
- package/dist/collection/lib/sources/pmtiles.js +10 -4
- package/dist/collection/lib/sources/raster.js +3 -3
- package/dist/collection/lib/sources/source.js +26 -7
- package/dist/collection/lib/sources/tilejson.js +7 -1
- package/dist/collection/lib/sources/tms.js +3 -0
- package/dist/collection/lib/sources/vector.js +3 -3
- package/dist/collection/lib/sources/wms.js +6 -11
- package/dist/collection/lib/sources/xyz.js +3 -0
- package/dist/collection/lib/themes/maplibre.js +46 -0
- package/dist/collection/lib/themes/theme.js +23 -0
- package/dist/esm/{index-BdFT_kJa.js → index-DTLAlWKQ.js} +66 -3
- package/dist/esm/{lerc-DFDScDrO.js → lerc-Bz409klg.js} +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{ogm-image.ogm-map.ogm-menubar.ogm-metadata.ogm-settings.ogm-sidebar.ogm-viewer-r5w_49n3.js → ogm-attributes.ogm-image.ogm-map.ogm-menubar.ogm-metadata.ogm-previews.ogm-settings.ogm-sidebar.ogm-viewer-C9zV3wMe.js} +13639 -7140
- package/dist/esm/ogm-attributes_9.entry.js +2 -0
- package/dist/esm/ogm-viewer.js +3 -3
- package/dist/ogm-viewer/assets/webawesome/styles/color/palettes/base.css +44 -0
- package/dist/ogm-viewer/assets/webawesome/styles/color/palettes/bright.css +145 -0
- package/dist/ogm-viewer/assets/webawesome/styles/color/palettes/default.css +146 -0
- package/dist/ogm-viewer/assets/webawesome/styles/color/palettes/shoelace.css +146 -0
- package/dist/ogm-viewer/assets/webawesome/styles/color/variants/brand.css +162 -0
- package/dist/ogm-viewer/assets/webawesome/styles/color/variants/danger.css +162 -0
- package/dist/ogm-viewer/assets/webawesome/styles/color/variants/neutral.css +162 -0
- package/dist/ogm-viewer/assets/webawesome/styles/color/variants/success.css +162 -0
- package/dist/ogm-viewer/assets/webawesome/styles/color/variants/warning.css +162 -0
- package/dist/ogm-viewer/assets/webawesome/styles/color/variants.css +5 -0
- package/dist/ogm-viewer/assets/webawesome/styles/component/form-control.styles.d.ts +2 -0
- package/dist/ogm-viewer/assets/webawesome/styles/component/form-control.styles.ts +43 -0
- package/dist/ogm-viewer/assets/webawesome/styles/component/host.styles.d.ts +2 -0
- package/dist/ogm-viewer/assets/webawesome/styles/component/host.styles.ts +18 -0
- package/dist/ogm-viewer/assets/webawesome/styles/component/segmented-field.styles.d.ts +19 -0
- package/dist/ogm-viewer/assets/webawesome/styles/component/segmented-field.styles.ts +92 -0
- package/dist/ogm-viewer/assets/webawesome/styles/component/size.styles.d.ts +2 -0
- package/dist/ogm-viewer/assets/webawesome/styles/component/size.styles.ts +26 -0
- package/dist/ogm-viewer/assets/webawesome/styles/component/variants.styles.d.ts +2 -0
- package/dist/ogm-viewer/assets/webawesome/styles/component/variants.styles.ts +69 -0
- package/dist/ogm-viewer/assets/webawesome/styles/component/visually-hidden.styles.d.ts +2 -0
- package/dist/ogm-viewer/assets/webawesome/styles/component/visually-hidden.styles.ts +19 -0
- package/dist/ogm-viewer/assets/webawesome/styles/layers.css +21 -0
- package/dist/ogm-viewer/assets/webawesome/styles/native.css +1439 -0
- package/dist/ogm-viewer/assets/webawesome/styles/themes/awesome.css +614 -0
- package/dist/ogm-viewer/assets/webawesome/styles/themes/default.css +373 -0
- package/dist/ogm-viewer/assets/webawesome/styles/themes/shoelace.css +648 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/align-items.css +44 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/border-radius.css +20 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/flex-wrap.css +16 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/fouce.css +17 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/gap.css +56 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/justify-content.css +32 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/layout.css +159 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/placeholder.css +9 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/prose.css +161 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/scroll-lock.css +20 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/size.css +21 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/text.css +262 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/variants.css +62 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities/visually-hidden.css +17 -0
- package/dist/ogm-viewer/assets/webawesome/styles/utilities.css +17 -0
- package/dist/ogm-viewer/assets/webawesome/styles/webawesome.css +11 -0
- package/dist/ogm-viewer/ogm-viewer.esm.js +1 -1
- package/dist/ogm-viewer/p-86b8fafc.entry.js +1 -0
- package/dist/ogm-viewer/{p-BeA3REDA.js → p-BrovdLv6.js} +1 -1
- package/dist/ogm-viewer/p-CpCT3zlD.js +2750 -0
- package/dist/ogm-viewer/p-DTLAlWKQ.js +2 -0
- package/dist/types/components/ogm-attributes/ogm-attributes.d.ts +10 -0
- package/dist/types/components/ogm-image/ogm-image.d.ts +3 -3
- package/dist/types/components/ogm-map/ogm-map.d.ts +32 -14
- package/dist/types/components/ogm-menubar/ogm-menubar.d.ts +1 -1
- package/dist/types/components/ogm-metadata/ogm-metadata.d.ts +1 -1
- package/dist/types/components/ogm-previews/ogm-previews.d.ts +16 -0
- package/dist/types/components/ogm-settings/ogm-settings.d.ts +2 -2
- package/dist/types/components/ogm-sidebar/ogm-sidebar.d.ts +1 -1
- package/dist/types/components/ogm-viewer/ogm-viewer.d.ts +10 -12
- package/dist/types/components.d.ts +70 -18
- package/dist/types/lib/previewers/cog-deck.d.ts +7 -3
- package/dist/types/lib/previewers/cog.d.ts +2 -2
- package/dist/types/lib/previewers/maplibre.d.ts +7 -9
- package/dist/types/lib/previewers/pmtiles-vector.d.ts +1 -0
- package/dist/types/lib/previewers/vector.d.ts +3 -15
- package/dist/types/lib/record.d.ts +1 -1
- package/dist/types/lib/references.d.ts +0 -8
- package/dist/types/lib/sources/cog.d.ts +3 -2
- package/dist/types/lib/sources/geojson.d.ts +3 -2
- package/dist/types/lib/sources/iiif-manifest.d.ts +12 -0
- package/dist/types/lib/sources/iiif-manifest.test.d.ts +1 -0
- package/dist/types/lib/sources/iiif.d.ts +5 -0
- package/dist/types/lib/sources/maplibre.d.ts +7 -0
- package/dist/types/lib/sources/openindexmap.d.ts +1 -0
- package/dist/types/lib/sources/pmtiles.d.ts +6 -4
- package/dist/types/lib/sources/raster.d.ts +3 -3
- package/dist/types/lib/sources/source.d.ts +6 -6
- package/dist/types/lib/sources/tilejson.d.ts +3 -2
- package/dist/types/lib/sources/tms.d.ts +1 -0
- package/dist/types/lib/sources/vector.d.ts +4 -5
- package/dist/types/lib/sources/wms.d.ts +4 -3
- package/dist/types/lib/sources/xyz.d.ts +1 -0
- package/dist/types/lib/themes/maplibre.d.ts +27 -0
- package/dist/types/lib/themes/theme.d.ts +7 -0
- package/package.json +3 -2
- package/dist/cjs/ogm-image_7.cjs.entry.js +0 -14
- package/dist/collection/lib/previewers/index.js +0 -36
- package/dist/collection/lib/sources/index.js +0 -29
- package/dist/esm/ogm-image_7.entry.js +0 -2
- package/dist/ogm-viewer/p-0b81e024.entry.js +0 -1
- package/dist/ogm-viewer/p-33R3d9fV.js +0 -1950
- package/dist/ogm-viewer/p-BdFT_kJa.js +0 -2
- package/dist/types/lib/previewers/index.d.ts +0 -3
- package/dist/types/lib/sources/index.d.ts +0 -3
|
@@ -1,19 +1,39 @@
|
|
|
1
|
-
import { setBasePath } from "@
|
|
2
|
-
import { getAssetPath, h } from "@stencil/core";
|
|
3
|
-
import
|
|
1
|
+
import { setBasePath, getBasePath, registerIconLibrary } from "@awesome.me/webawesome";
|
|
2
|
+
import { Host, getAssetPath, h } from "@stencil/core";
|
|
3
|
+
import OgmRecord from "../../lib/record";
|
|
4
4
|
// Only need to call this once, at the top level
|
|
5
5
|
setBasePath(getAssetPath(''));
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
// Serve icons from our self-hosted bootstrap-icons subset instead of the default Font Awesome library
|
|
7
|
+
registerIconLibrary('default', {
|
|
8
|
+
resolver: name => getBasePath(`assets/icons/${name}.svg`),
|
|
9
|
+
});
|
|
10
|
+
// Web Awesome's raw color palette is scoped to `:root`, which can only ever match the actual
|
|
11
|
+
// document root - never an element inside a shadow tree, so a component-scoped @import can't
|
|
12
|
+
// activate it. Loading it here, at the document level, lets it match `:root` for real, and lets
|
|
13
|
+
// its `.wa-light`/`.wa-dark` theme rules match the <ogm-viewer> host itself (see render() below),
|
|
14
|
+
// from which every token inherits down through the rest of the shadow tree. Injecting it here
|
|
15
|
+
// means consumers don't have to remember to add it to their own page.
|
|
16
|
+
function loadWebAwesomeStylesheet() {
|
|
17
|
+
const id = 'ogm-viewer-webawesome-styles';
|
|
18
|
+
if (document.getElementById(id))
|
|
19
|
+
return;
|
|
20
|
+
const link = document.createElement('link');
|
|
21
|
+
link.id = id;
|
|
22
|
+
link.rel = 'stylesheet';
|
|
23
|
+
link.href = getBasePath('assets/webawesome/styles/webawesome.css');
|
|
24
|
+
document.head.appendChild(link);
|
|
25
|
+
}
|
|
26
|
+
loadWebAwesomeStylesheet();
|
|
27
|
+
// Import all required Web Awesome components
|
|
28
|
+
import "@awesome.me/webawesome/dist/components/button/button.js";
|
|
29
|
+
import "@awesome.me/webawesome/dist/components/icon/icon.js";
|
|
30
|
+
import "@awesome.me/webawesome/dist/components/scroller/scroller.js";
|
|
31
|
+
import "@awesome.me/webawesome/dist/components/slider/slider.js";
|
|
32
|
+
import "@awesome.me/webawesome/dist/components/spinner/spinner.js";
|
|
33
|
+
import "@awesome.me/webawesome/dist/components/tab-group/tab-group.js";
|
|
34
|
+
import "@awesome.me/webawesome/dist/components/tab-panel/tab-panel.js";
|
|
35
|
+
import "@awesome.me/webawesome/dist/components/tab/tab.js";
|
|
36
|
+
import "@awesome.me/webawesome/dist/components/tooltip/tooltip.js";
|
|
17
37
|
export class OgmViewer {
|
|
18
38
|
el;
|
|
19
39
|
recordUrl;
|
|
@@ -63,14 +83,12 @@ export class OgmViewer {
|
|
|
63
83
|
const data = await response.json();
|
|
64
84
|
return new OgmRecord(data);
|
|
65
85
|
}
|
|
66
|
-
// Choose a preview component based on the record type
|
|
67
|
-
renderPreview() {
|
|
68
|
-
if (this.record && this.record.references.iiifOnly)
|
|
69
|
-
return h("ogm-image", { theme: this.theme, record: this.record, padding: this.sidebarPadding });
|
|
70
|
-
return h("ogm-map", { "preview-opacity": this.previewOpacity, theme: this.theme, record: this.record, padding: this.sidebarPadding });
|
|
71
|
-
}
|
|
72
86
|
render() {
|
|
73
|
-
return (
|
|
87
|
+
return (
|
|
88
|
+
// Applying the theme class to the host (rather than an internal div) lets the document-level
|
|
89
|
+
// Web Awesome stylesheet's `.wa-light`/`.wa-dark` rules match it directly, since the host sits
|
|
90
|
+
// in the consuming page's own light DOM while everything inside this shadow root does not.
|
|
91
|
+
h(Host, { key: 'db64abdf2b961976aa7359d089a57dcaf37fb175', class: `wa-${this.theme}` }, h("div", { key: '8fc67a48693890f017f481b91d0b870a79a5dc58', class: "container" }, h("ogm-menubar", { key: '9818fefb02eec280b73319c87e0a11b93bd69626', theme: this.theme, record: this.record, loading: this.loading }), h("div", { key: '5653ffea28fe78c8aa2d254db29e5c5d0ece96eb', class: "main-container" }, h("ogm-sidebar", { key: '97bda51d3b84e9d535e25bc1abb7615703485450', theme: this.theme, record: this.record, open: this.sidebarOpen }), h("ogm-previews", { key: '97f8dab53279ac2a9ce5f0a1da2e9f0dcb4ec5fd', theme: this.theme, record: this.record, "preview-opacity": this.previewOpacity, "sidebar-padding": this.sidebarPadding })))));
|
|
74
92
|
}
|
|
75
93
|
static get is() { return "ogm-viewer"; }
|
|
76
94
|
static get encapsulation() { return "shadow"; }
|
|
@@ -150,10 +168,8 @@ export class OgmViewer {
|
|
|
150
168
|
"id": "global::Promise"
|
|
151
169
|
},
|
|
152
170
|
"OgmRecord": {
|
|
153
|
-
"location": "
|
|
154
|
-
"
|
|
155
|
-
"id": "src/lib/record.ts::OgmRecord",
|
|
156
|
-
"referenceLocation": "OgmRecord"
|
|
171
|
+
"location": "global",
|
|
172
|
+
"id": "global::OgmRecord"
|
|
157
173
|
}
|
|
158
174
|
},
|
|
159
175
|
"return": "Promise<void>"
|
|
@@ -7,26 +7,33 @@ import Previewer from "./previewer";
|
|
|
7
7
|
// NOTE: can't be built currently due to a bug; see:
|
|
8
8
|
// https://github.com/OpenGeoMetadata/ogm-viewer/issues/100
|
|
9
9
|
export default class DeckCogPreviewer extends Previewer {
|
|
10
|
+
// Store reference to the map and styles
|
|
11
|
+
style;
|
|
10
12
|
map;
|
|
13
|
+
// Store reference to the deck.gl overlay and the layer ID for cleanup
|
|
11
14
|
deckOverlay;
|
|
12
15
|
layerId = undefined;
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
// Bounds so we don't recalculate them
|
|
17
|
+
bounds;
|
|
18
|
+
// Current opacity state
|
|
19
|
+
opacity;
|
|
20
|
+
// Initialize with opacity at the theme's opacity value
|
|
21
|
+
constructor(source, map, style) {
|
|
15
22
|
super(source);
|
|
16
23
|
this.map = map;
|
|
24
|
+
this.style = style;
|
|
25
|
+
this.opacity = this.style.opacity;
|
|
17
26
|
this.deckOverlay = this.getDeckOverlay();
|
|
18
27
|
}
|
|
19
28
|
async preview() {
|
|
20
29
|
if (!this.layerId) {
|
|
21
30
|
const layer = this.createLayer();
|
|
22
|
-
console.debug('Created COG preview layer', layer.id);
|
|
23
31
|
this.layerId = layer.id;
|
|
24
32
|
this.deckOverlay.setProps({ layers: [layer] });
|
|
25
33
|
}
|
|
26
34
|
}
|
|
27
35
|
async clearPreview() {
|
|
28
36
|
if (this.layerId) {
|
|
29
|
-
console.debug('Clearing COG preview layer', this.layerId);
|
|
30
37
|
this.deckOverlay.setProps({ layers: [] });
|
|
31
38
|
this.layerId = undefined;
|
|
32
39
|
}
|
|
@@ -37,9 +44,8 @@ export default class DeckCogPreviewer extends Previewer {
|
|
|
37
44
|
createLayer() {
|
|
38
45
|
return new COGLayer({
|
|
39
46
|
id: this.getSourceId(),
|
|
40
|
-
geotiff: this.source.
|
|
41
|
-
onGeoTIFFLoad: (
|
|
42
|
-
console.debug('COG loaded', data, options);
|
|
47
|
+
geotiff: this.source.getMapLibreSourceUrl(),
|
|
48
|
+
onGeoTIFFLoad: (_data, options) => {
|
|
43
49
|
const { west, south, east, north } = options.geographicBounds;
|
|
44
50
|
this.bounds = [
|
|
45
51
|
[west, south],
|
|
@@ -56,6 +62,7 @@ export default class DeckCogPreviewer extends Previewer {
|
|
|
56
62
|
}),
|
|
57
63
|
});
|
|
58
64
|
}
|
|
65
|
+
// We get bounds for free from geoTIFF metadata
|
|
59
66
|
async getBounds() {
|
|
60
67
|
return this.bounds;
|
|
61
68
|
}
|
|
@@ -64,7 +71,6 @@ export default class DeckCogPreviewer extends Previewer {
|
|
|
64
71
|
// No built-in way to query existing controls...
|
|
65
72
|
const overlay = this.map._controls.find(control => control instanceof DeckOverlay);
|
|
66
73
|
if (overlay) {
|
|
67
|
-
console.debug('Deck.gl overlay exists; skipping creation', overlay);
|
|
68
74
|
return overlay;
|
|
69
75
|
}
|
|
70
76
|
return this.createDeckOverlay();
|
|
@@ -73,7 +79,6 @@ export default class DeckCogPreviewer extends Previewer {
|
|
|
73
79
|
createDeckOverlay() {
|
|
74
80
|
const overlay = new DeckOverlay({ interleaved: true });
|
|
75
81
|
this.map.addControl(overlay);
|
|
76
|
-
console.debug('Deck.gl overlay created', overlay);
|
|
77
82
|
return overlay;
|
|
78
83
|
}
|
|
79
84
|
}
|
|
@@ -6,15 +6,15 @@ import RasterPreviewer from "./raster";
|
|
|
6
6
|
// See: https://github.com/geomatico/maplibre-cog-protocol
|
|
7
7
|
export default class CogPreviewer extends RasterPreviewer {
|
|
8
8
|
// Register the 'cog://' protocol handler with MapLibre when the previewer is created
|
|
9
|
-
constructor(source, map,
|
|
10
|
-
super(source, map,
|
|
9
|
+
constructor(source, map, style) {
|
|
10
|
+
super(source, map, style);
|
|
11
11
|
maplibregl.addProtocol('cog', cogProtocol);
|
|
12
12
|
}
|
|
13
13
|
// COG sources use 'url' instead of 'tiles' and have no scheme
|
|
14
14
|
async createSource() {
|
|
15
15
|
return {
|
|
16
16
|
type: 'raster',
|
|
17
|
-
url: await this.source.
|
|
17
|
+
url: await this.source.getMapLibreSourceUrl(),
|
|
18
18
|
tileSize: this.source.getTileSize(),
|
|
19
19
|
};
|
|
20
20
|
}
|
|
@@ -2,8 +2,9 @@ import VectorPreviewer from "./vector";
|
|
|
2
2
|
export default class GeoJSONPreviewer extends VectorPreviewer {
|
|
3
3
|
async createSource() {
|
|
4
4
|
return {
|
|
5
|
-
type: await this.source.
|
|
6
|
-
data: await this.source.
|
|
5
|
+
type: await this.source.getMapLibreSourceType(),
|
|
6
|
+
data: await this.source.getMapLibreSourceUrl(),
|
|
7
|
+
generateId: true,
|
|
7
8
|
};
|
|
8
9
|
}
|
|
9
10
|
}
|
|
@@ -1,42 +1,38 @@
|
|
|
1
1
|
import Previewer from "./previewer";
|
|
2
|
-
const defaultOptions = {
|
|
3
|
-
padding: 40,
|
|
4
|
-
opacity: 1,
|
|
5
|
-
};
|
|
6
2
|
export default class MapLibrePreviewer extends Previewer {
|
|
3
|
+
// Store reference to the map and styles
|
|
4
|
+
style;
|
|
7
5
|
map;
|
|
8
|
-
|
|
9
|
-
opacity;
|
|
6
|
+
// Stored state for added source and layers to allow for cleanup
|
|
10
7
|
sourceId = null;
|
|
11
8
|
layerIds = [];
|
|
12
|
-
|
|
9
|
+
// Current opacity state
|
|
10
|
+
opacity;
|
|
11
|
+
// Initialize with opacity at the theme's opacity value
|
|
12
|
+
constructor(source, map, style) {
|
|
13
13
|
super(source);
|
|
14
14
|
this.map = map;
|
|
15
|
-
this.
|
|
16
|
-
this.opacity = this.
|
|
15
|
+
this.style = style;
|
|
16
|
+
this.opacity = this.style.opacity;
|
|
17
17
|
}
|
|
18
18
|
// Add source and preview layers if they don't already exist
|
|
19
19
|
async preview() {
|
|
20
20
|
if (!this.sourceId) {
|
|
21
21
|
if (this.map.getSource(this.getSourceId())) {
|
|
22
|
-
console.debug(`MapLibre source ${this.getSourceId()} exists; skipping creation`);
|
|
23
22
|
return;
|
|
24
23
|
}
|
|
25
24
|
const source = await this.createSource();
|
|
26
25
|
this.map.addSource(this.getSourceId(), source);
|
|
27
26
|
this.sourceId = this.getSourceId();
|
|
28
|
-
console.debug('Added MapLibre source', this.getSourceId(), source);
|
|
29
27
|
}
|
|
30
28
|
if (this.layerIds.length == 0) {
|
|
31
29
|
const layers = await this.createLayers();
|
|
32
30
|
layers.forEach(layer => {
|
|
33
31
|
if (this.map.getLayer(layer.id)) {
|
|
34
|
-
console.debug(`MapLibre layer ${layer.id} exists; skipping creation`);
|
|
35
32
|
return;
|
|
36
33
|
}
|
|
37
34
|
this.map.addLayer(layer);
|
|
38
35
|
this.layerIds.push(layer.id);
|
|
39
|
-
console.debug('Added MapLibre layer', layer.id);
|
|
40
36
|
});
|
|
41
37
|
}
|
|
42
38
|
}
|
|
@@ -44,13 +40,11 @@ export default class MapLibrePreviewer extends Previewer {
|
|
|
44
40
|
async clearPreview() {
|
|
45
41
|
this.layerIds.forEach(layerId => {
|
|
46
42
|
if (this.map.getLayer(layerId)) {
|
|
47
|
-
console.debug('Removing MapLibre layer', layerId);
|
|
48
43
|
this.map.removeLayer(layerId);
|
|
49
44
|
}
|
|
50
45
|
});
|
|
51
46
|
this.layerIds = [];
|
|
52
47
|
if (this.sourceId && this.map.getSource(this.getSourceId())) {
|
|
53
|
-
console.debug('Removing MapLibre source', this.getSourceId());
|
|
54
48
|
this.map.removeSource(this.getSourceId());
|
|
55
49
|
this.sourceId = null;
|
|
56
50
|
}
|
|
@@ -3,7 +3,7 @@ export default class PMTilesVectorPreviewer extends VectorPreviewer {
|
|
|
3
3
|
async createSource() {
|
|
4
4
|
return {
|
|
5
5
|
type: 'vector',
|
|
6
|
-
url: this.source.
|
|
6
|
+
url: this.source.getMapLibreSourceUrl(),
|
|
7
7
|
encoding: await this.source.getVectorEncoding(),
|
|
8
8
|
};
|
|
9
9
|
}
|
|
@@ -14,6 +14,12 @@ export default class PMTilesVectorPreviewer extends VectorPreviewer {
|
|
|
14
14
|
'source-layer': layerId,
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
+
createPolygonOutlineLayer(layerId) {
|
|
18
|
+
return {
|
|
19
|
+
...super.createPolygonOutlineLayer(layerId),
|
|
20
|
+
'source-layer': layerId,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
17
23
|
createLineLayer(layerId) {
|
|
18
24
|
return {
|
|
19
25
|
...super.createLineLayer(layerId),
|
|
@@ -3,7 +3,7 @@ export default class RasterPreviewer extends MapLibrePreviewer {
|
|
|
3
3
|
async createSource() {
|
|
4
4
|
return {
|
|
5
5
|
type: 'raster',
|
|
6
|
-
tiles: [await this.source.
|
|
6
|
+
tiles: [await this.source.getMapLibreSourceUrl()],
|
|
7
7
|
scheme: this.source.getScheme(),
|
|
8
8
|
tileSize: this.source.getTileSize(),
|
|
9
9
|
};
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
import MapLibrePreviewer from "./maplibre";
|
|
2
|
-
const defaultOptions = {
|
|
3
|
-
fillColor: '#888888',
|
|
4
|
-
fillOpacity: 0.6,
|
|
5
|
-
fillHighlightOpacity: 0.8,
|
|
6
|
-
lineColor: '#000000',
|
|
7
|
-
labelFont: 'Noto Sans Regular',
|
|
8
|
-
labelSize: 10,
|
|
9
|
-
textColor: '#000000',
|
|
10
|
-
};
|
|
11
2
|
export default class VectorPreviewer extends MapLibrePreviewer {
|
|
12
|
-
constructor(source, map, options) {
|
|
13
|
-
super(source, map, options);
|
|
14
|
-
this.options = { ...defaultOptions, ...options };
|
|
15
|
-
}
|
|
16
3
|
// Set opacity of all layers in this previewer
|
|
17
4
|
async setOpacity(opacity) {
|
|
18
5
|
this.opacity = opacity;
|
|
@@ -28,6 +15,7 @@ export default class VectorPreviewer extends MapLibrePreviewer {
|
|
|
28
15
|
return layerIds.flatMap(layerId => {
|
|
29
16
|
return [
|
|
30
17
|
this.createPolygonLayer(layerId),
|
|
18
|
+
this.createPolygonOutlineLayer(layerId),
|
|
31
19
|
this.createLineLayer(layerId),
|
|
32
20
|
this.createPointLayer(layerId),
|
|
33
21
|
this.createPolygonLabelLayer(layerId),
|
|
@@ -43,9 +31,35 @@ export default class VectorPreviewer extends MapLibrePreviewer {
|
|
|
43
31
|
type: 'fill',
|
|
44
32
|
source: this.getSourceId(),
|
|
45
33
|
paint: {
|
|
46
|
-
'fill-color':
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
'fill-color': [
|
|
35
|
+
'case',
|
|
36
|
+
['boolean', ['feature-state', 'selected'], false],
|
|
37
|
+
this.style.fillSelectedColor,
|
|
38
|
+
['boolean', ['feature-state', 'hover'], false],
|
|
39
|
+
this.style.fillHighlightColor,
|
|
40
|
+
this.style.fillColor,
|
|
41
|
+
],
|
|
42
|
+
'fill-opacity': ['case', ['boolean', ['feature-state', 'selected'], false], this.style.fillHighlightOpacity, this.style.fillOpacity],
|
|
43
|
+
},
|
|
44
|
+
filter: ['==', ['geometry-type'], 'Polygon'],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Create a styled layer that will be used to outline polygon geometry
|
|
48
|
+
createPolygonOutlineLayer(layerId) {
|
|
49
|
+
return {
|
|
50
|
+
id: `${this.getSourceId()}-${layerId}-polygon-outlines`,
|
|
51
|
+
type: 'line',
|
|
52
|
+
source: this.getSourceId(),
|
|
53
|
+
paint: {
|
|
54
|
+
'line-color': [
|
|
55
|
+
'case',
|
|
56
|
+
['boolean', ['feature-state', 'selected'], false],
|
|
57
|
+
this.style.strokeSelectedColor,
|
|
58
|
+
['boolean', ['feature-state', 'hover'], false],
|
|
59
|
+
this.style.strokeHighlightColor,
|
|
60
|
+
this.style.strokeColor,
|
|
61
|
+
],
|
|
62
|
+
'line-width': ['case', ['boolean', ['feature-state', 'selected'], false], 2, 1],
|
|
49
63
|
},
|
|
50
64
|
filter: ['==', ['geometry-type'], 'Polygon'],
|
|
51
65
|
};
|
|
@@ -57,7 +71,14 @@ export default class VectorPreviewer extends MapLibrePreviewer {
|
|
|
57
71
|
type: 'line',
|
|
58
72
|
source: this.getSourceId(),
|
|
59
73
|
paint: {
|
|
60
|
-
'line-color':
|
|
74
|
+
'line-color': [
|
|
75
|
+
'case',
|
|
76
|
+
['boolean', ['feature-state', 'selected'], false],
|
|
77
|
+
this.style.strokeSelectedColor,
|
|
78
|
+
['boolean', ['feature-state', 'hover'], false],
|
|
79
|
+
this.style.strokeHighlightColor,
|
|
80
|
+
this.style.strokeColor,
|
|
81
|
+
],
|
|
61
82
|
'line-width': 4,
|
|
62
83
|
},
|
|
63
84
|
filter: ['==', ['geometry-type'], 'LineString'],
|
|
@@ -70,11 +91,25 @@ export default class VectorPreviewer extends MapLibrePreviewer {
|
|
|
70
91
|
type: 'circle',
|
|
71
92
|
source: this.getSourceId(),
|
|
72
93
|
paint: {
|
|
73
|
-
'circle-color':
|
|
74
|
-
|
|
75
|
-
|
|
94
|
+
'circle-color': [
|
|
95
|
+
'case',
|
|
96
|
+
['boolean', ['feature-state', 'selected'], false],
|
|
97
|
+
this.style.fillSelectedColor,
|
|
98
|
+
['boolean', ['feature-state', 'hover'], false],
|
|
99
|
+
this.style.fillHighlightColor,
|
|
100
|
+
this.style.fillColor,
|
|
101
|
+
],
|
|
102
|
+
'circle-stroke-color': [
|
|
103
|
+
'case',
|
|
104
|
+
['boolean', ['feature-state', 'selected'], false],
|
|
105
|
+
this.style.strokeSelectedColor,
|
|
106
|
+
['boolean', ['feature-state', 'hover'], false],
|
|
107
|
+
this.style.strokeHighlightColor,
|
|
108
|
+
this.style.strokeColor,
|
|
109
|
+
],
|
|
110
|
+
'circle-stroke-width': ['case', ['boolean', ['feature-state', 'selected'], false], 2, 1],
|
|
76
111
|
'circle-radius': ['interpolate', ['linear'], ['zoom'], 4, 2, 12, 4],
|
|
77
|
-
'circle-opacity': ['case', ['boolean', ['feature-state', '
|
|
112
|
+
'circle-opacity': ['case', ['boolean', ['feature-state', 'selected'], false], this.style.fillHighlightOpacity, this.style.fillOpacity],
|
|
78
113
|
},
|
|
79
114
|
filter: ['==', ['geometry-type'], 'Point'],
|
|
80
115
|
};
|
|
@@ -87,9 +122,9 @@ export default class VectorPreviewer extends MapLibrePreviewer {
|
|
|
87
122
|
source: this.getSourceId(),
|
|
88
123
|
layout: {
|
|
89
124
|
'text-field': ['get', 'id'],
|
|
90
|
-
'text-font': [this.
|
|
125
|
+
'text-font': [this.style.textFont],
|
|
91
126
|
'text-max-angle': 85,
|
|
92
|
-
'text-size': this.
|
|
127
|
+
'text-size': this.style.textSize,
|
|
93
128
|
'text-offset': [0, 1],
|
|
94
129
|
'text-anchor': 'bottom',
|
|
95
130
|
'text-rotation-alignment': 'map',
|
|
@@ -98,7 +133,7 @@ export default class VectorPreviewer extends MapLibrePreviewer {
|
|
|
98
133
|
'symbol-spacing': 250,
|
|
99
134
|
},
|
|
100
135
|
paint: {
|
|
101
|
-
'text-color': this.
|
|
136
|
+
'text-color': this.style.textColor,
|
|
102
137
|
'text-halo-color': 'white',
|
|
103
138
|
'text-halo-width': 1,
|
|
104
139
|
},
|
|
@@ -114,11 +149,11 @@ export default class VectorPreviewer extends MapLibrePreviewer {
|
|
|
114
149
|
layout: {
|
|
115
150
|
'symbol-placement': 'line',
|
|
116
151
|
'text-field': ['get', 'id'],
|
|
117
|
-
'text-font': [this.
|
|
118
|
-
'text-size': this.
|
|
152
|
+
'text-font': [this.style.textFont],
|
|
153
|
+
'text-size': this.style.textSize,
|
|
119
154
|
},
|
|
120
155
|
paint: {
|
|
121
|
-
'text-color': this.
|
|
156
|
+
'text-color': this.style.textColor,
|
|
122
157
|
'text-halo-color': 'white',
|
|
123
158
|
'text-halo-width': 1,
|
|
124
159
|
},
|
|
@@ -133,12 +168,12 @@ export default class VectorPreviewer extends MapLibrePreviewer {
|
|
|
133
168
|
source: this.getSourceId(),
|
|
134
169
|
layout: {
|
|
135
170
|
'text-field': ['get', 'id'],
|
|
136
|
-
'text-font': [this.
|
|
137
|
-
'text-size': this.
|
|
171
|
+
'text-font': [this.style.textFont],
|
|
172
|
+
'text-size': this.style.textSize,
|
|
138
173
|
'text-offset': [0, -1],
|
|
139
174
|
},
|
|
140
175
|
paint: {
|
|
141
|
-
'text-color': this.
|
|
176
|
+
'text-color': this.style.textColor,
|
|
142
177
|
'text-halo-color': 'white',
|
|
143
178
|
'text-halo-width': 1,
|
|
144
179
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from "@stencil/vitest";
|
|
2
|
-
import { OgmRecord } from "./record";
|
|
3
2
|
import { LngLatBounds } from "maplibre-gl";
|
|
3
|
+
import OgmRecord from "./record";
|
|
4
4
|
describe('OgmRecord', () => {
|
|
5
5
|
it('errors when initialized with an unsupported version', () => {
|
|
6
6
|
expect(() => {
|
|
@@ -35,8 +35,6 @@ const METADATA_REFERENCE_URIS = [
|
|
|
35
35
|
export class References {
|
|
36
36
|
// Underlying object to hold references
|
|
37
37
|
references;
|
|
38
|
-
// Cache for fetched IIIF manifest
|
|
39
|
-
iiifManifest;
|
|
40
38
|
// Create a new instance with the JSON string from a record
|
|
41
39
|
constructor(dct_references_s) {
|
|
42
40
|
try {
|
|
@@ -91,33 +89,6 @@ export class References {
|
|
|
91
89
|
get iiifManifestUrl() {
|
|
92
90
|
return this.references['http://iiif.io/api/presentation#manifest'];
|
|
93
91
|
}
|
|
94
|
-
// List of IIIF image URLs extracted from the manifest
|
|
95
|
-
async iiifImageUrls() {
|
|
96
|
-
if (this.iiifImageUrl)
|
|
97
|
-
return [this.iiifImageUrl];
|
|
98
|
-
if (!this.iiifManifestUrl)
|
|
99
|
-
return [];
|
|
100
|
-
// Fetch and cache the manifest if we haven't already
|
|
101
|
-
if (!this.iiifManifest) {
|
|
102
|
-
try {
|
|
103
|
-
await this.fetchManifest();
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
console.error('Failed to fetch IIIF manifest:', error);
|
|
107
|
-
return [];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
// Try to extract image URLs from the manifest
|
|
111
|
-
try {
|
|
112
|
-
if (this.iiifVersion == 3)
|
|
113
|
-
return this.extractIiif3ImageUrls(this.iiifManifest);
|
|
114
|
-
return this.extractIiif2ImageUrls(this.iiifManifest);
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
console.error('Failed to extract IIIF image URLs from manifest:', error);
|
|
118
|
-
return [];
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
92
|
// List of download links with URL and label, if using multiple downloads
|
|
122
93
|
get downloadLinks() {
|
|
123
94
|
const fieldContents = this.references['http://schema.org/downloadUrl'];
|
|
@@ -169,40 +140,4 @@ export class References {
|
|
|
169
140
|
get iiifReferences() {
|
|
170
141
|
return [this.iiifImageUrl, this.iiifManifestUrl];
|
|
171
142
|
}
|
|
172
|
-
// Get the IIIF presentation spec version of the manifest, if we have one
|
|
173
|
-
get iiifVersion() {
|
|
174
|
-
return this.iiifManifest['@context']?.includes('http://iiif.io/api/presentation/3/context.json') ? 3 : 2;
|
|
175
|
-
}
|
|
176
|
-
// Given a v2 manifest, extract all of the IIIF images and format as info.json URLs
|
|
177
|
-
extractIiif2ImageUrls(manifest) {
|
|
178
|
-
return (manifest.sequences
|
|
179
|
-
.flatMap(seq => seq.canvases)
|
|
180
|
-
.flatMap(can => can.images)
|
|
181
|
-
.flatMap(img => img.resource)
|
|
182
|
-
//@ts-ignore
|
|
183
|
-
.flatMap(res => (res['@type'] === 'dctypes:Image' ? res.service['@id'] + '/info.json' : [])));
|
|
184
|
-
}
|
|
185
|
-
// Given a v3 manifest, extract all of the IIIF images and format as info.json URLs
|
|
186
|
-
extractIiif3ImageUrls(manifest) {
|
|
187
|
-
// Recursively search the '.items' key until we end up with nodes that have type 'ImageService2'
|
|
188
|
-
return (manifest.items
|
|
189
|
-
.flatMap(canvas => canvas.items)
|
|
190
|
-
.flatMap(annotationPage => annotationPage?.items || [])
|
|
191
|
-
.flatMap(annotation => (Array.isArray(annotation.body) ? annotation.body : [annotation.body]))
|
|
192
|
-
//@ts-ignore
|
|
193
|
-
.flatMap(annotationBody => annotationBody.service)
|
|
194
|
-
.flatMap(service => service.id + '/info.json'));
|
|
195
|
-
}
|
|
196
|
-
// TODO: use navPlace as the bounds source if available
|
|
197
|
-
// Attempt to fetch and parse the IIIF manifest, if any
|
|
198
|
-
async fetchManifest() {
|
|
199
|
-
if (!this.iiifManifestUrl)
|
|
200
|
-
return;
|
|
201
|
-
const response = await fetch(this.iiifManifestUrl);
|
|
202
|
-
if (!response.ok)
|
|
203
|
-
throw new Error(`Unexpected response fetching IIIF manifest: ${response.statusText}`);
|
|
204
|
-
const manifest = await response.json();
|
|
205
|
-
this.iiifManifest = manifest;
|
|
206
|
-
return manifest;
|
|
207
|
-
}
|
|
208
143
|
}
|