Bridges-C++  3.1.1
Bridges(C++API)
OSMVertex.h
Go to the documentation of this file.
1 #ifndef OSM_VERTEX_H
2 
3 #define OSM_VERTEX_H
4 
5 #include <string>
6 #include <cmath>
7 #include <math.h>
8 
9 //workaround a VS2017 idiosyncracies
10 #ifndef M_PI
11 #define M_PI 3.1415926535897
12 #endif
13 
14 
15 using namespace std;
16 
17 namespace bridges {
18  namespace dataset {
28  class OSMVertex {
29  public:
30  typedef long OSMVertexID;
31 
32  private:
33  OSMVertexID id;
34  double latitude = 0.0; // latitude
35  double longitude = 0.0; // longitude
36 
37  double cartesian_coords[2] = {0.0, 0.0};
42  void toCartesianCoords() {
43  const double R = 6378.; // Radius of the earth in km
44  double lat_rad = latitude * M_PI / 180.;
45  double longit_rad = longitude * M_PI / 180.;
46  cartesian_coords[0] = R * cos(lat_rad) * cos (longit_rad);
47  cartesian_coords[1] = R * cos(lat_rad) * sin (longit_rad);
48  }
49 
50  public:
51 
53  }
54 
55  OSMVertex (OSMVertexID vid, double latit, double longit)
56  : id(vid), latitude(latit), longitude(longit) {
57 
58  toCartesianCoords ();
59  }
60 
61  OSMVertex(const OSMVertex *vert)
62  : id(vert->id), latitude(vert->latitude), longitude(vert->longitude) {
63  }
64 
70  double getLatitude() const {
71  return latitude;
72  }
78  void setLatitude(double latit) {
79  latitude = latit;
80  toCartesianCoords();
81  }
87  double getLongitude() const {
88  return longitude;
89  }
95  void setLongitude(double longit) {
96  this->longitude = longit;
97  toCartesianCoords();
98  }
99 
105  void getCartesianCoords(double *coords) const {
106  coords[0] = cartesian_coords[0];
107  coords[1] = cartesian_coords[1];
108  }
109  void setVertexID(OSMVertexID vid) {
110  this->id = vid;
111  }
112  OSMVertexID getVertexID() const {
113  return this->id;
114  }
115  };
116  }
117 } // namespace bridges
118 
119 #endif
void setLongitude(double longit)
Definition: OSMVertex.h:95
double getLatitude() const
Definition: OSMVertex.h:70
OSMVertex(OSMVertexID vid, double latit, double longit)
Definition: OSMVertex.h:55
#define M_PI
Definition: OSMVertex.h:11
void setVertexID(OSMVertexID vid)
Definition: OSMVertex.h:109
STL namespace.
long OSMVertexID
Definition: OSMVertex.h:30
void setLatitude(double latit)
Definition: OSMVertex.h:78
OSMVertex()
Definition: OSMVertex.h:52
double getLongitude() const
Definition: OSMVertex.h:87
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4
OSMVertex(const OSMVertex *vert)
Definition: OSMVertex.h:61
OSMVertexID getVertexID() const
Definition: OSMVertex.h:112
void getCartesianCoords(double *coords) const
Definition: OSMVertex.h:105
Class that hold Open Street Map vertices.
Definition: OSMVertex.h:28