mapnik/test/unit/imaging/image_painted_test.cpp

74 lines
1.9 KiB
C++
Raw Normal View History

2015-04-24 12:40:22 +00:00
#include "catch.hpp"
#include <iostream>
#include <mapnik/map.hpp>
#include <mapnik/layer.hpp>
#include <mapnik/rule.hpp>
#include <mapnik/feature_type_style.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/agg_renderer.hpp>
#include <mapnik/expression.hpp>
#include <mapnik/util/fs.hpp>
2015-04-24 12:40:22 +00:00
TEST_CASE("image") {
SECTION("painting") {
using namespace mapnik;
try
{
std::string csv_plugin("./plugins/input/csv.input");
if (mapnik::util::exists(csv_plugin))
{
Map m(256, 256);
2015-04-24 12:40:22 +00:00
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));
2015-04-24 12:40:22 +00:00
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));
2015-04-24 12:40:22 +00:00
parameters p;
p["type"] = "csv";
p["separator"] = "|";
p["inline"] = "wkt\nLINESTRING(-10 0, 0 20, 10 0, 15 5)";
2015-04-24 12:40:22 +00:00
layer lyr("layer");
lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("lines");
lyr.add_style("markers");
m.add_layer(lyr);
2015-04-24 12:40:22 +00:00
m.zoom_all();
2015-04-24 12:40:22 +00:00
image_rgba8 image(m.width(), m.height());
agg_renderer<image_rgba8> ren(m, image);
ren.apply();
2015-04-24 12:40:22 +00:00
REQUIRE(image.painted() == true);
}
2015-04-24 12:40:22 +00:00
}
catch (std::exception const & ex)
{
std::clog << ex.what() << std::endl;
REQUIRE(false);
}
}
2017-05-05 11:02:01 +00:00
}