NeighboringPathWays.cs
3.4 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
using log4net;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CtuDeviceLib
{
public class NeighboringPathWays
{
static List<NeighboringPathWay> _NeighboringPathWays { get; set; }
public static bool Reload()
{
List<NeighboringPathWay> tempNeighboringPathWays = new List<NeighboringPathWay>();
var pws = PathWays.GetAllPathWays();
List<uint> keyPoints = new List<uint>();
foreach (var pw in pws)
{
if (!keyPoints.Contains(pw.Paths[0]))
{
keyPoints.Add(pw.Paths[0]);
}
else if (!keyPoints.Contains(pw.Paths[pw.Paths.Count - 1]))
{
keyPoints.Add(pw.Paths[pw.Paths.Count - 1]);
}
}
keyPoints.Sort();
keyPoints.ForEach(s => LogUtil.debug($"【keyPoint={s}"));
foreach (var p in keyPoints)
{
var ways = pws.FindAll(s => s.Paths.Contains(p));
for (int i = 0; i < ways.Count - 1; i++)
{
for (int j = i + 1; j < ways.Count; j++)
{
var tmpNB = new NeighboringPathWay()
{
KeyLandmark = p,
StartPathWay = ways[i].Id,
EndPathWay = ways[j].Id,
IsTwoWayLanes = ways[i].IsTwoWayLanes && ways[j].IsTwoWayLanes,
};
var find = tempNeighboringPathWays.Find(s => tmpNB.IsSame(s));
if (find == null)
{
tempNeighboringPathWays.Add(tmpNB);
LogUtil.debug($"生成邻接路线:startWay={tmpNB.StartPathWay},stopWay={tmpNB.EndPathWay},keyPoint={tmpNB.KeyLandmark},is-two-way={tmpNB.IsTwoWayLanes}");
}
}
}
}
//var nb = new NeighboringPathWay();
LogUtil.debug($"生成邻接路线完成");
return true;
}
}
/// <summary>
/// 邻接路线
/// </summary>
public class NeighboringPathWay
{
/// <summary>
/// 两路线的关键路标号
/// </summary>
public uint KeyLandmark { get; set; }
/// <summary>
/// 起始路线编号
/// </summary>
public uint StartPathWay { get; set; }
/// <summary>
///结束路线编号
/// </summary>
public uint EndPathWay { get; set;}
/// <summary>
/// 是否是双向路线
/// </summary>
public bool IsTwoWayLanes { get; set; }
/// <summary>
/// 是否是相同的邻接路线
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public bool IsSame( NeighboringPathWay other )
{
return other.IsTwoWayLanes == IsTwoWayLanes
&& KeyLandmark == other.KeyLandmark
&& ((StartPathWay == other.StartPathWay && EndPathWay == other.EndPathWay)||
(StartPathWay == other.EndPathWay && EndPathWay == other.StartPathWay));
}
}
}