26 lines
991 B
TypeScript
26 lines
991 B
TypeScript
import type { PoiRepository } from '@/domain/poi'
|
|||
|
|
|
||
|
|
export const LEGACY_PLACE_ID_TO_POI_ID: Readonly<Record<string, string>> = Object.freeze({
|
||
|
|
'guangming-science-park': 'poi_amap_b0j2jc4n0w',
|
||
|
|
'guangming-happy-farm': 'poi_happy_pastoral',
|
||
|
|
'guangming-farm-grand-view': 'poi_farm_grand_view',
|
||
|
|
'guangming-hongqiao-park': 'poi_hongqiao_park',
|
||
|
|
'guangming-dadingling-greenway': 'poi_dadingling_greenway',
|
||
|
|
'guangming-culture-art-center': 'poi_gm_culture_center',
|
||
|
|
'guangming-honghua-park': 'poi_honghuashan_park',
|
||
|
|
'guangming-zuoan-tech-park': 'poi_amap_b0g0kzrt5s',
|
||
|
|
'guangming-minghu-park': 'poi_amap_b0fffwu1l5',
|
||
|
|
})
|
||
|
|
|
||
|
|
export function resolveCanonicalPoiId(placeId: string, repository: PoiRepository): string | null {
|
||
|
|
const normalized = placeId.trim()
|
||
|
|
if (!normalized)
|
||
|
|
return null
|
||
|
|
|
||
|
|
if (repository.getPoiById(normalized))
|
||
|
|
return normalized
|
||
|
|
|
||
|
|
const mappedId = LEGACY_PLACE_ID_TO_POI_ID[normalized]
|
||
|
|
return mappedId && repository.getPoiById(mappedId) ? mappedId : null
|
||
|
|
}
|