Merge pull request #3672 from mapnik/filter_factor_removal

Removed filter factor
This commit is contained in:
Blake Thompson 2017-05-10 16:02:17 -05:00 committed by GitHub
commit e945eb74fe
4 changed files with 352 additions and 373 deletions

View file

@ -216,7 +216,8 @@ void render_raster_symbolizer(raster_symbolizer const& sym,
{
box2d<double> target_ext = box2d<double>(source->ext_);
box2d<double> target_query_ext = box2d<double>(source->query_ext_);
if (!prj_trans.equal()) {
if (!prj_trans.equal())
{
prj_trans.backward(target_ext, PROJ_ENVELOPE_POINTS);
prj_trans.backward(target_query_ext, PROJ_ENVELOPE_POINTS);
}

View file

@ -189,7 +189,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
//calculate actual box2d of returned raster
box2d<double> feature_raster_extent(x_off, y_off, x_off + width, y_off + height);
intersect = t.backward(feature_raster_extent);
feature_raster_extent = t.backward(feature_raster_extent);
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Raster extent=" << raster_extent_;
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: View extent=" << intersect;
@ -198,26 +198,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
if (width > 0 && height > 0)
{
double width_res = std::get<0>(q.resolution());
double height_res = std::get<1>(q.resolution());
int im_width = int(width_res * intersect.width() + 0.5);
int im_height = int(height_res * intersect.height() + 0.5);
double filter_factor = q.get_filter_factor();
im_width = int(im_width * filter_factor + 0.5);
im_height = int(im_height * filter_factor + 0.5);
// case where we need to avoid upsampling so that the
// image can be later scaled within raster_symbolizer
if (im_width >= width || im_height >= height)
{
im_width = width;
im_height = height;
}
if (im_width > 0 && im_height > 0)
{
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Image Size=(" << im_width << "," << im_height << ")";
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Image Size=(" << width << "," << height << ")";
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Reading band=" << band_;
if (band_ > 0) // we are querying a single band
{
@ -233,7 +214,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
case GDT_Byte:
{
mapnik::image_gray8 image(im_width, im_height);
mapnik::image_gray8 image(width, height);
image.set(std::numeric_limits<std::uint8_t>::max());
raster_nodata = band->GetNoDataValue(&raster_has_nodata);
raster_io_error = band->RasterIO(GF_Read, x_off, y_off, width, height,
@ -243,7 +224,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
throw datasource_exception(CPLGetLastErrorMsg());
}
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(intersect, image, filter_factor);
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, 0.0);
// set nodata value to be used in raster colorizer
if (nodata_value_) raster->set_nodata(*nodata_value_);
else raster->set_nodata(raster_nodata);
@ -253,7 +234,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
case GDT_Float64:
case GDT_Float32:
{
mapnik::image_gray32f image(im_width, im_height);
mapnik::image_gray32f image(width, height);
image.set(std::numeric_limits<float>::max());
raster_nodata = band->GetNoDataValue(&raster_has_nodata);
raster_io_error = band->RasterIO(GF_Read, x_off, y_off, width, height,
@ -263,7 +244,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
throw datasource_exception(CPLGetLastErrorMsg());
}
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(intersect, image, filter_factor);
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, 0.0);
// set nodata value to be used in raster colorizer
if (nodata_value_) raster->set_nodata(*nodata_value_);
else raster->set_nodata(raster_nodata);
@ -272,7 +253,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
}
case GDT_UInt16:
{
mapnik::image_gray16 image(im_width, im_height);
mapnik::image_gray16 image(width, height);
image.set(std::numeric_limits<std::uint16_t>::max());
raster_nodata = band->GetNoDataValue(&raster_has_nodata);
raster_io_error = band->RasterIO(GF_Read, x_off, y_off, width, height,
@ -282,7 +263,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
throw datasource_exception(CPLGetLastErrorMsg());
}
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(intersect, image, filter_factor);
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, 0.0);
// set nodata value to be used in raster colorizer
if (nodata_value_) raster->set_nodata(*nodata_value_);
else raster->set_nodata(raster_nodata);
@ -292,7 +273,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
default:
case GDT_Int16:
{
mapnik::image_gray16s image(im_width, im_height);
mapnik::image_gray16s image(width, height);
image.set(std::numeric_limits<std::int16_t>::max());
raster_nodata = band->GetNoDataValue(&raster_has_nodata);
raster_io_error = band->RasterIO(GF_Read, x_off, y_off, width, height,
@ -302,7 +283,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
throw datasource_exception(CPLGetLastErrorMsg());
}
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(intersect, image, filter_factor);
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, 0.0);
// set nodata value to be used in raster colorizer
if (nodata_value_) raster->set_nodata(*nodata_value_);
else raster->set_nodata(raster_nodata);
@ -313,7 +294,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
}
else // working with all bands
{
mapnik::image_rgba8 image(im_width, im_height);
mapnik::image_rgba8 image(width, height);
image.set(std::numeric_limits<std::uint32_t>::max());
for (int i = 0; i < nbands_; ++i)
{
@ -602,7 +583,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
}
}
}
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(intersect, image, filter_factor);
mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent, intersect, image, 0.0);
// set nodata value to be used in raster colorizer
if (nodata_value_) raster->set_nodata(*nodata_value_);
else raster->set_nodata(raster_nodata);
@ -615,7 +596,6 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
}
return feature;
}
}
return feature_ptr();
}

View file

@ -96,6 +96,8 @@ feature_ptr raster_featureset<LookupPolicy>::next()
int end_y = static_cast<int>(std::ceil(ext.maxy()));
// clip to available data
if (x_off >= image_width) x_off = image_width - 1;
if (y_off >= image_width) y_off = image_width - 1;
if (x_off < 0) x_off = 0;
if (y_off < 0) y_off = 0;
if (end_x > image_width) end_x = image_width;
@ -103,12 +105,8 @@ feature_ptr raster_featureset<LookupPolicy>::next()
int width = end_x - x_off;
int height = end_y - y_off;
if (width < 1) {
width = 1;
}
if (height < 1) {
height = 1;
}
if (width < 1) width = 1;
if (height < 1) height = 1;
// calculate actual box2d of returned raster
box2d<double> feature_raster_extent(rem.minx() + x_off,

@ -1 +1 @@
Subproject commit 457eb219475d5a50e742d97ccbbe1015ff4f6246
Subproject commit 7023ba0a782ed64ebe254e653e0f7a9a7ee1d92b