Bridges-C++  3.2.0
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 
56  }
57 
64  OSMVertex (OSMVertexID vid, double latit, double longit)
65  : id(vid), latitude(latit), longitude(longit) {
66 
67  toCartesianCoords ();
68  }
69 
70 
75  OSMVertex(const OSMVertex *vert)
76  : id(vert->id), latitude(vert->latitude), longitude(vert->longitude) {
77  }
78 
84  double getLatitude() const {
85  return latitude;
86  }
92  void setLatitude(double latit) {
93  latitude = latit;
94  toCartesianCoords();
95  }
101  double getLongitude() const {
102  return longitude;
103  }
109  void setLongitude(double longit) {
110  this->longitude = longit;
111  toCartesianCoords();
112  }
113 
119  void getCartesianCoords(double *coords) const {
120  coords[0] = cartesian_coords[0];
121  coords[1] = cartesian_coords[1];
122  }
127  void setVertexID(OSMVertexID vid) {
128  this->id = vid;
129  }
134  OSMVertexID getVertexID() const {
135  return this->id;
136  }
137  };
138  }
139 } // namespace bridges
140 
141 #endif
void setLongitude(double longit)
Definition: OSMVertex.h:109
double getLatitude() const
Definition: OSMVertex.h:84
OSMVertex(OSMVertexID vid, double latit, double longit)
Definition: OSMVertex.h:64
#define M_PI
Definition: OSMVertex.h:11
void setVertexID(OSMVertexID vid)
Definition: OSMVertex.h:127
STL namespace.
long OSMVertexID
Definition: OSMVertex.h:30
void setLatitude(double latit)
Definition: OSMVertex.h:92
OSMVertex()
Definition: OSMVertex.h:55
double getLongitude() const
Definition: OSMVertex.h:101
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:75
OSMVertexID getVertexID() const
Definition: OSMVertex.h:134
void getCartesianCoords(double *coords) const
Definition: OSMVertex.h:119
Class that hold Open Street Map vertices.
Definition: OSMVertex.h:28