csv: detect as wkt columns with 'geom' substring and use more aggressive detection for blank lines
This commit is contained in:
parent
cd26cd51bc
commit
da4a7af14c
1 changed files with 23 additions and 8 deletions
|
@ -274,7 +274,8 @@ void csv_datasource::parse_csv(T& stream,
|
||||||
{
|
{
|
||||||
std::string val = boost::trim_copy(*beg);
|
std::string val = boost::trim_copy(*beg);
|
||||||
std::string lower_val = boost::algorithm::to_lower_copy(val);
|
std::string lower_val = boost::algorithm::to_lower_copy(val);
|
||||||
if (lower_val == "wkt")
|
if (lower_val == "wkt"
|
||||||
|
|| (lower_val.find("geom") != std::string::npos))
|
||||||
{
|
{
|
||||||
wkt_idx = idx;
|
wkt_idx = idx;
|
||||||
has_wkt_field = true;
|
has_wkt_field = true;
|
||||||
|
@ -343,7 +344,8 @@ void csv_datasource::parse_csv(T& stream,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string lower_val = boost::algorithm::to_lower_copy(val);
|
std::string lower_val = boost::algorithm::to_lower_copy(val);
|
||||||
if (lower_val == "wkt")
|
if (lower_val == "wkt"
|
||||||
|
|| (lower_val.find("geom") != std::string::npos))
|
||||||
{
|
{
|
||||||
wkt_idx = idx;
|
wkt_idx = idx;
|
||||||
has_wkt_field = true;
|
has_wkt_field = true;
|
||||||
|
@ -401,13 +403,20 @@ void csv_datasource::parse_csv(T& stream,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned line_length = csv_line.length();
|
||||||
|
|
||||||
// skip blank lines
|
// skip blank lines
|
||||||
if (csv_line.empty()){
|
if (line_length < 5)
|
||||||
++line_number;
|
{
|
||||||
continue;
|
std::string trimmed = csv_line;
|
||||||
|
boost::trim_if(trimmed,boost::algorithm::is_any_of("\",'\r\n"));
|
||||||
|
if (trimmed.empty()){
|
||||||
|
++line_number;
|
||||||
|
continue;
|
||||||
#ifdef MAPNIK_DEBUG
|
#ifdef MAPNIK_DEBUG
|
||||||
std::clog << "CSV Plugin: empty row encountered at line: " << line_number << "\n";
|
std::clog << "CSV Plugin: empty row encountered at line: " << line_number << "\n";
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -443,7 +452,14 @@ void csv_datasource::parse_csv(T& stream,
|
||||||
std::string value;
|
std::string value;
|
||||||
if (beg == tok.end())
|
if (beg == tok.end())
|
||||||
{
|
{
|
||||||
boost::put(*feature,fld_name,mapnik::value_null());
|
UnicodeString ustr = tr.transcode(value.c_str());
|
||||||
|
boost::put(*feature,fld_name,ustr);
|
||||||
|
//boost::put(*feature,fld_name,mapnik::value_null());
|
||||||
|
null_geom = true;
|
||||||
|
if (feature_count == 1)
|
||||||
|
{
|
||||||
|
desc_.add_descriptor(mapnik::attribute_descriptor(fld_name,mapnik::String));
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -452,7 +468,6 @@ void csv_datasource::parse_csv(T& stream,
|
||||||
++beg;
|
++beg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int value_length = value.length();
|
int value_length = value.length();
|
||||||
|
|
||||||
// parse wkt
|
// parse wkt
|
||||||
|
|
Loading…
Reference in a new issue