Skip to content

Commit 112d0a7

Browse files
committed
Support visualizing collection results on a map
1 parent 44b90e5 commit 112d0a7

File tree

6 files changed

+58
-32
lines changed

6 files changed

+58
-32
lines changed

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"commonmark": "^0.31.2",
5252
"oidc-client-ts": "^3.0.1",
5353
"ol": "~10.6.0",
54-
"ol-stac": "^1.0.5",
54+
"ol-stac": "^1.1.0",
5555
"proj4": "^2.15.0",
5656
"remove-markdown": "^0.6.2",
5757
"stac-js": "~0.1.9",

src/components/Catalogs.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<header>
44
<h2 class="title me-2">{{ title }}</h2>
55
<b-badge v-if="catalogCount !== null" pill variant="secondary" class="me-4">{{ catalogCount }}</b-badge>
6-
<ViewButtons class="me-2" v-model="view" />
7-
<SortButtons v-if="isComplete && catalogs.length > 1" v-model="sort" />
6+
<ViewButtons v-if="!hideControls" class="me-2" v-model="view" />
7+
<SortButtons v-if="!hideControls && isComplete && catalogs.length > 1" v-model="sort" />
88
</header>
9-
<section v-if="isComplete && catalogs.length > 1" class="catalog-filter mb-2">
9+
<section v-if="!hideControls && isComplete && catalogs.length > 1" class="catalog-filter mb-2">
1010
<SearchBox v-model="searchTerm" :placeholder="filterPlaceholder" />
1111
<multiselect
1212
v-if="allKeywords.length > 0"
@@ -68,6 +68,14 @@ export default defineComponent({
6868
type: Boolean,
6969
required: false
7070
},
71+
enforceCards: {
72+
type: Boolean,
73+
default: false
74+
},
75+
hideControls: {
76+
type: Boolean,
77+
default: false
78+
},
7179
loading: {
7280
type: Boolean,
7381
default: false
@@ -194,9 +202,15 @@ export default defineComponent({
194202
},
195203
view: {
196204
get() {
205+
if (this.enforceCards) {
206+
return 'cards';
207+
}
197208
return this.$store.state.cardViewMode;
198209
},
199210
async set(cardViewMode) {
211+
if (this.enforceCards) {
212+
return;
213+
}
200214
await this.$store.dispatch('config', { cardViewMode });
201215
}
202216
}

src/components/MapView.vue

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
:target="selection.target" :teleport-to="container" class="map-popover"
1313
:boundary-padding="10"
1414
>
15-
<section class="popover-items">
16-
<Items v-if="selection && selection.type === 'items'" :stac="stac" :items="selection.items" />
17-
<Features v-else-if="selection" :features="selection.items" />
15+
<section class="popover-children">
16+
<Items v-if="selection && selection.type === 'items'" :stac="stac" :items="selection.children" />
17+
<Catalogs v-if="selection && selection.type === 'collections'" collectionsOnly enforceCards hideControls :stac="stac" :catalogs="selection.children" />
18+
<Features v-else-if="selection" :features="selection.children" />
1819
</section>
1920
<div class="text-center">
2021
<b-button variant="danger" @click="resetSelection">{{ $t('mapping.close') }}</b-button>
@@ -44,6 +45,7 @@ export default {
4445
components: {
4546
BPopover: defineAsyncComponent(() => import('bootstrap-vue-next').then(m => m.BPopover)),
4647
Features: defineAsyncComponent(() => import('../components/Features.vue')),
48+
Catalogs: defineAsyncComponent(() => import('../components/Catalogs.vue')),
4749
Items: defineAsyncComponent(() => import('../components/Items.vue')),
4850
LayerControl,
4951
TextControl
@@ -60,7 +62,7 @@ export default {
6062
type: Array,
6163
default: null
6264
},
63-
items: {
65+
children: {
6466
type: Object,
6567
default: null
6668
},
@@ -109,12 +111,12 @@ export default {
109111
}
110112
await this.stacLayer.setAssets(this.assets);
111113
},
112-
async items() {
114+
async children() {
113115
if (!this.stacLayer) {
114116
return;
115117
}
116118
await this.stacLayer.setAssets(null, false);
117-
await this.stacLayer.setChildren(this.items, this.childrenOptions, false);
119+
await this.stacLayer.setChildren(this.children, this.childrenOptions, false);
118120
await this.stacLayer.updateLayers();
119121
this.fit();
120122
},
@@ -152,7 +154,7 @@ export default {
152154
// Don't set the URL here, as it is already set in the STAC object and is read-only.
153155
// url: this.stac.getAbsoluteUrl(),
154156
data: this.stac,
155-
children: this.items,
157+
children: this.children,
156158
assets: this.assets || null,
157159
displayWebMapLink: true,
158160
disableMigration: true,
@@ -175,7 +177,7 @@ export default {
175177
multi: true,
176178
style: selectStyle,
177179
layers: (layer) => {
178-
if (this.items) {
180+
if (this.children) {
179181
// For item selection
180182
return false;
181183
}
@@ -204,7 +206,7 @@ export default {
204206
this.map.on('singleclick', async (event) => {
205207
// For item selection
206208
this.selection = null;
207-
if (this.items) {
209+
if (this.children) {
208210
this.setTargetPosition(event);
209211
this.selector.getFeatures().clear();
210212
const features = this.selector.getFeatures();
@@ -213,8 +215,8 @@ export default {
213215
if (objects.length > 0) {
214216
this.selection = {
215217
target: this.$refs.target,
216-
type: 'items',
217-
items: objects
218+
type: this.children.isCollectionCollection() ? 'collections': 'items',
219+
children: objects
218220
};
219221
}
220222
}
@@ -271,15 +273,15 @@ export default {
271273
left: -1px;
272274
}
273275
274-
.popover-items {
276+
.popover-children {
275277
max-height: 500px;
276278
overflow: auto;
277279
margin-top: -0.5rem;
278280
margin-left: -0.75rem;
279281
margin-right: -0.75rem;
280282
padding: 0.5rem 0.75rem 0 0.75rem;
281283
282-
.items, .features {
284+
.items, .features, .catalogs {
283285
margin-bottom: 0 !important;
284286
}
285287

src/views/Catalog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export default defineComponent({
227227
else {
228228
const items = this.items.filter(item => item.type === 'Feature');
229229
if (items.length > 0) {
230-
data.items = new ItemCollection({
230+
data.children = new ItemCollection({
231231
type: 'FeatureCollection',
232232
features: items
233233
});

src/views/Search.vue

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
<b-alert v-else-if="results.length === 0 && noFurtherItems" variant="info" show>{{ $t('search.noFurtherItemsFound') }}</b-alert>
2727
<b-alert v-else-if="results.length === 0" variant="warning" show>{{ $t('search.noItemsFound') }}</b-alert>
2828
<template v-else>
29-
<div id="search-map" v-if="itemCollection">
30-
<MapView :stac="parent" :items="itemCollection" onfocusOnly popover />
29+
<div id="search-map" v-if="resultCollection">
30+
<MapView :stac="parent" :children="resultCollection" onfocusOnly popover />
3131
</div>
3232
<Catalogs
3333
v-if="isCollectionSearch" :catalogs="results" collectionsOnly
@@ -67,7 +67,7 @@ import Utils from '../utils';
6767
import SearchFilter from '../components/SearchFilter.vue';
6868
import Loading from '../components/Loading.vue';
6969
import ErrorAlert from '../components/ErrorAlert.vue';
70-
import { getDisplayTitle, createSTAC, ItemCollection } from '../models/stac';
70+
import { getDisplayTitle, createSTAC, CollectionCollection, ItemCollection } from '../models/stac';
7171
import { STAC } from 'stac-js';
7272
import { defineComponent, defineAsyncComponent } from 'vue';
7373
import { getErrorCode, getErrorMessage, processSTAC, stacRequest } from '../store/utils';
@@ -128,15 +128,20 @@ export default defineComponent({
128128
itemSearch() {
129129
return this.canSearchItems && this.parent && this.parent.getSearchLink();
130130
},
131-
itemCollection() {
131+
resultCollection() {
132132
if (this.isCollectionSearch) {
133-
return null; // wait for stac-js to convert bboxes to geojson
133+
return new CollectionCollection({
134+
collections: this.results,
135+
links: []
136+
});
137+
}
138+
else {
139+
return new ItemCollection({
140+
type: 'FeatureCollection',
141+
features: this.results,
142+
links: []
143+
});
134144
}
135-
return new ItemCollection({
136-
type: 'FeatureCollection',
137-
features: this.results,
138-
links: []
139-
});
140145
},
141146
results() {
142147
if (Utils.size(this.data) === 0) {
@@ -307,6 +312,10 @@ export default defineComponent({
307312
}
308313
}
309314
315+
#search-map {
316+
margin-bottom: $block-margin;
317+
}
318+
310319
#stac-browser .search {
311320
.selected-collections-action {
312321
position: fixed;

0 commit comments

Comments
 (0)