Skip to content

Commit 7f32c65

Browse files
committed
[build] Use pi constant from boost, switch back to -std=c++0x
1 parent e6a94ea commit 7f32c65

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ENDIF(EXISTS "${PROJECT_SOURCE_DIR}/gmock" AND IS_DIRECTORY "${PROJECT_SOURCE_DI
6464

6565
include_directories(include ${Boost_INCLUDE_DIRS} ${LOG4CPP_INCLUDE_DIRS} ${SigC++_INCLUDE_DIRS} ${Freetype_INCLUDE_DIRS} ${Cairomm_INCLUDE_DIRS})
6666

67-
ADD_DEFINITIONS("-std=gnu++0x") # gnu is required for e.g. M_PI to be defined
67+
ADD_DEFINITIONS("-std=c++0x")
6868
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
6969
ADD_DEFINITIONS(${LOG4CPP_DEFINITIONS})
7070
ADD_DEFINITIONS(-DStatistic_Activated)

src/server/renderer/node_renderer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*/
3131

3232
#include <boost/unordered_map.hpp>
33+
#include <boost/math/constants/constants.hpp>
3334

3435
#include "general/geodata.hpp"
3536
#include "general/node.hpp"
@@ -62,7 +63,7 @@ void NodeRenderer::casing(const Cairo::RefPtr<Cairo::Context>& cr)
6263

6364
cr->save();
6465

65-
cr->arc(location.x, location.y, s->width/2.0 + s->casing_width, 0, 2*M_PI);
66+
cr->arc(location.x, location.y, s->width/2.0 + s->casing_width, 0, 2*boost::math::constants::pi<double>());
6667

6768
cr->set_source_color(s->casing_color);
6869

@@ -78,7 +79,7 @@ void NodeRenderer::stroke(const Cairo::RefPtr<Cairo::Context>& cr)
7879

7980
cr->save();
8081

81-
cr->arc(location.x, location.y, s->width/2.0, 0, 2*M_PI);
82+
cr->arc(location.x, location.y, s->width/2.0, 0, 2*boost::math::constants::pi<double>());
8283

8384
cr->set_source_color(s->color);
8485

src/server/renderer/renderer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
*/
3131
#include "config.hpp"
3232
#include <boost/unordered_map.hpp>
33+
#include <boost/math/constants/constants.hpp>
3334
#include <sigc++/bind.h>
3435

3536
#include "utils/transform.hpp"
@@ -431,9 +432,9 @@ void Renderer::renderShields(const Cairo::RefPtr<Cairo::Context>& cr,
431432
}
432433
if (s->shield_shape == Style::ShieldShape::ROUNDED) {
433434
cr->arc(x0 + height/2.0, y0 + height/2.0,
434-
height/2.0, M_PI/2.0, 3.0*M_PI/2.0);
435+
height/2.0, boost::math::constants::pi<double>()/2.0, 3.0*boost::math::constants::pi<double>()/2.0);
435436
cr->arc(x0 + width - height/2.0, y0 + height/2.0,
436-
height/2.0, 3.0*M_PI/2.0, M_PI/2.0);
437+
height/2.0, 3.0*boost::math::constants::pi<double>()/2.0, boost::math::constants::pi<double>()/2.0);
437438
cr->close_path();
438439
} else
439440
cr->rectangle(x0, y0, width, height);

src/server/renderer/way_renderer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222

2323
#include <boost/unordered_map.hpp>
24+
#include <boost/math/constants/constants.hpp>
2425

2526
#include "general/geodata.hpp"
2627
#include "general/way.hpp"
@@ -83,7 +84,7 @@ bool WayRenderer::getTextPosition(Cairo::Path* transformedPath, int width, Float
8384
if (abs(dx) > 0)
8485
angle = atan(dy/dx);
8586
else
86-
angle = -M_PI/2.0;
87+
angle = -boost::math::constants::pi<double>()/2.0;
8788
best.x = current.point.x - dx * 0.5;
8889
best.y = current.point.y - dy * 0.5;
8990
bestDiff = diff;

src/utils/transform.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* =====================================================================================
3030
*/
3131

32+
#include <boost/math/constants/constants.hpp>
3233
#include <cmath>
3334

3435
#include "settings.hpp"
@@ -85,10 +86,10 @@ void mercatorToTile(coord_t x, coord_t y, int zoom, int& tx, int& ty)
8586
*/
8687
void projectMercator(const FloatPoint& p, coord_t& x, coord_t& y)
8788
{
88-
double lon = p.lon / 180.0 * M_PI;
89-
double lat = p.lat / 180.0 * M_PI;
90-
x = lon / M_PI * NORM;
91-
y = log(tan(M_PI / 4.0 + lat / 2.0)) / M_PI * NORM;
89+
double lon = p.lon / 180.0 * boost::math::constants::pi<double>();
90+
double lat = p.lat / 180.0 * boost::math::constants::pi<double>();
91+
x = lon / boost::math::constants::pi<double>() * NORM;
92+
y = log(tan(boost::math::constants::pi<double>() / 4.0 + lat / 2.0)) / boost::math::constants::pi<double>() * NORM;
9293
}
9394

9495
/**
@@ -101,6 +102,6 @@ void projectMercator(const FloatPoint& p, coord_t& x, coord_t& y)
101102
void inverseMercator(const FixedPoint& p, double& lat, double& lon)
102103
{
103104
lon = p.x / NORM * 180.0;
104-
lat = atan(sinh(p.y / NORM * M_PI)) / M_PI * 180.0;
105+
lat = atan(sinh(p.y / NORM * boost::math::constants::pi<double>())) / boost::math::constants::pi<double>() * 180.0;
105106
}
106107

0 commit comments

Comments
 (0)