From 955ff4c4f5f19102a7326d53d70fab280be08d87 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Fri, 23 Dec 2005 12:31:54 +0000 Subject: [PATCH] 1. fixed shape datasource bug - attributes were ignored for point/pointz/pointm types 2. use boost::thread for mutex/lock 3 use boost::noncopyable 4 build agg as a shared lib for now 5. corrected panning code in map.cpp 6. improved coord_transform --- SConstruct | 7 +- agg/SConscript | 3 +- boost/SConscript | 5 + datasources/postgis/connection_manager.hpp | 7 +- datasources/shape/shape_featureset.cpp | 36 ++--- datasources/shape/shape_index_featureset.cpp | 36 ++--- include/ctrans.hpp | 70 ++++---- include/datasource.hpp | 1 - include/feature_type_style.hpp | 2 + include/filter_factory.hpp | 2 +- include/image_symbolizer.hpp | 26 ++- include/line_symbolizer.hpp | 161 ++++++++----------- include/regex_filter.hpp | 1 + include/style_cache.hpp | 17 +- include/utils.hpp | 70 +------- include/vertex_vector.hpp | 4 +- src/SConscript | 5 +- src/datasource_cache.cpp | 5 +- src/map.cpp | 13 +- src/render.cpp | 33 +--- src/style_cache.cpp | 37 +---- 21 files changed, 204 insertions(+), 337 deletions(-) diff --git a/SConstruct b/SConstruct index d62d28bf0..c49b8434c 100644 --- a/SConstruct +++ b/SConstruct @@ -81,13 +81,10 @@ if not conf.CheckLibWithHeader('tiff','tiff.h','C'): env = conf.Finish() Export('env') - -#build boost libs (filesystem, regex, python) -env.SConscript('boost/SConscript') - #build agg lib env.SConscript('agg/SConscript') - +#build boost libs (filesystem, regex, python etc) +env.SConscript('boost/SConscript') #main lib SConscript('src/SConscript') diff --git a/agg/SConscript b/agg/SConscript index 8ce860d15..94280424d 100644 --- a/agg/SConscript +++ b/agg/SConscript @@ -25,4 +25,5 @@ agg_root = env['AGG_ROOT'] agg_headers = agg_root + '/include' agg_src_dir = agg_root + '/src/' agg_src = glob.glob(agg_src_dir + '*.cpp') -agg_lib = env.StaticLibrary('libagg',agg_src,LIBS=[],CPPPATH=agg_headers) +agg_lib = env.SharedLibrary('libagg',agg_src,LIBS=[],CPPPATH=agg_headers) +env.Install(prefix+'/lib',agg_lib) diff --git a/boost/SConscript b/boost/SConscript index 17c8b30d8..955a20467 100644 --- a/boost/SConscript +++ b/boost/SConscript @@ -44,3 +44,8 @@ boost_serialization_src = glob.glob(serialization_src_dir+ '*.cpp') lib_boost_serialization = env.SharedLibrary('libboost-serialization',boost_serialization_src,LIBS=[],CPPPATH=boost_root) env.Install(prefix+'/lib',lib_boost_serialization) +#boost thread +thread_src_dir = boost_root + '/libs/thread/src/' +boost_thread_src = glob.glob(thread_src_dir+ '*.cpp') +lib_boost_thread = env.SharedLibrary('libboost-thread',boost_thread_src,LIBS=[],CPPPATH=boost_root) +env.Install(prefix+'/lib',lib_boost_thread) diff --git a/datasources/postgis/connection_manager.hpp b/datasources/postgis/connection_manager.hpp index 4379d65e4..73bfb65d3 100644 --- a/datasources/postgis/connection_manager.hpp +++ b/datasources/postgis/connection_manager.hpp @@ -26,6 +26,7 @@ #include "utils.hpp" #include "connection.hpp" #include +#include using namespace mapnik; using std::string; @@ -68,7 +69,7 @@ public: bool registerPool(const ConnectionCreator& creator,int initialSize,int maxSize) { - Lock lock(&mutex_); + mutex::scoped_lock lock(mutex_); if (pools_.find(creator.id())==pools_.end()) { return pools_.insert(std::make_pair(creator.id(), @@ -80,7 +81,7 @@ public: } const boost::shared_ptr& getPool(const std::string& key) { - Lock lock(&mutex_); + mutex::scoped_lock lock(mutex_); ContType::const_iterator itr=pools_.find(key); if (itr!=pools_.end()) { @@ -92,7 +93,7 @@ public: const HolderType& get(const std::string& key) { - Lock lock(&mutex_); + mutex::scoped_lock lock(mutex_); ContType::const_iterator itr=pools_.find(key); if (itr!=pools_.end()) { diff --git a/datasources/shape/shape_featureset.cpp b/datasources/shape/shape_featureset.cpp index a83e69b1f..3516948e9 100644 --- a/datasources/shape/shape_featureset.cpp +++ b/datasources/shape/shape_featureset.cpp @@ -151,27 +151,25 @@ feature_ptr shape_featureset::next() ++count_; break; } - default: - return feature_ptr(); + } - - if (attr_ids_.size()) - { - shape_.dbf().move_to(shape_.id_); - typename std::vector::const_iterator pos=attr_ids_.begin(); - while (pos!=attr_ids_.end()) + } + if (attr_ids_.size()) + { + shape_.dbf().move_to(shape_.id_); + typename std::vector::const_iterator pos=attr_ids_.begin(); + while (pos!=attr_ids_.end()) + { + try { - try - { - shape_.dbf().add_attribute(*pos,feature.get());//TODO optimize!!! - } - catch (...) - { - //TODO - } - ++pos; - } - } + shape_.dbf().add_attribute(*pos,feature.get());//TODO optimize!!! + } + catch (...) + { + std::cerr << "error processing attributes " << std::endl; + } + ++pos; + } } return feature; } diff --git a/datasources/shape/shape_index_featureset.cpp b/datasources/shape/shape_index_featureset.cpp index 96c798b3d..b2da58fdb 100644 --- a/datasources/shape/shape_index_featureset.cpp +++ b/datasources/shape/shape_index_featureset.cpp @@ -154,25 +154,25 @@ feature_ptr shape_index_featureset::next() break; } } - if (attr_ids_.size()) - { - feature->reserve_props(attr_ids_.size()); - shape_.dbf().move_to(shape_.id_); - std::vector::const_iterator pos=attr_ids_.begin(); - while (pos!=attr_ids_.end()) - { - try - { - shape_.dbf().add_attribute(*pos,feature.get()); - } - catch (...) - { - std::cerr<<"exception caught\n"; - } - ++pos; - } - } } + if (attr_ids_.size()) + { + feature->reserve_props(attr_ids_.size()); + shape_.dbf().move_to(shape_.id_); + std::vector::const_iterator pos=attr_ids_.begin(); + while (pos!=attr_ids_.end()) + { + try + { + shape_.dbf().add_attribute(*pos,feature.get()); + } + catch (...) + { + std::cerr<<"exception caught\n"; + } + ++pos; + } + } return feature; } else diff --git a/include/ctrans.hpp b/include/ctrans.hpp index 4255bf8a5..aedb43cac 100644 --- a/include/ctrans.hpp +++ b/include/ctrans.hpp @@ -35,14 +35,13 @@ namespace mapnik int height; double scale_; Envelope extent; - coord2d center_; public: CoordTransform(int width,int height,const Envelope& extent) - :width(width),height(height),extent(extent),center_(extent.center()) + :width(width),height(height),extent(extent) { double sx=((double)width)/extent.width(); double sy=((double)height)/extent.height(); - scale_=std::min(sx,sy); + scale_=sx;//std::min(sx,sy); } inline double scale() const @@ -50,51 +49,64 @@ namespace mapnik return scale_; } - double forward_x(double x) const + inline void forward_x(double* x) const { - return (x-center_.x)*scale_+0.5*width; + *x = (*x - extent.minx() ) * scale_; } - double forward_y(double y) const + inline void forward_y(double* y) const { - return -(y-center_.y)*scale_+0.5*height; + *y = (extent.maxy() - *y) * scale_; } - + + inline void backward_x(double* x) const + { + *x = extent.minx() + *x/scale_; + } + + inline void backward_y(double* y) const + { + *y = extent.maxy() - *y/scale_; + } + inline coord2d& forward(coord2d& c) const { - c.x=(c.x-center_.x)*scale_+0.5*width; - c.y=-(c.y-center_.y)*scale_+0.5*height; + forward_x(&c.x); + forward_y(&c.y); return c; } inline coord2d& backward(coord2d& c) const { - c.x=(c.x-0.5*width)/scale_+center_.x; - c.y=-(c.y-0.5*height)/scale_+center_.y; + backward_x(&c.x); + backward_y(&c.y); return c; } inline Envelope forward(const Envelope& e) const { - - double x0=(e.minx()-center_.x)*scale_+0.5*width; - double x1=(e.maxx()-center_.x)*scale_+0.5*width; - - double y0=-(e.miny()-center_.y)*scale_+0.5*height; - double y1=-(e.maxy()-center_.y)*scale_+0.5*height; - + double x0 = e.minx(); + double y0 = e.miny(); + double x1 = e.maxx(); + double y1 = e.maxy(); + forward_x(&x0); + forward_y(&y0); + forward_x(&x1); + forward_y(&y1); return Envelope(x0,y0,x1,y1); } inline Envelope backward(const Envelope& e) const { - - double x0=(e.minx()-0.5*width)/scale_+center_.x; - double x1=(e.maxx()-0.5*width)/scale_+center_.x; - - double y0=-(e.miny()-0.5*height)/scale_+center_.y; - double y1=-(e.maxy()-0.5*height)/scale_+center_.y; - + double x0 = e.minx(); + double y0 = e.miny(); + double x1 = e.maxx(); + double y1 = e.maxy(); + backward_x(&x0); + backward_y(&y0); + backward_x(&x1); + backward_y(&y1); + return Envelope(x0,y0,x1,y1); } @@ -102,8 +114,7 @@ namespace mapnik { for (unsigned i=0;i namespace mapnik diff --git a/include/feature_type_style.hpp b/include/feature_type_style.hpp index 4cce62909..945d0e7c6 100644 --- a/include/feature_type_style.hpp +++ b/include/feature_type_style.hpp @@ -25,6 +25,7 @@ #include "feature.hpp" #include + namespace mapnik { typedef rule rule_type; @@ -50,6 +51,7 @@ namespace mapnik { rules_.push_back(rule); } + rules const& get_rules() const { return rules_; diff --git a/include/filter_factory.hpp b/include/filter_factory.hpp index 6c840b89f..cc2f141c9 100644 --- a/include/filter_factory.hpp +++ b/include/filter_factory.hpp @@ -35,7 +35,7 @@ namespace mapnik { stack > > filters; stack > > exps; - filter_grammar grammar(filters,exps); + filter_grammar grammar(filters,exps); char const *text = str.c_str(); parse_info<> info = parse(text,text+strlen(text),grammar,space_p); if (info.full && !filters.empty()) diff --git a/include/image_symbolizer.hpp b/include/image_symbolizer.hpp index b54828cb6..e580c242a 100644 --- a/include/image_symbolizer.hpp +++ b/include/image_symbolizer.hpp @@ -23,10 +23,12 @@ #include "symbolizer.hpp" #include "image_data.hpp" +#include namespace mapnik { - struct image_symbolizer : public symbolizer + struct image_symbolizer : public symbolizer, + private boost::noncopyable { private: ImageData32 symbol_; @@ -40,8 +42,6 @@ namespace mapnik try { std::auto_ptr reader(get_image_reader(type,file)); - std::cout<<"image width="<width()< namespace mapnik { - struct line_symbolizer : public symbolizer + struct line_symbolizer : public symbolizer, + private boost::noncopyable { private: stroke stroke_; @@ -77,110 +78,84 @@ namespace mapnik double g=col.green()/255.0; double b=col.blue()/255.0; - if (0) //stroke_.width() == 1.0) - { - typedef agg::renderer_outline_aa renderer_oaa; - typedef agg::rasterizer_outline_aa rasterizer_outline_aa; - agg::line_profile_aa prof; - prof.width(stroke_.get_width()); - renderer_oaa ren_oaa(renb, prof); - rasterizer_outline_aa ras_oaa(ren_oaa); - ren_oaa.color(agg::rgba(r, g, b, stroke_.get_opacity())); - ras_oaa.add_path(geom); + typedef agg::renderer_scanline_aa_solid renderer; + renderer ren(renb); + agg::rasterizer_scanline_aa<> ras; + agg::scanline_u8 sl; - //LineRasterizerAA rasterizer(image); - //rasterizer.render(geom,stroke_.get_color()); + if (stroke_.has_dash()) + { + + agg::conv_dash > dash(geom); + dash_array const& d = stroke_.get_dash_array(); + dash_array::const_iterator itr = d.begin(); + dash_array::const_iterator end = d.end(); + while (itr != end) + { + dash.add_dash(itr->first, itr->second); + ++itr; + } + agg::conv_stroke > > stroke(dash); + line_join_e join=stroke_.get_line_join(); + if ( join == MITER_JOIN) + stroke.generator().line_join(agg::miter_join); + else if( join == MITER_REVERT_JOIN) + stroke.generator().line_join(agg::miter_join); + else if( join == ROUND_JOIN) + stroke.generator().line_join(agg::round_join); + else + stroke.generator().line_join(agg::bevel_join); + + line_cap_e cap=stroke_.get_line_cap(); + if (cap == BUTT_CAP) + stroke.generator().line_cap(agg::butt_cap); + else if (cap == SQUARE_CAP) + stroke.generator().line_cap(agg::square_cap); + else + stroke.generator().line_cap(agg::round_cap); + + stroke.generator().miter_limit(4.0); + stroke.generator().width(stroke_.get_width()); + + ras.clip_box(0,0,image.width(),image.height()); + ras.add_path(stroke); + ren.color(agg::rgba(r, g, b, stroke_.get_opacity())); + agg::render_scanlines(ras, sl, ren); } else { + agg::conv_stroke > stroke(geom); - //typedef agg::renderer_base ren_base; - - typedef agg::renderer_scanline_aa_solid renderer; - renderer ren(renb); - - agg::rasterizer_scanline_aa<> ras; - agg::scanline_u8 sl; - - if (stroke_.has_dash()) - { + line_join_e join=stroke_.get_line_join(); + if ( join == MITER_JOIN) + stroke.generator().line_join(agg::miter_join); + else if( join == MITER_REVERT_JOIN) + stroke.generator().line_join(agg::miter_join); + else if( join == ROUND_JOIN) + stroke.generator().line_join(agg::round_join); + else + stroke.generator().line_join(agg::bevel_join); - agg::conv_dash > dash(geom); - dash_array const& d = stroke_.get_dash_array(); - dash_array::const_iterator itr = d.begin(); - dash_array::const_iterator end = d.end(); - while (itr != end) - { - dash.add_dash(itr->first, itr->second); - ++itr; - } - agg::conv_stroke > > stroke(dash); - - line_join_e join=stroke_.get_line_join(); - if ( join == MITER_JOIN) - stroke.generator().line_join(agg::miter_join); - else if( join == MITER_REVERT_JOIN) - stroke.generator().line_join(agg::miter_join); - else if( join == ROUND_JOIN) - stroke.generator().line_join(agg::round_join); - else - stroke.generator().line_join(agg::bevel_join); - - line_cap_e cap=stroke_.get_line_cap(); - if (cap == BUTT_CAP) - stroke.generator().line_cap(agg::butt_cap); - else if (cap == SQUARE_CAP) - stroke.generator().line_cap(agg::square_cap); - else - stroke.generator().line_cap(agg::round_cap); - - stroke.generator().miter_limit(4.0); - stroke.generator().width(stroke_.get_width()); - - ras.clip_box(0,0,image.width(),image.height()); - ras.add_path(stroke); - ren.color(agg::rgba(r, g, b, stroke_.get_opacity())); - agg::render_scanlines(ras, sl, ren); - } + line_cap_e cap=stroke_.get_line_cap(); + if (cap == BUTT_CAP) + stroke.generator().line_cap(agg::butt_cap); + else if (cap == SQUARE_CAP) + stroke.generator().line_cap(agg::square_cap); else - { - agg::conv_stroke > stroke(geom); - - line_join_e join=stroke_.get_line_join(); - if ( join == MITER_JOIN) - stroke.generator().line_join(agg::miter_join); - else if( join == MITER_REVERT_JOIN) - stroke.generator().line_join(agg::miter_join); - else if( join == ROUND_JOIN) - stroke.generator().line_join(agg::round_join); - else - stroke.generator().line_join(agg::bevel_join); - - line_cap_e cap=stroke_.get_line_cap(); - if (cap == BUTT_CAP) - stroke.generator().line_cap(agg::butt_cap); - else if (cap == SQUARE_CAP) - stroke.generator().line_cap(agg::square_cap); - else - stroke.generator().line_cap(agg::round_cap); + stroke.generator().line_cap(agg::round_cap); - stroke.generator().miter_limit(4.0); - stroke.generator().width(stroke_.get_width()); + stroke.generator().miter_limit(4.0); + stroke.generator().width(stroke_.get_width()); - ras.clip_box(0,0,image.width(),image.height()); - ras.add_path(stroke); - ren.color(agg::rgba(r, g, b, stroke_.get_opacity())); - agg::render_scanlines(ras, sl, ren); - } + ras.clip_box(0,0,image.width(),image.height()); + ras.add_path(stroke); + ren.color(agg::rgba(r, g, b, stroke_.get_opacity())); + agg::render_scanlines(ras, sl, ren); } - } - private: - line_symbolizer(const line_symbolizer&); - line_symbolizer& operator=(const line_symbolizer&); }; } diff --git a/include/regex_filter.hpp b/include/regex_filter.hpp index 807990dc9..b13139b65 100644 --- a/include/regex_filter.hpp +++ b/include/regex_filter.hpp @@ -25,6 +25,7 @@ #include "expression.hpp" #include +#include namespace mapnik { diff --git a/include/style_cache.hpp b/include/style_cache.hpp index a71e77758..425fda8f8 100644 --- a/include/style_cache.hpp +++ b/include/style_cache.hpp @@ -27,22 +27,7 @@ #include "feature_type_style.hpp" namespace mapnik { - - class style_cache : public singleton - { - friend class CreateStatic; - private: - static std::map styles_; - style_cache(); - ~style_cache(); - style_cache(const style_cache&); - style_cache& operator=(const style_cache&); - public: - static bool insert(const std::string& name,const Style& style); - static void remove(const std::string& name); - static const Style& find(const std::string& name); - }; - + class named_style_cache : public singleton { friend class CreateStatic; diff --git a/include/utils.hpp b/include/utils.hpp index 2bc6237bb..87afb518f 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -29,11 +29,12 @@ #include #include +#include + namespace mapnik { - class Mutex; - class Lock; - + using boost::mutex; + template class CreateUsingNew { @@ -90,7 +91,7 @@ namespace mapnik throw std::runtime_error("dead reference!"); } protected: - static Mutex mutex_; + static mutex mutex_; singleton() {} virtual ~singleton() { @@ -102,7 +103,7 @@ namespace mapnik { if (!pInstance_) { - Lock lock(&mutex_); + mutex::scoped_lock lock(mutex_); if (!pInstance_) { if (destroyed_) @@ -120,7 +121,7 @@ namespace mapnik }; template class CreatePolicy> Mutex singleton::mutex_; + template class CreatePolicy> mutex singleton::mutex_; template class CreatePolicy> T* singleton::pInstance_=0; template lock(); - } - - ~Lock() - { - if (mutex_) - mutex_->unlock(); - } - private: - Lock(); - Lock(const Lock&); - Lock& operator=(const Lock&); - void* operator new(std::size_t); - void* operator new[](std::size_t); - void operator delete(void*); - void operator delete[](void*); - Lock* operator&(); - }; struct timer { @@ -239,7 +187,7 @@ namespace mapnik std::cout<= pos_) return; unsigned block = pos >> block_shift; value_type* vertex = vertexs_[block] + (( pos & block_mask) << 1); - *vertex=t.forward_x(*vertex); + t.forward_x(vertex); ++vertex; - *vertex=t.forward_y(*vertex); + t.forward_y(vertex); } private: diff --git a/src/SConscript b/src/SConscript index 16acf8425..4c4b9625b 100644 --- a/src/SConscript +++ b/src/SConscript @@ -30,7 +30,7 @@ freetype2_root = env['FREETYPE2_ROOT'] headers =[ '#include',boost_root,freetype2_root,agg_headers] -libraries=['rt','z','png','ltdl','jpeg','tiff','agg','boost-filesystem','boost-regex','boost-serialization'] +libraries=['rt','z','png','ltdl','jpeg','tiff','agg','boost-filesystem','boost-regex','boost-serialization','boost-thread'] libpaths = [prefix+'/lib','#agg'] linkflags = '-Wl,-rpath-link,. -Wl,-soname,libmapnik.so' @@ -43,15 +43,12 @@ source = Split( image_reader.cpp image_util.cpp layer.cpp - line_aa.cpp map.cpp memory.cpp params.cpp plugin.cpp png_reader.cpp render.cpp - scanline_aa.cpp - scanline.cpp style_cache.cpp style.cpp text.cpp diff --git a/src/datasource_cache.cpp b/src/datasource_cache.cpp index 63c40be6c..250820113 100644 --- a/src/datasource_cache.cpp +++ b/src/datasource_cache.cpp @@ -22,6 +22,8 @@ #include #include + +#include #include namespace mapnik @@ -88,7 +90,8 @@ namespace mapnik void datasource_cache::register_datasources(const std::string& str) { - Lock lock(&mutex_); + mutex::scoped_lock lock(mapnik::singleton::mutex_); filesystem::path path(str); filesystem::directory_iterator end_itr; if (exists(path)) diff --git a/src/map.cpp b/src/map.cpp index 5e9e833e6..a5f48a351 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -140,6 +140,7 @@ namespace mapnik double h = factor * currentExtent_.height(); currentExtent_ = Envelope(center.x - 0.5 * w, center.y - 0.5 * h, center.x + 0.5 * w, center.y + 0.5 * h); + fixAspectRatio(); } void Map::zoomToBox(const Envelope &box) @@ -170,10 +171,14 @@ namespace mapnik void Map::pan(int x,int y) { - CoordTransform t(width_,height_,currentExtent_); - coord2d pt(x,y); - t.backward(pt); - currentExtent_.re_center(pt.x,pt.y); + int dx = x - int(0.5 * width_); + int dy = int(0.5 * height_) - y; + double s = width_/currentExtent_.width(); + double minx = currentExtent_.minx() + dx/s; + double maxx = currentExtent_.maxx() + dx/s; + double miny = currentExtent_.miny() + dy/s; + double maxy = currentExtent_.maxy() + dy/s; + currentExtent_.init(minx,miny,maxx,maxy); } void Map::pan_and_zoom(int x,int y,double factor) diff --git a/src/render.cpp b/src/render.cpp index a85027ede..0b29b7f24 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -50,7 +50,6 @@ namespace mapnik std::set names; attribute_collector collector(names); property_index indexer(names); - query q(bbox,width,height); double scale = 1.0/t.scale(); std::vector if_rules; @@ -138,28 +137,6 @@ namespace mapnik } } } - - //if (l.isSelectable() && l.selection().size()) //TODO !!! - //{ - //volatile style_cache* styles=style_cache::instance(); - // const Style& style=style_cache::instance()->find(l.selection_style()); - - // std::vector >& selection=l.selection(); - - // Style::Iterator pos = style.begin(); - // if (pos!=style.end()) { - // std::vector >::iterator itr=selection.begin(); - // - // while (itr!=selection.end()) - // { - // geometry_ptr& geom=(*itr)->get_geometry(); - // geom->transform(t); - // (*pos)->render(*geom,image); - // ++itr; - // } - // } - // l.clear_selection(); - //} } } } @@ -187,27 +164,27 @@ namespace mapnik } template - void Renderer::render(const Map& map,Image& image) + void Renderer::render(Map const& map,Image& image) { timer clock; ////////////////////////////////////////////////////// - const Envelope& extent=map.getCurrentExtent(); + Envelope const& extent=map.getCurrentExtent(); std::cout<<"BBOX:"< namespace mapnik { - - style_cache::style_cache() {} - style_cache::~style_cache() {} - - std::map style_cache::styles_; - - bool style_cache::insert(const std::string& name,const Style& style) - { - Lock lock(&mutex_); - return styles_.insert(make_pair(name,style)).second; - } - - void style_cache::remove(const std::string& name) - { - Lock lock(&mutex_); - styles_.erase(name); - } - - const Style& style_cache::find(const std::string& name) - { - Lock lock(&mutex_); - std::map::iterator itr=styles_.find(name); - if (itr!=styles_.end()) - { - return itr->second; - } - static const Style default_style(boost::shared_ptr(new line_symbolizer(Color(255,0,0)))); - return default_style; - } - //////////////////////////////////////////////////////////////////////////// named_style_cache::named_style_cache() {} named_style_cache::~named_style_cache() {} @@ -60,19 +31,19 @@ namespace mapnik bool named_style_cache::insert(const std::string& name,const feature_type_style& style) { - Lock lock(&mutex_); + mutex::scoped_lock lock(mutex_); return styles_.insert(make_pair(name,style)).second; } void named_style_cache::remove(const std::string& name) { - Lock lock(&mutex_); + mutex::scoped_lock lock(mutex_); styles_.erase(name); } feature_type_style named_style_cache::find(const std::string& name) { - Lock lock(&mutex_); + mutex::scoped_lock lock(mutex_); std::map::iterator itr=styles_.find(name); if (itr!=styles_.end()) {