Question: in c++ please. I need help implementing these functions. -typedef std::vector Coordinate; -Target point is (42.186144,-122.741260) Haversine Distance double Haversine(Coordinate a, Coordinate b){ //use the
in c++ please. I need help implementing these functions.
-typedef std::vector
-Target point is (42.186144,-122.741260)
Haversine Distance
double Haversine(Coordinate a, Coordinate b){
//use the haversine equation to calculate the distance between the target point(Coordinate a) and the rest of the points in the vector.
return distance}
SortByDistanceTo function
//sort a vector of Coordinate elements using selection sort by their distance from the target point //call Haversine function
//return a Coordinate with the closest point to the target.
Main function
write a loop that reads comma-delimited lines from standard input one line at a time and constructs a vector of coordinates.
Sort this vector of coordinates using the SortByDistanceTo function.
Print out the coordinate that is closest to the target point
Some of the input:
up until the first comma is not important, only need to make the pair vector out of the 2nd two points.
1016,42.159304,-122.656732
1017,42.174677,-122.726037
1018,42.181263,-122.666919
1019,42.171509,-122.657704
98,42.209400,-122.672342
99,42.186020,-122.719535
100,42.205174,-122.654785
101,42.212266,-122.657698
102,42.166009,-122.741935
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
