Tutorial :Matching GPS tracks to local days



Question:

I'm writing a geotagging app and running into headaches with timezones. Basically, my app has the following data:

  • Images with local timestamps (i.e. relative to a timezone)
  • GPS track files consisting of entries using UTC timestamps

My problem: I need a way to get all data that belongs to a give day, based on the timezone where the data was acquired. For the images, that is easy (I ask the timezone from the user upon import and save it in the EXIF data), but I'm not sure how to do it for the GPS tracks (there usually are multiple tracks per day, and assigning them timezones is not easy for the user when importing data that spans sever days and timezones). I can think of two possible solutions:

  • Use a heuristic based on the fact that the tracks are recorded at the same time and place as the images - but there can be tracks before a day's first image or after its last one that still need to be included - I'm not sure how to realiably handle such edge cases
  • Determine the timezone from the GPS coordinates - this would be an ideal solution, but is there an open source library that does this (ideally one that works offline)?


Solution:1

The heuristic method I don't think will work well.

Firstly always store times as UTC and timezone of origin, otherwise time is less meaningful.

After some thought I think that it would be sufficient to resolve down to the country code and from that lookup the timezone.

Depending on how much detail you want I think GeoTog may help you to locate a city and therefore a country from a lat/long (although it will need changing to work the other way).

If not that then Gisgraphy will work with the larger GeoNames database. You could use the web service or extract the data.

If none of these are good enough then I think you'll need to get a some GIS data, possibly boundaries from VMAP0 and process it into polygons or something searchable.


Solution:2

Option two: you could start by checking this site: http://www.twinsun.com/tz/tz-link.htm

Option one (less complicated, but I am not sure I accurately understand your need...) So you have as input:

  • A target day defined in a known timezone TZ, starting at t0 and ending at t1 (excluded)
  • Images with timestamps ti in the same timezone TZ (is this hypothesis true?)
  • GPS tracks with UTC timestamps tg which can span over several time zones We also know that there is at least one GPS track for each image.

Here's something that should work:

  • Convert your target day into UTC. You get the values t0/UTC and t1/UTC
  • Convert images' timestamps into UTC (you get ti/UTC from known ti/TZ)
  • process image if (t0/UTC <= ti/UTC < t1/UTC) i.e. it was taken during your target day.
  • find a GPS track including ti/UTC (no problem since tracks are timestamped in UTC), and then the closest timestamp within the list of points in this track. This point is the most likely position of your image.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »