Skip to content

Commit

Permalink
fix(location): improve location search result filtering and display (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn authored May 31, 2024
1 parent 779b983 commit 40403c6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/components/LocationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<v-card-text v-if="location">
<PriceCountChip :count="location.price_count" :withLabel="true" />
<v-chip label size="small" density="comfortable" class="mr-1" title="OpenStreetMap tag">
{{ location.osm_tag_key }}:{{ location.osm_tag_value }}
{{ getLocationCategory(location) }}
</v-chip>
</v-card-text>
</v-card>
Expand Down Expand Up @@ -39,6 +39,9 @@ export default {
}
return this.$route.params.id
},
getLocationCategory(location) {
return utils.getLocationCategory(location)
},
goToLocation(location) {
if (this.readonly) {
return
Expand Down
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ export default {
'apartments', 'barracks', 'bungalow', 'cabin', 'detached', 'dormitory', 'ger', 'house', 'houseboat', 'residential', // 'farm', 'hotel'
'fuel', 'gas', 'casino', 'parking', 'parking_space', 'charging_station', 'atm',
'car_sharing',
'yes',
],
}
2 changes: 1 addition & 1 deletion src/services/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export default {
})
.then((response) => response.json())
.then(data => data.features)
.then((data) => data.filter(l => !constants.NOMINATIM_RESULT_TYPE_EXCLUDE_LIST.includes(l.properties.osm_key)))
.then((data) => data.filter(l => !constants.NOMINATIM_RESULT_TYPE_EXCLUDE_LIST.includes(l.properties.osm_value)))
},
openstreetmapSearch(q, source='nominatim') {
if (source === 'photon') {
Expand Down
12 changes: 8 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,17 @@ function getLocationUniqueID(locationObject) {
}

function getLocationCategory(locationObject) {
// examples: shop, amenity, building
// examples: shop:supermarket, shop:convenience, shop:bakery, shop:doityourself
// Photon
if (locationObject.properties) {
return locationObject.properties.type
return `${locationObject.properties.osm_key}:${locationObject.properties.osm_value}`
}
// Nominatim or OP
return locationObject.type || locationObject.osm_type
// Nominatim
else if (locationObject.address) {
return `${locationObject.class}:${locationObject.type}`
}
// OP
return `${locationObject.osm_tag_key}:${locationObject.osm_tag_value}`
}

function getLocationLatLng(locationObject) {
Expand Down

0 comments on commit 40403c6

Please sign in to comment.