GpsUtils.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. /// <summary>
  7. /// GPS工具类
  8. /// </summary>
  9. namespace Wit.SDK.Utils
  10. {
  11. public class GpsUtils
  12. {
  13. /// <summary>
  14. /// 经纬度度分秒转换为度 选定保留小数
  15. /// </summary>
  16. public static double DmsToD(double value, int digits)
  17. {
  18. //度
  19. double Degree = Math.Floor(value / 100);
  20. //分
  21. double points = (value / 100 - Degree) * 100;
  22. Degree = Degree + points / 60;
  23. return Math.Round(Degree, digits);
  24. }
  25. /// <summary>
  26. /// 经纬度度分秒转换为度
  27. /// </summary>
  28. public static double DmsToD(double value)
  29. {
  30. return DmsToD(value,7);
  31. }
  32. /// <summary>
  33. ///经纬度 度转换为度分
  34. /// </summary>
  35. public static double DToDms(double value)
  36. {
  37. //度
  38. double Degree = Math.Floor(value);
  39. //分
  40. double points = (value - Degree) * 60.0;
  41. Degree = Degree * 100 + points;
  42. return Math.Round(Degree, 7);
  43. }
  44. }
  45. }