Scarygami / location-history-json-converter

Convert the Location History JSON File from Google Takeout into a useable format
Apache License 2.0
468 stars 117 forks source link

Invalid longitude values #22

Closed bbrouwer closed 5 years ago

bbrouwer commented 5 years ago

Recently, when exporting location history, the Longitude values being exported seem to be invalid. I believe it may be a problem with the JSON being exported from Google, but was wondering if you had seen this before. Here is an example record from the exported JSON:

  {
    "timestampMs" : "1555378518327",
    "latitudeE7" : 42xxxxxxx,
    "longitudeE7" : 343xxxxxxx,
    "accuracy" : 17
  }

Exporting to KML, GPX, whatever, simply gives me longitude values of 343.xxxxxxx when valid values are supposed to be -180 to 180. The actual longitude I'm expecting is somewhere around -85.xxxxxxx. Simple math of subtracting 360 doesn't even work as that only gives me about -16.xxxxxxx.

Have you seen this before? Is this something your tool was designed to handle?

RedPh0enix commented 5 years ago

Google's export seems to have an overflow.

If the number is greater than 1800000000 you need to subtract 2^32 (=4294967296) and you get the correct latitudeE7 or longitudeE7.

eg:

                if item["latitudeE7"] > 1800000000:
                    item["latitudeE7"] = item["latitudeE7"] - 4294967296
                if item["longitudeE7"] > 1800000000:
                    item["longitudeE7"] = item["longitudeE7"] - 4294967296

See https://gis.stackexchange.com/questions/318918/latitude-and-longitude-values-in-google-takeout-location-history-data-sometimes/319067

bbrouwer commented 5 years ago

That was it exactly. Thank you so much for the solution.

Scarygami commented 5 years ago

Fixed with https://github.com/Scarygami/location-history-json-converter/pull/24