Bridges-C++ 3.5.0-dev2-1-ge3e57bf
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
14using namespace std;
15
16namespace bridges {
17 namespace dataset {
33 class OSMVertex {
34 public:
35 typedef long OSMVertexID;
36
37 private:
38 OSMVertexID id;
39 double latitude = 0.0; // latitude
40 double longitude = 0.0; // longitude
41
42 double cartesian_coords[2] = {0.0, 0.0};
47 void toCartesianCoords() {
48 const double R = 6378.; // Radius of the earth in km
49 double lat_rad = latitude * M_PI / 180.;
50 double longit_rad = longitude * M_PI / 180.;
51 cartesian_coords[0] = R * cos(lat_rad) * cos (longit_rad);
52 cartesian_coords[1] = R * cos(lat_rad) * sin (longit_rad);
53 }
54
55 public:
56
61 }
62
69 OSMVertex (OSMVertexID vid, double latit, double longit)
70 : id(vid), latitude(latit), longitude(longit) {
71
72 toCartesianCoords ();
73 }
74
79 OSMVertex(const OSMVertex *vert)
80 : id(vert->id), latitude(vert->latitude), longitude(vert->longitude) {
81 }
82
88 double getLatitude() const {
89 return latitude;
90 }
96 void setLatitude(double latit) {
97 latitude = latit;
98 toCartesianCoords();
99 }
105 double getLongitude() const {
106 return longitude;
107 }
113 void setLongitude(double longit) {
114 this->longitude = longit;
115 toCartesianCoords();
116 }
117
123 void getCartesianCoords(double *coords) const {
124 coords[0] = cartesian_coords[0];
125 coords[1] = cartesian_coords[1];
126 }
132 this->id = vid;
133 }
139 return this->id;
140 }
141 };
142 }
143} // namespace bridges
144
145#endif
#define M_PI
Definition: OSMVertex.h:11
Class that hold Open Street Map vertices.
Definition: OSMVertex.h:33
void getCartesianCoords(double *coords) const
Definition: OSMVertex.h:123
OSMVertex(const OSMVertex *vert)
Definition: OSMVertex.h:79
double getLatitude() const
Definition: OSMVertex.h:88
void setLongitude(double longit)
Definition: OSMVertex.h:113
OSMVertexID getVertexID() const
Definition: OSMVertex.h:138
double getLongitude() const
Definition: OSMVertex.h:105
OSMVertex(OSMVertexID vid, double latit, double longit)
Definition: OSMVertex.h:69
OSMVertex()
Definition: OSMVertex.h:60
long OSMVertexID
Definition: OSMVertex.h:35
void setVertexID(OSMVertexID vid)
Definition: OSMVertex.h:131
void setLatitude(double latit)
Definition: OSMVertex.h:96
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4