fixup std:: prefixing of cmath functions - closes #1694

This commit is contained in:
Dane Springmeyer 2013-01-17 13:53:48 -08:00
parent f483e590d8
commit e16567fecb
22 changed files with 79 additions and 77 deletions

View file

@ -439,7 +439,7 @@ bool hit_test(PathType & path, double x, double y, double tol)
if (count == 0) // one vertex
{
return distance(x, y, x0, y0) <= fabs(tol);
return distance(x, y, x0, y0) <= std::fabs(tol);
}
return inside;
}

View file

@ -155,14 +155,14 @@ inline void read_double_xdr(const char* data, double & val)
#ifdef _WINDOWS
// msvc doesn't have rint in <cmath>
inline int rint( double val)
inline int rint(double val)
{
return int(floor(val + 0.5));
return int(std::floor(val + 0.5));
}
inline double round (double val)
inline double round(double val)
{
return floor(val);
return std::floor(val);
}
#define _USE_MATH_DEFINES

View file

@ -39,6 +39,8 @@
#include "agg_scanline_u.h"
#include "agg_blur.h"
// stl
#include <cmath>
// 8-bit YUV
//Y = ( ( 66 * R + 129 * G + 25 * B + 128) >> 8) + 16

View file

@ -34,6 +34,9 @@
// boost
#include <boost/math/constants/constants.hpp>
// stl
#include <cmath>
namespace mapnik
{
@ -213,8 +216,8 @@ private:
*/
static void displace(vertex2d & v, double dx, double dy, double a)
{
v.x += dx * cos(a) - dy * sin(a);
v.y += dx * sin(a) + dy * cos(a);
v.x += dx * std::cos(a) - dy * std::sin(a);
v.y += dx * std::sin(a) + dy * std::cos(a);
}
/**
@ -222,8 +225,8 @@ private:
*/
void displace(vertex2d & v, double a) const
{
v.x += offset_ * sin(a);
v.y -= offset_ * cos(a);
v.x += offset_ * std::sin(a);
v.y -= offset_ * std::cos(a);
}
/**
@ -231,16 +234,16 @@ private:
*/
void displace(vertex2d & v, vertex2d const& u, double a) const
{
v.x = u.x + offset_ * sin(a);
v.y = u.y - offset_ * cos(a);
v.x = u.x + offset_ * std::sin(a);
v.y = u.y - offset_ * std::cos(a);
v.cmd = u.cmd;
}
void displace2(vertex2d & v, double a, double b) const
{
double sa = offset_ * sin(a);
double ca = offset_ * cos(a);
double h = tan(0.5 * (b - a));
double sa = offset_ * std::sin(a);
double ca = offset_ * std::cos(a);
double h = std::tan(0.5 * (b - a));
v.x = v.x + sa + h * ca;
v.y = v.y - ca + h * sa;
}
@ -261,7 +264,7 @@ private:
return status_ = process;
double angle_a = 0;
double angle_b = atan2((v2.y - v1.y), (v2.x - v1.x));
double angle_b = std::atan2((v2.y - v1.y), (v2.x - v1.x));
double joint_angle;
// first vertex
@ -273,15 +276,15 @@ private:
// a fake vertex two offset-lengths before the first, and expect
// intersection detection smoothes it out.
pre_first_ = v1;
displace(pre_first_, -2 * fabs(offset_), 0, angle_b);
displace(pre_first_, -2 * std::fabs(offset_), 0, angle_b);
while ((v1 = v2, v2.cmd = geom_.vertex(&v2.x, &v2.y)) != SEG_END)
{
angle_a = angle_b;
angle_b = atan2((v2.y - v1.y), (v2.x - v1.x));
angle_b = std::atan2((v2.y - v1.y), (v2.x - v1.x));
joint_angle = explement_reflex_angle(angle_b - angle_a);
double half_turns = half_turn_segments_ * fabs(joint_angle);
double half_turns = half_turn_segments_ * std::fabs(joint_angle);
int bulge_steps = 0;
if (offset_ < 0.0)
@ -289,7 +292,7 @@ private:
if (joint_angle > 0.0)
joint_angle = joint_angle - 2 * pi;
else
bulge_steps = 1 + int(floor(half_turns / pi));
bulge_steps = 1 + int(std::floor(half_turns / pi));
}
else
{

View file

@ -12,6 +12,7 @@
#include <set>
#include <vector>
#include <deque>
#include <cmath>
// Boost
#include <boost/optional.hpp>
@ -57,9 +58,9 @@ struct sleeve
sleeve(vertex2d const& v0, vertex2d const& v1, double offset)
{
double a = atan2((v1.y - v0.y), (v1.x - v0.x));
double dx = offset * cos(a);
double dy = offset * sin(a);
double a = std::atan2((v1.y - v0.y), (v1.x - v0.x));
double dx = offset * std::cos(a);
double dy = offset * std::sin(a);
v[0].x = v0.x + dy;
v[0].y = v0.y - dx;
v[1].x = v0.x - dy;

View file

@ -34,9 +34,7 @@
namespace mapnik
{
using std::pair;
using std::vector;
typedef vector<pair<double,double> > dash_array;
typedef std::vector<std::pair<double,double> > dash_array;
// if you add new tokens, don't forget to add them to the corresponding
// string array in the cpp file.

View file

@ -369,8 +369,8 @@ void path_adapter<VC>::arc_to(double rx, double ry,
double y0 = 0.0;
vertices_.last_vertex(&x0, &y0);
rx = fabs(rx);
ry = fabs(ry);
rx = std::fabs(rx);
ry = std::fabs(ry);
// Ensure radii are valid
//-------------------------

View file

@ -278,7 +278,7 @@ public:
ras.reset();
// https://github.com/mapnik/mapnik/issues/1129
if(fabs(curved_trans_contour.width()) <= 1)
if(std::fabs(curved_trans_contour.width()) <= 1)
{
ras.add_path(curved_trans, attr.index);
}
@ -385,7 +385,7 @@ public:
{
ras.reset();
if(fabs(curved_trans_contour.width()) <= 1)
if(std::fabs(curved_trans_contour.width()) <= 1)
{
ras.add_path(curved_trans, attr.index);
}

View file

@ -33,6 +33,9 @@
#include <boost/format.hpp>
#include <boost/make_shared.hpp>
// stl
#include <cmath>
#include "gdal_featureset.hpp"
#include <gdal_priv.h>
@ -137,8 +140,8 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
box2d<double> box = t.forward(intersect);
//size of resized output pixel in source image domain
double margin_x = 1.0 / (fabs(dx_) * boost::get<0>(q.resolution()));
double margin_y = 1.0 / (fabs(dy_) * boost::get<1>(q.resolution()));
double margin_x = 1.0 / (std::fabs(dx_) * boost::get<0>(q.resolution()));
double margin_y = 1.0 / (std::fabs(dy_) * boost::get<1>(q.resolution()));
if (margin_x < 1)
{
margin_x = 1.0;

View file

@ -89,10 +89,10 @@ feature_ptr raster_featureset<LookupPolicy>::next()
if (ext.width() > 0.5 && ext.height() > 0.5 )
{
// select minimum raster containing whole ext
int x_off = static_cast<int>(floor(ext.minx()));
int y_off = static_cast<int>(floor(ext.miny()));
int end_x = static_cast<int>(ceil(ext.maxx()));
int end_y = static_cast<int>(ceil(ext.maxy()));
int x_off = static_cast<int>(std::floor(ext.minx()));
int y_off = static_cast<int>(std::floor(ext.miny()));
int end_x = static_cast<int>(std::ceil(ext.maxx()));
int end_y = static_cast<int>(std::ceil(ext.maxy()));
// clip to available data
if (x_off < 0)

View file

@ -48,6 +48,7 @@
// stl
#include <string>
#include <cmath>
namespace mapnik {
@ -93,8 +94,8 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
double half_stroke = stroke_.get_width()/2.0;
if (half_stroke > 1)
padding *= half_stroke;
if (fabs(sym.offset()) > 0)
padding *= fabs(sym.offset()) * 1.2;
if (std::fabs(sym.offset()) > 0)
padding *= std::fabs(sym.offset()) * 1.2;
clipping_extent.pad(padding);
// debugging
//box2d<double> inverse(x0 + padding, y0 + padding, x1 - padding , y1 - padding);
@ -116,7 +117,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
converter(clipping_extent,ras,sym,t_,prj_trans,tr,scale_factor_);
if (sym.clip()) converter.set<clip_line_tag>(); // optional clip (default: true)
converter.set<transform_tag>(); // always transform
if (fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
if (std::fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
converter.set<affine_transform_tag>(); // optional affine transform
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
@ -137,7 +138,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
if (sym.clip()) converter.set<clip_line_tag>(); // optional clip (default: true)
converter.set<transform_tag>(); // always transform
if (fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
if (std::fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
converter.set<affine_transform_tag>(); // optional affine transform
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter

View file

@ -65,8 +65,8 @@ void agg_renderer<T>::process(raster_symbolizer const& sym,
box2d<double> ext = t_.forward(target_ext);
int start_x = static_cast<int>(ext.minx());
int start_y = static_cast<int>(ext.miny());
int end_x = static_cast<int>(ceil(ext.maxx()));
int end_y = static_cast<int>(ceil(ext.maxy()));
int end_x = static_cast<int>(std::ceil(ext.maxx()));
int end_y = static_cast<int>(std::ceil(ext.maxy()));
int raster_width = end_x - start_x;
int raster_height = end_y - start_y;
if (raster_width > 0 && raster_height > 0)

View file

@ -428,10 +428,10 @@ void cairo_context::add_text(text_path const& path,
if (glyph)
{
cairo_matrix_t matrix;
matrix.xx = text_size * cos(angle);
matrix.xy = text_size * sin(angle);
matrix.yx = text_size * -sin(angle);
matrix.yy = text_size * cos(angle);
matrix.xx = text_size * std::cos(angle);
matrix.xy = text_size * std::sin(angle);
matrix.yx = text_size * -std::sin(angle);
matrix.yy = text_size * std::cos(angle);
matrix.x0 = 0;
matrix.y0 = 0;

View file

@ -404,8 +404,8 @@ void cairo_renderer_base::process(line_symbolizer const& sym,
double half_stroke = stroke_.get_width()/2.0;
if (half_stroke > 1)
padding *= half_stroke;
if (fabs(sym.offset()) > 0)
padding *= fabs(sym.offset()) * 1.2;
if (std::fabs(sym.offset()) > 0)
padding *= std::fabs(sym.offset()) * 1.2;
clipping_extent.pad(padding);
}
vertex_converter<box2d<double>, cairo_context, line_symbolizer,
@ -414,7 +414,7 @@ void cairo_renderer_base::process(line_symbolizer const& sym,
if (sym.clip()) converter.set<clip_line_tag>(); // optional clip (default: true)
converter.set<transform_tag>(); // always transform
if (fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
if (std::fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
converter.set<affine_transform_tag>(); // optional affine transform
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
@ -819,8 +819,8 @@ void cairo_renderer_base::process(raster_symbolizer const& sym,
box2d<double> ext = t_.forward(target_ext);
int start_x = static_cast<int>(ext.minx());
int start_y = static_cast<int>(ext.miny());
int end_x = static_cast<int>(ceil(ext.maxx()));
int end_y = static_cast<int>(ceil(ext.maxy()));
int end_x = static_cast<int>(std::ceil(ext.maxx()));
int end_y = static_cast<int>(std::ceil(ext.maxy()));
int raster_width = end_x - start_x;
int raster_height = end_y - start_y;
if (raster_width > 0 && raster_height > 0)

View file

@ -29,12 +29,6 @@
namespace mapnik {
using std::atan2;
using std::cos;
using std::pow;
using std::sin;
using std::sqrt;
static const double deg2rad = 0.0174532925199432958;
static const double R = 6372795.0; // average great-circle radius of the earth
@ -49,11 +43,11 @@ double great_circle_distance::operator() (coord2d const& pt0,
double dlat = lat1 - lat0;
double dlon = lon1 - lon0;
double sin_dlat = sin(0.5 * dlat);
double sin_dlon = sin(0.5 * dlon);
double sin_dlat = std::sin(0.5 * dlat);
double sin_dlon = std::sin(0.5 * dlon);
double a = pow(sin_dlat,2.0) + cos(lat0)*cos(lat1)*pow(sin_dlon,2.0);
double c = 2 * atan2(sqrt(a),sqrt(1 - a));
double a = std::pow(sin_dlat,2.0) + std::cos(lat0)*std::cos(lat1)*std::pow(sin_dlon,2.0);
double c = 2 * std::atan2(std::sqrt(a),std::sqrt(1 - a));
return R * c;
}
}

View file

@ -374,10 +374,10 @@ box2d<double> text_renderer<T>::prepare_glyphs(text_path const& path)
glyph_ptr glyph = faces->get_glyph(unsigned(c->c));
FT_Face face = glyph->get_face()->get_face();
matrix.xx = (FT_Fixed)( cos( angle ) * 0x10000L );
matrix.xy = (FT_Fixed)(-sin( angle ) * 0x10000L );
matrix.yx = (FT_Fixed)( sin( angle ) * 0x10000L );
matrix.yy = (FT_Fixed)( cos( angle ) * 0x10000L );
matrix.xx = (FT_Fixed)( std::cos( angle ) * 0x10000L );
matrix.xy = (FT_Fixed)(-std::sin( angle ) * 0x10000L );
matrix.yx = (FT_Fixed)( std::sin( angle ) * 0x10000L );
matrix.yy = (FT_Fixed)( std::cos( angle ) * 0x10000L );
FT_Set_Transform(face, &matrix, &pen);

View file

@ -78,8 +78,8 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
double half_stroke = stroke_.get_width()/2.0;
if (half_stroke > 1)
padding *= half_stroke;
if (fabs(sym.offset()) > 0)
padding *= fabs(sym.offset()) * 1.2;
if (std::fabs(sym.offset()) > 0)
padding *= std::fabs(sym.offset()) * 1.2;
clipping_extent.pad(padding);
}
@ -88,7 +88,7 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
converter(clipping_extent,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_);
if (sym.clip()) converter.set<clip_line_tag>(); // optional clip (default: true)
converter.set<transform_tag>(); // always transform
if (fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
if (std::fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
converter.set<affine_transform_tag>(); // optional affine transform
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter

View file

@ -66,8 +66,6 @@
using boost::tokenizer;
using std::endl;
namespace mapnik
{
using boost::optional;
@ -510,7 +508,7 @@ void map_parser::parse_fontset(Map & map, xml_node const& fset)
// XXX Hack because map object isn't accessible by text_symbolizer
// when it's parsed
fontsets_.insert(pair<std::string, font_set>(name, fontset));
fontsets_.insert(std::pair<std::string, font_set>(name, fontset));
}
catch (const config_error & ex)
{

View file

@ -41,6 +41,7 @@
//stl
#include <string>
#include <vector>
#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
@ -661,8 +662,8 @@ void placement_finder<DetectorT>::find_line_placements(PathT & shape_path)
anglesum += angle;
}
anglesum /= current_placement->nodes_.size(); //Now it is angle average
double cosa = orientation * cos(anglesum);
double sina = orientation * sin(anglesum);
double cosa = orientation * std::cos(anglesum);
double sina = orientation * std::sin(anglesum);
//Offset all the characters by this angle
for (unsigned i = 0; i < current_placement->nodes_.size(); i++)
@ -839,7 +840,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
while (angle_delta < -M_PI)
angle_delta += 2*M_PI;
if (p.max_char_angle_delta > 0 &&
fabs(angle_delta) > p.max_char_angle_delta)
std::fabs(angle_delta) > p.max_char_angle_delta)
{
//MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Too Bendy!";
return std::auto_ptr<text_path>(NULL);

View file

@ -226,7 +226,7 @@ void envelope_points(std::vector< coord<double,2> > & coords, box2d<double>& env
if (points <= 4) {
steps = 0;
} else {
steps = static_cast<int>(ceil((points - 4) / 4.0));
steps = static_cast<int>(std::ceil((points - 4) / 4.0));
}
steps += 1;

View file

@ -30,6 +30,7 @@
// stl
#include <limits>
#include <cmath>
namespace mapnik
{
@ -258,7 +259,7 @@ color raster_colorizer::get_color(float value) const
case COLORIZER_EXACT:
default:
//approximately equal (within epsilon)
if(fabs(value - stopValue) < epsilon_)
if(std::fabs(value - stopValue) < epsilon_)
{
outputColor = stopColor;
}

View file

@ -58,8 +58,8 @@ void reproject_and_scale_raster(raster & target, raster const& source,
CoordTransform tt(target.data_.width(), target.data_.height(),
target.ext_, offset_x, offset_y);
unsigned i, j;
unsigned mesh_nx = ceil(source.data_.width()/double(mesh_size) + 1);
unsigned mesh_ny = ceil(source.data_.height()/double(mesh_size) + 1);
unsigned mesh_nx = std::ceil(source.data_.width()/double(mesh_size) + 1);
unsigned mesh_ny = std::ceil(source.data_.height()/double(mesh_size) + 1);
ImageData<double> xs(mesh_nx, mesh_ny);
ImageData<double> ys(mesh_nx, mesh_ny);