Skip to main content
Glama
wbgt-service.ts2.43 kB
import { WBGTData, WBGTRealtimeData, TokyoLocation } from './types.js'; import { LOCATION_ID_MAP, WBGT_API_BASE_URLS } from './constants.js'; import { parseWBGTForecastCSV, parseAllTokyoCSV, parseRealtimeCSV } from './utils.js'; /** * WBGT データを取得するサービスクラス */ export class WBGTService { /** * 指定した東京都内地点のWBGT予測データを取得 */ async getTokyoWBGTForecast(location: TokyoLocation): Promise<WBGTData> { const locationId = LOCATION_ID_MAP[location]; if (!locationId) { throw new Error(`Unknown location: ${location}. Available: ${Object.keys(LOCATION_ID_MAP).join(", ")}`); } const url = `${WBGT_API_BASE_URLS.forecast}yohou_${locationId}.csv`; try { const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const csvData = await response.text(); return parseWBGTForecastCSV(csvData, location); } catch (error) { throw new Error(`Failed to fetch WBGT data: ${error instanceof Error ? error.message : String(error)}`); } } /** * 東京都内全地点のWBGT予測データを取得 */ async getAllTokyoLocations(): Promise<WBGTData[]> { const url = `${WBGT_API_BASE_URLS.forecast}yohou_tokyo.csv`; try { const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const csvData = await response.text(); return parseAllTokyoCSV(csvData); } catch (error) { throw new Error(`Failed to fetch all Tokyo WBGT data: ${error instanceof Error ? error.message : String(error)}`); } } /** * 東京都のWBGTリアルタイムデータを取得 */ async getTokyoRealtimeData(year: number, month: number): Promise<WBGTRealtimeData> { const monthStr = month.toString().padStart(2, '0'); const url = `${WBGT_API_BASE_URLS.realtime}Tokyo_${year}${monthStr}.csv`; try { const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const csvData = await response.text(); return parseRealtimeCSV(csvData); } catch (error) { throw new Error(`Failed to fetch realtime WBGT data: ${error instanceof Error ? error.message : String(error)}`); } } }

Implementation Reference

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yukit7s/cc-get-wbgt'

If you have feedback or need assistance with the MCP directory API, please join our Discord server