diff --git a/plugins/input/occi/occi_datasource.cpp b/plugins/input/occi/occi_datasource.cpp index 483cf4ea9..d8a2fd11b 100644 --- a/plugins/input/occi/occi_datasource.cpp +++ b/plugins/input/occi/occi_datasource.cpp @@ -26,6 +26,7 @@ // mapnik #include +#include // boost #include @@ -68,29 +69,6 @@ using oracle::occi::StatelessConnectionPool; 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) : datasource (params), table_(*params_.get("table","")), @@ -171,7 +149,7 @@ void occi_datasource::bind() const 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 { diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index 546a0354a..9e95c8842 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -26,6 +26,7 @@ // mapnik #include +#include // boost #include @@ -53,29 +54,6 @@ using mapnik::attribute_descriptor; 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) : datasource(params), 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_) {