+ use mapnik::table_from_sql in sqlite and occi plugins (after change r2337 thanx to dane)

This commit is contained in:
Lucio Asnaghi 2010-11-12 00:12:47 +00:00
parent 385ad05205
commit 07f455ebaa
2 changed files with 4 additions and 48 deletions

View file

@ -26,6 +26,7 @@
// mapnik // mapnik
#include <mapnik/ptree_helpers.hpp> #include <mapnik/ptree_helpers.hpp>
#include <mapnik/sql_utils.hpp>
// boost // boost
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
@ -68,29 +69,6 @@ using oracle::occi::StatelessConnectionPool;
DATASOURCE_PLUGIN(occi_datasource) DATASOURCE_PLUGIN(occi_datasource)
std::string table_from_sql(std::string const& sql)
{
std::string table_name = boost::algorithm::to_lower_copy(sql);
boost::algorithm::replace_all(table_name,"\n"," ");
std::string::size_type idx = table_name.rfind("from");
if (idx!=std::string::npos)
{
idx=table_name.find_first_not_of(" ",idx+4);
if (idx != std::string::npos)
{
table_name=table_name.substr(idx);
}
idx=table_name.find_first_of(" ),");
if (idx != std::string::npos)
{
table_name = table_name.substr(0,idx);
}
}
return table_name;
}
occi_datasource::occi_datasource(parameters const& params, bool bind) occi_datasource::occi_datasource(parameters const& params, bool bind)
: datasource (params), : datasource (params),
table_(*params_.get<std::string>("table","")), table_(*params_.get<std::string>("table","")),
@ -171,7 +149,7 @@ void occi_datasource::bind() const
throw datasource_exception(ex.getMessage()); throw datasource_exception(ex.getMessage());
} }
std::string table_name = table_from_sql(table_); std::string table_name = mapnik::table_from_sql(table_);
// get SRID from geometry metadata // get SRID from geometry metadata
{ {

View file

@ -26,6 +26,7 @@
// mapnik // mapnik
#include <mapnik/ptree_helpers.hpp> #include <mapnik/ptree_helpers.hpp>
#include <mapnik/sql_utils.hpp>
// boost // boost
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
@ -53,29 +54,6 @@ using mapnik::attribute_descriptor;
using mapnik::datasource_exception; using mapnik::datasource_exception;
std::string table_from_sql(std::string const& sql)
{
std::string table_name = boost::algorithm::to_lower_copy(sql);
boost::algorithm::replace_all(table_name,"\n"," ");
std::string::size_type idx = table_name.rfind("from");
if (idx!=std::string::npos)
{
idx=table_name.find_first_not_of(" ",idx+4);
if (idx != std::string::npos)
{
table_name=table_name.substr(idx);
}
idx=table_name.find_first_of(" ),");
if (idx != std::string::npos)
{
table_name = table_name.substr(0,idx);
}
}
return table_name;
}
sqlite_datasource::sqlite_datasource(parameters const& params, bool bind) sqlite_datasource::sqlite_datasource(parameters const& params, bool bind)
: datasource(params), : datasource(params),
extent_(), extent_(),
@ -158,7 +136,7 @@ void sqlite_datasource::bind() const
} }
} }
std::string table_name = table_from_sql(table_); std::string table_name = mapnik::table_from_sql(table_);
if (metadata_ != "" && ! extent_initialized_) if (metadata_ != "" && ! extent_initialized_)
{ {