Merge lp:~vthompson/ubuntu-weather-app/fix-1286589 into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Victor Thompson
Status: Merged
Approved by: Martin Borho
Approved revision: 215
Merged at revision: 212
Proposed branch: lp:~vthompson/ubuntu-weather-app/fix-1286589
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 45 lines (+7/-3)
2 files modified
components/ScrollingArea.qml (+1/-1)
components/WeatherApi.js (+6/-2)
To merge this branch: bzr merge lp:~vthompson/ubuntu-weather-app/fix-1286589
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Needs Fixing
Martin Borho Approve
Review via email: mp+208940@code.launchpad.net

Commit message

* Fix conversion of wind speed data for TWC data

Description of the change

The OWM wind speed data was in "meters/s", while the TWC data comes as "MPH". A conversion function was added to convert "MPH" to "KPH" to support the metric value.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Martin Borho (martin-borho) wrote :

Hi Victor,

thanks, there's an error, you're right!

But the error lies in the function "calcMph(ms)", which does its job right for OWM, because their wind speed value is in meters per second. Where as TWC gives us km/h (not mph).

You can verify this, by calling the TWC one time with units=m and another time without. Also checking the TWC webpage gives a reference value to check against.

The fix you've proposed just makes the kmh value in TWC to the mph value. So the right fix, I guess, would be to change the calcMph() function in _buildDataPoint() *and* _buildDayFormat() of the TWC api to something like

function convertKmhToMph(kmh) {
   return kmh/1.609344
}

Cheers
Martin

review: Needs Fixing
213. By Victor Thompson

Fix for TWC base speed in KMH

Revision history for this message
Victor Thompson (vthompson) wrote :

Thanks Martin! I had assumed TWC always returned MPH based on code I had seen elsewhere. I've fixed the conversion.

Revision history for this message
Martin Borho (martin-borho) wrote :

Victor, you've mashed up kmh and mph variable names in convertKmhToMph func ;)

214. By Victor Thompson

Fix for TWC base speed in KMH

Revision history for this message
Victor Thompson (vthompson) wrote :

Thanks Martin! Fingers were quicker than my thoughts.

Revision history for this message
Martin Borho (martin-borho) wrote :

Yeah, thanks! Now it looks good!

So good, I've found a bug in the hourly scrolling. The correct values for wind-mph don't get picked up when scrolling through hours. You can test it when enlarge the window to a big tablet size and by scrolling slowly.

Could you please do me a favour and replace Line 56 in components/ScrollingArea.qml with

currentWeather.windSpeed = currentHour[(mainView.settings.wind_units === 'mph') ? 'imperial' : 'metric'].windSpeed

Would be really cool! Then another bug would be fixed... :)

Cheers
Martin

215. By Victor Thompson

Fix wind speeds for mph in hourly forecast for tablet view

Revision history for this message
Victor Thompson (vthompson) wrote :

Cool, I've fixed it. I wasn't aware of the tablet view--now I have something to play around with!

Revision history for this message
Martin Borho (martin-borho) wrote :

Have fun! :)

Revision history for this message
Martin Borho (martin-borho) wrote :

Thanks again, great bugfix!

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components/ScrollingArea.qml'
2--- components/ScrollingArea.qml 2014-02-22 15:38:15 +0000
3+++ components/ScrollingArea.qml 2014-03-03 14:01:39 +0000
4@@ -53,7 +53,7 @@
5 adjustBackground(Math.round(temp));
6 // adjust detail data
7 currentWeather.humidity = currentHour.humidity
8- currentWeather.windSpeed = currentHour[mainView.settings["units"]].windSpeed
9+ currentWeather.windSpeed = currentHour[(mainView.settings.wind_units === 'mph') ? 'imperial' : 'metric'].windSpeed
10 currentWeather.windDir = currentHour.windDir
11 if(currentHour.propPrecip !== undefined && currentHour.propPrecip !== "") {
12 currentWeather.propPrecip = currentHour.propPrecip;
13
14=== modified file 'components/WeatherApi.js'
15--- components/WeatherApi.js 2014-02-22 15:38:15 +0000
16+++ components/WeatherApi.js 2014-03-03 14:01:39 +0000
17@@ -48,6 +48,10 @@
18 return ms*3.6;
19 }
20 //
21+function convertKmhToMph(kmh) {
22+ return kmh*0.621;
23+}
24+//
25 function calcWindDir(degrees) {
26 var direction = "?";
27 if(degrees >=0 && degrees <= 30){
28@@ -445,7 +449,7 @@
29 imperial: {
30 temp: calcFahrenheit(data.temp),
31 tempFeels: calcFahrenheit(data.feelsLike),
32- windSpeed: calcMph(data.wSpeed)
33+ windSpeed: convertKmhToMph(data.wSpeed)
34 },
35 precipType: data.precip_type || null,
36 propPrecip: data.pop || null,
37@@ -476,7 +480,7 @@
38 imperial: {
39 tempMin: calcFahrenheit(data.minTemp),
40 tempMax: calcFahrenheit(data.maxTemp || data.minTemp),
41- windSpeed: calcMph(partData.wSpeed)
42+ windSpeed: convertKmhToMph(partData.wSpeed)
43 },
44 precipType: partData.precip_type,
45 propPrecip: partData.pop,

Subscribers

People subscribed via source and target branches