Feature Generator
CysTerra can display complex details of an event both as texts and map elements, provided a feature is generated for the event. Feature generators are the components responsible for generating features from events.
A feature generator is a class implementing the IGenerator<Feature> interface. The following is an example implementation.
using Cryville.Common.Compat;
using Cryville.EEW;
using Cryville.EEW.Features;
using System;
using System.Globalization;
using static Cryville.EEW.TagTypeKeys;
public class MyFeatureGenerator : IGenerator<MyEvent, Feature> {
public Feature Generate(MyEvent e, ref CultureInfo culture) {
ThrowHelper.ThrowIfNull(e);
var f = new Feature() {
{ Is, Earthquake },
{ Time, /* ... */ },
{ At, new Feature(new Point(/* ... */)) {
{ Is, Hypocenter },
{ Name, /* ... */ },
{ HypocenterDepth, /* ... */ },
} },
{ Magnitude, /* ... */ },
{ Source, /* ... */ },
};
return f;
}
}
A feature is essentially a dictionary with TagTypeKey keys and any values. The keys defined in TagTypeKeys are usually used, and therefore it is recommended to use using static Cryville.EEW.TagTypeKeys;. Different keys have different recommended value types. See the API documentation of TagTypeKeys for more details.
For more information, see the API documentation of the Feature class.
A TTS message generator is built with a builder exported with [Export(typeof(IBuilder<IGenerator<Feature>>))].
Quantity
It is very common for physical quantities to appear in a feature, such as length, acceleration, etc. The package Cryville.Measure provides several types to represent these quantities.
| Type | Usage |
|---|---|
| Quantity | Represents a value with a unit, uncertainty unspecified |
| QuantityInc | Represents a value with a unit, uncertainty implied |
| QuantityUnc | Represents a value with a unit, uncertainty explicitly specified |
| Interval<Quantity> | Represents an interval of quantity |
| Interval<QuantityInc> | Represents an interval of quantity with implied uncertainty |
Examples:
new Quantity(10.0, Units.Metre): 10mnew QuantityInc(1.2, 0.05, Units.Metre): 1.2mnew QuantityInc(1.2, 0.005, Units.Metre): 1.20mnew QuantityUnc(12.0, 3.4, Units.Metre): 12.0±3.4mnew QuantityUnc(12.0, 3.4, 5.6, Units.Metre): 12.0(-3.4/+5.6)m
For quantities without a unit, use Dimensionless as the unit.