From db1e4453700ba0241949bf19de87275f6b33f6b5 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Sun, 22 Feb 2009 22:34:31 +0000 Subject: [PATCH] + 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 --- utils/pgsql2sqlite/main.cpp | 7 +++---- utils/pgsql2sqlite/pgsql2sqlite.hpp | 18 ++++-------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/utils/pgsql2sqlite/main.cpp b/utils/pgsql2sqlite/main.cpp index 79fffa6ae..878fdd2c1 100644 --- a/utils/pgsql2sqlite/main.cpp +++ b/utils/pgsql2sqlite/main.cpp @@ -59,7 +59,6 @@ int main ( int argc, char** argv) ("password,P",po::value(),"Connect to the database with the specified password.") ("query,q",po::value(),"Name of the table/or query to pass to postmaster") ("table,t",po::value(),"Name of the table to create") - ("simplify,s",po::value(),"Use this option to reduce the complexity\nand weight of a geometry using the Douglas-Peucker algorithm.") ("file,f",po::value(),"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(); if (vm.count("user")) user = vm["user"].as(); if (vm.count("password")) password = vm["password"].as(); - unsigned tolerance = 0; - if (vm.count("simplify")) tolerance = vm["simplify"].as(); ConnectionCreator 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() : mapnik::table_from_sql(query); std::string output_file = vm["file"].as(); - 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) { diff --git a/utils/pgsql2sqlite/pgsql2sqlite.hpp b/utils/pgsql2sqlite/pgsql2sqlite.hpp index 0bfab1487..ab050d8c6 100644 --- a/utils/pgsql2sqlite/pgsql2sqlite.hpp +++ b/utils/pgsql2sqlite/pgsql2sqlite.hpp @@ -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() 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");