void test_distance( typename bg::coordinate_type<Point>::type const& lon1, typename bg::coordinate_type<Point>::type const& lat1, typename bg::coordinate_type<Point>::type const& lon2, typename bg::coordinate_type<Point>::type const& lat2, typename bg::coordinate_type<Point>::type const& lon3, typename bg::coordinate_type<Point>::type const& lat3, typename bg::coordinate_type<Point>::type const& radius, typename bg::coordinate_type<Point>::type const& expected, typename bg::coordinate_type<Point>::type const& tolerance) { typedef bg::strategy::distance::cross_track < Point, Point > strategy_type; typedef typename bg::strategy::distance::services::return_type < strategy_type >::type return_type; BOOST_CONCEPT_ASSERT ( (bg::concept::PointSegmentDistanceStrategy<strategy_type>) ); Point p1, p2, p3; bg::assign_values(p1, lon1, LatitudePolicy::apply(lat1)); bg::assign_values(p2, lon2, LatitudePolicy::apply(lat2)); bg::assign_values(p3, lon3, LatitudePolicy::apply(lat3)); strategy_type strategy; return_type d = strategy.apply(p1, p2, p3); BOOST_CHECK_CLOSE(radius * d, expected, tolerance); // Test specifying radius explicitly strategy_type strategy_radius(radius); d = strategy_radius.apply(p1, p2, p3); BOOST_CHECK_CLOSE(d, expected, tolerance); // Test the "default strategy" registration bg::model::referring_segment<Point const> segment(p2, p3); d = bg::distance(p1, segment); BOOST_CHECK_CLOSE(radius * d, expected, tolerance); }
void test_distance( typename bg::coordinate_type<Point>::type const& lon1, typename bg::coordinate_type<Point>::type const& lat1, typename bg::coordinate_type<Point>::type const& lon2, typename bg::coordinate_type<Point>::type const& lat2, typename bg::coordinate_type<Point>::type const& lon3, typename bg::coordinate_type<Point>::type const& lat3, typename bg::coordinate_type<Point>::type const& radius, typename bg::coordinate_type<Point>::type const& expected, typename bg::coordinate_type<Point>::type const& tolerance) { typedef bg::strategy::distance::cross_track < typename bg::coordinate_type<Point>::type > strategy_type; typedef typename bg::strategy::distance::services::return_type < strategy_type, Point, Point >::type return_type; { // compile-check if there is a strategy for this type typedef typename bg::strategy::distance::services::default_strategy < bg::point_tag, bg::segment_tag, Point, Point >::type cross_track_strategy_type; typedef typename bg::strategy::distance::services::default_strategy < bg::segment_tag, bg::point_tag, Point, Point >::type reversed_tags_cross_track_strategy_type; boost::ignore_unused<cross_track_strategy_type, reversed_tags_cross_track_strategy_type>(); } BOOST_CONCEPT_ASSERT ( (bg::concept::PointSegmentDistanceStrategy<strategy_type, Point, Point>) ); Point p1, p2, p3; bg::assign_values(p1, lon1, LatitudePolicy::apply(lat1)); bg::assign_values(p2, lon2, LatitudePolicy::apply(lat2)); bg::assign_values(p3, lon3, LatitudePolicy::apply(lat3)); strategy_type strategy; return_type d = strategy.apply(p1, p2, p3); BOOST_CHECK_CLOSE(radius * d, expected, tolerance); // The strategy should return the same result if we reverse the parameters d = strategy.apply(p1, p3, p2); BOOST_CHECK_CLOSE(radius * d, expected, tolerance); // Test specifying radius explicitly strategy_type strategy_radius(radius); d = strategy_radius.apply(p1, p2, p3); BOOST_CHECK_CLOSE(d, expected, tolerance); // Test the "default strategy" registration bg::model::referring_segment<Point const> segment(p2, p3); d = bg::distance(p1, segment); BOOST_CHECK_CLOSE(radius * d, expected, tolerance); }