[Xfce4-commits] <xfce4-weather-plugin:master> Make available XML location data.

Harald Judt noreply at xfce.org
Mon Jul 2 12:38:13 CEST 2012


Updating branch refs/heads/master
         to feb84145ae8fce321356e366588230e9eca413ac (commit)
       from 11bdbebd104ff0e39f5fd22618189210bbd3d3e2 (commit)

commit feb84145ae8fce321356e366588230e9eca413ac
Author: Harald Judt <harald.judt at univie.ac.at>
Date:   Tue Jun 26 14:48:51 2012 +0200

    Make available XML location data.
    
    Add altitude, latitude and longitude from the XML feed.
    We may already know latitude and longitude from the location the
    user selected, but it might be a bit different in the XML document.

 panel-plugin/weather-data.c    |   14 ++++++++++++++
 panel-plugin/weather-data.h    |    3 +++
 panel-plugin/weather-parsers.c |   13 +++++++++++++
 panel-plugin/weather-parsers.h |    4 ++++
 panel-plugin/weather-summary.c |   13 ++++++++++---
 5 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
index c36402e..d27ca44 100644
--- a/panel-plugin/weather-data.c
+++ b/panel-plugin/weather-data.c
@@ -49,6 +49,12 @@ get_data (xml_time *timeslice, datas type)
 	loc = timeslice->location;
 
 	switch(type) {
+	case ALTITUDE:
+		return CHK_NULL(loc->altitude);
+	case LATITUDE:
+		return CHK_NULL(loc->latitude);
+	case LONGITUDE:
+		return CHK_NULL(loc->longitude);
 	case TEMPERATURE:
 		return CHK_NULL(loc->temperature_value);
 	case PRESSURE:
@@ -90,6 +96,8 @@ get_unit (xml_time *timeslice, units unit, datas type)
 	loc = timeslice->location;
 
 	switch(type) {
+	case ALTITUDE:
+		return "m";
 	case TEMPERATURE:
 		return strcmp(loc->temperature_unit, "celcius") ? "°F":"°C";
 	case PRESSURE:
@@ -97,6 +105,8 @@ get_unit (xml_time *timeslice, units unit, datas type)
 	case WIND_SPEED:
 		return "m/s";
 	case WIND_DIRECTION_DEG:
+	case LATITUDE:
+	case LONGITUDE:
 		return "°";
 	case HUMIDITY:
 	case CLOUDINESS_LOW:
@@ -264,6 +274,10 @@ make_combined_timeslice(xml_time *point, xml_time *interval)
     forecast->start = point->start;
     forecast->end = interval->end;
 
+    loc->altitude = g_strdup(point->location->altitude);
+    loc->latitude = g_strdup(point->location->latitude);
+    loc->longitude = g_strdup(point->location->longitude);
+
     loc->temperature_value = g_strdup(point->location->temperature_value);
     loc->temperature_unit = g_strdup(point->location->temperature_unit);
 
diff --git a/panel-plugin/weather-data.h b/panel-plugin/weather-data.h
index 798a4ec..37f04c5 100644
--- a/panel-plugin/weather-data.h
+++ b/panel-plugin/weather-data.h
@@ -21,6 +21,9 @@
 G_BEGIN_DECLS
 
 typedef enum {
+	ALTITUDE,
+	LATITUDE,
+	LONGITUDE,
 	TEMPERATURE,
 	PRESSURE,
 	WIND_SPEED,
diff --git a/panel-plugin/weather-parsers.c b/panel-plugin/weather-parsers.c
index d97cb00..704a396 100644
--- a/panel-plugin/weather-parsers.c
+++ b/panel-plugin/weather-parsers.c
@@ -197,6 +197,19 @@ xml_time *get_current_timeslice(xml_weather *data, gboolean interval)
 void parse_location (xmlNode * cur_node, xml_location *loc)
 {
 	xmlNode *child_node;
+	gchar *altitude, *latitude, *longitude;
+
+	g_free(loc->altitude);
+	loc->altitude = PROP(cur_node, "altitude");
+	xmlFree(altitude);
+
+	g_free(loc->latitude);
+	loc->latitude = PROP(cur_node, "latitude");
+	xmlFree(latitude);
+
+	g_free(loc->longitude);
+	loc->longitude = PROP(cur_node, "longitude");
+	xmlFree(longitude);
 
 	for (child_node = cur_node->children; child_node;
 	     child_node = child_node->next) {
diff --git a/panel-plugin/weather-parsers.h b/panel-plugin/weather-parsers.h
index d432507..144600e 100644
--- a/panel-plugin/weather-parsers.h
+++ b/panel-plugin/weather-parsers.h
@@ -38,6 +38,10 @@ enum
 
 typedef struct
 {
+    gchar *altitude;
+    gchar *latitude;
+    gchar *longitude;
+
 	gchar *temperature_value;
 	gchar *temperature_unit;
 	
diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
index defddad..0330f13 100644
--- a/panel-plugin/weather-summary.c
+++ b/panel-plugin/weather-summary.c
@@ -270,10 +270,17 @@ create_summary_tab (xfceweather_data *data)
 
   timeslice = get_current_timeslice(data->weatherdata, FALSE);
   APPEND_BTEXT(_("Coordinates and Time\n"));
-  value = g_strdup_printf (_("\tLatitude: %s \n"
-                             "\tLongitude: %s\n\n"
+  value = g_strdup_printf (_("\tAltitude: %s %s\n"
+                             "\tLatitude: %s%s\n"
+                             "\tLongitude: %s%s\n\n"
                              "\tData applies to: %s"),
-                           data->lat, data->lon, ctime(&timeslice->start));
+                           get_data(timeslice, ALTITUDE),
+                           get_unit(timeslice, data->unit, ALTITUDE),
+                           get_data(timeslice, LATITUDE),
+                           get_unit(timeslice, data->unit, LATITUDE),
+                           get_data(timeslice, LONGITUDE),
+                           get_unit(timeslice, data->unit, LONGITUDE),
+                           ctime(&timeslice->start));
   APPEND_TEXT_ITEM_REAL (value);
 
   /* Temperature */


More information about the Xfce4-commits mailing list