Boost logo

Geometry :

Subject: Re: [geometry] distance and comparable_distance
From: Barend Gehrels (barend_at_[hidden])
Date: 2012-11-26 17:18:52


Hi Jeff,

On 26-11-2012 19:27, jeffpoly wrote:
> hello Barend,
>
> Thanks for your reply, and soryy for delay to post the sample below is the
> sampel program,
>
> typedef model::d2::point_xy<double> point_2d;
> typedef model::linestring<point_2d> linestring_2d;
>
> point_2d lp;
> lp = make<point_2d>(31.988994, 7.738198);
>
> linestring_2d ls;
> ls.push_back(make<point_2d>(32.0, 9.637687));
> ls.push_back(make<point_2d>(32.0, 7.0));
> ls.push_back(make<point_2d>(33.544565, 7.0));
> ls.push_back(make<point_2d>(33.544565, 9.637687));
> ls.push_back(make<point_2d>(32.0, 9.637687));
>
> std::cout << "distance of " << dsv(lp)
> << " to line: " << distance(lp, ls) << std::endl;
>
> std::cout << "comparable_distance of " << dsv(lp)
> << " to line: " << comparable_distance(lp, ls) << std::endl;
>
> This gives the following results:
>
> distance of (31.989, 7.7382) to line: 0.011006
> comparable_distance of (31.989, 7.7382) to line: 0.011006
>

OK, I could reproduce it. It was wrong indeed, has been wrong since 2010
or so. Thanks for the message! Last time I checked (I think I did) the
underlying point-segment distance, which was OK. But this was wrong. The
corresponding unit-test was also wrong, why it was unnoticed.

It is fixed now, in the trunk. It will be released in 1.53. Thanks again
& sorry for the error.

Regards, Barend


Geometry list run by mateusz at loskot.net