All files / src/utils buildingIndoorMaps.ts

82.05% Statements 32/39
77.77% Branches 28/36
100% Functions 6/6
93.75% Lines 30/32

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60          4x 4x       1914x 6933x         7x 2x 2x   5x         5x 1x 1x   4x 1x 1x   3x 1x 1x   2x 1x 1x     1x         505x 505x 504x     1x 1x 1x 1x 1x 1x    
import { BuildingId } from '../data/buildings';
import { getBuildingFloorPlans } from '../data/floorPlans';
 
 
export function hasIndoorMaps(buildingId: BuildingId): boolean {
  const floorPlans = getBuildingFloorPlans(buildingId);
  return floorPlans.length > 0;
}
 
export function getAvailableFloors(buildingId: BuildingId): string[] {
  const floorPlans = getBuildingFloorPlans(buildingId);
  return floorPlans.map(plan => plan.floorNumber).sort((a, b) => a.localeCompare(b));
}
 
 
export function getBackendBuildingId(buildingId: BuildingId, floorNumber?: string): string {
  if (buildingId === 'H') {
    const floor = floorNumber || '8';
    return `Hall-${floor}`;
  }
  Iif (buildingId === 'VE') {
    const floor = floorNumber || '1';
    return `VE-${floor}`;
  }
 
  if (buildingId === 'VL') {
    const floor = floorNumber || '1';
    return `VL-${floor}`;
  }
  if (buildingId === 'LB') {
    const floor = floorNumber || '2';
    return `LB-${floor}`; 
  }
  if (buildingId === 'MB') {
    const floor = floorNumber || 'S2';
    return `MB-${floor}`;
  }
  if (buildingId === 'CC') {
    const floor = floorNumber || '1';
    return `CC-${floor}`;
  }
 
  return `Building-${buildingId}`;
}
 
 
export function getDefaultFloor(buildingId: BuildingId): string {
  const floors = getAvailableFloors(buildingId);
  if (floors.length > 0) {
    return floors[0];
  }
 
  Iif (buildingId === 'LB') return '2';
  Iif (buildingId === 'VL') return '1';
  Iif (buildingId === 'H') return '1';
  Iif (buildingId === 'MB') return 'S2';
  Iif (buildingId === 'CC') return '1';
  return '1'; 
}