Merge pull request #3235 from mapnik/raster_mem_ds

Raster Type Memory Datasource
This commit is contained in:
Artem Pavlenko 2016-01-14 16:19:43 +00:00
commit 7997f3725e
2 changed files with 27 additions and 1 deletions

View file

@ -55,6 +55,7 @@ private:
mapnik::layer_descriptor desc_;
datasource::datasource_t type_;
bool bbox_check_;
bool type_set_;
mutable box2d<double> extent_;
mutable bool dirty_extent_ = true;
};

View file

@ -73,7 +73,8 @@ memory_datasource::memory_datasource(parameters const& params)
desc_(memory_datasource::name(),
*params.get<std::string>("encoding","utf-8")),
type_(datasource::Vector),
bbox_check_(*params.get<boolean_type>("bbox_check", true)) {}
bbox_check_(*params.get<boolean_type>("bbox_check", true)),
type_set_(false) {}
memory_datasource::~memory_datasource() {}
@ -81,6 +82,30 @@ void memory_datasource::push(feature_ptr feature)
{
// TODO - collect attribute descriptors?
//desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Integer));
if (feature->get_raster())
{
// if a feature has a raster_ptr set it must be of raster type.
if (!type_set_)
{
type_ = datasource::Raster;
type_set_ = true;
}
else if (type_ == datasource::Vector)
{
throw std::runtime_error("Can not add a raster feature to a memory datasource that contains vectors");
}
}
else
{
if (!type_set_)
{
type_set_ = true;
}
else if (type_ == datasource::Raster)
{
throw std::runtime_error("Can not add a vector feature to a memory datasource that contains rasters");
}
}
features_.push_back(feature);
dirty_extent_ = true;
}