Skip to content

Commit

Permalink
Update ElectricityMapsDataSource.cs (#365)
Browse files Browse the repository at this point in the history
Issue : 

I have tested a ElectricityMaps forecast scenario CLI: 
"emissions-forecasts -l westeurope -v"
will return server error 500.

Analysis:

public async Task<EmissionsForecast> 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 <[email protected]>
  • Loading branch information
xcbinder authored Aug 21, 2023
1 parent ede7ab7 commit 371905a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public async Task<EmissionsForecast> 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 ?? "");
Expand Down

0 comments on commit 371905a

Please sign in to comment.