@@ -87,4 +87,49 @@ OpenWeatherMapServiceResponse<WeatherRoot> weatherResponse
8787} ;
8888AnsiConsole . Write ( weatherPanel ) ;
8989
90+ // == AIR POLLUTION ==
91+ OpenWeatherMapServiceResponse < AirPolutionRoot > airPollutionResponse
92+ = await openWeatherMapService . GetAirPolutionAsync ( geolocation . Latitude , geolocation . Longitude ) ;
93+
94+ if ( ! airPollutionResponse . IsSuccess || airPollutionResponse . Response is not AirPolutionRoot airQuality || airQuality . Entries . Count == 0 )
95+ {
96+ AnsiConsole . MarkupLine ( "[bold red]Unfortunately I can't retrieve air pollution data. Please try again.[/]" ) ;
97+ return ;
98+ }
99+
100+ AirPolutionEntry pollution = airQuality . Entries . First ( ) ;
101+
102+ // Map AQI to meaning
103+ string GetAqiMeaning ( int aqi ) => aqi switch
104+ {
105+ 1 => "[green]Good[/]" ,
106+ 2 => "[yellow]Fair[/]" ,
107+ 3 => "[orange1]Moderate[/]" ,
108+ 4 => "[red]Poor[/]" ,
109+ 5 => "[maroon]Very Poor[/]" ,
110+ _ => "[grey]Unknown[/]"
111+ } ;
112+
113+ // == AIR POLLUTION PANEL ==
114+ List < Markup > pollutionMarkupList =
115+ [
116+ new ( $ "[red]Air Quality Index (AQI): [/]{ pollution . AQI . Index } ({ GetAqiMeaning ( pollution . AQI . Index ) } )") ,
117+ new ( "-----" ) ,
118+ new ( $ "[red]PM2.5: [/]{ pollution . Components . FineParticlesMatter : 0.00} µg/m³") ,
119+ new ( $ "[red]PM10: [/]{ pollution . Components . CoarseParticulateMatter : 0.00} µg/m³") ,
120+ new ( $ "[red]O₃ (Ozone): [/]{ pollution . Components . Ozone : 0.00} µg/m³") ,
121+ new ( $ "[red]NO₂ (Nitrogen Dioxide): [/]{ pollution . Components . NitrogenDioxide : 0.00} µg/m³") ,
122+ new ( $ "[red]SO₂ (Sulfur Dioxide): [/]{ pollution . Components . SulfurDioxide : 0.00} µg/m³") ,
123+ new ( $ "[red]CO (Carbon Monoxide): [/]{ pollution . Components . CarbonMonoxide : 0.00} µg/m³") ,
124+ new ( $ "[red]NH₃ (Ammonia): [/]{ pollution . Components . Ammonia : 0.00} µg/m³")
125+ ] ;
126+
127+ Panel pollutionPanel = new ( new Rows ( pollutionMarkupList ) )
128+ {
129+ Header = new PanelHeader ( "Air Pollution" ) ,
130+ Width = 120
131+ } ;
132+ AnsiConsole . Write ( pollutionPanel ) ;
133+
134+
90135Console . ReadLine ( ) ;
0 commit comments