public static RiverFlowSnapshot MapFlowData(string usgsGaugeId, StreamFlow usgsStreamFlow) { // Current assumptions for simplicity // 1) One site at a time though API supports multiple // 2) One parameter value at a time (most recent) though API supports time period var timeSeries = usgsStreamFlow.Value.GetTimeSeriesForSite(usgsGaugeId); var snapshot = new RiverFlowSnapshot { AsOfUTC = DateTime.UtcNow, Site = GetSiteInfo(timeSeries.FirstOrDefault()?.SourceInfo) }; foreach (var ts in timeSeries) { var dataValue = GetDataValue(ts); if (dataValue != null) { snapshot.Values.Add(dataValue); } } if (!snapshot.Values.Any()) { return(null); } return(snapshot); }
public async Task SwipeChannel(bool toRight) { var currentChannelIndex = StreamFlow.IndexOf(StreamFlow.FirstOrDefault(a => a.Channel.ChannelId.Equals(CurrentStream.Channel.ChannelId))); bool changed = false; if (toRight && StreamFlow.Count - 1 != currentChannelIndex) { // Get next channel from right. CurrentStream = StreamFlow[currentChannelIndex + 1]; changed = true; } else if (!toRight && currentChannelIndex != 0) { // Get previous channel from left. CurrentStream = StreamFlow[currentChannelIndex - 1]; changed = true; } if (CurrentStream != null && changed) { await InitializeStreamByChannelName(CurrentStream.Channel.ChannelName); } }