Files
marco/app/utils/photo-tag-suggestions.js
T
raucao bf1fcbcb40
CI / Lint (pull_request) Successful in 1m1s
CI / Test (pull_request) Successful in 1m15s
Release Drafter / Update release notes draft (pull_request) Successful in 5s
Improve photo tags
2026-08-23 10:21:40 -06:00

33 lines
965 B
JavaScript

import { POI_CATEGORIES } from './poi-categories';
import { getMatchingPoiCategoryIds } from './poi-category-matcher';
export const CATEGORY_TAGS = {
restaurants: ['front', 'food', 'drinks', 'menu', 'vibe'],
coffee: ['front', 'food', 'drinks', 'menu', 'vibe'],
groceries: ['front', 'products'],
'things-to-do': ['front', 'architecture', 'amenities', 'vibe'],
accommodation: ['front', 'rooms', 'amenities', 'food', 'drinks', 'vibe'],
};
export function getSuggestedPhotoTags(place) {
const osmTags = place?.osmTags || place?.tags || {};
const categoryIds = getMatchingPoiCategoryIds(osmTags, POI_CATEGORIES);
const suggested = [];
for (const categoryId of categoryIds) {
const tags = CATEGORY_TAGS[categoryId];
if (!Array.isArray(tags)) continue;
for (const tag of tags) {
if (!suggested.includes(tag)) {
suggested.push(tag);
}
}
}
if (suggested.length === 0) {
return [];
}
return suggested;
}