Question: In c++ please. I'm struggling to implement this code. -typedef std::pair Coordinate; -Target point is (42.186144,-122.741260) Haversine Distance double Haversine(Coordinate a, Coordinate b){ //use the

In c++ please. I'm struggling to implement this code.

-typedef std::pair Coordinate;

-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 from unix input file 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. I need to read this from a UNIX input, so somehow get rid of everything up until the first comma, and then split the 2nd two into a vector .

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!