Bridges-C++  3.4.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 {
34  class OSMVertex {
35  public:
36  typedef long OSMVertexID;
37 
38  private:
39  OSMVertexID id;
40  double latitude = 0.0; // latitude
41  double longitude = 0.0; // longitude
42 
43  double cartesian_coords[2] = {0.0, 0.0};
48  void toCartesianCoords() {
49  const double R = 6378.; // Radius of the earth in km
50  double lat_rad = latitude * M_PI / 180.;
51  double longit_rad = longitude * M_PI / 180.;
52  cartesian_coords[0] = R * cos(lat_rad) * cos (longit_rad);
53  cartesian_coords[1] = R * cos(lat_rad) * sin (longit_rad);
54  }
55 
56  public:
57 
62  }
63 
70  OSMVertex (OSMVertexID vid, double latit, double longit)
71  : id(vid), latitude(latit), longitude(longit) {
72 
73  toCartesianCoords ();
74  }
75 
76 
81  OSMVertex(const OSMVertex *vert)
82  : id(vert->id), latitude(vert->latitude), longitude(vert->longitude) {
83  }
84 
90  double getLatitude() const {
91  return latitude;
92  }
98  void setLatitude(double latit) {
99  latitude = latit;
100  toCartesianCoords();
101  }
107  double getLongitude() const {
108  return longitude;
109  }
115  void setLongitude(double longit) {
116  this->longitude = longit;
117  toCartesianCoords();
118  }
119 
125  void getCartesianCoords(double *coords) const {
126  coords[0] = cartesian_coords[0];
127  coords[1] = cartesian_coords[1];
128  }
134  this->id = vid;
135  }
141  return this->id;
142  }
143  };
144  }
145 } // namespace bridges
146 
147 #endif
void setLongitude(double longit)
Definition: OSMVertex.h:115
double getLatitude() const
Definition: OSMVertex.h:90
OSMVertex(OSMVertexID vid, double latit, double longit)
Definition: OSMVertex.h:70
#define M_PI
Definition: OSMVertex.h:11
void setVertexID(OSMVertexID vid)
Definition: OSMVertex.h:133
long OSMVertexID
Definition: OSMVertex.h:36
void setLatitude(double latit)
Definition: OSMVertex.h:98
OSMVertex()
Definition: OSMVertex.h:61
double getLongitude() const
Definition: OSMVertex.h:107
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:81
OSMVertexID getVertexID() const
Definition: OSMVertex.h:140
void getCartesianCoords(double *coords) const
Definition: OSMVertex.h:125
Class that hold Open Street Map vertices.
Definition: OSMVertex.h:34