Skip to content

New option to setup default extent area for spatial query #587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: ol-stac
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ module.exports = {
socialSharing: ['email', 'bsky', 'mastodon', 'x'],
preprocessSTAC: null,
authConfig: null,
// defaultSearchExtent e.g. [12.227593034455793, 41.78656913683952, 12.652310726657447, 42.02970865107619]
defaultSearchExtent: null,
crs: {}
};
13 changes: 8 additions & 5 deletions src/components/SearchFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</b-form-group>

<b-form-group v-if="canFilterExtents" class="filter-bbox" :label="$t('search.spatialExtent')" :label-for="ids.bbox">
<b-form-checkbox :id="ids.bbox" v-model="provideBBox" value="1">{{ $t('search.filterBySpatialExtent') }}</b-form-checkbox>
<MapSelect class="mb-4" v-if="provideBBox" v-model="query.bbox" :stac="stac" />
<b-form-checkbox :id="ids.bbox" v-model="provideBBox" checked="provideBBox">{{ $t('search.filterBySpatialExtent') }}</b-form-checkbox>
<MapSelect class="mb-4" v-if="provideBBox" v-model="query.bbox" :stac="stac" :initExtent="defaultExtent" />
</b-form-group>

<b-form-group v-if="conformances.CollectionIdFilter" class="filter-collection" :label="$tc('stacCollection', collections.length)" :label-for="ids.collections">
Expand Down Expand Up @@ -216,7 +216,7 @@ export default {
},
computed: {
...mapState(['itemsPerPage', 'maxItemsPerPage', 'uiLanguage']),
...mapGetters(['canSearchCollections', 'supportsConformance']),
...mapGetters(['canSearchCollections', 'supportsConformance', 'defaultSearchExtent']),
collectionSelectOptions() {
let taggable = !this.hasAllCollections;
let isResult = this.collections.length > 0 && !this.hasAllCollections;
Expand Down Expand Up @@ -257,6 +257,9 @@ export default {
}
return null;
},
defaultExtent() {
return this.query?.bbox? this.query.bbox : this.defaultSearchExtent;
},
andOrOptions() {
return [
{ value: 'and', text: this.$t('search.logical.and') },
Expand Down Expand Up @@ -291,7 +294,7 @@ export default {
set(val) {
this.query.datetime = Array.isArray(val) ? val.map(d => Utils.dateToUTC(d)) : null;
}
}
},
},
watch: {
parent: {
Expand Down Expand Up @@ -337,7 +340,7 @@ export default {
this.query.bbox = null;
}
else {
this.query.bbox = this.bbox;
this.query.bbox = this.bbox? this.bbox : this.defaultExtent;
}
}
},
Expand Down
13 changes: 11 additions & 2 deletions src/components/maps/MapSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export default {
type: Object,
default: null
},
initExtent: {
type: Array,
default: null
},
value: {
type: Array,
default: null
Expand All @@ -50,8 +54,8 @@ export default {
data() {
return {
crs: 'EPSG:4326',
extent: this.value,
dragging: false
extent: this.initExtent,
dragging: true
};
},
computed: {
Expand Down Expand Up @@ -82,6 +86,9 @@ export default {
methods: {
async initMap() {
this.map = null;
if (this.initExtent) {
this.extent = this.initExtent;
}

await this.createMap(this.$refs.map, this.stac, true);

Expand Down Expand Up @@ -140,8 +147,10 @@ export default {
}
}
if (extent) {
this.map.updateSize();
this.map.getView().fit(extent, { padding: [50,50,50,50] });
}

},
addMask(stac) {
// Darken areas outside of the available area
Expand Down
10 changes: 10 additions & 0 deletions src/locales/it/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,17 @@
"label": "i",
"collapseLabel": "✕"
},
"bboxSelect": {
"add": "Cliccare sulla mappa per aggiungere un box di selezione.",
"remove": "Cliccare dentro il box per eliminarlo."
},
"close": "Chiudi",
"fit": "Adatta alla estensione",
"location": {
"description": "Vai alla tua posizione attuale"
},
"nobasemap": "Mappa base non disponibile.",
"nodata": "Indormazione spaziale mancante nei metadati.",
"zoom": {
"in": {
"description": "Zoom avanti",
Expand Down
3 changes: 3 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ function getStore(config, router) {
uiLanguage: config.locale
}),
getters: {
defaultSearchExtent: state => {
return state.defaultSearchExtent? state.defaultSearchExtent : null;
},
loading: state => !state.url || !state.data || state.database[state.url] instanceof Loading,
getApiItemsLoading: state => data => {
let id = '';
Expand Down