本文整理汇总了C++中mapnik::scale_denominator方法的典型用法代码示例。如果您正苦于以下问题:C++ mapnik::scale_denominator方法的具体用法?C++ mapnik::scale_denominator怎么用?C++ mapnik::scale_denominator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapnik
的用法示例。
在下文中一共展示了mapnik::scale_denominator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mousePressEvent
void MapWidget::mousePressEvent(QMouseEvent* e)
{
if (e->button()==Qt::LeftButton)
{
if (cur_tool_ == ZoomToBox || cur_tool_==Pan)
{
start_x_ = e->x();
start_y_ = e->y();
drag_=true;
}
else if (cur_tool_==Info)
{
if (map_)
{
QVector<QPair<QString,QString> > info;
projection map_proj(map_->srs()); // map projection
double scale_denom = scale_denominator(map_->scale(),map_proj.is_geographic());
CoordTransform t(map_->width(),map_->height(),map_->get_current_extent());
for (unsigned index = 0; index < map_->layer_count();++index)
{
if (int(index) != selectedLayer_) continue;
layer & layer = map_->layers()[index];
if (!layer.visible(scale_denom)) continue;
std::string name = layer.name();
double x = e->x();
double y = e->y();
std::cout << "query at " << x << "," << y << "\n";
projection layer_proj(layer.srs());
mapnik::proj_transform prj_trans(map_proj,layer_proj);
//std::auto_ptr<mapnik::memory_datasource> data(new mapnik::memory_datasource);
mapnik::featureset_ptr fs = map_->query_map_point(index,x,y);
if (fs)
{
feature_ptr feat = fs->next();
if (feat)
{
feature_kv_iterator itr(*feat,true);
feature_kv_iterator end(*feat);
for ( ;itr!=end; ++itr)
{
info.push_back(QPair<QString,QString>(QString(std::get<0>(*itr).c_str()),
std::get<1>(*itr).to_string().c_str()));
}
typedef mapnik::coord_transform<mapnik::CoordTransform,mapnik::geometry_type> path_type;
for (unsigned i=0; i<feat->num_geometries();++i)
{
mapnik::geometry_type & geom = feat->get_geometry(i);
path_type path(t,geom,prj_trans);
if (geom.size() > 0)
{
QPainterPath qpath;
double x,y;
path.vertex(&x,&y);
qpath.moveTo(x,y);
for (unsigned j = 1; j < geom.size(); ++j)
{
path.vertex(&x,&y);
qpath.lineTo(x,y);
}
QPainter painter(&pix_);
QPen pen(QColor(255,0,0,96));
pen.setWidth(3);
pen.setCapStyle(Qt::RoundCap);
pen.setJoinStyle(Qt::RoundJoin);
painter.setPen(pen);
painter.drawPath(qpath);
update();
}
}
}
}
if (info.size() > 0)
{
info_dialog info_dlg(info,this);
info_dlg.exec();
break;
}
}
// remove annotation layer
map_->layers().erase(remove_if(map_->layers().begin(),
map_->layers().end(),
bind(&layer::name,_1) == "*annotations*")
, map_->layers().end());
}
}
}
else if (e->button()==Qt::RightButton)
{
//updateMap();
}
//.........这里部分代码省略.........