Proper GPSCoords construction from a single float value, moved ref variables to GPSCoords
This commit is contained in:
@@ -191,11 +191,40 @@ namespace
|
||||
|
||||
namespace OpenVulkano::Image
|
||||
{
|
||||
GPSCoords::GPSCoords(int32_t valueForAll)
|
||||
GPSCoords::GPSCoords(float decimalDegrees, bool isLatitude)
|
||||
{
|
||||
this->degrees = valueForAll;
|
||||
this->minutes = valueForAll;
|
||||
this->seconds = valueForAll;
|
||||
degrees = static_cast<int32_t>(decimalDegrees);
|
||||
|
||||
float fractionalDegrees = decimalDegrees - degrees;
|
||||
minutes = static_cast<int32_t>(std::abs(fractionalDegrees) * 60);
|
||||
|
||||
float fractionalMinutes = (std::abs(fractionalDegrees) * 60) - minutes;
|
||||
seconds = static_cast<int32_t>(fractionalMinutes * 60);
|
||||
|
||||
if (isLatitude)
|
||||
{
|
||||
if (decimalDegrees < 0)
|
||||
{
|
||||
latitudeRef = LatitudeRef::SOUTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
latitudeRef = LatitudeRef::NORTH;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (decimalDegrees < 0)
|
||||
{
|
||||
longitudeRef = LongitudeRef::WEST;
|
||||
}
|
||||
else
|
||||
{
|
||||
longitudeRef = LongitudeRef::EAST;
|
||||
}
|
||||
}
|
||||
|
||||
degrees = std::abs(degrees);
|
||||
}
|
||||
|
||||
GPSCoords::GPSCoords(int32_t degrees, int32_t minutes, int32_t seconds)
|
||||
@@ -410,7 +439,7 @@ namespace OpenVulkano::Image
|
||||
// Latitude Ref
|
||||
AppendTagAndValueType(result, 1, (uint16_t) IFDValueType::ASCII);
|
||||
AppendU32(result, 2); // 2 for N/S + \0
|
||||
AppendU8(result, latitudeRef == LatitudeRef::NORTH ? 'N' : 'S');
|
||||
AppendU8(result, latitude.latitudeRef == LatitudeRef::NORTH ? 'N' : 'S');
|
||||
AppendU8(result, 0);
|
||||
AppendU8(result, 0); // padding
|
||||
AppendU8(result, 0); // padding
|
||||
@@ -423,7 +452,7 @@ namespace OpenVulkano::Image
|
||||
// Longitude Ref
|
||||
AppendTagAndValueType(result, 3, (uint16_t) IFDValueType::ASCII);
|
||||
AppendU32(result, 2); // 2 for E/W + \0
|
||||
AppendU8(result, longitudeRef == LongitudeRef::EAST ? 'E' : 'W');
|
||||
AppendU8(result, longitude.longitudeRef == LongitudeRef::EAST ? 'E' : 'W');
|
||||
AppendU8(result, 0);
|
||||
AppendU8(result, 0); // padding
|
||||
AppendU8(result, 0); // padding
|
||||
@@ -504,7 +533,7 @@ namespace OpenVulkano::Image
|
||||
{
|
||||
auto now = std::chrono::system_clock::now();
|
||||
std::time_t currentTime = std::chrono::system_clock::to_time_t(now);
|
||||
std::tm *timeInfo = std::localtime(¤tTime);
|
||||
std::tm* timeInfo = std::localtime(¤tTime);
|
||||
std::ostringstream oss;
|
||||
oss << std::put_time(timeInfo, "%Y:%m:%d %H:%M:%S");
|
||||
return oss.str();
|
||||
|
||||
@@ -36,8 +36,10 @@ namespace OpenVulkano::Image
|
||||
struct GPSCoords
|
||||
{
|
||||
int32_t degrees, minutes, seconds;
|
||||
LatitudeRef latitudeRef = LatitudeRef::NORTH;
|
||||
LongitudeRef longitudeRef = LongitudeRef::EAST;
|
||||
|
||||
GPSCoords(int32_t valueForAll = 0);
|
||||
GPSCoords(float decimalDegrees, bool isLatitude);
|
||||
GPSCoords(int32_t degrees, int32_t minutes, int32_t seconds);
|
||||
};
|
||||
|
||||
@@ -54,10 +56,7 @@ namespace OpenVulkano::Image
|
||||
std::string dateTaken; // format: yyyy:mm:dd hh:mm:ss
|
||||
std::string softwareUsed = "OpenVulkano";
|
||||
|
||||
LatitudeRef latitudeRef = LatitudeRef::NORTH;
|
||||
GPSCoords latitude = { 0, 0, 0 };
|
||||
|
||||
LongitudeRef longitudeRef = LongitudeRef::EAST;
|
||||
GPSCoords longitude = { 0, 0, 0 };
|
||||
|
||||
bool altitudeIsAboveSeaLevel = true;
|
||||
|
||||
Reference in New Issue
Block a user