PosData.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.ComponentModel.DataAnnotations.Schema;
  5. using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder.Spatial;
  6. namespace DataSimulation.Repostory
  7. {
  8. /// <summary>
  9. /// 指示某个属性需要导出
  10. /// </summary>
  11. [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
  12. public class ExportCellAttribute : Attribute
  13. {
  14. /// <summary>
  15. /// 指示某个属性需要导出
  16. /// </summary>
  17. public ExportCellAttribute()
  18. {
  19. }
  20. /// <summary>
  21. /// 指示某个属性需要导出
  22. /// </summary>
  23. /// <param name="format">浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串</param>
  24. public ExportCellAttribute(string format)
  25. {
  26. this.Format = format;
  27. }
  28. /// <summary>
  29. /// 浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串
  30. /// </summary>
  31. public string Format { get; set; }
  32. /// <summary>
  33. /// 列的排列顺序,未指定的ColumnIndex的按照属性顺序排在之后
  34. /// </summary>
  35. public int ColumnIndex { get; set; } = -1;
  36. }
  37. /// <summary>
  38. /// 指示某个属性在ToolTip中显示
  39. /// </summary>
  40. [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
  41. public class ToolTipAttribute : Attribute
  42. {
  43. /// <summary>
  44. /// 指示某个属性在ToolTip中显示
  45. /// </summary>
  46. public ToolTipAttribute()
  47. {
  48. }
  49. /// <summary>
  50. /// 指示某个属性在ToolTip中显示
  51. /// </summary>
  52. /// <param name="format">浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串</param>
  53. public ToolTipAttribute(string format)
  54. {
  55. this.Format = format;
  56. }
  57. /// <summary>
  58. /// 浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串
  59. /// </summary>
  60. public string Format { get; set; }
  61. /// <summary>
  62. /// ToolTip从上到下的排列顺序,未指定的Index将按照属性顺序排在之后
  63. /// </summary>
  64. public int Index { get; set; } = 10000;
  65. }
  66. /// <summary>
  67. /// 定位点绑定到地图的对象
  68. /// </summary>
  69. public class PosData : BaseModel<long>
  70. {
  71. /// <summary>
  72. /// 信号时刻
  73. /// </summary>
  74. [Display(Name = "信号时刻")]
  75. [DisplayFormat(DataFormatString = "yyyy-MM-dd HH:mm:ss.fff")]
  76. [ExportCell(ColumnIndex = 0)]//如果导出了SigTime,则内部会自动按照SigTime降序排列后再导出
  77. [ToolTip(Index = 0)]
  78. public DateTime SigTime { get; set; }
  79. /// <summary>
  80. /// 定位经度
  81. /// </summary>
  82. [Display(Name = "定位经度", AutoGenerateField = false)]
  83. [ExportCell("f4")]
  84. [ToolTip("f4")]
  85. public double PosLon { get; set; }
  86. /// <summary>
  87. /// 定位纬度
  88. /// </summary>
  89. [Display(Name = "定位纬度", AutoGenerateField = false)]
  90. [ExportCell("f4")]
  91. [ToolTip("f4")]
  92. public double PosLat { get; set; }
  93. /// <summary>
  94. /// 定位经度
  95. /// </summary>
  96. [Display(Name = "镜像经度", AutoGenerateField = false)]
  97. [ExportCell("f4")]
  98. [ToolTip("f4")]
  99. public double MirrLon { get; set; }
  100. /// <summary>
  101. /// 定位纬度
  102. /// </summary>
  103. [Display(Name = "镜像纬度", AutoGenerateField = false)]
  104. [ExportCell("f4")]
  105. [ToolTip("f4")]
  106. public double MirrLat { get; set; }
  107. /// <summary>
  108. /// 当前点是否被选中(默认false)
  109. /// </summary>
  110. [Display(Name = "是否选中", AutoGenerateField = false)]
  111. [NotMapped]
  112. public bool Selected { get; set; }
  113. /// <summary>
  114. /// 当前点是否可见(默认true)
  115. /// </summary>
  116. [Display(Name = "是否可见", AutoGenerateField = false)]
  117. [NotMapped]
  118. public bool Visible { get; set; } = true;
  119. /// <summary>
  120. /// 用于生成颜色的一个key,相同的key具有相同的颜色,当ColorKey为html颜色时则使用此颜色(如#A1B2FF),默认红色#CC3333
  121. /// </summary>、
  122. [Display(Name = "颜色标记", AutoGenerateField = false)]
  123. [NotMapped]
  124. public string ColorKey { get; set; } = "#CC3333";
  125. /// <summary>
  126. /// 判断定位点是否在一个框选的矩形区域内
  127. /// </summary>
  128. /// <param name="startLon"></param>
  129. /// <param name="startLat"></param>
  130. /// <param name="endLon"></param>
  131. /// <param name="endLat"></param>
  132. /// <returns></returns>
  133. public bool InRectangle(double startLon, double startLat, double endLon, double endLat)
  134. {
  135. return PosLon >= startLon && PosLon <= endLon && PosLat >= startLat && PosLat <= endLat;
  136. }
  137. /// <summary>
  138. /// 内部调用的属性
  139. /// </summary>
  140. [Display(AutoGenerateField = false)]
  141. [NotMapped]
  142. public int ClusterCount { get; set; } = 1;
  143. /// <summary>
  144. /// 内部调用的属性
  145. /// </summary>
  146. [Display(AutoGenerateField = false)]
  147. [NotMapped]
  148. public int ClusterKey { get; set; } = int.MinValue;
  149. }
  150. public class FlightInfo
  151. {
  152. public FlightInfo()
  153. {
  154. }
  155. public FlightInfo(string name, double Speed)
  156. {
  157. this.FlightName = name;
  158. this.Speed = Speed;
  159. flights = new List<FlightData>();
  160. }
  161. [Display(Name = "航迹名称")]
  162. public string FlightName { get; set; }
  163. /// <summary>
  164. /// 速度m/s
  165. /// </summary>
  166. [Display(Name = "航迹速度(m/s)")]
  167. public double Speed { get; set; }
  168. /// <summary>
  169. /// 航迹数据点
  170. /// </summary>
  171. [Display(Name = "航迹数据点")]
  172. [ExportCell()]
  173. public List<FlightData> flights { get; set; }
  174. }
  175. public class FlightData
  176. {
  177. public FlightData(double lon, double lat)
  178. {
  179. this.FlightLon = lon;
  180. this.FlightLat = lat;
  181. }
  182. [Display(Name = "航迹经度")]
  183. public double FlightLon { get; set; }
  184. [Display(Name = "航迹纬度")]
  185. public double FlightLat { get; set; }
  186. }
  187. public class FightDataCsv
  188. {
  189. public FightDataCsv()
  190. { }
  191. public FightDataCsv(string name, double speed, double lon, double lat)
  192. {
  193. FlightName = name;
  194. Speed = speed;
  195. FlightLon = lon;
  196. FlightLat = lat;
  197. }
  198. [Display(Name = "航迹名称")]
  199. [ExportCell("")]
  200. public string FlightName { get; set; }
  201. /// <summary>
  202. /// 速度m/s
  203. /// </summary>
  204. [Display(Name = "航迹速度(m/s)")]
  205. [ExportCell("f3")]
  206. public double Speed { get; set; }
  207. [Display(Name = "航迹经度(°)")]
  208. [ExportCell("f3")]
  209. public double FlightLon { get; set; }
  210. [Display(Name = "航迹纬度(°)")]
  211. [ExportCell("f3")]
  212. public double FlightLat { get; set; }
  213. }
  214. }