Guest User

Untitled

a guest
Nov 17th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. var exif = new ExifInterface(App._file.AbsolutePath);
  2. string lon = ExifInterface.TagGpsLongitude;
  3. string lon_data = exif.GetAttribute(lon);
  4. longitude_coord = FormatAsCoordinate(lon_data);
  5. string lat = ExifInterface.TagGpsLatitude;
  6. string lat_data = exif.GetAttribute(lat);
  7. latitude_coord = FormatAsCoordinate(lat_data);
  8.  
  9. public string FormatAsCoordinate(string unformattedCoordinate)
  10. {
  11. if (string.IsNullOrEmpty(unformattedCoordinate))
  12. return "";
  13. else
  14. {
  15. char divider = '/';
  16. char divider2 = ',';
  17. var strings = unformattedCoordinate.Split(divider);
  18. var strings1 = strings[1].Split(divider2);
  19. var strings2 = strings[2].Split(divider2);
  20. var numSeconds = (Convert.ToDouble(strings1[1]) * 60 + Convert.ToDouble(strings2[1]));
  21. double seconds = 0;
  22. try
  23. {
  24. seconds = numSeconds / 3600;
  25. seconds = Math.Round(seconds, 6, MidpointRounding.AwayFromZero);
  26. }
  27. catch
  28. {
  29. seconds = 0;
  30. }
  31. var coordinate = (Convert.ToDouble(strings[0])) + seconds;
  32. return (coordinate - 1).ToString();
  33. }
  34. }
Add Comment
Please, Sign In to add comment