Revert "csv_utils - check and skip processing lines consisting only of 0xa (windows) ( fixes #3359 )"
This reverts commit 9c09f15de9
.
This commit is contained in:
parent
9c09f15de9
commit
96b96c745d
6 changed files with 30 additions and 58 deletions
|
@ -128,11 +128,11 @@ std::tuple<char, bool, char, char> autodetect_csv_flavour(std::istream & stream,
|
|||
{
|
||||
if (size < file_length && ss.eof())
|
||||
{
|
||||
// we can't be sure that last line
|
||||
// we can't be sure last line
|
||||
// is not truncated so skip it
|
||||
break;
|
||||
}
|
||||
if (line.size() == 0 || (line.size() == 1 && line[0] == char(0xa))) continue; // empty lines are not interesting
|
||||
if (line.size() == 0) continue; // empty lines are not interesting
|
||||
auto num_quotes = std::count(line.begin(), line.end(), quote);
|
||||
if (num_quotes % 2 != 0)
|
||||
{
|
||||
|
|
|
@ -53,22 +53,22 @@ using mapnik::parameters;
|
|||
DATASOURCE_PLUGIN(sqlite_datasource)
|
||||
|
||||
sqlite_datasource::sqlite_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
extent_(),
|
||||
extent_initialized_(false),
|
||||
type_(datasource::Vector),
|
||||
table_(*params.get<std::string>("table", "")),
|
||||
fields_(*params.get<std::string>("fields", "*")),
|
||||
metadata_(*params.get<std::string>("metadata", "")),
|
||||
geometry_table_(*params.get<std::string>("geometry_table", "")),
|
||||
geometry_field_(*params.get<std::string>("geometry_field", "")),
|
||||
index_table_(*params.get<std::string>("index_table", "")),
|
||||
key_field_(*params.get<std::string>("key_field", "")),
|
||||
row_offset_(*params.get<mapnik::value_integer>("row_offset", 0)),
|
||||
row_limit_(*params.get<mapnik::value_integer>("row_limit", 0)),
|
||||
intersects_token_("!intersects!"),
|
||||
desc_(sqlite_datasource::name(), *params.get<std::string>("encoding", "utf-8")),
|
||||
format_(mapnik::wkbAuto)
|
||||
: datasource(params),
|
||||
extent_(),
|
||||
extent_initialized_(false),
|
||||
type_(datasource::Vector),
|
||||
table_(*params.get<std::string>("table", "")),
|
||||
fields_(*params.get<std::string>("fields", "*")),
|
||||
metadata_(*params.get<std::string>("metadata", "")),
|
||||
geometry_table_(*params.get<std::string>("geometry_table", "")),
|
||||
geometry_field_(*params.get<std::string>("geometry_field", "")),
|
||||
index_table_(*params.get<std::string>("index_table", "")),
|
||||
key_field_(*params.get<std::string>("key_field", "")),
|
||||
row_offset_(*params.get<mapnik::value_integer>("row_offset", 0)),
|
||||
row_limit_(*params.get<mapnik::value_integer>("row_limit", 0)),
|
||||
intersects_token_("!intersects!"),
|
||||
desc_(sqlite_datasource::name(), *params.get<std::string>("encoding", "utf-8")),
|
||||
format_(mapnik::wkbAuto)
|
||||
{
|
||||
/* TODO
|
||||
- throw if no primary key but spatial index is present?
|
||||
|
@ -448,7 +448,7 @@ boost::optional<mapnik::datasource_geometry_t> sqlite_datasource::get_geometry_t
|
|||
if (data)
|
||||
{
|
||||
|
||||
mapnik::geometry::geometry<double> geom = mapnik::geometry_utils::from_twkb(data, size);
|
||||
mapnik::geometry::geometry<double> geom = mapnik::geometry_utils::from_wkb(data, size, format_);
|
||||
if (mapnik::geometry::is_empty(geom))
|
||||
{
|
||||
continue;
|
||||
|
|
|
@ -81,7 +81,7 @@ feature_ptr sqlite_featureset::next()
|
|||
}
|
||||
|
||||
feature_ptr feature = feature_factory::create(ctx_,rs_->column_integer64(1));
|
||||
mapnik::geometry::geometry<double> geom = geometry_utils::from_twkb(data, size);
|
||||
mapnik::geometry::geometry<double> geom = geometry_utils::from_wkb(data, size, format_);
|
||||
if (mapnik::geometry::is_empty(geom))
|
||||
{
|
||||
continue;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
@ -7,7 +8,6 @@
|
|||
#include <mapnik/geometry_is_simple.hpp>
|
||||
#include <mapnik/geometry_correct.hpp>
|
||||
#include <mapnik/feature_factory.hpp>
|
||||
#include <mapnik/util/geometry_to_wkt.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
TEST_CASE("geometry formats") {
|
||||
|
@ -64,13 +64,8 @@ SECTION("wkb") {
|
|||
|
||||
// spatialite blob
|
||||
mapnik::geometry::geometry<double> geom = mapnik::geometry_utils::from_wkb((const char*)sp_valid_blob,
|
||||
sizeof(sp_valid_blob) / sizeof(sp_valid_blob[0]),
|
||||
mapnik::wkbSpatiaLite);
|
||||
std::string wkt;
|
||||
if (mapnik::util::to_wkt(wkt, geom))
|
||||
{
|
||||
std::cerr << wkt << std::endl;
|
||||
}
|
||||
sizeof(sp_valid_blob) / sizeof(sp_valid_blob[0]),
|
||||
mapnik::wkbSpatiaLite);
|
||||
// winding order is not correct per OGC so we'll fix it
|
||||
mapnik::geometry::correct(geom);
|
||||
#if BOOST_VERSION >= 105800
|
||||
|
@ -81,10 +76,7 @@ SECTION("wkb") {
|
|||
geom = mapnik::geometry_utils::from_wkb((const char*)sp_valid_blob,
|
||||
sizeof(sp_valid_blob) / sizeof(sp_valid_blob[0]),
|
||||
mapnik::wkbAuto);
|
||||
|
||||
|
||||
mapnik::geometry::correct(geom);
|
||||
|
||||
#if BOOST_VERSION >= 105800
|
||||
REQUIRE(mapnik::geometry::is_valid(geom));
|
||||
REQUIRE(mapnik::geometry::is_simple(geom));
|
||||
|
|
|
@ -58,7 +58,7 @@ int main ( int argc, char** argv)
|
|||
("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 output table to create (default: table in query)")
|
||||
("file,f",po::value<std::string>(),"Use this option to specify the name of the file to create.")
|
||||
("twkb", "Output geometries in TWKB format.")
|
||||
|
||||
;
|
||||
|
||||
//po::positional_options_description p;
|
||||
|
@ -90,8 +90,6 @@ int main ( int argc, char** argv)
|
|||
boost::optional<std::string> password;
|
||||
boost::optional<std::string> connect_timeout("4");
|
||||
|
||||
bool output_twkb = vm.count("twkb") ? true : false;
|
||||
|
||||
if (vm.count("host")) host = vm["host"].as<std::string>();
|
||||
if (vm.count("port")) port = vm["port"].as<std::string>();
|
||||
if (vm.count("dbname")) dbname = vm["dbname"].as<std::string>();
|
||||
|
@ -109,7 +107,7 @@ int main ( int argc, char** argv)
|
|||
|
||||
std::cout << "output_table : " << output_table_name << "\n";
|
||||
|
||||
mapnik::pgsql2sqlite(conn, query, output_table_name, output_file, output_twkb);
|
||||
mapnik::pgsql2sqlite(conn,query,output_table_name,output_file);
|
||||
}
|
||||
catch (mapnik::datasource_exception & ex)
|
||||
{
|
||||
|
|
|
@ -165,8 +165,7 @@ template <typename Connection>
|
|||
void pgsql2sqlite(Connection conn,
|
||||
std::string const& query,
|
||||
std::string const& output_table_name,
|
||||
std::string const& output_filename,
|
||||
bool output_twkb)
|
||||
std::string const& output_filename)
|
||||
{
|
||||
namespace sqlite = mapnik::sqlite;
|
||||
sqlite::database db(output_filename);
|
||||
|
@ -224,20 +223,11 @@ void pgsql2sqlite(Connection conn,
|
|||
geom_type = rs->getValue("type");
|
||||
}
|
||||
|
||||
// add AsBinary(<geometry_column>) modifier
|
||||
std::string select_sql_str = select_sql.str();
|
||||
if (output_twkb)
|
||||
{
|
||||
// add AsTWKB(<geometry_column>, 2) modifier
|
||||
boost::algorithm::replace_all(select_sql_str, "\"" + geom_col + "\"","ST_AsTWKB(" + geom_col+", 2) as " + geom_col);
|
||||
}
|
||||
else
|
||||
{
|
||||
// add AsBinary(<geometry_column>) modifier
|
||||
boost::algorithm::replace_all(select_sql_str, "\"" + geom_col + "\"","ST_AsBinary(" + geom_col+") as " + geom_col);
|
||||
}
|
||||
boost::algorithm::replace_all(select_sql_str, "\"" + geom_col + "\"","ST_AsBinary(" + geom_col+") as " + geom_col);
|
||||
|
||||
//#ifdef MAPNIK_DEBUG
|
||||
#if 1
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::cout << select_sql_str << "\n";
|
||||
#endif
|
||||
|
||||
|
@ -397,15 +387,7 @@ void pgsql2sqlite(Connection conn,
|
|||
if (oid == geometry_oid)
|
||||
{
|
||||
mapnik::feature_impl feat(ctx,pkid);
|
||||
mapnik::geometry::geometry<double> geom;
|
||||
if (output_twkb)
|
||||
{
|
||||
geom = geometry_utils::from_twkb(buf, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
geom = geometry_utils::from_wkb(buf, size, wkbGeneric);
|
||||
}
|
||||
mapnik::geometry::geometry<double> geom = geometry_utils::from_wkb(buf, size, wkbGeneric);
|
||||
if (!mapnik::geometry::is_empty(geom))
|
||||
{
|
||||
box2d<double> bbox = mapnik::geometry::envelope(geom);
|
||||
|
|
Loading…
Reference in a new issue