fix: harden SGS hall POI matching diagnostics
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -367,10 +367,32 @@ const findMatchedHallSpace = (
|
||||
const placeName = normalizedHallName(placeHallName(place))
|
||||
if (!placeName) return undefined
|
||||
|
||||
return spaces.find((space) => {
|
||||
const spaceName = normalizedHallName(space.name)
|
||||
return spaceName && (placeName.includes(spaceName) || spaceName.includes(placeName))
|
||||
})
|
||||
const rankedMatches = spaces
|
||||
.map((space) => {
|
||||
const spaceName = normalizedHallName(space.name)
|
||||
if (!spaceName) return null
|
||||
|
||||
const exact = placeName === spaceName
|
||||
const overlaps = exact || placeName.includes(spaceName) || spaceName.includes(placeName)
|
||||
if (!overlaps) return null
|
||||
|
||||
return {
|
||||
space,
|
||||
exact,
|
||||
specificity: spaceName.length
|
||||
}
|
||||
})
|
||||
.filter((match): match is {
|
||||
space: SgsSpacePayload
|
||||
exact: boolean
|
||||
specificity: number
|
||||
} => Boolean(match))
|
||||
.sort((left, right) => {
|
||||
if (left.exact !== right.exact) return left.exact ? -1 : 1
|
||||
return right.specificity - left.specificity
|
||||
})
|
||||
|
||||
return rankedMatches[0]?.space
|
||||
}
|
||||
|
||||
const floorLabelForSgs = (
|
||||
@@ -416,9 +438,10 @@ const createHallPoiId = (
|
||||
if (spaceId) return `hall-${spaceId}`
|
||||
|
||||
const ownerName = normalizedHallName(placeHallName(place))
|
||||
if (ownerName) return `hall-place-${ownerName}`
|
||||
const floorIdentity = normalizedHallName(stringifyId(place.floorId) || place.floorCode || 'unknown-floor')
|
||||
if (ownerName) return `hall-place-${floorIdentity}-${ownerName}`
|
||||
|
||||
return `hall-place-${stringifyId(place.id) || fallbackIndex + 1}`
|
||||
return `hall-place-${floorIdentity}-${stringifyId(place.id) || fallbackIndex + 1}`
|
||||
}
|
||||
|
||||
const createSpaceFallbackHallPoi = (
|
||||
@@ -556,8 +579,10 @@ export const createSgsHallPoiDiagnostics = (
|
||||
navigablePlaces: SgsNavigablePlacePayload[],
|
||||
hallPois: MuseumPoi[]
|
||||
): SgsHallPoiDiagnostics => {
|
||||
const eligibleSpaceCount = spaces.filter(isExhibitionHallSpace).length
|
||||
const eligibleHallSpaces = spaces.filter(isExhibitionHallSpace)
|
||||
const eligibleSpaceCount = eligibleHallSpaces.length
|
||||
const hallPlaceCount = navigablePlaces.filter(isExhibitionHallNavigablePlace).length
|
||||
const hallPoiIds = new Set(hallPois.map((poi) => poi.id))
|
||||
const hallPoiWithPositionCount = hallPois.filter((poi) => Boolean(poi.positionGltf)).length
|
||||
|
||||
return {
|
||||
@@ -567,7 +592,7 @@ export const createSgsHallPoiDiagnostics = (
|
||||
hallPlaceCount,
|
||||
hallPoiCount: hallPois.length,
|
||||
hallPoiWithPositionCount,
|
||||
skippedSpaceCount: Math.max(eligibleSpaceCount - hallPois.length, 0),
|
||||
skippedSpaceCount: eligibleHallSpaces.filter((space) => !hallPoiIds.has(`hall-${stringifyId(space.id)}`)).length,
|
||||
skippedPlaceCount: Math.max(hallPlaceCount - hallPois.reduce((count, poi) => count + (poi.entrances?.length || 0), 0), 0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user