code cleanup / c++11 usage in plugins
This commit is contained in:
parent
34a744f7db
commit
324f70652b
5 changed files with 43 additions and 49 deletions
|
@ -492,12 +492,9 @@ void validate_attribute_names(query const& q, std::vector<attribute_descriptor>
|
||||||
{
|
{
|
||||||
bool found_name = false;
|
bool found_name = false;
|
||||||
|
|
||||||
std::vector<attribute_descriptor>::const_iterator itr = names.begin();
|
for (auto const& attr_info : names)
|
||||||
std::vector<attribute_descriptor>::const_iterator end = names.end();
|
|
||||||
|
|
||||||
for (; itr!=end; ++itr)
|
|
||||||
{
|
{
|
||||||
if (itr->get_name() == *pos)
|
if (attr_info.get_name() == *pos)
|
||||||
{
|
{
|
||||||
found_name = true;
|
found_name = true;
|
||||||
break;
|
break;
|
||||||
|
@ -508,11 +505,9 @@ void validate_attribute_names(query const& q, std::vector<attribute_descriptor>
|
||||||
{
|
{
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
s << "OGR Plugin: no attribute named '" << *pos << "'. Valid attributes are: ";
|
s << "OGR Plugin: no attribute named '" << *pos << "'. Valid attributes are: ";
|
||||||
std::vector<attribute_descriptor>::const_iterator e_itr = names.begin();
|
for (auto const& attr_info2 : names)
|
||||||
std::vector<attribute_descriptor>::const_iterator e_end = names.end();
|
|
||||||
for ( ;e_itr!=e_end;++e_itr)
|
|
||||||
{
|
{
|
||||||
s << e_itr->get_name() << std::endl;
|
s << attr_info2.get_name() << std::endl;
|
||||||
}
|
}
|
||||||
throw mapnik::datasource_exception(s.str());
|
throw mapnik::datasource_exception(s.str());
|
||||||
}
|
}
|
||||||
|
@ -533,10 +528,10 @@ featureset_ptr ogr_datasource::features(query const& q) const
|
||||||
// feature context (schema)
|
// feature context (schema)
|
||||||
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
||||||
|
|
||||||
std::vector<attribute_descriptor>::const_iterator itr = desc_ar.begin();
|
for (auto const& attr_info : desc_ar)
|
||||||
std::vector<attribute_descriptor>::const_iterator end = desc_ar.end();
|
{
|
||||||
|
ctx->push(attr_info.get_name()); // TODO only push query attributes
|
||||||
for (; itr!=end; ++itr) ctx->push(itr->get_name()); // TODO only push query attributes
|
}
|
||||||
|
|
||||||
validate_attribute_names(q, desc_ar);
|
validate_attribute_names(q, desc_ar);
|
||||||
|
|
||||||
|
@ -576,9 +571,10 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol)
|
||||||
// feature context (schema)
|
// feature context (schema)
|
||||||
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
||||||
|
|
||||||
std::vector<attribute_descriptor>::const_iterator itr = desc_ar.begin();
|
for (auto const& attr_info : desc_ar)
|
||||||
std::vector<attribute_descriptor>::const_iterator end = desc_ar.end();
|
{
|
||||||
for (; itr!=end; ++itr) ctx->push(itr->get_name());
|
ctx->push(attr_info.get_name()); // TODO only push query attributes
|
||||||
|
}
|
||||||
|
|
||||||
OGRLayer* layer = layer_.layer();
|
OGRLayer* layer = layer_.layer();
|
||||||
|
|
||||||
|
|
|
@ -1042,28 +1042,29 @@ featureset_ptr pgraster_datasource::features_at_point(coord2d const& pt, double
|
||||||
s << "SELECT ST_AsBinary(\"" << geometryColumn_ << "\") AS geom";
|
s << "SELECT ST_AsBinary(\"" << geometryColumn_ << "\") AS geom";
|
||||||
|
|
||||||
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
||||||
std::vector<attribute_descriptor>::const_iterator itr = desc_.get_descriptors().begin();
|
auto const& desc = desc_.get_descriptors();
|
||||||
std::vector<attribute_descriptor>::const_iterator end = desc_.get_descriptors().end();
|
|
||||||
|
|
||||||
if (! key_field_.empty())
|
if (!key_field_.empty())
|
||||||
{
|
{
|
||||||
mapnik::sql_utils::quote_attr(s, key_field_);
|
mapnik::sql_utils::quote_attr(s, key_field_);
|
||||||
ctx->push(key_field_);
|
ctx->push(key_field_);
|
||||||
for (; itr != end; ++itr)
|
for (auto const& attr_info : desc)
|
||||||
{
|
{
|
||||||
if (itr->get_name() != key_field_)
|
std::string const& name = attr_info.get_name();
|
||||||
|
if (name != key_field_)
|
||||||
{
|
{
|
||||||
mapnik::sql_utils::quote_attr(s, itr->get_name());
|
mapnik::sql_utils::quote_attr(s, name);
|
||||||
ctx->push(itr->get_name());
|
ctx->push(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (; itr != end; ++itr)
|
for (auto const& attr_info : desc)
|
||||||
{
|
{
|
||||||
mapnik::sql_utils::quote_attr(s, itr->get_name());
|
std::string const& name = attr_info.get_name();
|
||||||
ctx->push(itr->get_name());
|
mapnik::sql_utils::quote_attr(s, name);
|
||||||
|
ctx->push(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -903,31 +903,32 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double t
|
||||||
s << "SELECT ST_AsBinary(\"" << geometryColumn_ << "\") AS geom";
|
s << "SELECT ST_AsBinary(\"" << geometryColumn_ << "\") AS geom";
|
||||||
|
|
||||||
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
||||||
std::vector<attribute_descriptor>::const_iterator itr = desc_.get_descriptors().begin();
|
auto const& desc = desc_.get_descriptors();
|
||||||
std::vector<attribute_descriptor>::const_iterator end = desc_.get_descriptors().end();
|
|
||||||
|
|
||||||
if (! key_field_.empty())
|
if (!key_field_.empty())
|
||||||
{
|
{
|
||||||
mapnik::sql_utils::quote_attr(s, key_field_);
|
mapnik::sql_utils::quote_attr(s, key_field_);
|
||||||
if (key_field_as_attribute_)
|
if (key_field_as_attribute_)
|
||||||
{
|
{
|
||||||
ctx->push(key_field_);
|
ctx->push(key_field_);
|
||||||
}
|
}
|
||||||
for (; itr != end; ++itr)
|
for (auto const& attr_info : desc)
|
||||||
{
|
{
|
||||||
if (itr->get_name() != key_field_)
|
std::string const& name = attr_info.get_name();
|
||||||
|
if (name != key_field_)
|
||||||
{
|
{
|
||||||
mapnik::sql_utils::quote_attr(s, itr->get_name());
|
mapnik::sql_utils::quote_attr(s, name);
|
||||||
ctx->push(itr->get_name());
|
ctx->push(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (; itr != end; ++itr)
|
for (auto const& attr_info : desc)
|
||||||
{
|
{
|
||||||
mapnik::sql_utils::quote_attr(s, itr->get_name());
|
std::string const& name = attr_info.get_name();
|
||||||
ctx->push(itr->get_name());
|
mapnik::sql_utils::quote_attr(s, name);
|
||||||
|
ctx->push(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,15 +263,12 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt, double tol
|
||||||
|
|
||||||
filter_at_point filter(pt,tol);
|
filter_at_point filter(pt,tol);
|
||||||
// collect all attribute names
|
// collect all attribute names
|
||||||
std::vector<attribute_descriptor> const& desc_vector = desc_.get_descriptors();
|
auto const& desc = desc_.get_descriptors();
|
||||||
std::vector<attribute_descriptor>::const_iterator itr = desc_vector.begin();
|
|
||||||
std::vector<attribute_descriptor>::const_iterator end = desc_vector.end();
|
|
||||||
std::set<std::string> names;
|
std::set<std::string> names;
|
||||||
|
|
||||||
while (itr != end)
|
for (auto const& attr_info : desc)
|
||||||
{
|
{
|
||||||
names.insert(itr->get_name());
|
names.insert(attr_info.get_name());
|
||||||
++itr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexed_)
|
if (indexed_)
|
||||||
|
|
|
@ -574,16 +574,15 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double to
|
||||||
ctx->push(key_field_);
|
ctx->push(key_field_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<attribute_descriptor>::const_iterator itr = desc_.get_descriptors().begin();
|
auto const& desc = desc_.get_descriptors();
|
||||||
std::vector<attribute_descriptor>::const_iterator end = desc_.get_descriptors().end();
|
|
||||||
|
|
||||||
for ( ; itr != end; ++itr)
|
for (auto const& attr_info : desc)
|
||||||
{
|
{
|
||||||
std::string fld_name = itr->get_name();
|
std::string const& name = attr_info.get_name();
|
||||||
if (fld_name != key_field_)
|
if (name != key_field_)
|
||||||
{
|
{
|
||||||
s << ",[" << itr->get_name() << "]";
|
s << ",[" << name << "]";
|
||||||
ctx->push(itr->get_name());
|
ctx->push(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue