followup nodata refactor - refs #2023
This commit is contained in:
parent
df3a455e19
commit
7aeff3fb59
1 changed files with 7 additions and 13 deletions
|
@ -127,27 +127,21 @@ void raster_colorizer::colorize(raster_ptr const& raster, feature_impl const& f)
|
||||||
unsigned *imageData = raster->data_.getData();
|
unsigned *imageData = raster->data_.getData();
|
||||||
|
|
||||||
int len = raster->data_.width() * raster->data_.height();
|
int len = raster->data_.width() * raster->data_.height();
|
||||||
|
boost::optional<double> const& nodata = raster->nodata();
|
||||||
bool hasNoData = false;
|
|
||||||
float noDataValue = 0;
|
|
||||||
|
|
||||||
//std::map<std::string,value>::const_iterator fi = Props.find("NODATA");
|
|
||||||
if (f.has_key("NODATA"))
|
|
||||||
{
|
|
||||||
hasNoData = true;
|
|
||||||
noDataValue = static_cast<float>(f.get("NODATA").to_double());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=0; i<len; ++i)
|
for (int i=0; i<len; ++i)
|
||||||
{
|
{
|
||||||
// the GDAL plugin reads single bands as floats
|
// the GDAL plugin reads single bands as floats
|
||||||
float value = *reinterpret_cast<float *> (&imageData[i]);
|
float value = *reinterpret_cast<float *> (&imageData[i]);
|
||||||
if (hasNoData && noDataValue == value)
|
if (nodata && (std::fabs(value - *nodata) < epsilon_))
|
||||||
imageData[i] = color(0,0,0,0).rgba();
|
{
|
||||||
|
imageData[i] = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
imageData[i] = get_color(value).rgba();
|
imageData[i] = get_color(value).rgba();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline unsigned interpolate(unsigned start, unsigned end, float fraction)
|
inline unsigned interpolate(unsigned start, unsigned end, float fraction)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue