本文整理汇总了C++中mapnik::Map类的典型用法代码示例。如果您正苦于以下问题:C++ Map类的具体用法?C++ Map怎么用?C++ Map使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Map类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_to_file2
void render_to_file2(const mapnik::Map& map,
const std::string& filename)
{
mapnik::image_32 image(map.getWidth(),map.getHeight());
render(map,image,0,0);
mapnik::save_to_file(image,filename);
}
示例2: render_agg
void render_agg(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
{
unsigned width=map.width();
unsigned height=map.height();
image_32 buf(width,height);
mapnik::agg_renderer<image_32> ren(map,buf,scaling_factor);
try
{
mapnik::auto_cpu_timer t(std::clog, "rendering took: ");
ren.apply();
QImage image((uchar*)buf.raw_data(),width,height,QImage::Format_ARGB32);
pix = QPixmap::fromImage(image.rgbSwapped());
}
catch (mapnik::config_error & ex)
{
std::cerr << ex.what() << std::endl;
}
catch (const std::exception & ex)
{
std::cerr << "exception: " << ex.what() << std::endl;
}
catch (...)
{
std::cerr << "Unknown exception caught!\n";
}
}
示例3: render
image_type render(mapnik::Map const & map, double scale_factor) const
{
image_type image(map.width(), map.height());
mapnik::agg_renderer<image_type> ren(map, image, scale_factor);
ren.apply();
return image;
}
示例4: render_to_file1
void render_to_file1(mapnik::Map const& map,
std::string const& filename,
std::string const& format)
{
if (format == "svg-ng")
{
#if defined(SVG_RENDERER)
std::ofstream file (filename.c_str(), std::ios::out|std::ios::trunc|std::ios::binary);
if (!file)
{
throw mapnik::image_writer_exception("could not open file for writing: " + filename);
}
using iter_type = std::ostream_iterator<char>;
iter_type output_stream_iterator(file);
mapnik::svg_renderer<iter_type> ren(map,output_stream_iterator);
ren.apply();
#else
throw mapnik::image_writer_exception("SVG backend not available, cannot write to format: " + format);
#endif
}
else if (format == "pdf" || format == "svg" || format =="ps" || format == "ARGB32" || format == "RGB24")
{
#if defined(HAVE_CAIRO)
mapnik::save_to_cairo_file(map,filename,format,1.0);
#else
throw mapnik::image_writer_exception("Cairo backend not available, cannot write to format: " + format);
#endif
}
else
{
mapnik::image_any image(map.width(),map.height());
render(map,image,1.0,0,0);
mapnik::save_to_file(image,filename,format);
}
}
示例5: test
result test(std::string const & name, mapnik::Map const & map, double scale_factor) const
{
typename Renderer::image_type image(ren.render(map, scale_factor));
boost::filesystem::path reference = reference_dir / image_file_name(name, map.width(), map.height(), scale_factor, true, Renderer::ext);
bool reference_exists = boost::filesystem::exists(reference);
result res;
res.state = reference_exists ? STATE_OK : STATE_OVERWRITE;
res.name = name;
res.renderer_name = Renderer::name;
res.scale_factor = scale_factor;
res.size = map_size(map.width(), map.height());
res.reference_image_path = reference;
res.diff = reference_exists ? ren.compare(image, reference) : 0;
if (res.diff)
{
boost::filesystem::create_directories(output_dir);
boost::filesystem::path path = output_dir / image_file_name(name, map.width(), map.height(), scale_factor, false, Renderer::ext);
res.actual_image_path = path;
res.state = STATE_FAIL;
ren.save(image, path);
}
if ((res.diff && overwrite) || !reference_exists)
{
ren.save(image, reference);
res.state = STATE_OVERWRITE;
}
return res;
}
示例6: set_maximum_extent
void set_maximum_extent(mapnik::Map & m, boost::optional<mapnik::box2d<double> > const& box)
{
if (box)
{
m.set_maximum_extent(*box);
}
else
{
m.reset_maximum_extent();
}
}
示例7: render_with_vars
void render_with_vars(mapnik::Map const& map,
mapnik::image_any& image,
boost::python::dict const& d,
double scale_factor = 1.0,
unsigned offset_x = 0u,
unsigned offset_y = 0u)
{
mapnik::attributes vars = mapnik::dict2attr(d);
mapnik::request req(map.width(),map.height(),map.get_current_extent());
req.set_buffer_size(map.buffer_size());
python_unblock_auto_block b;
mapnik::util::apply_visitor(agg_renderer_visitor_3(map, req, vars, scale_factor, offset_x, offset_y), image);
}
示例8: parameterize_map_language
static void parameterize_map_language(mapnik::Map &m, char * parameter) {
int i;
char * data = strdup(parameter);
char * tok;
char ** ctx;
char name_replace[256];
name_replace[0] = 0;
syslog(LOG_DEBUG, "Internationalizing map to language parameter: %s", parameter);
tok = strtok(data,",");
if (!tok) return; //No parameterization given
strncat(name_replace, ", coalesce(", 255);
while (tok) {
if (strcmp(tok,"_") == 0) {
strncat(name_replace,"name,", 255);
} else {
strncat(name_replace,"tags->'name:", 255);
strncat(name_replace, tok, 255);
strncat(name_replace,"',", 255);
}
tok = strtok(NULL, ",");
}
free(data);
name_replace[strlen(name_replace) - 1] = 0;
strncat(name_replace,") as name", 255);
for (i = 0; i < m.layer_count(); i++) {
mapnik::layer& l = m.getLayer(i);
mapnik::parameters params = l.datasource()->params();
if (params.find("table") != params.end()) {
if (boost::get<std::string>(params["table"]).find(",name") != std::string::npos) {
std::string str = boost::get<std::string>(params["table"]);
size_t pos = str.find(",name");
str.replace(pos,5,name_replace);
params["table"] = str;
#if MAPNIK_VERSION >= 200200
std::shared_ptr<mapnik::datasource> ds = mapnik::datasource_cache::instance().create(params);
#else
std::shared_ptr<mapnik::datasource> ds = mapnik::datasource_cache::instance()->create(params);
#endif
l.set_datasource(ds);
}
}
}
}
示例9: query_map_point
mapnik::featureset_ptr query_map_point(mapnik::Map const& m, int index, double x, double y)
{
if (index < 0){
PyErr_SetString(PyExc_IndexError, "Please provide a layer index >= 0");
boost::python::throw_error_already_set();
}
unsigned idx = index;
return m.query_map_point(idx, x, y);
}
示例10: render_to_file2
void render_to_file2(const mapnik::Map& map,const std::string& filename)
{
std::string format = mapnik::guess_type(filename);
if (format == "pdf" || format == "svg" || format =="ps")
{
#if defined(HAVE_CAIRO)
mapnik::save_to_cairo_file(map,filename,format);
#else
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
#endif
}
else
{
mapnik::image_32 image(map.width(),map.height());
render(map,image,1.0,0,0);
mapnik::save_to_file(image,filename);
}
}
示例11: render_to_file1
void render_to_file1(const mapnik::Map& map,
const std::string& filename,
const std::string& format)
{
if (format == "pdf" || format == "svg" || format =="ps" || format == "ARGB32" || format == "RGB24")
{
#if defined(HAVE_CAIRO)
mapnik::save_to_cairo_file(map,filename,format);
#else
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
#endif
}
else
{
mapnik::Image32 image(map.getWidth(),map.getHeight());
render(map,image,0,0);
mapnik::save_to_file(image,filename,format);
}
}
示例12: find_style
mapnik::feature_type_style find_style(mapnik::Map const& m, std::string const& name)
{
boost::optional<mapnik::feature_type_style const&> style = m.find_style(name);
if (!style)
{
PyErr_SetString(PyExc_KeyError, "Invalid style name");
boost::python::throw_error_already_set();
}
return *style;
}
示例13: find_fontset
mapnik::font_set find_fontset(mapnik::Map const& m, std::string const& name)
{
boost::optional<mapnik::font_set const&> fontset = m.find_fontset(name);
if (!fontset)
{
PyErr_SetString(PyExc_KeyError, "Invalid font_set name");
boost::python::throw_error_already_set();
}
return *fontset;
}
示例14: render_cairo
void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
{
// FIXME
#ifdef HAVE_CAIRO
mapnik::cairo_surface_ptr image_surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32,map.width(),map.height()),
mapnik::cairo_surface_closer());
mapnik::cairo_ptr cairo = mapnik::create_context(image_surface);
if (cairo)
{
mapnik::auto_cpu_timer t(std::clog, "rendering took: ");
mapnik::cairo_renderer<mapnik::cairo_ptr> renderer(map, cairo, scaling_factor);
renderer.apply();
}
mapnik::image_rgba8 data(map.width(), map.height());
mapnik::cairo_image_to_rgba8(data, image_surface);
QImage image((uchar*)data.getBytes(),data.width(),data.height(),QImage::Format_ARGB32);
pix = QPixmap::fromImage(image.rgbSwapped());
#endif
}
示例15: render_to_file3
void render_to_file3(mapnik::Map const& map,
std::string const& filename,
std::string const& format,
double scale_factor = 1.0
)
{
if (format == "pdf" || format == "svg" || format =="ps" || format == "ARGB32" || format == "RGB24")
{
#if defined(HAVE_CAIRO)
mapnik::save_to_cairo_file(map,filename,format,scale_factor);
#else
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
#endif
}
else
{
mapnik::image_32 image(map.width(),map.height());
render(map,image,scale_factor,0,0);
mapnik::save_to_file(image,filename,format);
}
}