File: image_painted_test.cpp

package info (click to toggle)
mapnik 3.0.12%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 17,084 kB
  • ctags: 18,454
  • sloc: cpp: 142,516; python: 1,416; sh: 769; makefile: 170; xml: 140; lisp: 13
file content (73 lines) | stat: -rw-r--r-- 1,921 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

#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>

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);

            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_rgba8 image(m.width(), m.height());
            agg_renderer<image_rgba8> ren(m, image);
            ren.apply();

            REQUIRE(image.painted() == true);
        }
    }
    catch (std::exception const & ex)
    {
        std::clog << ex.what() << std::endl;
        REQUIRE(false);
    }

}
}