Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

In c++ please. I'm struggling to implement the second function.

-typedef std::vector > 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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

Students also viewed these Databases questions

Question

Example. Evaluate 5n+7 lim 7-00 3n-5

Answered: 1 week ago