Skip to content

Commit

Permalink
Update save methods + bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelsk committed Jun 3, 2021
1 parent c698c87 commit 66f5a94
Show file tree
Hide file tree
Showing 15 changed files with 205 additions and 60 deletions.
6 changes: 5 additions & 1 deletion GISBlox.Services.CLI/GISBlox.Services.CLI/Cmd.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using GISBlox.Services.CLI.Commands.Auth;
// ------------------------------------------------------------
// Copyright (c) Bartels Online. All rights reserved.
// ------------------------------------------------------------

using GISBlox.Services.CLI.Commands.Auth;
using GISBlox.Services.CLI.Commands.Convert;
using GISBlox.Services.CLI.Commands.Project;
using McMaster.Extensions.CommandLineUtils;
Expand Down
6 changes: 5 additions & 1 deletion GISBlox.Services.CLI/GISBlox.Services.CLI/CmdBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using GISBlox.Services.CLI.Utils;
// ------------------------------------------------------------
// Copyright (c) Bartels Online. All rights reserved.
// ------------------------------------------------------------

using GISBlox.Services.CLI.Utils;
using GISBlox.Services.SDK;
using McMaster.Extensions.CommandLineUtils;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using GISBlox.Services.CLI.Utils;
// ------------------------------------------------------------
// Copyright (c) Bartels Online. All rights reserved.
// ------------------------------------------------------------

using GISBlox.Services.CLI.Utils;
using McMaster.Extensions.CommandLineUtils;
using System;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using McMaster.Extensions.CommandLineUtils;
// ------------------------------------------------------------
// Copyright (c) Bartels Online. All rights reserved.
// ------------------------------------------------------------

using McMaster.Extensions.CommandLineUtils;
using System;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using McMaster.Extensions.CommandLineUtils;
// ------------------------------------------------------------
// Copyright (c) Bartels Online. All rights reserved.
// ------------------------------------------------------------

using McMaster.Extensions.CommandLineUtils;
using System;
using System.Linq;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using GISBlox.Services.SDK.Models;
// ------------------------------------------------------------
// Copyright (c) Bartels Online. All rights reserved.
// ------------------------------------------------------------

using GISBlox.Services.SDK.Models;
using McMaster.Extensions.CommandLineUtils;
using System;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
using GISBlox.Services.CLI.Utils;
// ------------------------------------------------------------
// Copyright (c) Bartels Online. All rights reserved.
// ------------------------------------------------------------

using GISBlox.Services.CLI.Utils;
using GISBlox.Services.SDK.Models;
using McMaster.Extensions.CommandLineUtils;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;

namespace GISBlox.Services.CLI.Commands.Project
Expand Down Expand Up @@ -61,12 +66,12 @@ protected override async Task<int> OnExecute(CommandLineApplication app)
if (IncludeSource)
{
Location location = await GISBloxClient.Projection.ToWGS84Complete(p, Decimals > 0 ? Decimals : -1);
OutputToConsole($"X: { location.X } Y: { location.Y } Lat: { location.Lat.ToString(System.Globalization.CultureInfo.InvariantCulture) } Lon: { location.Lon.ToString(System.Globalization.CultureInfo.InvariantCulture) }", ConsoleColor.Green);
OutputToConsole(PositionParser.LocationToString(location, ";", false, XYFormat ? CoordinateOrderEnum.LatLon : CoordinateOrderEnum.LonLat, CultureInfo.CurrentCulture), ConsoleColor.Green);
}
else
{
Coordinate coordinate = await GISBloxClient.Projection.ToWGS84(p, Decimals > 0 ? Decimals : -1);
OutputToConsole($"Lat: { coordinate.Lat.ToString(System.Globalization.CultureInfo.InvariantCulture) } Lon: { coordinate.Lon.ToString(System.Globalization.CultureInfo.InvariantCulture) }", ConsoleColor.Green);
Coordinate coordinate = await GISBloxClient.Projection.ToWGS84(p, Decimals > 0 ? Decimals : -1);
OutputToConsole(PositionParser.CoordinateToString(coordinate, ";", XYFormat ? CoordinateOrderEnum.LatLon : CoordinateOrderEnum.LonLat, CultureInfo.CurrentCulture), ConsoleColor.Green);
}
return 0;
}
Expand All @@ -81,12 +86,12 @@ protected override async Task<int> OnExecute(CommandLineApplication app)
if (IncludeSource)
{
List<Location> locations = await GISBloxClient.Projection.ToWGS84Complete(rdPoints, Decimals > 0 ? Decimals : -1);
await IO.SaveToCSVFile(OutputFile, Separator, locations);
await IO.SaveToCSVFile(OutputFile, ";", locations, false, XYFormat ? CoordinateOrderEnum.LatLon : CoordinateOrderEnum.LonLat, CultureInfo.CurrentCulture);
}
else
{
List<Coordinate> coordinates = await GISBloxClient.Projection.ToWGS84(rdPoints, Decimals > 0 ? Decimals : -1);
await IO.SaveToCSVFile(OutputFile, Separator, rdPoints);
await IO.SaveToCSVFile(OutputFile, ";", coordinates, XYFormat ? CoordinateOrderEnum.LatLon : CoordinateOrderEnum.LonLat, CultureInfo.CurrentCulture);
}
OutputToConsole($"Output saved to file '{ OutputFile }'", ConsoleColor.Green);
return 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
using GISBlox.Services.CLI.Utils;
// ------------------------------------------------------------
// Copyright (c) Bartels Online. All rights reserved.
// ------------------------------------------------------------

using GISBlox.Services.CLI.Utils;
using GISBlox.Services.SDK.Models;
using McMaster.Extensions.CommandLineUtils;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;

namespace GISBlox.Services.CLI.Commands.Project
Expand Down Expand Up @@ -58,12 +63,12 @@ protected override async Task<int> OnExecute(CommandLineApplication app)
if (IncludeSource)
{
Location location = await GISBloxClient.Projection.ToRDSComplete(c);
OutputToConsole($"Lat: { location.Lat.ToString(System.Globalization.CultureInfo.InvariantCulture) } Lon: { location.Lon.ToString(System.Globalization.CultureInfo.InvariantCulture) } X: { location.X } Y: { location.Y }", ConsoleColor.Green);
OutputToConsole(PositionParser.LocationToString(location, ";", true, LatLonFormat ? CoordinateOrderEnum.LatLon : CoordinateOrderEnum.LonLat, CultureInfo.CurrentCulture), ConsoleColor.Green);
}
else
{
RDPoint rdPoint = await GISBloxClient.Projection.ToRDS(c);
OutputToConsole($"X: { rdPoint.X } Y: { rdPoint.Y }", ConsoleColor.Green);
OutputToConsole(PositionParser.RDPointToString(rdPoint, ";", LatLonFormat ? RDPointOrderEnum.XY : RDPointOrderEnum.YX, CultureInfo.CurrentCulture), ConsoleColor.Green);
}
return 0;
}
Expand All @@ -77,13 +82,13 @@ protected override async Task<int> OnExecute(CommandLineApplication app)
OutputToConsole("Writing output...");
if (IncludeSource)
{
List<Location> locations = await GISBloxClient.Projection.ToRDSComplete(coordinates);
await IO.SaveToCSVFile(OutputFile, Separator, locations);
List<Location> locations = await GISBloxClient.Projection.ToRDSComplete(coordinates);
await IO.SaveToCSVFile(OutputFile, ";", locations, true, LatLonFormat ? CoordinateOrderEnum.LatLon : CoordinateOrderEnum.LonLat, CultureInfo.CurrentCulture);
}
else
{
List<RDPoint> rdPoints = await GISBloxClient.Projection.ToRDS(coordinates);
await IO.SaveToCSVFile(OutputFile, Separator, rdPoints);
await IO.SaveToCSVFile(OutputFile, ";", rdPoints, LatLonFormat ? RDPointOrderEnum.XY : RDPointOrderEnum.YX, CultureInfo.CurrentCulture);
}
OutputToConsole($"Output saved to file '{ OutputFile }'", ConsoleColor.Green);
return 0;
Expand Down
6 changes: 5 additions & 1 deletion GISBlox.Services.CLI/GISBlox.Services.CLI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Microsoft.Extensions.Configuration;
// ------------------------------------------------------------
// Copyright (c) Bartels Online. All rights reserved.
// ------------------------------------------------------------

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using System;
using System.IO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"GISBlox.Services.CLI": {
"commandName": "Project",
"commandLineArgs": "project to-wgs84 -i \"C:\\Users\\thirt\\OneDrive\\Desktop\\test-to-wgs84.txt\" -o \"C:\\Users\\thirt\\OneDrive\\Desktop\\testout-to-wgs84.csv\" -x true -h false -s \";\" -is -d 2"
"commandLineArgs": "project to-rds -i \"C:\\Users\\thirt\\OneDrive\\Desktop\\testdata.txt\" -o \"C:\\Users\\thirt\\OneDrive\\Desktop\\testout.txt\" -l true -h true -s \";\" -is"
}
}
}
8 changes: 3 additions & 5 deletions GISBlox.Services.CLI/GISBlox.Services.CLI/UserProfile.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// ------------------------------------------------------------
// Copyright (c) Bartels Online. All rights reserved.
// ------------------------------------------------------------

namespace GISBlox.Services.CLI
{
Expand Down
6 changes: 5 additions & 1 deletion GISBlox.Services.CLI/GISBlox.Services.CLI/Utils/Enums.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace GISBlox.Services.CLI.Utils
// ------------------------------------------------------------
// Copyright (c) Bartels Online. All rights reserved.
// ------------------------------------------------------------

namespace GISBlox.Services.CLI.Utils
{
internal enum CoordinateOrderEnum { LatLon, LonLat, Invariant };

Expand Down
Loading

0 comments on commit 66f5a94

Please sign in to comment.