test: prefer SGS hall entrance anchors
This commit is contained in:
@@ -121,6 +121,12 @@ const toHallPois = (spaces, navigablePlaces, fallbackFloorId) => {
|
||||
|
||||
const existing = halls.get(poiId)
|
||||
if (existing) {
|
||||
// Finding 1: Upgrade existing POI if later entrance has BOTH position and nodeId
|
||||
if (entrancePosition && place.nodeId) {
|
||||
existing.positionGltf = entrancePosition
|
||||
existing.sourceConfidence = 'backend-sgs-sdk-hall-entrance'
|
||||
existing.sourceObjectName = place.name
|
||||
}
|
||||
existing.entrances.push({ name: place.name, positionGltf: entrancePosition })
|
||||
return
|
||||
}
|
||||
@@ -136,6 +142,7 @@ const toHallPois = (spaces, navigablePlaces, fallbackFloorId) => {
|
||||
primaryCategory: 'exhibition_hall',
|
||||
positionGltf: position,
|
||||
sourceConfidence,
|
||||
sourceObjectName: place.name,
|
||||
entrances: [{ name: place.name, positionGltf: entrancePosition }]
|
||||
})
|
||||
})
|
||||
@@ -176,15 +183,15 @@ const spaces = [
|
||||
const places = [
|
||||
{ id: 101, name: '展厅1宇宙厅 出入口 1', ownerName: '展厅1宇宙厅', floorId: 'B2', position: { x: 11, y: 0, z: 21 }, nodeId: 'n101' },
|
||||
{ id: 102, name: '巨幕影院 出入口 1', ownerName: '巨幕影院', floorId: 'L1', position: { x: 31, y: 0, z: 41 }, nodeId: 'n102' },
|
||||
// Finding 4: entrance with missing coordinates falls back to matched space.center
|
||||
// Finding 3: entrance with missing coordinates falls back to matched space.center (creates POI with space-center sourceConfidence)
|
||||
{ id: 104, name: '地球科学展厅 出入口', ownerName: '地球科学展厅', floorId: 'L3' },
|
||||
// Finding 1: entrance-backed hall (with nodeId) must have backend-sgs-sdk-hall-entrance
|
||||
{ id: 105, name: '古生物展厅 出入口', ownerName: '古生物展厅', floorId: 'L2', position: { x: 151, y: 0, z: 161 }, nodeId: 'n105' },
|
||||
// Finding 2: entrance WITHOUT nodeId that matches a space should use space-center semantics (no position provided)
|
||||
{ id: 107, name: '自然科学展厅 出入口', ownerName: '自然科学展厅', floorId: 'L2' },
|
||||
// Issue 2: place with coordinates but no nodeId should match space center, not entrance position
|
||||
// Finding 2: place with coordinates but no nodeId should match space center, not entrance position
|
||||
{ id: 108, name: '自然科学展厅【主】出入口1', ownerName: '自然科学展厅', floorId: 'L2', position: { x: 111, y: 0, z: 121 } },
|
||||
// Issue 3: normalization fixture with spacing and brackets — matches space 7 with normalized name
|
||||
// Finding 1: later entrance with BOTH nodeId and position upgrades POI from space-center to entrance-backed
|
||||
{ id: 109, name: '地球 科学 展厅 (主)出入口 1', ownerName: '地球科学展厅', floorId: 'L3', position: { x: 131, y: 0, z: 141 }, nodeId: 'n109' }
|
||||
]
|
||||
|
||||
@@ -192,19 +199,15 @@ const result = toHallPois(spaces, places, 'B2')
|
||||
const byName = new Map(result.map((poi) => [poi.name, poi]))
|
||||
const byId = new Map(result.map((poi) => [poi.id, poi]))
|
||||
|
||||
// Finding 3: Ensure result names are unique (no duplicates hidden by Map-by-name)
|
||||
const nameList = result.map((poi) => poi.name)
|
||||
const uniqueNames = new Set(nameList)
|
||||
assert.equal(nameList.length, uniqueNames.size, `POI names must be unique; found ${nameList.length} POIs but only ${uniqueNames.size} unique names`)
|
||||
|
||||
// All fixtures merge into existing POIs, maintaining 7 unique halls
|
||||
assert.equal(result.length, 7)
|
||||
assert.deepEqual(byName.get('展厅1宇宙厅').positionGltf, [11, 0, 21])
|
||||
assert.deepEqual(byName.get('巨幕影院').positionGltf, [31, 0, 41])
|
||||
assert.deepEqual(byName.get('博物馆之友活动室').positionGltf, [50, 0, 60])
|
||||
assert.deepEqual(byName.get('展览坡道').positionGltf, [70, 0, 80])
|
||||
assert.equal(byName.has('茶水间'), false)
|
||||
assert.equal(byName.get('博物馆之友活动室').sourceConfidence, 'backend-sgs-sdk-space-center')
|
||||
// All fixtures merge into existing POIs, maintaining 7 unique halls (verified by ID-based map)
|
||||
assert.equal(result.length, 7, 'result contains 7 POIs')
|
||||
assert.equal(byId.size, 7, 'all POI IDs are unique')
|
||||
assert.deepEqual(byId.get('hall-1').positionGltf, [11, 0, 21])
|
||||
assert.deepEqual(byId.get('hall-2').positionGltf, [31, 0, 41])
|
||||
assert.deepEqual(byId.get('hall-3').positionGltf, [50, 0, 60])
|
||||
assert.deepEqual(byId.get('hall-4').positionGltf, [70, 0, 80])
|
||||
assert.equal(byId.has('hall-5'), false)
|
||||
assert.equal(byId.get('hall-3').sourceConfidence, 'backend-sgs-sdk-space-center')
|
||||
|
||||
// Finding 2: whitelist enforcement prevents unrelated types
|
||||
assert.equal(byName.has('茶水间'), false, 'service type rejected by whitelist')
|
||||
@@ -221,11 +224,14 @@ assert.equal(byName.get('自然科学展厅').entrances.some((e) => e.name === '
|
||||
|
||||
// Finding 4: entrance with missing coordinates falls back to matched space.center
|
||||
assert.equal(byName.has('地球科学展厅'), true, 'entrance fallback to space.center')
|
||||
assert.deepEqual(byName.get('地球科学展厅').positionGltf, [130, 0, 140])
|
||||
assert.equal(byName.get('地球科学展厅').sourceConfidence, 'backend-sgs-sdk-space-center', 'Finding 5: sourceConfidence from space-center not entrance')
|
||||
// Finding 4: entrance still recorded even with undefined positionGltf (no coordinates)
|
||||
// Finding 1: later entrance with BOTH nodeId and position upgrades POI to entrance-backed
|
||||
assert.deepEqual(byName.get('地球科学展厅').positionGltf, [131, 0, 141], 'upgraded to entrance position [131, 0, 141]')
|
||||
assert.equal(byName.get('地球科学展厅').sourceConfidence, 'backend-sgs-sdk-hall-entrance', 'Finding 1: upgraded to hall-entrance sourceConfidence')
|
||||
// Finding 3: both entrances recorded, including the no-coordinate one
|
||||
assert.equal(byName.get('地球科学展厅').entrances.length, 2, 'both place 104 (no-coord) and 109 (with nodeId) recorded')
|
||||
assert.equal(byName.get('地球科学展厅').entrances[0].name, '地球科学展厅 出入口')
|
||||
assert.equal(byName.get('地球科学展厅').entrances[0].positionGltf, undefined)
|
||||
assert.equal(byName.get('地球科学展厅').entrances[0].positionGltf, undefined, 'first entrance has no coordinates')
|
||||
assert.equal(byName.get('地球科学展厅').entrances.some((e) => e.name === '地球 科学 展厅 (主)出入口 1'), true, 'normalized entrance name recorded')
|
||||
|
||||
// Finding 1: entrance-derived sourceConfidence branch — entrance-backed halls must be backend-sgs-sdk-hall-entrance
|
||||
assert.equal(byName.has('古生物展厅'), true, 'entrance with nodeId creates hall POI')
|
||||
@@ -249,13 +255,13 @@ const place109 = places.find((p) => p.id === 109)
|
||||
assert.equal(place109.nodeId, 'n109', 'fixture 109 has nodeId')
|
||||
assert.equal(byName.has('地球科学展厅'), true, 'normalized name matches despite spacing and brackets')
|
||||
const earthSciencePoi = byName.get('地球科学展厅')
|
||||
// Place 104 (no nodeId, no position) created the POI with space-center
|
||||
// Place 109 (has nodeId and position) merges as another entrance but doesn't change sourceConfidence
|
||||
// sourceConfidence is determined by the first POI creator, not subsequent entrances
|
||||
assert.equal(earthSciencePoi.sourceConfidence, 'backend-sgs-sdk-space-center', 'sourceConfidence set by first place (104) without nodeId')
|
||||
// Place 109's entrance should be recorded despite no nodeId requirement for sourceConfidence
|
||||
assert.equal(earthSciencePoi.entrances.length >= 2, true, 'both place 104 and 109 entrances recorded')
|
||||
assert.equal(earthSciencePoi.entrances.some((e) => e.name === '地球 科学 展厅 (主)出入口 1'), true, 'normalized entrance name recorded')
|
||||
// Place 104 (no nodeId, no position) created the POI with space-center sourceConfidence
|
||||
// Place 109 (has nodeId and position) upgrades the POI to entrance-backed with new position
|
||||
assert.equal(earthSciencePoi.sourceConfidence, 'backend-sgs-sdk-hall-entrance', 'sourceConfidence upgraded by place 109 with nodeId and position')
|
||||
assert.deepEqual(earthSciencePoi.positionGltf, [131, 0, 141], 'position upgraded to place 109 entrance coordinates')
|
||||
assert.equal(earthSciencePoi.entrances.length, 2, 'both place 104 and 109 entrances recorded')
|
||||
assert.equal(earthSciencePoi.entrances.some((e) => e.name === '地球科学展厅 出入口'), true, 'place 104 no-coordinate entrance recorded')
|
||||
assert.equal(earthSciencePoi.entrances.some((e) => e.name === '地球 科学 展厅 (主)出入口 1'), true, 'place 109 normalized entrance recorded')
|
||||
|
||||
// Issue 4: keep unmatched exhibition space fallback coverage
|
||||
assert.equal(byName.has('自然科学展厅'), true, 'unmatched space-center POI still emitted')
|
||||
|
||||
Reference in New Issue
Block a user