Skip to content

Commit

Permalink
Add support for Google Takeout Location History (#1160)
Browse files Browse the repository at this point in the history
* Add support for Google Takeout Location History

This adds support for parsing the location history provided by Google Takeout.
This makes it possible to convert a month's, year's, or your entire location
history at once instead of having to export one day's history at a time on
Google Maps.

There is documentation in the `xmldoc` folder with some examples.

It works great, but there are one, possibly two, other additions I'd like to
make in following diffs:

1. Add the ability to select date ranges. For example, I went on a road trip
   that started in the last week of February, but right now I can only select
	 tracks at the resolution of a whole month.

2. Add support for the higher-resolution "roadSegment" blocks in newer
   "activitySegment" blocks. This will have to be optional as you have to
	 query the Google Maps API to get lat/long, which costs money. However,
	 if you're willing to pay for it, you can get great detail out of it.
	 They look like this:

```
       "roadSegment": [{
          "placeId": "ChIJBdXmuuWaK4gRoiClERhZcy8",
          "duration": "76s"
        }, {
          "placeId": "ChIJ4ekNlOWaK4gRxu-moMRFo60",
          "duration": "58s"
        }, {
          "placeId": "ChIJ10qEheWaK4gRQ1T24wEuuN4",
          "duration": "58s"
        }, {
          "placeId": "ChIJe7NWfu-aK4gRFHBB6P0PMe4",
          "duration": "58s"
[...]
```

* rename variable

* this TODO is done

* now builds on focal, fix documentation

* patch -p2 < ~/testo.log

* use `&&` instead of `and` for old compilers

* don't leak objects when we skip events at exact lat/lon 0/0

* use a reference (even though the compiler would have optimized that away)

* rename to googletakeout

* fix docs

* Address code review requests

* add `googletakeout.h` to HEADERS
* convert most `#define`s to static members
* don't pollute global namespace
* rename logging functions
* convert some methods to static functions for clang-tidy
* `title_case` loop by reference instead of by index (clang-tidy)
* better use of debugging levels
* drop dead simplifiedRawPath code for now
* drop empty tracks
* default constructor for GoogleTakeoutInputStream
* add some tests that check the content of the data

Also, I found some unofficial documentation about the location history
format and added that (thanks @CarlosBergillos !)

* apply @tsteven4 's patch. thank you!!

* add license

* fix logging

* As I assigned the correct license to my code, I am skeptical that this makes a difference, but give Robert co-copyright.

* make the test more boring

* rm xml_slice

* revert constructor change from @tsteven4 's patch

* apply @tsteven4 's latest constructor

* apply @tsteven4 's latest patch -- `cmake --build . --target check` passes

---------

Co-authored-by: tsteven4 <[email protected]>
  • Loading branch information
postmaxin and tsteven4 authored Aug 28, 2023
1 parent 34ab490 commit fb04802
Show file tree
Hide file tree
Showing 16 changed files with 23,634 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
/debug/
/gpsbabel
/gpsbabel-debug
/gpsbabel_coverage.xml
/gpsbabel.exe
/gpsbabel.fo
/gpsbabel.html
/gpsbabel.pdf
/gpsbabel_autogen/
/gpsbabel_coverage.xml
/Makefile
.qmake.cache
.qmake.stash
Expand All @@ -26,11 +27,13 @@
*.a
.ninja_deps
.ninja_log
.qt
build.ninja
rules.ninja
cmake_install.cmake
CMakeCache.txt
CMakeFiles/
CTestTestfile.cmake
/GPSBabel[0-9]*.[0-9]*.[0-9]*/
/GPSBabel[0-9]*.[0-9]*.[0-9]*.tar.bz2
/makelinuxdist.sh
Expand All @@ -47,3 +50,4 @@ CMakeFiles/
/gbversion.h
/qrc_gpsbabel.cpp
/.vscode/
Testing
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ set(ALL_FMTS ${MINIMAL_FMTS}
geocache.cc
geojson.cc
globalsat_sport.cc
googletakeout.cc
gtm.cc
gtrnctr.cc
html.cc
Expand Down Expand Up @@ -213,6 +214,7 @@ set(HEADERS
geojson.h
globalsat_sport.h
geo.h
googletakeout.h
gpx.h
grtcirc.h
gtrnctr.h
Expand Down Expand Up @@ -380,6 +382,7 @@ set(TESTS
geojson
geo
globalsat_sport
googletakeout
gpsdrive
gpx
grapheme
Expand Down
Loading

0 comments on commit fb04802

Please sign in to comment.