w-dwdata-tweq 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.jsdoc +25 -0
  5. package/LICENSE +21 -0
  6. package/README.md +48 -0
  7. package/SECURITY.md +5 -0
  8. package/babel.config.js +16 -0
  9. package/dist/w-dwdata-tweq.umd.js +8 -0
  10. package/dist/w-dwdata-tweq.umd.js.map +1 -0
  11. package/docs/WDwdataTweq.mjs.html +318 -0
  12. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  13. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  14. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  15. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  16. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  17. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  18. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  19. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  20. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  24. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  25. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  26. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  27. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  28. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  29. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  30. package/docs/global.html +781 -0
  31. package/docs/index.html +84 -0
  32. package/docs/scripts/collapse.js +39 -0
  33. package/docs/scripts/commonNav.js +28 -0
  34. package/docs/scripts/linenumber.js +25 -0
  35. package/docs/scripts/nav.js +12 -0
  36. package/docs/scripts/polyfill.js +4 -0
  37. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  38. package/docs/scripts/prettify/lang-css.js +2 -0
  39. package/docs/scripts/prettify/prettify.js +28 -0
  40. package/docs/scripts/search.js +99 -0
  41. package/docs/styles/jsdoc.css +776 -0
  42. package/docs/styles/prettify.css +80 -0
  43. package/g.downloadEqs.mjs +16 -0
  44. package/g.mjs +53 -0
  45. package/g.parseData.mjs +26 -0
  46. package/package.json +34 -0
  47. package/script.txt +17 -0
  48. package/src/WDwdataTweq.mjs +246 -0
  49. package/src/cropPic.mjs +15 -0
  50. package/src/downloadEqs.mjs +124 -0
  51. package/src/downloadFile.mjs +77 -0
  52. package/src/downloadPics.mjs +57 -0
  53. package/src/parseData.mjs +152 -0
  54. package/test/WDwdataTweq.test.mjs +150 -0
  55. package/toolg/addVersion.mjs +4 -0
  56. package/toolg/cleanFolder.mjs +4 -0
  57. package/toolg/gDistRollup.mjs +26 -0
  58. package/toolg/modifyReadme.mjs +4 -0
@@ -0,0 +1,57 @@
1
+ import pmSeries from 'wsemi/src/pmSeries.mjs'
2
+ import downloadFile from './downloadFile.mjs'
3
+ import fsIsFolder from 'wsemi/src/fsIsFolder.mjs'
4
+ import fsCreateFolder from 'wsemi/src/fsCreateFolder.mjs'
5
+
6
+
7
+ let downloadPics = async (fd, v) => {
8
+
9
+ // urlWebEqInfor: 'https://scweb.cwa.gov.tw/zh-TW/earthquake/Details/2024040307580971019',
10
+ // urlWebEqReport: 'https://scweb.cwa.gov.tw/zh-TW/earthquake/Imgs/2024040307580971019',
11
+ // urlWebEqIntensity: 'https://scweb.cwa.gov.tw/zh-TW/earthquake/ShakeMap/2024040307580971019',
12
+ // urlWebEqWave: 'https://scweb.cwa.gov.tw/zh-TW/earthquake/WaveformAcc/2024040307580971019',
13
+ // urlPicEqReport: 'https://scweb.cwa.gov.tw/webdata/OLDEQ/202404/2024040307580971019.gif',
14
+ // urlPicEqIntensity: 'https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/2024/2024019i.png',
15
+ // urlPicEqPga: 'https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/2024/2024019a.png',
16
+ // urlPicEqPgv: 'https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/2024/2024019v.png'
17
+
18
+ //check
19
+ if (!fsIsFolder(fd)) {
20
+ fsCreateFolder(fd)
21
+ }
22
+
23
+ //ms
24
+ let ms = [
25
+ {
26
+ url: v.urlPicEqReport,
27
+ fn: `picEqReport.gif`,
28
+ },
29
+ {
30
+ url: v.urlPicEqIntensity,
31
+ fn: `picEqIntensity.png`,
32
+ },
33
+ {
34
+ url: v.urlPicEqPga,
35
+ fn: `picEqPga.png`,
36
+ },
37
+ {
38
+ url: v.urlPicEqPgv,
39
+ fn: `picEqPgv.png`,
40
+ },
41
+ ]
42
+
43
+ await pmSeries(ms, async(m) => {
44
+ // console.log('m', m)
45
+
46
+ //fp
47
+ let fp = `${fd}/${m.fn}`
48
+
49
+ //downloadFile
50
+ await downloadFile(m.url, fp)
51
+
52
+ })
53
+
54
+ }
55
+
56
+
57
+ export default downloadPics
@@ -0,0 +1,152 @@
1
+ import get from 'lodash-es/get.js'
2
+ import map from 'lodash-es/map.js'
3
+ import trim from 'lodash-es/trim.js'
4
+ import isnum from 'wsemi/src/isnum.mjs'
5
+ import cint from 'wsemi/src/cint.mjs'
6
+ import ot from 'dayjs'
7
+
8
+
9
+ let parserEq = (o) => {
10
+ //heads:
11
+ // "eArea": "小區域有感地震",
12
+ // "eDetailsEvent": "第{0}號",
13
+ // "hDate": "日期",
14
+ // "hTime": "時間",
15
+ // "eDetailsDate3": "yyyy年M月d日",
16
+ // "eDetailsDate4": "H時m分s秒",
17
+ // "Location": "位置",
18
+ // "eDetailsLat": "北緯 {0} °",
19
+ // "eDetailsLon": "東經 {0} °",
20
+ // "eDetailsDepth": "地震深度",
21
+ // "eDetailsScale": "芮氏規模",
22
+ // "hKM": "公里",
23
+ // "OrginDate": "地震時間",
24
+ // "Scale": "規模",
25
+ // "Depth": "深度",
26
+ // "Lon": "經度",
27
+ // "Lat": "緯度",
28
+ // "hDistrict": "行政分區",
29
+ // "gStation": "測站名稱",
30
+ // "Intensity": "震度",
31
+ // "gCenter": "中心位置",
32
+ // "gRadius": "半徑",
33
+ // "eFar": "遠地地震"
34
+
35
+ let data = get(o, 'data', [])
36
+
37
+ let rs = map(data, (v) => {
38
+ //value:
39
+ // "2025081903554745113", //地震戳記
40
+ // "113 ", //當年地震編號
41
+ // "2025-08-19 03:55:47", //地震時間
42
+ // "4.5", //芮式規模
43
+ // "22.4", //深度(km)
44
+ // "花蓮縣政府東北方 28.0 公里 (位於臺灣東部海域)", //地震位置
45
+ // "3", //最大震度
46
+ // "121.836", //經度
47
+ // "24.1473", //緯度
48
+ // "Alert"
49
+
50
+ let tag = get(v, 0, '') //地震戳記
51
+ let number = get(v, 1, '') //當年地震編號
52
+ let timeRec = get(v, 2, '') //地震時間
53
+ let ml = get(v, 3, '') //芮式規模
54
+ let depth = get(v, 4, '') //深度(km)
55
+ let location = get(v, 5, '') //地震位置
56
+ let intensity = get(v, 6, '') //最大震度
57
+ let longitude = get(v, 7, '') //經度
58
+ let latitude = get(v, 8, '') //緯度
59
+
60
+ number = trim(number)
61
+
62
+ let t = ot(timeRec, 'YYYY-MM-DD HH-mm:ss')
63
+
64
+ let time = t.format('YYYY-MM-DDTHH:mm:ssZ') //轉UTC時間
65
+
66
+ let timeTag = t.format('YYYYMMDDHHmmss')
67
+
68
+ let timeY = t.format('YYYY')
69
+
70
+ let timeYM = t.format('YYYYMM')
71
+
72
+ //地震id
73
+ let id = ''
74
+ if (isnum(number) && isnum(timeY)) {
75
+ id = `${cint(timeY) - 1911}${number}`
76
+ }
77
+
78
+ //地震資訊網頁
79
+ // https://scweb.cwa.gov.tw/zh-TW/earthquake/Details/{地震戳記}
80
+ // 例: https://scweb.cwa.gov.tw/zh-TW/earthquake/Details/2025081903554745113
81
+ let urlWebEqInfor = `https://scweb.cwa.gov.tw/zh-TW/earthquake/Details/${tag}`
82
+
83
+ //地震報告(圖)網頁
84
+ // https://scweb.cwa.gov.tw/zh-TW/earthquake/Imgs/{地震戳記}
85
+ // 例: https://scweb.cwa.gov.tw/zh-TW/earthquake/Imgs/2025081903554745113
86
+ let urlWebEqReport = `https://scweb.cwa.gov.tw/zh-TW/earthquake/Imgs/${tag}`
87
+
88
+ //震度圖網頁
89
+ // https://scweb.cwa.gov.tw/zh-TW/earthquake/ShakeMap/{地震戳記}
90
+ // 例: https://scweb.cwa.gov.tw/zh-TW/earthquake/ShakeMap/2025081903554745113
91
+ let urlWebEqIntensity = `https://scweb.cwa.gov.tw/zh-TW/earthquake/ShakeMap/${tag}`
92
+
93
+ //即時強地動震波圖網頁
94
+ // https://scweb.cwa.gov.tw/zh-TW/earthquake/WaveformAcc/{地震戳記}
95
+ // 例: https://scweb.cwa.gov.tw/zh-TW/earthquake/WaveformAcc/2025081903554745113
96
+ let urlWebEqWave = `https://scweb.cwa.gov.tw/zh-TW/earthquake/WaveformAcc/${tag}`
97
+
98
+ //地震報告(圖)
99
+ // https://scweb.cwa.gov.tw/webdata/OLDEQ/{地震西元年月}/{地震戳記}.gif
100
+ // 例: https://scweb.cwa.gov.tw/webdata/OLDEQ/202508/2025081903554745113.gif
101
+ let urlPicEqReport = `https://scweb.cwa.gov.tw/webdata/OLDEQ/${timeYM}/${tag}.gif`
102
+
103
+ //震度圖
104
+ // https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/{地震西元年}/{地震西元年}{當年地震編號}i.png
105
+ // 例: https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/2025/2025113i.png
106
+ let urlPicEqIntensity = `https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/${timeY}/${timeY}${number}i.png`
107
+
108
+ //最大地動加速度圖
109
+ // https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/{地震西元年}/{地震西元年}{當年地震編號}a.png
110
+ // 例: https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/2025/2025113a.png
111
+ let urlPicEqPga = `https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/${timeY}/${timeY}${number}a.png`
112
+
113
+ //最大地動速度圖
114
+ // https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/{地震西元年}/{地震西元年}{當年地震編號}v.png
115
+ // 例: https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/2025/2025113v.png
116
+ let urlPicEqPgv = `https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/${timeY}/${timeY}${number}v.png`
117
+
118
+ let r = {
119
+
120
+ id,
121
+ tag,
122
+ number,
123
+ time,
124
+ timeRec,
125
+ timeTag,
126
+ ml,
127
+ depth,
128
+ location,
129
+ intensity,
130
+ longitude,
131
+ latitude,
132
+
133
+ urlWebEqInfor,
134
+ urlWebEqReport,
135
+ urlWebEqIntensity,
136
+ urlWebEqWave,
137
+ urlPicEqReport,
138
+ urlPicEqIntensity,
139
+ urlPicEqPga,
140
+ urlPicEqPgv,
141
+
142
+ }
143
+
144
+ return r
145
+ })
146
+ // console.log('rs', rs)
147
+
148
+ return rs
149
+ }
150
+
151
+
152
+ export default parserEq
@@ -0,0 +1,150 @@
1
+ import fs from 'fs'
2
+ import _ from 'lodash-es'
3
+ import w from 'wsemi'
4
+ import assert from 'assert'
5
+ import WDwdataTweq from '../src/WDwdataTweq.mjs'
6
+
7
+
8
+ describe('WDwdataTweq', function() {
9
+
10
+ let test = async() => {
11
+
12
+ let pm = w.genPm()
13
+
14
+ let ms = []
15
+
16
+ //fdDwAttime
17
+ let fdDwAttime = `./_dwAttime`
18
+ w.fsCleanFolder(fdDwAttime)
19
+
20
+ //fdDwCurrent
21
+ let fdDwCurrent = `./_dwCurrent`
22
+ w.fsCleanFolder(fdDwCurrent)
23
+
24
+ //fdResult
25
+ let fdResult = './_result'
26
+ w.fsCleanFolder(fdResult)
27
+
28
+ //funDownload
29
+ let funDownload = async() => {
30
+
31
+ //reverse
32
+ let eqs = [
33
+ {
34
+ 'id': '114115',
35
+ 'tag': '2025082116374751115',
36
+ 'number': '115',
37
+ 'time': '2025-08-21T16:37:47+08:00',
38
+ 'timeRec': '2025-08-21 16:37:47',
39
+ 'timeTag': '20250821163747',
40
+ 'ml': '5.1',
41
+ 'urlWebEqInfor': 'https://scweb.cwa.gov.tw/zh-TW/earthquake/Details/2025082116374751115',
42
+ 'urlWebEqReport': 'https://scweb.cwa.gov.tw/zh-TW/earthquake/Imgs/2025082116374751115',
43
+ 'urlWebEqIntensity': 'https://scweb.cwa.gov.tw/zh-TW/earthquake/ShakeMap/2025082116374751115',
44
+ 'urlWebEqWave': 'https://scweb.cwa.gov.tw/zh-TW/earthquake/WaveformAcc/2025082116374751115',
45
+ 'urlPicEqReport': 'https://scweb.cwa.gov.tw/webdata/OLDEQ/202508/2025082116374751115.gif',
46
+ 'urlPicEqIntensity': 'https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/2025/2025115i.png',
47
+ 'urlPicEqPga': 'https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/2025/2025115a.png',
48
+ 'urlPicEqPgv': 'https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/2025/2025115v.png'
49
+ },
50
+ {
51
+ 'id': '114116',
52
+ 'tag': '2025082214061554116',
53
+ 'number': '116',
54
+ 'time': '2025-08-22T14:06:15+08:00',
55
+ 'timeRec': '2025-08-22 14:06:15',
56
+ 'timeTag': '20250822140615',
57
+ 'ml': '5.4',
58
+ 'urlWebEqInfor': 'https://scweb.cwa.gov.tw/zh-TW/earthquake/Details/2025082214061554116',
59
+ 'urlWebEqReport': 'https://scweb.cwa.gov.tw/zh-TW/earthquake/Imgs/2025082214061554116',
60
+ 'urlWebEqIntensity': 'https://scweb.cwa.gov.tw/zh-TW/earthquake/ShakeMap/2025082214061554116',
61
+ 'urlWebEqWave': 'https://scweb.cwa.gov.tw/zh-TW/earthquake/WaveformAcc/2025082214061554116',
62
+ 'urlPicEqReport': 'https://scweb.cwa.gov.tw/webdata/OLDEQ/202508/2025082214061554116.gif',
63
+ 'urlPicEqIntensity': 'https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/2025/2025116i.png',
64
+ 'urlPicEqPga': 'https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/2025/2025116a.png',
65
+ 'urlPicEqPgv': 'https://scweb.cwa.gov.tw/webdata/drawTrace/plotContour/2025/2025116v.png'
66
+ },
67
+ ]
68
+
69
+ _.each(eqs, (v) => {
70
+
71
+ let fp = `${fdDwAttime}/${v.id}.json`
72
+
73
+ fs.writeFileSync(fp, JSON.stringify(v), 'utf8')
74
+
75
+ })
76
+
77
+ return eqs
78
+ }
79
+
80
+ let yearStart = 2022
81
+ let yearEnd = 2022
82
+ let opt = {
83
+ fdDwAttime,
84
+ fdDwCurrent,
85
+ fdResult,
86
+ funDownload,
87
+ // funGetCurrent,
88
+ // funRemove,
89
+ // funAdd,
90
+ // funModify,
91
+ }
92
+ let ev = await WDwdataTweq(yearStart, yearEnd, opt)
93
+ .catch((err) => {
94
+ console.log(err)
95
+ })
96
+ ev.on('change', (msg) => {
97
+ delete msg.type
98
+ delete msg.timeRunStart
99
+ delete msg.timeRunEnd
100
+ delete msg.timeRunSpent
101
+ // console.log('change', msg)
102
+ ms.push(msg)
103
+ if (msg.event === 'end') {
104
+ // console.log('ms', ms)
105
+ pm.resolve(ms)
106
+ }
107
+ })
108
+ // change { event: 'start', msg: 'running...' }
109
+ // change { event: 'proc-callfun-download', msg: 'start...' }
110
+ // change { event: 'proc-callfun-download', msg: 'done' }
111
+ // change { event: 'proc-callfun-getCurrent', msg: 'start...' }
112
+ // change { event: 'proc-callfun-getCurrent', msg: 'done' }
113
+ // change { event: 'compare', msg: 'start...' }
114
+ // change { event: 'compare', msg: 'done' }
115
+ // change { event: 'proc-add-callfun-add', id: '114116', msg: 'start...' }
116
+ // change { event: 'proc-add-callfun-add', id: '114116', msg: 'done' }
117
+ // change { event: 'proc-add-callfun-add', id: '114115', msg: 'start...' }
118
+ // change { event: 'proc-add-callfun-add', id: '114115', msg: 'done' }
119
+ // change {
120
+ // event: 'end',
121
+ // timeRunStart: '2025-08-23T15:47:24+08:00',
122
+ // timeRunEnd: '2025-08-23T15:47:24+08:00',
123
+ // timeRunSpent: '0s',
124
+ // msg: 'done'
125
+ // }
126
+
127
+ return pm
128
+ }
129
+ let ms = [
130
+ { event: 'start', msg: 'running...' },
131
+ { event: 'proc-callfun-download', msg: 'start...' },
132
+ { event: 'proc-callfun-download', msg: 'done' },
133
+ { event: 'proc-callfun-getCurrent', msg: 'start...' },
134
+ { event: 'proc-callfun-getCurrent', msg: 'done' },
135
+ { event: 'compare', msg: 'start...' },
136
+ { event: 'compare', msg: 'done' },
137
+ { event: 'proc-add-callfun-add', id: '114115', msg: 'start...' },
138
+ { event: 'proc-add-callfun-add', id: '114115', msg: 'done' },
139
+ { event: 'proc-add-callfun-add', id: '114116', msg: 'start...' },
140
+ { event: 'proc-add-callfun-add', id: '114116', msg: 'done' },
141
+ { event: 'end', msg: 'done' }
142
+ ]
143
+
144
+ it('test in localhost', async () => {
145
+ let r = await test()
146
+ let rr = ms
147
+ assert.strict.deepEqual(r, rr)
148
+ })
149
+
150
+ })
@@ -0,0 +1,4 @@
1
+ import addVersion from 'w-package-tools/src/addVersion.mjs'
2
+
3
+
4
+ addVersion()
@@ -0,0 +1,4 @@
1
+ import cleanFolder from 'w-package-tools/src/cleanFolder.mjs'
2
+
3
+
4
+ cleanFolder('docs')
@@ -0,0 +1,26 @@
1
+ import rollupFiles from 'w-package-tools/src/rollupFiles.mjs'
2
+ import getFiles from 'w-package-tools/src/getFiles.mjs'
3
+
4
+
5
+ let fdSrc = './src'
6
+ let fdTar = './dist'
7
+
8
+
9
+ rollupFiles({
10
+ fns: 'WDwdataTweq.mjs',
11
+ fdSrc,
12
+ fdTar,
13
+ // nameDistType: 'kebabCase',
14
+ hookNameDist: () => {
15
+ return 'w-dwdata-tweq'
16
+ },
17
+ globals: {
18
+ 'path': 'path',
19
+ 'fs': 'fs',
20
+ },
21
+ external: [
22
+ 'path',
23
+ 'fs',
24
+ ],
25
+ })
26
+
@@ -0,0 +1,4 @@
1
+ import modifyReadme from 'w-package-tools/src/modifyReadme.mjs'
2
+
3
+
4
+ modifyReadme()