-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDistance.cpp
38 lines (31 loc) · 1011 Bytes
/
Distance.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include "Distance.h"
using namespace GeographicLib;
double Distance::calculateDistance(const Point& point1, const Point& point2)
{
return distance;
}
double GreatCircleDistance::calculateDistance(const Point& point1,const Point& point2)
{
double lat2 = point2.getCoordinate1();
double lon2 = point2.getCoordinate2();
//cout << "The value of lat is " << lat2 << endl;
//cout << "The value of lon is " << lon2 << endl;
double lat1 = point1.getCoordinate1();
double lon1 = point1.getCoordinate2();
//cout << "The value of lat is " << lat1 << endl;
//cout << "The value of lon is " << lon1 << endl;
geod.Inverse(lat1,lon1,lat2,lon2,distance);
if (!(distance >= 0))
throw GeographicErr("distance does not satisfy d >= 0");
distance = deg2km(distance);
//cout << "The value of distance is " << distance << endl;
return distance;
}
double GreatCircleDistance::deg2km(double d)
{
double Re = 6371.;
double km;
km = (d * M_PI * Re)/180.;
return km;
}