本文整理汇总了C++中mapnik::query::resolution方法的典型用法代码示例。如果您正苦于以下问题:C++ query::resolution方法的具体用法?C++ query::resolution怎么用?C++ query::resolution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapnik::query
的用法示例。
在下文中一共展示了query::resolution方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_feature
feature_ptr rasterlite_featureset::get_feature(mapnik::query const& q)
{
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Running get_feature";
feature_ptr feature(feature_factory::create(ctx_,1));
double x0, y0, x1, y1;
rasterliteGetExtent (dataset_, &x0, &y0, &x1, &y1);
box2d<double> raster_extent(x0, y0, x1, y1);
box2d<double> intersect = raster_extent.intersect(q.get_bbox());
const int width = static_cast<int>(std::get<0>(q.resolution()) * intersect.width() + 0.5);
const int height = static_cast<int>(std::get<0>(q.resolution()) * intersect.height() + 0.5);
const double pixel_size = (intersect.width() >= intersect.height()) ?
(intersect.width() / (double) width) : (intersect.height() / (double) height);
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Raster extent=" << raster_extent;
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: View extent=" << q.get_bbox();
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Intersect extent=" << intersect;
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Query resolution=" << std::get<0>(q.resolution()) << "," << std::get<1>(q.resolution());
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Size=" << width << " " << height;
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Pixel Size=" << pixel_size;
if (width > 0 && height > 0)
{
int size = 0;
void* raster = 0;
if (rasterliteGetRawImageByRect(dataset_,
intersect.minx(),
intersect.miny(),
intersect.maxx(),
intersect.maxy(),
pixel_size,
width,
height,
GAIA_RGBA_ARRAY,
&raster,
&size) == RASTERLITE_OK)
{
if (size > 0)
{
mapnik::image_rgba8 image(width,height);
unsigned char* raster_data = static_cast<unsigned char*>(raster);
std::memcpy(image.bytes(), raster_data, size);
feature->set_raster(std::make_shared<mapnik::raster>(intersect, std::move(image), 1.0));
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Done";
}
else
{
MAPNIK_LOG_ERROR(rasterlite) << "Rasterlite Plugin: Error " << rasterliteGetLastError (dataset_);
}
}
return feature;
}
return feature_ptr();
}
示例2: features
mapnik::featureset_ptr rasterizer_datasource::features(const mapnik::query& q) const
{
std::clog << "Rasterizer::features"
<< ", resolution_type=(" << q.resolution().head << "," << q.resolution().tail.head << ")"
<< ", scale_denominator=" << q.scale_denominator()
<< ", bbox=[" << q.get_bbox().minx() << "," << q.get_bbox().miny() << "," << q.get_bbox().maxx() << "," << q.get_bbox().maxy() << "]"
<< std::endl;
double resx=q.resolution().head,
resy=q.resolution().tail.head,
bbox_width=q.get_bbox().width(),
bbox_height=q.get_bbox().height();
int pixel_width=round(bbox_width * resx),
pixel_height=round(bbox_height * resy);
if (pixel_width<=0 || pixel_height<=0) {
std::clog << "Illegal rasterizer display metrics" << std::endl;
return mapnik::featureset_ptr();
}
std::clog << "Rasterizer generating image of size (" << pixel_width << "," << pixel_height << ")" << std::endl;
// Setup for render
mapnik::feature_ptr feature(mapnik::feature_factory::create(1));
mapnik::image_data_32 image(pixel_width, pixel_height);
rasterize_params params(q, image);
rasterize(params);
// Prepare and return the raster feature
feature->set_raster(boost::make_shared<mapnik::raster>(q.get_bbox(), image));
return boost::make_shared<singleton_featureset>(singleton_featureset(feature));
}
示例3: get_feature
feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
feature_ptr feature = feature_factory::create(ctx_,1);
GDALRasterBand * red = 0;
GDALRasterBand * green = 0;
GDALRasterBand * blue = 0;
GDALRasterBand * alpha = 0;
GDALRasterBand * grey = 0;
/*
#ifdef MAPNIK_LOG
double tr[6];
dataset_.GetGeoTransform(tr);
const double dx = tr[1];
const double dy = tr[5];
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: dx_=" << dx_ << " dx=" << dx << " dy_=" << dy_ << "dy=" << dy;
#endif
*/
CoordTransform t(raster_width_, raster_height_, raster_extent_, 0, 0);
box2d<double> intersect = raster_extent_.intersect(q.get_bbox());
box2d<double> 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()));
if (margin_x < 1)
{
margin_x = 1.0;
}
if (margin_y < 1)
{
margin_y = 1.0;
}
//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);
//clip to available data
if (x_off < 0)
{
x_off = 0;
}
if (y_off < 0)
{
y_off = 0;
}
if (end_x > (int)raster_width_)
{
end_x = raster_width_;
}
if (end_y > (int)raster_height_)
{
end_y = raster_height_;
}
int width = end_x - x_off;
int height = end_y - y_off;
// don't process almost invisible data
if (box.width() < 0.5)
{
width = 0;
}
if (box.height() < 0.5)
{
height = 0;
}
//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);
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Raster extent=" << raster_extent_;
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: View extent=" << intersect;
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Query resolution=" << boost::get<0>(q.resolution()) << "," << boost::get<1>(q.resolution());
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: StartX=" << x_off << " StartY=" << y_off << " Width=" << width << " Height=" << height;
if (width > 0 && height > 0)
{
double width_res = boost::get<0>(q.resolution());
double height_res = boost::get<1>(q.resolution());
int im_width = int(width_res * intersect.width() + 0.5);
int im_height = int(height_res * intersect.height() + 0.5);
// if layer-level filter_factor is set, apply it
if (filter_factor_)
{
im_width *= filter_factor_;
im_height *= filter_factor_;
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Applying layer filter_factor=" << filter_factor_;
}
// otherwise respect symbolizer level factor applied to query, default of 1.0
else
{
//.........这里部分代码省略.........
示例4: get_feature
feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
feature_ptr feature = feature_factory::create(ctx_,1);
int raster_has_nodata = 0;
double raster_nodata = 0;
GDALRasterBand * red = 0;
GDALRasterBand * green = 0;
GDALRasterBand * blue = 0;
GDALRasterBand * alpha = 0;
GDALRasterBand * grey = 0;
CPLErr raster_io_error = CE_None;
/*
#ifdef MAPNIK_LOG
double tr[6];
dataset_.GetGeoTransform(tr);
const double dx = tr[1];
const double dy = tr[5];
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: dx_=" << dx_ << " dx=" << dx << " dy_=" << dy_ << "dy=" << dy;
#endif
*/
view_transform t(raster_width_, raster_height_, raster_extent_, 0, 0);
box2d<double> intersect = raster_extent_.intersect(q.get_bbox());
box2d<double> box = t.forward(intersect);
//size of resized output pixel in source image domain
double margin_x = 1.0 / (std::fabs(dx_) * std::get<0>(q.resolution()));
double margin_y = 1.0 / (std::fabs(dy_) * std::get<1>(q.resolution()));
if (margin_x < 1)
{
margin_x = 1.0;
}
if (margin_y < 1)
{
margin_y = 1.0;
}
//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);
//clip to available data
if (x_off < 0)
{
x_off = 0;
}
if (y_off < 0)
{
y_off = 0;
}
if (end_x > (int)raster_width_)
{
end_x = raster_width_;
}
if (end_y > (int)raster_height_)
{
end_y = raster_height_;
}
int width = end_x - x_off;
int height = end_y - y_off;
// don't process almost invisible data
if (box.width() < 0.5)
{
width = 0;
}
if (box.height() < 0.5)
{
height = 0;
}
//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);
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Raster extent=" << raster_extent_;
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: View extent=" << intersect;
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Query resolution=" << std::get<0>(q.resolution()) << "," << std::get<1>(q.resolution());
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: StartX=" << x_off << " StartY=" << y_off << " Width=" << width << " Height=" << height;
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;
//.........这里部分代码省略.........
示例5: get_feature
feature_ptr rasterlite_featureset::get_feature(mapnik::query const& q)
{
#ifdef MAPNIK_DEBUG
std::clog << "Rasterlite Plugin: get_feature" << "\n";
#endif
feature_ptr feature(new Feature(1));
double x0, y0, x1, y1;
rasterliteGetExtent (dataset_, &x0, &y0, &x1, &y1);
box2d<double> raster_extent(x0,y0,x1,y1);
box2d<double> intersect = raster_extent.intersect(q.get_bbox());
int width = static_cast<int>(q.resolution() * intersect.width() + 0.5);
int height = static_cast<int>(q.resolution() * intersect.height() + 0.5);
double pixel_size = (intersect.width() >= intersect.height()) ?
(intersect.width() / (double) width) : (intersect.height() / (double) height);
#ifdef MAPNIK_DEBUG
std::clog << "Rasterlite Plugin: Raster extent=" << raster_extent << "\n";
std::clog << "Rasterlite Plugin: View extent=" << q.get_bbox() << "\n";
std::clog << "Rasterlite Plugin: Intersect extent=" << intersect << "\n";
std::clog << "Rasterlite Plugin: Query resolution=" << q.resolution() << "\n";
std::clog << "Rasterlite Plugin: Size=" << width << " " << height << "\n";
std::clog << "Rasterlite Plugin: Pixel Size=" << pixel_size << "\n";
#endif
if (width > 0 && height > 0)
{
int size;
void *raster;
if (rasterliteGetRawImageByRect(dataset_,
intersect.minx(), intersect.miny(), intersect.maxx(), intersect.maxy(),
pixel_size, width, height, GAIA_RGBA_ARRAY, &raster, &size) == RASTERLITE_OK)
{
if (size > 0)
{
mapnik::image_data_32 image(width, height);
image.set(0xffffffff);
unsigned char* raster_data = static_cast<unsigned char*>(raster);
unsigned char* image_data = image.getBytes();
memcpy (image_data, raster_data, size);
feature->set_raster(mapnik::raster_ptr(new mapnik::raster(intersect,image)));
free (raster);
#ifdef MAPNIK_DEBUG
std::clog << "Rasterlite Plugin: Done" << "\n";
#endif
}
else
{
#ifdef MAPNIK_DEBUG
std::clog << "Rasterlite Plugin: Error=" << rasterliteGetLastError (dataset_) << "\n";
#endif
}
}
return feature;
}
return feature_ptr();
}
示例6: get_feature
feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
feature_ptr feature(new Feature(1));
GDALRasterBand * red = 0;
GDALRasterBand * green = 0;
GDALRasterBand * blue = 0;
GDALRasterBand * alpha = 0;
GDALRasterBand * grey = 0;
/*
double tr[6];
dataset_.GetGeoTransform(tr);
double dx = tr[1];
double dy = tr[5];
std::clog << "dx_: " << dx_ << " dx: " << dx << " dy_: " << dy_ << "dy: " << dy << "\n";
*/
CoordTransform t(raster_width_,raster_height_,raster_extent_,0,0);
box2d<double> intersect = raster_extent_.intersect(q.get_bbox());
box2d<double> 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()));
if (margin_x < 1)
margin_x = 1.0;
if (margin_y < 1)
margin_y = 1.0;
//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);
//clip to available data
if (x_off < 0)
x_off = 0;
if (y_off < 0)
y_off = 0;
if (end_x > (int)raster_width_)
end_x = raster_width_;
if (end_y > (int)raster_height_)
end_y = raster_height_;
int width = end_x - x_off;
int height = end_y - y_off;
// don't process almost invisible data
if (box.width() < 0.5)
width = 0;
if (box.height() < 0.5)
height = 0;
//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);
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Raster extent=" << raster_extent_ << std::endl;
std::clog << "GDAL Plugin: View extent=" << intersect << std::endl;
std::clog << "GDAL Plugin: Query resolution=" << boost::get<0>(q.resolution()) << "," << boost::get<1>(q.resolution()) << std::endl;
std::clog << boost::format("GDAL Plugin: StartX=%d StartY=%d Width=%d Height=%d") % x_off % y_off % width % height << std::endl;
#endif
if (width > 0 && height > 0)
{
double width_res = boost::get<0>(q.resolution());
double height_res = boost::get<1>(q.resolution());
int im_width = int(width_res * intersect.width() + 0.5);
int im_height = int(height_res * intersect.height() + 0.5);
// if layer-level filter_factor is set, apply it
if (filter_factor_)
{
im_width *= filter_factor_;
im_height *= filter_factor_;
}
// otherwise respect symbolizer level factor applied to query, default of 1.0
else
{
double sym_downsample_factor = q.get_filter_factor();
im_width *= sym_downsample_factor;
im_height *= sym_downsample_factor;
}
// 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::image_data_32 image(im_width, im_height);
image.set(0xffffffff);
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: Image Size=(" << im_width << "," << im_height << ")" << std::endl;
std::clog << "GDAL Plugin: Reading band " << band_ << std::endl;
#endif
//.........这里部分代码省略.........