Opened 8 years ago

Closed 8 years ago

#10421 closed Bugs (fixed)

Wrong Pt/Box distance/comparable_distance results in spherical CS

Reported by: awulkiew Owned by: Barend Gehrels
Milestone: Boost 1.57.0 Component: geometry
Version: Boost 1.56.0 Severity: Problem
Keywords: Cc:

Description (last modified by awulkiew)

distance(Pt, Box) and comparable_distance(Pt, Box) returns invalid results in some cases, or at least not-corresponding to the Pt/Pt versions. E.g. for:

    point target(10.932501600000000, 59.922640600000001);
    point pt(10.7535660, 59.9131705);
    point pmin(10.187599199999999, 59.747306700000003);
    point pmax(10.753619700000000, 59.917844000000002);
    box bounding_box(pmin, pmax);

    bool target_inside_box = bg::covered_by(target, bounding_box);
    bool point_inside_box = bg::covered_by(pt, bounding_box);
    // the same for bg::comparable_distance()
    double dp = bg::distance(target, pt);
    double db = bg::distance(target, bounding_box);
    double dm = bg::distance(target, pmax);

The results are:

    target inside box = FALSE
    point inside box = TRUE
    target to point = 0.00157408
    target to box = 0.178946
    target to max = 0.00156704

Since the point lies inside the box and target outside the box the distance from target to box should be smaller than from target to point.

This bug affects the R-tree and is related with this ticket: boost::geometry::index::rtree does not work properly spherical_equatorial.

EDIT: The algorithm uses the cartesian pythagoras_point_box strategy to calculate the distance.

Attachments (3)

spherical_pt_box_distance_test.cpp (1.3 KB ) - added by awulkiew 8 years ago.
Isolated failing test case.
test_boost_geo2_index.cc (4.4 KB ) - added by awulkiew 8 years ago.
The R-tree test exposing the bug.
test_boost_geo2_data.h (254.9 KB ) - added by awulkiew 8 years ago.
The file containing data required by the R-tree test. The original ~30k named Points trimmed to fit the trac requirements.

Download all attachments as: .zip

Change History (5)

by awulkiew, 8 years ago

Isolated failing test case.

by awulkiew, 8 years ago

Attachment: test_boost_geo2_index.cc added

The R-tree test exposing the bug.

by awulkiew, 8 years ago

Attachment: test_boost_geo2_data.h added

The file containing data required by the R-tree test. The original ~30k named Points trimmed to fit the trac requirements.

comment:1 by awulkiew, 8 years ago

Description: modified (diff)

comment:2 by awulkiew, 8 years ago

Milestone: To Be DeterminedBoost 1.57.0
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.