+ 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:
parent
4868eb805e
commit
db1e445370
2 changed files with 7 additions and 18 deletions
|
@ -59,7 +59,6 @@ int main ( int argc, char** argv)
|
||||||
("password,P",po::value<std::string>(),"Connect to the database with the specified password.")
|
("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")
|
("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")
|
("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.")
|
("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("dbname")) dbname = vm["dbname"].as<std::string>();
|
||||||
if (vm.count("user")) user = vm["user"].as<std::string>();
|
if (vm.count("user")) user = vm["user"].as<std::string>();
|
||||||
if (vm.count("password")) password = vm["password"].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);
|
ConnectionCreator<Connection> creator(host,port,dbname,user,password);
|
||||||
try
|
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_table_name = vm.count("table") ? vm["table"].as<std::string>() : mapnik::table_from_sql(query);
|
||||||
std::string output_file = vm["file"].as<std::string>();
|
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)
|
catch (mapnik::datasource_exception & ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,7 +82,7 @@ namespace mapnik {
|
||||||
{
|
{
|
||||||
table_name=table_name.substr(idx);
|
table_name=table_name.substr(idx);
|
||||||
}
|
}
|
||||||
idx=table_name.find_first_of(" )");
|
idx=table_name.find_first_of(" ),");
|
||||||
if (idx != std::string::npos)
|
if (idx != std::string::npos)
|
||||||
{
|
{
|
||||||
table_name = table_name.substr(0,idx);
|
table_name = table_name.substr(0,idx);
|
||||||
|
@ -96,8 +96,7 @@ namespace mapnik {
|
||||||
void pgsql2sqlite(Connection conn,
|
void pgsql2sqlite(Connection conn,
|
||||||
std::string const& query,
|
std::string const& query,
|
||||||
std::string const& output_table_name,
|
std::string const& output_table_name,
|
||||||
std::string const& output_filename ,
|
std::string const& output_filename)
|
||||||
unsigned tolerance)
|
|
||||||
{
|
{
|
||||||
namespace sqlite = mapnik::sqlite;
|
namespace sqlite = mapnik::sqlite;
|
||||||
sqlite::database db(output_filename);
|
sqlite::database db(output_filename);
|
||||||
|
@ -145,16 +144,7 @@ namespace mapnik {
|
||||||
|
|
||||||
// add AsBinary(<geometry_column>) modifier
|
// add AsBinary(<geometry_column>) modifier
|
||||||
std::string select_sql_str = select_sql.str();
|
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
|
#ifdef MAPNIK_DEBUG
|
||||||
std::cout << select_sql_str << "\n";
|
std::cout << select_sql_str << "\n";
|
||||||
|
|
Loading…
Reference in a new issue