Bug 97107

Summary: weather info not shown for stations needing maintenance
Product: [Unmaintained] kweather-kde3 Reporter: Sok Ann Yap <sokann>
Component: generalAssignee: geiseri
Status: RESOLVED FIXED    
Severity: wishlist CC: kde
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Patch to disregard the maintenance flag
Complete patch

Description Sok Ann Yap 2005-01-15 23:49:58 UTC
Version:            (using KDE KDE 3.3.91)
Installed from:    Gentoo Packages

This wishlist is in regard to the following commit:
( http://webcvs.kde.org/kdetoys/kweather/weatherservice.h?rev=1.28&view=markup )

"For stations needing maintenance I added a new DCOP function: bool stationNeedsMaintenance(const QString &StationID), which returns true
if the station needs maintenance. The dockwidget then uses this new DCOP function to check and display a somewhat informative tool tip.  Also the icon will be "dunno" for stations that need maintenance.  I added this support because for some reason the station near me started going into this "needs maintenance" state.  I noticed that weather.com has switched my area report to a different station, which is something we could think about doing in the future."

Unfortunately, my nearest station, KLNK, seems to be having this $ maintenance flag all the time, so kweather can only show me the "dunno" icon plus all the ???.

If you go to http://weather.noaa.gov/weather/current/KLNK.html , things seem to be fine.

Also, quoting from the FAQ at http://shadow.agry.purdue.edu/sc.hly-faq.html#q7 , "$ flag indicates only that maintenance is needed, not necessarily that the data are erroneous. Often observers at the ASOS site can catch errors in an observation and change suspect values before the observation is transmitted to users".

So, I suggest to change the code such that it will still calculate the weather information regardless of the maintenance flag.
Comment 1 Sok Ann Yap 2005-01-15 23:55:57 UTC
Created attachment 9110 [details]
Patch to disregard the maintenance flag

After applying the patch, kweather finally shows me the weather infos. Compared
to the results from websites such as weather.com and weather.yahoo.com, I can
say that they are accurate.
Comment 2 Sok Ann Yap 2005-01-16 00:29:07 UTC
Created attachment 9112 [details]
Complete patch

Ahh... I forgot to update the frontend in the previous patch. Please see this
one.
Comment 3 Christian Loose 2005-05-23 15:17:52 UTC
*** Bug 95870 has been marked as a duplicate of this bug. ***
Comment 4 Martin Koller 2006-12-25 23:26:56 UTC
SVN commit 616506 by mkoller:

BUG: 97107
BUG: 134426
BUG: 108427

Display weather data even if station needs maintenance
Patch included from Sok Ann Yap sokann@gmail.com

Make the tooltip more informative by showing station name
and more data



 M  +56 -31    dockwidget.cpp  
 M  +3 -6      metar_parser.cpp  
 M  +6 -10     reportview.cpp  
 M  +1 -4      weatherlib.cpp  


--- branches/KDE/3.5/kdetoys/kweather/dockwidget.cpp #616505:616506
@@ -41,7 +41,8 @@
     setBackgroundOrigin( AncestorOrigin );
 }
 
-dockwidget::~dockwidget(){
+dockwidget::~dockwidget()
+{
     delete m_weatherService;
 }
 
@@ -77,51 +78,74 @@
 
 void dockwidget::showWeather()
 {
-    QString tip;
+    QString tip = "<qt>";
 
     QString temp     = "?";
     QString wind     = "?";
     QString pressure = "?";
 
-    if ( !m_locationCode.isEmpty() && m_weatherService->stationNeedsMaintenance( m_locationCode ) )
+    if ( !m_locationCode.isEmpty() )
     {
-        tip = i18n("Station reports that it needs maintenance\n"
-                   "Please try again later");
-    }
-    else
-    {
-        if ( !m_locationCode.isEmpty() )
-        {
-            temp     = m_weatherService->temperature( m_locationCode );
-            wind     = m_weatherService->wind( m_locationCode );
-            pressure = m_weatherService->pressure( m_locationCode );
-        }
+        temp     = m_weatherService->temperature( m_locationCode );
+        wind     = m_weatherService->wind( m_locationCode );
+        pressure = m_weatherService->pressure( m_locationCode );
 
-        if (m_mode != ShowAll)
-        {
-            tip = i18n("Temperature: ") + temp;
-            tip += i18n("\nWind: ") + wind;
-            tip += i18n("\nAir pressure: ") + pressure;
-        }
+        QString dewPoint    = m_weatherService->dewPoint( m_locationCode);
+        QString relHumidity = m_weatherService->relativeHumidity( m_locationCode );
+        QString heatIndex   = m_weatherService->heatIndex( m_locationCode );
+        QString windChill   = m_weatherService->windChill( m_locationCode );
+        QString sunRiseTime = m_weatherService->sunRiseTime( m_locationCode );
+        QString sunSetTime  = m_weatherService->sunSetTime( m_locationCode );
+
+        tip += "<h3><center><nobr>" +
+               m_weatherService->stationName( m_locationCode ) + " (" +
+               m_weatherService->stationCountry( m_locationCode ) + ")</nobr></center></h3><br>";
+
+        tip += QString("<table>"
+                "<tr><th><nobr>" + i18n( "Temperature:"   ) + "</nobr></th><td><nobr>%1</nobr></td>"
+                    "<th><nobr>" + i18n( "Dew Point:"     ) + "</nobr></th><td><nobr>%2</nobr></td></nobr></tr>"
+
+                "<tr><th><nobr>" + i18n( "Air Pressure:"  ) + "</nobr></th><td><nobr>%3</nobr></td>"
+                    "<th><nobr>" + i18n( "Rel. Humidity:" ) + "</nobr></th><td><nobr>%4</nobr></td></nobr></tr>"
+
+                "<tr><th><nobr>" + i18n( "Wind Speed:"    ) + "</nobr></th><td><nobr>%5</nobr></td>")
+                .arg(temp).arg(dewPoint).arg(pressure).arg(relHumidity).arg(wind);
+
+        if ( !heatIndex.isEmpty() )
+            tip += QString("<th><nobr>" + i18n( "Heat Index:" ) + "</nobr></th><td><nobr>%1</nobr></td>").arg(heatIndex);
+        else if ( !windChill.isEmpty() )
+            tip += QString("<th><nobr>" + i18n( "Wind Chill:" ) + "</nobr></th><td><nobr>%1</nobr></td>").arg(windChill);
         else
+            tip += "<td>&nbsp;</td><td>&nbsp;</td>";
+        tip += "</tr>";
+
+        tip += QString("<tr><th><nobr>" + i18n( "Sunrise:" ) + "</nobr></th><td><nobr>%1</nobr></td>" +
+                           "<th><nobr>" + i18n( "Sunset:"  ) + "</nobr></th><td><nobr>%2</nobr></td>")
+                 .arg(sunRiseTime).arg(sunSetTime);
+
+        tip += "</tr></table>";
+
+        if ( m_weatherService->stationNeedsMaintenance( m_locationCode ) )
         {
-            tip = i18n("Click here to see\nthe detailed weather report...");
+            tip += "<br>" + i18n("Station reports that it needs maintenance\n"
+                                 "Please try again later");
         }
     }
+    else
+    {
+        tip += i18n("Temperature: ") + temp + "<br>";
+        tip += i18n("\nWind: ") + wind + "<br>";
+        tip += i18n("\nAir pressure: ") + pressure + "<br>";
+    }
 
+    tip += "</qt>";
+
     // On null or empty location code, or if the station needs maintenance, this will return the dunno icon.
     QPixmap icon = m_weatherService->icon( m_locationCode );
 
-    if ( ! m_locationCode.isEmpty() )
-    {
-        tip = m_weatherService->stationName( m_locationCode ) + "\n" +
-              m_weatherService->stationCountry( m_locationCode ) + "\n" +
-              tip;
-    }
+    QToolTip::remove(this);
+    QToolTip::add(this, tip);
 
-    QToolTip::remove(m_button);
-    QToolTip::add(m_button, tip);
-
     kdDebug(12004) << "show weather: " << endl;
     kdDebug(12004) << "location: " << m_locationCode << endl;
     kdDebug(12004) << "temp,wind,pressure: " << temp << " " << wind << " " << pressure << endl;
@@ -134,7 +158,8 @@
     m_button->setPixmap( icon );
 }
 
-void dockwidget::initDock(){
+void dockwidget::initDock()
+{
     kdDebug(12004) << "Init dockwidget " << endl;
 
     m_button= new WeatherButton(this,"m_button");
--- branches/KDE/3.5/kdetoys/kweather/metar_parser.cpp #616505:616506
@@ -135,12 +135,9 @@
 		}
 	}
 
-	if (!weatherInfo.stationNeedsMaintenance)
-	{
-		calcTemperatureVariables();
-		calcWindChill();
-		calcCurrentIcon();
-	}
+	calcTemperatureVariables();
+	calcWindChill();
+	calcCurrentIcon();
 	
 	return weatherInfo;
 }
--- branches/KDE/3.5/kdetoys/kweather/reportview.cpp #616505:616506
@@ -100,18 +100,14 @@
     if ( m_weatherService->stationNeedsMaintenance( m_locationCode ) )
     {
         weatherText += "<li>" + i18n( "Station reports that it needs maintenance" ) + " \n";
-        weatherText += "<li>" + i18n( "Please try a different one" ) + " \n";
     }
-    else
-    {
-        for (QStringList::const_iterator it = cover.begin();
-                it != cover.end(); ++it)
-            weatherText += "<li>" + *it + "\n";
+    for (QStringList::const_iterator it = cover.begin();
+            it != cover.end(); ++it)
+        weatherText += "<li>" + *it + "\n";
 
-        for (QStringList::const_iterator it = weather.begin();
-                it != weather.end(); ++it)
-            weatherText += "<li>" + *it + "\n";
-    }
+    for (QStringList::const_iterator it = weather.begin();
+            it != weather.end(); ++it)
+        weatherText += "<li>" + *it + "\n";
 
     weatherText += "</ul>\n";
 
--- branches/KDE/3.5/kdetoys/kweather/weatherlib.cpp #616505:616506
@@ -276,10 +276,7 @@
 	if ( !stationID.isEmpty() )
 	{
 		Data *d = findData(stationID);
-		if (!d->wi.stationNeedsMaintenance)
-		{
-			result = d->wi.theWeather;
-		}
+		result = d->wi.theWeather;
 	}
 	
 	return result;