Use an extra vertex radial with missing data to prevent stretching

This commit is contained in:
Dan Paulat 2024-10-02 05:56:27 -05:00
parent a548497767
commit fe4a324a04
3 changed files with 89 additions and 8 deletions

View file

@ -3,6 +3,8 @@
#include <string>
#include <vector>
#include <units/angle.h>
namespace scwx
{
namespace common
@ -46,6 +48,17 @@ enum class DistanceType
Miles
};
/**
* Calculate the absolute angle delta between two angles.
*
* @param [in] angle1 First angle
* @param [in] angle2 Second angle
*
* @return Absolute angle delta normalized to [0, 360)
*/
units::degrees<float> GetAngleDelta(units::degrees<float> angle1,
units::degrees<float> angle2);
/**
* Calculate the geographic midpoint of a set of coordinates. Uses Method A
* described at http://www.geomidpoint.com/calculation.html.

View file

@ -14,6 +14,34 @@ static std::string GetDegreeString(double degrees,
DegreeStringType type,
const std::string& suffix);
units::degrees<float> GetAngleDelta(units::degrees<float> angle1,
units::degrees<float> angle2)
{
// Normalize angles to [0, 360)
while (angle1.value() < 0.0f)
{
angle1 += units::degrees<float> {360.0f};
}
while (angle2.value() < 0.0f)
{
angle2 += units::degrees<float> {360.0f};
}
angle1 = units::degrees<float> {std::fmod(angle1.value(), 360.f)};
angle2 = units::degrees<float> {std::fmod(angle2.value(), 360.f)};
// Calculate the absolute difference
auto delta = angle1 - angle2;
if (delta < units::degrees<float> {0.0f})
{
delta *= -1.0f;
}
// Account for wrapping
delta = std::min(delta, units::degrees<float> {360.0f} - delta);
return delta;
}
Coordinate GetCentroid(const std::vector<Coordinate>& coordinates)
{
double x = 0.0;