Skip to content

Commit cea707f

Browse files
committed
feat: setting to color stations by PGA or PGV
1 parent 18cfb30 commit cea707f

9 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/locales/en-US/translations.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
"settingsTtsPuter": "Puter.js (opens a popup)",
3939
"settingsTtsDefault": "Default",
4040
"settingsNotifications": "Notifications",
41+
"settingsStnColor": "Station colors",
4142
"settingsReloadNote": "Saving reloads the app"
4243
}

src/locales/es-ES/translations.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
"settingsTtsPuter": "Puter.js (abre una ventana emergente)",
3939
"settingsTtsDefault": "Predeterminada",
4040
"settingsNotifications": "Notificaciones",
41+
"settingsStnColor": "Color de las estaciones",
4142
"settingsReloadNote": "Al guardar se recargará la aplicación"
4243
}

src/locales/it-IT/translations.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
"settingsTtsPuter": "Puter.js (apre un popup)",
3939
"settingsTtsDefault": "Predefinita",
4040
"settingsNotifications": "Notifiche",
41+
"settingsStnColor": "Colore delle stazioni",
4142
"settingsReloadNote": "Il salvataggio ricaricherà l'app"
4243
}

src/locales/ja-JP/translations.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
"settingsTtsPuter": "Puter.js(ポップアップが開きます)",
3939
"settingsTtsDefault": "デフォルト",
4040
"settingsNotifications": "通知",
41+
"settingsStnColor": "観測点の色",
4142
"settingsReloadNote": "保存するとアプリが再読み込みされます"
4243
}

src/locales/pl-PL/translations.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
"settingsTtsPuter": "Puter.js (otwiera wyskakujące okno)",
3939
"settingsTtsDefault": "Domyślny",
4040
"settingsNotifications": "Powiadomienia",
41+
"settingsStnColor": "Kolory stacji",
4142
"settingsReloadNote": "Zapisanie ponownie załaduje aplikację"
4243
}

src/locales/zh-CN/translations.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
"settingsTtsPuter": "Puter.js(会打开弹窗)",
3939
"settingsTtsDefault": "默认",
4040
"settingsNotifications": "通知",
41+
"settingsStnColor": "监测站颜色",
4142
"settingsReloadNote": "保存后将重新加载应用"
4243
}

src/locales/zh-TW/translations.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
"settingsTtsPuter": "Puter.js(會開啟彈出視窗)",
3939
"settingsTtsDefault": "預設",
4040
"settingsNotifications": "通知",
41+
"settingsStnColor": "測站顏色",
4142
"settingsReloadNote": "儲存後將重新載入應用程式"
4243
}

src/ts/stn.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { placeMarker, map } from "./utils/map";
33
import { getColorPga, getColorPgv } from "./utils/transform";
44
import { playSound } from "./utils/speaker";
5+
import { settings } from "./utils/settings";
56
import type { Feature, FeatureCollection, Point, GeoJsonProperties } from "geojson";
67
import type { StnPacket } from "./ws";
78

@@ -13,6 +14,10 @@ import newInt4 from "../assets/sounds/int/NewInt4.wav";
1314
import newInt5 from "../assets/sounds/int/NewInt5.wav";
1415
import newInt6 from "../assets/sounds/int/NewInt6.wav";
1516

17+
const usePga = settings?.stnColor === "pga";
18+
const stnColor = (pga: number, pgv: number): string =>
19+
usePga ? getColorPga(pga) : getColorPgv(pgv);
20+
1621
const loadedStns = new Set<string>();
1722

1823
const stnsGeojson: FeatureCollection<Point, GeoJsonProperties> = {
@@ -39,7 +44,7 @@ export const stn = (stns: StnPacket) => {
3944
id: stn.code,
4045
net: stn.author,
4146
name: stn.name,
42-
color: getColorPgv(stn.pgv),
47+
color: stnColor(stn.pga, stn.pgv),
4348
opacity: 1
4449
}
4550
};
@@ -52,7 +57,7 @@ export const stn = (stns: StnPacket) => {
5257
);
5358

5459
if (stnFeature && stnFeature.properties) {
55-
stnFeature.properties.color = getColorPgv(stn.pgv);
60+
stnFeature.properties.color = stnColor(stn.pga, stn.pgv);
5661
}
5762
}
5863
}

src/ts/utils/settingsSchema.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ export const SETTINGS_SCHEMA: SettingSection[] = [
6969
{ value: "on", labelKey: "settingsEnabled" },
7070
{ value: "off", labelKey: "settingsDisabled" }
7171
]
72+
},
73+
{
74+
key: "stnColor",
75+
labelKey: "settingsStnColor",
76+
type: "select",
77+
default: "pgv",
78+
options: [
79+
{ value: "pgv", label: "PGV" },
80+
{ value: "pga", label: "PGA" }
81+
]
7282
}
7383
]
7484
},

0 commit comments

Comments
 (0)