Advertisement
Guest User

Untitled

a guest
Mar 18th, 2020
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  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));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement