// Relate segments a and b
template
<
- typename Segment1,
- typename Segment2,
- typename Policy,
- typename RobustPolicy
+ typename UniqueSubRange1,
+ typename UniqueSubRange2,
+ typename Policy
>
- inline typename Policy::return_type apply(Segment1 const& a, Segment2 const& b,
- Policy const& policy,
- RobustPolicy const& robust_policy) const
+ inline typename Policy::return_type apply(UniqueSubRange1 const& range_p,
+ UniqueSubRange2 const& range_q,
+ Policy const&) const
{
- typedef typename point_type<Segment1>::type point1_t;
- typedef typename point_type<Segment2>::type point2_t;
- point1_t a1, a2;
- point2_t b1, b2;
-
- detail::assign_point_from_index<0>(a, a1);
- detail::assign_point_from_index<1>(a, a2);
- detail::assign_point_from_index<0>(b, b1);
- detail::assign_point_from_index<1>(b, b2);
+ typedef typename UniqueSubRange1::point_type point1_type;
+ typedef typename UniqueSubRange2::point_type point2_type;
+ typedef model::referring_segment<point1_type const> segment_type1;
+ typedef model::referring_segment<point2_type const> segment_type2;
- return apply(a, b, policy, robust_policy, a1, a2, b1, b2);
- }
+ BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<point1_type>) );
+ BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<point2_type>) );
- // Relate segments a and b
- template
- <
- typename Segment1,
- typename Segment2,
- typename Policy,
- typename RobustPolicy,
- typename Point1,
- typename Point2
- >
- inline typename Policy::return_type apply(Segment1 const& a, Segment2 const& b,
- Policy const&, RobustPolicy const&,
- Point1 a1, Point1 a2, Point2 b1, Point2 b2) const
- {
- bool is_a_reversed = get<1>(a1) > get<1>(a2);
- bool is_b_reversed = get<1>(b1) > get<1>(b2);
/*
typename coordinate_type<Point1>::type
const a1_lon = get<0>(a1),
const b2_lon = get<0>(b2);
bool is_a_reversed = a1_lon > a2_lon || a1_lon == a2_lon && get<1>(a1) > get<1>(a2);
bool is_b_reversed = b1_lon > b2_lon || b1_lon == b2_lon && get<1>(b1) > get<1>(b2);
- */
- if (is_a_reversed)
- {
- std::swap(a1, a2);
- }
-
- if (is_b_reversed)
- {
- std::swap(b1, b2);
- }
-
- return apply<Policy>(a, b, a1, a2, b1, b2, is_a_reversed, is_b_reversed);
+ */
+
+ bool const is_p_reversed = get<1>(range_p.at(0)) > get<1>(range_p.at(1));
+ bool const is_q_reversed = get<1>(range_q.at(0)) > get<1>(range_q.at(1));
+
+ // Call apply with original segments and ordered points
+ return apply<Policy>(segment_type1(range_p.at(0), range_p.at(1)),
+ segment_type2(range_q.at(0), range_q.at(1)),
+ range_p.at(is_p_reversed ? 1 : 0),
+ range_p.at(is_p_reversed ? 0 : 1),
+ range_q.at(is_q_reversed ? 1 : 0),
+ range_q.at(is_q_reversed ? 0 : 1),
+ is_p_reversed, is_q_reversed);
}
private:
return false;
}
+ typedef typename FormulaPolicy::template inverse<CalcT, true, false, false, false, false> inverse_dist;
+
ip_flag = ipi_inters;
if (is_on_b1)
{
lon = b1_lon;
lat = b1_lat;
+ dist_a1_ip = inverse_dist::apply(a1_lon, a1_lat, lon, lat, spheroid).distance; // for consistency
dist_b1_ip = 0;
ip_flag = ipi_at_b1;
}
{
lon = b2_lon;
lat = b2_lat;
+ dist_a1_ip = inverse_dist::apply(a1_lon, a1_lat, lon, lat, spheroid).distance; // for consistency
dist_b1_ip = res_b1_b2.distance;
ip_flag = ipi_at_b2;
}
lon = a1_lon;
lat = a1_lat;
dist_a1_ip = 0;
+ dist_b1_ip = inverse_dist::apply(b1_lon, b1_lat, lon, lat, spheroid).distance; // for consistency
ip_flag = ipi_at_a1;
}
else if (is_on_a2)
lon = a2_lon;
lat = a2_lat;
dist_a1_ip = res_a1_a2.distance;
+ dist_b1_ip = inverse_dist::apply(b1_lon, b1_lat, lon, lat, spheroid).distance; // for consistency
ip_flag = ipi_at_a2;
}