#include #include #include "CPstring.h" #include "list.h" #include "place.h" #include "distance.h" static double DegToRad(double deg) // pre: deg = degrees measure // post: returns # radians = deg { return deg * 3.14159/180; } double Distance::ComputeDistance (double lat1, double long1, double lat2, double long2) // postcondition: returns miles between a (lat1, long1) // and b (lat2, long2). // (a/b are latitude/longitude) { const double RADIUS = 6366*0.62; // Earth's radius in miles const double UNITS_TO_DEGREES = 1000000.; // transform from database units to degrees long1 /= UNITS_TO_DEGREES; lat1 /= UNITS_TO_DEGREES; long2 /= UNITS_TO_DEGREES; lat2 /= UNITS_TO_DEGREES; return RADIUS * acos(sin(DegToRad(lat1)) * sin(DegToRad(lat2)) + (cos(DegToRad(lat1)) * cos(DegToRad(lat2)) * cos(DegToRad(long1-long2))) ); } Distance::Distance() // constructor { // nothing to construct, no private data } Distance::~Distance() { // Do Nothing } void Distance::Function(string & name, List &list) { // please implement me } void Distance::Report() { cout << "nothing to report from class Distance" << endl; }