Merge branch 'master' into harfbuzz

Conflicts:
	src/symbolizer_helpers.cpp
This commit is contained in:
Hermann Kraus 2012-09-08 01:26:47 +02:00
commit 297bfeb454
41 changed files with 177 additions and 186 deletions

View file

@ -6,6 +6,11 @@ Developers: Please commit along with changes.
For a complete change history, see the git log. For a complete change history, see the git log.
## Future
- Fixed zoom_all behavior when Map maximum-extent is provided. Previously maximum-extent was used outright but
now the combined layer extents will be again respected: they will be clipped to the maximum-extent if possible
and only when back-projecting fails for all layers will the maximum-extent be used as a fallback (#1473)
## Mapnik 2.1.0 ## Mapnik 2.1.0

View file

@ -81,7 +81,7 @@ boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
} }
} }
return mapnik::datasource_cache::instance()->create(params, bind); return mapnik::datasource_cache::instance().create(params, bind);
} }
boost::python::dict describe(boost::shared_ptr<mapnik::datasource> const& ds) boost::python::dict describe(boost::shared_ptr<mapnik::datasource> const& ds)

View file

@ -61,22 +61,22 @@ boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
} }
} }
return mapnik::datasource_cache::instance()->create(params, bind); return mapnik::datasource_cache::instance().create(params, bind);
} }
void register_datasources(std::string const& path) void register_datasources(std::string const& path)
{ {
mapnik::datasource_cache::instance()->register_datasources(path); mapnik::datasource_cache::instance().register_datasources(path);
} }
std::vector<std::string> plugin_names() std::vector<std::string> plugin_names()
{ {
return mapnik::datasource_cache::instance()->plugin_names(); return mapnik::datasource_cache::instance().plugin_names();
} }
std::string plugin_directories() std::string plugin_directories()
{ {
return mapnik::datasource_cache::instance()->plugin_directories(); return mapnik::datasource_cache::instance().plugin_directories();
} }
} }

View file

@ -77,7 +77,7 @@ struct layer_pickle_suite : boost::python::pickle_suite
l.set_queryable(extract<bool>(state[3])); l.set_queryable(extract<bool>(state[3]));
mapnik::parameters params = extract<parameters>(state[4]); mapnik::parameters params = extract<parameters>(state[4]);
l.set_datasource(datasource_cache::instance()->create(params)); l.set_datasource(datasource_cache::instance().create(params));
boost::python::list s = extract<boost::python::list>(state[5]); boost::python::list s = extract<boost::python::list>(state[5]);
for (int i=0;i<len(s);++i) for (int i=0;i<len(s);++i)

View file

@ -54,11 +54,11 @@ void set_marker_type(mapnik::markers_symbolizer & symbolizer, std::string const&
std::string filename; std::string filename;
if (marker_type == "ellipse") if (marker_type == "ellipse")
{ {
filename = mapnik::marker_cache::known_svg_prefix_ + "ellipse"; filename = mapnik::marker_cache::instance().known_svg_prefix_ + "ellipse";
} }
else if (marker_type == "arrow") else if (marker_type == "arrow")
{ {
filename = mapnik::marker_cache::known_svg_prefix_ + "arrow"; filename = mapnik::marker_cache::instance().known_svg_prefix_ + "arrow";
} }
else else
{ {

View file

@ -96,8 +96,8 @@ void export_logger();
void clear_cache() void clear_cache()
{ {
mapnik::marker_cache::instance()->clear(); mapnik::marker_cache::instance().clear();
mapnik::mapped_memory_cache::instance()->clear(); mapnik::mapped_memory_cache::instance().clear();
} }
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO) #if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)

View file

@ -56,7 +56,7 @@ int main ( int argc , char** argv)
std::cout << " running demo ... \n"; std::cout << " running demo ... \n";
std::string mapnik_dir(argv[1]); std::string mapnik_dir(argv[1]);
std::cout << " looking for 'shape.input' plugin in... " << mapnik_dir << "/input/" << "\n"; std::cout << " looking for 'shape.input' plugin in... " << mapnik_dir << "/input/" << "\n";
datasource_cache::instance()->register_datasources(mapnik_dir + "/input/"); datasource_cache::instance().register_datasources(mapnik_dir + "/input/");
std::cout << " looking for DejaVuSans font in... " << mapnik_dir << "/fonts/DejaVuSans.ttf" << "\n"; std::cout << " looking for DejaVuSans font in... " << mapnik_dir << "/fonts/DejaVuSans.ttf" << "\n";
freetype_engine::register_font(mapnik_dir + "/fonts/DejaVuSans.ttf"); freetype_engine::register_font(mapnik_dir + "/fonts/DejaVuSans.ttf");
@ -182,7 +182,7 @@ int main ( int argc , char** argv)
p["encoding"]="latin1"; p["encoding"]="latin1";
layer lyr("Provinces"); layer lyr("Provinces");
lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("provinces"); lyr.add_style("provinces");
m.addLayer(lyr); m.addLayer(lyr);
} }
@ -193,7 +193,7 @@ int main ( int argc , char** argv)
p["type"]="shape"; p["type"]="shape";
p["file"]="../data/qcdrainage"; p["file"]="../data/qcdrainage";
layer lyr("Quebec Hydrography"); layer lyr("Quebec Hydrography");
lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("drainage"); lyr.add_style("drainage");
m.addLayer(lyr); m.addLayer(lyr);
} }
@ -204,7 +204,7 @@ int main ( int argc , char** argv)
p["file"]="../data/ontdrainage"; p["file"]="../data/ontdrainage";
layer lyr("Ontario Hydrography"); layer lyr("Ontario Hydrography");
lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("drainage"); lyr.add_style("drainage");
m.addLayer(lyr); m.addLayer(lyr);
} }
@ -215,7 +215,7 @@ int main ( int argc , char** argv)
p["type"]="shape"; p["type"]="shape";
p["file"]="../data/boundaries_l"; p["file"]="../data/boundaries_l";
layer lyr("Provincial borders"); layer lyr("Provincial borders");
lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("provlines"); lyr.add_style("provlines");
m.addLayer(lyr); m.addLayer(lyr);
} }
@ -226,7 +226,7 @@ int main ( int argc , char** argv)
p["type"]="shape"; p["type"]="shape";
p["file"]="../data/roads"; p["file"]="../data/roads";
layer lyr("Roads"); layer lyr("Roads");
lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("smallroads"); lyr.add_style("smallroads");
lyr.add_style("road-border"); lyr.add_style("road-border");
lyr.add_style("road-fill"); lyr.add_style("road-fill");
@ -242,7 +242,7 @@ int main ( int argc , char** argv)
p["file"]="../data/popplaces"; p["file"]="../data/popplaces";
p["encoding"] = "latin1"; p["encoding"] = "latin1";
layer lyr("Populated Places"); layer lyr("Populated Places");
lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("popplaces"); lyr.add_style("popplaces");
m.addLayer(lyr); m.addLayer(lyr);
} }
@ -258,7 +258,7 @@ int main ( int argc , char** argv)
save_to_file(buf,"demo.png","png"); save_to_file(buf,"demo.png","png");
save_to_file(buf,"demo256.png","png256"); save_to_file(buf,"demo256.png","png256");
save_to_file(buf,"demo.tif","tiff"); save_to_file(buf,"demo.tif","tiff");
std::cout << "Three maps have been rendered using AGG in the current directory:\n" std::cout << "Three maps have been rendered using AGG in the current directory:\n"
"- demo.jpg\n" "- demo.jpg\n"
"- demo.png\n" "- demo.png\n"

View file

@ -45,7 +45,7 @@ int main( int argc, char **argv )
// register input plug-ins // register input plug-ins
QString plugins_dir = settings.value("mapnik/plugins_dir", QString plugins_dir = settings.value("mapnik/plugins_dir",
QVariant("/usr/local/lib/mapnik/input/")).toString(); QVariant("/usr/local/lib/mapnik/input/")).toString();
datasource_cache::instance()->register_datasources(plugins_dir.toStdString()); datasource_cache::instance().register_datasources(plugins_dir.toStdString());
// register fonts // register fonts
int count = settings.beginReadArray("mapnik/fonts"); int count = settings.beginReadArray("mapnik/fonts");
for (int index=0; index < count; ++index) for (int index=0; index < count; ++index)

View file

@ -36,28 +36,27 @@
// stl // stl
#include <map> #include <map>
namespace mapnik { namespace detail { namespace mapnik {
class MAPNIK_DECL datasource_cache_impl
class MAPNIK_DECL datasource_cache
: public singleton<datasource_cache, CreateStatic>,
private boost::noncopyable
{ {
friend class CreateStatic<datasource_cache>;
public: public:
datasource_cache_impl();
~datasource_cache_impl();
std::vector<std::string> plugin_names(); std::vector<std::string> plugin_names();
std::string plugin_directories(); std::string plugin_directories();
void register_datasources(std::string const& path); void register_datasources(std::string const& path);
bool register_datasource(std::string const& path); bool register_datasource(std::string const& path);
boost::shared_ptr<datasource> create(parameters const& params, bool bind=true); boost::shared_ptr<datasource> create(parameters const& params, bool bind=true);
private: private:
datasource_cache();
~datasource_cache();
std::map<std::string,boost::shared_ptr<PluginInfo> > plugins_; std::map<std::string,boost::shared_ptr<PluginInfo> > plugins_;
bool registered_; bool registered_;
bool insert(std::string const& name,const lt_dlhandle module); bool insert(std::string const& name,const lt_dlhandle module);
std::vector<std::string> plugin_directories_; std::vector<std::string> plugin_directories_;
}; };
} }
typedef singleton<detail::datasource_cache_impl, CreateStatic> datasource_cache;
}
#endif // MAPNIK_DATASOURCE_CACHE_HPP #endif // MAPNIK_DATASOURCE_CACHE_HPP

View file

@ -42,17 +42,16 @@ using namespace boost::interprocess;
typedef boost::shared_ptr<mapped_region> mapped_region_ptr; typedef boost::shared_ptr<mapped_region> mapped_region_ptr;
struct MAPNIK_DECL mapped_memory_cache : struct MAPNIK_DECL mapped_memory_cache :
public singleton <mapped_memory_cache, CreateStatic>, public singleton<mapped_memory_cache, CreateStatic>,
private boost::noncopyable private boost::noncopyable
{ {
friend class CreateStatic<mapped_memory_cache>; friend class CreateStatic<mapped_memory_cache>;
static boost::unordered_map<std::string,mapped_region_ptr> cache_; boost::unordered_map<std::string,mapped_region_ptr> cache_;
static bool insert(std::string const& key, mapped_region_ptr); bool insert(std::string const& key, mapped_region_ptr);
static boost::optional<mapped_region_ptr> find(std::string const& key, bool update_cache = false); boost::optional<mapped_region_ptr> find(std::string const& key, bool update_cache = false);
static void clear(); void clear();
}; };
} }
#endif // MAPNIK_MAPPED_MEMORY_CACHE_HPP #endif // MAPNIK_MAPPED_MEMORY_CACHE_HPP

View file

@ -49,15 +49,15 @@ class MAPNIK_DECL marker_cache :
private: private:
marker_cache(); marker_cache();
~marker_cache(); ~marker_cache();
static bool insert_marker(std::string const& key, marker_ptr path); bool insert_marker(std::string const& key, marker_ptr path);
static boost::unordered_map<std::string,marker_ptr> marker_cache_; boost::unordered_map<std::string,marker_ptr> marker_cache_;
static bool insert_svg(std::string const& name, std::string const& svg_string); bool insert_svg(std::string const& name, std::string const& svg_string);
static boost::unordered_map<std::string,std::string> svg_cache_; boost::unordered_map<std::string,std::string> svg_cache_;
public: public:
static std::string known_svg_prefix_; std::string known_svg_prefix_;
static bool is_uri(std::string const& path); bool is_uri(std::string const& path);
static boost::optional<marker_ptr> find(std::string const& key, bool update_cache = false); boost::optional<marker_ptr> find(std::string const& key, bool update_cache = false);
static void clear(); void clear();
}; };
} }

View file

@ -129,7 +129,7 @@ protected:
#endif #endif
singleton() {} singleton() {}
public: public:
static T* instance() static T& instance()
{ {
if (! pInstance_) if (! pInstance_)
{ {
@ -151,7 +151,7 @@ public:
} }
} }
} }
return pInstance_; return *pInstance_;
} }
}; };
#ifdef MAPNIK_THREADSAFE #ifdef MAPNIK_THREADSAFE

View file

@ -64,7 +64,7 @@ ogr_index_featureset<filterT>::ogr_index_featureset(mapnik::context_ptr const &
fidcolumn_(layer_.GetFIDColumn()) fidcolumn_(layer_.GetFIDColumn())
{ {
boost::optional<mapnik::mapped_region_ptr> memory = mapnik::mapped_memory_cache::find(index_file.c_str(),true); boost::optional<mapnik::mapped_region_ptr> memory = mapnik::mapped_memory_cache::instance().find(index_file.c_str(),true);
if (memory) if (memory)
{ {
boost::interprocess::ibufferstream file(static_cast<char*>((*memory)->get_address()),(*memory)->get_size()); boost::interprocess::ibufferstream file(static_cast<char*>((*memory)->get_address()),(*memory)->get_size());

View file

@ -320,7 +320,7 @@ void MapSource::setOSMLayers(Map& m, const parameters &p)
if(boost::get<std::string>(q["type"])=="osm") if(boost::get<std::string>(q["type"])=="osm")
{ {
m.getLayer(count).set_datasource m.getLayer(count).set_datasource
(datasource_cache::instance()->create(p)); (datasource_cache::instance().create(p));
} }
} }
} }
@ -353,7 +353,7 @@ void MapSource::addSRTMLayers(Map& m,double w,double s,double e,double n)
<<(lon>=0 ? lon:-lon)<<"c10"; <<(lon>=0 ? lon:-lon)<<"c10";
p["file"] = str.str(); p["file"] = str.str();
cerr<<"ADDING SRTM LAYER: " << p["file"] << endl; cerr<<"ADDING SRTM LAYER: " << p["file"] << endl;
m.getLayer(i).set_datasource(datasource_cache::instance()->create(p)); m.getLayer(i).set_datasource(datasource_cache::instance().create(p));
// do we have more than one srtm layer? // do we have more than one srtm layer?
if(floor(w) != floor(e) || floor(s) != floor(n)) if(floor(w) != floor(e) || floor(s) != floor(n))
@ -385,7 +385,7 @@ void MapSource::addSRTMLayers(Map& m,double w,double s,double e,double n)
lyr.add_style("contours"); lyr.add_style("contours");
lyr.add_style("contours-text"); lyr.add_style("contours-text");
lyr.set_datasource lyr.set_datasource
(datasource_cache::instance()->create(p)); (datasource_cache::instance().create(p));
m.addLayer(lyr); m.addLayer(lyr);
} }
} }

View file

@ -32,7 +32,7 @@ int main(int argc,char *argv[])
exit(1); exit(1);
} }
datasource_cache::instance()->register_datasources datasource_cache::instance().register_datasources
("/usr/local/lib/mapnik/input"); ("/usr/local/lib/mapnik/input");
freetype_engine::register_font freetype_engine::register_font
("/usr/local/lib/mapnik/fonts/DejaVuSans.ttf"); ("/usr/local/lib/mapnik/fonts/DejaVuSans.ttf");

View file

@ -43,7 +43,7 @@ int main(int argc,char *argv[])
exit(0); exit(0);
} }
mapnik::datasource_cache::instance()->register_datasources("/usr/local/lib/mapnik/input"); mapnik::datasource_cache::instance().register_datasources("/usr/local/lib/mapnik/input");
mapnik::freetype_engine::register_font("/usr/local/lib/mapnik/fonts/DejaVuSans.ttf"); mapnik::freetype_engine::register_font("/usr/local/lib/mapnik/fonts/DejaVuSans.ttf");
mapnik::Map m(800, 800); mapnik::Map m(800, 800);
@ -57,7 +57,7 @@ int main(int argc,char *argv[])
for (int count = 0; count < m.layer_count(); count++) for (int count = 0; count < m.layer_count(); count++)
{ {
mapnik::parameters q = m.getLayer(count).datasource()->params(); mapnik::parameters q = m.getLayer(count).datasource()->params();
m.getLayer(count).set_datasource(mapnik::datasource_cache::instance()->create(p)); m.getLayer(count).set_datasource(mapnik::datasource_cache::instance().create(p));
} }
} }

View file

@ -120,10 +120,8 @@ void postgis_datasource::bind() const
boost::optional<mapnik::boolean> simplify_opt = params_.get<mapnik::boolean>("simplify_geometries", false); boost::optional<mapnik::boolean> simplify_opt = params_.get<mapnik::boolean>("simplify_geometries", false);
simplify_geometries_ = simplify_opt && *simplify_opt; simplify_geometries_ = simplify_opt && *simplify_opt;
ConnectionManager* mgr = ConnectionManager::instance(); ConnectionManager::instance().registerPool(creator_, *initial_size, *max_size);
mgr->registerPool(creator_, *initial_size, *max_size); shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id());
shared_ptr< Pool<Connection,ConnectionCreator> > pool = mgr->getPool(creator_.id());
if (pool) if (pool)
{ {
shared_ptr<Connection> conn = pool->borrowObject(); shared_ptr<Connection> conn = pool->borrowObject();
@ -430,8 +428,7 @@ postgis_datasource::~postgis_datasource()
{ {
if (is_bound_ && ! persist_connection_) if (is_bound_ && ! persist_connection_)
{ {
ConnectionManager* mgr = ConnectionManager::instance(); shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id());
shared_ptr< Pool<Connection,ConnectionCreator> > pool = mgr->getPool(creator_.id());
if (pool) if (pool)
{ {
shared_ptr<Connection> conn = pool->borrowObject(); shared_ptr<Connection> conn = pool->borrowObject();
@ -613,8 +610,7 @@ featureset_ptr postgis_datasource::features(const query& q) const
box2d<double> const& box = q.get_bbox(); box2d<double> const& box = q.get_bbox();
double scale_denom = q.scale_denominator(); double scale_denom = q.scale_denominator();
ConnectionManager* mgr = ConnectionManager::instance(); shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id());
shared_ptr< Pool<Connection,ConnectionCreator> > pool = mgr->getPool(creator_.id());
if (pool) if (pool)
{ {
shared_ptr<Connection> conn = pool->borrowObject(); shared_ptr<Connection> conn = pool->borrowObject();
@ -723,9 +719,7 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt) const
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "postgis_datasource::features_at_point"); mapnik::progress_timer __stats__(std::clog, "postgis_datasource::features_at_point");
#endif #endif
shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id());
ConnectionManager* mgr = ConnectionManager::instance();
shared_ptr< Pool<Connection,ConnectionCreator> > pool = mgr->getPool(creator_.id());
if (pool) if (pool)
{ {
shared_ptr<Connection> conn = pool->borrowObject(); shared_ptr<Connection> conn = pool->borrowObject();
@ -814,8 +808,7 @@ box2d<double> postgis_datasource::envelope() const
bind(); bind();
} }
ConnectionManager* mgr = ConnectionManager::instance(); shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id());
shared_ptr< Pool<Connection,ConnectionCreator> > pool = mgr->getPool(creator_.id());
if (pool) if (pool)
{ {
shared_ptr<Connection> conn = pool->borrowObject(); shared_ptr<Connection> conn = pool->borrowObject();
@ -915,8 +908,7 @@ boost::optional<mapnik::datasource::geometry_t> postgis_datasource::get_geometry
boost::optional<mapnik::datasource::geometry_t> result; boost::optional<mapnik::datasource::geometry_t> result;
ConnectionManager* mgr = ConnectionManager::instance(); shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id());
shared_ptr< Pool<Connection,ConnectionCreator> > pool = mgr->getPool(creator_.id());
if (pool) if (pool)
{ {
shared_ptr<Connection> conn = pool->borrowObject(); shared_ptr<Connection> conn = pool->borrowObject();

View file

@ -34,6 +34,8 @@
#include <string> #include <string>
using mapnik::mapped_memory_cache;
dbf_file::dbf_file() dbf_file::dbf_file()
: num_records_(0), : num_records_(0),
num_fields_(0), num_fields_(0),
@ -53,7 +55,7 @@ dbf_file::dbf_file(std::string const& file_name)
{ {
#ifdef SHAPE_MEMORY_MAPPED_FILE #ifdef SHAPE_MEMORY_MAPPED_FILE
boost::optional<mapnik::mapped_region_ptr> memory = mapnik::mapped_memory_cache::find(file_name.c_str(),true); boost::optional<mapnik::mapped_region_ptr> memory = mapped_memory_cache::instance().find(file_name.c_str(),true);
if (memory) if (memory)
{ {
file_.buffer(static_cast<char*>((*memory)->get_address()),(*memory)->get_size()); file_.buffer(static_cast<char*>((*memory)->get_address()),(*memory)->get_size());

View file

@ -155,7 +155,7 @@ public:
{ {
#ifdef SHAPE_MEMORY_MAPPED_FILE #ifdef SHAPE_MEMORY_MAPPED_FILE
boost::optional<mapnik::mapped_region_ptr> memory = boost::optional<mapnik::mapped_region_ptr> memory =
mapnik::mapped_memory_cache::find(file_name.c_str(),true); mapnik::mapped_memory_cache::instance().find(file_name.c_str(),true);
if (memory) if (memory)
{ {

View file

@ -137,7 +137,7 @@ void agg_renderer<T>::setup(Map const &m)
boost::optional<std::string> const& image_filename = m.background_image(); boost::optional<std::string> const& image_filename = m.background_image();
if (image_filename) if (image_filename)
{ {
boost::optional<mapnik::marker_ptr> bg_marker = mapnik::marker_cache::instance()->find(*image_filename,true); boost::optional<mapnik::marker_ptr> bg_marker = mapnik::marker_cache::instance().find(*image_filename,true);
if (bg_marker && (*bg_marker)->is_bitmap()) if (bg_marker && (*bg_marker)->is_bitmap())
{ {
mapnik::image_ptr bg_image = *(*bg_marker)->get_bitmap_data(); mapnik::image_ptr bg_image = *(*bg_marker)->get_bitmap_data();

View file

@ -67,7 +67,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature); std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<marker_ptr> mark = marker_cache::instance()->find(filename,true); boost::optional<marker_ptr> mark = marker_cache::instance().find(filename,true);
if (!mark) return; if (!mark) return;
if (!(*mark)->is_bitmap()) if (!(*mark)->is_bitmap())

View file

@ -75,7 +75,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
if (!filename.empty()) if (!filename.empty())
{ {
boost::optional<marker_ptr> mark = mapnik::marker_cache::instance()->find(filename, true); boost::optional<marker_ptr> mark = mapnik::marker_cache::instance().find(filename, true);
if (mark && *mark) if (mark && *mark)
{ {
ras_ptr->reset(); ras_ptr->reset();

View file

@ -52,7 +52,7 @@ void agg_renderer<T>::process(point_symbolizer const& sym,
boost::optional<mapnik::marker_ptr> marker; boost::optional<mapnik::marker_ptr> marker;
if ( !filename.empty() ) if ( !filename.empty() )
{ {
marker = marker_cache::instance()->find(filename, true); marker = marker_cache::instance().find(filename, true);
} }
else else
{ {

View file

@ -63,7 +63,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
boost::optional<mapnik::marker_ptr> marker; boost::optional<mapnik::marker_ptr> marker;
if ( !filename.empty() ) if ( !filename.empty() )
{ {
marker = marker_cache::instance()->find(filename, true); marker = marker_cache::instance().find(filename, true);
} }
else else
{ {

View file

@ -1170,7 +1170,7 @@ void cairo_renderer_base::process(point_symbolizer const& sym,
boost::optional<marker_ptr> marker; boost::optional<marker_ptr> marker;
if ( !filename.empty() ) if ( !filename.empty() )
{ {
marker = marker_cache::instance()->find(filename, true); marker = marker_cache::instance().find(filename, true);
} }
else else
{ {
@ -1266,7 +1266,7 @@ void cairo_renderer_base::process(line_pattern_symbolizer const& sym,
typedef coord_transform<CoordTransform,clipped_geometry_type> path_type; typedef coord_transform<CoordTransform,clipped_geometry_type> path_type;
std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature); std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<mapnik::marker_ptr> marker = mapnik::marker_cache::instance()->find(filename,true); boost::optional<mapnik::marker_ptr> marker = mapnik::marker_cache::instance().find(filename,true);
if (!marker && !(*marker)->is_bitmap()) return; if (!marker && !(*marker)->is_bitmap()) return;
unsigned width((*marker)->width()); unsigned width((*marker)->width());
@ -1343,7 +1343,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym,
context.set_operator(sym.comp_op()); context.set_operator(sym.comp_op());
std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature); std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<mapnik::marker_ptr> marker = mapnik::marker_cache::instance()->find(filename,true); boost::optional<mapnik::marker_ptr> marker = mapnik::marker_cache::instance().find(filename,true);
if (!marker && !(*marker)->is_bitmap()) return; if (!marker && !(*marker)->is_bitmap()) return;
cairo_pattern pattern(**((*marker)->get_bitmap_data())); cairo_pattern pattern(**((*marker)->get_bitmap_data()));
@ -1640,7 +1640,7 @@ void cairo_renderer_base::process(markers_symbolizer const& sym,
if (!filename.empty()) if (!filename.empty())
{ {
boost::optional<marker_ptr> mark = mapnik::marker_cache::instance()->find(filename, true); boost::optional<marker_ptr> mark = mapnik::marker_cache::instance().find(filename, true);
if (mark && *mark) if (mark && *mark)
{ {
agg::trans_affine geom_tr; agg::trans_affine geom_tr;

View file

@ -38,7 +38,7 @@
#include <iostream> #include <iostream>
#include <stdexcept> #include <stdexcept>
namespace mapnik { namespace detail { namespace mapnik {
bool is_input_plugin (std::string const& filename) bool is_input_plugin (std::string const& filename)
{ {
@ -46,21 +46,17 @@ bool is_input_plugin (std::string const& filename)
} }
datasource_cache_impl::datasource_cache_impl() datasource_cache::datasource_cache()
{ {
if (lt_dlinit()) throw std::runtime_error("lt_dlinit() failed"); if (lt_dlinit()) throw std::runtime_error("lt_dlinit() failed");
} }
datasource_cache_impl::~datasource_cache_impl() datasource_cache::~datasource_cache()
{ {
lt_dlexit(); lt_dlexit();
} }
//std::map<std::string,boost::shared_ptr<PluginInfo> > datasource_cache::plugins_; datasource_ptr datasource_cache::create(const parameters& params, bool bind)
//bool datasource_cache::registered_=false;
//std::vector<std::string> datasource_cache::plugin_directories_;
datasource_ptr datasource_cache_impl::create(const parameters& params, bool bind)
{ {
boost::optional<std::string> type = params.get<std::string>("type"); boost::optional<std::string> type = params.get<std::string>("type");
if ( ! type) if ( ! type)
@ -70,7 +66,7 @@ datasource_ptr datasource_cache_impl::create(const parameters& params, bool bind
} }
#ifdef MAPNIK_THREADSAFE #ifdef MAPNIK_THREADSAFE
//mutex::scoped_lock lock(mutex_); mutex::scoped_lock lock(mutex_);
#endif #endif
datasource_ptr ds; datasource_ptr ds;
@ -101,34 +97,34 @@ datasource_ptr datasource_cache_impl::create(const parameters& params, bool bind
} }
#ifdef MAPNIK_LOG #ifdef MAPNIK_LOG
MAPNIK_LOG_DEBUG(datasource_cache_impl) << "datasource_cache: Size=" << params.size(); MAPNIK_LOG_DEBUG(datasource_cache) << "datasource_cache: Size=" << params.size();
parameters::const_iterator i = params.begin(); parameters::const_iterator i = params.begin();
for (; i != params.end(); ++i) for (; i != params.end(); ++i)
{ {
MAPNIK_LOG_DEBUG(datasource_cache_impl) << "datasource_cache: -- " << i->first << "=" << i->second; MAPNIK_LOG_DEBUG(datasource_cache) << "datasource_cache: -- " << i->first << "=" << i->second;
} }
#endif #endif
ds = datasource_ptr(create_datasource(params, bind), datasource_deleter()); ds = datasource_ptr(create_datasource(params, bind), datasource_deleter());
MAPNIK_LOG_DEBUG(datasource_cache_impl) << "datasource_cache: Datasource=" << ds << " type=" << type; MAPNIK_LOG_DEBUG(datasource_cache) << "datasource_cache: Datasource=" << ds << " type=" << type;
return ds; return ds;
} }
bool datasource_cache_impl::insert(std::string const& type,const lt_dlhandle module) bool datasource_cache::insert(std::string const& type,const lt_dlhandle module)
{ {
return plugins_.insert(make_pair(type,boost::make_shared<PluginInfo> return plugins_.insert(make_pair(type,boost::make_shared<PluginInfo>
(type,module))).second; (type,module))).second;
} }
std::string datasource_cache_impl::plugin_directories() std::string datasource_cache::plugin_directories()
{ {
return boost::algorithm::join(plugin_directories_,", "); return boost::algorithm::join(plugin_directories_,", ");
} }
std::vector<std::string> datasource_cache_impl::plugin_names() std::vector<std::string> datasource_cache::plugin_names()
{ {
std::vector<std::string> names; std::vector<std::string> names;
std::map<std::string,boost::shared_ptr<PluginInfo> >::const_iterator itr; std::map<std::string,boost::shared_ptr<PluginInfo> >::const_iterator itr;
@ -139,11 +135,10 @@ std::vector<std::string> datasource_cache_impl::plugin_names()
return names; return names;
} }
void datasource_cache_impl::register_datasources(std::string const& str) void datasource_cache::register_datasources(std::string const& str)
{ {
#ifdef MAPNIK_THREADSAFE #ifdef MAPNIK_THREADSAFE
//mutex::scoped_lock lock(mapnik::singleton<mapnik::datasource_cache, mutex::scoped_lock lock(mutex_);
// mapnik::CreateStatic>::mutex_);
#endif #endif
boost::filesystem::path path(str); boost::filesystem::path path(str);
// TODO - only push unique paths // TODO - only push unique paths
@ -174,7 +169,7 @@ void datasource_cache_impl::register_datasources(std::string const& str)
} }
} }
bool datasource_cache_impl::register_datasource(std::string const& str) bool datasource_cache::register_datasource(std::string const& str)
{ {
bool success = false; bool success = false;
try try
@ -215,4 +210,4 @@ bool datasource_cache_impl::register_datasource(std::string const& str)
return success; return success;
} }
}} }

View file

@ -101,7 +101,7 @@ namespace mapnik { namespace util {
parameters p(ds_in->params()); parameters p(ds_in->params());
// TODO : re-use datasource extent if already set. // TODO : re-use datasource extent if already set.
datasource_ptr ds_out = datasource_cache::instance()->create(p); datasource_ptr ds_out = datasource_cache::instance().create(p);
if (ds_out) if (ds_out)
{ {
lyr_out.set_datasource(ds_out); lyr_out.set_datasource(ds_out);

View file

@ -50,7 +50,7 @@ node_ptr node::from_xml(xml_node const& xml)
{ {
continue; continue;
} }
node_ptr n = registry::instance()->from_xml(*itr); node_ptr n = registry::instance().from_xml(*itr);
if (n) list->push_back(n); if (n) list->push_back(n);
} }
if (list->get_children().size() == 1) { if (list->get_children().size() == 1) {

View file

@ -94,7 +94,7 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
if (!filename.empty()) if (!filename.empty())
{ {
boost::optional<marker_ptr> mark = mapnik::marker_cache::instance()->find(filename, true); boost::optional<marker_ptr> mark = mapnik::marker_cache::instance().find(filename, true);
if (mark && *mark) if (mark && *mark)
{ {
ras_ptr->reset(); ras_ptr->reset();

View file

@ -54,7 +54,7 @@ void grid_renderer<T>::process(point_symbolizer const& sym,
boost::optional<mapnik::marker_ptr> marker; boost::optional<mapnik::marker_ptr> marker;
if ( !filename.empty() ) if ( !filename.empty() )
{ {
marker = marker_cache::instance()->find(filename, true); marker = marker_cache::instance().find(filename, true);
} }
else else
{ {

View file

@ -33,12 +33,12 @@ typedef factory<image_reader,std::string,
bool register_image_reader(std::string const& type,image_reader* (* fun)(std::string const&)) bool register_image_reader(std::string const& type,image_reader* (* fun)(std::string const&))
{ {
return ImageReaderFactory::instance()->register_product(type,fun); return ImageReaderFactory::instance().register_product(type,fun);
} }
image_reader* get_image_reader(std::string const& filename,std::string const& type) image_reader* get_image_reader(std::string const& filename,std::string const& type)
{ {
return ImageReaderFactory::instance()->create_object(type,filename); return ImageReaderFactory::instance().create_object(type,filename);
} }
image_reader* get_image_reader(std::string const& filename) image_reader* get_image_reader(std::string const& filename)
@ -46,7 +46,7 @@ image_reader* get_image_reader(std::string const& filename)
boost::optional<std::string> type = type_from_filename(filename); boost::optional<std::string> type = type_from_filename(filename);
if (type) if (type)
{ {
return ImageReaderFactory::instance()->create_object(*type,filename); return ImageReaderFactory::instance().create_object(*type,filename);
} }
return 0; return 0;
} }

View file

@ -700,7 +700,7 @@ void map_parser::parse_layer(Map & map, xml_node const& node)
try try
{ {
boost::shared_ptr<datasource> ds = boost::shared_ptr<datasource> ds =
datasource_cache::instance()->create(params); datasource_cache::instance().create(params);
lyr.set_datasource(ds); lyr.set_datasource(ds);
} }
catch (std::exception const& ex) catch (std::exception const& ex)
@ -960,11 +960,11 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& sym)
{ {
if (*marker_type == "ellipse") if (*marker_type == "ellipse")
{ {
filename = marker_cache::known_svg_prefix_ + "ellipse"; filename = marker_cache::instance().known_svg_prefix_ + "ellipse";
} }
else if (*marker_type == "arrow") else if (*marker_type == "arrow")
{ {
filename = marker_cache::known_svg_prefix_ + "arrow"; filename = marker_cache::instance().known_svg_prefix_ + "arrow";
} }
} }
} }
@ -997,16 +997,16 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& sym)
optional<color> c = sym.get_opt_attr<color>("fill"); optional<color> c = sym.get_opt_attr<color>("fill");
if (c) symbol.set_fill(*c); if (c) symbol.set_fill(*c);
optional<double> spacing = sym.get_opt_attr<double>("spacing"); optional<double> spacing = sym.get_opt_attr<double>("spacing");
if (spacing) symbol.set_spacing(*spacing); if (spacing) symbol.set_spacing(*spacing);
optional<double> max_error = sym.get_opt_attr<double>("max-error"); optional<double> max_error = sym.get_opt_attr<double>("max-error");
if (max_error) symbol.set_max_error(*max_error); if (max_error) symbol.set_max_error(*max_error);
optional<boolean> allow_overlap = sym.get_opt_attr<boolean>("allow-overlap"); optional<boolean> allow_overlap = sym.get_opt_attr<boolean>("allow-overlap");
if (allow_overlap) symbol.set_allow_overlap(*allow_overlap); if (allow_overlap) symbol.set_allow_overlap(*allow_overlap);
optional<boolean> ignore_placement = sym.get_opt_attr<boolean>("ignore-placement"); optional<boolean> ignore_placement = sym.get_opt_attr<boolean>("ignore-placement");
if (ignore_placement) symbol.set_ignore_placement(*ignore_placement); if (ignore_placement) symbol.set_ignore_placement(*ignore_placement);
@ -1129,7 +1129,7 @@ void map_parser::parse_text_symbolizer(rule & rule, xml_node const& sym)
text_placements_ptr placement_finder; text_placements_ptr placement_finder;
optional<std::string> placement_type = sym.get_opt_attr<std::string>("placement-type"); optional<std::string> placement_type = sym.get_opt_attr<std::string>("placement-type");
if (placement_type) { if (placement_type) {
placement_finder = placements::registry::instance()->from_xml(*placement_type, sym, fontsets_); placement_finder = placements::registry::instance().from_xml(*placement_type, sym, fontsets_);
} else { } else {
placement_finder = boost::make_shared<text_placements_dummy>(); placement_finder = boost::make_shared<text_placements_dummy>();
placement_finder->defaults.from_xml(sym, fontsets_); placement_finder->defaults.from_xml(sym, fontsets_);
@ -1158,7 +1158,7 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym)
text_placements_ptr placement_finder; text_placements_ptr placement_finder;
optional<std::string> placement_type = sym.get_opt_attr<std::string>("placement-type"); optional<std::string> placement_type = sym.get_opt_attr<std::string>("placement-type");
if (placement_type) { if (placement_type) {
placement_finder = placements::registry::instance()->from_xml(*placement_type, sym, fontsets_); placement_finder = placements::registry::instance().from_xml(*placement_type, sym, fontsets_);
} else { } else {
placement_finder = boost::make_shared<text_placements_dummy>(); placement_finder = boost::make_shared<text_placements_dummy>();
} }
@ -1599,7 +1599,7 @@ void map_parser::ensure_font_face(std::string const& face_name)
std::string map_parser::ensure_relative_to_xml(boost::optional<std::string> opt_path) std::string map_parser::ensure_relative_to_xml(boost::optional<std::string> opt_path)
{ {
if (marker_cache::is_uri(*opt_path)) if (marker_cache::instance().is_uri(*opt_path))
return *opt_path; return *opt_path;
if (relative_to_xml_) if (relative_to_xml_)
@ -1627,7 +1627,7 @@ std::string map_parser::ensure_relative_to_xml(boost::optional<std::string> opt_
void map_parser::ensure_exists(std::string const& file_path) void map_parser::ensure_exists(std::string const& file_path)
{ {
if (marker_cache::is_uri(file_path)) if (marker_cache::instance().is_uri(file_path))
return; return;
// validate that the filename exists if it is not a dynamic PathExpression // validate that the filename exists if it is not a dynamic PathExpression
if (!boost::algorithm::find_first(file_path,"[") && !boost::algorithm::find_first(file_path,"]")) if (!boost::algorithm::find_first(file_path,"[") && !boost::algorithm::find_first(file_path,"]"))

View file

@ -340,54 +340,59 @@ void Map::zoom(double factor)
void Map::zoom_all() void Map::zoom_all()
{ {
if (maximum_extent_) { try
zoom_to_box(*maximum_extent_);
}
else
{ {
try if (!layers_.size() > 0)
return;
projection proj0(srs_);
box2d<double> ext;
bool success = false;
bool first = true;
std::vector<layer>::const_iterator itr = layers_.begin();
std::vector<layer>::const_iterator end = layers_.end();
while (itr != end)
{ {
if (!layers_.size() > 0) if (itr->active())
return;
projection proj0(srs_);
box2d<double> ext;
bool success = false;
bool first = true;
std::vector<layer>::const_iterator itr = layers_.begin();
std::vector<layer>::const_iterator end = layers_.end();
while (itr != end)
{ {
if (itr->active()) std::string const& layer_srs = itr->srs();
projection proj1(layer_srs);
proj_transform prj_trans(proj0,proj1);
box2d<double> layer_ext = itr->envelope();
if (prj_trans.backward(layer_ext, PROJ_ENVELOPE_POINTS))
{ {
std::string const& layer_srs = itr->srs(); success = true;
projection proj1(layer_srs); MAPNIK_LOG_DEBUG(map) << "map: Layer " << itr->name() << " original ext=" << itr->envelope();
MAPNIK_LOG_DEBUG(map) << "map: Layer " << itr->name() << " transformed to map srs=" << layer_ext;
proj_transform prj_trans(proj0,proj1); if (first)
box2d<double> layer_ext = itr->envelope();
if (prj_trans.backward(layer_ext, PROJ_ENVELOPE_POINTS))
{ {
success = true; ext = layer_ext;
first = false;
MAPNIK_LOG_DEBUG(map) << "map: Layer " << itr->name() << " original ext=" << itr->envelope(); }
MAPNIK_LOG_DEBUG(map) << "map: Layer " << itr->name() << " transformed to map srs=" << layer_ext; else
{
if (first) ext.expand_to_include(layer_ext);
{
ext = layer_ext;
first = false;
}
else
{
ext.expand_to_include(layer_ext);
}
} }
} }
++itr;
} }
if (success) { ++itr;
zoom_to_box(ext); }
} else { if (success)
{
if (maximum_extent_) {
ext.clip(*maximum_extent_);
}
zoom_to_box(ext);
}
else
{
if (maximum_extent_)
{
MAPNIK_LOG_ERROR(map) << "could not zoom to combined layer extents"
<< " so falling back to maximum-extent for zoom_all result";
zoom_to_box(*maximum_extent_);
}
else
{
std::ostringstream s; std::ostringstream s;
s << "could not zoom to combined layer extents " s << "could not zoom to combined layer extents "
<< "using zoom_all because proj4 could not " << "using zoom_all because proj4 could not "
@ -396,10 +401,10 @@ void Map::zoom_all()
throw std::runtime_error(s.str()); throw std::runtime_error(s.str());
} }
} }
catch (proj_init_error & ex) }
{ catch (proj_init_error & ex)
throw mapnik::config_error(std::string("Projection error during map.zoom_all: ") + ex.what()); {
} throw mapnik::config_error(std::string("Projection error during map.zoom_all: ") + ex.what());
} }
} }
@ -544,7 +549,8 @@ featureset_ptr Map::query_point(unsigned index, double x, double y) const
if (fs) if (fs)
{ {
mapnik::box2d<double> map_ex = current_extent_; mapnik::box2d<double> map_ex = current_extent_;
if (maximum_extent_) { if (maximum_extent_)
{
map_ex.clip(*maximum_extent_); map_ex.clip(*maximum_extent_);
} }
if (!prj_trans.backward(map_ex,PROJ_ENVELOPE_POINTS)) if (!prj_trans.backward(map_ex,PROJ_ENVELOPE_POINTS))

View file

@ -33,8 +33,6 @@
namespace mapnik namespace mapnik
{ {
boost::unordered_map<std::string, mapped_region_ptr> mapped_memory_cache::cache_;
void mapped_memory_cache::clear() void mapped_memory_cache::clear()
{ {
#ifdef MAPNIK_THREADSAFE #ifdef MAPNIK_THREADSAFE

View file

@ -45,11 +45,8 @@
namespace mapnik namespace mapnik
{ {
boost::unordered_map<std::string, marker_ptr> marker_cache::marker_cache_;
boost::unordered_map<std::string, std::string> marker_cache::svg_cache_;
std::string marker_cache::known_svg_prefix_ = "shape://";
marker_cache::marker_cache() marker_cache::marker_cache()
: known_svg_prefix_("shape://")
{ {
insert_svg("ellipse", insert_svg("ellipse",
"<?xml version='1.0' standalone='no'?>" "<?xml version='1.0' standalone='no'?>"

View file

@ -267,7 +267,7 @@ void text_symbolizer_helper::init_marker()
boost::optional<marker_ptr> opt_marker; //TODO: Why boost::optional? boost::optional<marker_ptr> opt_marker; //TODO: Why boost::optional?
if (!filename.empty()) if (!filename.empty())
{ {
opt_marker = marker_cache::instance()->find(filename, true); opt_marker = marker_cache::instance().find(filename, true);
} }
marker_ptr m; marker_ptr m;
if (opt_marker) m = *opt_marker; if (opt_marker) m = *opt_marker;

View file

@ -44,11 +44,11 @@ int main( int, char*[] )
std::string csv_plugin("./plugins/input/csv.input"); std::string csv_plugin("./plugins/input/csv.input");
if (boost::filesystem::exists(csv_plugin)) { if (boost::filesystem::exists(csv_plugin)) {
try { try {
mapnik::datasource_cache::instance()->register_datasource(csv_plugin); mapnik::datasource_cache::instance().register_datasource(csv_plugin);
mapnik::parameters p; mapnik::parameters p;
p["type"]="csv"; p["type"]="csv";
p["inline"]="x,y\n0,0"; p["inline"]="x,y\n0,0";
mapnik::datasource_ptr ds = mapnik::datasource_cache::instance()->create(p); mapnik::datasource_ptr ds = mapnik::datasource_cache::instance().create(p);
//mapnik::datasource_ptr ds = boost::make_shared<mapnik::memory_datasource>(); //mapnik::datasource_ptr ds = boost::make_shared<mapnik::memory_datasource>();
//mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>(); //mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
//mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx, 1)); //mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx, 1));
@ -75,29 +75,29 @@ int main( int, char*[] )
std::string shape_plugin("./plugins/input/shape.input"); std::string shape_plugin("./plugins/input/shape.input");
if (boost::filesystem::exists(shape_plugin)) { if (boost::filesystem::exists(shape_plugin)) {
try { try {
mapnik::datasource_cache::instance()->register_datasource(shape_plugin); mapnik::datasource_cache::instance().register_datasource(shape_plugin);
mapnik::parameters p2; mapnik::parameters p2;
p2["type"]="shape"; p2["type"]="shape";
p2["file"]="foo"; p2["file"]="foo";
mapnik::datasource_cache::instance()->create(p2); mapnik::datasource_cache::instance().create(p2);
BOOST_TEST(false); BOOST_TEST(false);
} catch (...) { } catch (...) {
BOOST_TEST(true); BOOST_TEST(true);
} }
} }
/* /*
// not working, oddly segfaults valgrind // not working, oddly segfaults valgrind
try { try {
sqlite3_initialize(); sqlite3_initialize();
// http://stackoverflow.com/questions/11107703/sqlite3-sigsegvs-with-valgrind // http://stackoverflow.com/questions/11107703/sqlite3-sigsegvs-with-valgrind
sqlite3_config(SQLITE_CONFIG_HEAP, malloc (1024*1024), 1024*1024, 64); sqlite3_config(SQLITE_CONFIG_HEAP, malloc (1024*1024), 1024*1024, 64);
mapnik::datasource_cache::instance()->register_datasource("./plugins/input/sqlite.input"); mapnik::datasource_cache::instance().register_datasource("./plugins/input/sqlite.input");
mapnik::parameters p; mapnik::parameters p;
p["type"]="sqlite"; p["type"]="sqlite";
p["file"]="tests/data/sqlite/world.sqlite"; p["file"]="tests/data/sqlite/world.sqlite";
p["table"]="world_merc"; p["table"]="world_merc";
mapnik::datasource_cache::instance()->create(p); mapnik::datasource_cache::instance().create(p);
sqlite3_shutdown(); sqlite3_shutdown();
BOOST_TEST(true); BOOST_TEST(true);
} catch (...) { } catch (...) {

View file

@ -28,7 +28,7 @@ void prepare_map(Map& m)
{ {
const std::string mapnik_dir("/usr/local/lib/mapnik/"); const std::string mapnik_dir("/usr/local/lib/mapnik/");
std::cout << " looking for 'shape.input' plugin in... " << mapnik_dir << "input/" << "\n"; std::cout << " looking for 'shape.input' plugin in... " << mapnik_dir << "input/" << "\n";
datasource_cache::instance()->register_datasources(mapnik_dir + "input/"); datasource_cache::instance().register_datasources(mapnik_dir + "input/");
// create styles // create styles
@ -135,7 +135,7 @@ void prepare_map(Map& m)
p["file"]="../../../demo/data/boundaries"; p["file"]="../../../demo/data/boundaries";
layer lyr("Provinces"); layer lyr("Provinces");
lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("provinces"); lyr.add_style("provinces");
m.addLayer(lyr); m.addLayer(lyr);
} }
@ -146,7 +146,7 @@ void prepare_map(Map& m)
p["type"]="shape"; p["type"]="shape";
p["file"]="../../../demo/data/qcdrainage"; p["file"]="../../../demo/data/qcdrainage";
layer lyr("Quebec Hydrography"); layer lyr("Quebec Hydrography");
lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("drainage"); lyr.add_style("drainage");
m.addLayer(lyr); m.addLayer(lyr);
} }
@ -157,7 +157,7 @@ void prepare_map(Map& m)
p["file"]="../../../demo/data/ontdrainage"; p["file"]="../../../demo/data/ontdrainage";
layer lyr("Ontario Hydrography"); layer lyr("Ontario Hydrography");
lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("drainage"); lyr.add_style("drainage");
m.addLayer(lyr); m.addLayer(lyr);
} }
@ -168,7 +168,7 @@ void prepare_map(Map& m)
p["type"]="shape"; p["type"]="shape";
p["file"]="../../../demo/data/boundaries_l"; p["file"]="../../../demo/data/boundaries_l";
layer lyr("Provincial borders"); layer lyr("Provincial borders");
lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("provlines"); lyr.add_style("provlines");
m.addLayer(lyr); m.addLayer(lyr);
} }
@ -179,7 +179,7 @@ void prepare_map(Map& m)
p["type"]="shape"; p["type"]="shape";
p["file"]="../../../demo/data/roads"; p["file"]="../../../demo/data/roads";
layer lyr("Roads"); layer lyr("Roads");
lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("smallroads"); lyr.add_style("smallroads");
lyr.add_style("road-border"); lyr.add_style("road-border");
lyr.add_style("road-fill"); lyr.add_style("road-fill");

View file

@ -102,7 +102,7 @@ if __name__ == "__main__":
for name in sys.argv[1:]: for name in sys.argv[1:]:
active.append({"name": name}) active.append({"name": name})
if 'osm' in mapnik.DatasourceCache.instance().plugin_names(): if 'osm' in mapnik.DatasourceCache.plugin_names():
for f in files: for f in files:
config = dict(defaults) config = dict(defaults)
config.update(f) config.update(f)

View file

@ -43,7 +43,7 @@ int main (int argc, char ** argv )
std::cerr << "Geometry to WKB converter\n"; std::cerr << "Geometry to WKB converter\n";
mapnik::datasource_cache::instance()->register_datasources("/opt/mapnik/lib/mapnik/input/"); mapnik::datasource_cache::instance().register_datasources("/opt/mapnik/lib/mapnik/input/");
std::string filename(argv[1]); std::string filename(argv[1]);
std::cerr << filename << std::endl; std::cerr << filename << std::endl;
@ -56,7 +56,7 @@ int main (int argc, char ** argv )
try try
{ {
ds = mapnik::datasource_cache::instance()->create(p); ds = mapnik::datasource_cache::instance().create(p);
} }
catch ( ... ) catch ( ... )
{ {
@ -104,5 +104,3 @@ int main (int argc, char ** argv )
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View file

@ -127,7 +127,7 @@ int main (int argc,char** argv)
} }
boost::optional<mapnik::marker_ptr> marker_ptr = boost::optional<mapnik::marker_ptr> marker_ptr =
mapnik::marker_cache::instance()->find(svg_name, false); mapnik::marker_cache::instance().find(svg_name, false);
if (!marker_ptr) if (!marker_ptr)
{ {
std::clog << "svg2png error: could not open: '" << svg_name << "'\n"; std::clog << "svg2png error: could not open: '" << svg_name << "'\n";