double grid encoding performance in python - closes #1315
This commit is contained in:
parent
58d848ae8e
commit
62e039d2c9
3 changed files with 52 additions and 8 deletions
|
@ -11,6 +11,8 @@ For a complete change history, see the git log.
|
||||||
|
|
||||||
Not yet released
|
Not yet released
|
||||||
|
|
||||||
|
- Increased grid encoding performance (#1315)
|
||||||
|
|
||||||
- Added support for overriding fill, stroke, and opacity for svg markers using marker properties
|
- Added support for overriding fill, stroke, and opacity for svg markers using marker properties
|
||||||
|
|
||||||
- Added support for setting opacity dynamically on images in polygon pattern and markers symbolizers
|
- Added support for setting opacity dynamically on images in polygon pattern and markers symbolizers
|
||||||
|
|
|
@ -233,9 +233,50 @@ void write_features(T const& grid_type,
|
||||||
boost::python::dict& feature_data,
|
boost::python::dict& feature_data,
|
||||||
std::vector<typename T::lookup_type> const& key_order)
|
std::vector<typename T::lookup_type> const& key_order)
|
||||||
{
|
{
|
||||||
std::string const& key = grid_type.get_key();
|
|
||||||
std::set<std::string> const& attributes = grid_type.property_names();
|
|
||||||
typename T::feature_type const& g_features = grid_type.get_grid_features();
|
typename T::feature_type const& g_features = grid_type.get_grid_features();
|
||||||
|
if (g_features.size() <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::set<std::string> const& attributes = grid_type.property_names();
|
||||||
|
typename T::feature_type::const_iterator feat_end = g_features.end();
|
||||||
|
BOOST_FOREACH ( std::string const& key_item, key_order )
|
||||||
|
{
|
||||||
|
if (key_item.empty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
typename T::feature_type::const_iterator feat_itr = g_features.find(key_item);
|
||||||
|
if (feat_itr == feat_end)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
boost::python::dict feat;
|
||||||
|
mapnik::feature_ptr feature = feat_itr->second;
|
||||||
|
BOOST_FOREACH ( std::string const& attr, attributes )
|
||||||
|
{
|
||||||
|
if (attr == "__id__")
|
||||||
|
{
|
||||||
|
feat[attr.c_str()] = feature->id();
|
||||||
|
}
|
||||||
|
else if (feature->has_key(attr))
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
feat[attr.c_str()] = feature->get(attr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
{
|
||||||
|
feature_data[feat_itr->first] = feat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* std::string const& key = grid_type.get_key();
|
||||||
|
std::set<std::string> const& attributes = grid_type.property_names();
|
||||||
typename T::feature_type::const_iterator feat_itr = g_features.begin();
|
typename T::feature_type::const_iterator feat_itr = g_features.begin();
|
||||||
typename T::feature_type::const_iterator feat_end = g_features.end();
|
typename T::feature_type::const_iterator feat_end = g_features.end();
|
||||||
bool include_key = (attributes.find(key) != attributes.end());
|
bool include_key = (attributes.find(key) != attributes.end());
|
||||||
|
@ -298,6 +339,7 @@ void write_features(T const& grid_type,
|
||||||
MAPNIK_LOG_DEBUG(bindings) << "write_features: Should not get here: key " << key << " not found in grid feature properties";
|
MAPNIK_LOG_DEBUG(bindings) << "write_features: Should not get here: key " << key << " not found in grid feature properties";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -194,7 +194,7 @@ grid_feat_id = {'keys': ['', '3', '4', '2', '1'], 'data': {'1': {'Name': 'South
|
||||||
|
|
||||||
grid_feat_id2 = {"data": {"1": {"Name": "South East"}, "2": {"Name": "South West"}, "3": {"Name": "North West"}, "4": {"Name": "North East"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]}
|
grid_feat_id2 = {"data": {"1": {"Name": "South East"}, "2": {"Name": "South West"}, "3": {"Name": "North West"}, "4": {"Name": "North East"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $$ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]}
|
||||||
|
|
||||||
grid_feat_id3 = {"data": {"1": {"Name": "South East"}, "2": {"Name": "South West"}, "3": {"Name": "North West"}, "4": {"Name": "North East"}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]}
|
grid_feat_id3 = {"data": {"1": {"Name": "South East", "__id__": 1}, "2": {"Name": "South West", "__id__": 2}, "3": {"Name": "North West", "__id__": 3}, "4": {"Name": "North East", "__id__": 4}}, "grid": [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " !! ## ", " !!! ### ", " !! ## ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " $$ %% ", " $$$ %% ", " $ %% ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "], "keys": ["", "3", "4", "2", "1"]}
|
||||||
|
|
||||||
def test_render_grid3():
|
def test_render_grid3():
|
||||||
""" test using feature id"""
|
""" test using feature id"""
|
||||||
|
@ -225,10 +225,10 @@ def test_render_grid3():
|
||||||
# resolve some center points in the
|
# resolve some center points in the
|
||||||
# resampled view
|
# resampled view
|
||||||
utf5 = grid_view.encode('utf',resolution=4)
|
utf5 = grid_view.encode('utf',resolution=4)
|
||||||
eq_(resolve(utf5,25,10),{"Name": "North West"})
|
eq_(resolve(utf5,25,10),{"Name": "North West","__id__": 3})
|
||||||
eq_(resolve(utf5,25,46),{"Name": "North East"})
|
eq_(resolve(utf5,25,46),{"Name": "North East","__id__": 4})
|
||||||
eq_(resolve(utf5,38,10),{"Name": "South West"})
|
eq_(resolve(utf5,38,10),{"Name": "South West","__id__": 2})
|
||||||
eq_(resolve(utf5,38,46),{"Name": "South East"})
|
eq_(resolve(utf5,38,46),{"Name": "South East","__id__": 1})
|
||||||
|
|
||||||
|
|
||||||
def gen_grid_for_id(pixel_key):
|
def gen_grid_for_id(pixel_key):
|
||||||
|
@ -310,7 +310,7 @@ def test_line_rendering():
|
||||||
m.zoom_all()
|
m.zoom_all()
|
||||||
#mapnik.render_to_file(m,'test.png')
|
#mapnik.render_to_file(m,'test.png')
|
||||||
grid = mapnik.Grid(m.width,m.height,key='__id__')
|
grid = mapnik.Grid(m.width,m.height,key='__id__')
|
||||||
mapnik.render_layer(m,grid,layer=0,fields=['__id__','Name'])
|
mapnik.render_layer(m,grid,layer=0,fields=['Name'])
|
||||||
utf1 = grid.encode()
|
utf1 = grid.encode()
|
||||||
eq_(utf1,line_expected,show_grids('line',utf1,line_expected))
|
eq_(utf1,line_expected,show_grids('line',utf1,line_expected))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue