XlController.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Data.Entity;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Web.Http;
  10. using Serilog;
  11. using XdCxRhDw.Dto;
  12. using XdCxRhDW.App.Api;
  13. using XdCxRhDW.Core.Api;
  14. using XdCxRhDW.Dto;
  15. namespace XdCxRhDW.WebApi.Controllers
  16. {
  17. /// <summary>
  18. /// 星历推算功能相关接口
  19. /// </summary>
  20. public class XlController : BaseController
  21. {
  22. /// <summary>
  23. /// 推算某个时间点星历
  24. /// </summary>
  25. /// <param name="dto">推算参数</param>
  26. /// <returns></returns>
  27. [HttpPost]
  28. public AjaxResult<SatEphDto> Calc(XlCalcDto dto)
  29. {
  30. try
  31. {
  32. var p = EphHelper.Calc(dto.tleStr, dto.dt);
  33. return Success(new SatEphDto()
  34. {
  35. SatId = p.SatId,
  36. SatTime = p.SatTime,
  37. TleTime = p.TleTime,
  38. X = p.X,
  39. Y = p.Y,
  40. Z = p.Z,
  41. VX = p.VX,
  42. VY = p.VY,
  43. VZ = p.VZ,
  44. });
  45. }
  46. catch (Exception ex)
  47. {
  48. return Error<SatEphDto>(ex.Message);
  49. }
  50. }
  51. /// <summary>
  52. /// 推算某个时间段星星历
  53. /// </summary>
  54. /// <param name="dto">推算参数</param>
  55. /// <returns></returns>
  56. [HttpPost]
  57. public AjaxResult<List<EphResDto>> CalcMult(XlCalcMultDto dto)
  58. {
  59. try
  60. {
  61. var eph = EphHelper.CalcMult(dto.tleStr, dto.start, dto.end, dto.spanSeconds);
  62. return Success(eph.Select(p => new EphResDto()
  63. {
  64. SatId = p.SatId,
  65. SatTime = p.SatTime,
  66. TleTime = p.TleTime,
  67. X = p.X,
  68. Y = p.Y,
  69. Z = p.Z,
  70. VX = p.VX,
  71. VY = p.VY,
  72. VZ = p.VZ,
  73. }).ToList());
  74. }
  75. catch (Exception ex)
  76. {
  77. return Error<List<EphResDto>>(ex.Message);
  78. }
  79. }
  80. }
  81. }