Skip to content

Commit

Permalink
osm upload
Browse files Browse the repository at this point in the history
  • Loading branch information
spektor56 committed Feb 8, 2022
1 parent a7f288a commit 85c3104
Show file tree
Hide file tree
Showing 12 changed files with 525 additions and 134 deletions.
39 changes: 35 additions & 4 deletions OpenpilotSdk/Hardware/OpenpilotDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ public async Task<List<GpxWaypoint>> MapillaryExportAsync(Drive drive)

foreach (var driveSegment in drive.Segments.OrderBy(segment => segment.Index))
{
waypoints.AddRange(await OpenPilot.Logging.LogFile.GetWayPointsAsync(SftpClient.OpenRead(driveSegment.RawLog.FullName)));
waypoints.AddRange(await OpenPilot.Logging.LogFile.GetWaypointsAsync(SftpClient.OpenRead(driveSegment.RawLog.FullName)));

}

Expand Down Expand Up @@ -546,19 +546,50 @@ public async Task<IEnumerable<Firmware>> GetFirmwareVersions(IProgress<int> prog
return firmwares;
}

private async Task<IEnumerable<GpxWaypoint>> GetWaypoints(Drive drive)
{
var waypoints = new List<GpxWaypoint>();

var wayPointTasks = drive.Segments.OrderBy(segment => segment.Index)
.Select(GetWaypointsFromSegment);

int i = 0;
foreach (var wayPointTask in wayPointTasks)
{
i++;
waypoints.AddRange(await wayPointTask);
}

return waypoints;
}

private async Task<IEnumerable<GpxWaypoint>> GetWaypointsFromSegment(DriveSegment driveSegment)
{
await using (var fileStream = await SftpClient.OpenAsync(driveSegment.QuickLog.FullName, FileMode.Open,
FileAccess.Read, CancellationToken.None))
{
return await OpenPilot.Logging.LogFile.GetWaypointsAsync(fileStream);
}
}

public async Task<GpxFile> GenerateGpxFileAsync(Drive drive, IProgress<int> progress = null)
{
await ConnectAsync();

var waypoints = new List<GpxWaypoint>();

foreach (var driveSegment in drive.Segments.OrderBy(segment => segment.Index))
var wayPointTasks = drive.Segments.OrderBy(segment => segment.Index)
.Select(GetWaypointsFromSegment).ToArray();

int i = 0;
foreach (var wayPointTask in wayPointTasks)
{
waypoints.AddRange(await OpenPilot.Logging.LogFile.GetWayPointsAsync(SftpClient.OpenRead(driveSegment.RawLog.FullName)));
i++;
waypoints.AddRange(await wayPointTask);

if (progress != null)
{
progress.Report(driveSegment.Index);
progress.Report(i);
}
}

Expand Down
40 changes: 40 additions & 0 deletions OpenpilotSdk/OpenPilot/Drive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,46 @@ namespace OpenpilotSdk.OpenPilot
{
public class Drive
{
protected bool Equals(Drive other)
{
return Date.Equals(other.Date);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}

if (ReferenceEquals(this, obj))
{
return true;
}

if (obj.GetType() != this.GetType())
{
return false;
}

return Equals((Drive)obj);
}

public override int GetHashCode()
{
return Date.GetHashCode();
}

public static bool operator ==(Drive left, Drive right)
{
return Equals(left, right);
}

public static bool operator !=(Drive left, Drive right)
{
return !Equals(left, right);
}

public ReadOnlyCollection<DriveSegment> Segments { get; }
public DateTime Date { get; }

Expand Down
3 changes: 1 addition & 2 deletions OpenpilotSdk/OpenPilot/Logging/LogFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ namespace OpenpilotSdk.OpenPilot.Logging
{
public class LogFile
{
public static async Task<IEnumerable<GpxWaypoint>> GetWayPointsAsync(Stream fileStream)
public static async Task<IEnumerable<GpxWaypoint>> GetWaypointsAsync(Stream fileStream)
{
List<GpxWaypoint> waypoints = new List<GpxWaypoint>();

//using (var fileStream = File.OpenRead(file))
using (var bz2Stream = new BZip2InputStream(fileStream))
{
var pump = new FramePump(bz2Stream);
Expand Down
4 changes: 2 additions & 2 deletions OpenpilotSdk/OpenpilotSdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
<ItemGroup>
<PackageReference Include="Capnp.Net.Runtime" Version="1.3.118" />
<PackageReference Include="CapnpC.CSharp.MsBuild.Generation" Version="1.3.118" />
<PackageReference Include="FFMpegCore" Version="4.6.0" />
<PackageReference Include="FFMpegCore" Version="4.7.0" />
<PackageReference Include="GeoCoordinate.NetStandard1" Version="1.0.1" />
<PackageReference Include="NetTopologySuite" Version="2.4.0" />
<PackageReference Include="NetTopologySuite.IO.GPX" Version="1.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="SharpZipLib" Version="1.3.3" />
<PackageReference Include="SshNet.Security.Cryptography" Version="1.3.0" />
Expand Down
6 changes: 3 additions & 3 deletions OpenpilotToolkit/OpenpilotToolkit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CefSharp.WinForms.NetCore" Version="97.1.60" />
<PackageReference Include="CefSharp.WinForms.NetCore" Version="97.1.61" />
<PackageReference Include="chromiumembeddedframework.runtime.win-arm64" Version="97.1.6" />
<PackageReference Include="chromiumembeddedframework.runtime.win-x64" />
<PackageReference Include="chromiumembeddedframework.runtime.win-x86" Version="97.1.6" />
Expand All @@ -642,8 +642,8 @@
<PackageReference Include="Octokit" Version="0.50.0" />
<PackageReference Include="Serilog" Version="2.10.1-dev-01343" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
<PackageReference Include="SshKeyGenerator" Version="1.1.40" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.0.0" />
<PackageReference Include="SshKeyGenerator" Version="1.1.45" />
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.16" />
</ItemGroup>

Expand Down
Loading

0 comments on commit 85c3104

Please sign in to comment.