Skip to content

Commit 86b46a2

Browse files
committed
fix: station
1 parent 0d1d377 commit 86b46a2

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

src/ts/utils/station.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class StationManager {
1414

1515
try {
1616
const response = await fetch(
17-
"https://raw.githubusercontent.com/ExpTechTW/API/refs/heads/main/resource/station.csv",
17+
"http://api.core-tyo1.exptech.dev/api/v1/device/list",
1818
);
1919
const csvText = await response.text();
2020

@@ -51,21 +51,24 @@ class StationManager {
5151

5252
if (cols.length >= 7) {
5353
const id = cols[1];
54-
const areaCode = cols[5]; // Area code from code column (region code)
54+
const lat = parseFloat(cols[2]);
55+
const lon = parseFloat(cols[3]);
5556
let net = cols[6];
5657
if (net === "1") net = "SE-Net";
5758
else if (net === "2") net = "MS-Net";
5859
else if (net === "3") net = "ES-Net";
59-
const stationCode = cols[5];
60+
else if (net === "4") net = "ES-Pro";
61+
const locCode = cols[5];
6062

61-
// Only include ES-Net stations
62-
if (net === "ES-Net") {
63-
const location = this.getLocationName(stationCode); // Use code column for location lookup
64-
// console.log('Adding station:', id, 'code:', stationCode, 'location:', location);
63+
if (net === "ES-Net" || net === "ES-Pro") {
64+
const location = this.getLocationName(locCode); // Use code column for location lookup
65+
// console.log('Adding station:', id, 'code:', locCode, 'location:', location);
6566
this.stations[id] = {
6667
net: net,
67-
areaCode: areaCode,
68-
info: [{ code: stationCode }],
68+
lat: isNaN(lat) ? 0 : lat,
69+
lon: isNaN(lon) ? 0 : lon,
70+
areaCode: locCode,
71+
info: [{ code: locCode }],
6972
location: location,
7073
};
7174
}
@@ -106,7 +109,7 @@ class StationManager {
106109

107110
getESNetStations() {
108111
return Object.entries(this.stations)
109-
.filter(([id, station]) => station.net === "ES-Net")
112+
.filter(([id, station]) => station.net === "ES-Net" || station.net === "ES-Pro")
110113
.map(([id, station]) => ({
111114
id: id,
112115
location: station.location || "未知地區",

src/view/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/>
99
<meta
1010
http-equiv="Content-Security-Policy"
11-
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src https://raw.githubusercontent.com wss://bamboo.exptech.dev;"
11+
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src https://raw.githubusercontent.com wss://bamboo.exptech.dev http://api.core-tyo1.exptech.dev;"
1212
/>
1313
<link rel="stylesheet" href="../css/base.css" />
1414
<link rel="stylesheet" href="../css/info-area.css" />

0 commit comments

Comments
 (0)