Returns shortest distance from the |pivot| to the |rect|. NOTE* calculations below are incorrect, because shortest distance on the Mercator's plane is not the same as shortest distance on the Earth. But we assume that it is not an issue here.
| 283 | // on the Mercator's plane is not the same as shortest distance on the |
| 284 | // Earth. But we assume that it is not an issue here. |
| 285 | double GetDistanceMeters(m2::PointD const & pivot, m2::RectD const & rect) |
| 286 | { |
| 287 | if (rect.IsPointInside(pivot)) |
| 288 | return 0.0; |
| 289 | |
| 290 | double distance = numeric_limits<double>::max(); |
| 291 | |
| 292 | rect.ForEachSide([&](m2::PointD const & a, m2::PointD const & b) |
| 293 | { |
| 294 | m2::ParametrizedSegment<m2::PointD> segment(a, b); |
| 295 | distance = min(distance, mercator::DistanceOnEarth(pivot, segment.ClosestPointTo(pivot))); |
| 296 | }); |
| 297 | |
| 298 | return distance; |
| 299 | } |
| 300 | |
| 301 | unique_ptr<MwmContext> GetWorldContext(DataSource const & dataSource) |
| 302 | { |
no test coverage detected