Skip to content

Commit e804d8d

Browse files
committed
Fixed Float/Double casting
1 parent fd490d8 commit e804d8d

File tree

2 files changed

+50
-50
lines changed

2 files changed

+50
-50
lines changed

Source/DataPoint.swift

+46-46
Original file line numberDiff line numberDiff line change
@@ -27,91 +27,91 @@ public struct DataPoint {
2727
public let sunsetTime: Date?
2828

2929
/// The fractional part of the lunation number during the given day: a value of `0` corresponds to a new moon, `0.25` to a first quarter moon, `0.5` to a full moon, and `0.75` to a last quarter moon. The ranges in between these represent waxing crescent, waxing gibbous, waning gibbous, and waning crescent moons, respectively. Only defined on `Forecast`'s `daily` `DataPoint`s.
30-
public let moonPhase: Float?
30+
public let moonPhase: Double?
3131

3232
/// The approximate distance to the nearest storm. A storm distance of `0` doesn't necessarily refer to a storm at the requested location, but rather a storm in the vicinity of that location. Only defined on `Forecast`'s `currently` `DataPoint`s.
33-
public let nearestStormDistance: Float?
33+
public let nearestStormDistance: Double?
3434

3535
/// The approximate direction of the nearest storm in degrees, with true north at 0º and progressing clockwise. If `nearestStormDistance` is `0`, then this value will be `nil`. Only defined on `Forecast`'s `currently` `DataPoint`s.
36-
public let nearestStormBearing: Float?
36+
public let nearestStormBearing: Double?
3737

3838
/// The intensity of precipitation occuring at the given time. This value is *conditional on probability* (that is, assuming any precipitation falls at all) for `minutely` `DataPoint`s, and unconditional otherwise.
39-
public let precipitationIntensity: Float?
39+
public let precipitationIntensity: Double?
4040

4141
/// The maximum value of `precipitationIntensity` during a given day. Only defined on `Forecast`'s `daily` `DataPoint`s.
42-
public let precipitationIntensityMax: Float?
42+
public let precipitationIntensityMax: Double?
4343

4444
/// The time at which `precipitationIntensityMax` occurs during a given day. Only defined on `Forecast`'s `daily` `DataPoint`s.
4545
public let precipitationIntensityMaxTime: Date?
4646

4747
/// The probability of precipitation occurring, between `0` and `1`, inclusive.
48-
public let precipitationProbability: Float?
48+
public let precipitationProbability: Double?
4949

5050
/// The type of precipitation occurring at the given time. If `precipIntensity` is `0`, then this will be `nil`.
5151
public let precipitationType: Precipitation?
5252

5353
/// The amount of snowfall accumulation expected to occur. This will be `nil` if no accumulation is expected. Only defined on `Forecast`'s `hourly` and `daily` `DataPoint`s.
54-
public let precipitationAccumulation: Float?
54+
public let precipitationAccumulation: Double?
5555

5656
/// The air temperature. Not defined on `Forecast`'s `minutely` `DataPoint`s.
57-
public let temperature: Float?
57+
public let temperature: Double?
5858

5959
/// The overnight low temperature. Only defined on `Forecast`'s `daily` `DataPoint`s.
60-
public let temperatureLow: Float?
60+
public let temperatureLow: Double?
6161

6262
/// The time at which the overnight low temperature occurs. Only defined on `Forecast`'s `daily` `DataPoint`s.
6363
public let temperatureLowTime: Date?
6464

6565
/// The daytime high temperature. Only defined on `Forecast`'s `daily` `DataPoint`s.
66-
public let temperatureHigh: Float?
66+
public let temperatureHigh: Double?
6767

6868
/// The time at which the daytime high temperature occurs. Only defined on `Forecast`'s `daily` `DataPoint`s.
6969
public let temperatureHighTime: Date?
7070

7171
/// The apparent or "feels like" temperature. Not defined on `Forecast`'s `daily` `DataPoint`s.
72-
public let apparentTemperature: Float?
72+
public let apparentTemperature: Double?
7373

7474
/// The overnight low apparent temperature. Only defined on `Forecast`'s `daily` `DataPoint`s.
75-
public let apparentTemperatureLow: Float?
75+
public let apparentTemperatureLow: Double?
7676

7777
/// The time at which the overnight low apparent temperature occurs. Only defined on `Forecast`'s `daily` `DataPoint`s.
7878
public let apparentTemperatureLowTime: Date?
7979

8080
/// The daytime high apparent temperature. Only defined on `Forecast`'s `daily` `DataPoint`s.
81-
public let apparentTemperatureHigh: Float?
81+
public let apparentTemperatureHigh: Double?
8282

8383
/// The time at which the daytime high apparent temperature occurs. Only defined on `Forecast`'s `daily` `DataPoint`s.
8484
public let apparentTemperatureHighTime: Date?
8585

8686
/// The dew point at the given time.
87-
public let dewPoint: Float?
87+
public let dewPoint: Double?
8888

8989
/// The wind gust speed.
90-
public let windGust: Float?
90+
public let windGust: Double?
9191

9292
/// The wind speed at the given time.
93-
public let windSpeed: Float?
93+
public let windSpeed: Double?
9494

9595
/// The direction that the wind is coming *from* in degrees, with true north at 0º and progressing clockwise. If `windSpeed` is `0`, then this will be `nil`.
96-
public let windBearing: Float?
96+
public let windBearing: Double?
9797

9898
/// The percentage of sky occluded by clouds, between `0` and `1`, inclusive.
99-
public let cloudCover: Float?
99+
public let cloudCover: Double?
100100

101101
/// The relative humidity, between `0` and `1`, inclusive.
102-
public let humidity: Float?
102+
public let humidity: Double?
103103

104104
/// The sea-level air pressure.
105-
public let pressure: Float?
105+
public let pressure: Double?
106106

107107
/// The average visibility, capped at 10 miles.
108-
public let visibility: Float?
108+
public let visibility: Double?
109109

110110
/// The columnar density of total atomspheric ozone at the given time in Dobson units.
111-
public let ozone: Float?
111+
public let ozone: Double?
112112

113113
/// The UV index.
114-
public let uvIndex: Float?
114+
public let uvIndex: Double?
115115

116116
/// The time at which the maximum UV index occurs during the given day. Only defined on `Forecast`'s `daily` `DataPoint`s.
117117
public let uvIndexTime: Date?
@@ -139,59 +139,59 @@ public struct DataPoint {
139139
} else {
140140
sunsetTime = nil
141141
}
142-
moonPhase = json["moonPhase"] as? Float
143-
nearestStormDistance = json["nearestStormDistance"] as? Float
144-
nearestStormBearing = json["nearestStormBearing"] as? Float
145-
precipitationIntensity = json["precipIntensity"] as? Float
146-
precipitationIntensityMax = json["precipIntensityMax"] as? Float
142+
moonPhase = json["moonPhase"] as? Double
143+
nearestStormDistance = json["nearestStormDistance"] as? Double
144+
nearestStormBearing = json["nearestStormBearing"] as? Double
145+
precipitationIntensity = json["precipIntensity"] as? Double
146+
precipitationIntensityMax = json["precipIntensityMax"] as? Double
147147
if let jsonPrecipitationIntensityMaxTime = json["precipIntensityMaxTime"] as? Double {
148148
precipitationIntensityMaxTime = Date(timeIntervalSince1970: jsonPrecipitationIntensityMaxTime)
149149
} else {
150150
precipitationIntensityMaxTime = nil
151151
}
152-
precipitationProbability = json["precipProbability"] as? Float
152+
precipitationProbability = json["precipProbability"] as? Double
153153
if let jsonPrecipitationType = json["precipType"] as? String {
154154
precipitationType = Precipitation(rawValue: jsonPrecipitationType)
155155
} else {
156156
precipitationType = nil
157157
}
158-
precipitationAccumulation = json["precipAccumulation"] as? Float
159-
temperature = json["temperature"] as? Float
160-
temperatureLow = json["temperatureLow"] as? Float
158+
precipitationAccumulation = json["precipAccumulation"] as? Double
159+
temperature = json["temperature"] as? Double
160+
temperatureLow = json["temperatureLow"] as? Double
161161
if let jsonTemperatureLowTime = json["temperatureLowTime"] as? Double {
162162
temperatureLowTime = Date(timeIntervalSince1970: jsonTemperatureLowTime)
163163
} else {
164164
temperatureLowTime = nil
165165
}
166-
temperatureHigh = json["temperatureHigh"] as? Float
166+
temperatureHigh = json["temperatureHigh"] as? Double
167167
if let jsonTemperatureHighTime = json["temperatureHighTime"] as? Double {
168168
temperatureHighTime = Date(timeIntervalSince1970: jsonTemperatureHighTime)
169169
} else {
170170
temperatureHighTime = nil
171171
}
172-
apparentTemperature = json["apparentTemperature"] as? Float
173-
apparentTemperatureLow = json["apparentTemperatureLow"] as? Float
172+
apparentTemperature = json["apparentTemperature"] as? Double
173+
apparentTemperatureLow = json["apparentTemperatureLow"] as? Double
174174
if let jsonApparentTemperatureLowTime = json["apparentTemperatureLowTime"] as? Double {
175175
apparentTemperatureLowTime = Date(timeIntervalSince1970: jsonApparentTemperatureLowTime)
176176
} else {
177177
apparentTemperatureLowTime = nil
178178
}
179-
apparentTemperatureHigh = json["apparentTemperatureHigh"] as? Float
179+
apparentTemperatureHigh = json["apparentTemperatureHigh"] as? Double
180180
if let jsonApparentTemperatureHighTime = json["apparentTemperatureHighTime"] as? Double {
181181
apparentTemperatureHighTime = Date(timeIntervalSince1970: jsonApparentTemperatureHighTime)
182182
} else {
183183
apparentTemperatureHighTime = nil
184184
}
185-
dewPoint = json["dewPoint"] as? Float
186-
windGust = json["windGust"] as? Float
187-
windSpeed = json["windSpeed"] as? Float
188-
windBearing = json["windBearing"] as? Float
189-
cloudCover = json["cloudCover"] as? Float
190-
humidity = json["humidity"] as? Float
191-
pressure = json["pressure"] as? Float
192-
visibility = json["visibility"] as? Float
193-
ozone = json["ozone"] as? Float
194-
uvIndex = json["uvIndex"] as? Float
185+
dewPoint = json["dewPoint"] as? Double
186+
windGust = json["windGust"] as? Double
187+
windSpeed = json["windSpeed"] as? Double
188+
windBearing = json["windBearing"] as? Double
189+
cloudCover = json["cloudCover"] as? Double
190+
humidity = json["humidity"] as? Double
191+
pressure = json["pressure"] as? Double
192+
visibility = json["visibility"] as? Double
193+
ozone = json["ozone"] as? Double
194+
uvIndex = json["uvIndex"] as? Double
195195
if let jsonUVIndexTime = json["uvIndexTime"] as? Double {
196196
uvIndexTime = Date(timeIntervalSince1970: jsonUVIndexTime)
197197
} else {

Source/Forecast.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import Foundation
1212
public struct Forecast {
1313

1414
/// The requested latitude.
15-
public let latitude: Float
15+
public let latitude: Double
1616

1717
/// The requested longitude.
18-
public let longitude: Float
18+
public let longitude: Double
1919

2020
/// The IANA timezone name for the requested location (e.g. "America/New_York"). Rely on local user settings over this property.
2121
public let timezone: String
@@ -66,8 +66,8 @@ public struct Forecast {
6666
///
6767
/// - returns: A new `Forecast` filled with data from the given JSON object.
6868
public init(fromJSON json: NSDictionary) {
69-
latitude = json["latitude"] as! Float
70-
longitude = json["longitude"] as! Float
69+
latitude = json["latitude"] as! Double
70+
longitude = json["longitude"] as! Double
7171
timezone = json["timezone"] as! String
7272

7373
if let jsonCurrently = json["currently"] as? NSDictionary {

0 commit comments

Comments
 (0)