don't call *params.get<std::string>("type"), instead use static datasource::name()
(FIXME: consider removing redundant 'name' in feature_layer_descriptor)
This commit is contained in:
parent
b197cbcdb7
commit
0702679bb0
15 changed files with 44 additions and 43 deletions
|
@ -57,23 +57,23 @@ using mapnik::parameters;
|
|||
DATASOURCE_PLUGIN(csv_datasource)
|
||||
|
||||
csv_datasource::csv_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding", "utf-8")),
|
||||
extent_(),
|
||||
filename_(),
|
||||
inline_string_(),
|
||||
file_length_(0),
|
||||
row_limit_(*params.get<mapnik::value_integer>("row_limit", 0)),
|
||||
features_(),
|
||||
escape_(*params.get<std::string>("escape", "")),
|
||||
separator_(*params.get<std::string>("separator", "")),
|
||||
quote_(*params.get<std::string>("quote", "")),
|
||||
headers_(),
|
||||
manual_headers_(mapnik::util::trim_copy(*params.get<std::string>("headers", ""))),
|
||||
strict_(*params.get<mapnik::boolean>("strict", false)),
|
||||
filesize_max_(*params.get<double>("filesize_max", 20.0)), // MB
|
||||
ctx_(std::make_shared<mapnik::context_type>()),
|
||||
extent_initialized_(false)
|
||||
: datasource(params),
|
||||
desc_(csv_datasource::name(), *params.get<std::string>("encoding", "utf-8")),
|
||||
extent_(),
|
||||
filename_(),
|
||||
inline_string_(),
|
||||
file_length_(0),
|
||||
row_limit_(*params.get<mapnik::value_integer>("row_limit", 0)),
|
||||
features_(),
|
||||
escape_(*params.get<std::string>("escape", "")),
|
||||
separator_(*params.get<std::string>("separator", "")),
|
||||
quote_(*params.get<std::string>("quote", "")),
|
||||
headers_(),
|
||||
manual_headers_(mapnik::util::trim_copy(*params.get<std::string>("headers", ""))),
|
||||
strict_(*params.get<mapnik::boolean>("strict", false)),
|
||||
filesize_max_(*params.get<double>("filesize_max", 20.0)), // MB
|
||||
ctx_(std::make_shared<mapnik::context_type>()),
|
||||
extent_initialized_(false)
|
||||
{
|
||||
/* TODO:
|
||||
general:
|
||||
|
@ -475,16 +475,16 @@ void csv_datasource::parse_csv(T & stream,
|
|||
{
|
||||
std::ostringstream s;
|
||||
s << "CSV Plugin: # of columns("
|
||||
<< num_fields << ") > # of headers("
|
||||
<< num_headers << ") parsed for row " << line_number << "\n";
|
||||
<< num_fields << ") > # of headers("
|
||||
<< num_headers << ") parsed for row " << line_number << "\n";
|
||||
throw mapnik::datasource_exception(s.str());
|
||||
}
|
||||
else if (num_fields < num_headers)
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << "CSV Plugin: # of headers("
|
||||
<< num_headers << ") > # of columns("
|
||||
<< num_fields << ") parsed for row " << line_number << "\n";
|
||||
<< num_headers << ") > # of columns("
|
||||
<< num_fields << ") parsed for row " << line_number << "\n";
|
||||
if (strict_)
|
||||
{
|
||||
throw mapnik::datasource_exception(s.str());
|
||||
|
@ -691,9 +691,9 @@ void csv_datasource::parse_csv(T & stream,
|
|||
}
|
||||
}
|
||||
else if ((value[0] >= '0' && value[0] <= '9') ||
|
||||
value[0] == '-' ||
|
||||
value[0] == '+' ||
|
||||
value[0] == '.')
|
||||
value[0] == '-' ||
|
||||
value[0] == '+' ||
|
||||
value[0] == '.')
|
||||
{
|
||||
bool has_e = value.find("e") != std::string::npos;
|
||||
if (has_dot || has_e)
|
||||
|
@ -805,14 +805,14 @@ void csv_datasource::parse_csv(T & stream,
|
|||
s << "CSV Plugin: does your csv have valid headers?\n";
|
||||
if (!parsed_x)
|
||||
{
|
||||
s << "Could not detect or parse any rows named 'x' or 'longitude' "
|
||||
s << "Could not detect or parse any rows named 'x' or 'longitude' "
|
||||
<< "for line " << line_number << " but found " << headers_.size()
|
||||
<< " with values like: " << csv_line << "\n"
|
||||
<< "for: " << boost::algorithm::join(collected, ",") << "\n";
|
||||
}
|
||||
if (!parsed_y)
|
||||
{
|
||||
s << "Could not detect or parse any rows named 'y' or 'latitude' "
|
||||
s << "Could not detect or parse any rows named 'y' or 'latitude' "
|
||||
<< "for line " << line_number << " but found " << headers_.size()
|
||||
<< " with values like: " << csv_line << "\n"
|
||||
<< "for: " << boost::algorithm::join(collected, ",") << "\n";
|
||||
|
|
|
@ -76,7 +76,7 @@ inline GDALDataset* gdal_datasource::open_dataset() const
|
|||
|
||||
gdal_datasource::gdal_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
desc_(*params.get<std::string>("type"), "utf-8"),
|
||||
desc_(gdal_datasource::name(), "utf-8"),
|
||||
nodata_value_(params.get<double>("nodata")),
|
||||
nodata_tolerance_(*params.get<double>("nodata_tolerance",1e-12))
|
||||
{
|
||||
|
|
|
@ -94,9 +94,9 @@ struct attr_value_converter : public boost::static_visitor<mapnik::eAttributeTyp
|
|||
};
|
||||
|
||||
geojson_datasource::geojson_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
: datasource(params),
|
||||
type_(datasource::Vector),
|
||||
desc_(*params.get<std::string>("type"),
|
||||
desc_(geojson_datasource::name(),
|
||||
*params.get<std::string>("encoding","utf-8")),
|
||||
file_(*params.get<std::string>("file","")),
|
||||
extent_(),
|
||||
|
|
|
@ -76,7 +76,7 @@ occi_datasource::occi_datasource(parameters const& params)
|
|||
scale_denom_token_("!scale_denominator!"),
|
||||
pixel_width_token_("!pixel_width!"),
|
||||
pixel_height_token_("!pixel_height!"),
|
||||
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding", "utf-8")),
|
||||
desc_(occi_datasource::name(), *params.get<std::string>("encoding", "utf-8")),
|
||||
use_wkb_(*params.get<mapnik::boolean>("use_wkb", false)),
|
||||
row_limit_(*params.get<mapnik::value_integer>("row_limit", 0)),
|
||||
row_prefetch_(*params.get<int>("row_prefetch", 100)),
|
||||
|
|
|
@ -61,7 +61,7 @@ ogr_datasource::ogr_datasource(parameters const& params)
|
|||
: datasource(params),
|
||||
extent_(),
|
||||
type_(datasource::Vector),
|
||||
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding", "utf-8")),
|
||||
desc_(ogr_datasource::name(), *params.get<std::string>("encoding", "utf-8")),
|
||||
indexed_(false)
|
||||
{
|
||||
init(params);
|
||||
|
|
|
@ -52,7 +52,7 @@ osm_datasource::osm_datasource(const parameters& params)
|
|||
: datasource (params),
|
||||
extent_(),
|
||||
type_(datasource::Vector),
|
||||
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding", "utf-8"))
|
||||
desc_(osm_datasource::name(), *params.get<std::string>("encoding", "utf-8"))
|
||||
{
|
||||
osm_data_ = nullptr;
|
||||
std::string osm_filename = *params.get<std::string>("file", "");
|
||||
|
|
|
@ -70,7 +70,7 @@ postgis_datasource::postgis_datasource(parameters const& params)
|
|||
srid_(*params.get<mapnik::value_integer>("srid", 0)),
|
||||
extent_initialized_(false),
|
||||
simplify_geometries_(false),
|
||||
desc_(*params.get<std::string>("type"), "utf-8"),
|
||||
desc_(postgis_datasource::name(), "utf-8"),
|
||||
creator_(params.get<std::string>("host"),
|
||||
params.get<std::string>("port"),
|
||||
params.get<std::string>("dbname"),
|
||||
|
|
|
@ -21,7 +21,7 @@ DATASOURCE_PLUGIN(python_datasource)
|
|||
|
||||
python_datasource::python_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding","utf-8")),
|
||||
desc_(python_datasource::name(), *params.get<std::string>("encoding","utf-8")),
|
||||
factory_(*params.get<std::string>("factory", ""))
|
||||
{
|
||||
// extract any remaining parameters as keyword args for the factory
|
||||
|
|
|
@ -46,8 +46,8 @@ using mapnik::image_reader;
|
|||
DATASOURCE_PLUGIN(raster_datasource)
|
||||
|
||||
raster_datasource::raster_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
desc_(*params.get<std::string>("type"), "utf-8"),
|
||||
: datasource(params),
|
||||
desc_(raster_datasource::name(), "utf-8"),
|
||||
extent_initialized_(false)
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(raster) << "raster_datasource: Initializing...";
|
||||
|
|
|
@ -72,7 +72,7 @@ inline void* rasterlite_datasource::open_dataset() const
|
|||
|
||||
rasterlite_datasource::rasterlite_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
desc_(*params.get<std::string>("type"),"utf-8")
|
||||
desc_(rasterlite_datasource::name(),"utf-8")
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_datasource: Initializing...";
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ shape_datasource::shape_datasource(parameters const& params)
|
|||
file_length_(0),
|
||||
indexed_(false),
|
||||
row_limit_(*params.get<mapnik::value_integer>("row_limit",0)),
|
||||
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding","utf-8"))
|
||||
desc_(shape_datasource::name(), *params.get<std::string>("encoding","utf-8"))
|
||||
{
|
||||
#ifdef MAPNIK_STATS
|
||||
mapnik::progress_timer __stats__(std::clog, "shape_datasource::init");
|
||||
|
|
|
@ -66,7 +66,7 @@ sqlite_datasource::sqlite_datasource(parameters const& params)
|
|||
row_offset_(*params.get<mapnik::value_integer>("row_offset", 0)),
|
||||
row_limit_(*params.get<mapnik::value_integer>("row_limit", 0)),
|
||||
intersects_token_("!intersects!"),
|
||||
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding", "utf-8")),
|
||||
desc_(sqlite_datasource::name(), *params.get<std::string>("encoding", "utf-8")),
|
||||
format_(mapnik::wkbAuto)
|
||||
{
|
||||
/* TODO
|
||||
|
|
|
@ -11,8 +11,8 @@ using mapnik::parameters;
|
|||
DATASOURCE_PLUGIN(hello_datasource)
|
||||
|
||||
hello_datasource::hello_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding","utf-8")),
|
||||
: datasource(params),
|
||||
desc_(hello_datasource::name(), *params.get<std::string>("encoding","utf-8")),
|
||||
extent_()
|
||||
{
|
||||
this->init(params);
|
||||
|
|
|
@ -143,7 +143,7 @@ struct collect_attributes_visitor : public boost::static_visitor<void>
|
|||
topojson_datasource::topojson_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
type_(datasource::Vector),
|
||||
desc_(*params.get<std::string>("type"),
|
||||
desc_(topojson_datasource::name(),
|
||||
*params.get<std::string>("encoding","utf-8")),
|
||||
file_(*params.get<std::string>("file","")),
|
||||
extent_(),
|
||||
|
|
|
@ -72,7 +72,8 @@ const char * memory_datasource::name()
|
|||
|
||||
memory_datasource::memory_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding","utf-8")),
|
||||
desc_(memory_datasource::name(),
|
||||
*params.get<std::string>("encoding","utf-8")),
|
||||
type_(datasource::Vector),
|
||||
bbox_check_(*params.get<boolean>("bbox_check", true)) {}
|
||||
|
||||
|
|
Loading…
Reference in a new issue