raster scaling: use mapnik::safe_cast, fixes clipping negative floats
This commit is contained in:
parent
9b72dd868f
commit
348067dcfd
1 changed files with 3 additions and 13 deletions
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include <limits>
|
||||
|
||||
#include <mapnik/safe_cast.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
|
@ -140,19 +142,7 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
fg /= total_weight;
|
||||
if (fg < std::numeric_limits<value_type>::min())
|
||||
{
|
||||
span->v = std::numeric_limits<value_type>::min();
|
||||
}
|
||||
else if (fg > std::numeric_limits<value_type>::max())
|
||||
{
|
||||
span->v = std::numeric_limits<value_type>::max();
|
||||
}
|
||||
else
|
||||
{
|
||||
span->v = static_cast<value_type>(fg);
|
||||
}
|
||||
span->v = safe_cast<value_type>(fg / total_weight);
|
||||
}
|
||||
|
||||
span->a = base_mask;
|
||||
|
|
Loading…
Reference in a new issue