-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdist.h
More file actions
27 lines (21 loc) · 943 Bytes
/
dist.h
File metadata and controls
27 lines (21 loc) · 943 Bytes
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
#pragma once
struct Coordinates {
double lat;
double lon;
Coordinates() : Coordinates(0, 0) {}
Coordinates(double lat, double lon) : lat(lat), lon(lon) {}
bool operator==(const Coordinates &other) const {
return this->lat == other.lat && this->lon == other.lon;
}
};
// Returns the distance in miles between 2 points (lat1, long1) and
// (lat2, long2). Latitudes are positive above the equator and
// negative below; longitudes are positive heading east of Greenwich
// and negative heading west. Example: Chicago is (41.88, -87.63).
//
// NOTE: you may get slightly different results depending on which
// (lat, long) pair is passed as the first parameter.
double distBetween2Points(Coordinates p1, Coordinates p2);
// Returns the center Coordinate between (lat1, lon1) and (lat2, lon2)
// Reference: http://www.movable-type.co.uk/scripts/latlong.html
Coordinates centerBetween2Points(Coordinates p1, Coordinates p2);