Skip to content

Commit

Permalink
Merge pull request #1179 from strk/master-pgis_vector_reduction
Browse files Browse the repository at this point in the history
PostGIS vectors reduction, XML parameter driven (#1136)
  • Loading branch information
Dane Springmeyer committed Apr 19, 2012
2 parents 61d3cf6 + f7c5e69 commit cfc0866
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion plugins/input/postgis/postgis_datasource.cpp
Expand Up @@ -606,8 +606,29 @@ featureset_ptr postgis_datasource::features(const query& q) const
throw mapnik::datasource_exception(s_error.str()); throw mapnik::datasource_exception(s_error.str());
} }


boost::optional<mapnik::boolean> simplify_opt =
params_.get<mapnik::boolean>("simplify", false);

bool simplify = simplify_opt && *simplify_opt;

std::ostringstream s; std::ostringstream s;
s << "SELECT ST_AsBinary(\"" << geometryColumn_ << "\") AS geom"; s << "SELECT ST_AsBinary(";

if (simplify) {
s << "ST_Simplify(";
}

s << "\"" << geometryColumn_ << "\"";

if (simplify) {
double px_gw = 1.0/boost::get<0>(q.resolution());
double px_gh = 1.0/boost::get<1>(q.resolution());

double tolerance = std::min(px_gw,px_gh) / 2;
s << ", " << tolerance << ")";
}

s << ") AS geom";


mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>(); mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
std::set<std::string> const& props = q.property_names(); std::set<std::string> const& props = q.property_names();
Expand Down

0 comments on commit cfc0866

Please sign in to comment.