Add more place types, refactor tag usage

This commit is contained in:
2026-02-23 17:53:46 +04:00
parent ecb3fe4b5a
commit 323aab8256
6 changed files with 113 additions and 42 deletions

View File

@@ -1,5 +1,5 @@
import Service, { service } from '@ember/service';
import { getLocalizedName } from '../utils/osm';
import { getLocalizedName, getPlaceType } from '../utils/osm';
export default class OsmService extends Service {
@service settings;
@@ -61,15 +61,20 @@ out center;
}
normalizePoi(poi) {
const tags = poi.tags || {};
const type = getPlaceType(tags) || 'Point of Interest';
return {
title: getLocalizedName(poi.tags),
title: getLocalizedName(tags),
lat: poi.lat || poi.center?.lat,
lon: poi.lon || poi.center?.lon,
url: poi.tags?.website,
url: tags.website,
osmId: String(poi.id),
osmType: poi.type,
osmTags: poi.tags || {},
description: poi.tags?.description,
osmTags: tags,
description: tags.description,
source: 'osm',
type: type,
};
}
@@ -224,15 +229,20 @@ out center;
}
}
const tags = mainElement.tags || {};
const type = getPlaceType(tags) || 'Point of Interest';
return {
title: getLocalizedName(mainElement.tags),
title: getLocalizedName(tags),
lat,
lon,
url: mainElement.tags?.website,
url: tags.website,
osmId: String(mainElement.id),
osmType: mainElement.type,
osmTags: mainElement.tags || {},
description: mainElement.tags?.description,
osmTags: tags,
description: tags.description,
source: 'osm',
type: type,
};
}
}

View File

@@ -1,4 +1,6 @@
import Service from '@ember/service';
import { getPlaceType } from '../utils/osm';
import { humanizeOsmTag } from '../utils/format-text';
export default class PhotonService extends Service {
baseUrl = 'https://photon.komoot.io/api/';
@@ -67,15 +69,24 @@ export default class PhotonService extends Service {
R: 'relation',
};
const osmTags = { ...props };
// Photon often returns osm_key and osm_value for the main tag
if (props.osm_key && props.osm_value) {
osmTags[props.osm_key] = props.osm_value;
}
const type = getPlaceType(osmTags) || humanizeOsmTag(props.osm_value);
return {
title,
lat,
lon,
osmId: props.osm_id,
osmType: osmTypeMap[props.osm_type] || props.osm_type, // 'node', 'way', 'relation'
osmTags: props, // Keep all properties as tags for now
osmTags,
description: props.name ? description : addressParts.slice(1).join(', '),
source: 'photon',
type: type,
};
}