[distance] Spheroid passed as parameter, more general strategy getter for distance strategy

This commit is contained in:
Vissarion Fysikopoulos
2017-07-13 12:52:52 +03:00
parent 8b33899ec7
commit 36232a3cdb
5 changed files with 35 additions and 70 deletions

View File

@@ -25,26 +25,25 @@ template
typename Inverse_type_distance,
typename Direct_type
>
class cross_track_geo_formula{
class distance_point_segment{
public:
template <typename Spheroid>
CT static inline apply(CT lon1, CT lat1, //p1
CT lon2, CT lat2, //p2
CT lon3, CT lat3) //query point p3
CT lon3, CT lat3, //query point p3
Spheroid const& spheroid,
CT earth_radius =
geometry::srs::sphere<CT>().get_radius<1>())
{
int print = 0;
// Constants
geometry::srs::spheroid<CT> spheroid;
CT const f = flattening<CT>(spheroid);
CT const pi = math::pi<CT>();
CT const half_pi = math::pi<CT>() / CT(2);
geometry::srs::sphere<CT> sphere;
CT const earth_radius = sphere.get_radius<1>();
//CT const earth_radius = 6372795;
//CT const earth_radius = 6378137;
// Convert to radians
lon1 = math::as_radian<Units>(lon1);

View File

@@ -49,18 +49,15 @@ namespace boost { namespace geometry
namespace strategy { namespace distance
{
/*!
\brief Strategy functor for distance point to segment calculation
\brief Strategy functor for distance point to segment calculation on ellipsoid
\ingroup strategies
\details Class which calculates the distance of a point to a segment, for points on a sphere or globe
\see http://williams.best.vwh.net/avform.htm
\details Class which calculates the distance of a point to a segment, for points
on the ellipsoid
\see https://arxiv.org/abs/1102.1215
\tparam FormulaPolicy underlying point-point distance strategy
\tparam Spheroid is the spheroidal model used
\tparam CalculationType \tparam_calculation
\tparam Strategy underlying point-point distance strategy
\qbk{
[heading See also]
[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
}
*/
template
<
@@ -84,21 +81,21 @@ public :
>
{};
inline cross_track_geo()
struct distance_strategy
{
typedef geographic<FormulaPolicy, Spheroid, CalculationType> type;
};
inline typename distance_strategy::type get_distance_strategy() const
{
typedef typename distance_strategy::type distance_type;
return distance_type(m_spheroid);
}
explicit cross_track_geo(Spheroid const& spheroid = Spheroid())
: m_spheroid(spheroid)
{}
typedef geographic
<
FormulaPolicy, Spheroid, CalculationType
> DistanceStrategy;
/*
template <typename T>
inline T comparable_to_distance(T& a) const
{
return a;
}
*/
template <typename Point, typename PointOfSegment>
inline typename return_type<Point, PointOfSegment>::type
apply(Point const& p, PointOfSegment const& sp1, PointOfSegment const& sp2) const
@@ -136,7 +133,7 @@ public :
false
> direct_type;
return geometry::formula::cross_track_geo_formula
return geometry::formula::distance_point_segment
<
CT,
units_type,
@@ -145,14 +142,12 @@ public :
direct_type
>::apply(get<0>(sp1), get<1>(sp1),
get<0>(sp2), get<1>(sp2),
get<0>(p), get<1>(p));
get<0>(p), get<1>(p),
m_spheroid);
}
//TODO: apply a more general strategy getter
inline DistanceStrategy get_distance_strategy() const
{
return DistanceStrategy();
}
private :
Spheroid m_spheroid;
};
@@ -278,32 +273,6 @@ public :
}
};
/*
template
<
typename FormulaPolicy,
typename P,
typename PS
>
struct result_from_comparable
<
cross_track_geo<FormulaPolicy>, P, PS
>
{
private :
typedef cross_track_geo<FormulaPolicy> strategy_type;
// typedef typename return_type<strategy_type, P, PS>::type return_type;
public :
template <typename T>
static inline T apply(strategy_type const& strategy,
T const& comparable_distance)
{
//T c = T(2.0) * asin(math::sqrt(a));
//return c * strategy.radius();
return comparable_distance;
}
};
*/
template <typename Point, typename PointOfSegment>
struct default_strategy

View File

@@ -118,7 +118,6 @@ struct geographic_segments
return strategy_type(m_spheroid);
}
template <typename Geometry>
struct distance_strategy
{
typedef distance::geographic
@@ -129,10 +128,9 @@ struct geographic_segments
> type;
};
template <typename Geometry>
inline typename distance_strategy<Geometry>::type get_distance_strategy() const
inline typename distance_strategy::type get_distance_strategy() const
{
typedef typename distance_strategy<Geometry>::type strategy_type;
typedef typename distance_strategy::type strategy_type;
return strategy_type(m_spheroid);
}