From e16567fecb3fd11960697663a955e5cf82225110 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 17 Jan 2013 13:53:48 -0800 Subject: [PATCH] fixup std:: prefixing of cmath functions - closes #1694 --- include/mapnik/geom_util.hpp | 2 +- include/mapnik/global.hpp | 8 +++--- include/mapnik/image_filter.hpp | 2 ++ include/mapnik/offset_converter.hpp | 31 ++++++++++++---------- include/mapnik/simplify_converter.hpp | 7 ++--- include/mapnik/stroke.hpp | 4 +-- include/mapnik/svg/svg_path_adapter.hpp | 4 +-- include/mapnik/svg/svg_renderer_agg.hpp | 4 +-- plugins/input/gdal/gdal_featureset.cpp | 7 +++-- plugins/input/raster/raster_featureset.cpp | 8 +++--- src/agg/process_line_symbolizer.cpp | 9 ++++--- src/agg/process_raster_symbolizer.cpp | 4 +-- src/cairo_context.cpp | 8 +++--- src/cairo_renderer.cpp | 10 +++---- src/distance.cpp | 14 +++------- src/font_engine_freetype.cpp | 8 +++--- src/grid/process_line_symbolizer.cpp | 6 ++--- src/load_map.cpp | 4 +-- src/placement_finder.cpp | 7 ++--- src/proj_transform.cpp | 2 +- src/raster_colorizer.cpp | 3 ++- src/warp.cpp | 4 +-- 22 files changed, 79 insertions(+), 77 deletions(-) diff --git a/include/mapnik/geom_util.hpp b/include/mapnik/geom_util.hpp index 2ec355a5c..94d1b746f 100644 --- a/include/mapnik/geom_util.hpp +++ b/include/mapnik/geom_util.hpp @@ -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; } diff --git a/include/mapnik/global.hpp b/include/mapnik/global.hpp index 6e43d0a8d..22efed271 100644 --- a/include/mapnik/global.hpp +++ b/include/mapnik/global.hpp @@ -155,14 +155,14 @@ inline void read_double_xdr(const char* data, double & val) #ifdef _WINDOWS // msvc doesn't have rint in -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 diff --git a/include/mapnik/image_filter.hpp b/include/mapnik/image_filter.hpp index b8936a198..d2fabc9f2 100644 --- a/include/mapnik/image_filter.hpp +++ b/include/mapnik/image_filter.hpp @@ -39,6 +39,8 @@ #include "agg_scanline_u.h" #include "agg_blur.h" +// stl +#include // 8-bit YUV //Y = ( ( 66 * R + 129 * G + 25 * B + 128) >> 8) + 16 diff --git a/include/mapnik/offset_converter.hpp b/include/mapnik/offset_converter.hpp index 1fb0dd82d..3c2659280 100644 --- a/include/mapnik/offset_converter.hpp +++ b/include/mapnik/offset_converter.hpp @@ -34,6 +34,9 @@ // boost #include +// stl +#include + 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 { diff --git a/include/mapnik/simplify_converter.hpp b/include/mapnik/simplify_converter.hpp index 4eea9d87c..8aab345cc 100644 --- a/include/mapnik/simplify_converter.hpp +++ b/include/mapnik/simplify_converter.hpp @@ -12,6 +12,7 @@ #include #include #include +#include // Boost #include @@ -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; diff --git a/include/mapnik/stroke.hpp b/include/mapnik/stroke.hpp index 10e453d46..31c4ab22e 100644 --- a/include/mapnik/stroke.hpp +++ b/include/mapnik/stroke.hpp @@ -34,9 +34,7 @@ namespace mapnik { -using std::pair; -using std::vector; -typedef vector > dash_array; +typedef std::vector > dash_array; // if you add new tokens, don't forget to add them to the corresponding // string array in the cpp file. diff --git a/include/mapnik/svg/svg_path_adapter.hpp b/include/mapnik/svg/svg_path_adapter.hpp index 57f38aafd..04f24c1a1 100644 --- a/include/mapnik/svg/svg_path_adapter.hpp +++ b/include/mapnik/svg/svg_path_adapter.hpp @@ -369,8 +369,8 @@ void path_adapter::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 //------------------------- diff --git a/include/mapnik/svg/svg_renderer_agg.hpp b/include/mapnik/svg/svg_renderer_agg.hpp index c55f01254..5d0032e9b 100644 --- a/include/mapnik/svg/svg_renderer_agg.hpp +++ b/include/mapnik/svg/svg_renderer_agg.hpp @@ -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); } diff --git a/plugins/input/gdal/gdal_featureset.cpp b/plugins/input/gdal/gdal_featureset.cpp index 3e04e5eb1..780c6ee90 100644 --- a/plugins/input/gdal/gdal_featureset.cpp +++ b/plugins/input/gdal/gdal_featureset.cpp @@ -33,6 +33,9 @@ #include #include +// stl +#include + #include "gdal_featureset.hpp" #include @@ -137,8 +140,8 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q) box2d 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; diff --git a/plugins/input/raster/raster_featureset.cpp b/plugins/input/raster/raster_featureset.cpp index a9460ed62..729052df5 100644 --- a/plugins/input/raster/raster_featureset.cpp +++ b/plugins/input/raster/raster_featureset.cpp @@ -89,10 +89,10 @@ feature_ptr raster_featureset::next() if (ext.width() > 0.5 && ext.height() > 0.5 ) { // select minimum raster containing whole ext - int x_off = static_cast(floor(ext.minx())); - int y_off = static_cast(floor(ext.miny())); - int end_x = static_cast(ceil(ext.maxx())); - int end_y = static_cast(ceil(ext.maxy())); + int x_off = static_cast(std::floor(ext.minx())); + int y_off = static_cast(std::floor(ext.miny())); + int end_x = static_cast(std::ceil(ext.maxx())); + int end_y = static_cast(std::ceil(ext.maxy())); // clip to available data if (x_off < 0) diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index eecb37224..8138ff098 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -48,6 +48,7 @@ // stl #include +#include namespace mapnik { @@ -93,8 +94,8 @@ void agg_renderer::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 inverse(x0 + padding, y0 + padding, x1 - padding , y1 - padding); @@ -116,7 +117,7 @@ void agg_renderer::process(line_symbolizer const& sym, converter(clipping_extent,ras,sym,t_,prj_trans,tr,scale_factor_); if (sym.clip()) converter.set(); // optional clip (default: true) converter.set(); // always transform - if (fabs(sym.offset()) > 0.0) converter.set(); // parallel offset + if (std::fabs(sym.offset()) > 0.0) converter.set(); // parallel offset converter.set(); // optional affine transform if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter @@ -137,7 +138,7 @@ void agg_renderer::process(line_symbolizer const& sym, if (sym.clip()) converter.set(); // optional clip (default: true) converter.set(); // always transform - if (fabs(sym.offset()) > 0.0) converter.set(); // parallel offset + if (std::fabs(sym.offset()) > 0.0) converter.set(); // parallel offset converter.set(); // optional affine transform if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter diff --git a/src/agg/process_raster_symbolizer.cpp b/src/agg/process_raster_symbolizer.cpp index 58cbcc591..7da8bbdef 100644 --- a/src/agg/process_raster_symbolizer.cpp +++ b/src/agg/process_raster_symbolizer.cpp @@ -65,8 +65,8 @@ void agg_renderer::process(raster_symbolizer const& sym, box2d ext = t_.forward(target_ext); int start_x = static_cast(ext.minx()); int start_y = static_cast(ext.miny()); - int end_x = static_cast(ceil(ext.maxx())); - int end_y = static_cast(ceil(ext.maxy())); + int end_x = static_cast(std::ceil(ext.maxx())); + int end_y = static_cast(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) diff --git a/src/cairo_context.cpp b/src/cairo_context.cpp index f6acc7276..d2a3a9271 100644 --- a/src/cairo_context.cpp +++ b/src/cairo_context.cpp @@ -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; diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index eeccef970..1381d3c50 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -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, cairo_context, line_symbolizer, @@ -414,7 +414,7 @@ void cairo_renderer_base::process(line_symbolizer const& sym, if (sym.clip()) converter.set(); // optional clip (default: true) converter.set(); // always transform - if (fabs(sym.offset()) > 0.0) converter.set(); // parallel offset + if (std::fabs(sym.offset()) > 0.0) converter.set(); // parallel offset converter.set(); // optional affine transform if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter @@ -819,8 +819,8 @@ void cairo_renderer_base::process(raster_symbolizer const& sym, box2d ext = t_.forward(target_ext); int start_x = static_cast(ext.minx()); int start_y = static_cast(ext.miny()); - int end_x = static_cast(ceil(ext.maxx())); - int end_y = static_cast(ceil(ext.maxy())); + int end_x = static_cast(std::ceil(ext.maxx())); + int end_y = static_cast(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) diff --git a/src/distance.cpp b/src/distance.cpp index 34be8dd6c..8c24fda20 100644 --- a/src/distance.cpp +++ b/src/distance.cpp @@ -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; } } diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 6def8cba7..1c0f686ac 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -374,10 +374,10 @@ box2d text_renderer::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); diff --git a/src/grid/process_line_symbolizer.cpp b/src/grid/process_line_symbolizer.cpp index 4639ee8be..88fa3d13a 100644 --- a/src/grid/process_line_symbolizer.cpp +++ b/src/grid/process_line_symbolizer.cpp @@ -78,8 +78,8 @@ void grid_renderer::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::process(line_symbolizer const& sym, converter(clipping_extent,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_); if (sym.clip()) converter.set(); // optional clip (default: true) converter.set(); // always transform - if (fabs(sym.offset()) > 0.0) converter.set(); // parallel offset + if (std::fabs(sym.offset()) > 0.0) converter.set(); // parallel offset converter.set(); // optional affine transform if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter diff --git a/src/load_map.cpp b/src/load_map.cpp index 2a6f37cd7..85b949c62 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -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(name, fontset)); + fontsets_.insert(std::pair(name, fontset)); } catch (const config_error & ex) { diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index 1dc5ca877..3f7ac239e 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -41,6 +41,7 @@ //stl #include #include +#include #ifndef M_PI #define M_PI 3.14159265358979323846 @@ -661,8 +662,8 @@ void placement_finder::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 placement_finder::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(NULL); diff --git a/src/proj_transform.cpp b/src/proj_transform.cpp index b604fa094..2ac711a18 100644 --- a/src/proj_transform.cpp +++ b/src/proj_transform.cpp @@ -226,7 +226,7 @@ void envelope_points(std::vector< coord > & coords, box2d& env if (points <= 4) { steps = 0; } else { - steps = static_cast(ceil((points - 4) / 4.0)); + steps = static_cast(std::ceil((points - 4) / 4.0)); } steps += 1; diff --git a/src/raster_colorizer.cpp b/src/raster_colorizer.cpp index 036387c20..25cacf679 100644 --- a/src/raster_colorizer.cpp +++ b/src/raster_colorizer.cpp @@ -30,6 +30,7 @@ // stl #include +#include 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; } diff --git a/src/warp.cpp b/src/warp.cpp index 4fa185d94..178e66ec9 100644 --- a/src/warp.cpp +++ b/src/warp.cpp @@ -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 xs(mesh_nx, mesh_ny); ImageData ys(mesh_nx, mesh_ny);