SearchPointVector::const_iterator SearchPointVector::NearestIndexConvex(const FlatGeoPoint &p3) const { unsigned distance_min = 0 - 1; const_iterator i_best = end(); // find nearest point in vector for (auto i = begin(); i != end(); ++i) { unsigned d_this = p3.DistanceSquared(i->GetFlatLocation()); if (d_this < distance_min) { distance_min = d_this; i_best = i; } } return i_best; }
gcc_pure static FlatGeoPoint NearestPointNonConvex(const SearchPointVector& spv, const FlatGeoPoint &p3) { unsigned distance_min = 0-1; FlatGeoPoint point_best; for (auto i = spv.begin(); i!= spv.end(); ++i) { FlatGeoPoint pa = SegmentNearestPoint(spv,i,p3); unsigned d_this = p3.DistanceSquared(pa); if (d_this<distance_min) { distance_min = d_this; point_best = pa; } } return point_best; }
/** * Calculate the "flat" square distance. This is cheaper than * flat_distance(), because it does not need to calculate the square * root. */ gcc_pure unsigned FlatSquareDistanceTo(const SearchPoint& sp) const { return flat_location.DistanceSquared(sp.flat_location); }