[Marble-devel] Obtaining time zone data through MarbleWidget

John Layt jlayt at kde.org
Thu May 9 15:41:54 UTC 2013


On 9 May 2013 11:39, Akarsh Simha <akarsh.simha at kdemail.net> wrote:
> Hi
>
>> I intend to use MarbleWidget in KStars to replace our current
>> "Geographic Location" tool.
>>
>> However, I would need to be able to obtain the time zone and DST rules
>> for a given geographical location, in addition to the latitude and
>> longitude. Looking at the documentation on techbase, I couldn't find
>> out how to do this.
>
> So, I tinkered around with MarbleWidget a bit today.
>
> What I want to do is the following:
>
> 1. Allow the user to search for a city, just like in Marble
>
> 2. Alternately, allow the user to point to a location on the map
>
> 3. Obtain the following information about the "selected" point:
>
>    1. Latitude / Longitude
>
>    2. Name of the city, if the user selected a city
>
>    3. Province, Country
>
>    4. Time zone information and DST rules
>
>    5. Possibly the altitude as well
>
> 4. Allow the user to add to the map his/her own locations (eg: maybe
>    an observatory that is in the middle of nowhere) to the map.
>
> 5. Maybe maintain a list of favourite locations
>
> What is the best way to do these with Marble's libraries?

Nice set of requirements, I suspect you'd need to load and manipulate
your own KML files to do that, but I'll leave that to people who know
better.  I have been thinking/talking for a while about developing a
specialised widget for use in System Settings, a first-run wizard, or
distro installers to choose locale country and time zone etc, so I
would be very interested in seeing anything you develop eventually
wind up in KF5.

Unfortunately kdelibs wouldn't be able to depend on libmarble for such
things, so one suggestion in the past was to develop a fall-back
SVG-based mode that had a lo-res vector map of all the supported
countries, time zones and major cities to fall-back to if libmarble is
not available.  This could also be theme-able.  When the user clicks
on a point the widget would return the geo-location, nearest city, the
time zone and country.  I've been experimenting lately with
http://www.naturalearthdata.com and http://kartograph.org to see if I
can generate a small-enough SVG file for that purpose.  It's probably
not something I'll have done any time soon but an approach to keep in
mind.

As for the DST rules for a time zone, well I'm pretty sure Marble
won't tell you that, but you can find those out by using KTimeZone in
KDE4 which will give you a list of transition dates/times, but not a
generic 'rule' as such as they can vary from year-to-year.  It can
also tell you what country a time zone belongs to and the lat/lon of
the zone if available (i.e not on Windows without shipping your own tz
file).  In fact, in your current dialog you could easily replace your
DST Rule combobox with a list of available Time Zone ID's from
KTimeZones, perhaps filtered on the currently selected country.
Alternatively if you really need that actual rule and not just the
calculated transitions you'll need to read the tz file directly to get
the default POSIX rule, I have code for that I've been developing for
Qt5.

Cheers!

John.


More information about the Marble-devel mailing list