Commit 34d2ba5d authored by xuebingbing's avatar xuebingbing

new project“

parent 49bd8bd1
Pipeline #169 failed with stages
using HDMapBase.Common;
using HDMapBase.Geometry;
using HDMapBase.Model.Gps;
using HDMapBase.Model.Graph;
using HDMapBase.Serialize;
using System;
using System.Collections.Generic;
namespace Gps2GraphPB
{
internal class Program
{
private static void Main(string[] args)
{
// 以 / 结尾
String strLocalPath = "D:/data/JF/ly/";
uint taskId = 1012;
Dictionary<ulong, ulong> prevnextdict = new Dictionary<ulong, ulong>()
{
//1-三角带
{ 4348832257812,4348835232812},
{ 4348835598012,4348832282212},
//2-主辅路
{ 4348829713012,4348831607312},
//{ 4348830155312,4348831940612},
//3-桥下
{ 4348829683112,4348835812112},
{ 4348839472112,4348836356412}
};
PatternOne(strLocalPath, taskId, prevnextdict);
}
private static ulong CalcGpsId(uint taskId, int week, double seconds)
{
return (((ulong)taskId << 32) | TimeUtil.GetUtcShortMsFromGps(week, seconds));
}
private static void PatternOne(string localRootPath, uint taskId, Dictionary<ulong, ulong> prevnextdict)
{
RValue<bool> rtn;
FileSource.SetLocalTraceDir(localRootPath + "/");
TaskGpsData data = TaskGpsData.LoadTaskData(taskId, SourceType.Local);
var imgpoints = TaskGpsData.FilterNoImg(data.rawData.GpsList);
RawGpsPointTimeGraph timegraph = new RawGpsPointTimeGraph(taskId,
MeshUtil.INVALID_MESHID, imgpoints);
// 时间间隔大于 x 之的不建立前后链接关系
timegraph.Build(2);
Console.WriteLine("Check1 whole timegraph");
Console.WriteLine("---------------------");
foreach (var v in timegraph.GraphPoints)
{
if (!v.Value.HasNext && !v.Value.HasPrev)
{
string msg = $"孤立拓扑点 mesh:{v.Value.meshId} gpsId:{v.Key}";
Console.WriteLine(msg);
}
if (v.Value.Next.Count > 1 && v.Value.Prev.Count > 1)
{
string msg = $"出现X形状 拓扑关系mesh:{v.Value.meshId} gpsId:{v.Key}";
Console.WriteLine(msg);
}
}
Console.WriteLine(">>>check end");
AppointPrevNextRelation(timegraph, prevnextdict);
#region 过滤
// 过滤不影响前后挂接关系
timegraph.FilterNearest();
// 过滤掉倒车点
timegraph.FilterBack();
// 过滤抖动不直的点
//timegraph.FilterCrack();
#endregion 过滤
Console.WriteLine("Check2 whole timegraph");
Console.WriteLine("---------------------");
foreach (var v in timegraph.GraphPoints)
{
if (!v.Value.HasNext && !v.Value.HasPrev)
{
string msg = $"孤立拓扑点 mesh:{v.Value.meshId} gpsId:{v.Key}";
Console.WriteLine(msg);
}
if (v.Value.Next.Count > 1 && v.Value.Prev.Count > 1)
{
string msg = $"出现X形状 拓扑关系mesh:{v.Value.meshId} gpsId:{v.Key}";
Console.WriteLine(msg);
}
}
Console.WriteLine(">>>check end");
Dictionary<uint, RawGpsPointTimeGraph> meshtimegraphs = timegraph.SplitDataToMesh();
var enumerator = meshtimegraphs.GetEnumerator();
while (enumerator.MoveNext())
{
uint meshid = enumerator.Current.Key;
var meshtimegraph = enumerator.Current.Value;
GpsPointGraph gpsPointGraph = new GpsPointGraph(meshid);
gpsPointGraph.ResetPoints(meshtimegraph.GraphPoints);
var rv = gpsPointGraph.ExportGpsPoints(SourceType.Local);
if (!rv.value)
{
Console.WriteLine($"保存图幅 $(gpsPointGraph.meshId) 失败");
}
Console.WriteLine($"Check mesh:{meshid} ");
foreach (var v in meshtimegraph.GraphPoints)
{
if (!v.Value.HasNext && !v.Value.HasPrev)
{
string msg = $"孤立拓扑点 mesh:{meshid} gpsId:{v.Key}";
Console.WriteLine(msg);
}
if (v.Value.Next.Count > 1 && v.Value.Prev.Count > 1)
{
string msg = $"出现X形状 拓扑关系mesh:{meshid} gpsId:{v.Key}";
Console.WriteLine(msg);
}
}
Console.WriteLine(">>>check end");
}
}
private static void AppointPrevNextRelation(RawGpsPointTimeGraph timeGraph,
Dictionary<ulong, ulong> prevnextdict)
{
var enumerator = prevnextdict.GetEnumerator();
while (enumerator.MoveNext())
{
var pr = enumerator.Current;
var rv = timeGraph.Connect(pr.Key, pr.Value);
if (!rv.value)
{
Console.WriteLine(rv.errorString);
}
}
}
private static Dictionary<ulong, GpsPoint> FilterMeshid(GpsBaseData meshdata, RawGpsPointTimeGraph timegraph)
{
Dictionary<ulong, GpsPoint> meshdatadict = new Dictionary<ulong, GpsPoint>(meshdata.GpsList.Count);
foreach (var item in meshdata.GpsList)
{
GpsPoint point = null;
if (timegraph.GraphPoints.TryGetValue(item.gpsId, out point))
{
meshdatadict.Add(item.gpsId, point);
}
}
var enumtor = meshdatadict.GetEnumerator();
List<GpsPoint> applist = new List<GpsPoint>();
while (enumtor.MoveNext())
{
var cu = enumtor.Current;
var pt = cu.Value;
foreach (var item in pt.Next)
{
if (!meshdatadict.ContainsKey(item.gpsId))
{
GpsPoint point = null;
if (timegraph.GraphPoints.TryGetValue(item.gpsId, out point))
{
applist.Add(point);
}
}
}
foreach (var item in pt.Prev)
{
if (!meshdatadict.ContainsKey(item.gpsId))
{
GpsPoint point = null;
if (timegraph.GraphPoints.TryGetValue(item.gpsId, out point))
{
applist.Add(point);
}
}
}
}
// 有漏洞
foreach (var item1 in applist)
{
meshdatadict.Add(item1.gpsId, item1);
}
return meshdatadict;
}
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\HDMapBase\HDMapBase\HDMapBase.csproj" />
</ItemGroup>
</Project>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment