public List <WeatherReport> GetWeatherForAllNodes(DateTime?time = null) { List <WeatherReport> reports = new List <WeatherReport>(); foreach (var matchingNode in _config.Nodes) { if (matchingNode == null) { return(null); } var fixedPointLat = matchingNode.Latitude; var fixedPointLon = matchingNode.Longitude; var lat = FixedPointCoordConversion.ToFloat(fixedPointLat); var lon = FixedPointCoordConversion.ToFloat(fixedPointLon); var request = time.HasValue ? new ForecastIORequest(_config.APIKey, lat, lon, time.Value, Unit.us) : new ForecastIORequest(_config.APIKey, lat, lon, Unit.us); var response = request.Get(); var report = new WeatherReport(); report.Hourly = response.hourly?.data?.Select(x => MapWeatherHourly(x, fixedPointLat, fixedPointLon)).ToList(); report.Daily = response.daily?.data?.Select(x => MapWeatherDaily(x, fixedPointLat, fixedPointLon)).ToList(); reports.Add(report); } return(reports); }
public DistanceFilter(int lat, int lon, double distanceThreshold) { var doubleLat = FixedPointCoordConversion.ToDouble(lat); var doubleLon = FixedPointCoordConversion.ToDouble(lon); _originLat = doubleLat; _originLon = doubleLon; _distanceThreshold = distanceThreshold; }
public IEnumerable <T> FilterCoords(IEnumerable <T> coords) { return(coords.Where(x => Geometry.Measure( _originLat, _originLon, FixedPointCoordConversion.ToDouble(x.Latitude), FixedPointCoordConversion.ToDouble(x.Longitude)) < _distanceThreshold )); }
public WeatherReport GetWeather(string nodeName, DateTime?time = null) { var matchingNode = _config.Nodes.FirstOrDefault(x => x.Name == nodeName); if (matchingNode == null) { return(null); } var fixedPointLat = matchingNode.Latitude; var fixedPointLon = matchingNode.Longitude; var lat = FixedPointCoordConversion.ToFloat(fixedPointLat); var lon = FixedPointCoordConversion.ToFloat(fixedPointLon); var request = time.HasValue ? new ForecastIORequest(_config.APIKey, lat, lon, time.Value, Unit.us) : new ForecastIORequest(_config.APIKey, lat, lon, Unit.us); var response = request.Get(); var report = new WeatherReport(); report.Hourly = response.hourly?.data?.Select(x => MapWeatherHourly(x, fixedPointLat, fixedPointLon)).ToList(); report.Daily = response.daily?.data?.Select(x => MapWeatherDaily(x, fixedPointLat, fixedPointLon)).ToList(); return(report); }