Add more place types, refactor tag usage
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user