feat: Add new event sources
This commit is contained in:
@@ -34,20 +34,26 @@ namespace Cryville.EEW.Unity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[JsonPolymorphic(TypeDiscriminatorPropertyName = "Type", UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FallBackToBaseType)]
|
[JsonPolymorphic(TypeDiscriminatorPropertyName = "Type", UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FallBackToBaseType)]
|
||||||
|
[JsonDerivedType(typeof(BMKGOpenDataEventSourceConfig), "BMKGOpenData")]
|
||||||
[JsonDerivedType(typeof(CWAOpenDataEventSourceConfig), "CWAOpenData")]
|
[JsonDerivedType(typeof(CWAOpenDataEventSourceConfig), "CWAOpenData")]
|
||||||
|
[JsonDerivedType(typeof(EMSCRealTimeEventSourceConfig), "EMSCRealTime")]
|
||||||
[JsonDerivedType(typeof(GlobalQuakeServerEventSourceConfig), "GlobalQuakeServer")]
|
[JsonDerivedType(typeof(GlobalQuakeServerEventSourceConfig), "GlobalQuakeServer")]
|
||||||
[JsonDerivedType(typeof(GlobalQuakeServer15EventSourceConfig), "GlobalQuakeServer15")]
|
[JsonDerivedType(typeof(GlobalQuakeServer15EventSourceConfig), "GlobalQuakeServer15")]
|
||||||
[JsonDerivedType(typeof(JMAAtomEventSourceConfig), "JMAAtom")]
|
[JsonDerivedType(typeof(JMAAtomEventSourceConfig), "JMAAtom")]
|
||||||
[JsonDerivedType(typeof(NOAAEventSourceConfig), "NOAA")]
|
[JsonDerivedType(typeof(NOAAEventSourceConfig), "NOAA")]
|
||||||
[JsonDerivedType(typeof(UpdateCheckerEventSourceConfig), "UpdateChecker")]
|
[JsonDerivedType(typeof(UpdateCheckerEventSourceConfig), "UpdateChecker")]
|
||||||
|
[JsonDerivedType(typeof(USGSQuakeMLEventSourceConfig), "USGSQuakeML")]
|
||||||
[JsonDerivedType(typeof(WolfxEventSourceConfig), "Wolfx")]
|
[JsonDerivedType(typeof(WolfxEventSourceConfig), "Wolfx")]
|
||||||
abstract record EventSourceConfig();
|
abstract record EventSourceConfig();
|
||||||
|
record BMKGOpenDataEventSourceConfig([property: JsonRequired] string[] Subtypes) : EventSourceConfig;
|
||||||
record CWAOpenDataEventSourceConfig([property: JsonRequired] string Subtype, [property: JsonRequired] string Token) : EventSourceConfig;
|
record CWAOpenDataEventSourceConfig([property: JsonRequired] string Subtype, [property: JsonRequired] string Token) : EventSourceConfig;
|
||||||
|
record EMSCRealTimeEventSourceConfig() : EventSourceConfig;
|
||||||
record GlobalQuakeServerEventSourceConfig([property: JsonRequired] string Host, int Port = 38000) : EventSourceConfig;
|
record GlobalQuakeServerEventSourceConfig([property: JsonRequired] string Host, int Port = 38000) : EventSourceConfig;
|
||||||
record GlobalQuakeServer15EventSourceConfig(string Host, int Port = 38000) : GlobalQuakeServerEventSourceConfig(Host, Port);
|
record GlobalQuakeServer15EventSourceConfig(string Host, int Port = 38000) : GlobalQuakeServerEventSourceConfig(Host, Port);
|
||||||
record JMAAtomEventSourceConfig(IReadOnlyCollection<string> Filter = null, bool IsFilterWhitelist = false) : EventSourceConfig;
|
record JMAAtomEventSourceConfig(IReadOnlyCollection<string> Filter = null, bool IsFilterWhitelist = false) : EventSourceConfig;
|
||||||
record NOAAEventSourceConfig([property: JsonRequired] string Subtype) : EventSourceConfig;
|
record NOAAEventSourceConfig([property: JsonRequired] string Subtype) : EventSourceConfig;
|
||||||
record UpdateCheckerEventSourceConfig : EventSourceConfig;
|
record UpdateCheckerEventSourceConfig : EventSourceConfig;
|
||||||
|
record USGSQuakeMLEventSourceConfig([property: JsonRequired] string Subtype) : EventSourceConfig;
|
||||||
record WolfxEventSourceConfig(IReadOnlyCollection<string> Filter = null, bool IsFilterWhitelist = false) : EventSourceConfig;
|
record WolfxEventSourceConfig(IReadOnlyCollection<string> Filter = null, bool IsFilterWhitelist = false) : EventSourceConfig;
|
||||||
|
|
||||||
[JsonSerializable(typeof(Config))]
|
[JsonSerializable(typeof(Config))]
|
||||||
|
@@ -1,9 +1,12 @@
|
|||||||
|
using Cryville.EEW.BMKGOpenData.Map;
|
||||||
using Cryville.EEW.Core;
|
using Cryville.EEW.Core;
|
||||||
using Cryville.EEW.CWAOpenData.Map;
|
using Cryville.EEW.CWAOpenData.Map;
|
||||||
|
using Cryville.EEW.EMSC.Map;
|
||||||
using Cryville.EEW.GlobalQuake.Map;
|
using Cryville.EEW.GlobalQuake.Map;
|
||||||
using Cryville.EEW.JMAAtom.Map;
|
using Cryville.EEW.JMAAtom.Map;
|
||||||
using Cryville.EEW.Map;
|
using Cryville.EEW.Map;
|
||||||
using Cryville.EEW.NOAA.Map;
|
using Cryville.EEW.NOAA.Map;
|
||||||
|
using Cryville.EEW.QuakeML.Map;
|
||||||
using Cryville.EEW.Report;
|
using Cryville.EEW.Report;
|
||||||
using Cryville.EEW.Wolfx.Map;
|
using Cryville.EEW.Wolfx.Map;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -124,16 +127,19 @@ namespace Cryville.EEW.Unity.Map {
|
|||||||
}
|
}
|
||||||
|
|
||||||
readonly ContextedGeneratorManager<IMapGeneratorContext, MapElement> _gen = new(new IContextedGenerator<IMapGeneratorContext, MapElement>[] {
|
readonly ContextedGeneratorManager<IMapGeneratorContext, MapElement> _gen = new(new IContextedGenerator<IMapGeneratorContext, MapElement>[] {
|
||||||
|
new BMKGEarthquakeMapGenerator(),
|
||||||
new CENCEarthquakeMapGenerator(),
|
new CENCEarthquakeMapGenerator(),
|
||||||
new CENCEEWMapGenerator(),
|
new CENCEEWMapGenerator(),
|
||||||
new CWAEarthquakeMapGenerator(),
|
new CWAEarthquakeMapGenerator(),
|
||||||
new CWAEEWMapGenerator(),
|
new CWAEEWMapGenerator(),
|
||||||
new CWATsunamiMapGenerator(),
|
new CWATsunamiMapGenerator(),
|
||||||
|
new EMSCRealTimeEventMapGenerator(),
|
||||||
new FujianEEWMapGenerator(),
|
new FujianEEWMapGenerator(),
|
||||||
new GlobalQuakeMapViewGenerator(),
|
new GlobalQuakeMapViewGenerator(),
|
||||||
new JMAAtomMapGenerator(),
|
new JMAAtomMapGenerator(),
|
||||||
new JMAEEWMapGenerator(),
|
new JMAEEWMapGenerator(),
|
||||||
new NOAAMapGenerator(),
|
new NOAAMapGenerator(),
|
||||||
|
new QuakeMLEventMapGenerator(),
|
||||||
new SichuanEEWMapGenerator(),
|
new SichuanEEWMapGenerator(),
|
||||||
});
|
});
|
||||||
public UnityMapElement Build(object e, out CultureInfo culture, out int order) {
|
public UnityMapElement Build(object e, out CultureInfo culture, out int order) {
|
||||||
|
@@ -1,21 +1,27 @@
|
|||||||
|
using Cryville.EEW.BMKGOpenData;
|
||||||
|
using Cryville.EEW.BMKGOpenData.TTS;
|
||||||
using Cryville.EEW.Core;
|
using Cryville.EEW.Core;
|
||||||
using Cryville.EEW.CWAOpenData;
|
using Cryville.EEW.CWAOpenData;
|
||||||
using Cryville.EEW.CWAOpenData.Model;
|
using Cryville.EEW.CWAOpenData.Model;
|
||||||
using Cryville.EEW.CWAOpenData.TTS;
|
using Cryville.EEW.CWAOpenData.TTS;
|
||||||
|
using Cryville.EEW.EMSC;
|
||||||
using Cryville.EEW.GlobalQuake;
|
using Cryville.EEW.GlobalQuake;
|
||||||
using Cryville.EEW.JMAAtom;
|
using Cryville.EEW.JMAAtom;
|
||||||
using Cryville.EEW.JMAAtom.TTS;
|
using Cryville.EEW.JMAAtom.TTS;
|
||||||
using Cryville.EEW.NOAA;
|
using Cryville.EEW.NOAA;
|
||||||
using Cryville.EEW.NOAA.TTS;
|
using Cryville.EEW.NOAA.TTS;
|
||||||
|
using Cryville.EEW.QuakeML;
|
||||||
using Cryville.EEW.Report;
|
using Cryville.EEW.Report;
|
||||||
using Cryville.EEW.Unity.Map;
|
using Cryville.EEW.Unity.Map;
|
||||||
using Cryville.EEW.Unity.UI;
|
using Cryville.EEW.Unity.UI;
|
||||||
using Cryville.EEW.UpdateChecker;
|
using Cryville.EEW.UpdateChecker;
|
||||||
|
using Cryville.EEW.USGS;
|
||||||
using Cryville.EEW.Wolfx;
|
using Cryville.EEW.Wolfx;
|
||||||
using Cryville.EEW.Wolfx.Model;
|
using Cryville.EEW.Wolfx.Model;
|
||||||
using Cryville.EEW.Wolfx.TTS;
|
using Cryville.EEW.Wolfx.TTS;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
@@ -80,20 +86,24 @@ namespace Cryville.EEW.Unity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void RegisterViewModelGenerators(CoreWorker worker) {
|
static void RegisterViewModelGenerators(CoreWorker worker) {
|
||||||
|
worker.RegisterViewModelGenerator(new BMKGEarthquakeRVMGenerator());
|
||||||
worker.RegisterViewModelGenerator(new CENCEarthquakeRVMGenerator());
|
worker.RegisterViewModelGenerator(new CENCEarthquakeRVMGenerator());
|
||||||
worker.RegisterViewModelGenerator(new CENCEEWRVMGenerator());
|
worker.RegisterViewModelGenerator(new CENCEEWRVMGenerator());
|
||||||
worker.RegisterViewModelGenerator(new CWAEarthquakeRVMGenerator());
|
worker.RegisterViewModelGenerator(new CWAEarthquakeRVMGenerator());
|
||||||
worker.RegisterViewModelGenerator(new CWAEEWRVMGenerator());
|
worker.RegisterViewModelGenerator(new CWAEEWRVMGenerator());
|
||||||
worker.RegisterViewModelGenerator(new CWATsunamiRVMGenerator());
|
worker.RegisterViewModelGenerator(new CWATsunamiRVMGenerator());
|
||||||
|
worker.RegisterViewModelGenerator(new EMSCRealTimeEventRVMGenerator());
|
||||||
worker.RegisterViewModelGenerator(new FujianEEWRVMGenerator());
|
worker.RegisterViewModelGenerator(new FujianEEWRVMGenerator());
|
||||||
worker.RegisterViewModelGenerator(new GlobalQuakeRVMGenerator());
|
worker.RegisterViewModelGenerator(new GlobalQuakeRVMGenerator());
|
||||||
worker.RegisterViewModelGenerator(new JMAAtomRVMGenerator());
|
worker.RegisterViewModelGenerator(new JMAAtomRVMGenerator());
|
||||||
worker.RegisterViewModelGenerator(new JMAEEWRVMGenerator());
|
worker.RegisterViewModelGenerator(new JMAEEWRVMGenerator());
|
||||||
worker.RegisterViewModelGenerator(new NOAAAtomRVMGenerator());
|
worker.RegisterViewModelGenerator(new NOAAAtomRVMGenerator());
|
||||||
|
worker.RegisterViewModelGenerator(new QuakeMLEventRVMGenerator());
|
||||||
worker.RegisterViewModelGenerator(new SichuanEEWRVMGenerator());
|
worker.RegisterViewModelGenerator(new SichuanEEWRVMGenerator());
|
||||||
worker.RegisterViewModelGenerator(new VersionRVMGenerator());
|
worker.RegisterViewModelGenerator(new VersionRVMGenerator());
|
||||||
}
|
}
|
||||||
static void RegisterTTSMessageGenerators(CoreWorker worker) {
|
static void RegisterTTSMessageGenerators(CoreWorker worker) {
|
||||||
|
worker.RegisterTTSMessageGenerator(new BMKGEarthquakeTTSMessageGenerator());
|
||||||
worker.RegisterTTSMessageGenerator(new CENCEarthquakeTTSMessageGenerator());
|
worker.RegisterTTSMessageGenerator(new CENCEarthquakeTTSMessageGenerator());
|
||||||
worker.RegisterTTSMessageGenerator(new CENCEEWTTSMessageGenerator());
|
worker.RegisterTTSMessageGenerator(new CENCEEWTTSMessageGenerator());
|
||||||
worker.RegisterTTSMessageGenerator(new CWAEarthquakeTTSMessageGenerator());
|
worker.RegisterTTSMessageGenerator(new CWAEarthquakeTTSMessageGenerator());
|
||||||
@@ -114,17 +124,22 @@ namespace Cryville.EEW.Unity {
|
|||||||
_worker.AddWorker(new CWAReportWorker<Tsunami>(new Uri("http://localhost:9095/E-A0014-001.json"), "1"));
|
_worker.AddWorker(new CWAReportWorker<Tsunami>(new Uri("http://localhost:9095/E-A0014-001.json"), "1"));
|
||||||
_worker.AddWorker(new CWAReportWorker<Earthquake>(new Uri("http://localhost:9095/E-A0015-001.json"), "1"));
|
_worker.AddWorker(new CWAReportWorker<Earthquake>(new Uri("http://localhost:9095/E-A0015-001.json"), "1"));
|
||||||
_worker.AddWorker(new CWAReportWorker<Earthquake>(new Uri("http://localhost:9095/E-A0016-001.json"), "1"));
|
_worker.AddWorker(new CWAReportWorker<Earthquake>(new Uri("http://localhost:9095/E-A0016-001.json"), "1"));
|
||||||
|
BMKGOpenDataWorker bmkgWorker = new(new Uri("http://localhost:9095/autogempa.json"));
|
||||||
|
bmkgWorker.SetDataUris(new Uri[] { new("http://localhost:9095/gempadirasakan.json") });
|
||||||
|
_worker.AddWorker(bmkgWorker);
|
||||||
_worker.AddWorker(new NOAAAtomWorker(new("http://localhost:9095/PAAQAtom.xml")));
|
_worker.AddWorker(new NOAAAtomWorker(new("http://localhost:9095/PAAQAtom.xml")));
|
||||||
_worker.AddWorker(new UpdateCheckerWorker(typeof(Worker).Assembly.GetName().Version?.ToString(3) ?? "", "unity"));
|
_worker.AddWorker(new UpdateCheckerWorker(typeof(Worker).Assembly.GetName().Version?.ToString(3) ?? "", "unity"));
|
||||||
#else
|
#else
|
||||||
foreach (var source in SharedSettings.Instance.EventSources) {
|
foreach (var source in SharedSettings.Instance.EventSources) {
|
||||||
_worker.AddWorker(source switch {
|
_worker.AddWorker(source switch {
|
||||||
|
BMKGOpenDataEventSourceConfig bmkgOpenData => BuildBMKGOpenDataWorkerUris(new BMKGOpenDataWorker(new("https://data.bmkg.go.id/DataMKG/TEWS/autogempa.json")), bmkgOpenData),
|
||||||
CWAOpenDataEventSourceConfig cwaOpenData => cwaOpenData.Subtype switch {
|
CWAOpenDataEventSourceConfig cwaOpenData => cwaOpenData.Subtype switch {
|
||||||
"E-A0014-001" => new CWAReportWorker<Tsunami>(new Uri("https://opendata.cwa.gov.tw/api/v1/rest/datastore/E-A0014-001"), cwaOpenData.Token, 1440, 17280),
|
"E-A0014-001" => new CWAReportWorker<Tsunami>(new Uri("https://opendata.cwa.gov.tw/api/v1/rest/datastore/E-A0014-001"), cwaOpenData.Token, 1440, 17280),
|
||||||
"E-A0015-001" => new CWAReportWorker<Earthquake>(new Uri("https://opendata.cwa.gov.tw/api/v1/rest/datastore/E-A0015-001"), cwaOpenData.Token),
|
"E-A0015-001" => new CWAReportWorker<Earthquake>(new Uri("https://opendata.cwa.gov.tw/api/v1/rest/datastore/E-A0015-001"), cwaOpenData.Token),
|
||||||
"E-A0016-001" => new CWAReportWorker<Earthquake>(new Uri("https://opendata.cwa.gov.tw/api/v1/rest/datastore/E-A0016-001"), cwaOpenData.Token),
|
"E-A0016-001" => new CWAReportWorker<Earthquake>(new Uri("https://opendata.cwa.gov.tw/api/v1/rest/datastore/E-A0016-001"), cwaOpenData.Token),
|
||||||
_ => throw new InvalidOperationException("Unknown CWA open data sub-type."),
|
_ => throw new InvalidOperationException("Unknown CWA open data sub-type."),
|
||||||
},
|
},
|
||||||
|
EMSCRealTimeEventSourceConfig => new EMSCRealTimeWorker(new("wss://www.seismicportal.eu/standing_order/websocket")),
|
||||||
GlobalQuakeServer15EventSourceConfig gq => new GlobalQuakeWorker15(gq.Host, gq.Port),
|
GlobalQuakeServer15EventSourceConfig gq => new GlobalQuakeWorker15(gq.Host, gq.Port),
|
||||||
GlobalQuakeServerEventSourceConfig gq => new GlobalQuakeWorker(gq.Host, gq.Port),
|
GlobalQuakeServerEventSourceConfig gq => new GlobalQuakeWorker(gq.Host, gq.Port),
|
||||||
JMAAtomEventSourceConfig jmaAtom => BuildJMAAtomWorkerFilter(new JMAAtomWorker(new("https://www.data.jma.go.jp/developer/xml/feed/eqvol.xml")), jmaAtom),
|
JMAAtomEventSourceConfig jmaAtom => BuildJMAAtomWorkerFilter(new JMAAtomWorker(new("https://www.data.jma.go.jp/developer/xml/feed/eqvol.xml")), jmaAtom),
|
||||||
@@ -134,18 +149,19 @@ namespace Cryville.EEW.Unity {
|
|||||||
_ => throw new InvalidOperationException("Unknown NOAA sub-type."),
|
_ => throw new InvalidOperationException("Unknown NOAA sub-type."),
|
||||||
},
|
},
|
||||||
UpdateCheckerEventSourceConfig => new UpdateCheckerWorker(typeof(Worker).Assembly.GetName().Version?.ToString(3) ?? "", "unity"),
|
UpdateCheckerEventSourceConfig => new UpdateCheckerWorker(typeof(Worker).Assembly.GetName().Version?.ToString(3) ?? "", "unity"),
|
||||||
|
USGSQuakeMLEventSourceConfig usgsQuakeML => BuildUSGSQuakeMLWorkerUri(new USGSQuakeMLWorker(new Uri("https://earthquake.usgs.gov/earthquakes/feed/v1.0/quakeml.php")), usgsQuakeML),
|
||||||
WolfxEventSourceConfig wolfx => BuildWolfxWorkerFilter(new WolfxWorker(new Uri("wss://ws-api.wolfx.jp/all_eew")), wolfx),
|
WolfxEventSourceConfig wolfx => BuildWolfxWorkerFilter(new WolfxWorker(new Uri("wss://ws-api.wolfx.jp/all_eew")), wolfx),
|
||||||
_ => throw new InvalidOperationException("Unknown event source type."),
|
_ => throw new InvalidOperationException("Unknown event source type."),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
JMAAtomWorker BuildJMAAtomWorkerFilter(JMAAtomWorker worker, JMAAtomEventSourceConfig config) {
|
static JMAAtomWorker BuildJMAAtomWorkerFilter(JMAAtomWorker worker, JMAAtomEventSourceConfig config) {
|
||||||
if (config.Filter != null) worker.SetFilter(config.Filter);
|
if (config.Filter != null) worker.SetFilter(config.Filter);
|
||||||
worker.IsFilterWhitelist = config.IsFilterWhitelist;
|
worker.IsFilterWhitelist = config.IsFilterWhitelist;
|
||||||
return worker;
|
return worker;
|
||||||
}
|
}
|
||||||
WolfxWorker BuildWolfxWorkerFilter(WolfxWorker worker, WolfxEventSourceConfig config) {
|
static WolfxWorker BuildWolfxWorkerFilter(WolfxWorker worker, WolfxEventSourceConfig config) {
|
||||||
if (config.Filter != null) worker.SetFilter(config.Filter.Select(i => i switch {
|
if (config.Filter != null) worker.SetFilter(config.Filter.Select(i => i switch {
|
||||||
"cenc_eew" => typeof(CENCEEW),
|
"cenc_eew" => typeof(CENCEEW),
|
||||||
"cenc_eqlist" => typeof(WolfxEarthquakeList<CENCEarthquake>),
|
"cenc_eqlist" => typeof(WolfxEarthquakeList<CENCEarthquake>),
|
||||||
@@ -158,6 +174,14 @@ namespace Cryville.EEW.Unity {
|
|||||||
worker.IsFilterWhitelist = config.IsFilterWhitelist;
|
worker.IsFilterWhitelist = config.IsFilterWhitelist;
|
||||||
return worker;
|
return worker;
|
||||||
}
|
}
|
||||||
|
static BMKGOpenDataWorker BuildBMKGOpenDataWorkerUris(BMKGOpenDataWorker worker, BMKGOpenDataEventSourceConfig config) {
|
||||||
|
worker.SetDataUris(config.Subtypes.Select(i => new Uri(string.Format(CultureInfo.InvariantCulture, "https://data.bmkg.go.id/DataMKG/TEWS/{0}.json", i))));
|
||||||
|
return worker;
|
||||||
|
}
|
||||||
|
static USGSQuakeMLWorker BuildUSGSQuakeMLWorkerUri(USGSQuakeMLWorker worker, USGSQuakeMLEventSourceConfig config) {
|
||||||
|
worker.SetFeedRelativeUri(new(string.Format(CultureInfo.InvariantCulture, "/earthquakes/feed/v1.0/summary/{0}.quakeml", config.Subtype), UriKind.Relative));
|
||||||
|
return worker;
|
||||||
|
}
|
||||||
|
|
||||||
readonly OngoingReportManager _ongoingReportManager = new();
|
readonly OngoingReportManager _ongoingReportManager = new();
|
||||||
readonly ConcurrentQueue<Action> _uiActionQueue = new();
|
readonly ConcurrentQueue<Action> _uiActionQueue = new();
|
||||||
|
Reference in New Issue
Block a user