private DateTimeOffset?GetMeasurementTime(XmlRootSummaryStation station, string lastStationId)
        {
            //station.Start_T is "-" at the first and last station. It should be safe to assume
            //that first has the start measurement time and last has the end time.

            var timeText = station.Start_T?.Trim();

            if (string.IsNullOrEmpty(timeText) || timeText == "-")
            {
                if (station.id == "1")
                {
                    return(_measurementInterval.Start);
                }

                if (station.id == lastStationId)
                {
                    return(_measurementInterval.End);
                }

                throw new ArgumentException($"'{station.Start_T}' is not a valid start time for station ID={station.id}");
            }

            if (!DateTime.TryParse(timeText, CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault, out var dateTime) || dateTime.Date != DateTime.MinValue)
            {
                throw new ArgumentException($"'{station.Start_T}' is not a valid start time for station ID={station.id}");
            }

            return(new DateTimeOffset(_measurementInterval.Start.Date, _measurementInterval.Start.Offset)
                   .Add(dateTime.TimeOfDay));
        }
 private Segment GetSegment(XmlRootSummaryStation station)
 {
     return(new Segment
     {
         Area = station.Area.AsDouble(),
         Discharge = station.Stn_Q.AsDouble(),
         Velocity = station.Avg_V.AsDouble(),
         Width = station.Width.AsDouble(),
         TotalDischargePortion = station.Percent_Tot.AsDouble()
     });
 }
 private VelocityDepthObservation GetVelocityDepthObservation(XmlRootSummaryStation station)
 {
     //TODO: some fields are not applicable. eg. RevolutionCount.
     return(new VelocityDepthObservation
     {
         Depth = station.ADCP_Depth.AsDouble(),
         ObservationInterval = station.Meas_T.AsDouble(),
         RevolutionCount = 0,
         Velocity = station.Avg_V.AsDouble()
     });
 }
        private VelocityObservation GetVelocityObservation(XmlRootSummaryStation station)
        {
            var observation = GetVelocityDepthObservation(station);

            return(new VelocityObservation
            {
                MeterCalibration = _meterCalibration,
                DeploymentMethod = DeploymentMethodType.StationaryBoat,
                //TODO: This is required, but OneAtPointFive is not correct for ADCP measurement.
                VelocityObservationMethod = PointVelocityObservationType.OneAtPointFive,
                MeanVelocity = station.Avg_V.AsDouble(),
                Observations = { observation }
            });
        }
 private Vertical Map(XmlRootSummaryStation station, string lastStationId)
 {
     return(new Vertical
     {
         Segment = GetSegment(station),
         MeasurementConditionData = CreateMeasurementCondition(station),
         TaglinePosition = station.Dist.AsDouble(),
         SequenceNumber = int.Parse(station.id),
         MeasurementTime = GetMeasurementTime(station, lastStationId),
         VerticalType = VerticalType.MidRiver, //TODO: is this correct?
         SoundedDepth = station.Depth.AsDouble(),
         EffectiveDepth = station.Depth.AsDouble() - station.WS_Btm_Of_Slush.AsDouble(),
         VelocityObservation = GetVelocityObservation(station),
         FlowDirection = FlowDirectionType.Normal,
         Comments = AddUnMappedFieldsToVerticalComments(station)
     });
 }
        private MeasurementConditionData CreateMeasurementCondition(XmlRootSummaryStation station)
        {
            var isIce = station.WS_Btm_Of_Ice != 0 ||
                        station.WS_Btm_Of_Slush != 0 ||
                        station.Solid_Ice_Thickness != 0;

            if (isIce)
            {
                return new IceCoveredData
                       {
                           IceThickness = station.Solid_Ice_Thickness.AsDouble(),
                           WaterSurfaceToBottomOfIce   = station.WS_Btm_Of_Ice.AsDouble(),
                           WaterSurfaceToBottomOfSlush = station.WS_Btm_Of_Slush.AsDouble()
                       }
            }
            ;

            return(new OpenWaterData());
        }
 private string AddUnMappedFieldsToVerticalComments(XmlRootSummaryStation station)
 {
     return($"Dir.: {station.Dir_V}; " +
            $"Coeff. of Var.: {station.CV};" +
            $" Angle Corr. Coeff.: {station.Ang_Cf}");
 }