diff --git a/bindings/python/mapnik_datasource_cache.cpp b/bindings/python/mapnik_datasource_cache.cpp index 531a329de..29ec61c98 100644 --- a/bindings/python/mapnik_datasource_cache.cpp +++ b/bindings/python/mapnik_datasource_cache.cpp @@ -33,15 +33,15 @@ void export_datasource_cache() using namespace boost::python; class_,boost::noncopyable>("Singleton",no_init) .def("instance",&singleton::instance, - return_value_policy()) + return_value_policy()) .staticmethod("instance") ; - + class_ >, boost::noncopyable>("DatasourceCache",no_init) .def("create",&datasource_cache::create) .staticmethod("create") - .def("register_datasources",&datasource_cache::register_datasources) - .staticmethod("register_datasources") + .def("register_datasources",&datasource_cache::register_datasources) + .staticmethod("register_datasources") ; } diff --git a/bindings/python/mapnik_envelope.cpp b/bindings/python/mapnik_envelope.cpp index 63e56e0a1..836cbc095 100644 --- a/bindings/python/mapnik_envelope.cpp +++ b/bindings/python/mapnik_envelope.cpp @@ -60,29 +60,32 @@ bool (Envelope::*intersects_p3)(Envelope const&) const = &Envelo void export_envelope() { using namespace boost::python; - class_ >("Envelope","A spacial envelope (i.e. bounding box) which also defines some basic operators.",init()) + class_ >("Envelope", + "A spacial envelope (i.e. bounding box) " + "which also defines some basic operators." , + init()) .def(init<>()) - .def(init&, const coord&>()) + .def(init&, const coord&>()) .add_property("minx",&Envelope::minx, "X coordinate for the lower left corner") .add_property("miny",&Envelope::miny, "Y coordinate for the lower left corner") .add_property("maxx",&Envelope::maxx, "X coordinate for the upper right corner") .add_property("maxy",&Envelope::maxy, "Y coordinate for the upper right corner") .def("center",&Envelope::center) - .def("center",&Envelope::re_center) - .def("width",width_p1) - .def("width",width_p2) - .def("height",height_p1) - .def("height",height_p2) - .def("expand_to_include",expand_to_include_p1) - .def("expand_to_include",expand_to_include_p2) - .def("expand_to_include",expand_to_include_p3) - .def("contains",contains_p1) - .def("contains",contains_p2) - .def("contains",contains_p3) - .def("intersects",intersects_p1) - .def("intersects",intersects_p2) - .def("intersects",intersects_p3) - .def(self == self) + .def("center",&Envelope::re_center) + .def("width",width_p1) + .def("width",width_p2) + .def("height",height_p1) + .def("height",height_p2) + .def("expand_to_include",expand_to_include_p1) + .def("expand_to_include",expand_to_include_p2) + .def("expand_to_include",expand_to_include_p3) + .def("contains",contains_p1) + .def("contains",contains_p2) + .def("contains",contains_p3) + .def("intersects",intersects_p1) + .def("intersects",intersects_p2) + .def("intersects",intersects_p3) + .def(self == self) .def_pickle(envelope_pickle_suite()) ; } diff --git a/bindings/python/mapnik_filter.cpp b/bindings/python/mapnik_filter.cpp index 4039ce467..12271cc25 100644 --- a/bindings/python/mapnik_filter.cpp +++ b/bindings/python/mapnik_filter.cpp @@ -28,7 +28,6 @@ #include #include #include -#include using mapnik::filter; using mapnik::filter_ptr; diff --git a/bindings/python/mapnik_layer.cpp b/bindings/python/mapnik_layer.cpp index 941f5e422..04cd2d601 100644 --- a/bindings/python/mapnik_layer.cpp +++ b/bindings/python/mapnik_layer.cpp @@ -30,76 +30,6 @@ using mapnik::Layer; using mapnik::parameters; -struct layer_pickle_suite : boost::python::pickle_suite -{ - - static boost::python::tuple - getinitargs(const Layer& l) - { - using namespace boost::python; - return boost::python::make_tuple(l.params()); - } - static boost::python::tuple - getstate(const Layer& l) - { - using namespace boost::python; - - std::vector const& styles=l.styles(); - std::vector::const_iterator itr=styles.begin(); - boost::python::list py_styles; - - while (itr!=styles.end()) - { - py_styles.append(*itr++); - } - - return boost::python::make_tuple(l.getMinZoom(), - l.getMaxZoom(), - py_styles); - } - - static void - setstate (Layer& l, boost::python::tuple state) - { - using namespace boost::python; - if (len(state) != 3) - { - PyErr_SetObject(PyExc_ValueError, - ("expected 3-item tuple in call to __setstate__; got %s" - % state).ptr() - ); - throw_error_already_set(); - } - - l.setMinZoom(extract(state[0])); - l.setMaxZoom(extract(state[1])); - - boost::python::list styles=extract(state[2]); - for (int i=0;i(styles[i])); - } - } -}; - -namespace -{ - //user-friendly wrapper that uses Python dictionary - using namespace boost::python; - Layer create_layer(const dict& d) - { - parameters params; - boost::python::list keys=d.keys(); - for (int i=0;i(keys[i]); - std::string value=extract(d[key]); - params[key] = value; - } - return Layer(params); - } -} - void export_layer() { using namespace boost::python; @@ -107,17 +37,42 @@ void export_layer() .def(vector_indexing_suite,true >()) ; - class_("Layer","A map layer.",no_init) - .def("name",&Layer::name,return_value_policy(), "Return the name of the layer.") - .def("title",&Layer::title,return_value_policy(), "Return the title of the layer.") - .def("abstract",&Layer::abstract,return_value_policy(), "Return the abstract of the layer.") - .def("params",&Layer::params,return_value_policy(), "The configuration parameters of the layer. These vary depending on the type of data source.") - .def("envelope",&Layer::envelope, "Return the geographic envelope/bounding box of the data in the layer.") - .add_property("minzoom",&Layer::getMinZoom,&Layer::setMinZoom) - .add_property("maxzoom",&Layer::getMaxZoom,&Layer::setMaxZoom) - .add_property("styles",make_function - (&Layer::styles,return_value_policy())) - .def_pickle(layer_pickle_suite()) + class_("Layer","A map layer.", init()) + .add_property("name", + make_function(&Layer::name, return_value_policy()), + &Layer::set_name, + "Get/Set the name of the layer.") + + .add_property("title", + make_function(&Layer::title, return_value_policy()), + &Layer::set_title, + "Get/Set the title of the layer.") + + .add_property("abstract", + make_function(&Layer::abstract,return_value_policy()), + &Layer::set_abstract, + "Get/Set the abstract of the layer.") + + .add_property("minzoom", + &Layer::getMinZoom, + &Layer::setMinZoom) + + .add_property("maxzoom", + &Layer::getMaxZoom, + &Layer::setMaxZoom) + + .add_property("styles", + make_function(&Layer::styles, + return_value_policy())) + + .add_property("datasource", + &Layer::datasource, + &Layer::set_datasource, + "The datasource attached to this layer") + + .def("envelope",&Layer::envelope, + "Return the geographic envelope/bounding box " + "of the data in the layer.") + ; - def("CreateLayer",&create_layer); } diff --git a/bindings/python/mapnik_python.cpp b/bindings/python/mapnik_python.cpp index 1f8913ddc..441b1ae62 100644 --- a/bindings/python/mapnik_python.cpp +++ b/bindings/python/mapnik_python.cpp @@ -25,8 +25,6 @@ #include #include -//#include - void export_color(); void export_layer(); void export_parameters(); @@ -49,12 +47,10 @@ void export_raster_symbolizer(); void export_text_symbolizer(); void export_font_engine(); -//using namespace mapnik; #include #include #include -//#include -//#include +#include void render_to_file(const mapnik::Map& map, const std::string& file, @@ -72,6 +68,25 @@ void render(const mapnik::Map& map,mapnik::Image32& image) ren.apply(); } +namespace +{ + //user-friendly wrapper that uses Python dictionary + using namespace boost::python; + boost::shared_ptr create_datasource(const dict& d) + { + mapnik::parameters params; + boost::python::list keys=d.keys(); + for (int i=0; i(keys[i]); + std::string value=extract(d[key]); + params[key] = value; + } + + return mapnik::datasource_cache::create(params); + } +} + BOOST_PYTHON_MODULE(_mapnik) { using namespace boost::python; @@ -87,11 +102,16 @@ BOOST_PYTHON_MODULE(_mapnik) ; class_, - boost::noncopyable>("Datasource",no_init) - .def("envelope",&datasource::envelope, - return_value_policy()) - .def("features",&datasource::features) - ; + boost::noncopyable>("Datasource",no_init) + .def("envelope",&datasource::envelope, + return_value_policy()) + .def("features",&datasource::features) + .def("params",&datasource::params,return_value_policy(), + "The configuration parameters of the data source. " + "These vary depending on the type of data source.") + ; + + def("CreateDatasource",&create_datasource); export_parameters(); export_color(); @@ -111,13 +131,14 @@ BOOST_PYTHON_MODULE(_mapnik) export_raster_symbolizer(); export_text_symbolizer(); export_font_engine(); + class_ >("Coord",init()) .def_readwrite("x", &coord::x) .def_readwrite("y", &coord::y) ; - + export_map(); - + def("render_to_file",&render_to_file); def("render",&render); register_ptr_to_python(); diff --git a/bindings/python/mapnik_style.cpp b/bindings/python/mapnik_style.cpp index 5b2b8243a..3fe4924d0 100644 --- a/bindings/python/mapnik_style.cpp +++ b/bindings/python/mapnik_style.cpp @@ -34,13 +34,13 @@ void export_style() using mapnik::rules; class_("Rules",init<>("default ctor")) - .def(vector_indexing_suite()) - ; + .def(vector_indexing_suite()) + ; class_("Style",init<>("default style constructor")) - .add_property("rules",make_function - (&feature_type_style::get_rules, - return_value_policy())) - ; + .add_property("rules",make_function + (&feature_type_style::get_rules, + return_value_policy())) + ; } diff --git a/demo/c++/rundemo.cpp b/demo/c++/rundemo.cpp index 2f1a51c75..36427b822 100644 --- a/demo/c++/rundemo.cpp +++ b/demo/c++/rundemo.cpp @@ -1,5 +1,13 @@ -#include +#include + +#include +#include +#include +#include +#include +#include + #include using namespace mapnik; @@ -133,11 +141,11 @@ int main ( int argc , char** argv) // Provincial polygons { parameters p; - p["name"]="Provinces"; p["type"]="shape"; p["file"]="../data/boundaries"; - Layer lyr(p); + Layer lyr("Provinces"); + lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.add_style("provinces"); m.addLayer(lyr); } @@ -145,21 +153,21 @@ int main ( int argc , char** argv) // Drainage { parameters p; - p["name"]="Quebec Hydrography"; p["type"]="shape"; p["file"]="../data/qcdrainage"; - - Layer lyr(p); + Layer lyr("Quebec Hydrography"); + lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.add_style("drainage"); m.addLayer(lyr); } + { parameters p; - p["name"]="Ontario Hydrography"; p["type"]="shape"; p["file"]="../data/ontdrainage"; - Layer lyr(p); + Layer lyr("Ontario Hydrography"); + lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.add_style("drainage"); m.addLayer(lyr); } @@ -167,11 +175,10 @@ int main ( int argc , char** argv) // Provincial boundaries { parameters p; - p["name"]="Provincial borders"; p["type"]="shape"; p["file"]="../data/boundaries_l"; - - Layer lyr(p); + Layer lyr("Provincial borders"); + lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.add_style("provlines"); m.addLayer(lyr); } @@ -179,29 +186,29 @@ int main ( int argc , char** argv) // Roads { parameters p; - p["name"]="Roads"; p["type"]="shape"; - p["file"]="../data/roads"; - - Layer lyr(p); + p["file"]="../data/roads"; + Layer lyr("Roads"); + lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.add_style("smallroads"); lyr.add_style("road-border"); lyr.add_style("road-fill"); lyr.add_style("highway-border"); lyr.add_style("highway-fill"); + m.addLayer(lyr); } // popplaces { parameters p; - p["name"]="Populated Places"; p["type"]="shape"; p["file"]="../data/popplaces"; - - Layer lyr(p); + Layer lyr("Populated Places"); + lyr.set_datasource(datasource_cache::instance()->create(p)); lyr.add_style("popplaces"); m.addLayer(lyr); } + m.zoomToBox(Envelope(1405120.04127408,-247003.813399447,1706357.31328276,-25098.593149577)); Image32 buf(m.getWidth(),m.getHeight()); diff --git a/demo/python/rundemo.py b/demo/python/rundemo.py index af17c0967..bc36b14c0 100644 --- a/demo/python/rundemo.py +++ b/demo/python/rundemo.py @@ -55,7 +55,8 @@ m.background = Color('white') # password='mypassword' # table= TODO -provpoly_lyr = Layer(name='Provinces', type='shape', file='../data/boundaries') +provpoly_lyr = Layer('Provinces') +provpoly_lyr.datasource = Datasource(type='shape', file='../data/boundaries') # We then define a style for the layer. A layer can have one or many styles. # Styles are named, so they can be shared across different layers. @@ -118,8 +119,10 @@ m.layers.append(provpoly_lyr) # A simple example ... -qcdrain_lyr = Layer(name='Quebec Hydrography', type='shape', - file='../data/qcdrainage') +qcdrain_lyr = Layer('Quebec Hydrography') + +qcdrain_lyr.datasource = Datasource( type='shape', + file='../data/qcdrainage') qcdrain_style = Style() qcdrain_rule = Rule() @@ -135,15 +138,18 @@ m.layers.append(qcdrain_lyr) # attributes, and same desired style), so we're going to # re-use the style defined in the above layer for the next one. -ondrain_lyr = Layer(name='Ontario Hydrography', type='shape', - file='../data/ontdrainage') +ondrain_lyr = Layer('Ontario Hydrography') +ondrain_lyr.datasource = Datasource(type='shape', + file='../data/ontdrainage') + ondrain_lyr.styles.append('drainage') m.layers.append(ondrain_lyr) # Provincial boundaries -provlines_lyr = Layer(name='Provincial borders', type='shape', - file='../data/boundaries_l') +provlines_lyr = Layer('Provincial borders') +provlines_lyr.datasource = Datasource (type='shape', + file='../data/boundaries_l') # Here we define a "dash dot dot dash" pattern for the provincial boundaries. @@ -165,7 +171,8 @@ m.layers.append(provlines_lyr) # Roads 3 and 4 (The "grey" roads) -roads34_lyr = Layer(name='Roads', type='shape', file='../data/roads') +roads34_lyr = Layer('Roads') +roads34_lyr.datasource = Datasource(type='shape', file='../data/roads') roads34_style = Style() roads34_rule = Rule() @@ -195,7 +202,8 @@ m.layers.append(roads34_lyr) # Roads 2 (The thin yellow ones) -roads2_lyr = Layer(name='Roads', type='shape', file='../data/roads') +roads2_lyr = Layer('Roads') +roads2_lyr.datasource = Datasource (type='shape', file='../data/roads') roads2_style_1 = Style() roads2_rule_1 = Rule() @@ -228,7 +236,8 @@ m.layers.append(roads2_lyr) # Roads 1 (The big orange ones, the highways) -roads1_lyr = Layer(name='Roads', type='shape', file='../data/roads') +roads1_lyr = Layer('Roads') +roads1_lyr.datasource = Datasource(type='shape', file='../data/roads') roads1_style_1 = Style() roads1_rule_1 = Rule() @@ -260,8 +269,9 @@ m.layers.append(roads1_lyr) # Populated Places -popplaces_lyr = Layer(name='Populated Places', type='shape', - file='../data/popplaces') +popplaces_lyr = Layer('Populated Places') +popplaces_lyr.datasource = Datasource (type='shape', + file='../data/popplaces') popplaces_style = Style() popplaces_rule = Rule() diff --git a/include/color_factory.hpp b/include/color_factory.hpp index df1d69abc..bcf9928ac 100644 --- a/include/color_factory.hpp +++ b/include/color_factory.hpp @@ -25,6 +25,7 @@ #ifndef COLOR_FACTORY_HPP #define COLOR_FACTORY_HPP +#include "config.hpp" #include "css_color_parser.hpp" namespace mapnik @@ -33,19 +34,19 @@ namespace mapnik class MAPNIK_DECL color_factory { public: - static Color from_string(char const* css_color) - { - Color color; - actions a(color); - css_color_grammar > grammar(a); - parse_info<> info = parse(css_color, grammar, space_p); - if (info.full) return color; - return Color(0,0,0); - } + static Color from_string(char const* css_color) + { + Color color; + actions a(color); + css_color_grammar > grammar(a); + parse_info<> info = parse(css_color, grammar, space_p); + if (info.full) return color; + return Color(0,0,0); + } private: - color_factory(); - color_factory(color_factory const&); - color_factory& operator=(color_factory const&); + color_factory(); + color_factory(color_factory const&); + color_factory& operator=(color_factory const&); }; } diff --git a/include/filter_factory.hpp b/include/filter_factory.hpp index 5f0effc9c..7a1ec0e93 100644 --- a/include/filter_factory.hpp +++ b/include/filter_factory.hpp @@ -35,24 +35,26 @@ namespace mapnik class MAPNIK_DECL filter_factory { public: - static filter_ptr compile(string const& str) - { - stack > > filters; - stack > > 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()) - { - return filters.top(); - } - else - { - clog << "failed at :" << info.stop << "\n"; - return filter_ptr(new none_filter()); - } - } + static filter_ptr compile(string const& str) + { + stack > > filters; + stack > > 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()) + { + return filters.top(); + } + else + { + clog << "failed at :" << info.stop << "\n"; + return filter_ptr(new none_filter()); + } + } }; + + MAPNIK_DECL filter_ptr create_filter (std::string const& wkt); } #endif //FILTER_FACTORY_HPP diff --git a/include/filter_parser.hpp b/include/filter_parser.hpp index 28e77aa24..c4b1b8214 100644 --- a/include/filter_parser.hpp +++ b/include/filter_parser.hpp @@ -42,7 +42,7 @@ #include "expression.hpp" #include "filter.hpp" #include "regex_filter.hpp" - +#include "logical.hpp" using namespace boost::spirit; using std::string; diff --git a/include/layer.hpp b/include/layer.hpp index 7d6269032..d0ccdebc1 100644 --- a/include/layer.hpp +++ b/include/layer.hpp @@ -15,11 +15,10 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * #include -License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -* -*****************************************************************************/ + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ //$Id: layer.hpp 39 2005-04-10 20:39:53Z pavlenko $ #ifndef LAYER_HPP @@ -34,7 +33,6 @@ namespace mapnik { class MAPNIK_DECL Layer { - parameters params_; std::string name_; std::string title_; std::string abstract_; @@ -42,20 +40,18 @@ namespace mapnik double maxZoom_; bool active_; bool selectable_; - + std::vector styles_; std::string selection_style_; - + mutable std::vector > selection_; mutable datasource_p ds_; public: - Layer(); - explicit Layer(const parameters& params); + explicit Layer(std::string const& name); Layer(Layer const& l); Layer& operator=(Layer const& l); bool operator==(Layer const& other) const; - parameters const& params() const; void set_name(std::string const& name); const std::string& name() const; void set_title(std::string const& title); @@ -79,9 +75,9 @@ namespace mapnik std::vector >& selection() const; void clear_selection() const; void set_datasource(datasource_p const& ds); - datasource_p const& datasource() const; + datasource_p datasource() const; Envelope envelope() const; - virtual ~Layer(); + ~Layer(); private: void swap(const Layer& other); }; diff --git a/include/map.hpp b/include/map.hpp index 9f458419a..e0cd5799c 100644 --- a/include/map.hpp +++ b/include/map.hpp @@ -43,8 +43,8 @@ namespace mapnik Envelope currentExtent_; public: - - typedef std::map::const_iterator style_iterator; + + typedef std::map::const_iterator style_iterator; Map(); Map(int width,int height,int srid=-1); @@ -76,7 +76,7 @@ namespace mapnik void pan_and_zoom(int x,int y,double zoom); const Envelope& getCurrentExtent() const; double scale() const; - virtual ~Map(); + ~Map(); private: void fixAspectRatio(); }; diff --git a/include/mapnik.hpp b/include/mapnik.hpp deleted file mode 100644 index 7281bded4..000000000 --- a/include/mapnik.hpp +++ /dev/null @@ -1,84 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2006 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -//$Id: mapnik.hpp 39 2005-04-10 20:39:53Z pavlenko $ - -#ifndef MAPNIK_HPP -#define MAPNIK_HPP - -#include -#include -#include - -#include "global.hpp" -#include "factory.hpp" -#include "filter.hpp" -#include "query.hpp" -#include "rule.hpp" -#include "spatial.hpp" -#include "logical.hpp" -#include "comparison.hpp" -#include "regex_filter.hpp" -#include "utils.hpp" -#include "geometry.hpp" -#include "geom_util.hpp" -#include "raster.hpp" -#include "feature.hpp" -#include "attribute.hpp" -#include "attribute_collector.hpp" -#include "graphics.hpp" -#include "image_reader.hpp" -#include "line_symbolizer.hpp" -#include "polygon_symbolizer.hpp" -#include "agg_renderer.hpp" -#include "polygon_pattern_symbolizer.hpp" -#include "line_pattern_symbolizer.hpp" -#include "point_symbolizer.hpp" -#include "raster_symbolizer.hpp" -#include "text_symbolizer.hpp" -#include "image_util.hpp" -#include "datasource.hpp" -#include "layer.hpp" -#include "datasource_cache.hpp" -#include "wkb.hpp" -#include "map.hpp" -#include "feature_type_style.hpp" -#include "feature_factory.hpp" -#include "math_expr.hpp" -#include "value.hpp" -#include "expression.hpp" -#include "filter_visitor.hpp" -#include "filter_parser.hpp" -#include "filter_factory.hpp" -#include "text_symbolizer.hpp" -#include "label_placement.hpp" -#include "feature_layer_desc.hpp" -#include "css_color_parser.hpp" -#include "color_factory.hpp" -#include "config.hpp" - -namespace mapnik -{ - MAPNIK_DECL filter_ptr create_filter (std::string const& wkt); -} - -#endif //MAPNIK_HPP diff --git a/src/SConscript b/src/SConscript index ac7ab1abd..7f2e8bbc6 100644 --- a/src/SConscript +++ b/src/SConscript @@ -32,7 +32,6 @@ linkflags = '-Wl,-rpath-link,. -Wl,-soname,libmapnik.so' source = Split( """ - mapnik.cpp datasource_cache.cpp envelope.cpp graphics.cpp diff --git a/src/datasource_cache.cpp b/src/datasource_cache.cpp index 3d37fd8d2..62c8cb60e 100644 --- a/src/datasource_cache.cpp +++ b/src/datasource_cache.cpp @@ -1,4 +1,4 @@ - /***************************************************************************** +/***************************************************************************** * * This file is part of Mapnik (c++ mapping toolkit) * @@ -75,26 +75,26 @@ namespace mapnik } std::clog<<"datasource="<(new PluginInfo(type,module)))).second; + return plugins_.insert(make_pair(type,boost::shared_ptr(new PluginInfo(type,module)))).second; } void datasource_cache::register_datasources(const std::string& str) { mutex::scoped_lock lock(mapnik::singleton::mutex_); + mapnik::CreateStatic>::mutex_); filesystem::path path(str); filesystem::directory_iterator end_itr; if (exists(path)) diff --git a/src/mapnik.cpp b/src/filter_factory.cpp similarity index 97% rename from src/mapnik.cpp rename to src/filter_factory.cpp index 6512751f3..c55814fa1 100644 --- a/src/mapnik.cpp +++ b/src/filter_factory.cpp @@ -19,10 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ - //$Id$ -#include "mapnik.hpp" +#include "filter_factory.hpp" namespace mapnik { @@ -32,5 +31,3 @@ namespace mapnik return factory.compile(wkt); } } - - diff --git a/src/layer.cpp b/src/layer.cpp index 94a15032b..0952a737e 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -34,9 +34,8 @@ namespace mapnik { using namespace std; - Layer::Layer() - : params_(), - name_("unknown"), + Layer::Layer(std::string const& name) + : name_(name), title_(""), abstract_(""), minZoom_(0), @@ -45,31 +44,18 @@ namespace mapnik selectable_(false), selection_style_("default_selection") {} - - Layer::Layer(const parameters& params) - :params_(params), - name_(params_["name"]), - title_(params_["title"]), - abstract_(params_["abstract"]), - minZoom_(0), - maxZoom_(std::numeric_limits::max()), - active_(true), - selectable_(false), - selection_style_("default_selection") - {} Layer::Layer(const Layer& rhs) - :params_(rhs.params_), - name_(rhs.name_), - title_(rhs.title_), - abstract_(rhs.abstract_), - minZoom_(rhs.minZoom_), - maxZoom_(rhs.maxZoom_), - active_(rhs.active_), - selectable_(rhs.selectable_), - ds_(rhs.ds_), - styles_(rhs.styles_), - selection_style_(rhs.selection_style_) {} + : name_(rhs.name_), + title_(rhs.title_), + abstract_(rhs.abstract_), + minZoom_(rhs.minZoom_), + maxZoom_(rhs.maxZoom_), + active_(rhs.active_), + selectable_(rhs.selectable_), + styles_(rhs.styles_), + ds_(rhs.ds_), + selection_style_(rhs.selection_style_) {} Layer& Layer::operator=(const Layer& rhs) { @@ -85,7 +71,6 @@ namespace mapnik void Layer::swap(const Layer& rhs) { - params_=rhs.params_; name_=rhs.name_; title_=rhs.title_; abstract_=rhs.abstract_; @@ -93,17 +78,12 @@ namespace mapnik maxZoom_=rhs.maxZoom_; active_=rhs.active_; selectable_=rhs.selectable_; - ds_=rhs.ds_; styles_=rhs.styles_; + ds_=rhs.ds_; selection_style_=rhs.selection_style_; } - + Layer::~Layer() {} - - parameters const& Layer::params() const - { - return params_; - } void Layer::set_name( std::string const& name) { @@ -124,7 +104,7 @@ namespace mapnik { return title_; } - + void Layer::set_abstract( std::string const& abstract) { abstract_ = abstract; @@ -190,22 +170,11 @@ namespace mapnik return selectable_; } - const datasource_p& Layer::datasource() const + datasource_p Layer::datasource() const { - if (!ds_) - { - try - { - ds_=datasource_cache::instance()->create(params_); - } - catch (...) - { - std::clog << "exception caught : can not create datasource" << std::endl; - } - } return ds_; } - // TODO: !!!! + void Layer::set_datasource(datasource_p const& ds) { ds_ = ds; @@ -213,14 +182,10 @@ namespace mapnik Envelope Layer::envelope() const { - datasource_p const& ds = datasource(); - if (ds) - { - return ds->envelope(); - } + if (ds_) return ds_->envelope(); return Envelope(); } - + void Layer::selection_style(const std::string& name) { selection_style_=name; diff --git a/src/map.cpp b/src/map.cpp index aa1fd4f9d..86144db81 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -251,6 +251,6 @@ namespace mapnik return currentExtent_.width()/width_; return currentExtent_.width(); } - + Map::~Map() {} }