From b1070d22c82cc8dc295d6ce2af0d0d65facb2572 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 17 Mar 2010 22:03:39 +0000 Subject: [PATCH] postgis/oracle: use mapnik::boolean type for 'estimate_extent' rather than std::string, and strip double quotes as the estimated_extent function operates on single quotes - improves upon #393 --- plugins/input/occi/occi_datasource.cpp | 4 ++-- plugins/input/postgis/postgis.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/input/occi/occi_datasource.cpp b/plugins/input/occi/occi_datasource.cpp index 42098f199..516655012 100644 --- a/plugins/input/occi/occi_datasource.cpp +++ b/plugins/input/occi/occi_datasource.cpp @@ -297,9 +297,9 @@ box2d occi_datasource::envelope() const double lox, loy, hix, hiy; occi_connection_ptr conn (pool_); - boost::optional estimate_extent = params_.get("estimate_extent"); + boost::optional estimate_extent = params_.get("estimate_extent",false); - if (estimate_extent && *estimate_extent == "true") + if (estimate_extent && *estimate_extent) { std::ostringstream s; s << "select min(c.x), min(c.y), max(c.x), max(c.y) from "; diff --git a/plugins/input/postgis/postgis.cpp b/plugins/input/postgis/postgis.cpp index 3355a81a1..e2203f130 100644 --- a/plugins/input/postgis/postgis.cpp +++ b/plugins/input/postgis/postgis.cpp @@ -556,7 +556,7 @@ box2d postgis_datasource::envelope() const { PoolGuard,shared_ptr > > guard(conn,pool); std::ostringstream s; - boost::optional estimate_extent = params_.get("estimate_extent"); + boost::optional estimate_extent = params_.get("estimate_extent",false); if (!geometryColumn_.length() > 0) { @@ -569,18 +569,18 @@ box2d postgis_datasource::envelope() const throw mapnik::datasource_exception(s_error.str()); } - if (estimate_extent && *estimate_extent == "true") + if (estimate_extent && *estimate_extent) { s << "select xmin(ext),ymin(ext),xmax(ext),ymax(ext)" << " from (select estimated_extent('"; if (schema_.length() > 0) { - s << schema_ << "','"; + s << unquote(schema_) << "','"; } - s << geometry_table_ << "','" - << geometryColumn_ << "') as ext) as tmp"; + s << unquote(geometry_table_) << "','" + << unquote(geometryColumn_) << "') as ext) as tmp"; } else { @@ -609,7 +609,7 @@ box2d postgis_datasource::envelope() const { clog << boost::format("PostGIS: sending query: %s\n") % s.str(); }*/ - + shared_ptr rs=conn->executeQuery(s.str()); if (rs->next()) {