Skip to content

Commit

Permalink
Use rather the scoped enum for the coordinate format.
Browse files Browse the repository at this point in the history
  • Loading branch information
vahancho committed Feb 5, 2024
1 parent b9259a1 commit b4abadf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/coordinate.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ERKIR_EXPORT Coordinate
{
public:
/// The coordinates human readable format types.
enum Format
enum class Format
{
DMS, ///< Degrees Minutes Seconds (D° M' S")
DDM, ///< Decimal Minutes (D° M.M')
Expand Down
18 changes: 9 additions & 9 deletions src/coordinate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,21 @@ static double parseRx(const std::string &coord, const RxList &rxList, char hemis
auto v = parseRx(wcoord, rx.second);
if (!v.empty()) {
switch (rx.first) {
case Coordinate::DD:
case Coordinate::Format::DD:
{
assert(v.size() >= 1);
dd = std::stof(v.at(0));
break;
};
case Coordinate::DDM:
case Coordinate::Format::DDM:
{
assert(v.size() >= 2);
auto d = std::stof(v.at(0));
auto m = toDouble(v.at(1), 60.0);
dd = d + m / 60.0;
break;
}
case Coordinate::DMS:
case Coordinate::Format::DMS:
{
assert(v.size() >= 3);
auto d = std::stof(v.at(0));
Expand Down Expand Up @@ -221,9 +221,9 @@ Latitude Latitude::fromString(const std::string &coord)

static const RxList rxList =
{
{ DMS, rxDMS },
{ DDM, rxDDM },
{ DD , rxDD }
{ Coordinate::Format::DMS, rxDMS },
{ Coordinate::Format::DDM, rxDDM },
{ Coordinate::Format::DD , rxDD }
};

return { parseRx(coord, rxList, 'S')};
Expand All @@ -250,9 +250,9 @@ Longitude Longitude::fromString(const std::string &coord)

static const RxList rxList =
{
{ DMS, rxDMS },
{ DDM, rxDDM },
{ DD , rxDD }
{ Coordinate::Format::DMS, rxDMS },
{ Coordinate::Format::DDM, rxDDM },
{ Coordinate::Format::DD , rxDD }
};

return { parseRx(coord, rxList, 'W')};
Expand Down

0 comments on commit b4abadf

Please sign in to comment.