XlController.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.Entity;
  4. using System.Data.SqlClient;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Web.Http;
  9. using Serilog;
  10. using XdCxRhDw.Dto;
  11. using XdCxRhDW.App.Api;
  12. using XdCxRhDW.Core.Api;
  13. using XdCxRhDW.Dto;
  14. namespace XdCxRhDW.WebApi.Controllers
  15. {
  16. /// <summary>
  17. /// 星历推算功能相关接口
  18. /// </summary>
  19. public class XlController : BaseController
  20. {
  21. /// <summary>
  22. /// 推算某个时间点星历
  23. /// </summary>
  24. /// <param name="tleStr">双行根</param>
  25. /// <param name="dt">推算时刻(北京时刻)</param>
  26. /// <returns></returns>
  27. [HttpGet]
  28. public async Task<AjaxResult<SatEphDto>> Calc(string tleStr, DateTime dt)
  29. {
  30. var p = EphHelper.Calc(tleStr, dt);
  31. return Success(new SatEphDto()
  32. {
  33. SatId = p.SatId,
  34. SatTime = p.SatTime,
  35. TleTime = p.TleTime,
  36. X = p.X,
  37. Y = p.Y,
  38. Z = p.Z,
  39. VX = p.VX,
  40. VY = p.VY,
  41. VZ = p.VZ,
  42. });
  43. }
  44. /// <summary>
  45. /// 推算某个时间段星星历
  46. /// </summary>
  47. /// <param name="tleStr">双行根</param>
  48. /// <param name="start">开始时刻(北京时刻)</param>
  49. /// <param name="end">结束时刻(北京时刻)</param>
  50. /// <param name="spanSeconds">推算间隔(秒)</param>
  51. /// <returns></returns>
  52. [HttpGet]
  53. public async Task<AjaxResult<List<EphResDto>>> CalcMult(string tleStr, DateTime start, DateTime end, int spanSeconds)
  54. {
  55. var eph = EphHelper.CalcMult(tleStr, start, end, spanSeconds);
  56. return Success(eph.Select(p => new EphResDto()
  57. {
  58. SatId = p.SatId,
  59. SatTime = p.SatTime,
  60. TleTime = p.TleTime,
  61. X = p.X,
  62. Y = p.Y,
  63. Z = p.Z,
  64. VX = p.VX,
  65. VY = p.VY,
  66. VZ = p.VZ,
  67. }).ToList());
  68. }
  69. }
  70. }