Opened 10 years ago

Closed 10 years ago

#7030 closed Bugs (fixed)

distance of point to linestring with cs::spherical_equatorial gives wrong result

Reported by: anonymous Owned by: Barend Gehrels
Milestone: Boost 1.51.0 Component: geometry
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

The following code produces some strange results:

typedef cs::spherical_equatorial< boost::geometry::degree > cs_type; typedef model::point< double , 2, cs_type > point_type; typedef model::linestring< point_type > linestring_type;

point_type p( 1.0 , 1.0 ); linestring_type l; l.push_back( point_type( 0.0 , 2.0 ) ); l.push_back( point_type( 2.0 , 2.0 ) ); l.push_back( point_type( 4.0 , 2.0 ) );

cout << "Distance : " << boost::geometry::distance( p , l ) << endl;

for( size_t i=1 ; i<l.size() ; ++i ) {

linestring_type l_tmp; l_tmp.push_back( l[i-1] ); l_tmp.push_back( l[i] ); cout << "Point distance : " << boost::geometry::distance( p , l_tmp

) << endl; }

The output is

Distance : 0.0174373

Point distance : 0.0174586 Point distance : 0.0174373

The distance to the second segment can not be smaller than that to the first one. If the the coordinate system is changed to cartesian coordinates everything works as expected.

Attachments (1)

geom_distance.patch (2.4 KB ) - added by anonymous 10 years ago.

Download all attachments as: .zip

Change History (3)

by anonymous, 10 years ago

Attachment: geom_distance.patch added

comment:1 by anonymous, 10 years ago

Patch added!

comment:2 by Barend Gehrels, 10 years ago

Milestone: To Be DeterminedBoost 1.51.0
Resolution: fixed
Status: newclosed

Thanks for your patch (second one, sent off-list). It is applied.

Note: See TracTickets for help on using tickets.