Skip to content

Commit

Permalink
[build] Use pi constant from boost, switch back to -std=c++0x
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Apr 26, 2013
1 parent e6a94ea commit 7f32c65
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -64,7 +64,7 @@ ENDIF(EXISTS "${PROJECT_SOURCE_DIR}/gmock" AND IS_DIRECTORY "${PROJECT_SOURCE_DI

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

ADD_DEFINITIONS("-std=gnu++0x") # gnu is required for e.g. M_PI to be defined
ADD_DEFINITIONS("-std=c++0x")
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
ADD_DEFINITIONS(${LOG4CPP_DEFINITIONS})
ADD_DEFINITIONS(-DStatistic_Activated)
Expand Down
5 changes: 3 additions & 2 deletions src/server/renderer/node_renderer.cpp
Expand Up @@ -30,6 +30,7 @@
*/

#include <boost/unordered_map.hpp>
#include <boost/math/constants/constants.hpp>

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

cr->save();

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

cr->set_source_color(s->casing_color);

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

cr->save();

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

cr->set_source_color(s->color);

Expand Down
5 changes: 3 additions & 2 deletions src/server/renderer/renderer.cpp
Expand Up @@ -30,6 +30,7 @@
*/
#include "config.hpp"
#include <boost/unordered_map.hpp>
#include <boost/math/constants/constants.hpp>
#include <sigc++/bind.h>

#include "utils/transform.hpp"
Expand Down Expand Up @@ -431,9 +432,9 @@ void Renderer::renderShields(const Cairo::RefPtr<Cairo::Context>& cr,
}
if (s->shield_shape == Style::ShieldShape::ROUNDED) {
cr->arc(x0 + height/2.0, y0 + height/2.0,
height/2.0, M_PI/2.0, 3.0*M_PI/2.0);
height/2.0, boost::math::constants::pi<double>()/2.0, 3.0*boost::math::constants::pi<double>()/2.0);
cr->arc(x0 + width - height/2.0, y0 + height/2.0,
height/2.0, 3.0*M_PI/2.0, M_PI/2.0);
height/2.0, 3.0*boost::math::constants::pi<double>()/2.0, boost::math::constants::pi<double>()/2.0);
cr->close_path();
} else
cr->rectangle(x0, y0, width, height);
Expand Down
3 changes: 2 additions & 1 deletion src/server/renderer/way_renderer.cpp
Expand Up @@ -21,6 +21,7 @@


#include <boost/unordered_map.hpp>
#include <boost/math/constants/constants.hpp>

#include "general/geodata.hpp"
#include "general/way.hpp"
Expand Down Expand Up @@ -83,7 +84,7 @@ bool WayRenderer::getTextPosition(Cairo::Path* transformedPath, int width, Float
if (abs(dx) > 0)
angle = atan(dy/dx);
else
angle = -M_PI/2.0;
angle = -boost::math::constants::pi<double>()/2.0;
best.x = current.point.x - dx * 0.5;
best.y = current.point.y - dy * 0.5;
bestDiff = diff;
Expand Down
11 changes: 6 additions & 5 deletions src/utils/transform.cpp
Expand Up @@ -29,6 +29,7 @@
* =====================================================================================
*/

#include <boost/math/constants/constants.hpp>
#include <cmath>

#include "settings.hpp"
Expand Down Expand Up @@ -85,10 +86,10 @@ void mercatorToTile(coord_t x, coord_t y, int zoom, int& tx, int& ty)
*/
void projectMercator(const FloatPoint& p, coord_t& x, coord_t& y)
{
double lon = p.lon / 180.0 * M_PI;
double lat = p.lat / 180.0 * M_PI;
x = lon / M_PI * NORM;
y = log(tan(M_PI / 4.0 + lat / 2.0)) / M_PI * NORM;
double lon = p.lon / 180.0 * boost::math::constants::pi<double>();
double lat = p.lat / 180.0 * boost::math::constants::pi<double>();
x = lon / boost::math::constants::pi<double>() * NORM;
y = log(tan(boost::math::constants::pi<double>() / 4.0 + lat / 2.0)) / boost::math::constants::pi<double>() * NORM;
}

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

0 comments on commit 7f32c65

Please sign in to comment.