feat: Add new event sources
This commit is contained in:
@@ -61,7 +61,7 @@ namespace Cryville.EEW.Unity {
|
||||
[JsonDerivedType(typeof(JMAAtomEventSourceConfig), "JMAAtom")]
|
||||
[JsonDerivedType(typeof(NOAAEventSourceConfig), "NOAA")]
|
||||
[JsonDerivedType(typeof(UpdateCheckerEventSourceConfig), "UpdateChecker")]
|
||||
[JsonDerivedType(typeof(USGSQuakeMLEventSourceConfig), "USGSQuakeML")]
|
||||
[JsonDerivedType(typeof(USGSEventSourceConfig), "USGSQuakeML")]
|
||||
[JsonDerivedType(typeof(WolfxEventSourceConfig), "Wolfx")]
|
||||
abstract record EventSourceConfig();
|
||||
record BMKGOpenDataEventSourceConfig([property: JsonRequired] string[] Subtypes) : EventSourceConfig;
|
||||
@@ -73,7 +73,7 @@ namespace Cryville.EEW.Unity {
|
||||
record JMAAtomEventSourceConfig(IReadOnlyCollection<string> Filter = null, bool IsFilterWhitelist = false) : EventSourceConfig;
|
||||
record NOAAEventSourceConfig([property: JsonRequired] string Subtype) : EventSourceConfig;
|
||||
record UpdateCheckerEventSourceConfig : EventSourceConfig;
|
||||
record USGSQuakeMLEventSourceConfig([property: JsonRequired] string Subtype) : EventSourceConfig;
|
||||
record USGSEventSourceConfig([property: JsonRequired] string Subtype, bool UseGeoJSONFeeds, string[] Products) : EventSourceConfig;
|
||||
record WolfxEventSourceConfig(IReadOnlyCollection<string> Filter = null, bool IsFilterWhitelist = false, bool UseRawCENCLocationName = false) : EventSourceConfig;
|
||||
|
||||
[JsonSerializable(typeof(Config))]
|
||||
|
@@ -9,6 +9,7 @@ using Cryville.EEW.Map;
|
||||
using Cryville.EEW.NOAA.Map;
|
||||
using Cryville.EEW.QuakeML.Map;
|
||||
using Cryville.EEW.Report;
|
||||
using Cryville.EEW.USGS.Map;
|
||||
using Cryville.EEW.Wolfx.Map;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
@@ -145,6 +146,7 @@ namespace Cryville.EEW.Unity.Map {
|
||||
new NOAAMapGenerator(),
|
||||
new QuakeMLEventMapGenerator(),
|
||||
new SichuanEEWMapGenerator(),
|
||||
new USGSContoursMapGenerator(),
|
||||
});
|
||||
public UnityMapElement Build(object e, out CultureInfo culture, out int order) {
|
||||
culture = CultureInfo.InvariantCulture;
|
||||
|
@@ -111,8 +111,11 @@ namespace Cryville.EEW.Unity {
|
||||
worker.RegisterViewModelGenerator(new JMAAtomRVMGenerator());
|
||||
worker.RegisterViewModelGenerator(new JMAEEWRVMGenerator());
|
||||
worker.RegisterViewModelGenerator(new NOAAAtomRVMGenerator());
|
||||
worker.RegisterViewModelGenerator(new QuakeMLEventRVMGenerator());
|
||||
var quakemlEventRVMGenerator = new QuakeMLEventRVMGenerator();
|
||||
quakemlEventRVMGenerator.AddExtension(new USGSQuakeMLExtension());
|
||||
worker.RegisterViewModelGenerator(quakemlEventRVMGenerator);
|
||||
worker.RegisterViewModelGenerator(new SichuanEEWRVMGenerator());
|
||||
worker.RegisterViewModelGenerator(new USGSContoursRVMGenerator());
|
||||
worker.RegisterViewModelGenerator(new VersionRVMGenerator());
|
||||
}
|
||||
CENCEarthquakeTTSMessageGenerator _cencEarthquakeTTSMessageGenerator;
|
||||
@@ -168,7 +171,10 @@ namespace Cryville.EEW.Unity {
|
||||
_ => throw new InvalidOperationException("Unknown NOAA sub-type."),
|
||||
},
|
||||
UpdateCheckerEventSourceConfig => new UpdateCheckerWorker(typeof(Worker).Assembly.GetName().Version?.ToString(3) ?? "", "unity"),
|
||||
USGSQuakeMLEventSourceConfig usgsQuakeML => BuildUSGSQuakeMLWorkerUri(new USGSQuakeMLWorker(new("https://earthquake.usgs.gov/earthquakes/feed/v1.0/quakeml.php")), usgsQuakeML),
|
||||
USGSEventSourceConfig usgs => BuildUSGSWorker(usgs.UseGeoJSONFeeds
|
||||
? new USGSGeoJSONWorker(new Uri("https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php"))
|
||||
: new USGSQuakeMLWorker(new Uri("https://earthquake.usgs.gov/earthquakes/feed/v1.0/quakeml.php"))
|
||||
, usgs),
|
||||
WolfxEventSourceConfig wolfx => BuildWolfxWorkerFilter(new WolfxWorker(new("wss://ws-api.wolfx.jp/all_eew")), wolfx),
|
||||
_ => throw new InvalidOperationException("Unknown event source type."),
|
||||
});
|
||||
@@ -208,8 +214,16 @@ namespace Cryville.EEW.Unity {
|
||||
worker.DoGetStrongMotionInfo = pref.DoGetStrongMotionInfo;
|
||||
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));
|
||||
static USGSWorker BuildUSGSWorker(USGSWorker worker, USGSEventSourceConfig config) {
|
||||
worker.SetFeedRelativeUri(new(string.Format(CultureInfo.InvariantCulture, "/earthquakes/feed/v1.0/summary/{0}{1}", config.Subtype, config.UseGeoJSONFeeds ? ".geojson" : ".quakeml"), UriKind.Relative));
|
||||
if (worker is USGSGeoJSONWorker geojsonWorker) {
|
||||
geojsonWorker.SetFilter(
|
||||
config.Products
|
||||
.Select(i => i.Split('/', 2))
|
||||
.GroupBy(i => i[0])
|
||||
.ToDictionary(g => g.Key, g => g.Select(i => i[1]))
|
||||
);
|
||||
}
|
||||
return worker;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user