From 371905a8835f8a735b8b19b19dc3515bc8aa56b9 Mon Sep 17 00:00:00 2001 From: Christian Binder <43334159+xcbinder@users.noreply.github.com> Date: Tue, 22 Aug 2023 01:28:59 +0200 Subject: [PATCH] Update ElectricityMapsDataSource.cs (#365) Issue : I have tested a ElectricityMaps forecast scenario CLI: "emissions-forecasts -l westeurope -v" will return server error 500. Analysis: public async Task GetCurrentCarbonIntensityForecastAsync(Location location) is causing the EM server to return 500. Reason is that the "." in geolocation.Latitude will be passed as "," Fix: The following changes are fixing this bug. Signed-off-by: Christian Binder <43334159+xcbinder@users.noreply.github.com> --- .../src/ElectricityMapsDataSource.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/src/ElectricityMapsDataSource.cs b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/src/ElectricityMapsDataSource.cs index ea4a99b0e..01e494bbd 100644 --- a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/src/ElectricityMapsDataSource.cs +++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/src/ElectricityMapsDataSource.cs @@ -45,8 +45,8 @@ public async Task GetCurrentCarbonIntensityForecastAsync(Loca { ForecastedCarbonIntensityData forecast; var geolocation = await this._locationSource.ToGeopositionLocationAsync(location); - if (geolocation.Latitude != null && geolocation.Latitude != null) - forecast = await this._electricityMapsClient.GetForecastedCarbonIntensityAsync (geolocation.Latitude.ToString() ?? "", geolocation.Longitude.ToString() ?? ""); + if (geolocation.Latitude != null && geolocation.Longitude != null) + forecast = await this._electricityMapsClient.GetForecastedCarbonIntensityAsync (geolocation.LatitudeAsCultureInvariantString(), geolocation.LongitudeAsCultureInvariantString()); else { forecast = await this._electricityMapsClient.GetForecastedCarbonIntensityAsync (geolocation.Name ?? "");