add twkb support to sqlite plugin
This commit is contained in:
parent
7bd317a1bf
commit
9de7397043
4 changed files with 21 additions and 3 deletions
|
@ -68,7 +68,8 @@ sqlite_datasource::sqlite_datasource(parameters const& params)
|
||||||
row_limit_(*params.get<mapnik::value_integer>("row_limit", 0)),
|
row_limit_(*params.get<mapnik::value_integer>("row_limit", 0)),
|
||||||
intersects_token_("!intersects!"),
|
intersects_token_("!intersects!"),
|
||||||
desc_(sqlite_datasource::name(), *params.get<std::string>("encoding", "utf-8")),
|
desc_(sqlite_datasource::name(), *params.get<std::string>("encoding", "utf-8")),
|
||||||
format_(mapnik::wkbAuto)
|
format_(mapnik::wkbAuto),
|
||||||
|
twkb_encoding_(false)
|
||||||
{
|
{
|
||||||
/* TODO
|
/* TODO
|
||||||
- throw if no primary key but spatial index is present?
|
- throw if no primary key but spatial index is present?
|
||||||
|
@ -113,6 +114,11 @@ sqlite_datasource::sqlite_datasource(parameters const& params)
|
||||||
{
|
{
|
||||||
format_ = mapnik::wkbGeneric;
|
format_ = mapnik::wkbGeneric;
|
||||||
}
|
}
|
||||||
|
else if (*wkb == "twkb")
|
||||||
|
{
|
||||||
|
format_ = mapnik::wkbGeneric;
|
||||||
|
twkb_encoding_ = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
format_ = mapnik::wkbAuto;
|
format_ = mapnik::wkbAuto;
|
||||||
|
@ -448,7 +454,10 @@ boost::optional<mapnik::datasource_geometry_t> sqlite_datasource::get_geometry_t
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
|
|
||||||
mapnik::geometry::geometry<double> geom = mapnik::geometry_utils::from_wkb(data, size, format_);
|
mapnik::geometry::geometry<double> geom;
|
||||||
|
|
||||||
|
if (twkb_encoding_) geom = mapnik::geometry_utils::from_twkb(data, size);
|
||||||
|
else geom = mapnik::geometry_utils::from_wkb(data, size, format_);
|
||||||
if (mapnik::geometry::is_empty(geom))
|
if (mapnik::geometry::is_empty(geom))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -547,6 +556,7 @@ featureset_ptr sqlite_datasource::features(query const& q) const
|
||||||
desc_.get_encoding(),
|
desc_.get_encoding(),
|
||||||
e,
|
e,
|
||||||
format_,
|
format_,
|
||||||
|
twkb_encoding_,
|
||||||
has_spatial_index_,
|
has_spatial_index_,
|
||||||
using_subquery_);
|
using_subquery_);
|
||||||
}
|
}
|
||||||
|
@ -627,6 +637,7 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double to
|
||||||
desc_.get_encoding(),
|
desc_.get_encoding(),
|
||||||
e,
|
e,
|
||||||
format_,
|
format_,
|
||||||
|
twkb_encoding_,
|
||||||
has_spatial_index_,
|
has_spatial_index_,
|
||||||
using_subquery_);
|
using_subquery_);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,7 @@ private:
|
||||||
const std::string intersects_token_;
|
const std::string intersects_token_;
|
||||||
mapnik::layer_descriptor desc_;
|
mapnik::layer_descriptor desc_;
|
||||||
mapnik::wkbFormat format_;
|
mapnik::wkbFormat format_;
|
||||||
|
bool twkb_encoding_;
|
||||||
bool use_spatial_index_;
|
bool use_spatial_index_;
|
||||||
bool has_spatial_index_;
|
bool has_spatial_index_;
|
||||||
bool using_subquery_;
|
bool using_subquery_;
|
||||||
|
|
|
@ -49,6 +49,7 @@ sqlite_featureset::sqlite_featureset(std::shared_ptr<sqlite_resultset> rs,
|
||||||
std::string const& encoding,
|
std::string const& encoding,
|
||||||
mapnik::box2d<double> const& bbox,
|
mapnik::box2d<double> const& bbox,
|
||||||
mapnik::wkbFormat format,
|
mapnik::wkbFormat format,
|
||||||
|
bool twkb_encoding,
|
||||||
bool spatial_index,
|
bool spatial_index,
|
||||||
bool using_subquery)
|
bool using_subquery)
|
||||||
: rs_(rs),
|
: rs_(rs),
|
||||||
|
@ -56,6 +57,7 @@ sqlite_featureset::sqlite_featureset(std::shared_ptr<sqlite_resultset> rs,
|
||||||
tr_(new transcoder(encoding)),
|
tr_(new transcoder(encoding)),
|
||||||
bbox_(bbox),
|
bbox_(bbox),
|
||||||
format_(format),
|
format_(format),
|
||||||
|
twkb_encoding_(twkb_encoding),
|
||||||
spatial_index_(spatial_index),
|
spatial_index_(spatial_index),
|
||||||
using_subquery_(using_subquery)
|
using_subquery_(using_subquery)
|
||||||
{}
|
{}
|
||||||
|
@ -81,7 +83,9 @@ feature_ptr sqlite_featureset::next()
|
||||||
}
|
}
|
||||||
|
|
||||||
feature_ptr feature = feature_factory::create(ctx_,rs_->column_integer64(1));
|
feature_ptr feature = feature_factory::create(ctx_,rs_->column_integer64(1));
|
||||||
mapnik::geometry::geometry<double> geom = geometry_utils::from_wkb(data, size, format_);
|
mapnik::geometry::geometry<double> geom;
|
||||||
|
if (twkb_encoding_) geom = geometry_utils::from_twkb(data, size);
|
||||||
|
else geom = geometry_utils::from_wkb(data, size, format_);
|
||||||
if (mapnik::geometry::is_empty(geom))
|
if (mapnik::geometry::is_empty(geom))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
std::string const& encoding,
|
std::string const& encoding,
|
||||||
mapnik::box2d<double> const& bbox,
|
mapnik::box2d<double> const& bbox,
|
||||||
mapnik::wkbFormat format,
|
mapnik::wkbFormat format,
|
||||||
|
bool twkb_encoding,
|
||||||
bool spatial_index,
|
bool spatial_index,
|
||||||
bool using_subquery);
|
bool using_subquery);
|
||||||
virtual ~sqlite_featureset();
|
virtual ~sqlite_featureset();
|
||||||
|
@ -55,6 +56,7 @@ private:
|
||||||
const std::unique_ptr<mapnik::transcoder> tr_;
|
const std::unique_ptr<mapnik::transcoder> tr_;
|
||||||
mapnik::box2d<double> bbox_;
|
mapnik::box2d<double> bbox_;
|
||||||
mapnik::wkbFormat format_;
|
mapnik::wkbFormat format_;
|
||||||
|
bool twkb_encoding_;
|
||||||
bool spatial_index_;
|
bool spatial_index_;
|
||||||
bool using_subquery_;
|
bool using_subquery_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue