+ remove -simplify,s option as it can be specified in input query e.g

"select simplify(the_geom,300) as the_geom from world"
+ fixed table_from_sql to handle multiple table_names
This commit is contained in:
Artem Pavlenko 2009-02-22 22:34:31 +00:00
parent 4868eb805e
commit db1e445370
2 changed files with 7 additions and 18 deletions

View file

@ -59,7 +59,6 @@ int main ( int argc, char** argv)
("password,P",po::value<std::string>(),"Connect to the database with the specified password.")
("query,q",po::value<std::string>(),"Name of the table/or query to pass to postmaster")
("table,t",po::value<std::string>(),"Name of the table to create")
("simplify,s",po::value<unsigned>(),"Use this option to reduce the complexity\nand weight of a geometry using the Douglas-Peucker algorithm.")
("file,f",po::value<std::string>(),"Use this option to specify the name of the file to create.")
;
@ -97,8 +96,6 @@ int main ( int argc, char** argv)
if (vm.count("dbname")) dbname = vm["dbname"].as<std::string>();
if (vm.count("user")) user = vm["user"].as<std::string>();
if (vm.count("password")) password = vm["password"].as<std::string>();
unsigned tolerance = 0;
if (vm.count("simplify")) tolerance = vm["simplify"].as<unsigned>();
ConnectionCreator<Connection> creator(host,port,dbname,user,password);
try
@ -109,7 +106,9 @@ int main ( int argc, char** argv)
std::string output_table_name = vm.count("table") ? vm["table"].as<std::string>() : mapnik::table_from_sql(query);
std::string output_file = vm["file"].as<std::string>();
mapnik::pgsql2sqlite(conn,query,output_table_name,output_file,tolerance);
std::cout << "output_table : " << output_table_name << "\n";
mapnik::pgsql2sqlite(conn,query,output_table_name,output_file);
}
catch (mapnik::datasource_exception & ex)
{

View file

@ -82,7 +82,7 @@ namespace mapnik {
{
table_name=table_name.substr(idx);
}
idx=table_name.find_first_of(" )");
idx=table_name.find_first_of(" ),");
if (idx != std::string::npos)
{
table_name = table_name.substr(0,idx);
@ -96,8 +96,7 @@ namespace mapnik {
void pgsql2sqlite(Connection conn,
std::string const& query,
std::string const& output_table_name,
std::string const& output_filename ,
unsigned tolerance)
std::string const& output_filename)
{
namespace sqlite = mapnik::sqlite;
sqlite::database db(output_filename);
@ -145,21 +144,12 @@ namespace mapnik {
// add AsBinary(<geometry_column>) modifier
std::string select_sql_str = select_sql.str();
if (tolerance > 0)
{
std::string from = "\"" + geom_col + "\"";
std::string to = (boost::format("AsBinary(Simplify(%1%,%2%)) as %1%") % geom_col % tolerance).str();
boost::algorithm::replace_all(select_sql_str,from ,to);
}
else
{
boost::algorithm::replace_all(select_sql_str, "\"" + geom_col + "\"","AsBinary(" + geom_col+") as " + geom_col);
}
boost::algorithm::replace_all(select_sql_str, "\"" + geom_col + "\"","AsBinary(" + geom_col+") as " + geom_col);
#ifdef MAPNIK_DEBUG
std::cout << select_sql_str << "\n";
#endif
std::ostringstream cursor_sql;
std::string cursor_name("my_cursor");