mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-10 07:34:03 +00:00
[geometry] Fixed results for distance of integer point types point-segment
or point-linestring
This commit is contained in:
parent
cec1994358
commit
8af588045e
@ -85,7 +85,9 @@ public :
|
|||||||
<
|
<
|
||||||
Point1,
|
Point1,
|
||||||
Point2,
|
Point2,
|
||||||
CalculationType
|
CalculationType,
|
||||||
|
double,
|
||||||
|
double
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
@ -133,8 +133,27 @@ void test_all()
|
|||||||
test_distance_linestring<P>();
|
test_distance_linestring<P>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void test_double_result_from_integer()
|
||||||
|
{
|
||||||
|
typedef bg::model::point<T, 2, bg::cs::cartesian> point_type;
|
||||||
|
point_type point;
|
||||||
|
bg::model::linestring<point_type> ls;
|
||||||
|
bg::read_wkt("POINT(2 2)", point);
|
||||||
|
bg::read_wkt("LINESTRING(4 1,1 4)", ls);
|
||||||
|
|
||||||
|
double dd = bg::distance(point, ls);
|
||||||
|
double dc = bg::comparable_distance(point, ls);
|
||||||
|
|
||||||
|
BOOST_CHECK_CLOSE(dd, std::sqrt(0.5), 0.001);
|
||||||
|
BOOST_CHECK_CLOSE(dc, 0.5, 0.001);
|
||||||
|
}
|
||||||
|
|
||||||
int test_main(int, char* [])
|
int test_main(int, char* [])
|
||||||
{
|
{
|
||||||
|
test_double_result_from_integer<int>();
|
||||||
|
test_double_result_from_integer<boost::long_long_type>();
|
||||||
|
|
||||||
//test_all<bg::model::d2::point_xy<int> >();
|
//test_all<bg::model::d2::point_xy<int> >();
|
||||||
test_all<bg::model::d2::point_xy<float> >();
|
test_all<bg::model::d2::point_xy<float> >();
|
||||||
test_all<bg::model::d2::point_xy<double> >();
|
test_all<bg::model::d2::point_xy<double> >();
|
||||||
|
@ -253,7 +253,9 @@ void test_integer(bool check_types)
|
|||||||
if (check_types)
|
if (check_types)
|
||||||
{
|
{
|
||||||
BOOST_CHECK((boost::is_same<distance_type, double>::type::value));
|
BOOST_CHECK((boost::is_same<distance_type, double>::type::value));
|
||||||
BOOST_CHECK((boost::is_same<cdistance_type, boost::long_long_type>::type::value));
|
// comparable_distance results in now double too, obviously because
|
||||||
|
// comp.distance point-segment can be fraction, even for integer input
|
||||||
|
BOOST_CHECK((boost::is_same<cdistance_type, double>::type::value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user