Merge branch 'master' into spirit-x3

This commit is contained in:
artemp 2016-02-02 10:28:42 +01:00
commit e48aaf5c13
4 changed files with 32 additions and 13 deletions

2
deps/mapbox/variant vendored

@ -1 +1 @@
Subproject commit 64596e3aa2c0f47ab3e74a50c5c49acd5c57f5d5
Subproject commit 24391a9ea3e4b060c7a62debf6eb4e3515b9a5e6

View file

@ -321,14 +321,23 @@ void csv_datasource::parse_csv(T & stream)
try
{
auto values = csv_utils::parse_line(csv_line, separator_, quote_);
auto const* line_start = csv_line.data();
auto const* line_end = line_start + csv_line.size();
auto values = csv_utils::parse_line(line_start, line_end, separator_, quote_, num_headers);
unsigned num_fields = values.size();
if (num_fields > num_headers || num_fields < num_headers)
if (num_fields != num_headers)
{
std::ostringstream s;
s << "CSV Plugin: # of columns("
<< num_fields << ") > # of headers("
<< num_headers << ") parsed for row " << line_number;
s << "CSV Plugin: # of columns(" << num_fields << ")";
if (num_fields > num_headers)
{
s << " > ";
}
else
{
s << " < ";
}
s << "# of headers(" << num_headers << ") parsed";
throw mapnik::datasource_exception(s.str());
}

View file

@ -54,7 +54,9 @@ csv_inline_featureset::~csv_inline_featureset() {}
mapnik::feature_ptr csv_inline_featureset::parse_feature(std::string const& str)
{
auto values = csv_utils::parse_line(str, separator_, quote_);
auto const* start = str.data();
auto const* end = start + str.size();
auto values = csv_utils::parse_line(start, end, separator_, quote_, headers_.size());
auto geom = detail::extract_geometry(values, locator_);
if (!geom.is<mapnik::geometry::geometry_empty>())
{

View file

@ -186,15 +186,23 @@ std::pair<bool,box2d<double>> process_csv_file(T & boxes, std::string const& fil
}
try
{
auto values = csv_utils::parse_line(csv_line, separator, quote);
auto const* start_line = csv_line.data();
auto const* end_line = start_line + csv_line.size();
auto values = csv_utils::parse_line(start_line, end_line, separator, quote, num_headers);
unsigned num_fields = values.size();
if (num_fields > num_headers || num_fields < num_headers)
if (num_fields != num_headers)
{
// skip this row
std::ostringstream s;
s << "CSV Index: # of columns("
<< num_fields << ") > # of headers("
<< num_headers << ") parsed for row " << line_number;
s << "CSV Plugin: # of columns(" << num_fields << ")";
if (num_fields > num_headers)
{
s << " > ";
}
else
{
s << " < ";
}
s << "# of headers(" << num_headers << ") parsed";
throw mapnik::datasource_exception(s.str());
}