BoosterSeat  0.1
A C++ library that includes common utilities that are used in other projects.
geo.hpp
Go to the documentation of this file.
1 
9 #ifndef BOOSTERSEAT_GEO_HPP_
10 #define BOOSTERSEAT_GEO_HPP_
11 
12 #include <vector>
13 
14 namespace bst {
15 namespace geo {
16 
17 inline constexpr double EARTH_RADIUS_KM = 6378.1370;
18 
22 class Point {
23 public:
24  Point();
25 
32  Point(double latitude, double longitude);
33 
34  double latitude() const {
35  return lat_;
36  }
37  double longitude() const {
38  return lon_;
39  }
40 
41  Point shootVector(double bearing, double distance_m) const;
42 
43 private:
47  double lat_;
48 
52  double lon_;
53 };
54 
62 double distance(const Point &point_a, const Point &point_b);
63 
67 class Path {
68 public:
69  Path();
70  Path(std::vector<Point> points);
71 
72  void addPoint(Point point) {
73  points_.push_back(point);
74  }
75 
76  int getNumPoints() const {
77  return points_.size();
78  }
79 
80  double distance() const;
81 
82  std::vector<Point> points() const {
83  return points_;
84  }
85 
86  bool getLastPoint(Point &point) const;
87 
88  bool getFirstPoint(Point &point) const;
89 
90 private:
91  std::vector<Point> points_;
92 };
93 
94 } // namespace geo
95 } // namespace bst
96 
97 #endif /* GEO_HPP_ */
A path of geographical points.
Definition: geo.hpp:67
void addPoint(Point point)
Definition: geo.hpp:72
bool getFirstPoint(Point &point) const
Definition: geo_point.cpp:77
std::vector< Point > points_
Definition: geo.hpp:91
Path()
Definition: geo_point.cpp:55
bool getLastPoint(Point &point) const
Definition: geo_point.cpp:69
std::vector< Point > points() const
Definition: geo.hpp:82
double distance() const
Definition: geo_point.cpp:61
int getNumPoints() const
Definition: geo.hpp:76
A geographical point.
Definition: geo.hpp:22
double latitude() const
Definition: geo.hpp:34
double lat_
Latitude in degrees decimal. North is positive, south is negative.
Definition: geo.hpp:47
Point()
Definition: geo_point.cpp:8
Point shootVector(double bearing, double distance_m) const
Definition: geo_point.cpp:23
double lon_
Longitude in degrees decimal. East is positive, west is negative.
Definition: geo.hpp:52
double longitude() const
Definition: geo.hpp:37
double distance(const Point &a, const Point &b)
Get the distance between two points in kilometers.
Definition: geo_point.cpp:42
constexpr double EARTH_RADIUS_KM
Definition: geo.hpp:17
Definition: filesystem.cpp:34