Skip to content

Conversation

@tsjdev-apps
Copy link
Owner

Introduces AirPolutionComponents, AirPolutionEntry, AirPolutionIndex, and AirPolutionRoot classes to represent air quality data, pollutant concentrations, AQI, and API response structure. These models enable structured deserialization and handling of air pollution data from the OpenWeatherMap API.
This pull request introduces support for retrieving and displaying air pollution data from the OpenWeatherMap API. The changes include new API methods, data models, utility extensions, and unit tests to ensure functionality. The most important changes are grouped into functionality additions, data modeling, utility updates, and testing enhancements.

Functionality Additions:

  • API Methods for Air Pollution Data: Added methods in IOpenWeatherMapService and OpenWeatherMapService to retrieve current, forecasted, and historical air pollution data using geographic coordinates. ([[1]](https://github.com/tsjdev-apps/openweathermap-sharp/pull/10/files#diff-440e3d00a7ca4edf88d6fd6474e5df8b229872460600e623022ce46ab7bef452R124-R157), [[2]](https://github.com/tsjdev-apps/openweathermap-sharp/pull/10/files#diff-f268d1876ec5d13f379dd36ef5b70b6f47e8f8f310e57c3cb28f764c516fb30aR151-R171))
  • Air Pollution Display in Console Application: Integrated air pollution data into the console application, including a panel that visualizes AQI and pollutant concentrations. ([samples/OpenWeatherMapSharp.Console/Program.csR90-R134](https://github.com/tsjdev-apps/openweathermap-sharp/pull/10/files#diff-b33f3f44842b0cd27151536e7a0fc369618dfde39d2774a476c09ee6b490b8e9R90-R134))

Data Modeling:

  • Air Pollution Models: Added AirPolutionRoot, AirPolutionEntry, AirPolutionComponents, and AirPolutionIndex classes to represent air pollution data retrieved from the API. ([[1]](https://github.com/tsjdev-apps/openweathermap-sharp/pull/10/files#diff-c99198f91e1935b67de9f1a0559d6f692ab9091666717c87c2a2e3a659d72534R1-R23), [[2]](https://github.com/tsjdev-apps/openweathermap-sharp/pull/10/files#diff-010961e333b3e14e0fbdc047babe8be7cd87afb7c24a6dac16b4c54586405a86R1-R39), [[3]](https://github.com/tsjdev-apps/openweathermap-sharp/pull/10/files#diff-2a19f3d847c7d58047a72cb1cbc7692d6d56321638efdedbee265537f87cb555R1-R59), [[4]](https://github.com/tsjdev-apps/openweathermap-sharp/pull/10/files#diff-f742bd8331b13cb597f05190d55c403af7e2d623be7570257d0deb5a87b65900R1-R16))

Utility Updates:

  • Unix Timestamp Conversion: Added DateTimeExtensions for converting DateTime to Unix timestamps and updated LongExtensions to ensure timestamps are handled in UTC. ([[1]](https://github.com/tsjdev-apps/openweathermap-sharp/pull/10/files#diff-28a2eb861d9240db8529ef6049628a97f7d5e37e21ea0edd964beaf1d24c9892R1-R27), [[2]](https://github.com/tsjdev-apps/openweathermap-sharp/pull/10/files#diff-dcf54a12972a0b5007eeb66f2d0e88d96b6d3ced0d8c0d4fb89d42cd0873d00cL20-R25))
  • API Endpoint Constants: Introduced constants in Statics for air pollution API endpoints, including current, forecast, and historical data URIs. ([[1]](https://github.com/tsjdev-apps/openweathermap-sharp/pull/10/files#diff-424c8fbf4e4d4849fb754ae75ee7f0e30374a15916c7d9757fdf34f114c51eecR20-R22), [[2]](https://github.com/tsjdev-apps/openweathermap-sharp/pull/10/files#diff-424c8fbf4e4d4849fb754ae75ee7f0e30374a15916c7d9757fdf34f114c51eecR86-R106))

Testing Enhancements:

  • Unit Tests for Air Pollution Methods: Added tests to validate the functionality of retrieving current, forecasted, and historical air pollution data, ensuring proper responses and data plausibility. ([tests/OpenWeatherMapSharp.UnitTests/OpenWeatherMapServiceTests.csR268-R343](https://github.com/tsjdev-apps/openweathermap-sharp/pull/10/files#diff-b7661d50f7227a93f6bf7077d7f406e5e88178f35b32cb935ab43f55b2b90d15R268-R343))

Introduces AirPolutionComponents, AirPolutionEntry, AirPolutionIndex, and AirPolutionRoot classes to represent air quality data, pollutant concentrations, AQI, and API response structure. These models enable structured deserialization and handling of air pollution data from the OpenWeatherMap API.
Changed the ToDateTime method to return universal time (UTC) instead of local time when converting a Unix timestamp. This ensures consistent time representation across different environments.
Introduces DateTimeExtensions with a ToUnixTimestamp method for converting DateTime objects to Unix timestamps in seconds. Ensures conversion to UTC before calculation.
Introduces static URI strings for air pollution data, forecast, and history endpoints in the Statics utility class. This enables easier access to OpenWeatherMap air pollution APIs by geographic coordinates.
Introduces methods to retrieve current, forecast, and historical air pollution data in IOpenWeatherMapService and implements them in OpenWeatherMapService. This extends the API coverage to include air pollution endpoints.
Added unit tests for GetAirPollutionAsync, GetAirPollutionForecastAsync, and GetAirPollutionHistoryAsync methods in OpenWeatherMapService. These tests verify valid responses, future forecast entries, and historical data within a specified time range.
Fetches air pollution data using OpenWeatherMap API and displays AQI and pollutant levels in a new panel. Includes AQI meaning mapping and error handling for data retrieval.
@tsjdev-apps tsjdev-apps merged commit adde240 into main Jul 22, 2025
1 check passed
@tsjdev-apps tsjdev-apps deleted the feature/airpolution branch July 22, 2025 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants