Пример #1
0
 /// <summary>
 /// Generate Common Alerting Protocol (1.2) from bulletin
 /// </summary>
 /// <param name="segment">The bulletin.</param>
 /// <returns>alert.</returns>
 public static alert CreateAlert(this TextProductSegment segment) => new alert
 {
     identifier = Guid.NewGuid().ToString("N"),
     //sender = $"{segment.Header.WmoHeading.WmoId}@NWS.NOAA.GOV",
     sent    = segment.TimeStamp.DateTime,
     status  = GetAlertStatus(segment.GetPrimaryVtec().FirstOrDefault()),
     msgType = alertMsgType.Alert,
     scope   = alertScope.Public,
     note    = "",
     info    = new[] { GetAlertInfo(segment) }
 };
Пример #2
0
 /// <summary>
 /// Gets the areas.
 /// </summary>
 /// <param name="segment">The bulletin.</param>
 /// <returns>Emwin.Core.Contracts.alertInfoArea[].</returns>
 private static alertInfoArea[] GetAreas(TextProductSegment segment) => new[]
 {
     new alertInfoArea
     {
         //areaDesc = "",
         polygon = segment.GetPolygons().Select(x => x.GetPolygonText()).ToArray(),
         //geocode = new[]
         //{
         //    new alertInfoAreaGeocode {valueName = "FIPS6", value = ""},
         //    new alertInfoAreaGeocode {valueName = "UGC", value = ""}
         //}
     }
 };
Пример #3
0
 /// <summary>
 /// Gets the parameters.
 /// </summary>
 /// <param name="segment">The bulletin.</param>
 /// <returns>Emwin.Core.Contracts.alertInfoParameter[].</returns>
 private static alertInfoParameter[] GetParameters(TextProductSegment segment) => new alertInfoParameter[]
 {
     //new alertInfoParameter {valueName = "WMOHEADER", value = ""},
     //new alertInfoParameter {valueName = "UGC", value = ""},
     //new alertInfoParameter
     //{
     //    valueName = "VTEC",
     //    value = string.Join(Environment.NewLine, segment.GetPrimaryVtec().First().ToRaw(), segment.HydrologicVtec?.ToRaw())
     //},
     //segment.TrackingLine == null ? null : new alertInfoParameter
     //{
     //    valueName = "TIME...MOT...LOC",
     //    value = segment.TrackingLine?.ToString()
     //}
 };
Пример #4
0
 /// <summary>
 /// Gets the alert information.
 /// </summary>
 /// <param name="segment">The bulletin.</param>
 /// <returns>Emwin.Core.Contracts.alertInfo.</returns>
 public static alertInfo GetAlertInfo(this TextProductSegment segment) => new alertInfo
 {
     category = new[] { alertInfoCategory.Met },
     //@event = "",
     //urgency = segment.PrimaryVtec.GetUrgency(),
     //severity = segment.PrimaryVtec.GetSeverity(),
     //certainty = segment.PrimaryVtec.GetCertainty(),
     //eventCode = new[] { segment.PrimaryVtec.GetEventCode() },
     //effectiveSpecified = true,
     //effective = segment.PrimaryVtec.Begin.DateTime,
     //expiresSpecified = true,
     //expires = segment.PrimaryVtec.End.DateTime,
     //senderName = "DotEmwin",
     //headline = "",
     //description = segment.Content.Body,
     //instruction = "",
     //parameter = GetParameters(segment),
     //area = GetAreas(segment)
 };
Пример #5
0
        /// <summary>
        /// Gets the segments in the text product.
        /// </summary>
        /// <param name="product">The product.</param>
        /// <returns>IEnumerable&lt;TextProductSegment&gt;.</returns>
        public static IEnumerable <TextProductSegment> GetSegments(this TextProduct product)
        {
            var matches = SegmentSplitRegex.Split(product.Content.RawBody);
            var seq     = 1;

            foreach (var segment in matches)
            {
                var newFilename = string.Concat(
                    Path.GetFileNameWithoutExtension(product.Filename),
                    '-', seq.ToString("00"),
                    Path.GetExtension(product.Filename));

                yield return(TextProductSegment.Create(
                                 newFilename,
                                 product.TimeStamp,
                                 new TextContent {
                    RawHeader = product.Content.RawHeader, RawBody = segment.Trim()
                },
                                 product.ReceivedAt,
                                 seq++,
                                 product.Source));
            }
        }