Skip to content

Commit

Permalink
fixed parser errors (#34)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Greenwood <jagreenwood@gmail.com>
  • Loading branch information
mattes-bru and jagreenwood authored Dec 9, 2024
1 parent e199663 commit 5adc849
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extension APICurrentWeather {
symbolName: (WeatherCondition(rawValue: conditionCode) ?? .undefined).sfSymbol,
dewPoint: Measurement(value: temperatureDewPoint, unit: .celsius),
humidity: humidity,
percipationIntensity: Measurement(value: precipitationIntensity, unit: .millimetersPerHour),
pressure: Measurement(value: pressure, unit: .millibars),
pressureTrend: PressureTrend(rawValue: pressureTrend) ?? .undefined,
isDaylight: daylight,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ extension APIHour {
precipitationAmount: Measurement(value: precipitationAmount, unit: .millimeters),
pressure: Measurement(value: pressure, unit: .millibars),
pressureTrend: PressureTrend(rawValue: pressureTrend) ?? .undefined,
snowfallIntensity: Measurement(value: snowfallIntensity ?? 0.0, unit: .millimetersPerHour),
snowfallAmount: Measurement(value: snowfallAmount ?? 0.0, unit: .millimeters),
temperature: Measurement(value: temperature, unit: .celsius),
apparentTemperature: Measurement(value: temperatureApparent, unit: .celsius),
uvIndex: UVIndex(value: uvIndex, category: .init(value: uvIndex)),
Expand Down
12 changes: 12 additions & 0 deletions Sources/OpenWeatherKit/Internal/Extensions/UnitSpeed.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// UnitSpeed.swift
// open-weather-kit
//
// Created by Matthias Kollmann on 20.11.24.
//

import Foundation

extension UnitSpeed {
static let millimetersPerHour: UnitSpeed = UnitSpeed(symbol: "mm/h", converter: UnitConverterLinear(coefficient: 1.0/3.6))
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct APICurrentWeather: Codable, Equatable {
let conditionCode: String
let daylight: Bool
let humidity: Double
let precipitationIntensity: Int
let precipitationIntensity: Double
let pressure: Double
let pressureTrend: String
let temperature: Double
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ struct APIHour: Codable, Equatable {
let precipitationType: String
let pressure: Double
let pressureTrend: String
let snowfallIntensity: Int
let snowfallIntensity: Double?
let snowfallAmount: Double?
let temperature: Double
let temperatureApparent: Double
let temperatureDewPoint: Double
Expand All @@ -56,6 +57,7 @@ struct APIHour: Codable, Equatable {
case pressure = "pressure"
case pressureTrend = "pressureTrend"
case snowfallIntensity = "snowfallIntensity"
case snowfallAmount = "snowfallAmount"
case temperature = "temperature"
case temperatureApparent = "temperatureApparent"
case temperatureDewPoint = "temperatureDewPoint"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct APIAlertSummary: Codable, Equatable {
let name: String
let id: String
let areaID: String
let areaName: String
let areaName: String?
let attributionURL: String
let countryCode: String
let alertDescription: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct AlertSummary: Codable, Equatable, Sendable {
public var name: String
public var id: String
public var areaID: String
public var areaName: String
public var areaName: String?
public var attributionURL: String
public var countryCode: String
public var alertDescription: String
Expand All @@ -34,7 +34,7 @@ public struct AlertSummary: Codable, Equatable, Sendable {
name: String,
id: String,
areaID: String,
areaName: String,
areaName: String?,
attributionURL: String,
countryCode: String,
alertDescription: String,
Expand Down
6 changes: 6 additions & 0 deletions Sources/OpenWeatherKit/Public/Forecast/HourWeather.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public struct HourWeather: Sendable {
/// The pressure trend, or barometric tendency, is the kind and amount of atmospheric pressure
/// change over time.
public var pressureTrend: PressureTrend

/// The rate at which snow crystals are falling, in millimeters per hour.
public var snowfallIntensity: Measurement<UnitSpeed>

/// The amount of snowfall for the hour.
public var snowfallAmount: Measurement<UnitLength>

/// The temperature during the hour.
public var temperature: Measurement<UnitTemperature>
Expand Down
5 changes: 5 additions & 0 deletions Sources/OpenWeatherKit/Public/Requests/CurrentWeather.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public struct CurrentWeather: Sendable {
symbolName: String,
dewPoint: Measurement<UnitTemperature>,
humidity: Double,
percipationIntensity: Measurement<UnitSpeed>,
pressure: Measurement<UnitPressure>,
pressureTrend: PressureTrend,
isDaylight: Bool,
Expand All @@ -33,6 +34,7 @@ public struct CurrentWeather: Sendable {
self.symbolName = symbolName
self.dewPoint = dewPoint
self.humidity = humidity
self.percipationIntensity = percipationIntensity
self.pressure = pressure
self.pressureTrend = pressureTrend
self.isDaylight = isDaylight
Expand Down Expand Up @@ -69,6 +71,9 @@ public struct CurrentWeather: Sendable {
///
/// The range of this property is from 0 to 1, inclusive.
public var humidity: Double

/// The precipitation intensity, in millimeters per hour.
public var percipationIntensity: Measurement<UnitSpeed>

/// The atmospheric pressure at sea level at a given location.
///
Expand Down

0 comments on commit 5adc849

Please sign in to comment.