Merge branch 'master' into bigint

Conflicts:
	plugins/input/geojson/geojson_datasource.cpp
	plugins/input/postgis/postgis_featureset.cpp
This commit is contained in:
artemp 2012-12-18 13:57:39 +00:00
commit a38b252ccd
126 changed files with 1015 additions and 1042 deletions

View file

@ -1331,7 +1331,7 @@ if not preconfigured:
else: else:
color_print(4,'Not building with cairo support, pass CAIRO=True to enable') color_print(4,'Not building with cairo support, pass CAIRO=True to enable')
if 'python' in env['BINDINGS']: if 'python' in env['BINDINGS'] or 'python' in env['REQUESTED_PLUGINS']:
if not os.access(env['PYTHON'], os.X_OK): if not os.access(env['PYTHON'], os.X_OK):
color_print(1,"Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON']) color_print(1,"Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON'])
Exit(1) Exit(1)
@ -1386,22 +1386,22 @@ if not preconfigured:
else: else:
env['PYTHON_IS_64BIT'] = False env['PYTHON_IS_64BIT'] = False
if py3 and env['BOOST_PYTHON_LIB'] == 'boost_python': if 'python' in env['BINDINGS']:
env['BOOST_PYTHON_LIB'] = 'boost_python3%s' % env['BOOST_APPEND'] if py3 and env['BOOST_PYTHON_LIB'] == 'boost_python':
elif env['BOOST_PYTHON_LIB'] == 'boost_python': env['BOOST_PYTHON_LIB'] = 'boost_python3%s' % env['BOOST_APPEND']
env['BOOST_PYTHON_LIB'] = 'boost_python%s' % env['BOOST_APPEND'] elif env['BOOST_PYTHON_LIB'] == 'boost_python':
env['BOOST_PYTHON_LIB'] = 'boost_python%s' % env['BOOST_APPEND']
if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'):
color_print(1,'Could not find required header files for boost python')
env['MISSING_DEPS'].append('boost python')
if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'): if env['CAIRO']:
color_print(1,'Could not find required header files for boost python') if conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'):
env['MISSING_DEPS'].append('boost python') env['HAS_PYCAIRO'] = True
else:
if env['CAIRO']: env['SKIPPED_DEPS'].extend(['pycairo'])
if conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'):
env['HAS_PYCAIRO'] = True
else: else:
env['SKIPPED_DEPS'].extend(['pycairo']) color_print(4,'Not building with pycairo support, pass CAIRO=True to enable')
else:
color_print(4,'Not building with pycairo support, pass CAIRO=True to enable')
#### End Config Stage for Required Dependencies #### #### End Config Stage for Required Dependencies ####
@ -1526,7 +1526,7 @@ if not preconfigured:
if env['DEBUG_UNDEFINED']: if env['DEBUG_UNDEFINED']:
env.Append(CXXFLAGS = '-fcatch-undefined-behavior -ftrapv -fwrapv') env.Append(CXXFLAGS = '-fcatch-undefined-behavior -ftrapv -fwrapv')
if 'python' in env['BINDINGS']: if 'python' in env['BINDINGS'] or 'python' in env['REQUESTED_PLUGINS']:
majver, minver = env['PYTHON_VERSION'].split('.') majver, minver = env['PYTHON_VERSION'].split('.')
# we don't want the includes it in the main environment... # we don't want the includes it in the main environment...
# as they are later set in the python build.py # as they are later set in the python build.py
@ -1542,9 +1542,10 @@ if not preconfigured:
color_print(1,"Python version 2.2 or greater required") color_print(1,"Python version 2.2 or greater required")
Exit(1) Exit(1)
color_print(4,'Bindings Python version... %s' % env['PYTHON_VERSION']) if 'python' in env['BINDINGS']:
color_print(4,'Python %s prefix... %s' % (env['PYTHON_VERSION'], env['PYTHON_SYS_PREFIX'])) color_print(4,'Bindings Python version... %s' % env['PYTHON_VERSION'])
color_print(4,'Python bindings will install in... %s' % os.path.normpath(env['PYTHON_INSTALL_LOCATION'])) color_print(4,'Python %s prefix... %s' % (env['PYTHON_VERSION'], env['PYTHON_SYS_PREFIX']))
color_print(4,'Python bindings will install in... %s' % os.path.normpath(env['PYTHON_INSTALL_LOCATION']))
env.Replace(**backup) env.Replace(**backup)
# if requested, sort LIBPATH and CPPPATH one last time before saving... # if requested, sort LIBPATH and CPPPATH one last time before saving...

View file

@ -23,6 +23,7 @@
// boost // boost
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/python/detail/api_placeholder.hpp> #include <boost/python/detail/api_placeholder.hpp>
#include <boost/noncopyable.hpp>
// stl // stl
#include <sstream> #include <sstream>
@ -49,24 +50,15 @@ namespace
using namespace boost::python; using namespace boost::python;
boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d) boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
{ {
bool bind=true;
mapnik::parameters params; mapnik::parameters params;
boost::python::list keys=d.keys(); boost::python::list keys=d.keys();
for (int i=0; i<len(keys); ++i) for (int i=0; i<len(keys); ++i)
{ {
std::string key = extract<std::string>(keys[i]); std::string key = extract<std::string>(keys[i]);
object obj = d[key]; object obj = d[key];
if (key == "bind")
{
bind = extract<bool>(obj)();
continue;
}
extract<std::string> ex0(obj); extract<std::string> ex0(obj);
extract<mapnik::value_integer> ex1(obj); extract<mapnik::value_integer> ex1(obj);
extract<double> ex2(obj); extract<double> ex2(obj);
if (ex0.check()) if (ex0.check())
{ {
params[key] = ex0(); params[key] = ex0();
@ -81,7 +73,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);
} }
boost::python::dict describe(boost::shared_ptr<mapnik::datasource> const& ds) boost::python::dict describe(boost::shared_ptr<mapnik::datasource> const& ds)
@ -169,7 +161,6 @@ void export_datasource()
.def("describe",&describe) .def("describe",&describe)
.def("envelope",&datasource::envelope) .def("envelope",&datasource::envelope)
.def("features",&datasource::features) .def("features",&datasource::features)
.def("bind",&datasource::bind)
.def("fields",&fields) .def("fields",&fields)
.def("field_types",&field_types) .def("field_types",&field_types)
.def("features_at_point",&datasource::features_at_point, (arg("coord"),arg("tolerance")=0)) .def("features_at_point",&datasource::features_at_point, (arg("coord"),arg("tolerance")=0))

View file

@ -21,6 +21,8 @@
*****************************************************************************/ *****************************************************************************/
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/noncopyable.hpp>
#include <mapnik/datasource_cache.hpp> #include <mapnik/datasource_cache.hpp>
namespace { namespace {
@ -29,20 +31,12 @@ using namespace boost::python;
boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d) boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
{ {
bool bind=true;
mapnik::parameters params; mapnik::parameters params;
boost::python::list keys=d.keys(); boost::python::list keys=d.keys();
for (int i=0; i<len(keys); ++i) for (int i=0; i<len(keys); ++i)
{ {
std::string key = extract<std::string>(keys[i]); std::string key = extract<std::string>(keys[i]);
object obj = d[key]; object obj = d[key];
if (key == "bind")
{
bind = extract<bool>(obj)();
continue;
}
extract<std::string> ex0(obj); extract<std::string> ex0(obj);
extract<mapnik::value_integer> ex1(obj); extract<mapnik::value_integer> ex1(obj);
extract<double> ex2(obj); extract<double> ex2(obj);
@ -61,7 +55,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);
} }
void register_datasources(std::string const& path) void register_datasources(std::string const& path)

View file

@ -23,6 +23,8 @@
// boost // boost
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/variant.hpp> #include <boost/variant.hpp>
#include <boost/noncopyable.hpp>
// mapnik // mapnik
#include <mapnik/feature.hpp> #include <mapnik/feature.hpp>

View file

@ -28,6 +28,8 @@
#include <boost/python/tuple.hpp> #include <boost/python/tuple.hpp>
#include <boost/python/to_python_converter.hpp> #include <boost/python/to_python_converter.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/noncopyable.hpp>
// mapnik // mapnik
#include <mapnik/feature.hpp> #include <mapnik/feature.hpp>

View file

@ -22,6 +22,7 @@
// boost // boost
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/noncopyable.hpp>
// mapnik // mapnik
#include <mapnik/feature.hpp> #include <mapnik/feature.hpp>

View file

@ -21,6 +21,8 @@
*****************************************************************************/ *****************************************************************************/
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/noncopyable.hpp>
#include <mapnik/font_engine_freetype.hpp> #include <mapnik/font_engine_freetype.hpp>
void export_font_engine() void export_font_engine()

View file

@ -26,6 +26,8 @@
#include <boost/python/iterator.hpp> #include <boost/python/iterator.hpp>
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/noncopyable.hpp>
// mapnik // mapnik
#include <mapnik/geometry.hpp> #include <mapnik/geometry.hpp>

View file

@ -24,6 +24,8 @@
#include <boost/python/module.hpp> #include <boost/python/module.hpp>
#include <boost/python/def.hpp> #include <boost/python/def.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/noncopyable.hpp>
#include <mapnik/label_collision_detector.hpp> #include <mapnik/label_collision_detector.hpp>
#include <mapnik/map.hpp> #include <mapnik/map.hpp>

View file

@ -21,6 +21,8 @@
*****************************************************************************/ *****************************************************************************/
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/noncopyable.hpp>
#include <mapnik/debug.hpp> #include <mapnik/debug.hpp>
#include <mapnik/utils.hpp> #include <mapnik/utils.hpp>
#include "mapnik_enumeration.hpp" #include "mapnik_enumeration.hpp"

View file

@ -23,6 +23,7 @@
// boost // boost
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/noncopyable.hpp>
//mapnik //mapnik
#include <mapnik/palette.hpp> #include <mapnik/palette.hpp>

View file

@ -22,6 +22,7 @@
// mapnik // mapnik
#include <mapnik/proj_transform.hpp> #include <mapnik/proj_transform.hpp>
#include <boost/noncopyable.hpp>
// boost // boost
#include <boost/python.hpp> #include <boost/python.hpp>

View file

@ -21,6 +21,7 @@
*****************************************************************************/ *****************************************************************************/
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/python/stl_iterator.hpp> #include <boost/python/stl_iterator.hpp>
#include <boost/noncopyable.hpp>
#include <mapnik/text_properties.hpp> #include <mapnik/text_properties.hpp>
#include <mapnik/text_placements/simple.hpp> #include <mapnik/text_placements/simple.hpp>

View file

@ -22,6 +22,7 @@
#include <boost/optional/optional.hpp> #include <boost/optional/optional.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/noncopyable.hpp>
// boost::optional<T> to/from converter from John Wiegley // boost::optional<T> to/from converter from John Wiegley

View file

@ -20,17 +20,18 @@
#include "styles_model.hpp" #include "styles_model.hpp"
#include <mapnik/expression_string.hpp> #include <mapnik/expression_string.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/concept_check.hpp> #include <boost/concept_check.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp>
// qt // qt
#include <QList> #include <QList>
#include <QIcon> #include <QIcon>
#include <QPainter> #include <QPainter>
#include <QPixmap> #include <QPixmap>
class node : private boost::noncopyable class node : private mapnik::noncopyable
{ {
struct node_base struct node_base
{ {

View file

@ -25,9 +25,7 @@
// mapnik // mapnik
#include <mapnik/image_data.hpp> #include <mapnik/image_data.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/utility.hpp>
// agg // agg
#include "agg_color_rgba.h" #include "agg_color_rgba.h"
@ -35,7 +33,7 @@
namespace mapnik namespace mapnik
{ {
class pattern_source : private boost::noncopyable class pattern_source : private mapnik::noncopyable
{ {
public: public:
pattern_source(image_data_32 const& pattern) pattern_source(image_data_32 const& pattern)

View file

@ -23,15 +23,15 @@
#ifndef MAPNIK_AGG_RASTERIZER_HPP #ifndef MAPNIK_AGG_RASTERIZER_HPP
#define MAPNIK_AGG_RASTERIZER_HPP #define MAPNIK_AGG_RASTERIZER_HPP
// boost // mapnik
#include <boost/utility.hpp> #include <mapnik/noncopyable.hpp>
// agg // agg
#include "agg_rasterizer_scanline_aa.h" #include "agg_rasterizer_scanline_aa.h"
namespace mapnik { namespace mapnik {
struct rasterizer : agg::rasterizer_scanline_aa<>, boost::noncopyable {}; struct rasterizer : agg::rasterizer_scanline_aa<>, mapnik::noncopyable {};
} }

View file

@ -30,9 +30,9 @@
#include <mapnik/label_collision_detector.hpp> #include <mapnik/label_collision_detector.hpp>
#include <mapnik/map.hpp> #include <mapnik/map.hpp>
#include <mapnik/rule.hpp> // for all symbolizers #include <mapnik/rule.hpp> // for all symbolizers
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/optional.hpp> #include <boost/optional.hpp>
@ -53,7 +53,7 @@ struct rasterizer;
template <typename T> template <typename T>
class MAPNIK_DECL agg_renderer : public feature_style_processor<agg_renderer<T> >, class MAPNIK_DECL agg_renderer : public feature_style_processor<agg_renderer<T> >,
private boost::noncopyable private mapnik::noncopyable
{ {
public: public:

View file

@ -26,8 +26,9 @@
// mapnik // mapnik
#include <mapnik/rule.hpp> #include <mapnik/rule.hpp>
#include <mapnik/transform_processor.hpp> #include <mapnik/transform_processor.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/variant.hpp> #include <boost/variant.hpp>
#include <boost/concept_check.hpp> #include <boost/concept_check.hpp>
// stl // stl
@ -206,7 +207,7 @@ private:
}; };
class attribute_collector : public boost::noncopyable class attribute_collector : public mapnik::noncopyable
{ {
private: private:
std::set<std::string>& names_; std::set<std::string>& names_;

View file

@ -32,13 +32,13 @@
#include <mapnik/label_collision_detector.hpp> #include <mapnik/label_collision_detector.hpp>
#include <mapnik/map.hpp> #include <mapnik/map.hpp>
#include <mapnik/rule.hpp> // for all symbolizers #include <mapnik/rule.hpp> // for all symbolizers
#include <mapnik/noncopyable.hpp>
// cairo // cairo
#include <cairomm/context.h> #include <cairomm/context.h>
#include <cairomm/surface.h> #include <cairomm/surface.h>
// boost // boost
#include <boost/utility.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
// FIXME // FIXME
@ -57,7 +57,7 @@ class cairo_face;
typedef boost::shared_ptr<cairo_face> cairo_face_ptr; typedef boost::shared_ptr<cairo_face> cairo_face_ptr;
class cairo_face_manager : private boost::noncopyable class cairo_face_manager : private mapnik::noncopyable
{ {
public: public:
cairo_face_manager(boost::shared_ptr<freetype_engine> engine); cairo_face_manager(boost::shared_ptr<freetype_engine> engine);
@ -69,7 +69,7 @@ private:
cairo_face_cache cache_; cairo_face_cache cache_;
}; };
class MAPNIK_DECL cairo_renderer_base : private boost::noncopyable class MAPNIK_DECL cairo_renderer_base : private mapnik::noncopyable
{ {
protected: protected:
cairo_renderer_base(Map const& m, Cairo::RefPtr<Cairo::Context> const& context, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0); cairo_renderer_base(Map const& m, Cairo::RefPtr<Cairo::Context> const& context, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);

View file

@ -29,9 +29,9 @@
#include <mapnik/feature.hpp> #include <mapnik/feature.hpp>
#include <mapnik/query.hpp> #include <mapnik/query.hpp>
#include <mapnik/feature_layer_desc.hpp> #include <mapnik/feature_layer_desc.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
// stl // stl
@ -42,7 +42,7 @@ namespace mapnik {
typedef MAPNIK_DECL boost::shared_ptr<Feature> feature_ptr; typedef MAPNIK_DECL boost::shared_ptr<Feature> feature_ptr;
struct MAPNIK_DECL Featureset : private boost::noncopyable struct MAPNIK_DECL Featureset : private mapnik::noncopyable
{ {
virtual feature_ptr next() = 0; virtual feature_ptr next() = 0;
virtual ~Featureset() {} virtual ~Featureset() {}
@ -70,7 +70,7 @@ private:
std::string message_; std::string message_;
}; };
class MAPNIK_DECL datasource : private boost::noncopyable class MAPNIK_DECL datasource : private mapnik::noncopyable
{ {
public: public:
enum datasource_t { enum datasource_t {
@ -86,10 +86,7 @@ public:
}; };
datasource (parameters const& params) datasource (parameters const& params)
: params_(params), : params_(params) {}
is_bound_(false)
{
}
/*! /*!
* @brief Get the configuration parameters of the data source. * @brief Get the configuration parameters of the data source.
@ -108,12 +105,6 @@ public:
* @return The type of the datasource (Vector or Raster) * @return The type of the datasource (Vector or Raster)
*/ */
virtual datasource_t type() const = 0; virtual datasource_t type() const = 0;
/*!
* @brief Connect to the datasource
*/
virtual void bind() const {}
virtual featureset_ptr features(query const& q) const = 0; virtual featureset_ptr features(query const& q) const = 0;
virtual featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const = 0; virtual featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const = 0;
virtual box2d<double> envelope() const = 0; virtual box2d<double> envelope() const = 0;
@ -122,11 +113,10 @@ public:
virtual ~datasource() {} virtual ~datasource() {}
protected: protected:
parameters params_; parameters params_;
mutable bool is_bound_;
}; };
typedef const char * datasource_name(); typedef const char * datasource_name();
typedef datasource* create_ds(parameters const& params, bool bind); typedef datasource* create_ds(parameters const& params);
typedef void destroy_ds(datasource *ds); typedef void destroy_ds(datasource *ds);
class datasource_deleter class datasource_deleter
@ -145,9 +135,9 @@ typedef boost::shared_ptr<datasource> datasource_ptr;
{ \ { \
return classname::name(); \ return classname::name(); \
} \ } \
extern "C" MAPNIK_EXP datasource* create(parameters const& params, bool bind) \ extern "C" MAPNIK_EXP datasource* create(parameters const& params) \
{ \ { \
return new classname(params, bind); \ return new classname(params); \
} \ } \
extern "C" MAPNIK_EXP void destroy(datasource *ds) \ extern "C" MAPNIK_EXP void destroy(datasource *ds) \
{ \ { \

View file

@ -28,9 +28,9 @@
#include <mapnik/params.hpp> #include <mapnik/params.hpp>
#include <mapnik/plugin.hpp> #include <mapnik/plugin.hpp>
#include <mapnik/datasource.hpp> #include <mapnik/datasource.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
// stl // stl
@ -40,7 +40,7 @@ namespace mapnik {
class MAPNIK_DECL datasource_cache class MAPNIK_DECL datasource_cache
: public singleton<datasource_cache, CreateStatic>, : public singleton<datasource_cache, CreateStatic>,
private boost::noncopyable private mapnik::noncopyable
{ {
friend class CreateStatic<datasource_cache>; friend class CreateStatic<datasource_cache>;
public: public:
@ -48,7 +48,7 @@ public:
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);
private: private:
datasource_cache(); datasource_cache();
~datasource_cache(); ~datasource_cache();

View file

@ -26,9 +26,9 @@
// mapnik (should not depend on anything that need to use this) // mapnik (should not depend on anything that need to use this)
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/utils.hpp> #include <mapnik/utils.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#ifdef MAPNIK_THREADSAFE #ifdef MAPNIK_THREADSAFE
#include <boost/thread/mutex.hpp> #include <boost/thread/mutex.hpp>
@ -50,7 +50,7 @@ namespace mapnik {
*/ */
class MAPNIK_DECL logger : class MAPNIK_DECL logger :
public singleton<logger,CreateStatic>, public singleton<logger,CreateStatic>,
private boost::noncopyable private mapnik::noncopyable
{ {
public: public:
enum severity_type enum severity_type
@ -186,7 +186,7 @@ namespace mapnik {
class Ch = char, class Ch = char,
class Tr = std::char_traits<Ch>, class Tr = std::char_traits<Ch>,
class A = std::allocator<Ch> > class A = std::allocator<Ch> >
class base_log : public boost::noncopyable class base_log : public mapnik::noncopyable
{ {
public: public:
typedef OutputPolicy<Ch, Tr, A> output_policy; typedef OutputPolicy<Ch, Tr, A> output_policy;
@ -245,7 +245,7 @@ namespace mapnik {
class Ch = char, class Ch = char,
class Tr = std::char_traits<Ch>, class Tr = std::char_traits<Ch>,
class A = std::allocator<Ch> > class A = std::allocator<Ch> >
class base_log_always : public boost::noncopyable class base_log_always : public mapnik::noncopyable
{ {
public: public:
typedef OutputPolicy<Ch, Tr, A> output_policy; typedef OutputPolicy<Ch, Tr, A> output_policy;

View file

@ -29,6 +29,8 @@
#include <mapnik/geometry.hpp> #include <mapnik/geometry.hpp>
#include <mapnik/raster.hpp> #include <mapnik/raster.hpp>
#include <mapnik/feature_kv_iterator.hpp> #include <mapnik/feature_kv_iterator.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/version.hpp> #include <boost/version.hpp>
#if BOOST_VERSION >= 104000 #if BOOST_VERSION >= 104000
@ -36,7 +38,7 @@
#else #else
#include <boost/property_map.hpp> #include <boost/property_map.hpp>
#endif #endif
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
@ -52,7 +54,7 @@ typedef boost::shared_ptr<raster> raster_ptr;
class feature_impl; class feature_impl;
template <typename T> template <typename T>
class context : private boost::noncopyable, class context : private mapnik::noncopyable,
public boost::associative_property_map<T> public boost::associative_property_map<T>
{ {
@ -95,7 +97,7 @@ typedef MAPNIK_DECL boost::shared_ptr<context_type> context_ptr;
static const value default_value; static const value default_value;
class MAPNIK_DECL feature_impl : private boost::noncopyable class MAPNIK_DECL feature_impl : private mapnik::noncopyable
{ {
friend class feature_kv_iterator; friend class feature_kv_iterator;
public: public:

View file

@ -32,6 +32,7 @@
#include <mapnik/char_info.hpp> #include <mapnik/char_info.hpp>
#include <mapnik/pixel_position.hpp> #include <mapnik/pixel_position.hpp>
#include <mapnik/image_compositing.hpp> #include <mapnik/image_compositing.hpp>
#include <mapnik/noncopyable.hpp>
// freetype2 // freetype2
extern "C" extern "C"
@ -45,7 +46,6 @@ extern "C"
// boost // boost
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/utility.hpp>
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#ifdef MAPNIK_THREADSAFE #ifdef MAPNIK_THREADSAFE
@ -69,7 +69,7 @@ class string_info;
typedef boost::shared_ptr<font_face> face_ptr; typedef boost::shared_ptr<font_face> face_ptr;
class MAPNIK_DECL font_glyph : private boost::noncopyable class MAPNIK_DECL font_glyph : private mapnik::noncopyable
{ {
public: public:
font_glyph(face_ptr face, unsigned index) font_glyph(face_ptr face, unsigned index)
@ -91,7 +91,7 @@ private:
typedef boost::shared_ptr<font_glyph> glyph_ptr; typedef boost::shared_ptr<font_glyph> glyph_ptr;
class font_face : boost::noncopyable class font_face : mapnik::noncopyable
{ {
public: public:
font_face(FT_Face face) font_face(FT_Face face)
@ -145,7 +145,7 @@ private:
FT_Face face_; FT_Face face_;
}; };
class MAPNIK_DECL font_face_set : private boost::noncopyable class MAPNIK_DECL font_face_set : private mapnik::noncopyable
{ {
public: public:
font_face_set(void) font_face_set(void)
@ -200,7 +200,7 @@ private:
}; };
// FT_Stroker wrapper // FT_Stroker wrapper
class stroker : boost::noncopyable class stroker : mapnik::noncopyable
{ {
public: public:
explicit stroker(FT_Stroker s) explicit stroker(FT_Stroker s)
@ -264,7 +264,7 @@ private:
}; };
template <typename T> template <typename T>
class MAPNIK_DECL face_manager : private boost::noncopyable class MAPNIK_DECL face_manager : private mapnik::noncopyable
{ {
typedef T font_engine_type; typedef T font_engine_type;
typedef std::map<std::string,face_ptr> face_ptr_cache_type; typedef std::map<std::string,face_ptr> face_ptr_cache_type;
@ -351,9 +351,9 @@ private:
}; };
template <typename T> template <typename T>
struct text_renderer : private boost::noncopyable struct text_renderer : private mapnik::noncopyable
{ {
struct glyph_t : boost::noncopyable struct glyph_t : mapnik::noncopyable
{ {
FT_Glyph image; FT_Glyph image;
char_properties *properties; char_properties *properties;

View file

@ -25,9 +25,7 @@
// mapnik // mapnik
#include <mapnik/utils.hpp> #include <mapnik/utils.hpp>
#include <mapnik/formatting/base.hpp> #include <mapnik/formatting/base.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/utility.hpp>
// stl // stl
#include <string> #include <string>
@ -41,7 +39,7 @@ namespace formatting
typedef node_ptr (*from_xml_function_ptr)(xml_node const& xml); typedef node_ptr (*from_xml_function_ptr)(xml_node const& xml);
class registry : public singleton<registry, CreateStatic>, class registry : public singleton<registry, CreateStatic>,
private boost::noncopyable private mapnik::noncopyable
{ {
public: public:
registry(); registry();

View file

@ -26,10 +26,10 @@
// mapnik // mapnik
#include <mapnik/vertex_vector.hpp> #include <mapnik/vertex_vector.hpp>
#include <mapnik/box2d.hpp> #include <mapnik/box2d.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
namespace mapnik { namespace mapnik {
@ -42,7 +42,7 @@ enum eGeomType {
}; };
template <typename T, template <typename> class Container=vertex_vector> template <typename T, template <typename> class Container=vertex_vector>
class geometry : private::boost::noncopyable class geometry : private::mapnik::noncopyable
{ {
public: public:
typedef T coord_type; typedef T coord_type;
@ -91,10 +91,11 @@ public:
double x = 0; double x = 0;
double y = 0; double y = 0;
rewind(0); rewind(0);
for (unsigned i=0;i<size();++i) for (unsigned i=0; i < size(); ++i)
{ {
vertex(&x,&y); unsigned cmd = vertex(&x,&y);
if (i==0) if (cmd == SEG_CLOSE) continue;
if (i == 0)
{ {
result.init(x,y,x,y); result.init(x,y,x,y);
} }
@ -126,11 +127,31 @@ public:
push_vertex(x,y,SEG_CLOSE); push_vertex(x,y,SEG_CLOSE);
} }
void close() void set_close()
{ {
if (cont_.size() > 3) if (cont_.size() > 3)
{ {
cont_.set_command(cont_.size() - 1, SEG_CLOSE); unsigned cmd;
double x,y;
int index = cont_.size() - 1;
unsigned last_cmd = cont_.get_vertex(index,&x,&y);
if (last_cmd == SEG_LINETO)
{
double last_x = x;
double last_y = y;
for (int pos = index - 1; pos >=0 ; --pos)
{
cmd = cont_.get_vertex(pos,&x,&y);
if (cmd == SEG_MOVETO)
{
if (x == last_x && y == last_y)
{
cont_.set_command(index , SEG_CLOSE);
}
break;
}
}
}
} }
} }

View file

@ -23,12 +23,12 @@
#ifndef MAPNIK_GRID_RASTERIZER_HPP #ifndef MAPNIK_GRID_RASTERIZER_HPP
#define MAPNIK_GRID_RASTERIZER_HPP #define MAPNIK_GRID_RASTERIZER_HPP
#include <boost/utility.hpp> #include <mapnik/noncopyable.hpp>
#include "agg_rasterizer_scanline_aa.h" #include "agg_rasterizer_scanline_aa.h"
namespace mapnik { namespace mapnik {
struct grid_rasterizer : agg::rasterizer_scanline_aa<>, boost::noncopyable {}; struct grid_rasterizer : agg::rasterizer_scanline_aa<>, mapnik::noncopyable {};
} }

View file

@ -31,9 +31,9 @@
#include <mapnik/map.hpp> #include <mapnik/map.hpp>
#include <mapnik/rule.hpp> // for all symbolizers #include <mapnik/rule.hpp> // for all symbolizers
#include <mapnik/grid/grid.hpp> #include <mapnik/grid/grid.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
// FIXME // FIXME
@ -52,7 +52,7 @@ struct grid_rasterizer;
template <typename T> template <typename T>
class MAPNIK_DECL grid_renderer : public feature_style_processor<grid_renderer<T> >, class MAPNIK_DECL grid_renderer : public feature_style_processor<grid_renderer<T> >,
private boost::noncopyable private mapnik::noncopyable
{ {
public: public:

View file

@ -26,9 +26,9 @@
// mapnik // mapnik
#include <mapnik/global.hpp> #include <mapnik/global.hpp>
#include <mapnik/palette.hpp> #include <mapnik/palette.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/version.hpp> #include <boost/version.hpp>
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#if BOOST_VERSION >= 104600 #if BOOST_VERSION >= 104600
@ -60,7 +60,7 @@ struct RGBAPolicy
}; };
template <typename T, typename InsertPolicy = RGBAPolicy > template <typename T, typename InsertPolicy = RGBAPolicy >
class hextree : private boost::noncopyable class hextree : private mapnik::noncopyable
{ {
struct node struct node
{ {

View file

@ -25,6 +25,7 @@
// mapnik // mapnik
#include <mapnik/json/feature_grammar.hpp> #include <mapnik/json/feature_grammar.hpp>
#include <mapnik/feature.hpp>
// spirit::qi // spirit::qi
#include <boost/config/warning_disable.hpp> #include <boost/config/warning_disable.hpp>
@ -88,7 +89,7 @@ struct feature_collection_grammar :
> lit(']') > lit(']')
; ;
feature = eps[_a = construct<feature_ptr>(new_<feature_impl>(ctx_,generate_id_()))] feature = eps[_a = construct<mapnik::feature_ptr>(new_<mapnik::feature_impl>(ctx_,generate_id_()))]
>> feature_g(*_a)[push_back(_r1,_a)] >> feature_g(*_a)[push_back(_r1,_a)]
; ;

View file

@ -27,10 +27,11 @@
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/feature.hpp> #include <mapnik/feature.hpp>
#include <mapnik/datasource.hpp> #include <mapnik/datasource.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp>
// stl // stl
#include <vector> #include <vector>
@ -39,7 +40,7 @@ namespace mapnik { namespace json {
template <typename Iterator, typename FeatureType> struct feature_collection_grammar; template <typename Iterator, typename FeatureType> struct feature_collection_grammar;
template <typename Iterator> template <typename Iterator>
class feature_collection_parser : private boost::noncopyable class feature_collection_parser : private mapnik::noncopyable
{ {
typedef Iterator iterator_type; typedef Iterator iterator_type;
typedef mapnik::Feature feature_type; typedef mapnik::Feature feature_type;

View file

@ -25,8 +25,9 @@
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/feature.hpp> #include <mapnik/feature.hpp>
#include <mapnik/noncopyable.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp>
#include <string> #include <string>
namespace mapnik { namespace json { namespace mapnik { namespace json {
@ -36,7 +37,7 @@ namespace mapnik { namespace json {
template <typename OutputIterator> struct feature_generator_grammar; template <typename OutputIterator> struct feature_generator_grammar;
template <typename OutputIterator> struct multi_geometry_generator_grammar; template <typename OutputIterator> struct multi_geometry_generator_grammar;
class MAPNIK_DECL feature_generator : private boost::noncopyable class MAPNIK_DECL feature_generator : private mapnik::noncopyable
{ {
typedef std::back_insert_iterator<std::string> sink_type; typedef std::back_insert_iterator<std::string> sink_type;
public: public:
@ -47,7 +48,7 @@ private:
boost::scoped_ptr<feature_generator_grammar<sink_type> > grammar_; boost::scoped_ptr<feature_generator_grammar<sink_type> > grammar_;
}; };
class MAPNIK_DECL geometry_generator : private boost::noncopyable class MAPNIK_DECL geometry_generator : private mapnik::noncopyable
{ {
typedef std::back_insert_iterator<std::string> sink_type; typedef std::back_insert_iterator<std::string> sink_type;
public: public:
@ -60,7 +61,7 @@ private:
#else #else
class MAPNIK_DECL feature_generator : private boost::noncopyable class MAPNIK_DECL feature_generator : private mapnik::noncopyable
{ {
public: public:
feature_generator() {} feature_generator() {}
@ -68,7 +69,7 @@ public:
bool generate(std::string & geojson, mapnik::Feature const& f); bool generate(std::string & geojson, mapnik::Feature const& f);
}; };
class MAPNIK_DECL geometry_generator : private boost::noncopyable class MAPNIK_DECL geometry_generator : private mapnik::noncopyable
{ {
public: public:
geometry_generator() {} geometry_generator() {}

View file

@ -116,7 +116,28 @@ struct json_coordinate_policy : karma::real_policies<T>
{ {
typedef boost::spirit::karma::real_policies<T> base_type; typedef boost::spirit::karma::real_policies<T> base_type;
static int floatfield(T n) { return base_type::fmtflags::fixed; } static int floatfield(T n) { return base_type::fmtflags::fixed; }
static unsigned precision(T n) { return 12 ;}
static unsigned precision(T n)
{
if (n == 0.0) return 0;
using namespace boost::spirit;
return static_cast<unsigned>(15 - boost::math::trunc(log10(traits::get_absolute_value(n))));
}
template <typename OutputIterator>
static bool dot(OutputIterator& sink, T n, unsigned precision)
{
if (n == 0) return true;
return base_type::dot(sink, n, precision);
}
template <typename OutputIterator>
static bool fraction_part(OutputIterator& sink, T n
, unsigned adjprec, unsigned precision)
{
if (n == 0) return true;
return base_type::fraction_part(sink, n, adjprec, precision);
}
}; };
} }

View file

@ -69,7 +69,7 @@ struct close_path
void operator() (T path) const void operator() (T path) const
{ {
BOOST_ASSERT( path!=0 ); BOOST_ASSERT( path!=0 );
path->close(); path->set_close();
} }
}; };

View file

@ -26,10 +26,11 @@
// mapnik // mapnik
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/geometry.hpp> #include <mapnik/geometry.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp>
// stl // stl
//#include <vector> //#include <vector>
@ -40,7 +41,7 @@ template <typename Iterator> struct geometry_grammar;
MAPNIK_DECL bool from_geojson(std::string const& json, boost::ptr_vector<geometry_type> & paths); MAPNIK_DECL bool from_geojson(std::string const& json, boost::ptr_vector<geometry_type> & paths);
template <typename Iterator> template <typename Iterator>
class MAPNIK_DECL geometry_parser : private boost::noncopyable class MAPNIK_DECL geometry_parser : private mapnik::noncopyable
{ {
typedef Iterator iterator_type; typedef Iterator iterator_type;
public: public:

View file

@ -25,6 +25,7 @@
// mapnik // mapnik
#include <mapnik/quad_tree.hpp> #include <mapnik/quad_tree.hpp>
#include <mapnik/noncopyable.hpp>
// stl // stl
#include <vector> #include <vector>
@ -63,7 +64,7 @@ private:
}; };
// quad_tree based label collision detector // quad_tree based label collision detector
class label_collision_detector2 : boost::noncopyable class label_collision_detector2 : mapnik::noncopyable
{ {
typedef quad_tree<box2d<double> > tree_t; typedef quad_tree<box2d<double> > tree_t;
tree_t tree_; tree_t tree_;
@ -97,7 +98,7 @@ public:
}; };
// quad_tree based label collision detector with seperate check/insert // quad_tree based label collision detector with seperate check/insert
class label_collision_detector3 : boost::noncopyable class label_collision_detector3 : mapnik::noncopyable
{ {
typedef quad_tree< box2d<double> > tree_t; typedef quad_tree< box2d<double> > tree_t;
tree_t tree_; tree_t tree_;
@ -135,7 +136,7 @@ public:
//quad tree based label collision detector so labels dont appear within a given distance //quad tree based label collision detector so labels dont appear within a given distance
class label_collision_detector4 : boost::noncopyable class label_collision_detector4 : mapnik::noncopyable
{ {
public: public:
struct label struct label

View file

@ -26,9 +26,9 @@
// mapnik // mapnik
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/utils.hpp> #include <mapnik/utils.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#include <boost/interprocess/mapped_region.hpp> #include <boost/interprocess/mapped_region.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
@ -43,7 +43,7 @@ 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 mapnik::noncopyable
{ {
friend class CreateStatic<mapped_memory_cache>; friend class CreateStatic<mapped_memory_cache>;
boost::unordered_map<std::string,mapped_region_ptr> cache_; boost::unordered_map<std::string,mapped_region_ptr> cache_;

View file

@ -29,12 +29,12 @@
#include <mapnik/svg/svg_path_attributes.hpp> #include <mapnik/svg/svg_path_attributes.hpp>
#include <mapnik/svg/svg_storage.hpp> #include <mapnik/svg/svg_storage.hpp>
#include <mapnik/svg/svg_path_adapter.hpp> #include <mapnik/svg/svg_path_adapter.hpp>
#include <mapnik/noncopyable.hpp>
// agg // agg
#include "agg_path_storage.h" #include "agg_path_storage.h"
// boost // boost
#include <boost/utility.hpp>
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/optional.hpp> #include <boost/optional.hpp>
@ -55,7 +55,7 @@ typedef boost::shared_ptr<image_data_32> image_ptr;
* A class to hold either vector or bitmap marker data. This allows these to be treated equally * A class to hold either vector or bitmap marker data. This allows these to be treated equally
* in the image caches and most of the render paths. * in the image caches and most of the render paths.
*/ */
class marker: private boost::noncopyable class marker: private mapnik::noncopyable
{ {
public: public:
marker() marker()

View file

@ -26,9 +26,9 @@
// mapnik // mapnik
#include <mapnik/utils.hpp> #include <mapnik/utils.hpp>
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/optional.hpp> #include <boost/optional.hpp>
@ -43,7 +43,7 @@ typedef boost::shared_ptr<marker> marker_ptr;
class MAPNIK_DECL marker_cache : class MAPNIK_DECL marker_cache :
public singleton <marker_cache, CreateUsingNew>, public singleton <marker_cache, CreateUsingNew>,
private boost::noncopyable private mapnik::noncopyable
{ {
friend class CreateUsingNew<marker_cache>; friend class CreateUsingNew<marker_cache>;
private: private:

View file

@ -30,9 +30,7 @@
#include <mapnik/label_collision_detector.hpp> #include <mapnik/label_collision_detector.hpp>
#include <mapnik/global.hpp> //round #include <mapnik/global.hpp> //round
#include <mapnik/box2d.hpp> #include <mapnik/box2d.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/utility.hpp>
// agg // agg
#include "agg_basics.h" #include "agg_basics.h"
@ -48,7 +46,7 @@
namespace mapnik { namespace mapnik {
template <typename Locator, typename Detector> template <typename Locator, typename Detector>
class markers_placement : boost::noncopyable class markers_placement : mapnik::noncopyable
{ {
public: public:
/** Constructor for markers_placement object. /** Constructor for markers_placement object.

View file

@ -0,0 +1,45 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2012 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
*
*****************************************************************************/
#ifndef MAPNIK_NONCOPYABLE_HPP
#define MAPNIK_NONCOPYABLE_HPP
namespace mapnik {
namespace non_copyable_
{
class noncopyable
{
protected:
noncopyable() {}
~noncopyable() {}
private:
noncopyable( const noncopyable& );
const noncopyable& operator=( const noncopyable& );
};
}
typedef non_copyable_::noncopyable noncopyable;
} // namespace mapnik
#endif // MAPNIK_NONCOPYABLE_HPP

View file

@ -26,9 +26,7 @@
// mapnik // mapnik
#include <mapnik/global.hpp> #include <mapnik/global.hpp>
#include <mapnik/palette.hpp> #include <mapnik/palette.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/utility.hpp>
// stl // stl
#include <vector> #include <vector>
@ -51,7 +49,7 @@ struct RGBPolicy
}; };
template <typename T, typename InsertPolicy = RGBPolicy > template <typename T, typename InsertPolicy = RGBPolicy >
class octree : private boost::noncopyable class octree : private mapnik::noncopyable
{ {
struct node struct node
{ {

View file

@ -26,9 +26,9 @@
// mapnik // mapnik
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/global.hpp> #include <mapnik/global.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
// stl // stl
@ -126,7 +126,7 @@ struct rgba
typedef boost::unordered_map<unsigned, unsigned> rgba_hash_table; typedef boost::unordered_map<unsigned, unsigned> rgba_hash_table;
class MAPNIK_DECL rgba_palette : private boost::noncopyable { class MAPNIK_DECL rgba_palette : private mapnik::noncopyable {
public: public:
enum palette_type { PALETTE_RGBA = 0, PALETTE_RGB = 1, PALETTE_ACT = 2 }; enum palette_type { PALETTE_RGBA = 0, PALETTE_RGB = 1, PALETTE_ACT = 2 };

View file

@ -30,6 +30,7 @@
#include <mapnik/symbolizer_helpers.hpp> #include <mapnik/symbolizer_helpers.hpp>
#include <mapnik/label_collision_detector.hpp> #include <mapnik/label_collision_detector.hpp>
#include <mapnik/ctrans.hpp> #include <mapnik/ctrans.hpp>
#include <mapnik/noncopyable.hpp>
// agg // agg
@ -54,7 +55,7 @@ typedef label_collision_detector4 DetectorType;
template <typename DetectorT> template <typename DetectorT>
class placement_finder : boost::noncopyable class placement_finder : mapnik::noncopyable
{ {
public: public:
placement_finder(Feature const& feature, placement_finder(Feature const& feature,

View file

@ -23,8 +23,8 @@
#ifndef MAPNIK_PLUGIN_HPP #ifndef MAPNIK_PLUGIN_HPP
#define MAPNIK_PLUGIN_HPP #define MAPNIK_PLUGIN_HPP
// boost // mapnik
#include <boost/utility.hpp> #include <mapnik/noncopyable.hpp>
// stl // stl
#include <string> #include <string>
@ -34,7 +34,7 @@
namespace mapnik namespace mapnik
{ {
class PluginInfo : boost::noncopyable class PluginInfo : mapnik::noncopyable
{ {
private: private:
std::string name_; std::string name_;

View file

@ -26,10 +26,10 @@
// mapnik // mapnik
#include <mapnik/debug.hpp> #include <mapnik/debug.hpp>
#include <mapnik/utils.hpp> #include <mapnik/utils.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
#ifdef MAPNIK_THREADSAFE #ifdef MAPNIK_THREADSAFE
#include <boost/thread/mutex.hpp> #include <boost/thread/mutex.hpp>
#endif #endif
@ -65,7 +65,7 @@ private:
}; };
template <typename T,template <typename> class Creator> template <typename T,template <typename> class Creator>
class Pool : private boost::noncopyable class Pool : private mapnik::noncopyable
{ {
typedef boost::shared_ptr<T> HolderType; typedef boost::shared_ptr<T> HolderType;
typedef std::deque<HolderType> ContType; typedef std::deque<HolderType> ContType;

View file

@ -26,11 +26,12 @@
#include <mapnik/text_properties.hpp> #include <mapnik/text_properties.hpp>
#include <mapnik/font_engine_freetype.hpp> #include <mapnik/font_engine_freetype.hpp>
#include <mapnik/text_path.hpp> #include <mapnik/text_path.hpp>
#include <mapnik/noncopyable.hpp>
namespace mapnik namespace mapnik
{ {
class processed_text : boost::noncopyable class processed_text : mapnik::noncopyable
{ {
public: public:
class processed_expression class processed_expression

View file

@ -26,13 +26,11 @@
// mapnik // mapnik
#include <mapnik/projection.hpp> #include <mapnik/projection.hpp>
#include <mapnik/box2d.hpp> #include <mapnik/box2d.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/utility.hpp>
namespace mapnik { namespace mapnik {
class MAPNIK_DECL proj_transform : private boost::noncopyable class MAPNIK_DECL proj_transform : private mapnik::noncopyable
{ {
public: public:
proj_transform(projection const& source, proj_transform(projection const& source,

View file

@ -25,10 +25,10 @@
// mapnik // mapnik
#include <mapnik/box2d.hpp> #include <mapnik/box2d.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
#include <boost/noncopyable.hpp>
// stl // stl
#include <vector> #include <vector>
@ -37,7 +37,7 @@
namespace mapnik namespace mapnik
{ {
template <typename T> template <typename T>
class quad_tree : boost::noncopyable class quad_tree : mapnik::noncopyable
{ {
struct node struct node
{ {

View file

@ -26,12 +26,10 @@
// mapnik // mapnik
#include <mapnik/box2d.hpp> #include <mapnik/box2d.hpp>
#include <mapnik/image_data.hpp> #include <mapnik/image_data.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/utility.hpp>
namespace mapnik { namespace mapnik {
class raster : private boost::noncopyable class raster : private mapnik::noncopyable
{ {
public: public:
box2d<double> ext_; box2d<double> ext_;

View file

@ -5,6 +5,7 @@
#include <mapnik/box2d.hpp> #include <mapnik/box2d.hpp>
#include <mapnik/vertex.hpp> #include <mapnik/vertex.hpp>
#include <mapnik/simplify.hpp> #include <mapnik/simplify.hpp>
#include <mapnik/noncopyable.hpp>
// STL // STL
#include <limits> #include <limits>
@ -17,7 +18,7 @@
namespace mapnik namespace mapnik
{ {
struct weighted_vertex : private boost::noncopyable struct weighted_vertex : private mapnik::noncopyable
{ {
vertex2d coord; vertex2d coord;
double weight; double weight;

View file

@ -30,9 +30,8 @@
#include <mapnik/util/geometry_svg_generator.hpp> #include <mapnik/util/geometry_svg_generator.hpp>
#include <mapnik/svg/output/svg_output_grammars.hpp> #include <mapnik/svg/output/svg_output_grammars.hpp>
#include <mapnik/svg/output/svg_output_attributes.hpp> #include <mapnik/svg/output/svg_output_attributes.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/utility.hpp>
namespace mapnik { namespace svg { namespace mapnik { namespace svg {
@ -43,7 +42,7 @@ namespace mapnik { namespace svg {
* structure. * structure.
*/ */
template <typename OutputIterator> template <typename OutputIterator>
class svg_generator : private boost::noncopyable class svg_generator : private mapnik::noncopyable
{ {
typedef svg::svg_root_attributes_grammar<OutputIterator> root_attributes_grammar; typedef svg::svg_root_attributes_grammar<OutputIterator> root_attributes_grammar;
typedef svg::svg_rect_attributes_grammar<OutputIterator> rect_attributes_grammar; typedef svg::svg_rect_attributes_grammar<OutputIterator> rect_attributes_grammar;

View file

@ -28,6 +28,7 @@
#include <mapnik/map.hpp> #include <mapnik/map.hpp>
#include <mapnik/svg/output/svg_generator.hpp> #include <mapnik/svg/output/svg_generator.hpp>
#include <mapnik/svg/output/svg_output_attributes.hpp> #include <mapnik/svg/output/svg_output_attributes.hpp>
#include <mapnik/noncopyable.hpp>
// stl // stl
#include <string> #include <string>
@ -39,7 +40,7 @@ namespace mapnik
// can target many other output destinations besides streams. // can target many other output destinations besides streams.
template <typename OutputIterator> template <typename OutputIterator>
class MAPNIK_DECL svg_renderer : public feature_style_processor<svg_renderer<OutputIterator> >, class MAPNIK_DECL svg_renderer : public feature_style_processor<svg_renderer<OutputIterator> >,
private boost::noncopyable private mapnik::noncopyable
{ {
public: public:
typedef svg_renderer<OutputIterator> processor_impl_type; typedef svg_renderer<OutputIterator> processor_impl_type;
@ -103,6 +104,11 @@ public:
// nothing to do // nothing to do
} }
inline eAttributeCollectionPolicy attribute_collection_policy() const
{
return DEFAULT;
}
inline OutputIterator& get_output_iterator() inline OutputIterator& get_output_iterator()
{ {
return output_iterator_; return output_iterator_;

View file

@ -26,9 +26,7 @@
// mapnik // mapnik
#include <mapnik/svg/svg_path_attributes.hpp> #include <mapnik/svg/svg_path_attributes.hpp>
#include <mapnik/svg/svg_path_adapter.hpp> #include <mapnik/svg/svg_path_adapter.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/utility.hpp>
// agg // agg
#include "agg_path_storage.h" #include "agg_path_storage.h"
@ -46,7 +44,7 @@ namespace mapnik {
namespace svg { namespace svg {
template <typename VertexSource, typename AttributeSource> template <typename VertexSource, typename AttributeSource>
class svg_converter : boost::noncopyable class svg_converter : mapnik::noncopyable
{ {
public: public:

View file

@ -28,9 +28,9 @@
#include <mapnik/svg/svg_converter.hpp> #include <mapnik/svg/svg_converter.hpp>
#include <mapnik/svg/svg_path_adapter.hpp> #include <mapnik/svg/svg_path_adapter.hpp>
#include <mapnik/gradient.hpp> #include <mapnik/gradient.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <libxml/xmlreader.h> #include <libxml/xmlreader.h>
// stl // stl
@ -38,7 +38,7 @@
namespace mapnik { namespace svg { namespace mapnik { namespace svg {
class svg_parser : private boost::noncopyable class svg_parser : private mapnik::noncopyable
{ {
public: public:
explicit svg_parser(svg_converter_type & path); explicit svg_parser(svg_converter_type & path);

View file

@ -24,7 +24,7 @@
#define MAPNIK_SVG_PATH_ADAPTER_HPP #define MAPNIK_SVG_PATH_ADAPTER_HPP
// mapnik // mapnik
#include <boost/utility.hpp> #include <mapnik/noncopyable.hpp>
// agg // agg
#include "agg_math.h" #include "agg_math.h"
@ -40,7 +40,7 @@ namespace svg {
using namespace agg; using namespace agg;
template<class VertexContainer> class path_adapter : boost::noncopyable template<class VertexContainer> class path_adapter : mapnik::noncopyable
{ {
public: public:
typedef VertexContainer container_type; typedef VertexContainer container_type;
@ -838,7 +838,7 @@ void path_adapter<VC>::translate_all_paths(double dx, double dy)
} }
template<class Container> class vertex_stl_adapter : boost::noncopyable template<class Container> class vertex_stl_adapter : mapnik::noncopyable
{ {
public: public:

View file

@ -29,9 +29,9 @@
#include <mapnik/gradient.hpp> #include <mapnik/gradient.hpp>
#include <mapnik/box2d.hpp> #include <mapnik/box2d.hpp>
#include <mapnik/grid/grid_pixel.hpp> #include <mapnik/grid/grid_pixel.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
// agg // agg
@ -100,7 +100,7 @@ private:
}; };
template <typename VertexSource, typename AttributeSource, typename ScanlineRenderer, typename PixelFormat> template <typename VertexSource, typename AttributeSource, typename ScanlineRenderer, typename PixelFormat>
class svg_renderer_agg : boost::noncopyable class svg_renderer_agg : mapnik::noncopyable
{ {
public: public:
typedef agg::conv_curve<VertexSource> curved_type; typedef agg::conv_curve<VertexSource> curved_type;

View file

@ -25,15 +25,13 @@
// mapnik // mapnik
#include <mapnik/box2d.hpp> #include <mapnik/box2d.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/utility.hpp>
namespace mapnik { namespace mapnik {
namespace svg { namespace svg {
template <typename VertexSource ,typename AttributeSource> template <typename VertexSource ,typename AttributeSource>
class svg_storage : boost::noncopyable class svg_storage : mapnik::noncopyable
{ {
public: public:
svg_storage() {} svg_storage() {}

View file

@ -26,12 +26,12 @@
// mapnik // mapnik
#include <mapnik/char_info.hpp> #include <mapnik/char_info.hpp>
#include <mapnik/pixel_position.hpp> #include <mapnik/pixel_position.hpp>
#include <mapnik/noncopyable.hpp>
//stl //stl
#include <vector> #include <vector>
// boost // boost
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
// uci // uci
@ -40,7 +40,7 @@
namespace mapnik namespace mapnik
{ {
class string_info : private boost::noncopyable class string_info : private mapnik::noncopyable
{ {
protected: protected:
typedef std::vector<char_info> characters_t; typedef std::vector<char_info> characters_t;
@ -122,7 +122,7 @@ typedef char_info const * char_info_ptr;
/** List of all characters and their positions and formats for a placement. */ /** List of all characters and their positions and formats for a placement. */
class text_path : boost::noncopyable class text_path : mapnik::noncopyable
{ {
struct character_node struct character_node
{ {

View file

@ -37,7 +37,7 @@ class MAPNIK_DECL text_placements;
* This placement has first to be tested by placement_finder to verify it * This placement has first to be tested by placement_finder to verify it
* can actually be used. * can actually be used.
*/ */
class text_placement_info : boost::noncopyable class text_placement_info : mapnik::noncopyable
{ {
public: public:
/** Constructor. Takes the parent text_placements object as a parameter /** Constructor. Takes the parent text_placements object as a parameter

View file

@ -25,9 +25,7 @@
// mapnik // mapnik
#include <mapnik/utils.hpp> #include <mapnik/utils.hpp>
#include <mapnik/text_placements/base.hpp> #include <mapnik/text_placements/base.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/utility.hpp>
// stl // stl
#include <string> #include <string>
@ -42,7 +40,7 @@ typedef text_placements_ptr (*from_xml_function_ptr)(
xml_node const& xml, fontset_map const & fontsets); xml_node const& xml, fontset_map const & fontsets);
class registry : public singleton<registry, CreateStatic>, class registry : public singleton<registry, CreateStatic>,
private boost::noncopyable private mapnik::noncopyable
{ {
public: public:
registry(); registry();

View file

@ -25,13 +25,13 @@
//mapnik //mapnik
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/noncopyable.hpp>
// icu // icu
#include <unicode/unistr.h> #include <unicode/unistr.h>
#include <unicode/ucnv.h> #include <unicode/ucnv.h>
// boost // boost
#include <boost/utility.hpp>
#include <boost/cstdint.hpp> #include <boost/cstdint.hpp>
// stl // stl
@ -39,7 +39,7 @@
namespace mapnik { namespace mapnik {
class MAPNIK_DECL transcoder : private boost::noncopyable class MAPNIK_DECL transcoder : private mapnik::noncopyable
{ {
public: public:
explicit transcoder (std::string const& encoding); explicit transcoder (std::string const& encoding);

View file

@ -73,12 +73,80 @@ template <typename T>
struct double_policy : boost::spirit::karma::real_policies<T> struct double_policy : boost::spirit::karma::real_policies<T>
{ {
typedef boost::spirit::karma::real_policies<T> base_type; typedef boost::spirit::karma::real_policies<T> base_type;
static int floatfield(T n) { return base_type::fmtflags::fixed; }
static unsigned precision(T n) { return static_cast<unsigned>(15 - boost::math::trunc(log10(n))); } static int floatfield(T n) {
using namespace boost::spirit; // for traits
if (traits::test_zero(n))
return base_type::fmtflags::fixed;
T abs_n = traits::get_absolute_value(n);
return (abs_n >= 1e16 || abs_n < 1e-4)
? base_type::fmtflags::scientific : base_type::fmtflags::fixed;
}
static unsigned precision(T n) {
if ( n == 0.0 ) return 0;
using namespace boost::spirit; // for traits
return static_cast<unsigned>(15 - boost::math::trunc(log10(traits::get_absolute_value(n))));
}
template <typename OutputIterator> template <typename OutputIterator>
static bool dot(OutputIterator& sink, T n, unsigned precision) { static bool dot(OutputIterator& sink, T n, unsigned precision) {
return n ? *sink = '.', true : false; if (n == 0.0) return true; // avoid trailing zeroes
return base_type::dot(sink, n, precision);
} }
template <typename OutputIterator>
static bool fraction_part (OutputIterator& sink, T n
, unsigned precision_, unsigned precision)
{
// NOTE: copied from karma only to avoid trailing zeroes
// (maybe a bug ?)
// allow for ADL to find the correct overload for floor and log10
using namespace std;
using namespace boost::spirit; // for traits
using namespace boost::spirit::karma; // for char_inserter
using namespace boost; // for remove_const
if ( traits::test_zero(n) ) return true; // this part added to karma
// The following is equivalent to:
// generate(sink, right_align(precision, '0')[ulong], n);
// but it's spelled out to avoid inter-modular dependencies.
typename remove_const<T>::type digits =
(traits::test_zero(n) ? 0 : floor(log10(n))) + 1;
bool r = true;
for (/**/; r && digits < precision_; digits = digits + 1)
r = char_inserter<>::call(sink, '0');
if (precision && r)
r = int_inserter<10>::call(sink, n);
return r;
}
template <typename CharEncoding, typename Tag, typename OutputIterator>
static bool exponent (OutputIterator& sink, long n)
{
// NOTE: copied from karma to force sign in exponent
const bool force_sign = true;
using namespace boost::spirit; // for traits
using namespace boost::spirit::karma; // for char_inserter, sign_inserter
long abs_n = traits::get_absolute_value(n);
bool r = char_inserter<CharEncoding, Tag>::call(sink, 'e') &&
sign_inserter::call(sink, traits::test_zero(n)
, traits::test_negative(n), force_sign);
// the C99 Standard requires at least two digits in the exponent
if (r && abs_n < 10)
r = char_inserter<CharEncoding, Tag>::call(sink, '0');
return r && int_inserter<10>::call(sink, abs_n);
}
}; };

View file

@ -172,6 +172,8 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
double x = 0; double x = 0;
double y = 0; double y = 0;
double start_x = 0;
double start_y = 0;
std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings
for (unsigned i=0; i< num_points; ++i) for (unsigned i=0; i< num_points; ++i)
{ {
@ -179,8 +181,15 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
if (command == SEG_MOVETO) if (command == SEG_MOVETO)
{ {
rings.push_back(new linear_ring); // start new loop rings.push_back(new linear_ring); // start new loop
start_x = x;
start_y = y;
size += 4; // num_points size += 4; // num_points
} }
else if (command == SEG_CLOSE)
{
x = start_x;
y = start_y;
}
rings.back().push_back(std::make_pair(x,y)); rings.back().push_back(std::make_pair(x,y));
size += 2 * 8; // point size += 2 * 8; // point
} }

View file

@ -37,6 +37,7 @@
#include <boost/fusion/include/boost_tuple.hpp> #include <boost/fusion/include/boost_tuple.hpp>
#include <boost/type_traits/remove_pointer.hpp> #include <boost/type_traits/remove_pointer.hpp>
#include <boost/math/special_functions/trunc.hpp> // trunc to avoid needing C++11
//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 //#define BOOST_SPIRIT_USE_PHOENIX_V3 1
namespace boost { namespace spirit { namespace traits { namespace boost { namespace spirit { namespace traits {
@ -92,13 +93,40 @@ struct multi_geometry_
template <typename U> template <typename U>
struct result { typedef bool type; }; struct result { typedef bool type; };
bool operator() (geometry_container const& geom) const bool operator() (geometry_container const& geom) const
{ {
return geom.size() > 1 ? true : false; return geom.size() > 1 ? true : false;
} }
}; };
template <typename T>
struct get_x
{
typedef T value_type;
template <typename U>
struct result { typedef double type; };
double operator() (value_type const& val) const
{
return boost::get<1>(val);
}
};
template <typename T>
struct get_y
{
typedef T value_type;
template <typename U>
struct result { typedef double type; };
double operator() (value_type const& val) const
{
return boost::get<2>(val);
}
};
template <typename T> template <typename T>
struct multi_geometry_type struct multi_geometry_type
{ {
@ -116,7 +144,28 @@ struct wkt_coordinate_policy : karma::real_policies<T>
{ {
typedef boost::spirit::karma::real_policies<T> base_type; typedef boost::spirit::karma::real_policies<T> base_type;
static int floatfield(T n) { return base_type::fmtflags::fixed; } static int floatfield(T n) { return base_type::fmtflags::fixed; }
static unsigned precision(T n) { return 6 ;} static unsigned precision(T n)
{
if (n == 0.0) return 0;
return 6;
//using namespace boost::spirit; // for traits
//return std::max(6u, static_cast<unsigned>(15 - boost::math::trunc(log10(traits::get_absolute_value(n)))));
}
template <typename OutputIterator>
static bool dot(OutputIterator& sink, T n, unsigned precision)
{
if (n == 0) return true;
return base_type::dot(sink, n, precision);
}
template <typename OutputIterator>
static bool fraction_part(OutputIterator& sink, T n
, unsigned adjprec, unsigned precision)
{
if (n == 0) return true;
return base_type::fraction_part(sink, n, adjprec, precision);
}
}; };
} }
@ -136,13 +185,15 @@ struct wkt_generator :
karma::rule<OutputIterator, geometry_type const& ()> polygon; karma::rule<OutputIterator, geometry_type const& ()> polygon;
karma::rule<OutputIterator, geometry_type const& ()> coords; karma::rule<OutputIterator, geometry_type const& ()> coords;
karma::rule<OutputIterator, karma::locals<unsigned>, geometry_type const& ()> coords2; karma::rule<OutputIterator, karma::locals<unsigned,double,double>, geometry_type const& ()> coords2;
karma::rule<OutputIterator, coord_type ()> point_coord; karma::rule<OutputIterator, coord_type ()> point_coord;
karma::rule<OutputIterator, coord_type (unsigned& )> polygon_coord; karma::rule<OutputIterator, karma::locals<double,double>, coord_type (unsigned&, double&, double& )> polygon_coord;
// phoenix functions // phoenix functions
phoenix::function<detail::get_type<geometry_type> > _type; phoenix::function<detail::get_type<geometry_type> > _type;
phoenix::function<detail::get_first<geometry_type> > _first; phoenix::function<detail::get_first<geometry_type> > _first;
phoenix::function<detail::get_x<typename geometry_type::value_type> > _x;
phoenix::function<detail::get_y<typename geometry_type::value_type> > _y;
// //
karma::real_generator<double, detail::wkt_coordinate_policy<double> > coordinate; karma::real_generator<double, detail::wkt_coordinate_policy<double> > coordinate;
}; };

View file

@ -44,13 +44,13 @@
#include <boost/fusion/include/make_vector.hpp> #include <boost/fusion/include/make_vector.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/utility.hpp>
#include <boost/array.hpp> #include <boost/array.hpp>
// mapnik // mapnik
#include <mapnik/agg_helpers.hpp> #include <mapnik/agg_helpers.hpp>
#include <mapnik/offset_converter.hpp> #include <mapnik/offset_converter.hpp>
#include <mapnik/simplify_converter.hpp> #include <mapnik/simplify_converter.hpp>
#include <mapnik/noncopyable.hpp>
// agg // agg
#include "agg_conv_clip_polygon.h" #include "agg_conv_clip_polygon.h"
@ -317,7 +317,7 @@ struct dispatcher
template <typename B, typename R, typename S, typename T, typename P, typename A, typename C > template <typename B, typename R, typename S, typename T, typename P, typename A, typename C >
struct vertex_converter : private boost::noncopyable struct vertex_converter : private mapnik::noncopyable
{ {
typedef C conv_types; typedef C conv_types;
typedef B bbox_type; typedef B bbox_type;

View file

@ -29,9 +29,9 @@
// mapnik // mapnik
#include <mapnik/vertex.hpp> #include <mapnik/vertex.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <cstring> // required for memcpy with linux/g++ #include <cstring> // required for memcpy with linux/g++
@ -40,7 +40,7 @@ namespace mapnik
{ {
template <typename T> template <typename T>
class vertex_vector : private boost::noncopyable class vertex_vector : private mapnik::noncopyable
{ {
typedef T coord_type; typedef T coord_type;
typedef vertex<coord_type,2> vertex_type; typedef vertex<coord_type,2> vertex_type;

View file

@ -25,9 +25,7 @@
// mapnik // mapnik
#include <mapnik/geometry.hpp> #include <mapnik/geometry.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/utility.hpp>
namespace mapnik namespace mapnik
{ {
@ -50,7 +48,7 @@ enum wkbFormat
wkbSpatiaLite=3 wkbSpatiaLite=3
}; };
class MAPNIK_DECL geometry_utils : private boost::noncopyable class MAPNIK_DECL geometry_utils : private mapnik::noncopyable
{ {
public: public:

View file

@ -27,8 +27,9 @@
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/geometry.hpp> #include <mapnik/geometry.hpp>
#include <mapnik/wkt/wkt_grammar.hpp> #include <mapnik/wkt/wkt_grammar.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/version.hpp> #include <boost/version.hpp>
@ -42,7 +43,7 @@ MAPNIK_DECL bool from_wkt(std::string const& wkt, boost::ptr_vector<geometry_typ
#if BOOST_VERSION >= 104700 #if BOOST_VERSION >= 104700
class MAPNIK_DECL wkt_parser : boost::noncopyable class MAPNIK_DECL wkt_parser : mapnik::noncopyable
{ {
typedef std::string::const_iterator iterator_type; typedef std::string::const_iterator iterator_type;
public: public:

View file

@ -71,7 +71,7 @@ namespace mapnik { namespace wkt {
void operator() (T path) const void operator() (T path) const
{ {
BOOST_ASSERT( path!=0 ); BOOST_ASSERT( path!=0 );
path->close(); path->set_close();
} }
}; };

View file

@ -56,23 +56,23 @@ using namespace boost::spirit;
DATASOURCE_PLUGIN(csv_datasource) DATASOURCE_PLUGIN(csv_datasource)
csv_datasource::csv_datasource(parameters const& params, bool bind) csv_datasource::csv_datasource(parameters const& params)
: datasource(params), : datasource(params),
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")), desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding", "utf-8")),
extent_(), extent_(),
filename_(), filename_(),
inline_string_(), inline_string_(),
file_length_(0), file_length_(0),
row_limit_(*params_.get<int>("row_limit", 0)), row_limit_(*params.get<int>("row_limit", 0)),
features_(), features_(),
escape_(*params_.get<std::string>("escape", "")), escape_(*params.get<std::string>("escape", "")),
separator_(*params_.get<std::string>("separator", "")), separator_(*params.get<std::string>("separator", "")),
quote_(*params_.get<std::string>("quote", "")), quote_(*params.get<std::string>("quote", "")),
headers_(), headers_(),
manual_headers_(mapnik::util::trim_copy(*params_.get<std::string>("headers", ""))), manual_headers_(mapnik::util::trim_copy(*params.get<std::string>("headers", ""))),
strict_(*params_.get<mapnik::boolean>("strict", false)), strict_(*params.get<mapnik::boolean>("strict", false)),
quiet_(*params_.get<mapnik::boolean>("quiet", false)), quiet_(*params.get<mapnik::boolean>("quiet", false)),
filesize_max_(*params_.get<float>("filesize_max", 20.0)), // MB filesize_max_(*params.get<float>("filesize_max", 20.0)), // MB
ctx_(boost::make_shared<mapnik::context_type>()) ctx_(boost::make_shared<mapnik::context_type>())
{ {
/* TODO: /* TODO:
@ -97,36 +97,22 @@ csv_datasource::csv_datasource(parameters const& params, bool bind)
http://boost-spirit.com/home/articles/qi-example/tracking-the-input-position-while-parsing/ http://boost-spirit.com/home/articles/qi-example/tracking-the-input-position-while-parsing/
*/ */
boost::optional<std::string> inline_string = params_.get<std::string>("inline"); boost::optional<std::string> inline_string = params.get<std::string>("inline");
if (inline_string) if (inline_string)
{ {
inline_string_ = *inline_string; inline_string_ = *inline_string;
} }
else else
{ {
boost::optional<std::string> file = params_.get<std::string>("file"); boost::optional<std::string> file = params.get<std::string>("file");
if (!file) throw mapnik::datasource_exception("CSV Plugin: missing <file> parameter"); if (!file) throw mapnik::datasource_exception("CSV Plugin: missing <file> parameter");
boost::optional<std::string> base = params_.get<std::string>("base"); boost::optional<std::string> base = params.get<std::string>("base");
if (base) if (base)
filename_ = *base + "/" + *file; filename_ = *base + "/" + *file;
else else
filename_ = *file; filename_ = *file;
} }
if (bind)
{
this->bind();
}
}
csv_datasource::~csv_datasource() { }
void csv_datasource::bind() const
{
if (is_bound_) return;
if (!inline_string_.empty()) if (!inline_string_.empty())
{ {
std::istringstream in(inline_string_); std::istringstream in(inline_string_);
@ -140,14 +126,16 @@ void csv_datasource::bind() const
parse_csv(in,escape_, separator_, quote_); parse_csv(in,escape_, separator_, quote_);
in.close(); in.close();
} }
is_bound_ = true;
} }
csv_datasource::~csv_datasource() { }
template <typename T> template <typename T>
void csv_datasource::parse_csv(T & stream, void csv_datasource::parse_csv(T & stream,
std::string const& escape, std::string const& escape,
std::string const& separator, std::string const& separator,
std::string const& quote) const std::string const& quote)
{ {
stream.seekg(0, std::ios::end); stream.seekg(0, std::ios::end);
file_length_ = stream.tellg(); file_length_ = stream.tellg();
@ -890,14 +878,11 @@ datasource::datasource_t csv_datasource::type() const
mapnik::box2d<double> csv_datasource::envelope() const mapnik::box2d<double> csv_datasource::envelope() const
{ {
if (!is_bound_) bind();
return extent_; return extent_;
} }
boost::optional<mapnik::datasource::geometry_t> csv_datasource::get_geometry_type() const boost::optional<mapnik::datasource::geometry_t> csv_datasource::get_geometry_type() const
{ {
if (! is_bound_) bind();
boost::optional<mapnik::datasource::geometry_t> result; boost::optional<mapnik::datasource::geometry_t> result;
int multi_type = 0; int multi_type = 0;
unsigned num_features = features_.size(); unsigned num_features = features_.size();
@ -920,15 +905,11 @@ boost::optional<mapnik::datasource::geometry_t> csv_datasource::get_geometry_typ
mapnik::layer_descriptor csv_datasource::get_descriptor() const mapnik::layer_descriptor csv_datasource::get_descriptor() const
{ {
if (!is_bound_) bind();
return desc_; return desc_;
} }
mapnik::featureset_ptr csv_datasource::features(mapnik::query const& q) const mapnik::featureset_ptr csv_datasource::features(mapnik::query const& q) const
{ {
if (!is_bound_) bind();
const std::set<std::string>& attribute_names = q.property_names(); const std::set<std::string>& attribute_names = q.property_names();
std::set<std::string>::const_iterator pos = attribute_names.begin(); std::set<std::string>::const_iterator pos = attribute_names.begin();
while (pos != attribute_names.end()) while (pos != attribute_names.end())
@ -958,7 +939,5 @@ mapnik::featureset_ptr csv_datasource::features(mapnik::query const& q) const
mapnik::featureset_ptr csv_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const mapnik::featureset_ptr csv_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
{ {
if (!is_bound_) bind();
throw mapnik::datasource_exception("CSV Plugin: features_at_point is not supported yet"); throw mapnik::datasource_exception("CSV Plugin: features_at_point is not supported yet");
} }

View file

@ -42,7 +42,7 @@
class csv_datasource : public mapnik::datasource class csv_datasource : public mapnik::datasource
{ {
public: public:
csv_datasource(mapnik::parameters const& params, bool bind=true); csv_datasource(mapnik::parameters const& params);
virtual ~csv_datasource (); virtual ~csv_datasource ();
mapnik::datasource::datasource_t type() const; mapnik::datasource::datasource_t type() const;
static const char * name(); static const char * name();
@ -51,31 +51,30 @@ public:
mapnik::box2d<double> envelope() const; mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const; boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const; mapnik::layer_descriptor get_descriptor() const;
void bind() const;
template <typename T> template <typename T>
void parse_csv(T & stream, void parse_csv(T & stream,
std::string const& escape, std::string const& escape,
std::string const& separator, std::string const& separator,
std::string const& quote) const; std::string const& quote);
private: private:
mutable mapnik::layer_descriptor desc_; mapnik::layer_descriptor desc_;
mutable mapnik::box2d<double> extent_; mapnik::box2d<double> extent_;
mutable std::string filename_; std::string filename_;
mutable std::string inline_string_; std::string inline_string_;
mutable unsigned file_length_; unsigned file_length_;
mutable int row_limit_; int row_limit_;
mutable std::vector<mapnik::feature_ptr> features_; std::vector<mapnik::feature_ptr> features_;
mutable std::string escape_; std::string escape_;
mutable std::string separator_; std::string separator_;
mutable std::string quote_; std::string quote_;
mutable std::vector<std::string> headers_; std::vector<std::string> headers_;
mutable std::string manual_headers_; std::string manual_headers_;
mutable bool strict_; bool strict_;
mutable bool quiet_; bool quiet_;
mutable double filesize_max_; double filesize_max_;
mutable mapnik::context_ptr ctx_; mapnik::context_ptr ctx_;
}; };
#endif // MAPNIK_CSV_DATASOURCE_HPP #endif // MAPNIK_CSV_DATASOURCE_HPP

View file

@ -73,20 +73,24 @@ inline GDALDataset* gdal_datasource::open_dataset() const
} }
gdal_datasource::gdal_datasource(parameters const& params, bool bind) gdal_datasource::gdal_datasource(parameters const& params)
: datasource(params), : datasource(params),
desc_(*params.get<std::string>("type"), "utf-8"), desc_(*params.get<std::string>("type"), "utf-8"),
filter_factor_(*params_.get<double>("filter_factor", 0.0)), filter_factor_(*params.get<double>("filter_factor", 0.0)),
nodata_value_(params_.get<double>("nodata")) nodata_value_(params.get<double>("nodata"))
{ {
MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: Initializing..."; MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: Initializing...";
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "gdal_datasource::init");
#endif
GDALAllRegister(); GDALAllRegister();
boost::optional<std::string> file = params.get<std::string>("file"); boost::optional<std::string> file = params.get<std::string>("file");
if (! file) throw datasource_exception("missing <file> parameter"); if (! file) throw datasource_exception("missing <file> parameter");
boost::optional<std::string> base = params_.get<std::string>("base"); boost::optional<std::string> base = params.get<std::string>("base");
if (base) if (base)
{ {
dataset_name_ = *base + "/" + *file; dataset_name_ = *base + "/" + *file;
@ -96,22 +100,8 @@ gdal_datasource::gdal_datasource(parameters const& params, bool bind)
dataset_name_ = *file; dataset_name_ = *file;
} }
if (bind) shared_dataset_ = *params.get<mapnik::boolean>("shared", false);
{ band_ = *params.get<int>("band", -1);
this->bind();
}
}
void gdal_datasource::bind() const
{
if (is_bound_) return;
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "gdal_datasource::bind");
#endif
shared_dataset_ = *params_.get<mapnik::boolean>("shared", false);
band_ = *params_.get<int>("band", -1);
GDALDataset *dataset = open_dataset(); GDALDataset *dataset = open_dataset();
@ -121,7 +111,7 @@ void gdal_datasource::bind() const
double tr[6]; double tr[6];
bool bbox_override = false; bool bbox_override = false;
boost::optional<std::string> bbox_s = params_.get<std::string>("extent"); boost::optional<std::string> bbox_s = params.get<std::string>("extent");
if (bbox_s) if (bbox_s)
{ {
MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: BBox Parameter=" << *bbox_s; MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: BBox Parameter=" << *bbox_s;
@ -188,7 +178,6 @@ void gdal_datasource::bind() const
MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: Raster Size=" << width_ << "," << height_; MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: Raster Size=" << width_ << "," << height_;
MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: Raster Extent=" << extent_; MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: Raster Extent=" << extent_;
is_bound_ = true;
} }
gdal_datasource::~gdal_datasource() gdal_datasource::~gdal_datasource()
@ -207,8 +196,6 @@ const char * gdal_datasource::name()
box2d<double> gdal_datasource::envelope() const box2d<double> gdal_datasource::envelope() const
{ {
if (! is_bound_) bind();
return extent_; return extent_;
} }
@ -224,8 +211,6 @@ layer_descriptor gdal_datasource::get_descriptor() const
featureset_ptr gdal_datasource::features(query const& q) const featureset_ptr gdal_datasource::features(query const& q) const
{ {
if (! is_bound_) bind();
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "gdal_datasource::features"); mapnik::progress_timer __stats__(std::clog, "gdal_datasource::features");
#endif #endif
@ -248,8 +233,6 @@ featureset_ptr gdal_datasource::features(query const& q) const
featureset_ptr gdal_datasource::features_at_point(coord2d const& pt, double tol) const featureset_ptr gdal_datasource::features_at_point(coord2d const& pt, double tol) const
{ {
if (! is_bound_) bind();
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "gdal_datasource::features_at_point"); mapnik::progress_timer __stats__(std::clog, "gdal_datasource::features_at_point");
#endif #endif

View file

@ -45,7 +45,7 @@
class gdal_datasource : public mapnik::datasource class gdal_datasource : public mapnik::datasource
{ {
public: public:
gdal_datasource(mapnik::parameters const& params, bool bind = true); gdal_datasource(mapnik::parameters const& params);
virtual ~gdal_datasource(); virtual ~gdal_datasource();
mapnik::datasource::datasource_t type() const; mapnik::datasource::datasource_t type() const;
static const char * name(); static const char * name();
@ -54,19 +54,18 @@ public:
mapnik::box2d<double> envelope() const; mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const; boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const; mapnik::layer_descriptor get_descriptor() const;
void bind() const;
private: private:
GDALDataset* open_dataset() const; GDALDataset* open_dataset() const;
mutable mapnik::box2d<double> extent_; mapnik::box2d<double> extent_;
std::string dataset_name_; std::string dataset_name_;
mutable int band_; int band_;
mapnik::layer_descriptor desc_; mapnik::layer_descriptor desc_;
mutable unsigned width_; unsigned width_;
mutable unsigned height_; unsigned height_;
mutable double dx_; double dx_;
mutable double dy_; double dy_;
mutable int nbands_; int nbands_;
mutable bool shared_dataset_; bool shared_dataset_;
double filter_factor_; double filter_factor_;
boost::optional<double> nodata_value_; boost::optional<double> nodata_value_;
}; };

View file

@ -49,24 +49,6 @@ using mapnik::parameters;
DATASOURCE_PLUGIN(geojson_datasource) DATASOURCE_PLUGIN(geojson_datasource)
geojson_datasource::geojson_datasource(parameters const& params, bool bind)
: datasource(params),
type_(datasource::Vector),
desc_(*params_.get<std::string>("type"),
*params_.get<std::string>("encoding","utf-8")),
file_(*params_.get<std::string>("file","")),
extent_(),
tr_(new mapnik::transcoder(*params_.get<std::string>("encoding","utf-8"))),
features_(),
tree_(16,1)
{
if (file_.empty()) throw mapnik::datasource_exception("GeoJSON Plugin: missing <file> parameter");
if (bind)
{
this->bind();
}
}
struct attr_value_converter : public boost::static_visitor<mapnik::eAttributeType> struct attr_value_converter : public boost::static_visitor<mapnik::eAttributeType>
{ {
mapnik::eAttributeType operator() (mapnik::value_integer /*val*/) const mapnik::eAttributeType operator() (mapnik::value_integer /*val*/) const
@ -105,9 +87,18 @@ struct attr_value_converter : public boost::static_visitor<mapnik::eAttributeTyp
} }
}; };
void geojson_datasource::bind() const geojson_datasource::geojson_datasource(parameters const& params)
: datasource(params),
type_(datasource::Vector),
desc_(*params.get<std::string>("type"),
*params.get<std::string>("encoding","utf-8")),
file_(*params.get<std::string>("file","")),
extent_(),
tr_(new mapnik::transcoder(*params.get<std::string>("encoding","utf-8"))),
features_(),
tree_(16,1)
{ {
if (is_bound_) return; if (file_.empty()) throw mapnik::datasource_exception("GeoJSON Plugin: missing <file> parameter");
typedef std::istreambuf_iterator<char> base_iterator_type; typedef std::istreambuf_iterator<char> base_iterator_type;
@ -149,7 +140,6 @@ void geojson_datasource::bind() const
} }
tree_.insert(box_type(point_type(box.minx(),box.miny()),point_type(box.maxx(),box.maxy())), count++); tree_.insert(box_type(point_type(box.minx(),box.miny()),point_type(box.maxx(),box.maxy())), count++);
} }
is_bound_ = true;
} }
geojson_datasource::~geojson_datasource() { } geojson_datasource::~geojson_datasource() { }
@ -188,21 +178,16 @@ mapnik::datasource::datasource_t geojson_datasource::type() const
mapnik::box2d<double> geojson_datasource::envelope() const mapnik::box2d<double> geojson_datasource::envelope() const
{ {
if (!is_bound_) bind();
return extent_; return extent_;
} }
mapnik::layer_descriptor geojson_datasource::get_descriptor() const mapnik::layer_descriptor geojson_datasource::get_descriptor() const
{ {
if (!is_bound_) bind();
return desc_; return desc_;
} }
mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) const mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) const
{ {
if (!is_bound_) bind();
// if the query box intersects our world extent then query for features // if the query box intersects our world extent then query for features
mapnik::box2d<double> const& b = q.get_bbox(); mapnik::box2d<double> const& b = q.get_bbox();
if (extent_.intersects(b)) if (extent_.intersects(b))
@ -218,7 +203,6 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons
// FIXME // FIXME
mapnik::featureset_ptr geojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const mapnik::featureset_ptr geojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
{ {
if (!is_bound_) bind();
throw mapnik::datasource_exception("GeoJSON Plugin: features_at_point is not supported yet"); throw mapnik::datasource_exception("GeoJSON Plugin: features_at_point is not supported yet");
return mapnik::featureset_ptr(); return mapnik::featureset_ptr();
} }

View file

@ -55,7 +55,7 @@ public:
typedef boost::geometry::index::rtree<box_type,std::size_t> spatial_index_type; typedef boost::geometry::index::rtree<box_type,std::size_t> spatial_index_type;
// constructor // constructor
geojson_datasource(mapnik::parameters const& params, bool bind=true); geojson_datasource(mapnik::parameters const& params);
virtual ~geojson_datasource (); virtual ~geojson_datasource ();
mapnik::datasource::datasource_t type() const; mapnik::datasource::datasource_t type() const;
static const char * name(); static const char * name();
@ -64,16 +64,15 @@ public:
mapnik::box2d<double> envelope() const; mapnik::box2d<double> envelope() const;
mapnik::layer_descriptor get_descriptor() const; mapnik::layer_descriptor get_descriptor() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const; boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
void bind() const;
private: private:
mapnik::datasource::datasource_t type_; mapnik::datasource::datasource_t type_;
mutable std::map<std::string, mapnik::parameters> statistics_; std::map<std::string, mapnik::parameters> statistics_;
mutable mapnik::layer_descriptor desc_; mapnik::layer_descriptor desc_;
mutable std::string file_; std::string file_;
mutable mapnik::box2d<double> extent_; mapnik::box2d<double> extent_;
boost::shared_ptr<mapnik::transcoder> tr_; boost::shared_ptr<mapnik::transcoder> tr_;
mutable std::vector<mapnik::feature_ptr> features_; std::vector<mapnik::feature_ptr> features_;
mutable spatial_index_type tree_; spatial_index_type tree_;
mutable std::deque<std::size_t> index_array_; mutable std::deque<std::size_t> index_array_;
}; };

View file

@ -85,7 +85,7 @@ void geos_error(const char* format, ...)
} }
geos_datasource::geos_datasource(parameters const& params, bool bind) geos_datasource::geos_datasource(parameters const& params)
: datasource(params), : datasource(params),
extent_(), extent_(),
extent_initialized_(false), extent_initialized_(false),
@ -99,42 +99,22 @@ geos_datasource::geos_datasource(parameters const& params, bool bind)
if (! geometry) throw datasource_exception("missing <wkt> parameter"); if (! geometry) throw datasource_exception("missing <wkt> parameter");
geometry_string_ = *geometry; geometry_string_ = *geometry;
boost::optional<std::string> ext = params_.get<std::string>("extent"); boost::optional<std::string> ext = params.get<std::string>("extent");
if (ext) extent_initialized_ = extent_.from_string(*ext); if (ext) extent_initialized_ = extent_.from_string(*ext);
boost::optional<int> id = params_.get<int>("gid"); boost::optional<int> id = params.get<int>("gid");
if (id) geometry_id_ = *id; if (id) geometry_id_ = *id;
boost::optional<std::string> gdata = params_.get<std::string>("field_data"); boost::optional<std::string> gdata = params.get<std::string>("field_data");
if (gdata) geometry_data_ = *gdata; if (gdata) geometry_data_ = *gdata;
boost::optional<std::string> gdata_name = params_.get<std::string>("field_name"); boost::optional<std::string> gdata_name = params.get<std::string>("field_name");
if (gdata_name) geometry_data_name_ = *gdata_name; if (gdata_name) geometry_data_name_ = *gdata_name;
desc_.add_descriptor(attribute_descriptor(geometry_data_name_, mapnik::String)); desc_.add_descriptor(attribute_descriptor(geometry_data_name_, mapnik::String));
if (bind)
{
this->bind();
}
}
geos_datasource::~geos_datasource()
{
if (is_bound_)
{
geometry_.set_feature(0);
finishGEOS();
}
}
void geos_datasource::bind() const
{
if (is_bound_) return;
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "geos_datasource::bind"); mapnik::progress_timer __stats__(std::clog, "geos_datasource::init");
#endif #endif
// open geos driver // open geos driver
@ -151,7 +131,7 @@ void geos_datasource::bind() const
if (! extent_initialized_) if (! extent_initialized_)
{ {
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats2__(std::clog, "geos_datasource::bind(initialize_extent)"); mapnik::progress_timer __stats2__(std::clog, "geos_datasource::init(initialize_extent)");
#endif #endif
MAPNIK_LOG_DEBUG(geos) << "geos_datasource: Initializing extent from geometry"; MAPNIK_LOG_DEBUG(geos) << "geos_datasource: Initializing extent from geometry";
@ -222,9 +202,18 @@ void geos_datasource::bind() const
throw datasource_exception("GEOS Plugin: cannot determine extent for <wkt> geometry"); throw datasource_exception("GEOS Plugin: cannot determine extent for <wkt> geometry");
} }
is_bound_ = true;
} }
geos_datasource::~geos_datasource()
{
{
geometry_.set_feature(0);
finishGEOS();
}
}
const char * geos_datasource::name() const char * geos_datasource::name()
{ {
return "geos"; return "geos";
@ -237,14 +226,11 @@ mapnik::datasource::datasource_t geos_datasource::type() const
box2d<double> geos_datasource::envelope() const box2d<double> geos_datasource::envelope() const
{ {
if (! is_bound_) bind();
return extent_; return extent_;
} }
boost::optional<mapnik::datasource::geometry_t> geos_datasource::get_geometry_type() const boost::optional<mapnik::datasource::geometry_t> geos_datasource::get_geometry_type() const
{ {
if (! is_bound_) bind();
boost::optional<mapnik::datasource::geometry_t> result; boost::optional<mapnik::datasource::geometry_t> result;
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
@ -280,15 +266,11 @@ boost::optional<mapnik::datasource::geometry_t> geos_datasource::get_geometry_ty
layer_descriptor geos_datasource::get_descriptor() const layer_descriptor geos_datasource::get_descriptor() const
{ {
if (! is_bound_) bind();
return desc_; return desc_;
} }
featureset_ptr geos_datasource::features(query const& q) const featureset_ptr geos_datasource::features(query const& q) const
{ {
if (! is_bound_) bind();
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "geos_datasource::features"); mapnik::progress_timer __stats__(std::clog, "geos_datasource::features");
#endif #endif
@ -316,8 +298,6 @@ featureset_ptr geos_datasource::features(query const& q) const
featureset_ptr geos_datasource::features_at_point(coord2d const& pt, double tol) const featureset_ptr geos_datasource::features_at_point(coord2d const& pt, double tol) const
{ {
if (! is_bound_) bind();
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "geos_datasource::features_at_point"); mapnik::progress_timer __stats__(std::clog, "geos_datasource::features_at_point");
#endif #endif

View file

@ -45,7 +45,7 @@
class geos_datasource : public mapnik::datasource class geos_datasource : public mapnik::datasource
{ {
public: public:
geos_datasource(mapnik::parameters const& params, bool bind = true); geos_datasource(mapnik::parameters const& params);
virtual ~geos_datasource (); virtual ~geos_datasource ();
mapnik::datasource::datasource_t type() const; mapnik::datasource::datasource_t type() const;
static const char * name(); static const char * name();
@ -54,17 +54,17 @@ public:
mapnik::box2d<double> envelope() const; mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const; boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const; mapnik::layer_descriptor get_descriptor() const;
void bind() const;
private: private:
mutable mapnik::box2d<double> extent_; void init(mapnik::parameters const& params);
mutable bool extent_initialized_; mapnik::box2d<double> extent_;
bool extent_initialized_;
mapnik::datasource::datasource_t type_; mapnik::datasource::datasource_t type_;
mutable mapnik::layer_descriptor desc_; mapnik::layer_descriptor desc_;
mutable geos_feature_ptr geometry_; mutable geos_feature_ptr geometry_;
mutable std::string geometry_data_; std::string geometry_data_;
mutable std::string geometry_data_name_; std::string geometry_data_name_;
mutable int geometry_id_; int geometry_id_;
std::string geometry_string_; std::string geometry_string_;
}; };

View file

@ -67,7 +67,7 @@ boost::mutex knd_list_mutex;
std::list<kismet_network_data> knd_list; std::list<kismet_network_data> knd_list;
const unsigned int queue_size = 20; const unsigned int queue_size = 20;
kismet_datasource::kismet_datasource(parameters const& params, bool bind) kismet_datasource::kismet_datasource(parameters const& params)
: datasource(params), : datasource(params),
extent_(), extent_(),
extent_initialized_(false), extent_initialized_(false),
@ -75,7 +75,7 @@ kismet_datasource::kismet_datasource(parameters const& params, bool bind)
srs_("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"), srs_("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"),
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding","utf-8")) desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding","utf-8"))
{ {
boost::optional<std::string> host = params_.get<std::string>("host"); boost::optional<std::string> host = params.get<std::string>("host");
if (host) if (host)
{ {
host_ = *host; host_ = *host;
@ -85,37 +85,25 @@ kismet_datasource::kismet_datasource(parameters const& params, bool bind)
throw datasource_exception("Kismet Plugin: missing <host> parameter"); throw datasource_exception("Kismet Plugin: missing <host> parameter");
} }
boost::optional<unsigned int> port = params_.get<unsigned int>("port", 2501); boost::optional<unsigned int> port = params.get<unsigned int>("port", 2501);
if (port) if (port)
{ {
port_ = *port; port_ = *port;
} }
boost::optional<std::string> srs = params_.get<std::string>("srs"); boost::optional<std::string> srs = params.get<std::string>("srs");
if (srs) if (srs)
{ {
srs_ = *srs; srs_ = *srs;
} }
boost::optional<std::string> ext = params_.get<std::string>("extent"); boost::optional<std::string> ext = params.get<std::string>("extent");
if (ext) if (ext)
{ {
extent_initialized_ = extent_.from_string(*ext); extent_initialized_ = extent_.from_string(*ext);
} }
kismet_thread.reset(new boost::thread(boost::bind(&kismet_datasource::run, this, host_, port_))); kismet_thread.reset(new boost::thread(boost::bind(&kismet_datasource::run, this, host_, port_)));
if (bind)
{
this->bind();
}
}
void kismet_datasource::bind() const
{
if (is_bound_) return;
is_bound_ = true;
} }
kismet_datasource::~kismet_datasource() kismet_datasource::~kismet_datasource()
@ -134,7 +122,6 @@ mapnik::datasource::datasource_t kismet_datasource::type() const
box2d<double> kismet_datasource::envelope() const box2d<double> kismet_datasource::envelope() const
{ {
if (! is_bound_) bind();
return extent_; return extent_;
} }
@ -150,8 +137,6 @@ layer_descriptor kismet_datasource::get_descriptor() const
featureset_ptr kismet_datasource::features(query const& q) const featureset_ptr kismet_datasource::features(query const& q) const
{ {
if (! is_bound_) bind();
MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource::features()"; MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource::features()";
// TODO: use box2d to filter bbox before adding to featureset_ptr // TODO: use box2d to filter bbox before adding to featureset_ptr
@ -168,8 +153,6 @@ featureset_ptr kismet_datasource::features(query const& q) const
featureset_ptr kismet_datasource::features_at_point(coord2d const& pt, double tol) const featureset_ptr kismet_datasource::features_at_point(coord2d const& pt, double tol) const
{ {
if (! is_bound_) bind();
MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource::features_at_point()"; MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource::features_at_point()";
return featureset_ptr(); return featureset_ptr();

View file

@ -47,7 +47,7 @@
class kismet_datasource : public mapnik::datasource class kismet_datasource : public mapnik::datasource
{ {
public: public:
kismet_datasource(mapnik::parameters const& params, bool bind = true); kismet_datasource(mapnik::parameters const& params);
virtual ~kismet_datasource (); virtual ~kismet_datasource ();
datasource::datasource_t type() const; datasource::datasource_t type() const;
static const char * name(); static const char * name();
@ -56,7 +56,6 @@ public:
mapnik::box2d<double> envelope() const; mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const; boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const; mapnik::layer_descriptor get_descriptor() const;
void bind() const;
private: private:
void run (std::string const& host, const unsigned int port); void run (std::string const& host, const unsigned int port);
@ -67,7 +66,7 @@ private:
unsigned int port_; unsigned int port_;
mapnik::datasource::datasource_t type_; mapnik::datasource::datasource_t type_;
std::string srs_; std::string srs_;
mutable mapnik::layer_descriptor desc_; mapnik::layer_descriptor desc_;
boost::shared_ptr<boost::thread> kismet_thread; boost::shared_ptr<boost::thread> kismet_thread;
}; };

View file

@ -68,25 +68,29 @@ const std::string occi_datasource::METADATA_TABLE = "USER_SDO_GEOM_METADATA";
DATASOURCE_PLUGIN(occi_datasource) DATASOURCE_PLUGIN(occi_datasource)
occi_datasource::occi_datasource(parameters const& params, bool bind) occi_datasource::occi_datasource(parameters const& params)
: datasource (params), : datasource (params),
type_(datasource::Vector), type_(datasource::Vector),
fields_(*params_.get<std::string>("fields", "*")), fields_(*params.get<std::string>("fields", "*")),
geometry_field_(*params_.get<std::string>("geometry_field", "")), geometry_field_(*params.get<std::string>("geometry_field", "")),
srid_initialized_(false), srid_initialized_(false),
extent_initialized_(false), extent_initialized_(false),
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")), desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding", "utf-8")),
use_wkb_(*params_.get<mapnik::boolean>("use_wkb", false)), use_wkb_(*params.get<mapnik::boolean>("use_wkb", false)),
row_limit_(*params_.get<int>("row_limit", 0)), row_limit_(*params.get<int>("row_limit", 0)),
row_prefetch_(*params_.get<int>("row_prefetch", 100)), row_prefetch_(*params.get<int>("row_prefetch", 100)),
pool_(0), pool_(0),
conn_(0) conn_(0)
{ {
if (! params_.get<std::string>("user")) throw datasource_exception("OCCI Plugin: no <user> specified"); #ifdef MAPNIK_STATS
if (! params_.get<std::string>("password")) throw datasource_exception("OCCI Plugin: no <password> specified"); mapnik::progress_timer __stats__(std::clog, "occi_datasource::init");
if (! params_.get<std::string>("host")) throw datasource_exception("OCCI Plugin: no <host> string specified"); #endif
boost::optional<std::string> table = params_.get<std::string>("table"); if (! params.get<std::string>("user")) throw datasource_exception("OCCI Plugin: no <user> specified");
if (! params.get<std::string>("password")) throw datasource_exception("OCCI Plugin: no <password> specified");
if (! params.get<std::string>("host")) throw datasource_exception("OCCI Plugin: no <host> string specified");
boost::optional<std::string> table = params.get<std::string>("table");
if (! table) if (! table)
{ {
throw datasource_exception("OCCI Plugin: no <table> parameter specified"); throw datasource_exception("OCCI Plugin: no <table> parameter specified");
@ -95,57 +99,20 @@ occi_datasource::occi_datasource(parameters const& params, bool bind)
{ {
table_ = *table; table_ = *table;
} }
estimate_extent_ = *params.get<mapnik::boolean>("estimate_extent",false);
use_spatial_index_ = *params.get<mapnik::boolean>("use_spatial_index",true);
use_connection_pool_ = *params.get<mapnik::boolean>("use_connection_pool",true);
use_spatial_index_ = *params_.get<mapnik::boolean>("use_spatial_index",true); boost::optional<std::string> ext = params.get<std::string>("extent");
use_connection_pool_ = *params_.get<mapnik::boolean>("use_connection_pool",true);
boost::optional<std::string> ext = params_.get<std::string>("extent");
if (ext) extent_initialized_ = extent_.from_string(*ext); if (ext) extent_initialized_ = extent_.from_string(*ext);
boost::optional<int> srid = params_.get<int>("srid"); boost::optional<int> srid = params.get<int>("srid");
if (srid) if (srid)
{ {
srid_ = *srid; srid_ = *srid;
srid_initialized_ = true; srid_initialized_ = true;
} }
if (bind)
{
this->bind();
}
}
occi_datasource::~occi_datasource()
{
if (is_bound_)
{
Environment* env = occi_environment::get_environment();
if (use_connection_pool_)
{
if (pool_ != 0)
{
env->terminateStatelessConnectionPool(pool_, StatelessConnectionPool::SPD_FORCE);
}
}
else
{
if (conn_ != 0)
{
env->terminateConnection(conn_);
}
}
}
}
void occi_datasource::bind() const
{
if (is_bound_) return;
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "occi_datasource::bind");
#endif
// connect to environment // connect to environment
if (use_connection_pool_) if (use_connection_pool_)
{ {
@ -154,11 +121,11 @@ void occi_datasource::bind() const
Environment* env = occi_environment::get_environment(); Environment* env = occi_environment::get_environment();
pool_ = env->createStatelessConnectionPool( pool_ = env->createStatelessConnectionPool(
*params_.get<std::string>("user"), *params.get<std::string>("user"),
*params_.get<std::string>("password"), *params.get<std::string>("password"),
*params_.get<std::string>("host"), *params.get<std::string>("host"),
*params_.get<int>("max_size", 5), *params.get<int>("max_size", 5),
*params_.get<int>("initial_size", 1), *params.get<int>("initial_size", 1),
1, 1,
StatelessConnectionPool::HOMOGENEOUS); StatelessConnectionPool::HOMOGENEOUS);
} }
@ -174,9 +141,9 @@ void occi_datasource::bind() const
Environment* env = occi_environment::get_environment(); Environment* env = occi_environment::get_environment();
conn_ = env->createConnection( conn_ = env->createConnection(
*params_.get<std::string>("user"), *params.get<std::string>("user"),
*params_.get<std::string>("password"), *params.get<std::string>("password"),
*params_.get<std::string>("host")); *params.get<std::string>("host"));
} }
catch (SQLException& ex) catch (SQLException& ex)
{ {
@ -348,8 +315,28 @@ void occi_datasource::bind() const
throw datasource_exception(ex.getMessage()); throw datasource_exception(ex.getMessage());
} }
} }
}
is_bound_ = true; occi_datasource::~occi_datasource()
{
{
Environment* env = occi_environment::get_environment();
if (use_connection_pool_)
{
if (pool_ != 0)
{
env->terminateStatelessConnectionPool(pool_, StatelessConnectionPool::SPD_FORCE);
}
}
else
{
if (conn_ != 0)
{
env->terminateConnection(conn_);
}
}
}
} }
const char * occi_datasource::name() const char * occi_datasource::name()
@ -365,14 +352,11 @@ mapnik::datasource::datasource_t occi_datasource::type() const
box2d<double> occi_datasource::envelope() const box2d<double> occi_datasource::envelope() const
{ {
if (extent_initialized_) return extent_; if (extent_initialized_) return extent_;
if (! is_bound_) bind();
double lox = 0.0, loy = 0.0, hix = 0.0, hiy = 0.0; double lox = 0.0, loy = 0.0, hix = 0.0, hiy = 0.0;
boost::optional<mapnik::boolean> estimate_extent =
params_.get<mapnik::boolean>("estimate_extent",false);
if (estimate_extent && *estimate_extent) if (estimate_extent_)
{ {
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "occi_datasource::envelope(estimate_extent)"); mapnik::progress_timer __stats__(std::clog, "occi_datasource::envelope(estimate_extent)");
@ -487,22 +471,16 @@ box2d<double> occi_datasource::envelope() const
boost::optional<mapnik::datasource::geometry_t> occi_datasource::get_geometry_type() const boost::optional<mapnik::datasource::geometry_t> occi_datasource::get_geometry_type() const
{ {
// FIXME
//if (! is_bound_) bind();
return boost::optional<mapnik::datasource::geometry_t>(); return boost::optional<mapnik::datasource::geometry_t>();
} }
layer_descriptor occi_datasource::get_descriptor() const layer_descriptor occi_datasource::get_descriptor() const
{ {
if (! is_bound_) bind();
return desc_; return desc_;
} }
featureset_ptr occi_datasource::features(query const& q) const featureset_ptr occi_datasource::features(query const& q) const
{ {
if (! is_bound_) bind();
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "occi_datasource::features"); mapnik::progress_timer __stats__(std::clog, "occi_datasource::features");
#endif #endif
@ -592,8 +570,6 @@ featureset_ptr occi_datasource::features(query const& q) const
featureset_ptr occi_datasource::features_at_point(coord2d const& pt, double tol) const featureset_ptr occi_datasource::features_at_point(coord2d const& pt, double tol) const
{ {
if (! is_bound_) bind();
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "occi_datasource::features_at_point"); mapnik::progress_timer __stats__(std::clog, "occi_datasource::features_at_point");
#endif #endif

View file

@ -46,7 +46,7 @@
class occi_datasource : public mapnik::datasource class occi_datasource : public mapnik::datasource
{ {
public: public:
occi_datasource(mapnik::parameters const& params, bool bind = true); occi_datasource(mapnik::parameters const& params);
virtual ~occi_datasource (); virtual ~occi_datasource ();
mapnik::datasource::datasource_t type() const; mapnik::datasource::datasource_t type() const;
static const char * name(); static const char * name();
@ -55,28 +55,28 @@ public:
mapnik::box2d<double> envelope() const; mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const; boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const; mapnik::layer_descriptor get_descriptor() const;
void bind() const;
private: private:
static const std::string METADATA_TABLE; static const std::string METADATA_TABLE;
mapnik::datasource::datasource_t type_; mapnik::datasource::datasource_t type_;
mutable std::string table_; std::string table_;
mutable std::string table_name_; std::string table_name_;
mutable std::string fields_; std::string fields_;
mutable std::string geometry_field_; std::string geometry_field_;
mutable int srid_; int srid_;
mutable bool srid_initialized_; bool srid_initialized_;
mutable bool extent_initialized_; mutable bool extent_initialized_;
mutable mapnik::box2d<double> extent_; mutable mapnik::box2d<double> extent_;
mutable mapnik::layer_descriptor desc_; mapnik::layer_descriptor desc_;
mutable bool use_wkb_; bool use_wkb_;
int row_limit_; int row_limit_;
int row_prefetch_; int row_prefetch_;
mutable oracle::occi::StatelessConnectionPool* pool_; oracle::occi::StatelessConnectionPool* pool_;
mutable oracle::occi::Connection* conn_; oracle::occi::Connection* conn_;
bool use_connection_pool_; bool use_connection_pool_;
bool use_spatial_index_; bool use_spatial_index_;
bool estimate_extent_;
}; };
#endif // OCCI_DATASOURCE_HPP #endif // OCCI_DATASOURCE_HPP

View file

@ -57,13 +57,32 @@ using mapnik::filter_in_box;
using mapnik::filter_at_point; using mapnik::filter_at_point;
ogr_datasource::ogr_datasource(parameters const& params, bool bind) ogr_datasource::ogr_datasource(parameters const& params)
: datasource(params), : datasource(params),
extent_(), extent_(),
type_(datasource::Vector), type_(datasource::Vector),
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")), desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding", "utf-8")),
indexed_(false) indexed_(false)
{ {
init(params);
}
ogr_datasource::~ogr_datasource()
{
// free layer before destroying the datasource
layer_.free_layer();
OGRDataSource::DestroyDataSource (dataset_);
}
void ogr_datasource::init(mapnik::parameters const& params)
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "ogr_datasource::init");
#endif
// initialize ogr formats
OGRRegisterAll();
boost::optional<std::string> file = params.get<std::string>("file"); boost::optional<std::string> file = params.get<std::string>("file");
boost::optional<std::string> string = params.get<std::string>("string"); boost::optional<std::string> string = params.get<std::string>("string");
if (! file && ! string) if (! file && ! string)
@ -88,35 +107,7 @@ ogr_datasource::ogr_datasource(parameters const& params, bool bind)
} }
} }
if (bind) std::string driver = *params.get<std::string>("driver","");
{
this->bind();
}
}
ogr_datasource::~ogr_datasource()
{
if (is_bound_)
{
// free layer before destroying the datasource
layer_.free_layer();
OGRDataSource::DestroyDataSource (dataset_);
}
}
void ogr_datasource::bind() const
{
if (is_bound_) return;
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "ogr_datasource::bind");
#endif
// initialize ogr formats
OGRRegisterAll();
std::string driver = *params_.get<std::string>("driver","");
if (! driver.empty()) if (! driver.empty())
{ {
@ -147,9 +138,9 @@ void ogr_datasource::bind() const
} }
// initialize layer // initialize layer
boost::optional<std::string> layer_by_name = params_.get<std::string>("layer"); boost::optional<std::string> layer_by_name = params.get<std::string>("layer");
boost::optional<unsigned> layer_by_index = params_.get<unsigned>("layer_by_index"); boost::optional<unsigned> layer_by_index = params.get<unsigned>("layer_by_index");
boost::optional<std::string> layer_by_sql = params_.get<std::string>("layer_by_sql"); boost::optional<std::string> layer_by_sql = params.get<std::string>("layer_by_sql");
int passed_parameters = 0; int passed_parameters = 0;
passed_parameters += layer_by_name ? 1 : 0; passed_parameters += layer_by_name ? 1 : 0;
@ -185,7 +176,7 @@ void ogr_datasource::bind() const
else if (layer_by_sql) else if (layer_by_sql)
{ {
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats_sql__(std::clog, "ogr_datasource::bind(layer_by_sql)"); mapnik::progress_timer __stats_sql__(std::clog, "ogr_datasource::init(layer_by_sql)");
#endif #endif
layer_.layer_by_sql(dataset_, *layer_by_sql); layer_.layer_by_sql(dataset_, *layer_by_sql);
@ -278,7 +269,7 @@ void ogr_datasource::bind() const
#endif #endif
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats2__(std::clog, "ogr_datasource::bind(get_column_description)"); mapnik::progress_timer __stats2__(std::clog, "ogr_datasource::init(get_column_description)");
#endif #endif
// deal with attributes descriptions // deal with attributes descriptions
@ -328,8 +319,6 @@ void ogr_datasource::bind() const
} }
} }
} }
is_bound_ = true;
} }
const char * ogr_datasource::name() const char * ogr_datasource::name()
@ -344,7 +333,6 @@ mapnik::datasource::datasource_t ogr_datasource::type() const
box2d<double> ogr_datasource::envelope() const box2d<double> ogr_datasource::envelope() const
{ {
if (! is_bound_) bind();
return extent_; return extent_;
} }
@ -432,7 +420,6 @@ boost::optional<mapnik::datasource::geometry_t> ogr_datasource::get_geometry_typ
layer_descriptor ogr_datasource::get_descriptor() const layer_descriptor ogr_datasource::get_descriptor() const
{ {
if (! is_bound_) bind();
return desc_; return desc_;
} }
@ -475,8 +462,6 @@ void validate_attribute_names(query const& q, std::vector<attribute_descriptor>
featureset_ptr ogr_datasource::features(query const& q) const featureset_ptr ogr_datasource::features(query const& q) const
{ {
if (! is_bound_) bind();
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "ogr_datasource::features"); mapnik::progress_timer __stats__(std::clog, "ogr_datasource::features");
#endif #endif
@ -522,8 +507,6 @@ featureset_ptr ogr_datasource::features(query const& q) const
featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) const featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) const
{ {
if (!is_bound_) bind();
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "ogr_datasource::features_at_point"); mapnik::progress_timer __stats__(std::clog, "ogr_datasource::features_at_point");
#endif #endif

View file

@ -47,7 +47,7 @@
class ogr_datasource : public mapnik::datasource class ogr_datasource : public mapnik::datasource
{ {
public: public:
ogr_datasource(mapnik::parameters const& params, bool bind=true); ogr_datasource(mapnik::parameters const& params);
virtual ~ogr_datasource (); virtual ~ogr_datasource ();
mapnik::datasource::datasource_t type() const; mapnik::datasource::datasource_t type() const;
static const char * name(); static const char * name();
@ -56,18 +56,18 @@ public:
mapnik::box2d<double> envelope() const; mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const; boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const; mapnik::layer_descriptor get_descriptor() const;
void bind() const;
private: private:
mutable mapnik::box2d<double> extent_; void init(mapnik::parameters const& params);
mapnik::box2d<double> extent_;
mapnik::datasource::datasource_t type_; mapnik::datasource::datasource_t type_;
std::string dataset_name_; std::string dataset_name_;
mutable std::string index_name_; std::string index_name_;
mutable OGRDataSource* dataset_; OGRDataSource* dataset_;
mutable ogr_layer_ptr layer_; ogr_layer_ptr layer_;
mutable std::string layer_name_; std::string layer_name_;
mutable mapnik::layer_descriptor desc_; mapnik::layer_descriptor desc_;
mutable bool indexed_; bool indexed_;
}; };
#endif // OGR_DATASOURCE_HPP #endif // OGR_DATASOURCE_HPP

View file

@ -49,28 +49,17 @@ using mapnik::attribute_descriptor;
DATASOURCE_PLUGIN(osm_datasource) DATASOURCE_PLUGIN(osm_datasource)
osm_datasource::osm_datasource(const parameters& params, bool bind) osm_datasource::osm_datasource(const parameters& params)
: datasource (params), : datasource (params),
extent_(), extent_(),
type_(datasource::Vector), type_(datasource::Vector),
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")) desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding", "utf-8"))
{ {
if (bind)
{
this->bind();
}
}
void osm_datasource::bind() const
{
if (is_bound_) return;
osm_data_ = NULL; osm_data_ = NULL;
std::string osm_filename = *params_.get<std::string>("file", ""); std::string osm_filename = *params.get<std::string>("file", "");
std::string parser = *params_.get<std::string>("parser", "libxml2"); std::string parser = *params.get<std::string>("parser", "libxml2");
std::string url = *params_.get<std::string>("url", ""); std::string url = *params.get<std::string>("url", "");
std::string bbox = *params_.get<std::string>("bbox", ""); std::string bbox = *params.get<std::string>("bbox", "");
// load the data // load the data
if (url != "" && bbox != "") if (url != "" && bbox != "")
@ -118,7 +107,6 @@ void osm_datasource::bind() const
// Get the bounds of the data and set extent_ accordingly // Get the bounds of the data and set extent_ accordingly
bounds b = osm_data_->get_bounds(); bounds b = osm_data_->get_bounds();
extent_ = box2d<double>(b.w, b.s, b.e, b.n); extent_ = box2d<double>(b.w, b.s, b.e, b.n);
is_bound_ = true;
} }
osm_datasource::~osm_datasource() osm_datasource::~osm_datasource()
@ -144,8 +132,6 @@ layer_descriptor osm_datasource::get_descriptor() const
featureset_ptr osm_datasource::features(const query& q) const featureset_ptr osm_datasource::features(const query& q) const
{ {
if (!is_bound_) bind();
filter_in_box filter(q.get_bbox()); filter_in_box filter(q.get_bbox());
// so we need to filter osm features by bbox here... // so we need to filter osm features by bbox here...
@ -157,8 +143,6 @@ featureset_ptr osm_datasource::features(const query& q) const
featureset_ptr osm_datasource::features_at_point(coord2d const& pt, double tol) const featureset_ptr osm_datasource::features_at_point(coord2d const& pt, double tol) const
{ {
if (!is_bound_) bind();
filter_at_point filter(pt); filter_at_point filter(pt);
// collect all attribute names // collect all attribute names
std::vector<attribute_descriptor> const& desc_vector = desc_.get_descriptors(); std::vector<attribute_descriptor> const& desc_vector = desc_.get_descriptors();
@ -180,12 +164,10 @@ featureset_ptr osm_datasource::features_at_point(coord2d const& pt, double tol)
box2d<double> osm_datasource::envelope() const box2d<double> osm_datasource::envelope() const
{ {
if (!is_bound_) bind();
return extent_; return extent_;
} }
boost::optional<mapnik::datasource::geometry_t> osm_datasource::get_geometry_type() const boost::optional<mapnik::datasource::geometry_t> osm_datasource::get_geometry_type() const
{ {
if (! is_bound_) bind();
return boost::optional<mapnik::datasource::geometry_t>(mapnik::datasource::Collection); return boost::optional<mapnik::datasource::geometry_t>(mapnik::datasource::Collection);
} }

View file

@ -53,7 +53,7 @@ using mapnik::box2d;
class osm_datasource : public datasource class osm_datasource : public datasource
{ {
public: public:
osm_datasource(const parameters& params, bool bind = true); osm_datasource(const parameters& params);
virtual ~osm_datasource(); virtual ~osm_datasource();
mapnik::datasource::datasource_t type() const; mapnik::datasource::datasource_t type() const;
static const char * name(); static const char * name();
@ -62,13 +62,12 @@ public:
box2d<double> envelope() const; box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const; boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const; layer_descriptor get_descriptor() const;
void bind() const;
private: private:
mutable box2d<double> extent_; box2d<double> extent_;
mutable osm_dataset* osm_data_; osm_dataset* osm_data_;
mapnik::datasource::datasource_t type_; mapnik::datasource::datasource_t type_;
mutable layer_descriptor desc_; layer_descriptor desc_;
}; };
#endif // OSM_DATASOURCE_HPP #endif // OSM_DATASOURCE_HPP

View file

@ -55,20 +55,20 @@ using boost::shared_ptr;
using mapnik::PoolGuard; using mapnik::PoolGuard;
using mapnik::attribute_descriptor; using mapnik::attribute_descriptor;
postgis_datasource::postgis_datasource(parameters const& params, bool bind) postgis_datasource::postgis_datasource(parameters const& params)
: datasource(params), : datasource(params),
table_(*params_.get<std::string>("table", "")), table_(*params.get<std::string>("table", "")),
schema_(""), schema_(""),
geometry_table_(*params_.get<std::string>("geometry_table", "")), geometry_table_(*params.get<std::string>("geometry_table", "")),
geometry_field_(*params_.get<std::string>("geometry_field", "")), geometry_field_(*params.get<std::string>("geometry_field", "")),
key_field_(*params_.get<std::string>("key_field", "")), key_field_(*params.get<std::string>("key_field", "")),
cursor_fetch_size_(*params_.get<int>("cursor_size", 0)), cursor_fetch_size_(*params.get<int>("cursor_size", 0)),
row_limit_(*params_.get<int>("row_limit", 0)), row_limit_(*params.get<int>("row_limit", 0)),
type_(datasource::Vector), type_(datasource::Vector),
srid_(*params_.get<int>("srid", 0)), srid_(*params.get<int>("srid", 0)),
extent_initialized_(false), extent_initialized_(false),
simplify_geometries_(false), simplify_geometries_(false),
desc_(*params_.get<std::string>("type"), "utf-8"), desc_(*params.get<std::string>("type"), "utf-8"),
creator_(params.get<std::string>("host"), creator_(params.get<std::string>("host"),
params.get<std::string>("port"), params.get<std::string>("port"),
params.get<std::string>("dbname"), params.get<std::string>("dbname"),
@ -79,45 +79,32 @@ postgis_datasource::postgis_datasource(parameters const& params, bool bind)
scale_denom_token_("!scale_denominator!"), scale_denom_token_("!scale_denominator!"),
pixel_width_token_("!pixel_width!"), pixel_width_token_("!pixel_width!"),
pixel_height_token_("!pixel_height!"), pixel_height_token_("!pixel_height!"),
persist_connection_(*params_.get<mapnik::boolean>("persist_connection", true)), persist_connection_(*params.get<mapnik::boolean>("persist_connection", true)),
extent_from_subquery_(*params_.get<mapnik::boolean>("extent_from_subquery", false)), extent_from_subquery_(*params.get<mapnik::boolean>("extent_from_subquery", false)),
// params below are for testing purposes only (will likely be removed at any time) // params below are for testing purposes only (will likely be removed at any time)
intersect_min_scale_(*params_.get<int>("intersect_min_scale", 0)), intersect_min_scale_(*params.get<int>("intersect_min_scale", 0)),
intersect_max_scale_(*params_.get<int>("intersect_max_scale", 0)) intersect_max_scale_(*params.get<int>("intersect_max_scale", 0))
{ {
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "postgis_datasource::init");
#endif
if (table_.empty()) if (table_.empty())
{ {
throw mapnik::datasource_exception("Postgis Plugin: missing <table> parameter"); throw mapnik::datasource_exception("Postgis Plugin: missing <table> parameter");
} }
boost::optional<std::string> ext = params_.get<std::string>("extent"); boost::optional<std::string> ext = params.get<std::string>("extent");
if (ext && !ext->empty()) if (ext && !ext->empty())
{ {
extent_initialized_ = extent_.from_string(*ext); extent_initialized_ = extent_.from_string(*ext);
} }
if (bind) boost::optional<int> initial_size = params.get<int>("initial_size", 1);
{ boost::optional<int> max_size = params.get<int>("max_size", 10);
this->bind(); boost::optional<mapnik::boolean> autodetect_key_field = params.get<mapnik::boolean>("autodetect_key_field", false);
} boost::optional<mapnik::boolean> estimate_extent = params.get<mapnik::boolean>("estimate_extent", false);
} estimate_extent_ = estimate_extent && *estimate_extent;
boost::optional<mapnik::boolean> simplify_opt = params.get<mapnik::boolean>("simplify_geometries", false);
void postgis_datasource::bind() const
{
if (is_bound_)
{
return;
}
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "postgis_datasource::bind");
#endif
boost::optional<int> initial_size = params_.get<int>("initial_size", 1);
boost::optional<int> max_size = params_.get<int>("max_size", 10);
boost::optional<mapnik::boolean> autodetect_key_field = params_.get<mapnik::boolean>("autodetect_key_field", 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::instance().registerPool(creator_, *initial_size, *max_size); ConnectionManager::instance().registerPool(creator_, *initial_size, *max_size);
@ -158,7 +145,7 @@ void postgis_datasource::bind() const
if (geometryColumn_.empty() || srid_ == 0) if (geometryColumn_.empty() || srid_ == 0)
{ {
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats2__(std::clog, "postgis_datasource::bind(get_srid_and_geometry_column)"); mapnik::progress_timer __stats2__(std::clog, "postgis_datasource::init(get_srid_and_geometry_column)");
#endif #endif
std::ostringstream s; std::ostringstream s;
@ -424,14 +411,13 @@ void postgis_datasource::bind() const
rs->close(); rs->close();
is_bound_ = true; }
}
} }
} }
postgis_datasource::~postgis_datasource() postgis_datasource::~postgis_datasource()
{ {
if (is_bound_ && ! persist_connection_) if (! persist_connection_)
{ {
shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id()); shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id());
if (pool) if (pool)
@ -457,11 +443,6 @@ mapnik::datasource::datasource_t postgis_datasource::type() const
layer_descriptor postgis_datasource::get_descriptor() const layer_descriptor postgis_datasource::get_descriptor() const
{ {
if (! is_bound_)
{
bind();
}
return desc_; return desc_;
} }
@ -603,11 +584,6 @@ boost::shared_ptr<IResultSet> postgis_datasource::get_resultset(boost::shared_pt
featureset_ptr postgis_datasource::features(const query& q) const featureset_ptr postgis_datasource::features(const query& q) const
{ {
if (! is_bound_)
{
bind();
}
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "postgis_datasource::features"); mapnik::progress_timer __stats__(std::clog, "postgis_datasource::features");
#endif #endif
@ -725,11 +701,6 @@ featureset_ptr postgis_datasource::features(const query& q) const
featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double tol) const featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double tol) const
{ {
if (! is_bound_)
{
bind();
}
#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
@ -817,11 +788,6 @@ box2d<double> postgis_datasource::envelope() const
return extent_; return extent_;
} }
if (! is_bound_)
{
bind();
}
shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id()); shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id());
if (pool) if (pool)
{ {
@ -832,9 +798,6 @@ box2d<double> postgis_datasource::envelope() const
std::ostringstream s; std::ostringstream s;
boost::optional<mapnik::boolean> estimate_extent =
params_.get<mapnik::boolean>("estimate_extent", false);
if (geometryColumn_.empty()) if (geometryColumn_.empty())
{ {
std::ostringstream s_error; std::ostringstream s_error;
@ -852,7 +815,7 @@ box2d<double> postgis_datasource::envelope() const
throw mapnik::datasource_exception("Postgis Plugin: " + s_error.str()); throw mapnik::datasource_exception("Postgis Plugin: " + s_error.str());
} }
if (estimate_extent && *estimate_extent) if (estimate_extent_)
{ {
s << "SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext)" s << "SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext)"
<< " FROM (SELECT ST_Estimated_Extent('"; << " FROM (SELECT ST_Estimated_Extent('";
@ -915,11 +878,6 @@ box2d<double> postgis_datasource::envelope() const
boost::optional<mapnik::datasource::geometry_t> postgis_datasource::get_geometry_type() const boost::optional<mapnik::datasource::geometry_t> postgis_datasource::get_geometry_type() const
{ {
if (! is_bound_)
{
bind();
}
boost::optional<mapnik::datasource::geometry_t> result; boost::optional<mapnik::datasource::geometry_t> result;
shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id()); shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id());

View file

@ -58,7 +58,7 @@ using mapnik::coord2d;
class postgis_datasource : public datasource class postgis_datasource : public datasource
{ {
public: public:
postgis_datasource(const parameters &params, bool bind=true); postgis_datasource(const parameters &params);
~postgis_datasource(); ~postgis_datasource();
mapnik::datasource::datasource_t type() const; mapnik::datasource::datasource_t type() const;
static const char * name(); static const char * name();
@ -67,7 +67,6 @@ public:
mapnik::box2d<double> envelope() const; mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const; boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const; layer_descriptor get_descriptor() const;
void bind() const;
private: private:
std::string sql_bbox(box2d<double> const& env) const; std::string sql_bbox(box2d<double> const& env) const;
@ -84,19 +83,19 @@ private:
const std::string username_; const std::string username_;
const std::string password_; const std::string password_;
const std::string table_; const std::string table_;
mutable std::string schema_; std::string schema_;
mutable std::string geometry_table_; std::string geometry_table_;
const std::string geometry_field_; const std::string geometry_field_;
mutable std::string key_field_; std::string key_field_;
const int cursor_fetch_size_; const int cursor_fetch_size_;
const int row_limit_; const int row_limit_;
mutable std::string geometryColumn_; std::string geometryColumn_;
mapnik::datasource::datasource_t type_; mapnik::datasource::datasource_t type_;
mutable int srid_; int srid_;
mutable bool extent_initialized_; mutable bool extent_initialized_;
mutable mapnik::box2d<double> extent_; mutable mapnik::box2d<double> extent_;
mutable bool simplify_geometries_; bool simplify_geometries_;
mutable layer_descriptor desc_; layer_descriptor desc_;
ConnectionCreator<Connection> creator_; ConnectionCreator<Connection> creator_;
const std::string bbox_token_; const std::string bbox_token_;
const std::string scale_denom_token_; const std::string scale_denom_token_;
@ -104,6 +103,7 @@ private:
const std::string pixel_height_token_; const std::string pixel_height_token_;
bool persist_connection_; bool persist_connection_;
bool extent_from_subquery_; bool extent_from_subquery_;
bool estimate_extent_;
// params below are for testing purposes only (will likely be removed at any time) // params below are for testing purposes only (will likely be removed at any time)
int intersect_min_scale_; int intersect_min_scale_;
int intersect_max_scale_; int intersect_max_scale_;

View file

@ -75,8 +75,9 @@ feature_ptr postgis_featureset::next()
const char* buf = rs_->getValue(pos); const char* buf = rs_->getValue(pos);
std::string name = rs_->getFieldName(pos); std::string name = rs_->getFieldName(pos);
// validation happens of this type at bind() // validation happens of this type at initialization
mapnik::value_integer val; mapnik::value_integer val;
if (oid == 20) if (oid == 20)
{ {
val = int8net(buf); val = int8net(buf);

View file

@ -20,53 +20,27 @@ using mapnik::parameters;
DATASOURCE_PLUGIN(python_datasource) DATASOURCE_PLUGIN(python_datasource)
python_datasource::python_datasource(parameters const& params, bool bind) python_datasource::python_datasource(parameters const& params)
: datasource(params), : datasource(params),
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding","utf-8")), desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding","utf-8")),
factory_(*params_.get<std::string>("factory", "")) factory_(*params.get<std::string>("factory", ""))
{ {
// extract any remaining parameters as keyword args for the factory // extract any remaining parameters as keyword args for the factory
BOOST_FOREACH(const mapnik::parameters::value_type& kv, params_) BOOST_FOREACH(const mapnik::parameters::value_type& kv, params)
{ {
if((kv.first != "type") && (kv.first != "factory")) if((kv.first != "type") && (kv.first != "factory"))
{ {
kwargs_.insert(std::make_pair(kv.first, *params_.get<std::string>(kv.first))); kwargs_.insert(std::make_pair(kv.first, *params.get<std::string>(kv.first)));
} }
} }
if (bind) // The following methods call into the Python interpreter and hence require, unfortunately, that the GIL be held.
{
this->bind();
}
}
python_datasource::~python_datasource() { }
// This name must match the plugin filename, eg 'python.input'
const char* python_datasource::name_="python";
const char* python_datasource::name()
{
return name_;
}
mapnik::layer_descriptor python_datasource::get_descriptor() const
{
if (!is_bound_) bind();
return desc_;
}
// The following methods call into the Python interpreter and hence require, unfortunately, that the GIL be held.
void python_datasource::bind() const
{
using namespace boost; using namespace boost;
if (is_bound_) return; if (factory_.empty())
{
// if no factory callable is defined, bind is a nop throw mapnik::datasource_exception("Python: 'factory' option must be defined");
if (factory_.empty()) return; }
try try
{ {
@ -111,16 +85,27 @@ void python_datasource::bind() const
{ {
throw mapnik::datasource_exception(extractException()); throw mapnik::datasource_exception(extractException());
} }
}
is_bound_ = true; python_datasource::~python_datasource() { }
// This name must match the plugin filename, eg 'python.input'
const char* python_datasource::name_="python";
const char* python_datasource::name()
{
return name_;
}
mapnik::layer_descriptor python_datasource::get_descriptor() const
{
return desc_;
} }
mapnik::datasource::datasource_t python_datasource::type() const mapnik::datasource::datasource_t python_datasource::type() const
{ {
typedef boost::optional<mapnik::datasource::geometry_t> return_type; typedef boost::optional<mapnik::datasource::geometry_t> return_type;
if (!is_bound_) bind();
try try
{ {
ensure_gil lock; ensure_gil lock;
@ -137,8 +122,6 @@ mapnik::datasource::datasource_t python_datasource::type() const
mapnik::box2d<double> python_datasource::envelope() const mapnik::box2d<double> python_datasource::envelope() const
{ {
if (!is_bound_) bind();
try try
{ {
ensure_gil lock; ensure_gil lock;
@ -154,8 +137,6 @@ boost::optional<mapnik::datasource::geometry_t> python_datasource::get_geometry_
{ {
typedef boost::optional<mapnik::datasource::geometry_t> return_type; typedef boost::optional<mapnik::datasource::geometry_t> return_type;
if (!is_bound_) bind();
try try
{ {
ensure_gil lock; ensure_gil lock;
@ -181,8 +162,6 @@ boost::optional<mapnik::datasource::geometry_t> python_datasource::get_geometry_
mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const
{ {
if (!is_bound_) bind();
try try
{ {
// if the query box intersects our world extent then query for features // if the query box intersects our world extent then query for features
@ -209,8 +188,6 @@ mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const
mapnik::featureset_ptr python_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const mapnik::featureset_ptr python_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
{ {
if (!is_bound_) bind();
try try
{ {
ensure_gil lock; ensure_gil lock;

View file

@ -12,7 +12,7 @@ class python_datasource : public mapnik::datasource
public: public:
// constructor // constructor
// arguments must not change // arguments must not change
python_datasource(mapnik::parameters const& params, bool bind=true); python_datasource(mapnik::parameters const& params);
// destructor // destructor
virtual ~python_datasource (); virtual ~python_datasource ();
@ -41,15 +41,12 @@ public:
// mandatory: return the layer descriptor // mandatory: return the layer descriptor
mapnik::layer_descriptor get_descriptor() const; mapnik::layer_descriptor get_descriptor() const;
// mandatory: will bind the datasource given params
void bind() const;
private: private:
static const char* name_; static const char* name_;
mutable mapnik::layer_descriptor desc_; mapnik::layer_descriptor desc_;
const std::string factory_; const std::string factory_;
std::map<std::string, std::string> kwargs_; std::map<std::string, std::string> kwargs_;
mutable boost::python::object datasource_; boost::python::object datasource_;
}; };

View file

@ -45,7 +45,7 @@ using mapnik::image_reader;
DATASOURCE_PLUGIN(raster_datasource) DATASOURCE_PLUGIN(raster_datasource)
raster_datasource::raster_datasource(parameters const& params, bool bind) raster_datasource::raster_datasource(parameters const& params)
: datasource(params), : datasource(params),
desc_(*params.get<std::string>("type"), "utf-8"), desc_(*params.get<std::string>("type"), "utf-8"),
extent_initialized_(false) extent_initialized_(false)
@ -61,18 +61,19 @@ raster_datasource::raster_datasource(parameters const& params, bool bind)
else else
filename_ = *file; filename_ = *file;
multi_tiles_ = *params_.get<bool>("multi", false); multi_tiles_ = *params.get<bool>("multi", false);
tile_size_ = *params_.get<unsigned>("tile_size", 256); tile_size_ = *params.get<unsigned>("tile_size", 256);
tile_stride_ = *params_.get<unsigned>("tile_stride", 1); tile_stride_ = *params.get<unsigned>("tile_stride", 1);
format_ = *params_.get<std::string>("format","tiff"); format_ = *params.get<std::string>("format","tiff");
boost::optional<double> lox = params_.get<double>("lox");
boost::optional<double> loy = params_.get<double>("loy");
boost::optional<double> hix = params_.get<double>("hix");
boost::optional<double> hiy = params_.get<double>("hiy");
boost::optional<std::string> ext = params_.get<std::string>("extent");
boost::optional<double> lox = params.get<double>("lox");
boost::optional<double> loy = params.get<double>("loy");
boost::optional<double> hix = params.get<double>("hix");
boost::optional<double> hiy = params.get<double>("hiy");
boost::optional<std::string> ext = params.get<std::string>("extent");
if (lox && loy && hix && hiy) if (lox && loy && hix && hiy)
{ {
extent_.init(*lox, *loy, *hix, *hiy); extent_.init(*lox, *loy, *hix, *hiy);
@ -87,21 +88,11 @@ raster_datasource::raster_datasource(parameters const& params, bool bind)
{ {
throw datasource_exception("Raster Plugin: valid <extent> or <lox> <loy> <hix> <hiy> are required"); throw datasource_exception("Raster Plugin: valid <extent> or <lox> <loy> <hix> <hiy> are required");
} }
if (bind)
{
this->bind();
}
}
void raster_datasource::bind() const
{
if (is_bound_) return;
if (multi_tiles_) if (multi_tiles_)
{ {
boost::optional<unsigned> x_width = params_.get<unsigned>("x_width"); boost::optional<unsigned> x_width = params.get<unsigned>("x_width");
boost::optional<unsigned> y_width = params_.get<unsigned>("y_width"); boost::optional<unsigned> y_width = params.get<unsigned>("y_width");
if (! x_width) if (! x_width)
{ {
@ -148,7 +139,6 @@ void raster_datasource::bind() const
MAPNIK_LOG_DEBUG(raster) << "raster_datasource: Raster size=" << width_ << "," << height_; MAPNIK_LOG_DEBUG(raster) << "raster_datasource: Raster size=" << width_ << "," << height_;
is_bound_ = true;
} }
raster_datasource::~raster_datasource() raster_datasource::~raster_datasource()
@ -182,8 +172,6 @@ layer_descriptor raster_datasource::get_descriptor() const
featureset_ptr raster_datasource::features(query const& q) const featureset_ptr raster_datasource::features(query const& q) const
{ {
if (! is_bound_) bind();
mapnik::CoordTransform t(width_, height_, extent_, 0, 0); mapnik::CoordTransform t(width_, height_, extent_, 0, 0);
mapnik::box2d<double> intersect = extent_.intersect(q.get_bbox()); mapnik::box2d<double> intersect = extent_.intersect(q.get_bbox());
mapnik::box2d<double> ext = t.forward(intersect); mapnik::box2d<double> ext = t.forward(intersect);

View file

@ -44,7 +44,7 @@
class raster_datasource : public mapnik::datasource class raster_datasource : public mapnik::datasource
{ {
public: public:
raster_datasource(const mapnik::parameters& params, bool bind=true); raster_datasource(const mapnik::parameters& params);
virtual ~raster_datasource(); virtual ~raster_datasource();
datasource::datasource_t type() const; datasource::datasource_t type() const;
static const char * name(); static const char * name();
@ -54,7 +54,6 @@ public:
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const; boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const; mapnik::layer_descriptor get_descriptor() const;
bool log_enabled() const; bool log_enabled() const;
void bind() const;
private: private:
mapnik::layer_descriptor desc_; mapnik::layer_descriptor desc_;
@ -65,8 +64,8 @@ private:
bool multi_tiles_; bool multi_tiles_;
unsigned tile_size_; unsigned tile_size_;
unsigned tile_stride_; unsigned tile_stride_;
mutable unsigned width_; unsigned width_;
mutable unsigned height_; unsigned height_;
}; };
#endif // RASTER_DATASOURCE_HPP #endif // RASTER_DATASOURCE_HPP

View file

@ -71,7 +71,7 @@ inline void* rasterlite_datasource::open_dataset() const
} }
rasterlite_datasource::rasterlite_datasource(parameters const& params, bool bind) rasterlite_datasource::rasterlite_datasource(parameters const& params)
: datasource(params), : datasource(params),
desc_(*params.get<std::string>("type"),"utf-8") desc_(*params.get<std::string>("type"),"utf-8")
{ {
@ -91,16 +91,11 @@ rasterlite_datasource::rasterlite_datasource(parameters const& params, bool bind
else else
dataset_name_ = *file; dataset_name_ = *file;
if (bind) this->init(params);
{
this->bind();
}
} }
void rasterlite_datasource::bind() const void rasterlite_datasource::init(mapnik::parameters const& params)
{ {
if (is_bound_) return;
if (!boost::filesystem::exists(dataset_name_)) throw datasource_exception(dataset_name_ + " does not exist"); if (!boost::filesystem::exists(dataset_name_)) throw datasource_exception(dataset_name_ + " does not exist");
void *dataset = open_dataset(); void *dataset = open_dataset();
@ -158,8 +153,6 @@ void rasterlite_datasource::bind() const
#endif #endif
rasterliteClose(dataset); rasterliteClose(dataset);
is_bound_ = true;
} }
rasterlite_datasource::~rasterlite_datasource() rasterlite_datasource::~rasterlite_datasource()
@ -178,8 +171,6 @@ mapnik::datasource::datasource_t rasterlite_datasource::type() const
box2d<double> rasterlite_datasource::envelope() const box2d<double> rasterlite_datasource::envelope() const
{ {
if (!is_bound_) bind();
return extent_; return extent_;
} }
@ -195,16 +186,12 @@ layer_descriptor rasterlite_datasource::get_descriptor() const
featureset_ptr rasterlite_datasource::features(query const& q) const featureset_ptr rasterlite_datasource::features(query const& q) const
{ {
if (!is_bound_) bind();
rasterlite_query gq = q; rasterlite_query gq = q;
return boost::make_shared<rasterlite_featureset>(open_dataset(), gq); return boost::make_shared<rasterlite_featureset>(open_dataset(), gq);
} }
featureset_ptr rasterlite_datasource::features_at_point(coord2d const& pt, double tol) const featureset_ptr rasterlite_datasource::features_at_point(coord2d const& pt, double tol) const
{ {
if (!is_bound_) bind();
rasterlite_query gq = pt; rasterlite_query gq = pt;
return boost::make_shared<rasterlite_featureset>(open_dataset(), gq); return boost::make_shared<rasterlite_featureset>(open_dataset(), gq);
} }

View file

@ -45,7 +45,7 @@
class rasterlite_datasource : public mapnik::datasource class rasterlite_datasource : public mapnik::datasource
{ {
public: public:
rasterlite_datasource(mapnik::parameters const& params, bool bind = true); rasterlite_datasource(mapnik::parameters const& params);
virtual ~rasterlite_datasource (); virtual ~rasterlite_datasource ();
mapnik::datasource::datasource_t type() const; mapnik::datasource::datasource_t type() const;
static const char * name(); static const char * name();
@ -54,11 +54,10 @@ public:
mapnik::box2d<double> envelope() const; mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const; boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const; mapnik::layer_descriptor get_descriptor() const;
void bind() const;
private: private:
void* open_dataset() const; void* open_dataset() const;
mutable mapnik::box2d<double> extent_; mapnik::box2d<double> extent_;
std::string dataset_name_; std::string dataset_name_;
std::string table_name_; std::string table_name_;
mapnik::layer_descriptor desc_; mapnik::layer_descriptor desc_;

View file

@ -23,9 +23,11 @@
#ifndef DBFFILE_HPP #ifndef DBFFILE_HPP
#define DBFFILE_HPP #define DBFFILE_HPP
// mapnik
#include <mapnik/feature.hpp> #include <mapnik/feature.hpp>
#include <mapnik/noncopyable.hpp>
// boost // boost
#include <boost/utility.hpp>
#include <boost/interprocess/streams/bufferstream.hpp> #include <boost/interprocess/streams/bufferstream.hpp>
// stl // stl
@ -48,7 +50,7 @@ struct field_descriptor
}; };
class dbf_file : private boost::noncopyable class dbf_file : private mapnik::noncopyable
{ {
private: private:
int num_records_; int num_records_;

View file

@ -55,14 +55,17 @@ using mapnik::filter_in_box;
using mapnik::filter_at_point; using mapnik::filter_at_point;
using mapnik::attribute_descriptor; using mapnik::attribute_descriptor;
shape_datasource::shape_datasource(const parameters &params, bool bind) shape_datasource::shape_datasource(const parameters &params)
: datasource (params), : datasource (params),
type_(datasource::Vector), type_(datasource::Vector),
file_length_(0), file_length_(0),
indexed_(false), indexed_(false),
row_limit_(*params_.get<int>("row_limit",0)), row_limit_(*params.get<int>("row_limit",0)),
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding","utf-8")) desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding","utf-8"))
{ {
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::init");
#endif
boost::optional<std::string> file = params.get<std::string>("file"); boost::optional<std::string> file = params.get<std::string>("file");
if (!file) throw datasource_exception("Shape Plugin: missing <file> parameter"); if (!file) throw datasource_exception("Shape Plugin: missing <file> parameter");
@ -74,20 +77,6 @@ shape_datasource::shape_datasource(const parameters &params, bool bind)
boost::algorithm::ireplace_last(shape_name_,".shp",""); boost::algorithm::ireplace_last(shape_name_,".shp","");
if (bind)
{
this->bind();
}
}
void shape_datasource::bind() const
{
if (is_bound_) return;
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::bind");
#endif
if (!boost::filesystem::exists(shape_name_ + ".shp")) if (!boost::filesystem::exists(shape_name_ + ".shp"))
{ {
throw datasource_exception("Shape Plugin: shapefile '" + shape_name_ + ".shp' does not exist"); throw datasource_exception("Shape Plugin: shapefile '" + shape_name_ + ".shp' does not exist");
@ -107,7 +96,7 @@ void shape_datasource::bind() const
try try
{ {
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats2__(std::clog, "shape_datasource::bind(get_column_description)"); mapnik::progress_timer __stats2__(std::clog, "shape_datasource::init(get_column_description)");
#endif #endif
boost::shared_ptr<shape_io> shape_ref = boost::make_shared<shape_io>(shape_name_); boost::shared_ptr<shape_io> shape_ref = boost::make_shared<shape_io>(shape_name_);
@ -171,12 +160,9 @@ void shape_datasource::bind() const
throw; throw;
} }
is_bound_ = true;
} }
shape_datasource::~shape_datasource() {} void shape_datasource::init(shape_io& shape)
void shape_datasource::init(shape_io& shape) const
{ {
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::init"); mapnik::progress_timer __stats__(std::clog, "shape_datasource::init");
@ -240,6 +226,8 @@ void shape_datasource::init(shape_io& shape) const
MAPNIK_LOG_DEBUG(shape) << "shape_datasource: Shape type=" << shape_type_; MAPNIK_LOG_DEBUG(shape) << "shape_datasource: Shape type=" << shape_type_;
} }
shape_datasource::~shape_datasource() {}
const char * shape_datasource::name() const char * shape_datasource::name()
{ {
return "shape"; return "shape";
@ -252,14 +240,11 @@ datasource::datasource_t shape_datasource::type() const
layer_descriptor shape_datasource::get_descriptor() const layer_descriptor shape_datasource::get_descriptor() const
{ {
if (!is_bound_) bind();
return desc_; return desc_;
} }
featureset_ptr shape_datasource::features(const query& q) const featureset_ptr shape_datasource::features(const query& q) const
{ {
if (!is_bound_) bind();
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::features"); mapnik::progress_timer __stats__(std::clog, "shape_datasource::features");
#endif #endif
@ -290,8 +275,6 @@ featureset_ptr shape_datasource::features(const query& q) const
featureset_ptr shape_datasource::features_at_point(coord2d const& pt, double tol) const featureset_ptr shape_datasource::features_at_point(coord2d const& pt, double tol) const
{ {
if (!is_bound_) bind();
#ifdef MAPNIK_STATS #ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::features_at_point"); mapnik::progress_timer __stats__(std::clog, "shape_datasource::features_at_point");
#endif #endif
@ -334,8 +317,6 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt, double tol
box2d<double> shape_datasource::envelope() const box2d<double> shape_datasource::envelope() const
{ {
if (!is_bound_) bind();
return extent_; return extent_;
} }

View file

@ -52,7 +52,7 @@ using mapnik::coord2d;
class shape_datasource : public datasource class shape_datasource : public datasource
{ {
public: public:
shape_datasource(const parameters &params, bool bind=true); shape_datasource(const parameters &params);
virtual ~shape_datasource(); virtual ~shape_datasource();
datasource::datasource_t type() const; datasource::datasource_t type() const;
static const char * name(); static const char * name();
@ -61,20 +61,19 @@ public:
box2d<double> envelope() const; box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const; boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const; layer_descriptor get_descriptor() const;
void bind() const;
private: private:
void init(shape_io& shape) const; void init(shape_io& shape);
datasource::datasource_t type_; datasource::datasource_t type_;
std::string shape_name_; std::string shape_name_;
mutable boost::shared_ptr<shape_io> shape_; boost::shared_ptr<shape_io> shape_;
mutable shape_io::shapeType shape_type_; shape_io::shapeType shape_type_;
mutable long file_length_; long file_length_;
mutable box2d<double> extent_; box2d<double> extent_;
mutable bool indexed_; bool indexed_;
const int row_limit_; const int row_limit_;
mutable layer_descriptor desc_; layer_descriptor desc_;
}; };
#endif //SHAPE_HPP #endif //SHAPE_HPP

View file

@ -175,7 +175,8 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c
double x = record.read_double(); double x = record.read_double();
double y = record.read_double(); double y = record.read_double();
poly->move_to(x, y); poly->move_to(x, y);
double start_x = x;
double start_y = y;
for (int j=start+1;j<end-1;j++) for (int j=start+1;j<end-1;j++)
{ {
x = record.read_double(); x = record.read_double();
@ -184,8 +185,14 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c
} }
x = record.read_double(); x = record.read_double();
y = record.read_double(); y = record.read_double();
poly->close(x, y); if (x == start_x && y == start_y)
{
poly->close(x, y);
}
else
{
poly->line_to(x, y);
}
geom.push_back(poly); geom.push_back(poly);
} }
} }

Some files were not shown because too many files have changed in this diff Show more