SHARE
TWEET

Untitled

a guest Mar 18th, 2020 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import * as fs from "fs";
  2. import * as JSZip from "jszip";
  3.  
  4. interface Location {
  5.   timestampMs: string;
  6.   latitudeE7: number;
  7.   longitudeE7: number;
  8.   accuracy: number;
  9. }
  10.  
  11. export async function toKml(takeout: ArrayBuffer | Blob) {
  12.   const zip = await JSZip.loadAsync(takeout);
  13.   const content = await zip
  14.     .folder("Takeout")
  15.     .folder("Location History")
  16.     .file("Location History.json")
  17.     .async("text");
  18.   const { locations } = JSON.parse(content) as {
  19.     locations: Location[];
  20.   };
  21.   return locations;
  22. }
  23.  
  24. const f = fs.readFileSync("takeout.zip");
  25. toKml(f.buffer.slice(f.byteOffset, f.byteOffset + f.byteLength));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top