This commit is contained in:
parent
9ef6c0dce1
commit
25a1643d54
1 changed files with 21 additions and 31 deletions
|
@ -380,14 +380,12 @@ void render_layer_for_grid(const mapnik::Map& map,
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert python list to std::set
|
// convert python list to std::set
|
||||||
std::set<std::string> attributes;
|
|
||||||
boost::python::ssize_t num_fields = boost::python::len(fields);
|
boost::python::ssize_t num_fields = boost::python::len(fields);
|
||||||
for(boost::python::ssize_t i=0; i<num_fields; i++) {
|
for(boost::python::ssize_t i=0; i<num_fields; i++) {
|
||||||
boost::python::extract<std::string> name(fields[i]);
|
boost::python::extract<std::string> name(fields[i]);
|
||||||
if (name.check())
|
if (name.check())
|
||||||
{
|
{
|
||||||
grid.add_property_name(name());
|
grid.add_property_name(name());
|
||||||
attributes.insert(name());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -397,22 +395,20 @@ void render_layer_for_grid(const mapnik::Map& map,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const& key = grid.get_key();
|
// copy property names
|
||||||
|
std::set<std::string> attributes = grid.property_names();
|
||||||
// if key is special __id__ keyword
|
// todo - make this a static constant
|
||||||
if (key == grid.key_name())
|
std::string known_id_key = "__id__";
|
||||||
|
if (attributes.find(known_id_key) != attributes.end())
|
||||||
{
|
{
|
||||||
// TODO - should feature.id() be a first class attribute?
|
attributes.erase(known_id_key);
|
||||||
|
|
||||||
// if __id__ is requested to be dumped out
|
|
||||||
// remove it so that datasource queries will not break
|
|
||||||
attributes.erase(key);
|
|
||||||
}
|
}
|
||||||
// if key is not the special __id__ keyword
|
|
||||||
else
|
std::string join_field = grid.get_key();
|
||||||
|
if (known_id_key != join_field &&
|
||||||
|
attributes.find(join_field) == attributes.end())
|
||||||
{
|
{
|
||||||
// them make sure the datasource query includes this field
|
attributes.insert(join_field);
|
||||||
attributes.insert(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mapnik::grid_renderer<mapnik::grid> ren(map,grid,1.0,0,0);
|
mapnik::grid_renderer<mapnik::grid> ren(map,grid,1.0,0,0);
|
||||||
|
@ -445,7 +441,7 @@ boost::python::dict render_grid(const mapnik::Map& map,
|
||||||
// TODO - no need to pass step here
|
// TODO - no need to pass step here
|
||||||
mapnik::grid grid(grid_width,grid_height,key,step);
|
mapnik::grid grid(grid_width,grid_height,key,step);
|
||||||
|
|
||||||
// convert python list to std::vector
|
// convert python list to std::set
|
||||||
boost::python::ssize_t num_fields = boost::python::len(fields);
|
boost::python::ssize_t num_fields = boost::python::len(fields);
|
||||||
for(boost::python::ssize_t i=0; i<num_fields; i++) {
|
for(boost::python::ssize_t i=0; i<num_fields; i++) {
|
||||||
boost::python::extract<std::string> name(fields[i]);
|
boost::python::extract<std::string> name(fields[i]);
|
||||||
|
@ -462,24 +458,18 @@ boost::python::dict render_grid(const mapnik::Map& map,
|
||||||
|
|
||||||
// copy property names
|
// copy property names
|
||||||
std::set<std::string> attributes = grid.property_names();
|
std::set<std::string> attributes = grid.property_names();
|
||||||
|
// todo - make this a static constant
|
||||||
// if key is special __id__ keyword
|
std::string known_id_key = "__id__";
|
||||||
if (key == grid.key_name())
|
if (attributes.find(known_id_key) != attributes.end())
|
||||||
{
|
{
|
||||||
// TODO - should feature.id() be a first class attribute?
|
attributes.erase(known_id_key);
|
||||||
|
|
||||||
// if __id__ is requested to be dumped out
|
|
||||||
// remove it so that datasource queries will not break
|
|
||||||
if (attributes.find(key) != attributes.end())
|
|
||||||
{
|
|
||||||
attributes.erase(key);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// if key is not the special __id__ keyword
|
std::string join_field = grid.get_key();
|
||||||
else if (attributes.find(key) == attributes.end())
|
if (known_id_key != join_field &&
|
||||||
|
attributes.find(join_field) == attributes.end())
|
||||||
{
|
{
|
||||||
// them make sure the datasource query includes this field
|
attributes.insert(join_field);
|
||||||
attributes.insert(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in a new issue