- allow occi to compile with new changes in mapnik::sql_utils
- cache table_from_sql instead of recomputing on each query
This commit is contained in:
parent
25b14c3503
commit
1251a57e4e
2 changed files with 15 additions and 17 deletions
|
@ -179,14 +179,15 @@ void occi_datasource::bind() const
|
|||
}
|
||||
}
|
||||
|
||||
std::string table_name = mapnik::table_from_sql(table_);
|
||||
// extract real table name
|
||||
table_name_ = mapnik::sql_utils::table_from_sql(table_);
|
||||
|
||||
// get SRID and/or GEOMETRY_FIELD from metadata table only if we need to
|
||||
if (! srid_initialized_ || geometry_field_ == "")
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << "SELECT srid, column_name FROM " << METADATA_TABLE << " WHERE";
|
||||
s << " LOWER(table_name) = LOWER('" << table_name << "')";
|
||||
s << " LOWER(table_name) = LOWER('" << table_name_ << "')";
|
||||
|
||||
if (geometry_field_ != "")
|
||||
{
|
||||
|
@ -227,7 +228,7 @@ void occi_datasource::bind() const
|
|||
// get columns description
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << "SELECT " << fields_ << " FROM (" << table_name << ") WHERE rownum < 1";
|
||||
s << "SELECT " << fields_ << " FROM (" << table_name_ << ") WHERE rownum < 1";
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "OCCI Plugin: " << s.str() << std::endl;
|
||||
|
@ -408,16 +409,14 @@ box2d<double> occi_datasource::envelope() const
|
|||
}
|
||||
else if (use_spatial_index_)
|
||||
{
|
||||
std::string table_name = mapnik::table_from_sql(table_);
|
||||
|
||||
std::ostringstream s;
|
||||
s << "SELECT dim.sdo_lb, dim.sdo_ub FROM ";
|
||||
s << METADATA_TABLE << " m, TABLE(m.diminfo) dim ";
|
||||
s << " WHERE LOWER(m.table_name) = LOWER('" << table_name << "') AND dim.sdo_dimname = 'X'";
|
||||
s << " WHERE LOWER(m.table_name) = LOWER('" << table_name_ << "') AND dim.sdo_dimname = 'X'";
|
||||
s << " UNION ";
|
||||
s << "SELECT dim.sdo_lb, dim.sdo_ub FROM ";
|
||||
s << METADATA_TABLE << " m, TABLE(m.diminfo) dim ";
|
||||
s << " WHERE LOWER(m.table_name) = LOWER('" << table_name << "') AND dim.sdo_dimname = 'Y'";
|
||||
s << " WHERE LOWER(m.table_name) = LOWER('" << table_name_ << "') AND dim.sdo_dimname = 'Y'";
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "OCCI Plugin: " << s.str() << std::endl;
|
||||
|
@ -503,7 +502,6 @@ featureset_ptr occi_datasource::features(query const& q) const
|
|||
s << " FROM ";
|
||||
|
||||
std::string query(table_);
|
||||
std::string table_name = mapnik::table_from_sql(query);
|
||||
|
||||
if (use_spatial_index_)
|
||||
{
|
||||
|
@ -520,9 +518,9 @@ featureset_ptr occi_datasource::features(query const& q) const
|
|||
{
|
||||
boost::algorithm::ireplace_first(query, "WHERE", spatial_sql.str() + " AND ");
|
||||
}
|
||||
else if (boost::algorithm::ifind_first(query, table_name))
|
||||
else if (boost::algorithm::ifind_first(query, table_name_))
|
||||
{
|
||||
boost::algorithm::ireplace_first(query, table_name, table_name + " " + spatial_sql.str());
|
||||
boost::algorithm::ireplace_first(query, table_name_, table_name_ + " " + spatial_sql.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -540,9 +538,9 @@ featureset_ptr occi_datasource::features(query const& q) const
|
|||
{
|
||||
boost::algorithm::ireplace_first(query, "WHERE", row_limit_string + " AND ");
|
||||
}
|
||||
else if (boost::algorithm::ifind_first(query, table_name))
|
||||
else if (boost::algorithm::ifind_first(query, table_name_))
|
||||
{
|
||||
boost::algorithm::ireplace_first(query, table_name, table_name + " " + row_limit_string);
|
||||
boost::algorithm::ireplace_first(query, table_name_, table_name_ + " " + row_limit_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -587,7 +585,6 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
|||
s << " FROM ";
|
||||
|
||||
std::string query(table_);
|
||||
std::string table_name = mapnik::table_from_sql(query);
|
||||
|
||||
if (use_spatial_index_)
|
||||
{
|
||||
|
@ -603,9 +600,9 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
|||
{
|
||||
boost::algorithm::ireplace_first(query, "WHERE", spatial_sql.str() + " AND ");
|
||||
}
|
||||
else if (boost::algorithm::ifind_first(query, table_name))
|
||||
else if (boost::algorithm::ifind_first(query, table_name_))
|
||||
{
|
||||
boost::algorithm::ireplace_first(query, table_name, table_name + " " + spatial_sql.str());
|
||||
boost::algorithm::ireplace_first(query, table_name_, table_name_ + " " + spatial_sql.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -623,9 +620,9 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
|||
{
|
||||
boost::algorithm::ireplace_first(query, "WHERE", row_limit_string + " AND ");
|
||||
}
|
||||
else if (boost::algorithm::ifind_first(query, table_name))
|
||||
else if (boost::algorithm::ifind_first(query, table_name_))
|
||||
{
|
||||
boost::algorithm::ireplace_first(query, table_name, table_name + " " + row_limit_string);
|
||||
boost::algorithm::ireplace_first(query, table_name_, table_name_ + " " + row_limit_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
private:
|
||||
int type_;
|
||||
mutable std::string table_;
|
||||
mutable std::string table_name_;
|
||||
mutable std::string fields_;
|
||||
mutable std::string geometry_field_;
|
||||
mutable int srid_;
|
||||
|
|
Loading…
Reference in a new issue