All files / src/utils floorPlanPoiUtils.ts

100% Statements 7/7
66.66% Branches 4/6
100% Functions 2/2
100% Lines 7/7

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 411x                                   283x 283x 3842x         12x     271x       12x                
const POI_PATTERNS: [RegExp | string, string][] = [
  [/bathroom[-_]?women|women.*bathroom/i, "bathroom-women"],
  [/bathroom[-_]?men|men.*bathroom/i, "bathroom-men"],
  [/bathroom/i, "bathroom-men"],
  [/elevator/i, "elevator"],
  [/stairs[-_]?down|stairsdown/i, "stairs-down"],
  [/stairs[-_]?up|stairsup/i, "stairs-up"],
  [/stairs/i, "stairs"],
  [/water[-_]?fountain|waterfountain/i, "water-fountain"],
  [/emergency[-_]?exit|emergency[-_]?stairs/i, "emergency-exit"],
  [/exit|entrance/i, "entrance-exit"],
  [/printer/i, "printer"],
  [/computer[-_]?(station|area)?/i, "computer-station"],
  [/study[-_]?area|sitting[-_]?area|tabling|couch|stand/i, "study-area"],
  [/shelve|bookshelf/i, "bookshelf"],
];
 
export function inferPoiType(roomId: string): string | null {
  const lower = roomId.toLowerCase();
  for (const [pattern, type] of POI_PATTERNS) {
    if (
      typeof pattern === "string"
        ? lower.includes(pattern)
        : pattern.test(lower)
    ) {
      return type;
    }
  }
  return null;
}
 
export function getDisplayNameFromRoomId(roomId: string): string {
  return (
    roomId
      .split("-")
      .slice(1)
      .join(" ")
      .replaceAll(/([a-z])([A-Z])/g, "$1 $2") || roomId
  );
}