[libgweather/wip/forecasts: 2/6] Add support for hidden intermediate administrative divisions



commit 79a6010d4fd45537c6daacbd26b7aa67427080e7
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sat Dec 1 02:16:18 2012 +0100

    Add support for hidden intermediate administrative divisions
    
    yr.no wants to see the district/region name at all times, but we don't
    want to show them in the location entry. Let's put ADM2 to good use for
    this.

 data/locations.dtd              |    3 ++-
 libgweather/gweather-location.c |    8 +++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/data/locations.dtd b/data/locations.dtd
index f30376e..f0facaa 100644
--- a/data/locations.dtd
+++ b/data/locations.dtd
@@ -5,8 +5,9 @@
 <!ENTITY % name '(_name|name+)' >
 
 <!ELEMENT region (%name;, country+) >
-<!ELEMENT country (%name;, iso-code, fips-code+, pref-lang?, timezones, tz-hint?, (location|state|city)*) >
+<!ELEMENT country (%name;, iso-code, fips-code+, pref-lang?, timezones, tz-hint?, (location|state|province|city)*) >
 <!ELEMENT state (%name;, fips-code+, tz-hint?, (location|city)*) >
+<!ELEMENT province (%name;, (location|city)*) >
 <!ELEMENT city (%name;, coordinates?, location+) >
 <!ELEMENT location (%name;, code, tz-hint?, zone?, yahoo-woeid?, radar?, coordinates?) >
 
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index 8469c70..f3b4dcc 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -69,7 +69,8 @@ struct _GWeatherLocation {
  * administrative division"; ie, a state, province, or similar
  * division.
  * @GWEATHER_LOCATION_ADM2: A location representing a subdivision of a
- * %GWEATHER_LOCATION_ADM1 location. (Not currently used.)
+ * %GWEATHER_LOCATION_ADM1 location, or a direct subdivision of
+ * a country that is not represented in a #GWeatherLocationEntry.
  * @GWEATHER_LOCATION_CITY: A location representing a city
  * @GWEATHER_LOCATION_WEATHER_STATION: A location representing a
  * weather station.
@@ -233,6 +234,11 @@ location_new_from_xml (GWeatherParser *parser, GWeatherLocationLevel level,
 	    if (!child)
 		goto error_out;
 	    g_ptr_array_add (children, child);
+	} else if (!strcmp (tagname, "province")) {
+	    child = location_new_from_xml (parser, GWEATHER_LOCATION_ADM2, loc);
+	    if (!child)
+		goto error_out;
+	    g_ptr_array_add (children, child);
 	} else if (!strcmp (tagname, "city")) {
 	    child = location_new_from_xml (parser, GWEATHER_LOCATION_CITY, loc);
 	    if (!child)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]