double scale() const
 {
     if (tile_size_ > 0)
     {
         return extent_.width()/tile_size_;
     }
     return extent_.width();
 }
Exemplo n.º 2
0
boost::optional<std::string> linestring_bbox_clipping(mapnik::box2d<double> bbox,
                                                      std::string wkt_in)
{
    using namespace mapnik;
    agg::trans_affine tr;
    projection src(MAPNIK_LONGLAT_PROJ);
    projection dst(MAPNIK_LONGLAT_PROJ);
    proj_transform prj_trans(src,dst);
    line_symbolizer sym;
    CoordTransform t(bbox.width(),bbox.height(), bbox);
    boost::ptr_vector<mapnik::geometry_type> output_paths;
    output_geometry_backend backend(output_paths, mapnik::LineString);

    typedef boost::mpl::vector<clip_line_tag> conv_types;
    vertex_converter<box2d<double>, output_geometry_backend, line_symbolizer,
                     CoordTransform, proj_transform, agg::trans_affine, conv_types>
        converter(bbox, backend, sym, t, prj_trans, tr, 1.0);

    converter.set<clip_line_tag>();

    boost::ptr_vector<geometry_type> p;
    if (!mapnik::from_wkt(wkt_in , p))
    {
        throw std::runtime_error("Failed to parse WKT");
    }

    BOOST_FOREACH( geometry_type & geom, p)
    {
        converter.apply(geom);
    }
 box2d<double> get_buffered_extent() const
 {
     double extra = 2.0 * scale() * buffer_size_;
     box2d<double> ext(extent_);
     double extra_width = extent_.width() + extra;
     double extra_height = extent_.height() + extra;
     if (extra_width < 0.0)
     {
         extra_width = 0.0;
     }
     if (extra_height < 0.0)
     {
         extra_height = 0.0;
     }
     ext.width(extra_width);
     ext.height(extra_height);
     return ext;
 }