Skip to content

Commit

Permalink
Command line arguments added.
Browse files Browse the repository at this point in the history
  • Loading branch information
halmaia authored Mar 1, 2023
1 parent c012497 commit bb79521
Showing 1 changed file with 40 additions and 20 deletions.
60 changes: 40 additions & 20 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,60 @@
using System;
using System.Collections.Generic;
using System;
using static System.IO.Path;

namespace SL3Reader
{
public static class Program
{
public static void Main(string[] args)
{
if (args.Length != 2)
{
Console.WriteLine(@"Usage example: SL3Reader.exe C:\input.sl3 D:\output.csv");
namespace SL3Reader {

public static class Program {
public static void Main(string[] args) {
if (args.Length != 3) {
PrintUsage();
return;
}

string input = GetFullPath(args[0]);
if(!Exists(input))
{
if (!Exists(input)) {
Console.WriteLine("Input file not found!");
PrintUsage();
return;
}

string output = GetFullPath(args[1]);
if (!Exists(GetDirectoryName(output)))
{
if (!Exists(GetDirectoryName(output))) {
Console.WriteLine("Directory not found for the output file!");
PrintUsage();
return;
}

using SL3Reader sl3reader = new(input);

sl3reader.Export3D(output);
//sl3reader.ExportImagery(@"F:\SS\", SurveyType.DownScan);
//sl3reader.ExamineUnknown8Datasets();
string expSelector = args[2].Trim().ToLowerInvariant();
switch (expSelector) {
case "-3d":
sl3reader.Export3D(output);
break;
case "-route":
sl3reader.ExportToCSV(output);
break;
default:
Console.WriteLine("Invalid third argument (" + expSelector + ").");
PrintUsage();
return;
}

PrintSummary();

return;

//sl3reader.ExportToCSV(output);
static void PrintUsage() {
Console.WriteLine("Usage examples:");
Console.WriteLine("To export 3D points: SL3Reader.exe \"C:\\input.sl3\" \"D:\\output.csv\" -3d");
Console.WriteLine("To export route: SL3Reader.exe \"C:\\input.sl3\" \"D:\\output.csv\" -route");
}

void PrintSummary() {
Console.WriteLine("Number of frames: " + sl3reader.Frames.Count.ToString());
Console.WriteLine("Number of 3D frames: " + sl3reader.IndexByType[SurveyType.ThreeDimensional].Count.ToString());
Console.WriteLine("\nExport finished successfully.");
}
}
}
}
}

0 comments on commit bb79521

Please sign in to comment.