| 120 | } |
| 121 | |
| 122 | void Track::UpdateSelectionInfo(m2::RectD const & touchRect, TrackSelectionInfo & info) const |
| 123 | { |
| 124 | if (m_interactionData && !m_interactionData->m_limitRect.IsIntersect(touchRect)) |
| 125 | return; |
| 126 | |
| 127 | for (size_t lineIndex = 0; lineIndex < m_data.m_geometry.m_lines.size(); ++lineIndex) |
| 128 | { |
| 129 | auto const & line = m_data.m_geometry.m_lines[lineIndex]; |
| 130 | for (size_t ptIndex = 0; ptIndex + 1 < line.size(); ++ptIndex) |
| 131 | { |
| 132 | auto pt1 = line[ptIndex].GetPoint(); |
| 133 | auto pt2 = line[ptIndex + 1].GetPoint(); |
| 134 | if (!m2::Intersect(touchRect, pt1, pt2)) |
| 135 | continue; |
| 136 | |
| 137 | m2::ParametrizedSegment<m2::PointD> seg(pt1, pt2); |
| 138 | auto const closestPoint = seg.ClosestPointTo(touchRect.Center()); |
| 139 | auto const squaredDist = closestPoint.SquaredLength(touchRect.Center()); |
| 140 | if (squaredDist >= info.m_squareDist) |
| 141 | continue; |
| 142 | |
| 143 | info.m_squareDist = squaredDist; |
| 144 | info.m_trackId = m_data.m_id; |
| 145 | info.m_trackPoint = closestPoint; |
| 146 | |
| 147 | auto const segDistInMeters = mercator::DistanceOnEarth(line[ptIndex].GetPoint(), closestPoint); |
| 148 | info.m_distFromBegM = segDistInMeters + GetLengthMetersImpl(lineIndex, ptIndex); |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | df::DepthLayer Track::GetDepthLayer() const |
| 154 | { |
no test coverage detected