Merge commit '6b7c16297032aa24bab0950b2a837e58c7d52c86' into harfbuzz
Conflicts: src/grid/process_shield_symbolizer.cpp
This commit is contained in:
commit
fe54e4a6a1
129 changed files with 1692 additions and 1195 deletions
|
@ -10,4 +10,4 @@ before_install:
|
|||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-system-dev libboost-thread-dev python-nose libicu-dev libpng-dev libjpeg-dev libtiff-dev libz-dev libfreetype6-dev libxml2-dev libproj-dev libpq-dev libgdal-dev libcairomm-1.0-dev python-cairo-dev libsqlite3-dev
|
||||
|
||||
script: scons configure JOBS=2 FAST=True CXX="$CXX $CXX_SCONS" WARNING_CXXFLAGS=$WARNING_CXXFLAGS && sudo make install
|
||||
script: scons configure DEMO=False CPP_TESTS=False CAIRO=False INPUT_PLUGINS=shape,csv,osm OPTIMIZATION=2 JOBS=2 FAST=True CXX="$CXX $CXX_SCONS" WARNING_CXXFLAGS=$WARNING_CXXFLAGS && sudo make install
|
||||
|
|
|
@ -8,6 +8,12 @@ For a complete change history, see the git log.
|
|||
|
||||
## Future
|
||||
|
||||
- Added 64 bit integer support in the grid_renderer (#1662)
|
||||
|
||||
- `<Filter>[attr]</Filter>` now returns false if attr is an empty string (#1665)
|
||||
|
||||
- Added 64 bit integer support in expressions and feature ids (#1661,#1662)
|
||||
|
||||
- Added support for DBF `Logical` type: #1614
|
||||
|
||||
- Added serialization of `line-offset` to save_map (#1562)
|
||||
|
|
11
SConstruct
11
SConstruct
|
@ -330,6 +330,7 @@ opts.AddVariables(
|
|||
BoolVariable('RENDERING_STATS', 'Output rendering statistics during style processing', 'False'),
|
||||
|
||||
BoolVariable('SVG_RENDERER', 'build support for native svg renderer', 'False'),
|
||||
BoolVariable('CPP_TESTS', 'Compile the C++ tests', 'True'),
|
||||
|
||||
# Variables for optional dependencies
|
||||
('GEOS_CONFIG', 'The path to the geos-config executable.', 'geos-config'),
|
||||
|
@ -1746,13 +1747,11 @@ if not HELP_REQUESTED:
|
|||
SConscript('fonts/build.py')
|
||||
|
||||
# build C++ tests
|
||||
# not ready for release
|
||||
SConscript('tests/cpp_tests/build.py')
|
||||
if env['CPP_TESTS']:
|
||||
SConscript('tests/cpp_tests/build.py')
|
||||
|
||||
# not currently maintained
|
||||
# https://github.com/mapnik/mapnik/issues/1438
|
||||
if env['SVG_RENDERER']:
|
||||
SConscript('tests/cpp_tests/svg_renderer_tests/build.py')
|
||||
if env['SVG_RENDERER']:
|
||||
SConscript('tests/cpp_tests/svg_renderer_tests/build.py')
|
||||
|
||||
# install pkg-config script and mapnik-config script
|
||||
SConscript('utils/mapnik-config/build.py')
|
||||
|
|
|
@ -50,24 +50,15 @@ namespace
|
|||
using namespace boost::python;
|
||||
boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
|
||||
{
|
||||
bool bind=true;
|
||||
mapnik::parameters params;
|
||||
boost::python::list keys=d.keys();
|
||||
for (int i=0; i<len(keys); ++i)
|
||||
{
|
||||
std::string key = extract<std::string>(keys[i]);
|
||||
object obj = d[key];
|
||||
|
||||
if (key == "bind")
|
||||
{
|
||||
bind = extract<bool>(obj)();
|
||||
continue;
|
||||
}
|
||||
|
||||
extract<std::string> ex0(obj);
|
||||
extract<int> ex1(obj);
|
||||
extract<mapnik::value_integer> ex1(obj);
|
||||
extract<double> ex2(obj);
|
||||
|
||||
if (ex0.check())
|
||||
{
|
||||
params[key] = ex0();
|
||||
|
@ -82,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)
|
||||
|
@ -170,7 +161,6 @@ void export_datasource()
|
|||
.def("describe",&describe)
|
||||
.def("envelope",&datasource::envelope)
|
||||
.def("features",&datasource::features)
|
||||
.def("bind",&datasource::bind)
|
||||
.def("fields",&fields)
|
||||
.def("field_types",&field_types)
|
||||
.def("features_at_point",&datasource::features_at_point, (arg("coord"),arg("tolerance")=0))
|
||||
|
|
|
@ -31,22 +31,14 @@ using namespace boost::python;
|
|||
|
||||
boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
|
||||
{
|
||||
bool bind=true;
|
||||
mapnik::parameters params;
|
||||
boost::python::list keys=d.keys();
|
||||
for (int i=0; i<len(keys); ++i)
|
||||
{
|
||||
std::string key = extract<std::string>(keys[i]);
|
||||
object obj = d[key];
|
||||
|
||||
if (key == "bind")
|
||||
{
|
||||
bind = extract<bool>(obj)();
|
||||
continue;
|
||||
}
|
||||
|
||||
extract<std::string> ex0(obj);
|
||||
extract<int> ex1(obj);
|
||||
extract<mapnik::value_integer> ex1(obj);
|
||||
extract<double> ex2(obj);
|
||||
|
||||
if (ex0.check())
|
||||
|
@ -63,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)
|
||||
|
|
|
@ -59,6 +59,11 @@ mapnik::value expression_evaluate_(mapnik::expr_node const& expr, mapnik::Featur
|
|||
return boost::apply_visitor(mapnik::evaluate<mapnik::Feature,mapnik::value>(f),expr);
|
||||
}
|
||||
|
||||
bool expression_evaluate_to_bool_(mapnik::expr_node const& expr, mapnik::Feature const& f)
|
||||
{
|
||||
return boost::apply_visitor(mapnik::evaluate<mapnik::Feature,mapnik::value>(f),expr).to_bool();
|
||||
}
|
||||
|
||||
// path expression
|
||||
path_expression_ptr parse_path_(std::string const& path)
|
||||
{
|
||||
|
@ -82,6 +87,7 @@ void export_expression()
|
|||
"TODO"
|
||||
"",no_init)
|
||||
.def("evaluate", &expression_evaluate_)
|
||||
.def("to_bool", &expression_evaluate_to_bool_)
|
||||
.def("__str__",&expression_to_string_);
|
||||
;
|
||||
|
||||
|
|
|
@ -196,11 +196,11 @@ void export_feature()
|
|||
// Python to mapnik::value converters
|
||||
// NOTE: order matters here. For example value_null must be listed before
|
||||
// bool otherwise Py_None will be interpreted as bool (false)
|
||||
implicitly_convertible<UnicodeString,mapnik::value>();
|
||||
implicitly_convertible<mapnik::value_unicode_string,mapnik::value>();
|
||||
implicitly_convertible<mapnik::value_null,mapnik::value>();
|
||||
implicitly_convertible<bool,mapnik::value>();
|
||||
implicitly_convertible<int,mapnik::value>();
|
||||
implicitly_convertible<double,mapnik::value>();
|
||||
implicitly_convertible<mapnik::value_integer,mapnik::value>();
|
||||
implicitly_convertible<mapnik::value_double,mapnik::value>();
|
||||
implicitly_convertible<mapnik::value_bool,mapnik::value>();
|
||||
|
||||
// http://misspent.wordpress.com/2009/09/27/how-to-write-boost-python-converters/
|
||||
UnicodeString_from_python_str();
|
||||
|
@ -212,7 +212,7 @@ void export_feature()
|
|||
;
|
||||
|
||||
class_<Feature,boost::shared_ptr<Feature>,
|
||||
boost::noncopyable>("Feature",init<context_ptr,int>("Default ctor."))
|
||||
boost::noncopyable>("Feature",init<context_ptr,mapnik::value_integer>("Default ctor."))
|
||||
.def("id",&Feature::id)
|
||||
.def("__str__",&Feature::to_string)
|
||||
.def("add_geometries_from_wkb", &feature_add_geometries_from_wkb)
|
||||
|
|
|
@ -39,13 +39,12 @@ bool painted(mapnik::grid const& grid)
|
|||
return grid.painted();
|
||||
}
|
||||
|
||||
int get_pixel(mapnik::grid const& grid, int x, int y)
|
||||
mapnik::grid::value_type get_pixel(mapnik::grid const& grid, int x, int y)
|
||||
{
|
||||
if (x < static_cast<int>(grid.width()) && y < static_cast<int>(grid.height()))
|
||||
{
|
||||
mapnik::grid::value_type const * row = grid.getRow(y);
|
||||
mapnik::grid::value_type const pixel = row[x];
|
||||
return pixel;
|
||||
mapnik::grid::data_type const & data = grid.data();
|
||||
return data(x,y);
|
||||
}
|
||||
PyErr_SetString(PyExc_IndexError, "invalid x,y for grid dimensions");
|
||||
boost::python::throw_error_already_set();
|
||||
|
|
|
@ -78,7 +78,7 @@ struct parameters_pickle_suite : boost::python::pickle_suite
|
|||
std::string key = extract<std::string>(keys[i]);
|
||||
object obj = d[key];
|
||||
extract<std::string> ex0(obj);
|
||||
extract<int> ex1(obj);
|
||||
extract<mapnik::value_integer> ex1(obj);
|
||||
extract<double> ex2(obj);
|
||||
extract<UnicodeString> ex3(obj);
|
||||
|
||||
|
@ -185,7 +185,7 @@ boost::shared_ptr<mapnik::parameter> create_parameter_from_string(std::string co
|
|||
return boost::make_shared<mapnik::parameter>(key,mapnik::value_holder(value));
|
||||
}
|
||||
|
||||
boost::shared_ptr<mapnik::parameter> create_parameter_from_int(std::string const& key, int value)
|
||||
boost::shared_ptr<mapnik::parameter> create_parameter_from_int(std::string const& key, mapnik::value_integer value)
|
||||
{
|
||||
return boost::make_shared<mapnik::parameter>(key,mapnik::value_holder(value));
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace boost { namespace python {
|
|||
|
||||
struct value_converter : public boost::static_visitor<PyObject*>
|
||||
{
|
||||
PyObject * operator() (int val) const
|
||||
PyObject * operator() (mapnik::value_integer val) const
|
||||
{
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
return ::PyLong_FromLong(val);
|
||||
|
|
|
@ -52,14 +52,14 @@ struct geometry_type_attribute
|
|||
template <typename V, typename F>
|
||||
V value(F const& f) const
|
||||
{
|
||||
int type = 0;
|
||||
mapnik::value_integer type = 0;
|
||||
geometry_container::const_iterator itr = f.paths().begin();
|
||||
geometry_container::const_iterator end = f.paths().end();
|
||||
for ( ; itr != end; ++itr)
|
||||
{
|
||||
if (type != 0 && itr->type() != type)
|
||||
{
|
||||
return 4; // Collection
|
||||
return value_integer(4); // Collection
|
||||
}
|
||||
type = itr->type();
|
||||
}
|
||||
|
|
|
@ -86,10 +86,7 @@ public:
|
|||
};
|
||||
|
||||
datasource (parameters const& params)
|
||||
: params_(params),
|
||||
is_bound_(false)
|
||||
{
|
||||
}
|
||||
: params_(params) {}
|
||||
|
||||
/*!
|
||||
* @brief Get the configuration parameters of the data source.
|
||||
|
@ -108,12 +105,6 @@ public:
|
|||
* @return The type of the datasource (Vector or Raster)
|
||||
*/
|
||||
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_at_point(coord2d const& pt, double tol = 0) const = 0;
|
||||
virtual box2d<double> envelope() const = 0;
|
||||
|
@ -122,11 +113,10 @@ public:
|
|||
virtual ~datasource() {}
|
||||
protected:
|
||||
parameters params_;
|
||||
mutable bool is_bound_;
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
class datasource_deleter
|
||||
|
@ -145,9 +135,9 @@ typedef boost::shared_ptr<datasource> datasource_ptr;
|
|||
{ \
|
||||
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) \
|
||||
{ \
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
std::string plugin_directories();
|
||||
void register_datasources(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:
|
||||
datasource_cache();
|
||||
~datasource_cache();
|
||||
|
|
|
@ -108,7 +108,7 @@ struct regex_replace_impl
|
|||
mapnik::transcoder const& tr_;
|
||||
};
|
||||
|
||||
struct geometry_types : qi::symbols<char,int>
|
||||
struct geometry_types : qi::symbols<char,mapnik::value_integer>
|
||||
{
|
||||
geometry_types()
|
||||
{
|
||||
|
@ -121,6 +121,12 @@ struct geometry_types : qi::symbols<char,int>
|
|||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct integer_parser
|
||||
{
|
||||
typedef qi::int_parser<T,10,1,-1> type;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
|
||||
{
|
||||
|
@ -129,6 +135,7 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
|
|||
explicit expression_grammar(mapnik::transcoder const& tr);
|
||||
|
||||
qi::real_parser<double, qi::strict_real_policies<double> > strict_double;
|
||||
typename integer_parser<mapnik::value_integer>::type int__;
|
||||
boost::phoenix::function<unicode_impl> unicode_;
|
||||
boost::phoenix::function<regex_match_impl> regex_match_;
|
||||
boost::phoenix::function<regex_replace_impl> regex_replace_;
|
||||
|
|
|
@ -106,7 +106,7 @@ public:
|
|||
typedef std::vector<value_type> cont_type;
|
||||
typedef feature_kv_iterator iterator;
|
||||
|
||||
feature_impl(context_ptr const& ctx, int id)
|
||||
feature_impl(context_ptr const& ctx, mapnik::value_integer id)
|
||||
: id_(id),
|
||||
ctx_(ctx),
|
||||
data_(ctx_->mapping_.size()),
|
||||
|
@ -114,9 +114,9 @@ public:
|
|||
raster_()
|
||||
{}
|
||||
|
||||
inline int id() const { return id_;}
|
||||
inline mapnik::value_integer id() const { return id_;}
|
||||
|
||||
inline void set_id(int id) { id_ = id;}
|
||||
inline void set_id(mapnik::value_integer id) { id_ = id;}
|
||||
|
||||
template <typename T>
|
||||
void put(context_type::key_type const& key, T const& val)
|
||||
|
@ -181,13 +181,6 @@ public:
|
|||
return default_value;
|
||||
}
|
||||
|
||||
boost::optional<value_type const&> get_optional(std::size_t index) const
|
||||
{
|
||||
if (index < data_.size())
|
||||
return boost::optional<value_type const&>(data_[index]);
|
||||
return boost::optional<value_type const&>();
|
||||
}
|
||||
|
||||
std::size_t size() const
|
||||
{
|
||||
return data_.size();
|
||||
|
@ -304,7 +297,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
int id_;
|
||||
mapnik::value_integer id_;
|
||||
context_ptr ctx_;
|
||||
cont_type data_;
|
||||
boost::ptr_vector<geometry_type> geom_cont_;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/make_shared.hpp>
|
||||
|
@ -34,7 +35,7 @@ namespace mapnik
|
|||
{
|
||||
struct feature_factory
|
||||
{
|
||||
static boost::shared_ptr<Feature> create (context_ptr const& ctx, int fid)
|
||||
static boost::shared_ptr<Feature> create (context_ptr const& ctx, mapnik::value_integer fid)
|
||||
{
|
||||
//return boost::allocate_shared<Feature>(boost::pool_allocator<Feature>(),fid);
|
||||
//return boost::allocate_shared<Feature>(boost::fast_pool_allocator<Feature>(),fid);
|
||||
|
|
|
@ -91,10 +91,11 @@ public:
|
|||
double x = 0;
|
||||
double y = 0;
|
||||
rewind(0);
|
||||
for (unsigned i=0;i<size();++i)
|
||||
for (unsigned i=0; i < size(); ++i)
|
||||
{
|
||||
vertex(&x,&y);
|
||||
if (i==0)
|
||||
unsigned cmd = vertex(&x,&y);
|
||||
if (cmd == SEG_CLOSE) continue;
|
||||
if (i == 0)
|
||||
{
|
||||
result.init(x,y,x,y);
|
||||
}
|
||||
|
@ -126,11 +127,31 @@ public:
|
|||
push_vertex(x,y,SEG_CLOSE);
|
||||
}
|
||||
|
||||
void close()
|
||||
void set_close()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ public:
|
|||
|
||||
};
|
||||
|
||||
typedef MAPNIK_DECL hit_grid<int> grid;
|
||||
typedef MAPNIK_DECL hit_grid<mapnik::value_integer> grid;
|
||||
|
||||
}
|
||||
#endif //MAPNIK_GRID_HPP
|
||||
|
|
|
@ -44,8 +44,8 @@ namespace mapnik {
|
|||
template <typename BufferType, typename Rasterizer, typename PixFmt, typename RendererBase, typename RendererType, typename Detector, typename PixMapType>
|
||||
struct raster_markers_rasterizer_dispatch_grid
|
||||
{
|
||||
typedef mapnik::gray32 color_type;
|
||||
typedef typename RendererBase::pixfmt_type pixfmt_type;
|
||||
typedef typename RendererBase::pixfmt_type::color_type color_type;
|
||||
|
||||
raster_markers_rasterizer_dispatch_grid(BufferType & render_buffer,
|
||||
Rasterizer & ras,
|
||||
|
@ -156,7 +156,7 @@ struct raster_markers_rasterizer_dispatch_grid
|
|||
ras_.line_to_d(p[4],p[5]);
|
||||
ras_.line_to_d(p[6],p[7]);
|
||||
RendererType ren(renb_);
|
||||
ren.color(mapnik::gray32(feature_.id()));
|
||||
ren.color(color_type(feature_.id()));
|
||||
agg::render_scanlines(ras_, sl_, ren);
|
||||
}
|
||||
|
||||
|
|
|
@ -165,12 +165,17 @@ struct gray16
|
|||
static self_type no_color() { return self_type(0,0); }
|
||||
};
|
||||
|
||||
//==================================================================gray16
|
||||
//==================================================================gray32
|
||||
struct gray32
|
||||
{
|
||||
typedef agg::int32 value_type;
|
||||
typedef agg::int64u calc_type;
|
||||
typedef agg::int64 long_type;
|
||||
// NOTE: don't touch this enum since enums cannot be
|
||||
// 64 bit and we need to ensure that alpha = base_mask
|
||||
// in grid_pixfmt.hpp#blend_hiline#l256
|
||||
// otherwise code will get invoked that breaks
|
||||
// with 32 bit or 64 bit ints (blender_gray::blend_pix)
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = 16,
|
||||
|
@ -186,8 +191,8 @@ struct gray32
|
|||
gray32() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(unsigned v_, unsigned a_=base_mask) :
|
||||
v(agg::int32(v_)), a(agg::int32(a_)) {}
|
||||
gray32(value_type v_, unsigned a_=base_mask) :
|
||||
v(v_), a(value_type(a_)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(const self_type& c, unsigned a_) :
|
||||
|
@ -302,6 +307,148 @@ struct gray32
|
|||
static self_type no_color() { return self_type(0,0); }
|
||||
};
|
||||
|
||||
//==================================================================gray64
|
||||
struct gray64
|
||||
{
|
||||
typedef agg::int64 value_type;
|
||||
typedef agg::int64u calc_type;
|
||||
typedef agg::int64 long_type;
|
||||
// NOTE: don't touch this enum since enums cannot be
|
||||
// 64 bit and we need to ensure that alpha = base_mask
|
||||
// in grid_pixfmt.hpp#blend_hiline#l256
|
||||
// otherwise code will get invoked that breaks
|
||||
// with 32 bit or 64 bit ints (blender_gray::blend_pix)
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = 16,
|
||||
base_scale = 1 << base_shift,
|
||||
base_mask = base_scale - 1
|
||||
};
|
||||
typedef gray64 self_type;
|
||||
|
||||
value_type v;
|
||||
value_type a;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray64() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray64(value_type v_, unsigned a_=base_mask) :
|
||||
v(v_), a(value_type(a_)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray64(const self_type& c, unsigned a_) :
|
||||
v(c.v), a(value_type(a_)) {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void clear()
|
||||
{
|
||||
v = a = 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const self_type& transparent()
|
||||
{
|
||||
a = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void opacity(double a_)
|
||||
{
|
||||
if(a_ < 0.0) a_ = 0.0;
|
||||
if(a_ > 1.0) a_ = 1.0;
|
||||
a = (value_type)agg::uround(a_ * double(base_mask));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
double opacity() const
|
||||
{
|
||||
return double(a) / double(base_mask);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const self_type& premultiply()
|
||||
{
|
||||
if(a == base_mask) return *this;
|
||||
if(a == 0)
|
||||
{
|
||||
v = 0;
|
||||
return *this;
|
||||
}
|
||||
v = value_type((calc_type(v) * a) >> base_shift);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const self_type& premultiply(unsigned a_)
|
||||
{
|
||||
if(a == base_mask && a_ >= base_mask) return *this;
|
||||
if(a == 0 || a_ == 0)
|
||||
{
|
||||
v = a = 0;
|
||||
return *this;
|
||||
}
|
||||
calc_type v_ = (calc_type(v) * a_) / a;
|
||||
v = value_type((v_ > a_) ? a_ : v_);
|
||||
a = value_type(a_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const self_type& demultiply()
|
||||
{
|
||||
if(a == base_mask) return *this;
|
||||
if(a == 0)
|
||||
{
|
||||
v = 0;
|
||||
return *this;
|
||||
}
|
||||
calc_type v_ = (calc_type(v) * base_mask) / a;
|
||||
v = value_type((v_ > base_mask) ? base_mask : v_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
self_type gradient(self_type c, double k) const
|
||||
{
|
||||
self_type ret;
|
||||
calc_type ik = agg::uround(k * base_scale);
|
||||
ret.v = value_type(calc_type(v) + (((calc_type(c.v) - v) * ik) >> base_shift));
|
||||
ret.a = value_type(calc_type(a) + (((calc_type(c.a) - a) * ik) >> base_shift));
|
||||
return ret;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void add(const self_type& c, unsigned cover)
|
||||
{
|
||||
calc_type cv, ca;
|
||||
if(cover == agg::cover_mask)
|
||||
{
|
||||
if(c.a == base_mask)
|
||||
{
|
||||
*this = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
cv = v + c.v; v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
|
||||
ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv = v + ((c.v * cover + agg::cover_mask/2) >> agg::cover_shift);
|
||||
ca = a + ((c.a * cover + agg::cover_mask/2) >> agg::cover_shift);
|
||||
v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
|
||||
a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static self_type no_color() { return self_type(0,0); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -258,7 +258,16 @@ public:
|
|||
const color_type& c,
|
||||
agg::int8u cover)
|
||||
{
|
||||
if (c.a)
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
do
|
||||
{
|
||||
*p = c.v;
|
||||
p += Step;
|
||||
}
|
||||
while(--len);
|
||||
// We ignore alpha since grid_renderer is a binary renderer for now
|
||||
/*if (c.a)
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
|
@ -282,7 +291,7 @@ public:
|
|||
}
|
||||
while(--len);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -638,7 +647,12 @@ typedef pixfmt_alpha_blend_gray<blender_gray16,
|
|||
typedef blender_gray<gray32> blender_gray32;
|
||||
|
||||
typedef pixfmt_alpha_blend_gray<blender_gray32,
|
||||
mapnik::grid_rendering_buffer> pixfmt_gray32; //----pixfmt_gray16
|
||||
mapnik::grid_rendering_buffer> pixfmt_gray32; //----pixfmt_gray32
|
||||
|
||||
typedef blender_gray<gray64> blender_gray64;
|
||||
|
||||
typedef pixfmt_alpha_blend_gray<blender_gray64,
|
||||
mapnik::grid_rendering_buffer> pixfmt_gray64; //----pixfmt_gray64
|
||||
|
||||
}
|
||||
|
||||
|
|
36
include/mapnik/grid/grid_renderer_base.hpp
Normal file
36
include/mapnik/grid/grid_renderer_base.hpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* 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_GRID_RENDERER_BASE_HPP
|
||||
#define MAPNIK_GRID_RENDERER_BASE_HPP
|
||||
|
||||
#include "agg_renderer_base.h"
|
||||
#include <mapnik/grid/grid_pixfmt.hpp>
|
||||
#include <mapnik/grid/grid_pixel.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
typedef agg::renderer_base<mapnik::pixfmt_gray64> grid_renderer_base_type;
|
||||
|
||||
}
|
||||
|
||||
#endif //MAPNIK_AGG_RASTERIZER_HPP
|
|
@ -201,7 +201,7 @@ private:
|
|||
feature_type const& features_;
|
||||
};
|
||||
|
||||
typedef hit_grid_view<mapnik::ImageData<int> > grid_view;
|
||||
typedef hit_grid_view<mapnik::ImageData<mapnik::value_integer> > grid_view;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -186,7 +186,8 @@ struct feature_generator_grammar:
|
|||
using boost::spirit::karma::lit;
|
||||
using boost::spirit::karma::uint_;
|
||||
using boost::spirit::karma::bool_;
|
||||
using boost::spirit::karma::int_;
|
||||
//using boost::spirit::karma::int_;
|
||||
//using boost::spirit::karma::long_long;
|
||||
using boost::spirit::karma::double_;
|
||||
using boost::spirit::karma::_val;
|
||||
using boost::spirit::karma::_1;
|
||||
|
@ -212,7 +213,7 @@ struct feature_generator_grammar:
|
|||
<< value(phoenix::at_c<1>(_val))
|
||||
;
|
||||
|
||||
value = (value_null_| bool_ | int_| double_ | ustring)[_1 = value_base_(_r1)]
|
||||
value = (value_null_| bool_ | int__ | double_ | ustring)[_1 = value_base_(_r1)]
|
||||
;
|
||||
|
||||
value_null_ = string[_1 = "null"]
|
||||
|
@ -231,6 +232,7 @@ struct feature_generator_grammar:
|
|||
karma::rule<OutputIterator, void(mapnik::value const&)> value;
|
||||
karma::rule<OutputIterator, mapnik::value_null()> value_null_;
|
||||
karma::rule<OutputIterator, UnicodeString()> ustring;
|
||||
typename karma::int_generator<mapnik::value_integer,10, false> int__;
|
||||
// phoenix functions
|
||||
phoenix::function<get_id> id_;
|
||||
phoenix::function<value_base> value_base_;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
// spirit::qi
|
||||
#include <boost/config/warning_disable.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/phoenix.hpp>
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
|
@ -59,6 +60,7 @@ public:
|
|||
{
|
||||
return mapnik::value(val);
|
||||
}
|
||||
|
||||
mapnik::transcoder const& tr_;
|
||||
};
|
||||
|
||||
|
@ -109,9 +111,11 @@ struct feature_grammar :
|
|||
qi::rule<Iterator,space_type> value;
|
||||
qi::symbols<char const, char const> unesc_char;
|
||||
qi::uint_parser< unsigned, 16, 4, 4 > hex4 ;
|
||||
qi::int_parser<mapnik::value_integer,10,1,-1> int__;
|
||||
qi::rule<Iterator,std::string(), space_type> string_;
|
||||
qi::rule<Iterator,space_type> key_value;
|
||||
qi::rule<Iterator,boost::variant<value_null,bool,int,double>(),space_type> number;
|
||||
qi::rule<Iterator,boost::variant<value_null,bool,
|
||||
value_integer,value_double>(),space_type> number;
|
||||
qi::rule<Iterator,space_type> object;
|
||||
qi::rule<Iterator,space_type> array;
|
||||
qi::rule<Iterator,space_type> pairs;
|
||||
|
@ -123,7 +127,7 @@ struct feature_grammar :
|
|||
|
||||
qi::rule<Iterator,void(FeatureType &),space_type> properties;
|
||||
qi::rule<Iterator,qi::locals<std::string>, void(FeatureType &),space_type> attributes;
|
||||
qi::rule<Iterator,boost::variant<value_null,bool,int,double,std::string>(), space_type> attribute_value;
|
||||
qi::rule<Iterator,boost::variant<value_null,bool,value_integer,value_double,std::string>(), space_type> attribute_value;
|
||||
|
||||
phoenix::function<put_property> put_property_;
|
||||
phoenix::function<extract_geometry> extract_geometry_;
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <boost/spirit/include/phoenix_function.hpp>
|
||||
#include <boost/spirit/home/phoenix/statement/if.hpp>
|
||||
#include <boost/fusion/include/boost_tuple.hpp>
|
||||
#include <boost/math/special_functions/trunc.hpp> // trunc to avoid needing C++11
|
||||
|
||||
|
||||
//#define BOOST_SPIRIT_USE_PHOENIX_V3 1
|
||||
|
@ -116,7 +117,28 @@ struct json_coordinate_policy : karma::real_policies<T>
|
|||
{
|
||||
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 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);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ struct close_path
|
|||
void operator() (T path) const
|
||||
{
|
||||
BOOST_ASSERT( path!=0 );
|
||||
path->close();
|
||||
path->set_close();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
std::string const& srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
|
||||
|
||||
layer(layer const& l);
|
||||
layer& operator=(layer const& l);
|
||||
layer& operator=(layer const& rhs);
|
||||
bool operator==(layer const& other) const;
|
||||
|
||||
/*!
|
||||
|
@ -197,7 +197,7 @@ public:
|
|||
int buffer_size() const;
|
||||
~layer();
|
||||
private:
|
||||
void swap(const layer& other);
|
||||
void swap(layer& other);
|
||||
|
||||
std::string name_;
|
||||
std::string srs_;
|
||||
|
|
45
include/mapnik/noncopyable.hpp
Normal file
45
include/mapnik/noncopyable.hpp
Normal 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
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
namespace mapnik
|
||||
{
|
||||
typedef boost::variant<value_null,int,double,std::string> value_holder;
|
||||
typedef boost::variant<value_null,value_integer,value_double,std::string> value_holder;
|
||||
typedef std::pair<std::string, value_holder> parameter;
|
||||
typedef std::map<std::string, value_holder> param_map;
|
||||
|
||||
|
|
|
@ -104,6 +104,11 @@ public:
|
|||
// nothing to do
|
||||
}
|
||||
|
||||
inline eAttributeCollectionPolicy attribute_collection_policy() const
|
||||
{
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
inline OutputIterator& get_output_iterator()
|
||||
{
|
||||
return output_iterator_;
|
||||
|
|
|
@ -272,7 +272,7 @@ public:
|
|||
curved_.approximation_scale(scl);
|
||||
curved_.angle_tolerance(0.0);
|
||||
|
||||
rgba8 color;
|
||||
typename PixelFormat::color_type color;
|
||||
|
||||
if (attr.fill_flag || attr.fill_gradient.get_gradient_type() != NO_GRADIENT)
|
||||
{
|
||||
|
@ -380,7 +380,7 @@ public:
|
|||
curved_.approximation_scale(scl);
|
||||
curved_.angle_tolerance(0.0);
|
||||
|
||||
mapnik::gray32 color(feature_id);
|
||||
typename PixelFormat::color_type color(feature_id);
|
||||
|
||||
if (attr.fill_flag || attr.fill_gradient.get_gradient_type() != NO_GRADIENT)
|
||||
{
|
||||
|
|
|
@ -50,6 +50,9 @@ namespace mapnik { namespace util {
|
|||
MAPNIK_DECL bool string2int(const char * value, int & result);
|
||||
MAPNIK_DECL bool string2int(std::string const& value, int & result);
|
||||
|
||||
MAPNIK_DECL bool string2longlong(const char * value, boost::long_long_type & result);
|
||||
MAPNIK_DECL bool string2longlong(std::string const& value, boost::long_long_type & result);
|
||||
|
||||
MAPNIK_DECL bool string2double(std::string const& value, double & result);
|
||||
MAPNIK_DECL bool string2double(const char * value, double & result);
|
||||
|
||||
|
@ -70,12 +73,80 @@ template <typename T>
|
|||
struct double_policy : boost::spirit::karma::real_policies<T>
|
||||
{
|
||||
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>
|
||||
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);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -172,6 +172,8 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
|
|||
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double start_x = 0;
|
||||
double start_y = 0;
|
||||
std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings
|
||||
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)
|
||||
{
|
||||
rings.push_back(new linear_ring); // start new loop
|
||||
start_x = x;
|
||||
start_y = y;
|
||||
size += 4; // num_points
|
||||
}
|
||||
else if (command == SEG_CLOSE)
|
||||
{
|
||||
x = start_x;
|
||||
y = start_y;
|
||||
}
|
||||
rings.back().push_back(std::make_pair(x,y));
|
||||
size += 2 * 8; // point
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <boost/fusion/include/boost_tuple.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
|
||||
|
||||
namespace boost { namespace spirit { namespace traits {
|
||||
|
@ -92,13 +93,40 @@ struct multi_geometry_
|
|||
|
||||
template <typename U>
|
||||
struct result { typedef bool type; };
|
||||
|
||||
bool operator() (geometry_container const& geom) const
|
||||
{
|
||||
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>
|
||||
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;
|
||||
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& ()> 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 (unsigned& )> polygon_coord;
|
||||
karma::rule<OutputIterator, karma::locals<double,double>, coord_type (unsigned&, double&, double& )> polygon_coord;
|
||||
|
||||
// phoenix functions
|
||||
phoenix::function<detail::get_type<geometry_type> > _type;
|
||||
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;
|
||||
};
|
||||
|
|
|
@ -107,7 +107,19 @@ struct value_null
|
|||
}
|
||||
};
|
||||
|
||||
typedef boost::variant<value_null,bool,int,double,UnicodeString> value_base;
|
||||
#define BIGINT
|
||||
|
||||
#ifdef BIGINT
|
||||
typedef long long value_integer;
|
||||
#else
|
||||
typedef int value_integer;
|
||||
#endif
|
||||
|
||||
typedef double value_double;
|
||||
typedef UnicodeString value_unicode_string;
|
||||
typedef bool value_bool;
|
||||
|
||||
typedef boost::variant<value_null,value_bool,value_integer,value_double,value_unicode_string> value_base;
|
||||
|
||||
namespace impl {
|
||||
|
||||
|
@ -126,18 +138,18 @@ struct equals
|
|||
return lhs == rhs;
|
||||
}
|
||||
|
||||
bool operator() (int lhs, double rhs) const
|
||||
bool operator() (value_integer lhs, value_double rhs) const
|
||||
{
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
||||
bool operator() (double lhs, int rhs) const
|
||||
bool operator() (value_double lhs, value_integer rhs) const
|
||||
{
|
||||
return (lhs == rhs)? true : false ;
|
||||
}
|
||||
|
||||
bool operator() (UnicodeString const& lhs,
|
||||
UnicodeString const& rhs) const
|
||||
bool operator() (value_unicode_string const& lhs,
|
||||
value_unicode_string const& rhs) const
|
||||
{
|
||||
return (lhs == rhs) ? true: false;
|
||||
}
|
||||
|
@ -164,18 +176,18 @@ struct not_equals
|
|||
return lhs != rhs;
|
||||
}
|
||||
|
||||
bool operator() (int lhs, double rhs) const
|
||||
bool operator() (value_integer lhs, value_double rhs) const
|
||||
{
|
||||
return lhs != rhs;
|
||||
}
|
||||
|
||||
bool operator() (double lhs, int rhs) const
|
||||
bool operator() (value_double lhs, value_integer rhs) const
|
||||
{
|
||||
return lhs != rhs;
|
||||
}
|
||||
|
||||
bool operator() (UnicodeString const& lhs,
|
||||
UnicodeString const& rhs) const
|
||||
bool operator() (value_unicode_string const& lhs,
|
||||
value_unicode_string const& rhs) const
|
||||
{
|
||||
return (lhs != rhs)? true : false;
|
||||
}
|
||||
|
@ -215,17 +227,17 @@ struct greater_than
|
|||
return lhs > rhs;
|
||||
}
|
||||
|
||||
bool operator() (int lhs, double rhs) const
|
||||
bool operator() (value_integer lhs, value_double rhs) const
|
||||
{
|
||||
return lhs > rhs;
|
||||
}
|
||||
|
||||
bool operator() (double lhs, int rhs) const
|
||||
bool operator() (value_double lhs, value_integer rhs) const
|
||||
{
|
||||
return lhs > rhs;
|
||||
}
|
||||
|
||||
bool operator() (UnicodeString const& lhs, UnicodeString const& rhs) const
|
||||
bool operator() (value_unicode_string const& lhs, value_unicode_string const& rhs) const
|
||||
{
|
||||
return (lhs > rhs) ? true : false ;
|
||||
}
|
||||
|
@ -251,17 +263,17 @@ struct greater_or_equal
|
|||
return lhs >= rhs;
|
||||
}
|
||||
|
||||
bool operator() (int lhs, double rhs) const
|
||||
bool operator() (value_integer lhs, value_double rhs) const
|
||||
{
|
||||
return lhs >= rhs;
|
||||
}
|
||||
|
||||
bool operator() (double lhs, int rhs) const
|
||||
bool operator() (value_double lhs, value_integer rhs) const
|
||||
{
|
||||
return lhs >= rhs;
|
||||
}
|
||||
|
||||
bool operator() (UnicodeString const& lhs, UnicodeString const& rhs) const
|
||||
bool operator() (value_unicode_string const& lhs, value_unicode_string const& rhs) const
|
||||
{
|
||||
return ( lhs >= rhs ) ? true : false ;
|
||||
}
|
||||
|
@ -287,18 +299,18 @@ struct less_than
|
|||
return lhs < rhs;
|
||||
}
|
||||
|
||||
bool operator() (int lhs, double rhs) const
|
||||
bool operator() (value_integer lhs, value_double rhs) const
|
||||
{
|
||||
return lhs < rhs;
|
||||
}
|
||||
|
||||
bool operator() (double lhs, int rhs) const
|
||||
bool operator() (value_double lhs, value_integer rhs) const
|
||||
{
|
||||
return lhs < rhs;
|
||||
}
|
||||
|
||||
bool operator()(UnicodeString const& lhs,
|
||||
UnicodeString const& rhs ) const
|
||||
bool operator()(value_unicode_string const& lhs,
|
||||
value_unicode_string const& rhs ) const
|
||||
{
|
||||
return (lhs < rhs) ? true : false ;
|
||||
}
|
||||
|
@ -324,18 +336,18 @@ struct less_or_equal
|
|||
return lhs <= rhs;
|
||||
}
|
||||
|
||||
bool operator() (int lhs, double rhs) const
|
||||
bool operator() (value_integer lhs, value_double rhs) const
|
||||
{
|
||||
return lhs <= rhs;
|
||||
}
|
||||
|
||||
bool operator() (double lhs, int rhs) const
|
||||
bool operator() (value_double lhs, value_integer rhs) const
|
||||
{
|
||||
return lhs <= rhs;
|
||||
}
|
||||
|
||||
bool operator()(UnicodeString const& lhs,
|
||||
UnicodeString const& rhs ) const
|
||||
bool operator()(value_unicode_string const& lhs,
|
||||
value_unicode_string const& rhs ) const
|
||||
{
|
||||
return (lhs <= rhs) ? true : false ;
|
||||
}
|
||||
|
@ -350,6 +362,51 @@ template <typename V>
|
|||
struct add : public boost::static_visitor<V>
|
||||
{
|
||||
typedef V value_type;
|
||||
value_type operator() (value_unicode_string const& lhs ,
|
||||
value_unicode_string const& rhs ) const
|
||||
{
|
||||
return lhs + rhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_double lhs, value_integer rhs) const
|
||||
{
|
||||
return lhs + rhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_integer lhs, value_double rhs) const
|
||||
{
|
||||
return lhs + rhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_unicode_string const& lhs, value_null rhs) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(rhs);
|
||||
return lhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_null lhs, value_unicode_string const& rhs) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(lhs);
|
||||
return rhs;
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
value_type operator() (value_unicode_string const& lhs, R const& rhs) const
|
||||
{
|
||||
std::string val;
|
||||
if (util::to_string(val,rhs))
|
||||
return lhs + value_unicode_string(val.c_str());
|
||||
return lhs;
|
||||
}
|
||||
|
||||
template <typename L>
|
||||
value_type operator() (L const& lhs , value_unicode_string const& rhs) const
|
||||
{
|
||||
std::string val;
|
||||
if (util::to_string(val,lhs))
|
||||
return value_unicode_string(val.c_str()) + rhs;
|
||||
return rhs;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_type operator() (T lhs, T rhs) const
|
||||
|
@ -357,57 +414,16 @@ struct add : public boost::static_visitor<V>
|
|||
return lhs + rhs ;
|
||||
}
|
||||
|
||||
value_type operator() (UnicodeString const& lhs ,
|
||||
UnicodeString const& rhs ) const
|
||||
{
|
||||
return lhs + rhs;
|
||||
}
|
||||
|
||||
value_type operator() (double lhs, int rhs) const
|
||||
{
|
||||
return lhs + rhs;
|
||||
}
|
||||
|
||||
value_type operator() (int lhs, double rhs) const
|
||||
{
|
||||
return lhs + rhs;
|
||||
}
|
||||
|
||||
value_type operator() (UnicodeString const& lhs, value_null rhs) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(rhs);
|
||||
return lhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_null lhs, UnicodeString const& rhs) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(lhs);
|
||||
return rhs;
|
||||
}
|
||||
|
||||
template <typename R>
|
||||
value_type operator() (UnicodeString const& lhs, R const& rhs) const
|
||||
{
|
||||
std::string val;
|
||||
if (util::to_string(val,rhs))
|
||||
return lhs + UnicodeString(val.c_str());
|
||||
return lhs;
|
||||
}
|
||||
|
||||
template <typename L>
|
||||
value_type operator() (L const& lhs , UnicodeString const& rhs) const
|
||||
{
|
||||
std::string val;
|
||||
if (util::to_string(val,lhs))
|
||||
return UnicodeString(val.c_str()) + rhs;
|
||||
return rhs;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
value_type operator() (T1 const& lhs, T2 const&) const
|
||||
{
|
||||
return lhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_bool lhs, value_bool rhs) const
|
||||
{
|
||||
return value_integer(lhs + rhs);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename V>
|
||||
|
@ -421,26 +437,31 @@ struct sub : public boost::static_visitor<V>
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
value_type operator() (T lhs, T rhs) const
|
||||
value_type operator() (T lhs, T rhs) const
|
||||
{
|
||||
return lhs - rhs ;
|
||||
}
|
||||
|
||||
value_type operator() (UnicodeString const& lhs,
|
||||
UnicodeString const& ) const
|
||||
value_type operator() (value_unicode_string const& lhs,
|
||||
value_unicode_string const& ) const
|
||||
{
|
||||
return lhs;
|
||||
}
|
||||
|
||||
value_type operator() (double lhs, int rhs) const
|
||||
value_type operator() (value_double lhs, value_integer rhs) const
|
||||
{
|
||||
return lhs - rhs;
|
||||
}
|
||||
|
||||
value_type operator() (int lhs, double rhs) const
|
||||
value_type operator() (value_integer lhs, value_double rhs) const
|
||||
{
|
||||
return lhs - rhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_bool lhs, value_bool rhs) const
|
||||
{
|
||||
return value_integer(lhs - rhs);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename V>
|
||||
|
@ -458,21 +479,26 @@ struct mult : public boost::static_visitor<V>
|
|||
return lhs * rhs;
|
||||
}
|
||||
|
||||
value_type operator() (UnicodeString const& lhs,
|
||||
UnicodeString const& ) const
|
||||
value_type operator() (value_unicode_string const& lhs,
|
||||
value_unicode_string const& ) const
|
||||
{
|
||||
return lhs;
|
||||
}
|
||||
|
||||
value_type operator() (double lhs, int rhs) const
|
||||
value_type operator() (value_double lhs, value_integer rhs) const
|
||||
{
|
||||
return lhs * rhs;
|
||||
}
|
||||
|
||||
value_type operator() (int lhs, double rhs) const
|
||||
value_type operator() (value_integer lhs, value_double rhs) const
|
||||
{
|
||||
return lhs * rhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_bool lhs, value_bool rhs) const
|
||||
{
|
||||
return value_integer(0);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename V>
|
||||
|
@ -491,25 +517,25 @@ struct div: public boost::static_visitor<V>
|
|||
return lhs / rhs;
|
||||
}
|
||||
|
||||
value_type operator() (bool lhs, bool rhs ) const
|
||||
value_type operator() (value_bool lhs, value_bool rhs ) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(lhs);
|
||||
boost::ignore_unused_variable_warning(rhs);
|
||||
return false;
|
||||
}
|
||||
|
||||
value_type operator() (UnicodeString const& lhs,
|
||||
UnicodeString const&) const
|
||||
value_type operator() (value_unicode_string const& lhs,
|
||||
value_unicode_string const&) const
|
||||
{
|
||||
return lhs;
|
||||
}
|
||||
|
||||
value_type operator() (double lhs, int rhs) const
|
||||
value_type operator() (value_double lhs, value_integer rhs) const
|
||||
{
|
||||
return lhs / rhs;
|
||||
}
|
||||
|
||||
value_type operator() (int lhs, double rhs) const
|
||||
value_type operator() (value_integer lhs, value_double rhs) const
|
||||
{
|
||||
return lhs / rhs;
|
||||
}
|
||||
|
@ -531,31 +557,31 @@ struct mod: public boost::static_visitor<V>
|
|||
return lhs % rhs;
|
||||
}
|
||||
|
||||
value_type operator() (UnicodeString const& lhs,
|
||||
UnicodeString const&) const
|
||||
value_type operator() (value_unicode_string const& lhs,
|
||||
value_unicode_string const&) const
|
||||
{
|
||||
return lhs;
|
||||
}
|
||||
|
||||
value_type operator() (bool lhs,
|
||||
bool rhs) const
|
||||
value_type operator() (value_bool lhs,
|
||||
value_bool rhs) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(lhs);
|
||||
boost::ignore_unused_variable_warning(rhs);
|
||||
return false;
|
||||
}
|
||||
|
||||
value_type operator() (double lhs, int rhs) const
|
||||
value_type operator() (value_double lhs, value_integer rhs) const
|
||||
{
|
||||
return std::fmod(lhs, rhs);
|
||||
}
|
||||
|
||||
value_type operator() (int lhs, double rhs) const
|
||||
value_type operator() (value_integer lhs, value_double rhs) const
|
||||
{
|
||||
return std::fmod(lhs, rhs);
|
||||
}
|
||||
|
||||
value_type operator() (double lhs, double rhs) const
|
||||
value_type operator() (value_double lhs, value_double rhs) const
|
||||
{
|
||||
return std::fmod(lhs, rhs);
|
||||
}
|
||||
|
@ -577,39 +603,38 @@ struct negate : public boost::static_visitor<V>
|
|||
return val;
|
||||
}
|
||||
|
||||
value_type operator() (bool val) const
|
||||
value_type operator() (value_bool val) const
|
||||
{
|
||||
return val ? -1 : 0;
|
||||
return val ? value_integer(-1) : value_integer(0);
|
||||
}
|
||||
|
||||
value_type operator() (UnicodeString const& ustr) const
|
||||
value_type operator() (value_unicode_string const& ustr) const
|
||||
{
|
||||
UnicodeString inplace(ustr);
|
||||
value_unicode_string inplace(ustr);
|
||||
return inplace.reverse();
|
||||
}
|
||||
};
|
||||
|
||||
struct to_bool : public boost::static_visitor<bool>
|
||||
struct to_bool : public boost::static_visitor<value_bool>
|
||||
{
|
||||
bool operator() (bool val) const
|
||||
value_bool operator() (value_bool val) const
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
bool operator() (UnicodeString const& ustr) const
|
||||
value_bool operator() (value_unicode_string const& ustr) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(ustr);
|
||||
return true;
|
||||
return !ustr.isEmpty();
|
||||
}
|
||||
|
||||
bool operator() (value_null const& val) const
|
||||
value_bool operator() (value_null const& val) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator() (T val) const
|
||||
value_bool operator() (T val) const
|
||||
{
|
||||
return val > 0 ? true : false;
|
||||
}
|
||||
|
@ -626,14 +651,14 @@ struct to_string : public boost::static_visitor<std::string>
|
|||
}
|
||||
|
||||
// specializations
|
||||
std::string operator() (UnicodeString const& val) const
|
||||
std::string operator() (value_unicode_string const& val) const
|
||||
{
|
||||
std::string utf8;
|
||||
to_utf8(val,utf8);
|
||||
return utf8;
|
||||
}
|
||||
|
||||
std::string operator() (double val) const
|
||||
std::string operator() (value_double val) const
|
||||
{
|
||||
std::string str;
|
||||
util::to_string(str, val); // TODO set precision(16)
|
||||
|
@ -647,54 +672,54 @@ struct to_string : public boost::static_visitor<std::string>
|
|||
}
|
||||
};
|
||||
|
||||
struct to_unicode : public boost::static_visitor<UnicodeString>
|
||||
struct to_unicode : public boost::static_visitor<value_unicode_string>
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
UnicodeString operator() (T val) const
|
||||
value_unicode_string operator() (T val) const
|
||||
{
|
||||
std::string str;
|
||||
util::to_string(str,val);
|
||||
return UnicodeString(str.c_str());
|
||||
return value_unicode_string(str.c_str());
|
||||
}
|
||||
|
||||
// specializations
|
||||
UnicodeString const& operator() (UnicodeString const& val) const
|
||||
value_unicode_string const& operator() (value_unicode_string const& val) const
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
UnicodeString operator() (double val) const
|
||||
value_unicode_string operator() (value_double val) const
|
||||
{
|
||||
std::string str;
|
||||
util::to_string(str,val);
|
||||
return UnicodeString(str.c_str());
|
||||
return value_unicode_string(str.c_str());
|
||||
}
|
||||
|
||||
UnicodeString operator() (value_null const& val) const
|
||||
value_unicode_string operator() (value_null const& val) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return UnicodeString("");
|
||||
return value_unicode_string("");
|
||||
}
|
||||
};
|
||||
|
||||
struct to_expression_string : public boost::static_visitor<std::string>
|
||||
{
|
||||
std::string operator() (UnicodeString const& val) const
|
||||
std::string operator() (value_unicode_string const& val) const
|
||||
{
|
||||
std::string utf8;
|
||||
to_utf8(val,utf8);
|
||||
return "'" + utf8 + "'";
|
||||
}
|
||||
|
||||
std::string operator() (double val) const
|
||||
std::string operator() (value_double val) const
|
||||
{
|
||||
std::string output;
|
||||
util::to_string(output,val); // TODO precision(16)
|
||||
return output;
|
||||
}
|
||||
|
||||
std::string operator() (bool val) const
|
||||
std::string operator() (value_bool val) const
|
||||
{
|
||||
return val ? "true":"false";
|
||||
}
|
||||
|
@ -714,69 +739,85 @@ struct to_expression_string : public boost::static_visitor<std::string>
|
|||
}
|
||||
};
|
||||
|
||||
struct to_double : public boost::static_visitor<double>
|
||||
struct to_double : public boost::static_visitor<value_double>
|
||||
{
|
||||
double operator() (int val) const
|
||||
{
|
||||
return static_cast<double>(val);
|
||||
}
|
||||
|
||||
double operator() (double val) const
|
||||
value_double operator() (value_double val) const
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
double operator() (std::string const& val) const
|
||||
value_double operator() (value_integer val) const
|
||||
{
|
||||
double result;
|
||||
return static_cast<value_double>(val);
|
||||
}
|
||||
|
||||
value_double operator() (value_bool val) const
|
||||
{
|
||||
return static_cast<value_double>(val);
|
||||
}
|
||||
|
||||
value_double operator() (std::string const& val) const
|
||||
{
|
||||
value_double result;
|
||||
if (util::string2double(val,result))
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
double operator() (UnicodeString const& val) const
|
||||
|
||||
value_double operator() (value_unicode_string const& val) const
|
||||
{
|
||||
std::string utf8;
|
||||
to_utf8(val,utf8);
|
||||
return operator()(utf8);
|
||||
}
|
||||
|
||||
double operator() (value_null const& val) const
|
||||
value_double operator() (value_null const& val) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return 0.0;
|
||||
}
|
||||
};
|
||||
|
||||
struct to_int : public boost::static_visitor<double>
|
||||
struct to_int : public boost::static_visitor<value_integer>
|
||||
{
|
||||
int operator() (int val) const
|
||||
value_integer operator() (value_integer val) const
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
int operator() (double val) const
|
||||
value_integer operator() (value_double val) const
|
||||
{
|
||||
return rint(val);
|
||||
}
|
||||
|
||||
int operator() (std::string const& val) const
|
||||
value_integer operator() (value_bool val) const
|
||||
{
|
||||
int result;
|
||||
if (util::string2int(val,result))
|
||||
return result;
|
||||
return 0;
|
||||
return static_cast<int>(val);
|
||||
}
|
||||
int operator() (UnicodeString const& val) const
|
||||
|
||||
value_integer operator() (std::string const& val) const
|
||||
{
|
||||
value_integer result;
|
||||
#ifdef BIGINT
|
||||
if (util::string2longlong(val,result))
|
||||
#else
|
||||
if (util::string2int(val,result))
|
||||
#endif
|
||||
return result;
|
||||
return value_integer(0);
|
||||
}
|
||||
|
||||
value_integer operator() (value_unicode_string const& val) const
|
||||
{
|
||||
std::string utf8;
|
||||
to_utf8(val,utf8);
|
||||
return operator()(utf8);
|
||||
}
|
||||
|
||||
int operator() (value_null const& val) const
|
||||
value_integer operator() (value_null const& val) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(val);
|
||||
return 0;
|
||||
return value_integer(0);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -842,7 +883,7 @@ public:
|
|||
|
||||
bool is_null() const;
|
||||
|
||||
bool to_bool() const
|
||||
value_bool to_bool() const
|
||||
{
|
||||
return boost::apply_visitor(impl::to_bool(),base_);
|
||||
}
|
||||
|
@ -857,17 +898,17 @@ public:
|
|||
return boost::apply_visitor(impl::to_string(),base_);
|
||||
}
|
||||
|
||||
UnicodeString to_unicode() const
|
||||
value_unicode_string to_unicode() const
|
||||
{
|
||||
return boost::apply_visitor(impl::to_unicode(),base_);
|
||||
}
|
||||
|
||||
double to_double() const
|
||||
value_double to_double() const
|
||||
{
|
||||
return boost::apply_visitor(impl::to_double(),base_);
|
||||
}
|
||||
|
||||
double to_int() const
|
||||
value_integer to_int() const
|
||||
{
|
||||
return boost::apply_visitor(impl::to_int(),base_);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace mapnik { namespace wkt {
|
|||
void operator() (T path) const
|
||||
{
|
||||
BOOST_ASSERT( path!=0 );
|
||||
path->close();
|
||||
path->set_close();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -56,23 +56,23 @@ using namespace boost::spirit;
|
|||
|
||||
DATASOURCE_PLUGIN(csv_datasource)
|
||||
|
||||
csv_datasource::csv_datasource(parameters const& params, bool bind)
|
||||
csv_datasource::csv_datasource(parameters const& 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_(),
|
||||
filename_(),
|
||||
inline_string_(),
|
||||
file_length_(0),
|
||||
row_limit_(*params_.get<int>("row_limit", 0)),
|
||||
row_limit_(*params.get<int>("row_limit", 0)),
|
||||
features_(),
|
||||
escape_(*params_.get<std::string>("escape", "")),
|
||||
separator_(*params_.get<std::string>("separator", "")),
|
||||
quote_(*params_.get<std::string>("quote", "")),
|
||||
escape_(*params.get<std::string>("escape", "")),
|
||||
separator_(*params.get<std::string>("separator", "")),
|
||||
quote_(*params.get<std::string>("quote", "")),
|
||||
headers_(),
|
||||
manual_headers_(mapnik::util::trim_copy(*params_.get<std::string>("headers", ""))),
|
||||
strict_(*params_.get<mapnik::boolean>("strict", false)),
|
||||
quiet_(*params_.get<mapnik::boolean>("quiet", false)),
|
||||
filesize_max_(*params_.get<float>("filesize_max", 20.0)), // MB
|
||||
manual_headers_(mapnik::util::trim_copy(*params.get<std::string>("headers", ""))),
|
||||
strict_(*params.get<mapnik::boolean>("strict", false)),
|
||||
quiet_(*params.get<mapnik::boolean>("quiet", false)),
|
||||
filesize_max_(*params.get<float>("filesize_max", 20.0)), // MB
|
||||
ctx_(boost::make_shared<mapnik::context_type>())
|
||||
{
|
||||
/* 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/
|
||||
*/
|
||||
|
||||
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)
|
||||
{
|
||||
inline_string_ = *inline_string;
|
||||
}
|
||||
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");
|
||||
|
||||
boost::optional<std::string> base = params_.get<std::string>("base");
|
||||
boost::optional<std::string> base = params.get<std::string>("base");
|
||||
if (base)
|
||||
filename_ = *base + "/" + *file;
|
||||
else
|
||||
filename_ = *file;
|
||||
}
|
||||
|
||||
if (bind)
|
||||
{
|
||||
this->bind();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
csv_datasource::~csv_datasource() { }
|
||||
|
||||
void csv_datasource::bind() const
|
||||
{
|
||||
if (is_bound_) return;
|
||||
|
||||
if (!inline_string_.empty())
|
||||
{
|
||||
std::istringstream in(inline_string_);
|
||||
|
@ -140,14 +126,16 @@ void csv_datasource::bind() const
|
|||
parse_csv(in,escape_, separator_, quote_);
|
||||
in.close();
|
||||
}
|
||||
is_bound_ = true;
|
||||
}
|
||||
|
||||
|
||||
csv_datasource::~csv_datasource() { }
|
||||
|
||||
template <typename T>
|
||||
void csv_datasource::parse_csv(T & stream,
|
||||
std::string const& escape,
|
||||
std::string const& separator,
|
||||
std::string const& quote) const
|
||||
std::string const& quote)
|
||||
{
|
||||
stream.seekg(0, std::ios::end);
|
||||
file_length_ = stream.tellg();
|
||||
|
@ -410,7 +398,7 @@ void csv_datasource::parse_csv(T & stream,
|
|||
throw mapnik::datasource_exception("CSV Plugin: could not detect column headers with the name of wkt, geojson, x/y, or latitude/longitude - this is required for reading geometry data");
|
||||
}
|
||||
|
||||
int feature_count(0);
|
||||
mapnik::value_integer feature_count(0);
|
||||
bool extent_initialized = false;
|
||||
std::size_t num_headers = headers_.size();
|
||||
|
||||
|
@ -465,7 +453,7 @@ void csv_datasource::parse_csv(T & stream,
|
|||
{
|
||||
csv_utils::fix_json_quoting(csv_line);
|
||||
}
|
||||
|
||||
|
||||
Tokenizer tok(csv_line, grammer);
|
||||
Tokenizer::iterator beg = tok.begin();
|
||||
|
||||
|
@ -596,7 +584,7 @@ void csv_datasource::parse_csv(T & stream,
|
|||
MAPNIK_LOG_ERROR(csv) << s.str();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -664,7 +652,7 @@ void csv_datasource::parse_csv(T & stream,
|
|||
}
|
||||
}
|
||||
|
||||
// now, add attributes, skipping any WKT or JSON fiels
|
||||
// now, add attributes, skipping any WKT or JSON fields
|
||||
if ((has_wkt_field) && (i == wkt_idx)) continue;
|
||||
if ((has_json_field) && (i == json_idx)) continue;
|
||||
/* First we detect likely strings, then try parsing likely numbers,
|
||||
|
@ -676,27 +664,34 @@ void csv_datasource::parse_csv(T & stream,
|
|||
to assume are numbers)
|
||||
*/
|
||||
|
||||
bool matched = false;
|
||||
bool has_dot = value.find(".") != std::string::npos;
|
||||
if (value.empty() ||
|
||||
(value_length > 20) ||
|
||||
(value_length > 1 && !has_dot && value[0] == '0'))
|
||||
{
|
||||
matched = true;
|
||||
feature->put(fld_name,tr.transcode(value.c_str()));
|
||||
if (feature_count == 1)
|
||||
{
|
||||
desc_.add_descriptor(mapnik::attribute_descriptor(fld_name,mapnik::String));
|
||||
}
|
||||
}
|
||||
else if ((value[0] >= '0' && value[0] <= '9') || value[0] == '-')
|
||||
else if ((value[0] >= '0' && value[0] <= '9') ||
|
||||
value[0] == '-' ||
|
||||
value[0] == '+' ||
|
||||
value[0] == '.')
|
||||
{
|
||||
double float_val = 0.0;
|
||||
std::string::const_iterator str_beg = value.begin();
|
||||
std::string::const_iterator str_end = value.end();
|
||||
bool r = qi::phrase_parse(str_beg,str_end,qi::double_,ascii::space,float_val);
|
||||
if (r && (str_beg == str_end))
|
||||
bool has_e = value.find("e") != std::string::npos;
|
||||
if (has_dot || has_e)
|
||||
{
|
||||
if (has_dot)
|
||||
double float_val = 0.0;
|
||||
std::string::const_iterator str_beg = value.begin();
|
||||
std::string::const_iterator str_end = value.end();
|
||||
if (qi::phrase_parse(str_beg,str_end,qi::double_,ascii::space,float_val)
|
||||
&& (str_beg == str_end))
|
||||
{
|
||||
matched = true;
|
||||
feature->put(fld_name,float_val);
|
||||
if (feature_count == 1)
|
||||
{
|
||||
|
@ -705,9 +700,17 @@ void csv_datasource::parse_csv(T & stream,
|
|||
fld_name,mapnik::Double));
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
mapnik::value_integer int_val = 0;
|
||||
std::string::const_iterator str_beg = value.begin();
|
||||
std::string::const_iterator str_end = value.end();
|
||||
if (qi::phrase_parse(str_beg,str_end,qi::long_long,ascii::space,int_val)
|
||||
&& (str_beg == str_end))
|
||||
{
|
||||
feature->put(fld_name,static_cast<int>(float_val));
|
||||
matched = true;
|
||||
feature->put(fld_name,int_val);
|
||||
if (feature_count == 1)
|
||||
{
|
||||
desc_.add_descriptor(
|
||||
|
@ -716,19 +719,8 @@ void csv_datasource::parse_csv(T & stream,
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// fallback to normal string
|
||||
feature->put(fld_name,tr.transcode(value.c_str()));
|
||||
if (feature_count == 1)
|
||||
{
|
||||
desc_.add_descriptor(
|
||||
mapnik::attribute_descriptor(
|
||||
fld_name,mapnik::String));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!matched)
|
||||
{
|
||||
// fallback to normal string
|
||||
feature->put(fld_name,tr.transcode(value.c_str()));
|
||||
|
@ -890,14 +882,11 @@ datasource::datasource_t csv_datasource::type() const
|
|||
|
||||
mapnik::box2d<double> csv_datasource::envelope() const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
return extent_;
|
||||
}
|
||||
|
||||
boost::optional<mapnik::datasource::geometry_t> csv_datasource::get_geometry_type() const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
boost::optional<mapnik::datasource::geometry_t> result;
|
||||
int multi_type = 0;
|
||||
unsigned num_features = features_.size();
|
||||
|
@ -920,15 +909,11 @@ boost::optional<mapnik::datasource::geometry_t> csv_datasource::get_geometry_typ
|
|||
|
||||
mapnik::layer_descriptor csv_datasource::get_descriptor() const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
return desc_;
|
||||
}
|
||||
|
||||
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();
|
||||
std::set<std::string>::const_iterator pos = attribute_names.begin();
|
||||
while (pos != attribute_names.end())
|
||||
|
@ -958,7 +943,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
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
throw mapnik::datasource_exception("CSV Plugin: features_at_point is not supported yet");
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
class csv_datasource : public mapnik::datasource
|
||||
{
|
||||
public:
|
||||
csv_datasource(mapnik::parameters const& params, bool bind=true);
|
||||
csv_datasource(mapnik::parameters const& params);
|
||||
virtual ~csv_datasource ();
|
||||
mapnik::datasource::datasource_t type() const;
|
||||
static const char * name();
|
||||
|
@ -51,31 +51,30 @@ public:
|
|||
mapnik::box2d<double> envelope() const;
|
||||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
void bind() const;
|
||||
|
||||
template <typename T>
|
||||
void parse_csv(T & stream,
|
||||
std::string const& escape,
|
||||
std::string const& separator,
|
||||
std::string const& quote) const;
|
||||
std::string const& quote);
|
||||
|
||||
private:
|
||||
mutable mapnik::layer_descriptor desc_;
|
||||
mutable mapnik::box2d<double> extent_;
|
||||
mutable std::string filename_;
|
||||
mutable std::string inline_string_;
|
||||
mutable unsigned file_length_;
|
||||
mutable int row_limit_;
|
||||
mutable std::vector<mapnik::feature_ptr> features_;
|
||||
mutable std::string escape_;
|
||||
mutable std::string separator_;
|
||||
mutable std::string quote_;
|
||||
mutable std::vector<std::string> headers_;
|
||||
mutable std::string manual_headers_;
|
||||
mutable bool strict_;
|
||||
mutable bool quiet_;
|
||||
mutable double filesize_max_;
|
||||
mutable mapnik::context_ptr ctx_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
mapnik::box2d<double> extent_;
|
||||
std::string filename_;
|
||||
std::string inline_string_;
|
||||
unsigned file_length_;
|
||||
int row_limit_;
|
||||
std::vector<mapnik::feature_ptr> features_;
|
||||
std::string escape_;
|
||||
std::string separator_;
|
||||
std::string quote_;
|
||||
std::vector<std::string> headers_;
|
||||
std::string manual_headers_;
|
||||
bool strict_;
|
||||
bool quiet_;
|
||||
double filesize_max_;
|
||||
mapnik::context_ptr ctx_;
|
||||
};
|
||||
|
||||
#endif // MAPNIK_CSV_DATASOURCE_HPP
|
||||
|
|
|
@ -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),
|
||||
desc_(*params.get<std::string>("type"), "utf-8"),
|
||||
filter_factor_(*params_.get<double>("filter_factor", 0.0)),
|
||||
nodata_value_(params_.get<double>("nodata"))
|
||||
filter_factor_(*params.get<double>("filter_factor", 0.0)),
|
||||
nodata_value_(params.get<double>("nodata"))
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: Initializing...";
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "gdal_datasource::init");
|
||||
#endif
|
||||
|
||||
GDALAllRegister();
|
||||
|
||||
boost::optional<std::string> file = params.get<std::string>("file");
|
||||
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)
|
||||
{
|
||||
dataset_name_ = *base + "/" + *file;
|
||||
|
@ -96,22 +100,8 @@ gdal_datasource::gdal_datasource(parameters const& params, bool bind)
|
|||
dataset_name_ = *file;
|
||||
}
|
||||
|
||||
if (bind)
|
||||
{
|
||||
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);
|
||||
shared_dataset_ = *params.get<mapnik::boolean>("shared", false);
|
||||
band_ = *params.get<int>("band", -1);
|
||||
|
||||
GDALDataset *dataset = open_dataset();
|
||||
|
||||
|
@ -121,7 +111,7 @@ void gdal_datasource::bind() const
|
|||
|
||||
double tr[6];
|
||||
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)
|
||||
{
|
||||
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 Extent=" << extent_;
|
||||
|
||||
is_bound_ = true;
|
||||
}
|
||||
|
||||
gdal_datasource::~gdal_datasource()
|
||||
|
@ -207,8 +196,6 @@ const char * gdal_datasource::name()
|
|||
|
||||
box2d<double> gdal_datasource::envelope() const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
return extent_;
|
||||
}
|
||||
|
||||
|
@ -224,8 +211,6 @@ layer_descriptor gdal_datasource::get_descriptor() const
|
|||
|
||||
featureset_ptr gdal_datasource::features(query const& q) const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "gdal_datasource::features");
|
||||
#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
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "gdal_datasource::features_at_point");
|
||||
#endif
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
class gdal_datasource : public mapnik::datasource
|
||||
{
|
||||
public:
|
||||
gdal_datasource(mapnik::parameters const& params, bool bind = true);
|
||||
gdal_datasource(mapnik::parameters const& params);
|
||||
virtual ~gdal_datasource();
|
||||
mapnik::datasource::datasource_t type() const;
|
||||
static const char * name();
|
||||
|
@ -54,19 +54,18 @@ public:
|
|||
mapnik::box2d<double> envelope() const;
|
||||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
void bind() const;
|
||||
private:
|
||||
GDALDataset* open_dataset() const;
|
||||
mutable mapnik::box2d<double> extent_;
|
||||
mapnik::box2d<double> extent_;
|
||||
std::string dataset_name_;
|
||||
mutable int band_;
|
||||
int band_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
mutable unsigned width_;
|
||||
mutable unsigned height_;
|
||||
mutable double dx_;
|
||||
mutable double dy_;
|
||||
mutable int nbands_;
|
||||
mutable bool shared_dataset_;
|
||||
unsigned width_;
|
||||
unsigned height_;
|
||||
double dx_;
|
||||
double dy_;
|
||||
int nbands_;
|
||||
bool shared_dataset_;
|
||||
double filter_factor_;
|
||||
boost::optional<double> nodata_value_;
|
||||
};
|
||||
|
|
|
@ -445,10 +445,10 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
|
|||
{
|
||||
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Loading colour table...";
|
||||
|
||||
unsigned nodata_value = static_cast<unsigned>(nodata);
|
||||
unsigned nodata_value = static_cast<unsigned>(nodata); // FIXME: is it realy unsigned ?
|
||||
if (hasNoData)
|
||||
{
|
||||
feature->put("NODATA",static_cast<int>(nodata_value));
|
||||
feature->put("NODATA",static_cast<mapnik::value_integer>(nodata_value));
|
||||
}
|
||||
for (unsigned y = 0; y < image.height(); ++y)
|
||||
{
|
||||
|
|
|
@ -49,27 +49,9 @@ using mapnik::parameters;
|
|||
|
||||
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>
|
||||
{
|
||||
mapnik::eAttributeType operator() (int /*val*/) const
|
||||
mapnik::eAttributeType operator() (mapnik::value_integer /*val*/) const
|
||||
{
|
||||
return mapnik::Integer;
|
||||
}
|
||||
|
@ -105,33 +87,42 @@ 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;
|
||||
|
||||
std::ifstream is(file_.c_str());
|
||||
boost::spirit::multi_pass<base_iterator_type> begin =
|
||||
boost::spirit::multi_pass<base_iterator_type> begin =
|
||||
boost::spirit::make_default_multi_pass(base_iterator_type(is));
|
||||
|
||||
boost::spirit::multi_pass<base_iterator_type> end =
|
||||
boost::spirit::multi_pass<base_iterator_type> end =
|
||||
boost::spirit::make_default_multi_pass(base_iterator_type());
|
||||
|
||||
|
||||
mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
|
||||
mapnik::json::feature_collection_parser<boost::spirit::multi_pass<base_iterator_type> > p(ctx,*tr_);
|
||||
bool result = p.parse(begin,end, features_);
|
||||
if (!result)
|
||||
if (!result)
|
||||
{
|
||||
throw mapnik::datasource_exception("geojson_datasource: Failed parse GeoJSON file '" + file_ + "'");
|
||||
}
|
||||
|
||||
|
||||
bool first = true;
|
||||
std::size_t count=0;
|
||||
BOOST_FOREACH (mapnik::feature_ptr f, features_)
|
||||
{
|
||||
mapnik::box2d<double> const& box = f->envelope();
|
||||
if (first)
|
||||
if (first)
|
||||
{
|
||||
extent_ = box;
|
||||
first = false;
|
||||
|
@ -146,10 +137,9 @@ void geojson_datasource::bind() const
|
|||
else
|
||||
{
|
||||
extent_.expand_to_include(box);
|
||||
}
|
||||
}
|
||||
tree_.insert(box_type(point_type(box.minx(),box.miny()),point_type(box.maxx(),box.maxy())), count++);
|
||||
}
|
||||
is_bound_ = true;
|
||||
}
|
||||
|
||||
geojson_datasource::~geojson_datasource() { }
|
||||
|
@ -159,7 +149,7 @@ const char * geojson_datasource::name()
|
|||
return "geojson";
|
||||
}
|
||||
|
||||
boost::optional<mapnik::datasource::geometry_t> geojson_datasource::get_geometry_type() const
|
||||
boost::optional<mapnik::datasource::geometry_t> geojson_datasource::get_geometry_type() const
|
||||
{
|
||||
boost::optional<mapnik::datasource::geometry_t> result;
|
||||
int multi_type = 0;
|
||||
|
@ -181,28 +171,23 @@ boost::optional<mapnik::datasource::geometry_t> geojson_datasource::get_geometry
|
|||
return result;
|
||||
}
|
||||
|
||||
mapnik::datasource::datasource_t geojson_datasource::type() const
|
||||
mapnik::datasource::datasource_t geojson_datasource::type() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
mapnik::box2d<double> geojson_datasource::envelope() const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
return extent_;
|
||||
}
|
||||
|
||||
mapnik::layer_descriptor geojson_datasource::get_descriptor() const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
return desc_;
|
||||
}
|
||||
|
||||
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
|
||||
mapnik::box2d<double> const& b = q.get_bbox();
|
||||
if (extent_.intersects(b))
|
||||
|
@ -210,7 +195,7 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons
|
|||
box_type box(point_type(b.minx(),b.miny()),point_type(b.maxx(),b.maxy()));
|
||||
index_array_ = tree_.find(box);
|
||||
return boost::make_shared<geojson_featureset>(features_, index_array_.begin(), index_array_.end());
|
||||
}
|
||||
}
|
||||
// otherwise return an empty featureset pointer
|
||||
return mapnik::featureset_ptr();
|
||||
}
|
||||
|
@ -218,7 +203,6 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons
|
|||
// FIXME
|
||||
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");
|
||||
return mapnik::featureset_ptr();
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
typedef boost::geometry::index::rtree<box_type,std::size_t> spatial_index_type;
|
||||
|
||||
// constructor
|
||||
geojson_datasource(mapnik::parameters const& params, bool bind=true);
|
||||
geojson_datasource(mapnik::parameters const& params);
|
||||
virtual ~geojson_datasource ();
|
||||
mapnik::datasource::datasource_t type() const;
|
||||
static const char * name();
|
||||
|
@ -64,16 +64,15 @@ public:
|
|||
mapnik::box2d<double> envelope() const;
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
void bind() const;
|
||||
private:
|
||||
mapnik::datasource::datasource_t type_;
|
||||
mutable std::map<std::string, mapnik::parameters> statistics_;
|
||||
mutable mapnik::layer_descriptor desc_;
|
||||
mutable std::string file_;
|
||||
mutable mapnik::box2d<double> extent_;
|
||||
std::map<std::string, mapnik::parameters> statistics_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
std::string file_;
|
||||
mapnik::box2d<double> extent_;
|
||||
boost::shared_ptr<mapnik::transcoder> tr_;
|
||||
mutable std::vector<mapnik::feature_ptr> features_;
|
||||
mutable spatial_index_type tree_;
|
||||
std::vector<mapnik::feature_ptr> features_;
|
||||
spatial_index_type tree_;
|
||||
mutable std::deque<std::size_t> index_array_;
|
||||
};
|
||||
|
||||
|
|
|
@ -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),
|
||||
extent_(),
|
||||
extent_initialized_(false),
|
||||
|
@ -99,42 +99,22 @@ geos_datasource::geos_datasource(parameters const& params, bool bind)
|
|||
if (! geometry) throw datasource_exception("missing <wkt> parameter");
|
||||
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);
|
||||
|
||||
boost::optional<int> id = params_.get<int>("gid");
|
||||
boost::optional<int> id = params.get<int>("gid");
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
mapnik::progress_timer __stats__(std::clog, "geos_datasource::bind");
|
||||
mapnik::progress_timer __stats__(std::clog, "geos_datasource::init");
|
||||
#endif
|
||||
|
||||
// open geos driver
|
||||
|
@ -151,7 +131,7 @@ void geos_datasource::bind() const
|
|||
if (! extent_initialized_)
|
||||
{
|
||||
#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
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
is_bound_ = true;
|
||||
}
|
||||
|
||||
geos_datasource::~geos_datasource()
|
||||
{
|
||||
{
|
||||
geometry_.set_feature(0);
|
||||
|
||||
finishGEOS();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char * geos_datasource::name()
|
||||
{
|
||||
return "geos";
|
||||
|
@ -237,14 +226,11 @@ mapnik::datasource::datasource_t geos_datasource::type() const
|
|||
|
||||
box2d<double> geos_datasource::envelope() const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
return extent_;
|
||||
}
|
||||
|
||||
boost::optional<mapnik::datasource::geometry_t> geos_datasource::get_geometry_type() const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
boost::optional<mapnik::datasource::geometry_t> result;
|
||||
|
||||
#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
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
return desc_;
|
||||
}
|
||||
|
||||
featureset_ptr geos_datasource::features(query const& q) const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "geos_datasource::features");
|
||||
#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
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "geos_datasource::features_at_point");
|
||||
#endif
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
class geos_datasource : public mapnik::datasource
|
||||
{
|
||||
public:
|
||||
geos_datasource(mapnik::parameters const& params, bool bind = true);
|
||||
geos_datasource(mapnik::parameters const& params);
|
||||
virtual ~geos_datasource ();
|
||||
mapnik::datasource::datasource_t type() const;
|
||||
static const char * name();
|
||||
|
@ -54,17 +54,17 @@ public:
|
|||
mapnik::box2d<double> envelope() const;
|
||||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
void bind() const;
|
||||
|
||||
private:
|
||||
mutable mapnik::box2d<double> extent_;
|
||||
mutable bool extent_initialized_;
|
||||
void init(mapnik::parameters const& params);
|
||||
mapnik::box2d<double> extent_;
|
||||
bool extent_initialized_;
|
||||
mapnik::datasource::datasource_t type_;
|
||||
mutable mapnik::layer_descriptor desc_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
mutable geos_feature_ptr geometry_;
|
||||
mutable std::string geometry_data_;
|
||||
mutable std::string geometry_data_name_;
|
||||
mutable int geometry_id_;
|
||||
std::string geometry_data_;
|
||||
std::string geometry_data_name_;
|
||||
int geometry_id_;
|
||||
std::string geometry_string_;
|
||||
};
|
||||
|
||||
|
|
|
@ -44,14 +44,14 @@ using mapnik::feature_factory;
|
|||
|
||||
geos_featureset::geos_featureset(GEOSGeometry* geometry,
|
||||
GEOSGeometry* extent,
|
||||
int identifier,
|
||||
mapnik::value_integer feature_id,
|
||||
std::string const& field,
|
||||
std::string const& field_name,
|
||||
std::string const& encoding)
|
||||
: geometry_(geometry),
|
||||
tr_(new transcoder(encoding)),
|
||||
extent_(extent),
|
||||
identifier_(identifier),
|
||||
feature_id_(feature_id),
|
||||
field_(field),
|
||||
field_name_(field_name),
|
||||
already_rendered_(false),
|
||||
|
@ -108,7 +108,7 @@ feature_ptr geos_featureset::next()
|
|||
geos_wkb_ptr wkb(geometry_);
|
||||
if (wkb.is_valid())
|
||||
{
|
||||
feature_ptr feature(feature_factory::create(ctx_,identifier_));
|
||||
feature_ptr feature(feature_factory::create(ctx_,feature_id_));
|
||||
|
||||
if (geometry_utils::from_wkb(feature->paths(),
|
||||
wkb.data(),
|
||||
|
|
|
@ -41,7 +41,7 @@ class geos_featureset : public mapnik::Featureset
|
|||
public:
|
||||
geos_featureset(GEOSGeometry* geometry,
|
||||
GEOSGeometry* extent,
|
||||
int identifier,
|
||||
mapnik::value_integer feature_id,
|
||||
std::string const& field,
|
||||
std::string const& field_name,
|
||||
std::string const& encoding);
|
||||
|
@ -52,7 +52,7 @@ private:
|
|||
GEOSGeometry* geometry_;
|
||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||
geos_feature_ptr extent_;
|
||||
int identifier_;
|
||||
mapnik::value_integer feature_id_;
|
||||
std::string field_;
|
||||
std::string field_name_;
|
||||
bool already_rendered_;
|
||||
|
|
|
@ -67,7 +67,7 @@ boost::mutex knd_list_mutex;
|
|||
std::list<kismet_network_data> knd_list;
|
||||
const unsigned int queue_size = 20;
|
||||
|
||||
kismet_datasource::kismet_datasource(parameters const& params, bool bind)
|
||||
kismet_datasource::kismet_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
extent_(),
|
||||
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"),
|
||||
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)
|
||||
{
|
||||
host_ = *host;
|
||||
|
@ -85,37 +85,25 @@ kismet_datasource::kismet_datasource(parameters const& params, bool bind)
|
|||
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)
|
||||
{
|
||||
port_ = *port;
|
||||
}
|
||||
|
||||
boost::optional<std::string> srs = params_.get<std::string>("srs");
|
||||
boost::optional<std::string> srs = params.get<std::string>("srs");
|
||||
if (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)
|
||||
{
|
||||
extent_initialized_ = extent_.from_string(*ext);
|
||||
}
|
||||
|
||||
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()
|
||||
|
@ -134,7 +122,6 @@ mapnik::datasource::datasource_t kismet_datasource::type() const
|
|||
|
||||
box2d<double> kismet_datasource::envelope() const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
return extent_;
|
||||
}
|
||||
|
||||
|
@ -150,8 +137,6 @@ layer_descriptor kismet_datasource::get_descriptor() const
|
|||
|
||||
featureset_ptr kismet_datasource::features(query const& q) const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource::features()";
|
||||
|
||||
// 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
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource::features_at_point()";
|
||||
|
||||
return featureset_ptr();
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
class kismet_datasource : public mapnik::datasource
|
||||
{
|
||||
public:
|
||||
kismet_datasource(mapnik::parameters const& params, bool bind = true);
|
||||
kismet_datasource(mapnik::parameters const& params);
|
||||
virtual ~kismet_datasource ();
|
||||
datasource::datasource_t type() const;
|
||||
static const char * name();
|
||||
|
@ -56,7 +56,6 @@ public:
|
|||
mapnik::box2d<double> envelope() const;
|
||||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
void bind() const;
|
||||
|
||||
private:
|
||||
void run (std::string const& host, const unsigned int port);
|
||||
|
@ -67,7 +66,7 @@ private:
|
|||
unsigned int port_;
|
||||
mapnik::datasource::datasource_t type_;
|
||||
std::string srs_;
|
||||
mutable mapnik::layer_descriptor desc_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
boost::shared_ptr<boost::thread> kismet_thread;
|
||||
};
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
private:
|
||||
std::list<kismet_network_data> const& knd_list_;
|
||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||
int feature_id_;
|
||||
mapnik::value_integer feature_id_;
|
||||
std::list<kismet_network_data>::const_iterator knd_list_it;
|
||||
mapnik::projection source_;
|
||||
mapnik::context_ptr ctx_;
|
||||
|
|
|
@ -68,25 +68,29 @@ const std::string occi_datasource::METADATA_TABLE = "USER_SDO_GEOM_METADATA";
|
|||
|
||||
DATASOURCE_PLUGIN(occi_datasource)
|
||||
|
||||
occi_datasource::occi_datasource(parameters const& params, bool bind)
|
||||
occi_datasource::occi_datasource(parameters const& params)
|
||||
: datasource (params),
|
||||
type_(datasource::Vector),
|
||||
fields_(*params_.get<std::string>("fields", "*")),
|
||||
geometry_field_(*params_.get<std::string>("geometry_field", "")),
|
||||
fields_(*params.get<std::string>("fields", "*")),
|
||||
geometry_field_(*params.get<std::string>("geometry_field", "")),
|
||||
srid_initialized_(false),
|
||||
extent_initialized_(false),
|
||||
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")),
|
||||
use_wkb_(*params_.get<mapnik::boolean>("use_wkb", false)),
|
||||
row_limit_(*params_.get<int>("row_limit", 0)),
|
||||
row_prefetch_(*params_.get<int>("row_prefetch", 100)),
|
||||
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding", "utf-8")),
|
||||
use_wkb_(*params.get<mapnik::boolean>("use_wkb", false)),
|
||||
row_limit_(*params.get<int>("row_limit", 0)),
|
||||
row_prefetch_(*params.get<int>("row_prefetch", 100)),
|
||||
pool_(0),
|
||||
conn_(0)
|
||||
{
|
||||
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");
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "occi_datasource::init");
|
||||
#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)
|
||||
{
|
||||
throw datasource_exception("OCCI Plugin: no <table> parameter specified");
|
||||
|
@ -95,57 +99,20 @@ occi_datasource::occi_datasource(parameters const& params, bool bind)
|
|||
{
|
||||
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);
|
||||
use_connection_pool_ = *params_.get<mapnik::boolean>("use_connection_pool",true);
|
||||
|
||||
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);
|
||||
|
||||
boost::optional<int> srid = params_.get<int>("srid");
|
||||
boost::optional<int> srid = params.get<int>("srid");
|
||||
if (srid)
|
||||
{
|
||||
srid_ = *srid;
|
||||
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
|
||||
if (use_connection_pool_)
|
||||
{
|
||||
|
@ -154,11 +121,11 @@ void occi_datasource::bind() const
|
|||
Environment* env = occi_environment::get_environment();
|
||||
|
||||
pool_ = env->createStatelessConnectionPool(
|
||||
*params_.get<std::string>("user"),
|
||||
*params_.get<std::string>("password"),
|
||||
*params_.get<std::string>("host"),
|
||||
*params_.get<int>("max_size", 5),
|
||||
*params_.get<int>("initial_size", 1),
|
||||
*params.get<std::string>("user"),
|
||||
*params.get<std::string>("password"),
|
||||
*params.get<std::string>("host"),
|
||||
*params.get<int>("max_size", 5),
|
||||
*params.get<int>("initial_size", 1),
|
||||
1,
|
||||
StatelessConnectionPool::HOMOGENEOUS);
|
||||
}
|
||||
|
@ -174,9 +141,9 @@ void occi_datasource::bind() const
|
|||
Environment* env = occi_environment::get_environment();
|
||||
|
||||
conn_ = env->createConnection(
|
||||
*params_.get<std::string>("user"),
|
||||
*params_.get<std::string>("password"),
|
||||
*params_.get<std::string>("host"));
|
||||
*params.get<std::string>("user"),
|
||||
*params.get<std::string>("password"),
|
||||
*params.get<std::string>("host"));
|
||||
}
|
||||
catch (SQLException& ex)
|
||||
{
|
||||
|
@ -348,8 +315,28 @@ void occi_datasource::bind() const
|
|||
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()
|
||||
|
@ -365,14 +352,11 @@ mapnik::datasource::datasource_t occi_datasource::type() const
|
|||
box2d<double> occi_datasource::envelope() const
|
||||
{
|
||||
if (extent_initialized_) return extent_;
|
||||
if (! is_bound_) bind();
|
||||
|
||||
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
|
||||
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
|
||||
{
|
||||
// FIXME
|
||||
//if (! is_bound_) bind();
|
||||
return boost::optional<mapnik::datasource::geometry_t>();
|
||||
}
|
||||
|
||||
layer_descriptor occi_datasource::get_descriptor() const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
return desc_;
|
||||
}
|
||||
|
||||
featureset_ptr occi_datasource::features(query const& q) const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "occi_datasource::features");
|
||||
#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
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "occi_datasource::features_at_point");
|
||||
#endif
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
class occi_datasource : public mapnik::datasource
|
||||
{
|
||||
public:
|
||||
occi_datasource(mapnik::parameters const& params, bool bind = true);
|
||||
occi_datasource(mapnik::parameters const& params);
|
||||
virtual ~occi_datasource ();
|
||||
mapnik::datasource::datasource_t type() const;
|
||||
static const char * name();
|
||||
|
@ -55,28 +55,28 @@ public:
|
|||
mapnik::box2d<double> envelope() const;
|
||||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
void bind() const;
|
||||
|
||||
private:
|
||||
static const std::string METADATA_TABLE;
|
||||
|
||||
mapnik::datasource::datasource_t type_;
|
||||
mutable std::string table_;
|
||||
mutable std::string table_name_;
|
||||
mutable std::string fields_;
|
||||
mutable std::string geometry_field_;
|
||||
mutable int srid_;
|
||||
mutable bool srid_initialized_;
|
||||
std::string table_;
|
||||
std::string table_name_;
|
||||
std::string fields_;
|
||||
std::string geometry_field_;
|
||||
int srid_;
|
||||
bool srid_initialized_;
|
||||
mutable bool extent_initialized_;
|
||||
mutable mapnik::box2d<double> extent_;
|
||||
mutable mapnik::layer_descriptor desc_;
|
||||
mutable bool use_wkb_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
bool use_wkb_;
|
||||
int row_limit_;
|
||||
int row_prefetch_;
|
||||
mutable oracle::occi::StatelessConnectionPool* pool_;
|
||||
mutable oracle::occi::Connection* conn_;
|
||||
oracle::occi::StatelessConnectionPool* pool_;
|
||||
oracle::occi::Connection* conn_;
|
||||
bool use_connection_pool_;
|
||||
bool use_spatial_index_;
|
||||
bool estimate_extent_;
|
||||
};
|
||||
|
||||
#endif // OCCI_DATASOURCE_HPP
|
||||
|
|
|
@ -148,7 +148,7 @@ feature_ptr occi_featureset::next()
|
|||
case oracle::occi::OCCIINT:
|
||||
case oracle::occi::OCCIUNSIGNED_INT:
|
||||
case oracle::occi::OCCIROWID:
|
||||
feature->put(fld_name,rs_->getInt (i + 1));
|
||||
feature->put(fld_name,static_cast<mapnik::value_integer>(rs_->getInt (i + 1)));
|
||||
break;
|
||||
case oracle::occi::OCCIFLOAT:
|
||||
case oracle::occi::OCCIBFLOAT:
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
occi_connection_ptr conn_;
|
||||
oracle::occi::ResultSet* rs_;
|
||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||
mutable int feature_id_;
|
||||
mapnik::value_integer feature_id_;
|
||||
mapnik::context_ptr ctx_;
|
||||
bool use_wkb_;
|
||||
std::vector<char> buffer_;
|
||||
|
|
|
@ -57,13 +57,32 @@ using mapnik::filter_in_box;
|
|||
using mapnik::filter_at_point;
|
||||
|
||||
|
||||
ogr_datasource::ogr_datasource(parameters const& params, bool bind)
|
||||
ogr_datasource::ogr_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
extent_(),
|
||||
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)
|
||||
{
|
||||
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> string = params.get<std::string>("string");
|
||||
if (! file && ! string)
|
||||
|
@ -88,35 +107,7 @@ ogr_datasource::ogr_datasource(parameters const& params, bool bind)
|
|||
}
|
||||
}
|
||||
|
||||
if (bind)
|
||||
{
|
||||
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","");
|
||||
std::string driver = *params.get<std::string>("driver","");
|
||||
|
||||
if (! driver.empty())
|
||||
{
|
||||
|
@ -147,9 +138,9 @@ void ogr_datasource::bind() const
|
|||
}
|
||||
|
||||
// initialize 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<std::string> layer_by_sql = params_.get<std::string>("layer_by_sql");
|
||||
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<std::string> layer_by_sql = params.get<std::string>("layer_by_sql");
|
||||
|
||||
int passed_parameters = 0;
|
||||
passed_parameters += layer_by_name ? 1 : 0;
|
||||
|
@ -185,7 +176,7 @@ void ogr_datasource::bind() const
|
|||
else if (layer_by_sql)
|
||||
{
|
||||
#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
|
||||
|
||||
layer_.layer_by_sql(dataset_, *layer_by_sql);
|
||||
|
@ -278,7 +269,7 @@ void ogr_datasource::bind() const
|
|||
#endif
|
||||
|
||||
#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
|
||||
|
||||
// deal with attributes descriptions
|
||||
|
@ -328,8 +319,6 @@ void ogr_datasource::bind() const
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
is_bound_ = true;
|
||||
}
|
||||
|
||||
const char * ogr_datasource::name()
|
||||
|
@ -344,7 +333,6 @@ mapnik::datasource::datasource_t ogr_datasource::type() const
|
|||
|
||||
box2d<double> ogr_datasource::envelope() const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
return extent_;
|
||||
}
|
||||
|
||||
|
@ -432,7 +420,6 @@ boost::optional<mapnik::datasource::geometry_t> ogr_datasource::get_geometry_typ
|
|||
|
||||
layer_descriptor ogr_datasource::get_descriptor() const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
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
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "ogr_datasource::features");
|
||||
#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
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "ogr_datasource::features_at_point");
|
||||
#endif
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
class ogr_datasource : public mapnik::datasource
|
||||
{
|
||||
public:
|
||||
ogr_datasource(mapnik::parameters const& params, bool bind=true);
|
||||
ogr_datasource(mapnik::parameters const& params);
|
||||
virtual ~ogr_datasource ();
|
||||
mapnik::datasource::datasource_t type() const;
|
||||
static const char * name();
|
||||
|
@ -56,18 +56,18 @@ public:
|
|||
mapnik::box2d<double> envelope() const;
|
||||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
void bind() const;
|
||||
|
||||
|
||||
private:
|
||||
mutable mapnik::box2d<double> extent_;
|
||||
void init(mapnik::parameters const& params);
|
||||
mapnik::box2d<double> extent_;
|
||||
mapnik::datasource::datasource_t type_;
|
||||
std::string dataset_name_;
|
||||
mutable std::string index_name_;
|
||||
mutable OGRDataSource* dataset_;
|
||||
mutable ogr_layer_ptr layer_;
|
||||
mutable std::string layer_name_;
|
||||
mutable mapnik::layer_descriptor desc_;
|
||||
mutable bool indexed_;
|
||||
std::string index_name_;
|
||||
OGRDataSource* dataset_;
|
||||
ogr_layer_ptr layer_;
|
||||
std::string layer_name_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
bool indexed_;
|
||||
};
|
||||
|
||||
#endif // OGR_DATASOURCE_HPP
|
||||
|
|
|
@ -88,7 +88,7 @@ feature_ptr ogr_featureset::next()
|
|||
{
|
||||
// ogr feature ids start at 0, so add one to stay
|
||||
// consistent with other mapnik datasources that start at 1
|
||||
const int feature_id = (poFeature->GetFID() + 1);
|
||||
mapnik::value_integer feature_id = (poFeature->GetFID() + 1);
|
||||
feature_ptr feature(feature_factory::create(ctx_,feature_id));
|
||||
|
||||
OGRGeometry* geom = poFeature->GetGeometryRef();
|
||||
|
@ -117,7 +117,7 @@ feature_ptr ogr_featureset::next()
|
|||
{
|
||||
case OFTInteger:
|
||||
{
|
||||
feature->put( fld_name, poFeature->GetFieldAsInteger(i));
|
||||
feature->put<mapnik::value_integer>( fld_name, poFeature->GetFieldAsInteger(i));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ feature_ptr ogr_index_featureset<filterT>::next()
|
|||
|
||||
// ogr feature ids start at 0, so add one to stay
|
||||
// consistent with other mapnik datasources that start at 1
|
||||
int feature_id = (poFeature->GetFID() + 1);
|
||||
mapnik::value_integer feature_id = (poFeature->GetFID() + 1);
|
||||
feature_ptr feature(feature_factory::create(ctx_,feature_id));
|
||||
|
||||
OGRGeometry* geom=poFeature->GetGeometryRef();
|
||||
|
@ -126,7 +126,7 @@ feature_ptr ogr_index_featureset<filterT>::next()
|
|||
{
|
||||
case OFTInteger:
|
||||
{
|
||||
feature->put(fld_name,poFeature->GetFieldAsInteger (i));
|
||||
feature->put<mapnik::value_integer>(fld_name,poFeature->GetFieldAsInteger (i));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#ifndef OSM_H
|
||||
#define OSM_H
|
||||
|
||||
#include <mapnik/value.hpp>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
@ -65,7 +66,7 @@ public:
|
|||
|
||||
struct osm_item
|
||||
{
|
||||
long id;
|
||||
mapnik::value_integer id;
|
||||
std::map<std::string, std::string> keyvals;
|
||||
virtual std::string to_string();
|
||||
virtual ~osm_item() {}
|
||||
|
|
|
@ -49,28 +49,17 @@ using mapnik::attribute_descriptor;
|
|||
|
||||
DATASOURCE_PLUGIN(osm_datasource)
|
||||
|
||||
osm_datasource::osm_datasource(const parameters& params, bool bind)
|
||||
osm_datasource::osm_datasource(const parameters& params)
|
||||
: datasource (params),
|
||||
extent_(),
|
||||
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;
|
||||
std::string osm_filename = *params_.get<std::string>("file", "");
|
||||
std::string parser = *params_.get<std::string>("parser", "libxml2");
|
||||
std::string url = *params_.get<std::string>("url", "");
|
||||
std::string bbox = *params_.get<std::string>("bbox", "");
|
||||
|
||||
std::string osm_filename = *params.get<std::string>("file", "");
|
||||
std::string parser = *params.get<std::string>("parser", "libxml2");
|
||||
std::string url = *params.get<std::string>("url", "");
|
||||
std::string bbox = *params.get<std::string>("bbox", "");
|
||||
|
||||
// load the data
|
||||
if (url != "" && bbox != "")
|
||||
|
@ -118,7 +107,6 @@ void osm_datasource::bind() const
|
|||
// Get the bounds of the data and set extent_ accordingly
|
||||
bounds b = osm_data_->get_bounds();
|
||||
extent_ = box2d<double>(b.w, b.s, b.e, b.n);
|
||||
is_bound_ = true;
|
||||
}
|
||||
|
||||
osm_datasource::~osm_datasource()
|
||||
|
@ -144,8 +132,6 @@ layer_descriptor osm_datasource::get_descriptor() const
|
|||
|
||||
featureset_ptr osm_datasource::features(const query& q) const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
filter_in_box filter(q.get_bbox());
|
||||
// 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
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
filter_at_point filter(pt);
|
||||
// collect all attribute names
|
||||
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
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
return extent_;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ using mapnik::box2d;
|
|||
class osm_datasource : public datasource
|
||||
{
|
||||
public:
|
||||
osm_datasource(const parameters& params, bool bind = true);
|
||||
osm_datasource(const parameters& params);
|
||||
virtual ~osm_datasource();
|
||||
mapnik::datasource::datasource_t type() const;
|
||||
static const char * name();
|
||||
|
@ -62,13 +62,12 @@ public:
|
|||
box2d<double> envelope() const;
|
||||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
layer_descriptor get_descriptor() const;
|
||||
void bind() const;
|
||||
|
||||
private:
|
||||
mutable box2d<double> extent_;
|
||||
mutable osm_dataset* osm_data_;
|
||||
box2d<double> extent_;
|
||||
osm_dataset* osm_data_;
|
||||
mapnik::datasource::datasource_t type_;
|
||||
mutable layer_descriptor desc_;
|
||||
layer_descriptor desc_;
|
||||
};
|
||||
|
||||
#endif // OSM_DATASOURCE_HPP
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <cassert>
|
||||
|
||||
osm_item* osmparser::cur_item=NULL;
|
||||
long osmparser::curID=0;
|
||||
mapnik::value_integer osmparser::curID=0;
|
||||
bool osmparser::in_node=false, osmparser::in_way=false;
|
||||
osm_dataset* osmparser::components=NULL;
|
||||
std::string osmparser::error="";
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#ifndef OSMPARSER_H
|
||||
#define OSMPARSER_H
|
||||
|
||||
#include <mapnik/value.hpp>
|
||||
#include <libxml/xmlreader.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
@ -41,7 +42,7 @@ public:
|
|||
|
||||
private:
|
||||
static osm_item *cur_item;
|
||||
static long curID;
|
||||
static mapnik::value_integer curID;
|
||||
static bool in_node, in_way;
|
||||
static osm_dataset* components;
|
||||
static std::string error;
|
||||
|
|
|
@ -55,20 +55,20 @@ using boost::shared_ptr;
|
|||
using mapnik::PoolGuard;
|
||||
using mapnik::attribute_descriptor;
|
||||
|
||||
postgis_datasource::postgis_datasource(parameters const& params, bool bind)
|
||||
postgis_datasource::postgis_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
table_(*params_.get<std::string>("table", "")),
|
||||
table_(*params.get<std::string>("table", "")),
|
||||
schema_(""),
|
||||
geometry_table_(*params_.get<std::string>("geometry_table", "")),
|
||||
geometry_field_(*params_.get<std::string>("geometry_field", "")),
|
||||
key_field_(*params_.get<std::string>("key_field", "")),
|
||||
cursor_fetch_size_(*params_.get<int>("cursor_size", 0)),
|
||||
row_limit_(*params_.get<int>("row_limit", 0)),
|
||||
geometry_table_(*params.get<std::string>("geometry_table", "")),
|
||||
geometry_field_(*params.get<std::string>("geometry_field", "")),
|
||||
key_field_(*params.get<std::string>("key_field", "")),
|
||||
cursor_fetch_size_(*params.get<int>("cursor_size", 0)),
|
||||
row_limit_(*params.get<int>("row_limit", 0)),
|
||||
type_(datasource::Vector),
|
||||
srid_(*params_.get<int>("srid", 0)),
|
||||
srid_(*params.get<int>("srid", 0)),
|
||||
extent_initialized_(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"),
|
||||
params.get<std::string>("port"),
|
||||
params.get<std::string>("dbname"),
|
||||
|
@ -79,45 +79,32 @@ postgis_datasource::postgis_datasource(parameters const& params, bool bind)
|
|||
scale_denom_token_("!scale_denominator!"),
|
||||
pixel_width_token_("!pixel_width!"),
|
||||
pixel_height_token_("!pixel_height!"),
|
||||
persist_connection_(*params_.get<mapnik::boolean>("persist_connection", true)),
|
||||
extent_from_subquery_(*params_.get<mapnik::boolean>("extent_from_subquery", false)),
|
||||
persist_connection_(*params.get<mapnik::boolean>("persist_connection", true)),
|
||||
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)
|
||||
intersect_min_scale_(*params_.get<int>("intersect_min_scale", 0)),
|
||||
intersect_max_scale_(*params_.get<int>("intersect_max_scale", 0))
|
||||
intersect_min_scale_(*params.get<int>("intersect_min_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())
|
||||
{
|
||||
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())
|
||||
{
|
||||
extent_initialized_ = extent_.from_string(*ext);
|
||||
}
|
||||
|
||||
if (bind)
|
||||
{
|
||||
this->bind();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
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> 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);
|
||||
simplify_geometries_ = simplify_opt && *simplify_opt;
|
||||
|
||||
ConnectionManager::instance().registerPool(creator_, *initial_size, *max_size);
|
||||
|
@ -158,7 +145,7 @@ void postgis_datasource::bind() const
|
|||
if (geometryColumn_.empty() || srid_ == 0)
|
||||
{
|
||||
#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
|
||||
std::ostringstream s;
|
||||
|
||||
|
@ -424,14 +411,13 @@ void postgis_datasource::bind() const
|
|||
|
||||
rs->close();
|
||||
|
||||
is_bound_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
postgis_datasource::~postgis_datasource()
|
||||
{
|
||||
if (is_bound_ && ! persist_connection_)
|
||||
if (! persist_connection_)
|
||||
{
|
||||
shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id());
|
||||
if (pool)
|
||||
|
@ -457,11 +443,6 @@ mapnik::datasource::datasource_t postgis_datasource::type() const
|
|||
|
||||
layer_descriptor postgis_datasource::get_descriptor() const
|
||||
{
|
||||
if (! is_bound_)
|
||||
{
|
||||
bind();
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
if (! is_bound_)
|
||||
{
|
||||
bind();
|
||||
}
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "postgis_datasource::features");
|
||||
#endif
|
||||
|
@ -659,7 +635,10 @@ featureset_ptr postgis_datasource::features(const query& q) const
|
|||
s << "\"" << geometryColumn_ << "\"";
|
||||
|
||||
if (simplify_geometries_) {
|
||||
const double tolerance = std::min(px_gw, px_gh) / 2.0;
|
||||
// 1/20 of pixel seems to be a good compromise to avoid
|
||||
// drop of collapsed polygons.
|
||||
// See https://github.com/mapnik/mapnik/issues/1639
|
||||
const double tolerance = std::min(px_gw, px_gh) / 20.0;
|
||||
s << ", " << tolerance << ")";
|
||||
}
|
||||
|
||||
|
@ -725,11 +704,6 @@ featureset_ptr postgis_datasource::features(const query& q) const
|
|||
|
||||
featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double tol) const
|
||||
{
|
||||
if (! is_bound_)
|
||||
{
|
||||
bind();
|
||||
}
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "postgis_datasource::features_at_point");
|
||||
#endif
|
||||
|
@ -817,11 +791,6 @@ box2d<double> postgis_datasource::envelope() const
|
|||
return extent_;
|
||||
}
|
||||
|
||||
if (! is_bound_)
|
||||
{
|
||||
bind();
|
||||
}
|
||||
|
||||
shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id());
|
||||
if (pool)
|
||||
{
|
||||
|
@ -832,9 +801,6 @@ box2d<double> postgis_datasource::envelope() const
|
|||
|
||||
std::ostringstream s;
|
||||
|
||||
boost::optional<mapnik::boolean> estimate_extent =
|
||||
params_.get<mapnik::boolean>("estimate_extent", false);
|
||||
|
||||
if (geometryColumn_.empty())
|
||||
{
|
||||
std::ostringstream s_error;
|
||||
|
@ -852,7 +818,7 @@ box2d<double> postgis_datasource::envelope() const
|
|||
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)"
|
||||
<< " FROM (SELECT ST_Estimated_Extent('";
|
||||
|
@ -915,11 +881,6 @@ box2d<double> postgis_datasource::envelope() const
|
|||
|
||||
boost::optional<mapnik::datasource::geometry_t> postgis_datasource::get_geometry_type() const
|
||||
{
|
||||
if (! is_bound_)
|
||||
{
|
||||
bind();
|
||||
}
|
||||
|
||||
boost::optional<mapnik::datasource::geometry_t> result;
|
||||
|
||||
shared_ptr< Pool<Connection,ConnectionCreator> > pool = ConnectionManager::instance().getPool(creator_.id());
|
||||
|
|
|
@ -58,7 +58,7 @@ using mapnik::coord2d;
|
|||
class postgis_datasource : public datasource
|
||||
{
|
||||
public:
|
||||
postgis_datasource(const parameters ¶ms, bool bind=true);
|
||||
postgis_datasource(const parameters ¶ms);
|
||||
~postgis_datasource();
|
||||
mapnik::datasource::datasource_t type() const;
|
||||
static const char * name();
|
||||
|
@ -67,7 +67,6 @@ public:
|
|||
mapnik::box2d<double> envelope() const;
|
||||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
layer_descriptor get_descriptor() const;
|
||||
void bind() const;
|
||||
|
||||
private:
|
||||
std::string sql_bbox(box2d<double> const& env) const;
|
||||
|
@ -84,19 +83,19 @@ private:
|
|||
const std::string username_;
|
||||
const std::string password_;
|
||||
const std::string table_;
|
||||
mutable std::string schema_;
|
||||
mutable std::string geometry_table_;
|
||||
std::string schema_;
|
||||
std::string geometry_table_;
|
||||
const std::string geometry_field_;
|
||||
mutable std::string key_field_;
|
||||
std::string key_field_;
|
||||
const int cursor_fetch_size_;
|
||||
const int row_limit_;
|
||||
mutable std::string geometryColumn_;
|
||||
std::string geometryColumn_;
|
||||
mapnik::datasource::datasource_t type_;
|
||||
mutable int srid_;
|
||||
int srid_;
|
||||
mutable bool extent_initialized_;
|
||||
mutable mapnik::box2d<double> extent_;
|
||||
mutable bool simplify_geometries_;
|
||||
mutable layer_descriptor desc_;
|
||||
bool simplify_geometries_;
|
||||
layer_descriptor desc_;
|
||||
ConnectionCreator<Connection> creator_;
|
||||
const std::string bbox_token_;
|
||||
const std::string scale_denom_token_;
|
||||
|
@ -104,6 +103,7 @@ private:
|
|||
const std::string pixel_height_token_;
|
||||
bool persist_connection_;
|
||||
bool extent_from_subquery_;
|
||||
bool estimate_extent_;
|
||||
// params below are for testing purposes only (will likely be removed at any time)
|
||||
int intersect_min_scale_;
|
||||
int intersect_max_scale_;
|
||||
|
|
|
@ -75,8 +75,9 @@ feature_ptr postgis_featureset::next()
|
|||
const char* buf = rs_->getValue(pos);
|
||||
std::string name = rs_->getFieldName(pos);
|
||||
|
||||
// validation happens of this type at bind()
|
||||
int val;
|
||||
// validation happens of this type at initialization
|
||||
mapnik::value_integer val;
|
||||
|
||||
if (oid == 20)
|
||||
{
|
||||
val = int8net(buf);
|
||||
|
@ -94,7 +95,7 @@ feature_ptr postgis_featureset::next()
|
|||
// TODO - extend feature class to know
|
||||
// that its id is also an attribute to avoid
|
||||
// this duplication
|
||||
feature->put(name,val);
|
||||
feature->put<mapnik::value_integer>(name,val);
|
||||
++pos;
|
||||
}
|
||||
else
|
||||
|
@ -135,24 +136,19 @@ feature_ptr postgis_featureset::next()
|
|||
|
||||
case 23: //int4
|
||||
{
|
||||
int val = int4net(buf);
|
||||
feature->put(name, val);
|
||||
feature->put<mapnik::value_integer>(name, int4net(buf));
|
||||
break;
|
||||
}
|
||||
|
||||
case 21: //int2
|
||||
{
|
||||
int val = int2net(buf);
|
||||
feature->put(name, val);
|
||||
feature->put<mapnik::value_integer>(name, int2net(buf));
|
||||
break;
|
||||
}
|
||||
|
||||
case 20: //int8/BigInt
|
||||
{
|
||||
// TODO - need to support boost::uint64_t in mapnik::value
|
||||
// https://github.com/mapnik/mapnik/issues/895
|
||||
int val = int8net(buf);
|
||||
feature->put(name, val);
|
||||
feature->put<mapnik::value_integer>(name, int8net(buf));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ private:
|
|||
context_ptr ctx_;
|
||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||
unsigned totalGeomSize_;
|
||||
int feature_id_;
|
||||
mapnik::value_integer feature_id_;
|
||||
bool key_field_;
|
||||
};
|
||||
|
||||
|
|
|
@ -69,6 +69,9 @@ TARGET = plugin_env.SharedLibrary(
|
|||
LINKFLAGS=linkflags
|
||||
)
|
||||
|
||||
# if the plugin links to libmapnik ensure it is built first
|
||||
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||
|
||||
# if 'uninstall' is not passed on the command line
|
||||
# then we actually create the install targets that
|
||||
# scons will install if 'install' is passed as an arg
|
||||
|
|
|
@ -20,53 +20,27 @@ using mapnik::parameters;
|
|||
|
||||
DATASOURCE_PLUGIN(python_datasource)
|
||||
|
||||
python_datasource::python_datasource(parameters const& params, bool bind)
|
||||
python_datasource::python_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding","utf-8")),
|
||||
factory_(*params_.get<std::string>("factory", ""))
|
||||
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding","utf-8")),
|
||||
factory_(*params.get<std::string>("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"))
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
// The following methods call into the Python interpreter and hence require, unfortunately, that the GIL be held.
|
||||
using namespace boost;
|
||||
|
||||
if (is_bound_) return;
|
||||
|
||||
// if no factory callable is defined, bind is a nop
|
||||
if (factory_.empty()) return;
|
||||
if (factory_.empty())
|
||||
{
|
||||
throw mapnik::datasource_exception("Python: 'factory' option must be defined");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -111,16 +85,27 @@ void python_datasource::bind() const
|
|||
{
|
||||
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
|
||||
{
|
||||
typedef boost::optional<mapnik::datasource::geometry_t> return_type;
|
||||
|
||||
if (!is_bound_) bind();
|
||||
|
||||
try
|
||||
{
|
||||
ensure_gil lock;
|
||||
|
@ -137,8 +122,6 @@ mapnik::datasource::datasource_t python_datasource::type() const
|
|||
|
||||
mapnik::box2d<double> python_datasource::envelope() const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
try
|
||||
{
|
||||
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;
|
||||
|
||||
if (!is_bound_) bind();
|
||||
|
||||
try
|
||||
{
|
||||
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
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
try
|
||||
{
|
||||
// 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
|
||||
{
|
||||
|
||||
if (!is_bound_) bind();
|
||||
|
||||
try
|
||||
{
|
||||
ensure_gil lock;
|
||||
|
|
|
@ -12,7 +12,7 @@ class python_datasource : public mapnik::datasource
|
|||
public:
|
||||
// constructor
|
||||
// arguments must not change
|
||||
python_datasource(mapnik::parameters const& params, bool bind=true);
|
||||
python_datasource(mapnik::parameters const& params);
|
||||
|
||||
// destructor
|
||||
virtual ~python_datasource ();
|
||||
|
@ -41,15 +41,12 @@ public:
|
|||
// mandatory: return the layer descriptor
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
|
||||
// mandatory: will bind the datasource given params
|
||||
void bind() const;
|
||||
|
||||
private:
|
||||
static const char* name_;
|
||||
mutable mapnik::layer_descriptor desc_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
const std::string factory_;
|
||||
std::map<std::string, std::string> kwargs_;
|
||||
mutable boost::python::object datasource_;
|
||||
boost::python::object datasource_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ using mapnik::image_reader;
|
|||
|
||||
DATASOURCE_PLUGIN(raster_datasource)
|
||||
|
||||
raster_datasource::raster_datasource(parameters const& params, bool bind)
|
||||
raster_datasource::raster_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
desc_(*params.get<std::string>("type"), "utf-8"),
|
||||
extent_initialized_(false)
|
||||
|
@ -61,18 +61,19 @@ raster_datasource::raster_datasource(parameters const& params, bool bind)
|
|||
else
|
||||
filename_ = *file;
|
||||
|
||||
multi_tiles_ = *params_.get<bool>("multi", false);
|
||||
tile_size_ = *params_.get<unsigned>("tile_size", 256);
|
||||
tile_stride_ = *params_.get<unsigned>("tile_stride", 1);
|
||||
multi_tiles_ = *params.get<bool>("multi", false);
|
||||
tile_size_ = *params.get<unsigned>("tile_size", 256);
|
||||
tile_stride_ = *params.get<unsigned>("tile_stride", 1);
|
||||
|
||||
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");
|
||||
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");
|
||||
|
||||
if (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");
|
||||
}
|
||||
|
||||
if (bind)
|
||||
{
|
||||
this->bind();
|
||||
}
|
||||
}
|
||||
|
||||
void raster_datasource::bind() const
|
||||
{
|
||||
if (is_bound_) return;
|
||||
|
||||
|
||||
if (multi_tiles_)
|
||||
{
|
||||
boost::optional<unsigned> x_width = params_.get<unsigned>("x_width");
|
||||
boost::optional<unsigned> y_width = params_.get<unsigned>("y_width");
|
||||
boost::optional<unsigned> x_width = params.get<unsigned>("x_width");
|
||||
boost::optional<unsigned> y_width = params.get<unsigned>("y_width");
|
||||
|
||||
if (! x_width)
|
||||
{
|
||||
|
@ -148,7 +139,6 @@ void raster_datasource::bind() const
|
|||
|
||||
MAPNIK_LOG_DEBUG(raster) << "raster_datasource: Raster size=" << width_ << "," << height_;
|
||||
|
||||
is_bound_ = true;
|
||||
}
|
||||
|
||||
raster_datasource::~raster_datasource()
|
||||
|
@ -182,8 +172,6 @@ layer_descriptor raster_datasource::get_descriptor() const
|
|||
|
||||
featureset_ptr raster_datasource::features(query const& q) const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
mapnik::CoordTransform t(width_, height_, extent_, 0, 0);
|
||||
mapnik::box2d<double> intersect = extent_.intersect(q.get_bbox());
|
||||
mapnik::box2d<double> ext = t.forward(intersect);
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
class raster_datasource : public mapnik::datasource
|
||||
{
|
||||
public:
|
||||
raster_datasource(const mapnik::parameters& params, bool bind=true);
|
||||
raster_datasource(const mapnik::parameters& params);
|
||||
virtual ~raster_datasource();
|
||||
datasource::datasource_t type() const;
|
||||
static const char * name();
|
||||
|
@ -54,7 +54,6 @@ public:
|
|||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
bool log_enabled() const;
|
||||
void bind() const;
|
||||
|
||||
private:
|
||||
mapnik::layer_descriptor desc_;
|
||||
|
@ -65,8 +64,8 @@ private:
|
|||
bool multi_tiles_;
|
||||
unsigned tile_size_;
|
||||
unsigned tile_stride_;
|
||||
mutable unsigned width_;
|
||||
mutable unsigned height_;
|
||||
unsigned width_;
|
||||
unsigned height_;
|
||||
};
|
||||
|
||||
#endif // RASTER_DATASOURCE_HPP
|
||||
|
|
|
@ -315,7 +315,7 @@ public:
|
|||
|
||||
private:
|
||||
LookupPolicy policy_;
|
||||
int feature_id_;
|
||||
mapnik::value_integer feature_id_;
|
||||
mapnik::context_ptr ctx_;
|
||||
mapnik::box2d<double> extent_;
|
||||
mapnik::box2d<double> bbox_;
|
||||
|
|
|
@ -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),
|
||||
desc_(*params.get<std::string>("type"),"utf-8")
|
||||
{
|
||||
|
@ -91,16 +91,11 @@ rasterlite_datasource::rasterlite_datasource(parameters const& params, bool bind
|
|||
else
|
||||
dataset_name_ = *file;
|
||||
|
||||
if (bind)
|
||||
{
|
||||
this->bind();
|
||||
}
|
||||
this->init(params);
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
void *dataset = open_dataset();
|
||||
|
@ -158,8 +153,6 @@ void rasterlite_datasource::bind() const
|
|||
#endif
|
||||
|
||||
rasterliteClose(dataset);
|
||||
|
||||
is_bound_ = true;
|
||||
}
|
||||
|
||||
rasterlite_datasource::~rasterlite_datasource()
|
||||
|
@ -178,8 +171,6 @@ mapnik::datasource::datasource_t rasterlite_datasource::type() const
|
|||
|
||||
box2d<double> rasterlite_datasource::envelope() const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
return extent_;
|
||||
}
|
||||
|
||||
|
@ -195,16 +186,12 @@ layer_descriptor rasterlite_datasource::get_descriptor() const
|
|||
|
||||
featureset_ptr rasterlite_datasource::features(query const& q) const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
rasterlite_query gq = q;
|
||||
return boost::make_shared<rasterlite_featureset>(open_dataset(), gq);
|
||||
}
|
||||
|
||||
featureset_ptr rasterlite_datasource::features_at_point(coord2d const& pt, double tol) const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
rasterlite_query gq = pt;
|
||||
return boost::make_shared<rasterlite_featureset>(open_dataset(), gq);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
class rasterlite_datasource : public mapnik::datasource
|
||||
{
|
||||
public:
|
||||
rasterlite_datasource(mapnik::parameters const& params, bool bind = true);
|
||||
rasterlite_datasource(mapnik::parameters const& params);
|
||||
virtual ~rasterlite_datasource ();
|
||||
mapnik::datasource::datasource_t type() const;
|
||||
static const char * name();
|
||||
|
@ -54,11 +54,10 @@ public:
|
|||
mapnik::box2d<double> envelope() const;
|
||||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
void bind() const;
|
||||
|
||||
private:
|
||||
void* open_dataset() const;
|
||||
mutable mapnik::box2d<double> extent_;
|
||||
mapnik::box2d<double> extent_;
|
||||
std::string dataset_name_;
|
||||
std::string table_name_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
|
|
|
@ -173,7 +173,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature & f)
|
|||
}
|
||||
else
|
||||
{
|
||||
int val = 0;
|
||||
mapnik::value_integer val = 0;
|
||||
const char *itr = record_+fields_[col].offset_;
|
||||
const char *end = itr + fields_[col].length_;
|
||||
if (qi::phrase_parse(itr,end,int_,ascii::space,val))
|
||||
|
|
|
@ -55,14 +55,17 @@ using mapnik::filter_in_box;
|
|||
using mapnik::filter_at_point;
|
||||
using mapnik::attribute_descriptor;
|
||||
|
||||
shape_datasource::shape_datasource(const parameters ¶ms, bool bind)
|
||||
shape_datasource::shape_datasource(const parameters ¶ms)
|
||||
: datasource (params),
|
||||
type_(datasource::Vector),
|
||||
file_length_(0),
|
||||
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"))
|
||||
{
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "shape_datasource::init");
|
||||
#endif
|
||||
boost::optional<std::string> file = params.get<std::string>("file");
|
||||
if (!file) throw datasource_exception("Shape Plugin: missing <file> parameter");
|
||||
|
||||
|
@ -74,20 +77,6 @@ shape_datasource::shape_datasource(const parameters ¶ms, bool bind)
|
|||
|
||||
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"))
|
||||
{
|
||||
throw datasource_exception("Shape Plugin: shapefile '" + shape_name_ + ".shp' does not exist");
|
||||
|
@ -107,7 +96,7 @@ void shape_datasource::bind() const
|
|||
try
|
||||
{
|
||||
#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
|
||||
|
||||
boost::shared_ptr<shape_io> shape_ref = boost::make_shared<shape_io>(shape_name_);
|
||||
|
@ -171,12 +160,9 @@ void shape_datasource::bind() const
|
|||
throw;
|
||||
}
|
||||
|
||||
is_bound_ = true;
|
||||
}
|
||||
|
||||
shape_datasource::~shape_datasource() {}
|
||||
|
||||
void shape_datasource::init(shape_io& shape) const
|
||||
void shape_datasource::init(shape_io& shape)
|
||||
{
|
||||
#ifdef MAPNIK_STATS
|
||||
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_;
|
||||
}
|
||||
|
||||
shape_datasource::~shape_datasource() {}
|
||||
|
||||
const char * shape_datasource::name()
|
||||
{
|
||||
return "shape";
|
||||
|
@ -252,14 +240,11 @@ datasource::datasource_t shape_datasource::type() const
|
|||
|
||||
layer_descriptor shape_datasource::get_descriptor() const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
return desc_;
|
||||
}
|
||||
|
||||
featureset_ptr shape_datasource::features(const query& q) const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "shape_datasource::features");
|
||||
#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
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "shape_datasource::features_at_point");
|
||||
#endif
|
||||
|
@ -334,8 +317,6 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt, double tol
|
|||
|
||||
box2d<double> shape_datasource::envelope() const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
return extent_;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ using mapnik::coord2d;
|
|||
class shape_datasource : public datasource
|
||||
{
|
||||
public:
|
||||
shape_datasource(const parameters ¶ms, bool bind=true);
|
||||
shape_datasource(const parameters ¶ms);
|
||||
virtual ~shape_datasource();
|
||||
datasource::datasource_t type() const;
|
||||
static const char * name();
|
||||
|
@ -61,20 +61,19 @@ public:
|
|||
box2d<double> envelope() const;
|
||||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
layer_descriptor get_descriptor() const;
|
||||
void bind() const;
|
||||
|
||||
private:
|
||||
void init(shape_io& shape) const;
|
||||
void init(shape_io& shape);
|
||||
|
||||
datasource::datasource_t type_;
|
||||
std::string shape_name_;
|
||||
mutable boost::shared_ptr<shape_io> shape_;
|
||||
mutable shape_io::shapeType shape_type_;
|
||||
mutable long file_length_;
|
||||
mutable box2d<double> extent_;
|
||||
mutable bool indexed_;
|
||||
boost::shared_ptr<shape_io> shape_;
|
||||
shape_io::shapeType shape_type_;
|
||||
long file_length_;
|
||||
box2d<double> extent_;
|
||||
bool indexed_;
|
||||
const int row_limit_;
|
||||
mutable layer_descriptor desc_;
|
||||
layer_descriptor desc_;
|
||||
};
|
||||
|
||||
#endif //SHAPE_HPP
|
||||
|
|
|
@ -175,7 +175,8 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c
|
|||
double x = record.read_double();
|
||||
double y = record.read_double();
|
||||
poly->move_to(x, y);
|
||||
|
||||
double start_x = x;
|
||||
double start_y = y;
|
||||
for (int j=start+1;j<end-1;j++)
|
||||
{
|
||||
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();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,22 +52,22 @@ using mapnik::parameters;
|
|||
|
||||
DATASOURCE_PLUGIN(sqlite_datasource)
|
||||
|
||||
sqlite_datasource::sqlite_datasource(parameters const& params, bool bind)
|
||||
sqlite_datasource::sqlite_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
extent_(),
|
||||
extent_initialized_(false),
|
||||
type_(datasource::Vector),
|
||||
table_(*params_.get<std::string>("table", "")),
|
||||
fields_(*params_.get<std::string>("fields", "*")),
|
||||
metadata_(*params_.get<std::string>("metadata", "")),
|
||||
geometry_table_(*params_.get<std::string>("geometry_table", "")),
|
||||
geometry_field_(*params_.get<std::string>("geometry_field", "")),
|
||||
index_table_(*params_.get<std::string>("index_table", "")),
|
||||
key_field_(*params_.get<std::string>("key_field", "")),
|
||||
row_offset_(*params_.get<int>("row_offset", 0)),
|
||||
row_limit_(*params_.get<int>("row_limit", 0)),
|
||||
table_(*params.get<std::string>("table", "")),
|
||||
fields_(*params.get<std::string>("fields", "*")),
|
||||
metadata_(*params.get<std::string>("metadata", "")),
|
||||
geometry_table_(*params.get<std::string>("geometry_table", "")),
|
||||
geometry_field_(*params.get<std::string>("geometry_field", "")),
|
||||
index_table_(*params.get<std::string>("index_table", "")),
|
||||
key_field_(*params.get<std::string>("key_field", "")),
|
||||
row_offset_(*params.get<int>("row_offset", 0)),
|
||||
row_limit_(*params.get<int>("row_limit", 0)),
|
||||
intersects_token_("!intersects!"),
|
||||
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")),
|
||||
format_(mapnik::wkbAuto)
|
||||
{
|
||||
/* TODO
|
||||
|
@ -76,27 +76,14 @@ sqlite_datasource::sqlite_datasource(parameters const& params, bool bind)
|
|||
- if spatialite - leverage more of the metadata for geometry type detection
|
||||
*/
|
||||
|
||||
boost::optional<std::string> file = params_.get<std::string>("file");
|
||||
if (! file) throw datasource_exception("Sqlite Plugin: missing <file> parameter");
|
||||
|
||||
if (bind)
|
||||
{
|
||||
this->bind();
|
||||
}
|
||||
}
|
||||
|
||||
void sqlite_datasource::bind() const
|
||||
{
|
||||
if (is_bound_) return;
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::bind");
|
||||
mapnik::progress_timer __stats__(std::clog, "sqlite_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("Sqlite 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)
|
||||
dataset_name_ = *base + "/" + *file;
|
||||
else
|
||||
|
@ -107,15 +94,15 @@ void sqlite_datasource::bind() const
|
|||
throw datasource_exception("Sqlite Plugin: " + dataset_name_ + " does not exist");
|
||||
}
|
||||
|
||||
use_spatial_index_ = *params_.get<mapnik::boolean>("use_spatial_index", true);
|
||||
use_spatial_index_ = *params.get<mapnik::boolean>("use_spatial_index", true);
|
||||
|
||||
// TODO - remove this option once all datasources have an indexing api
|
||||
bool auto_index = *params_.get<mapnik::boolean>("auto_index", true);
|
||||
bool auto_index = *params.get<mapnik::boolean>("auto_index", true);
|
||||
|
||||
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);
|
||||
|
||||
boost::optional<std::string> wkb = params_.get<std::string>("wkb_format");
|
||||
boost::optional<std::string> wkb = params.get<std::string>("wkb_format");
|
||||
if (wkb)
|
||||
{
|
||||
if (*wkb == "spatialite")
|
||||
|
@ -139,13 +126,13 @@ void sqlite_datasource::bind() const
|
|||
// databases are relative to directory containing dataset_name_. Sqlite
|
||||
// will default to attaching from cwd. Typicaly usage means that the
|
||||
// map loader will produce full paths here.
|
||||
boost::optional<std::string> attachdb = params_.get<std::string>("attachdb");
|
||||
boost::optional<std::string> attachdb = params.get<std::string>("attachdb");
|
||||
if (attachdb)
|
||||
{
|
||||
parse_attachdb(*attachdb);
|
||||
}
|
||||
|
||||
boost::optional<std::string> initdb = params_.get<std::string>("initdb");
|
||||
boost::optional<std::string> initdb = params.get<std::string>("initdb");
|
||||
if (initdb)
|
||||
{
|
||||
init_statements_.push_back(*initdb);
|
||||
|
@ -154,10 +141,10 @@ void sqlite_datasource::bind() const
|
|||
// now actually create the connection and start executing setup sql
|
||||
dataset_ = boost::make_shared<sqlite_connection>(dataset_name_);
|
||||
|
||||
boost::optional<unsigned> table_by_index = params_.get<unsigned>("table_by_index");
|
||||
boost::optional<unsigned> table_by_index = params.get<unsigned>("table_by_index");
|
||||
|
||||
int passed_parameters = 0;
|
||||
passed_parameters += params_.get<std::string>("table") ? 1 : 0;
|
||||
passed_parameters += params.get<std::string>("table") ? 1 : 0;
|
||||
passed_parameters += table_by_index ? 1 : 0;
|
||||
|
||||
if (passed_parameters > 1)
|
||||
|
@ -289,7 +276,7 @@ void sqlite_datasource::bind() const
|
|||
if (use_spatial_index_)
|
||||
{
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats2__(std::clog, "sqlite_datasource::bind(use_spatial_index)");
|
||||
mapnik::progress_timer __stats2__(std::clog, "sqlite_datasource::init(use_spatial_index)");
|
||||
#endif
|
||||
|
||||
if (boost::filesystem::exists(index_db))
|
||||
|
@ -374,7 +361,6 @@ void sqlite_datasource::bind() const
|
|||
}
|
||||
}
|
||||
|
||||
is_bound_ = true;
|
||||
}
|
||||
|
||||
std::string sqlite_datasource::populate_tokens(std::string const& sql) const
|
||||
|
@ -487,15 +473,11 @@ mapnik::datasource::datasource_t sqlite_datasource::type() const
|
|||
|
||||
box2d<double> sqlite_datasource::envelope() const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
return extent_;
|
||||
}
|
||||
|
||||
boost::optional<mapnik::datasource::geometry_t> sqlite_datasource::get_geometry_type() const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::get_geometry_type");
|
||||
#endif
|
||||
|
@ -547,15 +529,11 @@ boost::optional<mapnik::datasource::geometry_t> sqlite_datasource::get_geometry_
|
|||
|
||||
layer_descriptor sqlite_datasource::get_descriptor() const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
return desc_;
|
||||
}
|
||||
|
||||
featureset_ptr sqlite_datasource::features(query const& q) const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::features");
|
||||
#endif
|
||||
|
@ -634,8 +612,6 @@ featureset_ptr sqlite_datasource::features(query const& q) const
|
|||
|
||||
featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double tol) const
|
||||
{
|
||||
if (! is_bound_) bind();
|
||||
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::features_at_point");
|
||||
#endif
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
class sqlite_datasource : public mapnik::datasource
|
||||
{
|
||||
public:
|
||||
sqlite_datasource(mapnik::parameters const& params, bool bind = true);
|
||||
sqlite_datasource(mapnik::parameters const& params);
|
||||
virtual ~sqlite_datasource ();
|
||||
datasource::datasource_t type() const;
|
||||
static const char * name();
|
||||
|
@ -57,7 +57,6 @@ public:
|
|||
mapnik::box2d<double> envelope() const;
|
||||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
void bind() const;
|
||||
|
||||
private:
|
||||
// Fill init_statements with any statements
|
||||
|
@ -65,30 +64,27 @@ private:
|
|||
void parse_attachdb(std::string const& attachdb) const;
|
||||
std::string populate_tokens(std::string const& sql) const;
|
||||
|
||||
// FIXME: remove mutable qualifier from data members
|
||||
// by factoring out bind() logic out from
|
||||
// datasource impl !!!
|
||||
mutable mapnik::box2d<double> extent_;
|
||||
mutable bool extent_initialized_;
|
||||
mapnik::box2d<double> extent_;
|
||||
bool extent_initialized_;
|
||||
mapnik::datasource::datasource_t type_;
|
||||
mutable std::string dataset_name_;
|
||||
mutable boost::shared_ptr<sqlite_connection> dataset_;
|
||||
mutable std::string table_;
|
||||
std::string dataset_name_;
|
||||
boost::shared_ptr<sqlite_connection> dataset_;
|
||||
std::string table_;
|
||||
std::string fields_;
|
||||
std::string metadata_;
|
||||
mutable std::string geometry_table_;
|
||||
mutable std::string geometry_field_;
|
||||
mutable std::string index_table_;
|
||||
mutable std::string key_field_;
|
||||
mutable int row_offset_;
|
||||
mutable int row_limit_;
|
||||
std::string geometry_table_;
|
||||
std::string geometry_field_;
|
||||
std::string index_table_;
|
||||
std::string key_field_;
|
||||
int row_offset_;
|
||||
int row_limit_;
|
||||
// TODO - also add to postgis.input
|
||||
const std::string intersects_token_;
|
||||
mutable mapnik::layer_descriptor desc_;
|
||||
mutable mapnik::wkbFormat format_;
|
||||
mutable bool use_spatial_index_;
|
||||
mutable bool has_spatial_index_;
|
||||
mutable bool using_subquery_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
mapnik::wkbFormat format_;
|
||||
bool use_spatial_index_;
|
||||
bool has_spatial_index_;
|
||||
bool using_subquery_;
|
||||
mutable std::vector<std::string> init_statements_;
|
||||
};
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ feature_ptr sqlite_featureset::next()
|
|||
return feature_ptr();
|
||||
}
|
||||
|
||||
feature_ptr feature = feature_factory::create(ctx_,rs_->column_integer(1));
|
||||
feature_ptr feature = feature_factory::create(ctx_,rs_->column_integer64(1));
|
||||
if (!geometry_utils::from_wkb(feature->paths(), data, size, format_))
|
||||
continue;
|
||||
|
||||
|
@ -104,7 +104,7 @@ feature_ptr sqlite_featureset::next()
|
|||
{
|
||||
case SQLITE_INTEGER:
|
||||
{
|
||||
feature->put(fld_name_str, rs_->column_integer(i));
|
||||
feature->put<mapnik::value_integer>(fld_name_str, rs_->column_integer64(i));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ private:
|
|||
boost::shared_ptr<sqlite_resultset> rs_;
|
||||
mapnik::context_ptr ctx_;
|
||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||
mapnik::box2d<double> const& bbox_;
|
||||
mapnik::box2d<double> bbox_;
|
||||
mapnik::wkbFormat format_;
|
||||
bool spatial_index_;
|
||||
bool using_subquery_;
|
||||
|
|
|
@ -640,7 +640,7 @@ public:
|
|||
found_table = true;
|
||||
const char* fld_name = rs->column_text(1);
|
||||
std::string fld_type(rs->column_text(2));
|
||||
int fld_pk = rs->column_integer(5);
|
||||
sqlite_int64 fld_pk = rs->column_integer64(5);
|
||||
boost::algorithm::to_lower(fld_type);
|
||||
|
||||
// TODO - how to handle primary keys on multiple columns ?
|
||||
|
|
|
@ -11,29 +11,22 @@ using mapnik::parameters;
|
|||
|
||||
DATASOURCE_PLUGIN(hello_datasource)
|
||||
|
||||
hello_datasource::hello_datasource(parameters const& params, bool bind)
|
||||
hello_datasource::hello_datasource(parameters const& 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_()
|
||||
{
|
||||
if (bind)
|
||||
{
|
||||
this->bind();
|
||||
}
|
||||
this->init(params);
|
||||
}
|
||||
|
||||
void hello_datasource::bind() const
|
||||
void hello_datasource::init(mapnik::parameters const& params)
|
||||
{
|
||||
if (is_bound_) return;
|
||||
|
||||
// every datasource must have some way of reporting its extent
|
||||
// in this case we are not actually reading from any data so for fun
|
||||
// let's just create a world extent in Mapnik's default srs:
|
||||
// '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' (equivalent to +init=epsg:4326)
|
||||
// see http://spatialreference.org/ref/epsg/4326/ for more details
|
||||
extent_.init(-180,-90,180,90);
|
||||
|
||||
is_bound_ = true;
|
||||
}
|
||||
|
||||
hello_datasource::~hello_datasource() { }
|
||||
|
@ -51,8 +44,6 @@ mapnik::datasource::datasource_t hello_datasource::type() const
|
|||
|
||||
mapnik::box2d<double> hello_datasource::envelope() const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
return extent_;
|
||||
}
|
||||
|
||||
|
@ -63,15 +54,11 @@ boost::optional<mapnik::datasource::geometry_t> hello_datasource::get_geometry_t
|
|||
|
||||
mapnik::layer_descriptor hello_datasource::get_descriptor() const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
return desc_;
|
||||
}
|
||||
|
||||
mapnik::featureset_ptr hello_datasource::features(mapnik::query const& q) const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
// if the query box intersects our world extent then query for features
|
||||
if (extent_.intersects(q.get_bbox()))
|
||||
{
|
||||
|
@ -84,8 +71,6 @@ mapnik::featureset_ptr hello_datasource::features(mapnik::query const& q) const
|
|||
|
||||
mapnik::featureset_ptr hello_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
// features_at_point is rarely used - only by custom applications,
|
||||
// so for this sample plugin let's do nothing...
|
||||
return mapnik::featureset_ptr();
|
||||
|
|
|
@ -22,7 +22,7 @@ class hello_datasource : public mapnik::datasource
|
|||
public:
|
||||
// constructor
|
||||
// arguments must not change
|
||||
hello_datasource(mapnik::parameters const& params, bool bind=true);
|
||||
hello_datasource(mapnik::parameters const& params);
|
||||
|
||||
// destructor
|
||||
virtual ~hello_datasource ();
|
||||
|
@ -51,15 +51,15 @@ public:
|
|||
// mandatory: return the layer descriptor
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
|
||||
// mandatory: will bind the datasource given params
|
||||
void bind() const;
|
||||
|
||||
private:
|
||||
// recommended - do intialization in a so-named init function
|
||||
// to reduce code in constructor
|
||||
void init(mapnik::parameters const& params);
|
||||
// recommended naming convention of datasource members:
|
||||
// name_, type_, extent_, and desc_
|
||||
static const std::string name_;
|
||||
mutable mapnik::layer_descriptor desc_;
|
||||
mutable mapnik::box2d<double> extent_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
mapnik::box2d<double> extent_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ public:
|
|||
|
||||
private:
|
||||
// members are up to you, but these are recommended
|
||||
mapnik::box2d<double> const& box_;
|
||||
mutable int feature_id_;
|
||||
mapnik::box2d<double> box_;
|
||||
mapnik::value_integer feature_id_;
|
||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||
mapnik::context_ptr ctx_;
|
||||
};
|
||||
|
|
66
src/build.py
66
src/build.py
|
@ -208,45 +208,6 @@ if env['HAS_CAIRO']:
|
|||
libmapnik_cxxflags.append('-DHAVE_CAIRO')
|
||||
lib_env.PrependUnique(CPPPATH=copy(env['CAIROMM_CPPPATHS']))
|
||||
source.insert(0,'cairo_renderer.cpp')
|
||||
#cairo_env.PrependUnique(CPPPATH=env['CAIROMM_CPPPATHS'])
|
||||
# not safe, to much depends on graphics.hpp
|
||||
#cairo_env = lib_env.Clone()
|
||||
#cairo_env.Append(CXXFLAGS = '-DHAVE_CAIRO')
|
||||
#fixup = ['feature_type_style.cpp','load_map.cpp','cairo_renderer.cpp','graphics.cpp','image_util.cpp']
|
||||
#for cpp in fixup:
|
||||
# if cpp in source:
|
||||
# source.remove(cpp)
|
||||
# if env['LINKING'] == 'static':
|
||||
# source.insert(0,cairo_env.StaticObject(cpp))
|
||||
# else:
|
||||
# source.insert(0,cairo_env.SharedObject(cpp))
|
||||
|
||||
|
||||
processor_cpp = 'feature_style_processor.cpp'
|
||||
|
||||
if env['RENDERING_STATS']:
|
||||
env3 = lib_env.Clone()
|
||||
env3.Append(CXXFLAGS='-DRENDERING_STATS')
|
||||
if env['LINKING'] == 'static':
|
||||
source.insert(0,env3.StaticObject(processor_cpp))
|
||||
else:
|
||||
source.insert(0,env3.SharedObject(processor_cpp))
|
||||
else:
|
||||
source.insert(0,processor_cpp);
|
||||
|
||||
if env.get('BOOST_LIB_VERSION_FROM_HEADER'):
|
||||
boost_version_from_header = int(env['BOOST_LIB_VERSION_FROM_HEADER'].split('_')[1])
|
||||
if boost_version_from_header < 46:
|
||||
# avoid ubuntu issue with boost interprocess:
|
||||
# https://github.com/mapnik/mapnik/issues/1001
|
||||
env4 = lib_env.Clone()
|
||||
env4.Append(CXXFLAGS = '-fpermissive')
|
||||
cpp ='mapped_memory_cache.cpp'
|
||||
source.remove(cpp)
|
||||
if env['LINKING'] == 'static':
|
||||
source.insert(0,env4.StaticObject(cpp))
|
||||
else:
|
||||
source.insert(0,env4.SharedObject(cpp))
|
||||
|
||||
if env['JPEG']:
|
||||
source += Split(
|
||||
|
@ -314,6 +275,21 @@ if env['SVG_RENDERER']: # svg backend
|
|||
lib_env.Append(CXXFLAGS = '-DSVG_RENDERER')
|
||||
libmapnik_cxxflags.append('-DSVG_RENDERER')
|
||||
|
||||
|
||||
if env.get('BOOST_LIB_VERSION_FROM_HEADER'):
|
||||
boost_version_from_header = int(env['BOOST_LIB_VERSION_FROM_HEADER'].split('_')[1])
|
||||
if boost_version_from_header < 46:
|
||||
# avoid ubuntu issue with boost interprocess:
|
||||
# https://github.com/mapnik/mapnik/issues/1001
|
||||
env4 = lib_env.Clone()
|
||||
env4.Append(CXXFLAGS = '-fpermissive')
|
||||
cpp ='mapped_memory_cache.cpp'
|
||||
source.remove(cpp)
|
||||
if env['LINKING'] == 'static':
|
||||
source.insert(0,env4.StaticObject(cpp))
|
||||
else:
|
||||
source.insert(0,env4.SharedObject(cpp))
|
||||
|
||||
if env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']:
|
||||
source += Split(
|
||||
"""
|
||||
|
@ -337,6 +313,18 @@ else:
|
|||
"""
|
||||
)
|
||||
|
||||
processor_cpp = 'feature_style_processor.cpp'
|
||||
|
||||
if env['RENDERING_STATS']:
|
||||
env3 = lib_env.Clone()
|
||||
env3.Append(CXXFLAGS='-DRENDERING_STATS')
|
||||
if env['LINKING'] == 'static':
|
||||
source.insert(0,env3.StaticObject(processor_cpp))
|
||||
else:
|
||||
source.insert(0,env3.SharedObject(processor_cpp))
|
||||
else:
|
||||
source.insert(0,processor_cpp);
|
||||
|
||||
if env['CUSTOM_LDFLAGS']:
|
||||
linkflags = '%s %s' % (env['CUSTOM_LDFLAGS'], mapnik_lib_link_flag)
|
||||
else:
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace mapnik { namespace util {
|
|||
using namespace boost::spirit;
|
||||
|
||||
BOOST_SPIRIT_AUTO(qi, INTEGER, qi::int_)
|
||||
BOOST_SPIRIT_AUTO(qi, LONGLONG, qi::long_long)
|
||||
BOOST_SPIRIT_AUTO(qi, FLOAT, qi::float_)
|
||||
BOOST_SPIRIT_AUTO(qi, DOUBLE, qi::double_)
|
||||
|
||||
|
@ -63,6 +64,27 @@ bool string2int(std::string const& value, int & result)
|
|||
return r && (str_beg == str_end);
|
||||
}
|
||||
|
||||
bool string2longlong(const char * value, boost::long_long_type & result)
|
||||
{
|
||||
size_t length = strlen(value);
|
||||
if (length < 1 || value == NULL)
|
||||
return false;
|
||||
const char *iter = value;
|
||||
const char *end = value + length;
|
||||
bool r = qi::phrase_parse(iter,end,LONGLONG,ascii::space,result);
|
||||
return r && (iter == end);
|
||||
}
|
||||
|
||||
bool string2longlong(std::string const& value, boost::long_long_type & result)
|
||||
{
|
||||
if (value.empty())
|
||||
return false;
|
||||
std::string::const_iterator str_beg = value.begin();
|
||||
std::string::const_iterator str_end = value.end();
|
||||
bool r = qi::phrase_parse(str_beg,str_end,LONGLONG,ascii::space,result);
|
||||
return r && (str_beg == str_end);
|
||||
}
|
||||
|
||||
bool string2double(std::string const& value, double & result)
|
||||
{
|
||||
if (value.empty())
|
||||
|
|
|
@ -55,7 +55,7 @@ datasource_cache::~datasource_cache()
|
|||
lt_dlexit();
|
||||
}
|
||||
|
||||
datasource_ptr datasource_cache::create(const parameters& params, bool bind)
|
||||
datasource_ptr datasource_cache::create(const parameters& params)
|
||||
{
|
||||
boost::optional<std::string> type = params.get<std::string>("type");
|
||||
if ( ! type)
|
||||
|
@ -114,7 +114,7 @@ datasource_ptr datasource_cache::create(const parameters& params, bool bind)
|
|||
}
|
||||
#endif
|
||||
|
||||
ds = datasource_ptr(create_datasource(params, bind), datasource_deleter());
|
||||
ds = datasource_ptr(create_datasource(params), datasource_deleter());
|
||||
|
||||
MAPNIK_LOG_DEBUG(datasource_cache) << "datasource_cache: Datasource=" << ds << " type=" << type;
|
||||
|
||||
|
|
|
@ -119,7 +119,6 @@ namespace mapnik { namespace util {
|
|||
feature_type_style style_out(style_in,true); // deep copy
|
||||
map_out.insert_style(kv.first, style_out);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}}
|
||||
}}
|
||||
|
|
|
@ -47,10 +47,10 @@ expr_node regex_replace_impl::operator() (T0 & node, T1 const& pattern, T2 const
|
|||
|
||||
template <typename Iterator>
|
||||
expression_grammar<Iterator>::expression_grammar(mapnik::transcoder const& tr)
|
||||
: expression_grammar::base_type(expr),
|
||||
unicode_(unicode_impl(tr)),
|
||||
regex_match_(regex_match_impl(tr)),
|
||||
regex_replace_(regex_replace_impl(tr))
|
||||
: expression_grammar::base_type(expr),
|
||||
unicode_(unicode_impl(tr)),
|
||||
regex_match_(regex_match_impl(tr)),
|
||||
regex_replace_(regex_replace_impl(tr))
|
||||
{
|
||||
using boost::phoenix::construct;
|
||||
using qi::_1;
|
||||
|
@ -63,12 +63,12 @@ expression_grammar<Iterator>::expression_grammar(mapnik::transcoder const& tr)
|
|||
using qi::lexeme;
|
||||
using qi::_val;
|
||||
using qi::lit;
|
||||
using qi::int_;
|
||||
using qi::double_;
|
||||
using qi::hex;
|
||||
using qi::omit;
|
||||
using standard_wide::char_;
|
||||
using standard_wide::no_case;
|
||||
|
||||
expr = logical_expr.alias();
|
||||
|
||||
logical_expr = not_expr [_val = _1]
|
||||
|
@ -138,7 +138,7 @@ expression_grammar<Iterator>::expression_grammar(mapnik::transcoder const& tr)
|
|||
;
|
||||
|
||||
primary_expr = strict_double [_val = _1]
|
||||
| int_ [_val = _1]
|
||||
| int__[_val = _1]
|
||||
| no_case[lit("true")] [_val = true]
|
||||
| no_case[lit("false")] [_val = false]
|
||||
| no_case[lit("null")] [_val = value_null() ]
|
||||
|
@ -171,4 +171,4 @@ expression_grammar<Iterator>::expression_grammar(mapnik::transcoder const& tr)
|
|||
|
||||
template struct mapnik::expression_grammar<std::string::const_iterator>;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,15 +49,13 @@ void feature_kv_iterator::advance(boost::iterator_difference<feature_kv_iterator
|
|||
|
||||
bool feature_kv_iterator::equal( feature_kv_iterator const& other) const
|
||||
{
|
||||
return ( itr_ == other.itr_);
|
||||
return ( itr_ == other.itr_ );
|
||||
}
|
||||
|
||||
feature_kv_iterator::value_type const& feature_kv_iterator::dereference() const
|
||||
{
|
||||
boost::get<0>(kv_) = itr_->first;
|
||||
boost::optional<mapnik::value const&> val = f_.get_optional(itr_->second);
|
||||
if (val) boost::get<1>(kv_) = *val;
|
||||
else boost::get<1>(kv_) = value_null();
|
||||
boost::get<1>(kv_) = f_.get(itr_->second);
|
||||
return kv_;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ void hit_grid<T>::clear()
|
|||
template <typename T>
|
||||
void hit_grid<T>::add_feature(mapnik::feature_impl & feature)
|
||||
{
|
||||
int feature_id = feature.id();
|
||||
value_type feature_id = feature.id();
|
||||
// avoid adding duplicate features (e.g. in the case of both a line symbolizer and a polygon symbolizer)
|
||||
typename feature_key_type::const_iterator feature_pos = f_keys_.find(feature_id);
|
||||
if (feature_pos != f_keys_.end())
|
||||
|
@ -138,6 +138,6 @@ void hit_grid<T>::add_feature(mapnik::feature_impl & feature)
|
|||
}
|
||||
|
||||
|
||||
template class hit_grid<int>;
|
||||
template class hit_grid<mapnik::value_integer>;
|
||||
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
// mapnik
|
||||
#include <mapnik/grid/grid_rasterizer.hpp>
|
||||
#include <mapnik/grid/grid_renderer.hpp>
|
||||
#include <mapnik/grid/grid_pixfmt.hpp>
|
||||
#include <mapnik/grid/grid_pixel.hpp>
|
||||
#include <mapnik/grid/grid_renderer_base.hpp>
|
||||
#include <mapnik/grid/grid.hpp>
|
||||
|
||||
#include <mapnik/debug.hpp>
|
||||
|
@ -130,15 +129,16 @@ void grid_renderer<T>::render_marker(mapnik::feature_impl & feature, unsigned in
|
|||
if (marker.is_vector())
|
||||
{
|
||||
typedef coord_transform<CoordTransform,geometry_type> path_type;
|
||||
typedef agg::renderer_base<mapnik::pixfmt_gray32> ren_base;
|
||||
typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
|
||||
typedef typename grid_renderer_base_type::pixfmt_type pixfmt_type;
|
||||
typedef typename grid_renderer_base_type::pixfmt_type::color_type color_type;
|
||||
typedef agg::renderer_scanline_bin_solid<grid_renderer_base_type> renderer_type;
|
||||
agg::scanline_bin sl;
|
||||
|
||||
grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_);
|
||||
mapnik::pixfmt_gray32 pixf(buf);
|
||||
pixfmt_type pixf(buf);
|
||||
|
||||
ren_base renb(pixf);
|
||||
renderer ren(renb);
|
||||
grid_renderer_base_type renb(pixf);
|
||||
renderer_type ren(renb);
|
||||
|
||||
ras_ptr->reset();
|
||||
|
||||
|
@ -156,8 +156,8 @@ void grid_renderer<T>::render_marker(mapnik::feature_impl & feature, unsigned in
|
|||
svg_path_adapter svg_path(stl_storage);
|
||||
svg_renderer_agg<svg_path_adapter,
|
||||
agg::pod_bvector<path_attributes>,
|
||||
renderer,
|
||||
mapnik::pixfmt_gray32> svg_renderer(svg_path,
|
||||
renderer_type,
|
||||
pixfmt_type> svg_renderer(svg_path,
|
||||
(*marker.get_vector_data())->attributes());
|
||||
|
||||
svg_renderer.render_id(*ras_ptr, sl, renb, feature.id(), mtx, opacity, bbox);
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
// mapnik
|
||||
#include <mapnik/grid/grid_rasterizer.hpp>
|
||||
#include <mapnik/grid/grid_renderer.hpp>
|
||||
#include <mapnik/grid/grid_pixfmt.hpp>
|
||||
#include <mapnik/grid/grid_pixel.hpp>
|
||||
#include <mapnik/grid/grid_renderer_base.hpp>
|
||||
#include <mapnik/grid/grid.hpp>
|
||||
#include <mapnik/segment.hpp>
|
||||
#include <mapnik/expression_evaluator.hpp>
|
||||
|
@ -49,16 +48,17 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
|
|||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef typename grid_renderer_base_type::pixfmt_type pixfmt_type;
|
||||
typedef typename grid_renderer_base_type::pixfmt_type::color_type color_type;
|
||||
typedef agg::renderer_scanline_bin_solid<grid_renderer_base_type> renderer_type;
|
||||
typedef coord_transform<CoordTransform,geometry_type> path_type;
|
||||
typedef agg::renderer_base<mapnik::pixfmt_gray32> ren_base;
|
||||
typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
|
||||
agg::scanline_bin sl;
|
||||
|
||||
grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_);
|
||||
mapnik::pixfmt_gray32 pixf(buf);
|
||||
pixfmt_type pixf(buf);
|
||||
|
||||
ren_base renb(pixf);
|
||||
renderer ren(renb);
|
||||
grid_renderer_base_type renb(pixf);
|
||||
renderer_type ren(renb);
|
||||
|
||||
ras_ptr->reset();
|
||||
|
||||
|
@ -111,7 +111,7 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
|
|||
|
||||
path_type faces_path (t_,*faces,prj_trans);
|
||||
ras_ptr->add_path(faces_path);
|
||||
ren.color(mapnik::gray32(feature.id()));
|
||||
ren.color(color_type(feature.id()));
|
||||
agg::render_scanlines(*ras_ptr, sl, ren);
|
||||
ras_ptr->reset();
|
||||
|
||||
|
@ -138,13 +138,13 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
|
|||
path_type path(t_,*frame,prj_trans);
|
||||
agg::conv_stroke<path_type> stroke(path);
|
||||
ras_ptr->add_path(stroke);
|
||||
ren.color(mapnik::gray32(feature.id()));
|
||||
ren.color(color_type(feature.id()));
|
||||
agg::render_scanlines(*ras_ptr, sl, ren);
|
||||
ras_ptr->reset();
|
||||
|
||||
path_type roof_path (t_,*roof,prj_trans);
|
||||
ras_ptr->add_path(roof_path);
|
||||
ren.color(mapnik::gray32(feature.id()));
|
||||
ren.color(color_type(feature.id()));
|
||||
agg::render_scanlines(*ras_ptr, sl, ren);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
// mapnik
|
||||
#include <mapnik/grid/grid_rasterizer.hpp>
|
||||
#include <mapnik/grid/grid_renderer.hpp>
|
||||
#include <mapnik/grid/grid_pixfmt.hpp>
|
||||
#include <mapnik/grid/grid_pixel.hpp>
|
||||
#include <mapnik/grid/grid_renderer_base.hpp>
|
||||
#include <mapnik/grid/grid.hpp>
|
||||
#include <mapnik/line_pattern_symbolizer.hpp>
|
||||
|
||||
|
@ -46,15 +45,16 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
|
|||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef coord_transform<CoordTransform,geometry_type> path_type;
|
||||
typedef agg::renderer_base<mapnik::pixfmt_gray32> ren_base;
|
||||
typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
|
||||
typedef typename grid_renderer_base_type::pixfmt_type pixfmt_type;
|
||||
typedef typename grid_renderer_base_type::pixfmt_type::color_type color_type;
|
||||
typedef agg::renderer_scanline_bin_solid<grid_renderer_base_type> renderer_type;
|
||||
agg::scanline_bin sl;
|
||||
|
||||
grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_);
|
||||
mapnik::pixfmt_gray32 pixf(buf);
|
||||
pixfmt_type pixf(buf);
|
||||
|
||||
ren_base renb(pixf);
|
||||
renderer ren(renb);
|
||||
grid_renderer_base_type renb(pixf);
|
||||
renderer_type ren(renb);
|
||||
|
||||
ras_ptr->reset();
|
||||
|
||||
|
@ -75,7 +75,7 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
|
|||
}
|
||||
|
||||
// render id
|
||||
ren.color(mapnik::gray32(feature.id()));
|
||||
ren.color(color_type(feature.id()));
|
||||
agg::render_scanlines(*ras_ptr, sl, ren);
|
||||
|
||||
// add feature properties to grid cache
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
// mapnik
|
||||
#include <mapnik/grid/grid_rasterizer.hpp>
|
||||
#include <mapnik/grid/grid_renderer.hpp>
|
||||
#include <mapnik/grid/grid_pixfmt.hpp>
|
||||
#include <mapnik/grid/grid_pixel.hpp>
|
||||
#include <mapnik/grid/grid_renderer_base.hpp>
|
||||
#include <mapnik/grid/grid.hpp>
|
||||
|
||||
#include <mapnik/line_symbolizer.hpp>
|
||||
|
@ -50,17 +49,18 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
|
|||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef agg::renderer_base<mapnik::pixfmt_gray32> renderer_base;
|
||||
typedef agg::renderer_scanline_bin_solid<renderer_base> renderer_type;
|
||||
typedef typename grid_renderer_base_type::pixfmt_type pixfmt_type;
|
||||
typedef typename grid_renderer_base_type::pixfmt_type::color_type color_type;
|
||||
typedef agg::renderer_scanline_bin_solid<grid_renderer_base_type> renderer_type;
|
||||
typedef boost::mpl::vector<clip_line_tag, transform_tag,
|
||||
offset_transform_tag, affine_transform_tag,
|
||||
simplify_tag, smooth_tag, dash_tag, stroke_tag> conv_types;
|
||||
agg::scanline_bin sl;
|
||||
|
||||
grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_);
|
||||
mapnik::pixfmt_gray32 pixf(buf);
|
||||
pixfmt_type pixf(buf);
|
||||
|
||||
renderer_base renb(pixf);
|
||||
grid_renderer_base_type renb(pixf);
|
||||
renderer_type ren(renb);
|
||||
|
||||
ras_ptr->reset();
|
||||
|
@ -103,7 +103,7 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
|
|||
}
|
||||
|
||||
// render id
|
||||
ren.color(mapnik::gray32(feature.id()));
|
||||
ren.color(color_type(feature.id()));
|
||||
agg::render_scanlines(*ras_ptr, sl, ren);
|
||||
|
||||
// add feature properties to grid cache
|
||||
|
|
|
@ -28,7 +28,6 @@ porting notes -->
|
|||
- current_buffer_ -> pixmap_
|
||||
- agg::rendering_buffer -> grid_renderering_buffer
|
||||
- no gamma
|
||||
- mapnik::pixfmt_gray32
|
||||
- agg::scanline_bin sl
|
||||
- grid_rendering_buffer
|
||||
- agg::renderer_scanline_bin_solid
|
||||
|
@ -45,8 +44,7 @@ porting notes -->
|
|||
// mapnik
|
||||
#include <mapnik/grid/grid_rasterizer.hpp>
|
||||
#include <mapnik/grid/grid_renderer.hpp>
|
||||
#include <mapnik/grid/grid_pixfmt.hpp>
|
||||
#include <mapnik/grid/grid_pixel.hpp>
|
||||
#include <mapnik/grid/grid_renderer_base.hpp>
|
||||
#include <mapnik/grid/grid.hpp>
|
||||
#include <mapnik/grid/grid_marker_helpers.hpp>
|
||||
|
||||
|
@ -84,9 +82,9 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
|
|||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef grid_rendering_buffer buf_type;
|
||||
typedef mapnik::pixfmt_gray32 pixfmt_type;
|
||||
typedef agg::renderer_base<pixfmt_type> renderer_base;
|
||||
typedef agg::renderer_scanline_bin_solid<renderer_base> renderer_type;
|
||||
typedef typename grid_renderer_base_type::pixfmt_type pixfmt_type;
|
||||
typedef typename grid_renderer_base_type::pixfmt_type::color_type color_type;
|
||||
typedef agg::renderer_scanline_bin_solid<grid_renderer_base_type> renderer_type;
|
||||
typedef label_collision_detector4 detector_type;
|
||||
typedef boost::mpl::vector<clip_line_tag,clip_poly_tag,transform_tag,smooth_tag> conv_types;
|
||||
|
||||
|
@ -221,7 +219,7 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
|
|||
typedef raster_markers_rasterizer_dispatch_grid<buf_type,
|
||||
grid_rasterizer,
|
||||
pixfmt_type,
|
||||
renderer_base,
|
||||
grid_renderer_base_type,
|
||||
renderer_type,
|
||||
detector_type,
|
||||
mapnik::grid > dispatch_type;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue