Skip to content
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

Add Manual bbox entry option to search page #389

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4ca7a34
WIP: add param on submit and clear on reset
stephenkilbourn Oct 25, 2023
03efc9a
implement loading filter values from params
stephenkilbourn Nov 2, 2023
94318fb
check & show geospatial map based on url param
stephenkilbourn Nov 3, 2023
dcec953
overwrite defaults with url params
stephenkilbourn Nov 3, 2023
8d6af73
submit form on load if query params present
stephenkilbourn Nov 3, 2023
01bd9da
allow bbox input via text or map
stephenkilbourn Nov 9, 2023
1bdf78f
set datetime to date object array when reading query param string
stephenkilbourn Nov 9, 2023
c54484b
move bbox entry to component
stephenkilbourn Nov 9, 2023
71df2ed
fix linting error
stephenkilbourn Nov 9, 2023
cfc913d
add manual BBoxEntry Component to search
stephenkilbourn Nov 10, 2023
933adc4
switch to tabs
stephenkilbourn Nov 13, 2023
8068ac4
remove console log
stephenkilbourn Nov 13, 2023
caca3a4
move defaults to component, validate prop, remove unused style import
stephenkilbourn Nov 14, 2023
fb0683e
Update src/components/BBoxEntry.vue
stephenkilbourn Nov 14, 2023
5a96538
map tab to initialize with query.bbox and set areaselect to that bbox
stephenkilbourn Nov 23, 2023
a07190e
Merge branch 'manual-bbox-entry' of github.com:stephenkilbourn/stac-b…
stephenkilbourn Nov 23, 2023
3fc9e29
move bbox labels to locales
stephenkilbourn Jan 12, 2024
23866c3
update setInitialBounds to use leaflet bounds methods
stephenkilbourn Jan 12, 2024
f25404a
fix: lat, lon were swapped
stephenkilbourn Jan 12, 2024
75ddf39
remove unused watcher & default bbox value
stephenkilbourn Jan 12, 2024
fed9d9d
use setBBox() instead of $set()
stephenkilbourn Jan 12, 2024
5230e3b
no need to initialize _bbox
stephenkilbourn Jan 12, 2024
3f58ecb
ensure map is centered on bounds from Bbox entry before rendering
stephenkilbourn Jan 24, 2024
569b34f
round value from bounding box
stephenkilbourn Jan 24, 2024
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
85 changes: 85 additions & 0 deletions src/components/BBoxEntry.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<template>
<b-form-group>
<b-form-row>
<b-col>
<b-form-group label="x_min" label-for="x_min">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this is usually done in forms, but x_min seems a little too technical as a user readable label.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked around and didn't find a clear answer. I could do something like Lat max/min and Lon max/min. Would that be clearer to most users?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe follow the specification terms? I guess there are names hidden in the API spec documents.

Copy link
Author

@stephenkilbourn stephenkilbourn Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the geojson spec, the bounding box uses the terms "southwest" and "northeast" and avoids min/max to avoid confusion when crossing the antimeridian. I've updated the labels to Southwest latitude/longitude and Northeast latitude/longitude to match that.
bbox

<b-form-input
id="x_min"
@input="updateBBoxArray($event, 0)"
:value="bbox[0]"
type="number"
no-wheel
step="any"
min="-180"
max="180"
/>
</b-form-group>
</b-col>
<b-col>
<b-form-group label="y_min" label-for="y_min">
<b-form-input
id="y_min"
@input="updateBBoxArray($event, 1)"
:value="bbox[1]"
type="number"
no-wheel
step="any"
min="-90"
max="90"
/>
</b-form-group>
</b-col>
<b-col>
<b-form-group label="x_max" label-for="x_max">
<b-form-input
id="x_max"
@input="updateBBoxArray($event, 2)"
:value="bbox[2]"
type="number"
no-wheel
step="any"
min="-180"
max="180"
/>
</b-form-group>
</b-col>
<b-col>
<b-form-group label="y_max" label-for="y_max">
<b-form-input
id="y_max"
@input="updateBBoxArray($event, 3)"
:value="bbox[3]"
type="number"
no-wheel
step="any"
min="-90"
max="90"
/>
</b-form-group>
</b-col>
</b-form-row>
</b-form-group>
</template>

<script>
import { BFormInput, BFormGroup} from 'bootstrap-vue';

export default {
name: 'BBoxEntry',
components: {
BFormGroup,
BFormInput,
},
props: {
bbox: {
type: Array,
required: true
}
},
methods: {
updateBBoxArray($event, position) {
this.$emit('updateBBoxArray', $event, position);
}
}
};
</script>
31 changes: 27 additions & 4 deletions src/components/SearchFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,22 @@
</b-form-group>

<b-form-group v-if="canFilterExtents" :label="$t('search.spatialExtent')" :label-for="ids.bbox">
<b-form-checkbox :id="ids.bbox" v-model="provideBBox" value="1" @change="setBBox()">{{ $t('search.filterBySpatialExtent') }}</b-form-checkbox>
<Map class="mb-4" v-if="provideBBox" :stac="stac" selectBounds @bounds="setBBox" scrollWheelZoom />
<b-form-checkbox :id="ids.bbox" v-model="provideBBox" @change="setBBox()">{{ $t('search.filterBySpatialExtent') }}</b-form-checkbox>
m-mohr marked this conversation as resolved.
Show resolved Hide resolved
<template>
<b-form-group v-if="provideBBox">
<b-form-radio-group
v-model="bboxSelectionStyle"
buttons
size="sm"
button-variant="outline-primary"
>
<b-form-radio value="map">{{ $t('search.defineBbox.map') }}</b-form-radio>
<b-form-radio value="text">{{ $t('search.defineBbox.text') }}</b-form-radio>
</b-form-radio-group>
</b-form-group>
<BBoxEntry v-if="provideBBox && bboxSelectionStyle === 'text'" :bbox="query.bbox || [180, 80, 180, 80]" @updateBBoxArray="updateBBoxArray" />
<Map class="mb-4" v-if="provideBBox && bboxSelectionStyle === 'map'" :stac="stac" selectBounds @bounds="setBBox" scrollWheelZoom />
</template>
</b-form-group>

<b-form-group v-if="conformances.CollectionIdFilter" :label="$tc('stacCollection', collections.length)" :label-for="ids.collections">
Expand Down Expand Up @@ -118,11 +132,12 @@
</template>

<script>
import { BBadge, BDropdown, BDropdownItem, BForm, BFormGroup, BFormInput, BFormCheckbox, BFormRadioGroup } from 'bootstrap-vue';
import { BBadge, BDropdown, BDropdownItem, BForm, BFormGroup, BFormInput, BFormCheckbox, BFormRadioGroup, BFormRadio } from 'bootstrap-vue';
import Multiselect from 'vue-multiselect';
import { mapGetters, mapState } from "vuex";
import refParser from '@apidevtools/json-schema-ref-parser';

import BBoxEntry from './BBoxEntry.vue';
import Utils, { schemaMediaType } from '../utils';
import { ogcQueryables } from "../rels";

Expand Down Expand Up @@ -159,7 +174,8 @@ function getDefaults() {
query: getQueryDefaults(),
filtersAndOr: 'and',
filters: [],
selectedCollections: []
selectedCollections: [],
bboxSelectionStyle: 'map'
};
}

Expand All @@ -169,13 +185,15 @@ export default {
name: 'SearchFilter',
components: {
BBadge,
BBoxEntry,
BDropdown,
BDropdownItem,
BForm,
BFormGroup,
BFormInput,
BFormCheckbox,
BFormRadioGroup,
BFormRadio,
QueryableInput: () => import('./QueryableInput.vue'),
Loading,
Map: () => import('./Map.vue'),
Expand Down Expand Up @@ -518,6 +536,11 @@ export default {
setSearchTerms(terms) {
this.$set(this.query, 'q', terms);
},
updateBBoxArray(entry, position) {
const bbox = this.query.bbox;
bbox[position] = Number(entry);
this.$set(this.query, 'bbox', bbox);
m-mohr marked this conversation as resolved.
Show resolved Hide resolved
},
setBBox(bounds) {
let bbox = null;
if (this.provideBBox) {
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@
"addSearchTerm": "Press enter to add a search term",
"additionalFilters": "Additional filters",
"dateDescription": "All times in Coordinated Universal Time (UTC).",
"defineBbox": {
"map": "Draw bounding box on map",
"text": "Enter coordinates"
},
"enterCollections": "Enter one or more Collection IDs...",
"enterItemIds": "Enter one or more Item IDs...",
"enterSearchTerms": "Enter one or more search terms...",
Expand Down