Merge branch 'master' into sqlite-refactor

This commit is contained in:
Dane Springmeyer 2011-11-04 20:44:15 -07:00
commit dcd19e05e5
3 changed files with 36 additions and 8 deletions

View file

@ -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

View file

@ -0,0 +1 @@
x,y,z 0,0,0 1,2,3
1 x y z 0 0 0 1 2 3

View 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
1 FID wkt REGIONNAME RID
2 Eth_Region_Boundary.1 POINT (0 0) Addis Ababa 14
3 Eth_Region_Boundary.2 POINT (0 0) Tigray 01
4 Eth_Region_Boundary.3 POINT (0 0) Somali 05
5 Eth_Region_Boundary.4 POINT (0 0) Dire Dawa 15
6 Eth_Region_Boundary.5 POINT (0 0) Hareri 13
7 Eth_Region_Boundary.6 POINT (0 0) SNNPR 07
8 Eth_Region_Boundary.7 POINT (0 0) Gambela 12
9 Eth_Region_Boundary.8 POINT (0 0) Beneshangul Gumu 06
10 Eth_Region_Boundary.9 POINT (0 0) Amhara 03
11 Eth_Region_Boundary.10 POINT (0 0) Afar 02
12 Eth_Region_Boundary.11 POINT (0 0) Oromia 04