Skip to content

Commit

Permalink
Fix intensity scale in localStorage, change URL of CWA
Browse files Browse the repository at this point in the history
  • Loading branch information
bclswl0827 committed Oct 21, 2023
1 parent 064af51 commit 4e1082e
Show file tree
Hide file tree
Showing 26 changed files with 72 additions and 61 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.1.20p
v2.1.21p
28 changes: 14 additions & 14 deletions app/trace/cwb.go → app/trace/cwa.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ import (
"github.com/bclswl0827/observer/utils/request"
)

type CWB struct {
type CWA struct {
DataSourceCache
}

func (c *CWB) Property() (string, string) {
func (c *CWA) Property() (string, string) {
const (
NAME string = "台湾交通部中央氣象局"
VALUE string = "CWB"
NAME string = "交通部中央氣象局"
VALUE string = "CWA"
)

return NAME, VALUE
}

func (c *CWB) Fetch() ([]byte, error) {
func (c *CWA) Fetch() ([]byte, error) {
if duration.Difference(time.Now(), c.Time) <= EXPIRATION {
return c.Cache, nil
}

res, err := request.GET(
"https://www.cwb.gov.tw/V8/C/E/MOD/MAP_LIST.html",
"https://www.cwa.gov.tw/V8/C/E/MOD/MAP_LIST.html",
10*time.Second, time.Second, 3, false,
)
if err != nil {
Expand All @@ -45,7 +45,7 @@ func (c *CWB) Fetch() ([]byte, error) {
return res, nil
}

func (c *CWB) Parse(data []byte) (map[string]any, error) {
func (c *CWA) Parse(data []byte) (map[string]any, error) {
result := make(map[string]any)
result["data"] = make([]any, 0)

Expand Down Expand Up @@ -83,7 +83,7 @@ func (c *CWB) Parse(data []byte) (map[string]any, error) {
return result, nil
}

func (c *CWB) Format(latitude, longitude float64, data map[string]any) ([]Event, error) {
func (c *CWA) Format(latitude, longitude float64, data map[string]any) ([]Event, error) {
var list []Event
for _, v := range data["data"].([]any) {
l := Event{
Expand All @@ -105,7 +105,7 @@ func (c *CWB) Format(latitude, longitude float64, data map[string]any) ([]Event,
return list, nil
}

func (c *CWB) List(latitude, longitude float64) ([]Event, error) {
func (c *CWA) List(latitude, longitude float64) ([]Event, error) {
res, err := c.Fetch()
if err != nil {
return nil, err
Expand All @@ -124,7 +124,7 @@ func (c *CWB) List(latitude, longitude float64) ([]Event, error) {
return list, nil
}

func (c *CWB) getDepth(data string) float64 {
func (c *CWA) getDepth(data string) float64 {
exp := regexp.MustCompile(`深度(\d+(\.\d{1,}公里)|([1-9]\d*公里))`)
if exp == nil {
return -1
Expand All @@ -141,7 +141,7 @@ func (c *CWB) getDepth(data string) float64 {
return string2Float(result)
}

func (c *CWB) getMagnitude(data string) float64 {
func (c *CWA) getMagnitude(data string) float64 {
exp := regexp.MustCompile(`模\d+(\.\d{1,})|([1-9]\d*)$`)
if exp == nil {
return -1
Expand All @@ -157,7 +157,7 @@ func (c *CWB) getMagnitude(data string) float64 {
return string2Float(result)
}

func (c *CWB) getEvent(data string) string {
func (c *CWA) getEvent(data string) string {
exp := regexp.MustCompile(`地點為.+方\d+(\.\d{1,}公里)|([1-9]\d*公里)`)
if exp == nil {
return "未知地震"
Expand All @@ -172,7 +172,7 @@ func (c *CWB) getEvent(data string) string {
return result
}

func (c *CWB) getRegion(data string) string {
func (c *CWA) getRegion(data string) string {
exp := regexp.MustCompile(`\(位於.+\)`)
if exp == nil {
return "未知地点"
Expand All @@ -188,7 +188,7 @@ func (c *CWB) getRegion(data string) string {
return result
}

func (c *CWB) getTimestamp(data string) int64 {
func (c *CWA) getTimestamp(data string) int64 {
exp := regexp.MustCompile(`時間為\d+月\d+日\d+時\d+,`)
if exp == nil {
return -1
Expand Down
2 changes: 1 addition & 1 deletion app/trace/hko.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type HKO struct {

func (h *HKO) Property() (string, string) {
const (
NAME string = "香港天文台全球地震資訊網"
NAME string = "天文台全球地震資訊網"
VALUE string = "HKO"
)

Expand Down
2 changes: 1 addition & 1 deletion app/trace/jma.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type JMA struct {

func (j *JMA) Property() (string, string) {
const (
NAME string = "日本気象庁地震情報"
NAME string = "気象庁地震情報"
VALUE string = "JMA"
)

Expand Down
4 changes: 2 additions & 2 deletions app/trace/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
// @Success 200 {object} response.HttpResponse{data=[]Event} "Successfully read the list of earthquake events"
func (t *Trace) RegisterModule(rg *gin.RouterGroup, options *app.ServerOptions) {
sources := []DataSource{
&USGS{}, &JMA{}, &CWB{}, &HKO{},
&CEIC{}, &SCEA_E{}, &SCEA_B{},
&SCEA_E{}, &SCEA_B{}, &CEIC{},
&USGS{}, &JMA{}, &CWA{}, &HKO{},
}

rg.POST("/trace", func(c *gin.Context) {
Expand Down
2 changes: 1 addition & 1 deletion app/trace/scea-b.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type SCEA_B struct {

func (s *SCEA_B) Property() (string, string) {
const (
NAME string = "四川地震局速报"
NAME string = "四川地震局(速报)"
VALUE string = "SCEA-B"
)

Expand Down
2 changes: 1 addition & 1 deletion app/trace/scea-e.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type SCEA_E struct {

func (s *SCEA_E) Property() (string, string) {
const (
NAME string = "四川地震局预警"
NAME string = "四川地震局(预警)"
VALUE string = "SCEA-E"
)

Expand Down
12 changes: 6 additions & 6 deletions frontend/dist/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"files": {
"main.css": "/static/css/main.3d547ccc.css",
"main.js": "/static/js/main.4471cbe2.js",
"main.js": "/static/js/main.43baa15e.js",
"static/css/278.525e2941.chunk.css": "/static/css/278.525e2941.chunk.css",
"static/js/278.d260dbf2.chunk.js": "/static/js/278.d260dbf2.chunk.js",
"static/js/967.2fd750da.chunk.js": "/static/js/967.2fd750da.chunk.js",
"static/js/555.f18587de.chunk.js": "/static/js/555.f18587de.chunk.js",
"static/js/278.f2bbf51e.chunk.js": "/static/js/278.f2bbf51e.chunk.js",
"static/js/967.89477617.chunk.js": "/static/js/967.89477617.chunk.js",
"static/js/555.a23f4689.chunk.js": "/static/js/555.a23f4689.chunk.js",
"static/js/756.f470d0ba.chunk.js": "/static/js/756.f470d0ba.chunk.js",
"static/js/886.b632e8a8.chunk.js": "/static/js/886.b632e8a8.chunk.js",
"static/js/886.2b35e155.chunk.js": "/static/js/886.2b35e155.chunk.js",
"static/js/377.f0e1c66a.chunk.js": "/static/js/377.f0e1c66a.chunk.js",
"static/js/453.30461b97.chunk.js": "/static/js/453.30461b97.chunk.js",
"static/js/59.a77c052b.chunk.js": "/static/js/59.a77c052b.chunk.js",
Expand Down Expand Up @@ -47,6 +47,6 @@
},
"entrypoints": [
"static/css/main.3d547ccc.css",
"static/js/main.4471cbe2.js"
"static/js/main.43baa15e.js"
]
}
2 changes: 1 addition & 1 deletion frontend/dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/><link rel="icon" href="/favicon.ico"/><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.4471cbe2.js"></script><link href="/static/css/main.3d547ccc.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/><link rel="icon" href="/favicon.ico"/><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.43baa15e.js"></script><link href="/static/css/main.3d547ccc.css" rel="stylesheet"></head><body><div id="root"></div></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 4e1082e

Please sign in to comment.