修复馆内导览楼层点位展示
This commit is contained in:
@@ -126,6 +126,43 @@ const warnSgsGuideModelDiagnostics = (
|
||||
console.warn(`[SGS guide model] ${message}`, payload)
|
||||
}
|
||||
|
||||
const summarizeYValues = (pois: GuideRenderPoi[]) => {
|
||||
const values = pois
|
||||
.map((poi) => poi.positionGltf?.[1])
|
||||
.filter((value): value is number => Number.isFinite(value))
|
||||
.sort((left, right) => left - right)
|
||||
|
||||
if (!values.length) {
|
||||
return {
|
||||
count: 0,
|
||||
min: null,
|
||||
median: null,
|
||||
max: null
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
count: values.length,
|
||||
min: values[0],
|
||||
median: values[Math.floor(values.length / 2)],
|
||||
max: values[values.length - 1]
|
||||
}
|
||||
}
|
||||
|
||||
const getMedianPoiY = (pois: GuideRenderPoi[]) => {
|
||||
const values = pois
|
||||
.map((poi) => poi.positionGltf?.[1])
|
||||
.filter((value): value is number => Number.isFinite(value))
|
||||
.sort((left, right) => left - right)
|
||||
|
||||
if (!values.length) return undefined
|
||||
|
||||
const middle = Math.floor(values.length / 2)
|
||||
return values.length % 2
|
||||
? values[middle]
|
||||
: (values[middle - 1] + values[middle]) / 2
|
||||
}
|
||||
|
||||
const getSgsFloorModelMatchKeys = (floor: SgsSdkFloorSummaryPayload, label: string) => (
|
||||
[
|
||||
String(floor.floorId),
|
||||
@@ -285,7 +322,10 @@ export class SgsSdkGuideModelRepository implements GuideModelRepository {
|
||||
loadFloorData('navigablePlaces', () => this.provider.getNavigablePlaces(resolvedFloorId))
|
||||
])
|
||||
const ordinaryPois = pois.map((poi) => toSgsRenderPoi(toMuseumPoiFromSgs(poi, manifest.floors)))
|
||||
const museumHallPois = toMuseumHallPoisFromSgs(spaces, navigablePlaces, manifest.floors, resolvedFloorId)
|
||||
const floorPoiMedianY = getMedianPoiY(ordinaryPois)
|
||||
const museumHallPois = toMuseumHallPoisFromSgs(spaces, navigablePlaces, manifest.floors, resolvedFloorId, {
|
||||
fallbackY: floorPoiMedianY
|
||||
})
|
||||
const hallDiagnostics = createSgsHallPoiDiagnostics(spaces, navigablePlaces, museumHallPois)
|
||||
|
||||
if (hallDiagnostics.eligibleSpaceCount > 0 && hallDiagnostics.hallPoiWithPositionCount === 0) {
|
||||
@@ -300,8 +340,21 @@ export class SgsSdkGuideModelRepository implements GuideModelRepository {
|
||||
...hallPois,
|
||||
...ordinaryPois
|
||||
])
|
||||
.filter((poi) => poi.floorId === resolvedFloorId)
|
||||
.filter((poi) => Array.isArray(poi.positionGltf) && poi.positionGltf.length === 3)
|
||||
|
||||
const renderHallPois = renderPois.filter((poi) => poi.kind === 'hall' || poi.primaryCategory === 'exhibition_hall')
|
||||
warnSgsGuideModelDiagnostics('floor render POI diagnostics', {
|
||||
floorId: resolvedFloorId,
|
||||
floorCode: matchedFloor.floorCode,
|
||||
poiCount: renderPois.length,
|
||||
hallPoiCount: renderHallPois.length,
|
||||
hallPoiWithPositionCount: renderHallPois.filter((poi) => Boolean(poi.positionGltf)).length,
|
||||
poiY: summarizeYValues(renderPois),
|
||||
hallPoiY: summarizeYValues(renderHallPois),
|
||||
fallbackHallY: floorPoiMedianY ?? null
|
||||
})
|
||||
|
||||
if (hallDiagnostics.hallPoiWithPositionCount > 0 && !renderPois.some((poi) => poi.primaryCategory === 'exhibition_hall')) {
|
||||
warnSgsGuideModelDiagnostics('render POI filter removed all hall POIs', {
|
||||
floorId: resolvedFloorId,
|
||||
|
||||
Reference in New Issue
Block a user