IMapCacheService.cs
6.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Rcs.Domain.Enums;
namespace Rcs.Application.Services
{
/// <summary>
/// 地图缓存服务接口 - 负责地图数据的Redis缓存操作
/// @author zzy
/// </summary>
public interface IMapCacheService
{
/// <summary>
/// 从Redis获取地图完整数据(含节点、边、资源)
/// @author zzy
/// </summary>
Task<MapCacheData?> GetMapAsync(Guid mapId);
/// <summary>
/// 获取所有地图ID列表
/// @author zzy
/// </summary>
Task<IEnumerable<Guid>> GetAllMapIdsAsync();
/// <summary>
/// 获取所有地图数据
/// @author zzy
/// </summary>
Task<IEnumerable<MapCacheData>> GetAllMapsAsync();
/// <summary>
/// 按MapCode分组获取地图(同一物理环境的不同厂商地图)
/// @author zzy
/// </summary>
Task<Dictionary<string, List<MapCacheData>>> GetMapsGroupedByCodeAsync();
/// <summary>
/// 通过节点编码快速查找节点ID
/// @author zzy
/// </summary>
Task<Guid?> GetNodeIdByCodeAsync(Guid mapId, string nodeCode);
/// <summary>
/// 更新单个地图缓存
/// @author zzy
/// </summary>
Task UpdateMapCacheAsync(Guid mapId);
/// <summary>
/// 删除地图缓存
/// @author zzy
/// </summary>
Task RemoveMapCacheAsync(Guid mapId);
/// <summary>
/// 根据坐标查询最近的MapNode,允许误差在EndDeviationPosition范围内
/// @author zzy
/// </summary>
/// <param name="mapId">地图ID</param>
/// <param name="x">X坐标</param>
/// <param name="y">Y坐标</param>
/// <returns>最近的节点,如果没有找到符合条件的节点则返回null</returns>
Task<MapNodeCache?> GetNearestNodeAsync(Guid mapId, double x, double y);
}
/// <summary>
/// 地图缓存数据
/// @author zzy
/// </summary>
public class MapCacheData
{
public Guid MapId { get; set; }
public string MapCode { get; set; } = string.Empty;
public string MapName { get; set; } = string.Empty;
public int MapType { get; set; }
public string Version { get; set; } = string.Empty;
public bool Active { get; set; }
public List<MapNodeCache> Nodes { get; set; } = new();
public List<MapEdgeCache> Edges { get; set; } = new();
public List<MapResourceCache> Resources { get; set; } = new();
}
/// <summary>
/// 节点缓存数据
/// @author zzy
/// </summary>
public class MapNodeCache
{
public Guid NodeId { get; set; }
public string NodeCode { get; set; } = string.Empty;
public double X { get; set; }
public double Y { get; set; }
public double? Theta { get; set; }
public int Type { get; set; }
public bool Active { get; set; }
public double? MaxCoordinateOffset { get; set; }
/// <summary>
/// 是否倒车进入
/// @author zzy
/// </summary>
public bool IsReverseParking { get; set; }
/// <summary>
/// 是否允许旋转
/// @author zzy
/// </summary>
public bool AllowRotate { get; set; }
}
/// <summary>
/// 边缓存数据
/// @author zzy
/// </summary>
public class MapEdgeCache
{
public Guid EdgeId { get; set; }
public string EdgeCode { get; set; } = string.Empty;
public Guid FromNode { get; set; }
public Guid ToNode { get; set; }
public double Length { get; set; }
public double? Cost { get; set; }
public bool Active { get; set; }
/// <summary>
/// 允许的行驶夹角角度列表(度)
/// @author zzy
/// </summary>
public List<double>? OrientationRads { get; set; }
/// <summary>
/// 最大速度(米/秒)
/// @author zzy
/// </summary>
public double? MaxSpeed { get; set; }
/// <summary>
/// 最大角度偏差(度)
/// @author zzy
/// </summary>
public double? MaxRadDeviation { get; set; }
/// <summary>
/// 是否为曲线
/// @author zzy
/// </summary>
public bool IsCurve { get; set; }
/// <summary>
/// NURBS控制点
/// @author zzy
/// </summary>
public List<PointCache>? ControlPoints { get; set; }
}
/// <summary>
/// 点缓存数据
/// @author zzy
/// </summary>
public class PointCache
{
public double X { get; set; }
public double Y { get; set; }
}
/// <summary>
/// 资源区域缓存数据
/// @author zzy
/// </summary>
public class MapResourceCache
{
public Guid ResourceId { get; set; }
public string ResourceCode { get; set; } = string.Empty;
public int Type { get; set; }
public int? Capacity { get; set; }
public List<PointCache>? LocationCoordinates { get; set; }
/// <summary>
/// 最大速度
/// @author zzy
/// </summary>
public double MaxSpeed { get; set; }
/// <summary>
/// 能否旋转
/// @author zzy
/// </summary>
public bool CanRotate { get; set; }
/// <summary>
/// 前置动作类型1(进入资源前)
/// @author zzy
/// </summary>
public ActionType? PreAction1Type { get; set; }
/// <summary>
/// 前置网络动作集合1(进入资源前)
/// @author zzy
/// </summary>
public List<Guid>? PreNetActions1 { get; set; }
/// <summary>
/// 后置动作类型1(进入资源后)
/// @author zzy
/// </summary>
public ActionType? PostAction1Type { get; set; }
/// <summary>
/// 后置网络动作集合1(进入资源后)
/// @author zzy
/// </summary>
public List<Guid>? PostNetActions1 { get; set; }
/// <summary>
/// 前置动作类型2(离开资源前)
/// @author zzy
/// </summary>
public ActionType? PreAction2Type { get; set; }
/// <summary>
/// 前置网络动作集合2(离开资源前)
/// @author zzy
/// </summary>
public List<Guid>? PreNetActions2 { get; set; }
/// <summary>
/// 后置动作类型2(离开资源后)
/// @author zzy
/// </summary>
public ActionType? PostAction2Type { get; set; }
/// <summary>
/// 后置网络动作集合2(离开资源后)
/// @author zzy
/// </summary>
public List<Guid>? PostNetActions2 { get; set; }
}
}