From f76d94cec9a8e6e1e7dd579e62f417df9f285374 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sat, 5 Mar 2011 18:01:05 +0000 Subject: [PATCH] fix up postgis error message formatting when no schema is used --- plugins/input/postgis/postgis.cpp | 40 ++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/plugins/input/postgis/postgis.cpp b/plugins/input/postgis/postgis.cpp index 4f8ee1820..b39d6d18a 100644 --- a/plugins/input/postgis/postgis.cpp +++ b/plugins/input/postgis/postgis.cpp @@ -435,9 +435,19 @@ featureset_ptr postgis_datasource::features(const query& q) const if (!geometryColumn_.length() > 0) { std::ostringstream s_error; - s_error << "PostGIS: geometry name lookup failed for table '" << schema_ << "." << geometry_table_ + s_error << "PostGIS: geometry name lookup failed for table '"; + if (!schema_.length() > 0) + { + s_error << schema_ << "."; + } + s_error << geometry_table_ << "'. Please manually provide the 'geometry_field' parameter or add an entry " - << "in the geometry_columns for '" << schema_ << "." << geometry_table_ << "'."; + << "in the geometry_columns for '"; + if (!schema_.length() > 0) + { + s_error << schema_ << "."; + } + s_error << "." << geometry_table_ << "'."; throw mapnik::datasource_exception("Postgis Plugin: " + s_error.str()); } @@ -495,9 +505,19 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt) const if (!geometryColumn_.length() > 0) { std::ostringstream s_error; - s_error << "PostGIS: geometry name lookup failed for table '" << schema_ << "." << geometry_table_ + s_error << "PostGIS: geometry name lookup failed for table '"; + if (!schema_.length() > 0) + { + s_error << schema_ << "."; + } + s_error << "." << geometry_table_ << "'. Please manually provide the 'geometry_field' parameter or add an entry " - << "in the geometry_columns for '" << schema_ << "." << geometry_table_ << "'."; + << "in the geometry_columns for '"; + if (!schema_.length() > 0) + { + s_error << schema_ << "."; + } + s_error << geometry_table_ << "'."; throw mapnik::datasource_exception(s_error.str()); } @@ -555,10 +575,14 @@ box2d postgis_datasource::envelope() const if (!geometryColumn_.length() > 0) { std::ostringstream s_error; - s_error << "PostGIS: unable to query the layer extent of table '" - << schema_ << "." << geometry_table_ << "' because we cannot determine the geometry field name." - << "\nPlease provide either 1) an 'extent' parameter to skip this query, " - << "2) a 'geometry_field' and/or 'geometry_table' parameter, or 3) add a " + s_error << "PostGIS: unable to query the layer extent of table '"; + if (!schema_.length() > 0) + { + s_error << schema_ << "."; + } + s_error << geometry_table_ << "' because we cannot determine the geometry field name." + << "\nPlease provide either an 'extent' parameter to skip this query, " + << "a 'geometry_field' and/or 'geometry_table' parameter, or add a " << "record to the 'geometry_columns' for your table."; throw mapnik::datasource_exception("Postgis Plugin: " + s_error.str()); }