+ cache SVG marker bounding box
This commit is contained in:
parent
c500451cd8
commit
2b3858df07
5 changed files with 38 additions and 14 deletions
|
@ -25,6 +25,7 @@
|
|||
#ifndef MAPNIK_SVG_STORAGE_HPP
|
||||
#define MAPNIK_SVG_STORAGE_HPP
|
||||
|
||||
#include <mapnik/box2d.hpp>
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
@ -45,9 +46,27 @@ public:
|
|||
{
|
||||
return attributes_;
|
||||
}
|
||||
|
||||
void set_bounding_box(box2d<double> const& b)
|
||||
{
|
||||
bounding_box_ = b;
|
||||
}
|
||||
|
||||
void set_bounding_box(double x0, double y0, double x1, double y1)
|
||||
{
|
||||
bounding_box_.init(x0,y0,x1,y1);
|
||||
}
|
||||
|
||||
box2d<double> const& bounding_box() const
|
||||
{
|
||||
return bounding_box_;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
VertexSource source_;
|
||||
AttributeSource attributes_;
|
||||
box2d<double> bounding_box_;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -83,9 +83,14 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
if (0)//marker && *marker)
|
||||
{
|
||||
svg_marker = true;
|
||||
double x1, y1, x2, y2;
|
||||
//(*marker)->bounding_rect(&x1, &y1, &x2, &y2);
|
||||
box2d<double> const& bbox = (*marker)->bounding_box();
|
||||
double x1 = bbox.minx();
|
||||
double y1 = bbox.miny();
|
||||
double x2 = bbox.maxx();
|
||||
double y2 = bbox.maxy();
|
||||
// FIXME
|
||||
extent.init(x1, y1, x2, y2);
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,13 +82,13 @@ void agg_renderer<T>::process(point_symbolizer const& sym,
|
|||
|
||||
if (marker && *marker)
|
||||
{
|
||||
double x1, y1, x2, y2;
|
||||
// FIXME: Cache bounding box /////////////
|
||||
mapnik::svg::svg_converter_type svg_converter((*marker)->source(),
|
||||
(*marker)->attributes());
|
||||
|
||||
svg_converter.bounding_rect(&x1, &y1, &x2, &y2);
|
||||
/////////////////////
|
||||
box2d<double> const& bbox = (*marker)->bounding_box();
|
||||
double x1 = bbox.minx();
|
||||
double y1 = bbox.miny();
|
||||
double x2 = bbox.maxx();
|
||||
double y2 = bbox.maxy();
|
||||
|
||||
mapnik::svg::svg_renderer<agg::path_storage,
|
||||
agg::pod_bvector<mapnik::svg::path_attributes> > svg_renderer((*marker)->source(),
|
||||
(*marker)->attributes());
|
||||
|
|
|
@ -84,13 +84,12 @@ void agg_renderer<T>::process(shield_symbolizer const& sym,
|
|||
if (text.length() > 0 && marker && *marker)
|
||||
{
|
||||
face_set_ptr faces;
|
||||
double x1, y1, x2, y2;
|
||||
|
||||
// FIXME: Cache bounding box /////////////
|
||||
mapnik::svg::svg_converter_type svg_converter((*marker)->source(),
|
||||
(*marker)->attributes());
|
||||
|
||||
svg_converter.bounding_rect(&x1, &y1, &x2, &y2);
|
||||
box2d<double> const& bbox = (*marker)->bounding_box();
|
||||
double x1 = bbox.minx();
|
||||
double y1 = bbox.miny();
|
||||
double x2 = bbox.maxx();
|
||||
double y2 = bbox.maxy();
|
||||
/////////////////////
|
||||
mapnik::svg::svg_renderer<agg::path_storage,
|
||||
agg::pod_bvector<mapnik::svg::path_attributes> > svg_renderer((*marker)->source(),
|
||||
|
|
|
@ -74,6 +74,7 @@ boost::optional<path_ptr> marker_cache::find(std::string const& uri, bool update
|
|||
svg.arrange_orientations();
|
||||
double lox,loy,hix,hiy;
|
||||
svg.bounding_rect(&lox, &loy, &hix, &hiy); //TODO: store bbox!
|
||||
marker->set_bounding_box(lox,loy,hix,hiy);
|
||||
if (update_cache)
|
||||
{
|
||||
cache_.insert(std::make_pair(uri,marker));
|
||||
|
|
Loading…
Add table
Reference in a new issue