Ditch rint
Removes all usages of rint from the codebase, in favor of the standard rounding and casting formula used throughout the codebase: static_cast<int>(std::floor(<val> + .5)) Fixes #2392
This commit is contained in:
parent
46478d4b5a
commit
918e1a3a90
3 changed files with 5 additions and 13 deletions
|
@ -111,12 +111,6 @@ inline void read_double_xdr(const char* data, double & val)
|
|||
}
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||
// msvc doesn't have rint in <cmath>
|
||||
inline int rint(double val)
|
||||
{
|
||||
return int(std::floor(val + 0.5));
|
||||
}
|
||||
|
||||
inline double round(double val)
|
||||
{
|
||||
return std::floor(val);
|
||||
|
@ -125,6 +119,4 @@ inline double round(double val)
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // MAPNIK_GLOBAL_HPP
|
||||
|
|
|
@ -194,10 +194,10 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
|
|||
}
|
||||
|
||||
//select minimum raster containing whole box
|
||||
int x_off = rint(box.minx() - margin_x);
|
||||
int y_off = rint(box.miny() - margin_y);
|
||||
int end_x = rint(box.maxx() + margin_x);
|
||||
int end_y = rint(box.maxy() + margin_y);
|
||||
int x_off = static_cast<int>(std::floor((box.minx() - margin_x) + .5));
|
||||
int y_off = static_cast<int>(std::floor((box.miny() - margin_y) + .5));
|
||||
int end_x = static_cast<int>(std::floor((box.maxx() + margin_x) + .5));
|
||||
int end_y = static_cast<int>(std::floor((box.maxy() + margin_y) + .5));
|
||||
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: x_off=" << x_off;
|
||||
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: y_off=" << y_off;
|
||||
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: end_x=" << end_x;
|
||||
|
|
|
@ -611,7 +611,7 @@ struct convert<value_integer>
|
|||
|
||||
value_integer operator()(value_double val) const
|
||||
{
|
||||
return static_cast<value_integer>(rint(val));
|
||||
return static_cast<value_integer>(std::floor(val) + .5);
|
||||
}
|
||||
|
||||
value_integer operator()(value_bool val) const
|
||||
|
|
Loading…
Reference in a new issue