Merge branch 'master' into sqlite-refactor
This commit is contained in:
commit
dcd19e05e5
3 changed files with 36 additions and 8 deletions
|
@ -274,7 +274,8 @@ void csv_datasource::parse_csv(T& stream,
|
|||
{
|
||||
std::string val = boost::trim_copy(*beg);
|
||||
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;
|
||||
has_wkt_field = true;
|
||||
|
@ -343,7 +344,8 @@ void csv_datasource::parse_csv(T& stream,
|
|||
else
|
||||
{
|
||||
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;
|
||||
has_wkt_field = true;
|
||||
|
@ -400,14 +402,21 @@ void csv_datasource::parse_csv(T& stream,
|
|||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned line_length = csv_line.length();
|
||||
|
||||
// skip blank lines
|
||||
if (csv_line.empty()){
|
||||
++line_number;
|
||||
continue;
|
||||
if (line_length < 5)
|
||||
{
|
||||
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
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -443,7 +452,14 @@ void csv_datasource::parse_csv(T& stream,
|
|||
std::string value;
|
||||
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;
|
||||
}
|
||||
else
|
||||
|
@ -452,7 +468,6 @@ void csv_datasource::parse_csv(T& stream,
|
|||
++beg;
|
||||
}
|
||||
|
||||
|
||||
int value_length = value.length();
|
||||
|
||||
// parse wkt
|
||||
|
|
1
tests/data/csv/trailing_newline_mac.csv
Normal file
1
tests/data/csv/trailing_newline_mac.csv
Normal file
|
@ -0,0 +1 @@
|
|||
x,y,z
0,0,0
1,2,3
|
|
12
tests/data/csv/trailing_newline_win.csv
Normal file
12
tests/data/csv/trailing_newline_win.csv
Normal file
|
@ -0,0 +1,12 @@
|
|||
FID,wkt,REGIONNAME,RID
|
||||
Eth_Region_Boundary.1,"POINT (0 0)",Addis Ababa,14
|
||||
Eth_Region_Boundary.2,"POINT (0 0)",Tigray,01
|
||||
Eth_Region_Boundary.3,"POINT (0 0)",Somali,05
|
||||
Eth_Region_Boundary.4,"POINT (0 0)",Dire Dawa,15
|
||||
Eth_Region_Boundary.5,"POINT (0 0)",Hareri,13
|
||||
Eth_Region_Boundary.6,"POINT (0 0)",SNNPR,07
|
||||
Eth_Region_Boundary.7,"POINT (0 0)",Gambela,12
|
||||
Eth_Region_Boundary.8,"POINT (0 0)",Beneshangul Gumu,06
|
||||
Eth_Region_Boundary.9,"POINT (0 0)",Amhara,03
|
||||
Eth_Region_Boundary.10,"POINT (0 0)",Afar,02
|
||||
Eth_Region_Boundary.11,"POINT (0 0)",Oromia,04
|
|
Loading…
Add table
Reference in a new issue