整改点位搜索数据加载与分类逻辑
This commit is contained in:
@@ -7,6 +7,9 @@ import type {
|
||||
import type {
|
||||
MuseumPoi
|
||||
} from '@/domain/museum'
|
||||
import {
|
||||
isVisitorSearchPoi
|
||||
} from '@/domain/poiCategories'
|
||||
import {
|
||||
getPoiDisplayPolicy
|
||||
} from '@/domain/poiDisplay'
|
||||
@@ -31,12 +34,12 @@ import {
|
||||
} from '@/data/providers/sgsSdkApiProvider'
|
||||
import {
|
||||
formatNavFloorLabel,
|
||||
isStaticIndoorNavigableFloorId
|
||||
isStaticIndoorNavigableFloorId,
|
||||
toMuseumPoi
|
||||
} from '@/data/adapters/navAssetsAdapter'
|
||||
import {
|
||||
defaultStaticNavAssetsProvider,
|
||||
type StaticNavAssetsProvider,
|
||||
type StaticNavPoiPayload
|
||||
type StaticNavAssetsProvider
|
||||
} from '@/data/providers/staticNavAssetsProvider'
|
||||
import {
|
||||
mapWithConcurrency
|
||||
@@ -59,26 +62,6 @@ const getNow = () => (
|
||||
: Date.now()
|
||||
)
|
||||
|
||||
const toRenderPoi = (poi: StaticNavPoiPayload): GuideRenderPoi => {
|
||||
const kind = poi.primaryCategory === 'touring_poi' ? 'hall' : 'facility'
|
||||
return {
|
||||
id: poi.id,
|
||||
name: poi.name,
|
||||
floorId: poi.floorId,
|
||||
primaryCategory: poi.primaryCategory,
|
||||
primaryCategoryZh: poi.primaryCategoryZh,
|
||||
iconType: poi.iconType || poi.primaryCategory,
|
||||
positionGltf: poi.positionGltf,
|
||||
sourceObjectName: poi.sourceObjectName,
|
||||
kind,
|
||||
hallName: poi.primaryCategory === 'touring_poi' ? poi.name : undefined,
|
||||
displayPolicy: getPoiDisplayPolicy({
|
||||
primaryCategory: poi.primaryCategory,
|
||||
kind
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const toGuideRenderPoi = (poi: MuseumPoi): GuideRenderPoi => ({
|
||||
id: poi.id,
|
||||
name: poi.name,
|
||||
@@ -104,10 +87,17 @@ const toGuideRenderPoi = (poi: MuseumPoi): GuideRenderPoi => ({
|
||||
const toSgsRenderPoi = (poi: ReturnType<typeof toMuseumPoiFromSgs>) => toGuideRenderPoi(poi)
|
||||
|
||||
const getRenderPoiDedupeKeys = (poi: GuideRenderPoi) => {
|
||||
// A facility can be located inside the same spatial area as other facilities.
|
||||
// That relationship must not collapse distinct visitor markers (for example,
|
||||
// a restroom and an elevator in one service zone). Space identity is only a
|
||||
// canonical-place key for halls, spaces, and business-place representations.
|
||||
const canDedupeBySpace = poi.kind === 'hall'
|
||||
|| poi.kind === 'space'
|
||||
|| poi.primaryCategory === 'business_poi'
|
||||
const stableKeys = [
|
||||
poi.id ? `id:${poi.id}` : '',
|
||||
poi.sourceSpaceId ? `space:${poi.floorId}:${poi.sourceSpaceId}` : '',
|
||||
poi.spaceId ? `space:${poi.floorId}:${poi.spaceId}` : '',
|
||||
canDedupeBySpace && poi.sourceSpaceId ? `space:${poi.floorId}:${poi.sourceSpaceId}` : '',
|
||||
canDedupeBySpace && poi.spaceId ? `space:${poi.floorId}:${poi.spaceId}` : '',
|
||||
poi.sourcePlaceId ? `place:${poi.floorId}:${poi.sourcePlaceId}` : ''
|
||||
].filter(Boolean)
|
||||
|
||||
@@ -303,7 +293,9 @@ export class StaticGuideModelRepository implements GuideModelRepository {
|
||||
|
||||
const pois = await this.provider.loadFloorPois(floor.poiDataAsset)
|
||||
return pois
|
||||
.map(toRenderPoi)
|
||||
.map(toMuseumPoi)
|
||||
.filter(isVisitorSearchPoi)
|
||||
.map(toGuideRenderPoi)
|
||||
.filter((poi) => Array.isArray(poi.positionGltf) && poi.positionGltf.length === 3)
|
||||
}
|
||||
}
|
||||
@@ -472,12 +464,19 @@ export class SgsSdkGuideModelRepository implements GuideModelRepository {
|
||||
loadFloorData('guidePois', () => this.guide.listPois()),
|
||||
loadFloorData('guideSpacePoints', () => this.guide.listSpacePoints())
|
||||
])
|
||||
const ordinaryPois = pois.map((poi) => toSgsRenderPoi(toMuseumPoiFromSgs(poi, manifest.floors)))
|
||||
const ordinaryPois = pois
|
||||
.map((poi) => toMuseumPoiFromSgs(poi, manifest.floors))
|
||||
.filter(isVisitorSearchPoi)
|
||||
.map(toSgsRenderPoi)
|
||||
const repositoryBusinessPois = guidePois
|
||||
.filter((poi) => poi.floorId === resolvedFloorId && poi.primaryCategory.id === 'business_poi')
|
||||
.filter((poi) => (
|
||||
poi.floorId === resolvedFloorId
|
||||
&& poi.primaryCategory.id === 'business_poi'
|
||||
&& isVisitorSearchPoi(poi)
|
||||
))
|
||||
.map(toGuideRenderPoi)
|
||||
const repositorySpacePois = guideSpacePoints
|
||||
.filter((poi) => poi.floorId === resolvedFloorId)
|
||||
.filter((poi) => poi.floorId === resolvedFloorId && isVisitorSearchPoi(poi))
|
||||
.map(toGuideRenderPoi)
|
||||
const floorPoiMedianY = getMedianPoiY(ordinaryPois)
|
||||
const museumHallPois = toMuseumHallPoisFromSgs(spaces, navigablePlaces, manifest.floors, resolvedFloorId, {
|
||||
@@ -492,7 +491,9 @@ export class SgsSdkGuideModelRepository implements GuideModelRepository {
|
||||
})
|
||||
}
|
||||
|
||||
const hallPois = museumHallPois.map(toSgsRenderPoi)
|
||||
const hallPois = museumHallPois
|
||||
.filter(isVisitorSearchPoi)
|
||||
.map(toSgsRenderPoi)
|
||||
const adaptedPois = dedupeRenderPoisById([
|
||||
...hallPois,
|
||||
...ordinaryPois,
|
||||
|
||||
Reference in New Issue
Block a user