Merge pull request #2418 from mapycz/fix-image-painted

fix image painted
This commit is contained in:
Dane Springmeyer 2014-09-19 14:07:39 -07:00
commit f67e300286
6 changed files with 108 additions and 1 deletions

View file

@ -132,6 +132,8 @@ public:
}
void painted(bool painted);
bool painted();
inline eAttributeCollectionPolicy attribute_collection_policy() const
{
return DEFAULT;

View file

@ -140,6 +140,12 @@ public:
// cairo renderer doesn't support processing of multiple symbolizers.
return false;
}
bool painted()
{
return true;
}
void painted(bool /*painted*/)
{
// nothing to do

View file

@ -707,7 +707,7 @@ void feature_style_processor<Processor>::render_style(
}
}
}
p.painted(was_painted);
p.painted(p.painted() | was_painted);
p.end_style_processing(*style);
}

View file

@ -119,14 +119,22 @@ public:
// grid renderer doesn't support processing of multiple symbolizers.
return false;
}
bool painted()
{
pixmap_.painted();
}
void painted(bool painted)
{
pixmap_.painted(painted);
}
inline eAttributeCollectionPolicy attribute_collection_policy() const
{
return DEFAULT;
}
inline double scale_factor() const
{
return common_.scale_factor_;

View file

@ -437,6 +437,12 @@ void agg_renderer<T0,T1>::render_marker(pixel_position const& pos,
}
}
template <typename T0, typename T1>
bool agg_renderer<T0,T1>::painted()
{
return pixmap_.painted();
}
template <typename T0, typename T1>
void agg_renderer<T0,T1>::painted(bool painted)
{

View file

@ -0,0 +1,85 @@
#include <iostream>
#include <boost/detail/lightweight_test.hpp>
#include <mapnik/map.hpp>
#include <mapnik/layer.hpp>
#include <mapnik/rule.hpp>
#include <mapnik/feature_type_style.hpp>
#include <mapnik/graphics.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/agg_renderer.hpp>
#include <mapnik/expression.hpp>
int main(int argc, char** argv)
{
std::vector<std::string> args;
for (int i = 1; i < argc; ++i)
{
args.push_back(argv[i]);
}
bool quiet = std::find(args.begin(), args.end(), "-q") != args.end();
using namespace mapnik;
try
{
datasource_cache::instance().register_datasources("plugins/input/");
Map m(256, 256);
feature_type_style lines_style;
{
rule r;
line_symbolizer line_sym;
r.append(std::move(line_sym));
lines_style.add_rule(std::move(r));
}
m.insert_style("lines", std::move(lines_style));
feature_type_style markers_style;
{
rule r;
r.set_filter(parse_expression("False"));
markers_symbolizer mark_sym;
r.append(std::move(mark_sym));
markers_style.add_rule(std::move(r));
}
m.insert_style("markers", std::move(markers_style));
parameters p;
p["type"] = "csv";
p["separator"] = "|";
p["inline"] = "wkt\nLINESTRING(-10 0, 0 20, 10 0, 15 5)";
layer lyr("layer");
lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("lines");
lyr.add_style("markers");
m.add_layer(lyr);
m.zoom_all();
image_32 image(m.width(), m.height());
agg_renderer<image_32> ren(m, image);
ren.apply();
BOOST_TEST_EQ(image.painted(), true);
}
catch (std::exception const & ex)
{
std::clog << "C++ image painted problem: " << ex.what() << std::endl;
BOOST_TEST(false);
}
if (::boost::detail::test_errors())
{
return ::boost::report_errors();
}
else
{
if (quiet) std::clog << "\x1b[1;32m.\x1b[0m";
else std::clog << "C++ image painted: \x1b[1;32m✓ \x1b[0m\n";
::boost::detail::report_errors_remind().called_report_errors_function = true;
}
}