Skip to content

Commit 962cb1d

Browse files
committed
Reflect remaining objects + update unit tests [WIP] [skip ci]
1 parent 91a878c commit 962cb1d

35 files changed

Lines changed: 886 additions & 657 deletions

setup.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ def check_output(args):
5858
Pybind11Extension(
5959
"mapnik._mapnik",
6060
[
61+
"src/mapnik_python.cpp",
6162
"src/mapnik_layer.cpp",
6263
"src/mapnik_query.cpp",
6364
"src/mapnik_map.cpp",
64-
"src/mapnik_python.cpp",
6565
"src/mapnik_color.cpp",
6666
"src/mapnik_composite_modes.cpp",
6767
"src/mapnik_coord.cpp",
@@ -74,19 +74,33 @@ def check_output(args):
7474
"src/mapnik_feature.cpp",
7575
"src/mapnik_featureset.cpp",
7676
"src/mapnik_font_engine.cpp",
77+
"src/mapnik_fontset.cpp",
78+
"src/mapnik_grid.cpp",
79+
"src/mapnik_grid_view.cpp",
7780
"src/mapnik_image.cpp",
81+
"src/mapnik_image_view.cpp",
7882
"src/mapnik_projection.cpp",
7983
"src/mapnik_proj_transform.cpp",
8084
"src/mapnik_rule.cpp",
8185
"src/mapnik_symbolizer.cpp",
86+
"src/mapnik_debug_symbolizer.cpp",
87+
"src/mapnik_markers_symbolizer.cpp",
8288
"src/mapnik_polygon_symbolizer.cpp",
89+
"src/mapnik_polygon_pattern_symbolizer.cpp",
8390
"src/mapnik_line_symbolizer.cpp",
91+
"src/mapnik_line_pattern_symbolizer.cpp",
8492
"src/mapnik_point_symbolizer.cpp",
93+
"src/mapnik_raster_symbolizer.cpp",
94+
"src/mapnik_scaling_method.cpp",
8595
"src/mapnik_style.cpp",
8696
"src/mapnik_logger.cpp",
8797
"src/mapnik_placement_finder.cpp",
8898
"src/mapnik_text_symbolizer.cpp",
99+
"src/mapnik_palette.cpp",
89100
"src/mapnik_parameters.cpp",
101+
"src/python_grid_utils.cpp",
102+
"src/mapnik_raster_colorizer.cpp",
103+
"src/mapnik_label_collision_detector.cpp"
90104
],
91105
extra_compile_args=extra_comp_args,
92106
extra_link_args=linkflags,

src/mapnik_composite_modes.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* This file is part of Mapnik (c++ mapping toolkit)
44
*
5-
* Copyright (C) 2015 Artem Pavlenko, Jean-Francois Doyon
5+
* Copyright (C) 2024 Artem Pavlenko
66
*
77
* This library is free software; you can redistribute it and/or
88
* modify it under the terms of the GNU Lesser General Public
@@ -22,7 +22,6 @@
2222

2323
// mapnik
2424
#include <mapnik/config.hpp>
25-
//#include "mapnik_enumeration.hpp"
2625
#include <mapnik/image_compositing.hpp>
2726
//pybind11
2827
#include <pybind11/pybind11.h>

src/mapnik_debug_symbolizer.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*****************************************************************************
2+
*
3+
* This file is part of Mapnik (c++ mapping toolkit)
4+
*
5+
* Copyright (C) 2024 Artem Pavlenko
6+
*
7+
* This library is free software; you can redistribute it and/or
8+
* modify it under the terms of the GNU Lesser General Public
9+
* License as published by the Free Software Foundation; either
10+
* version 2.1 of the License, or (at your option) any later version.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
*****************************************************************************/
22+
23+
// mapnik
24+
#include <mapnik/config.hpp>
25+
#include <mapnik/symbolizer.hpp>
26+
#include <mapnik/symbolizer_hash.hpp>
27+
#include <mapnik/symbolizer_utils.hpp>
28+
#include <mapnik/symbolizer_keys.hpp>
29+
#include "mapnik_symbolizer.hpp"
30+
//pybind11
31+
#include <pybind11/pybind11.h>
32+
33+
namespace py = pybind11;
34+
35+
void export_debug_symbolizer(py::module const& m)
36+
{
37+
using namespace python_mapnik;
38+
using mapnik::debug_symbolizer;
39+
using mapnik::debug_symbolizer_mode_enum;
40+
41+
py::enum_<debug_symbolizer_mode_enum>(m, "debug_symbolizer_mode")
42+
.value("COLLISION", debug_symbolizer_mode_enum::DEBUG_SYM_MODE_COLLISION)
43+
.value("VERTEX", debug_symbolizer_mode_enum::DEBUG_SYM_MODE_VERTEX)
44+
;
45+
46+
py::class_<debug_symbolizer, symbolizer_base>(m, "DebugSymbolizer")
47+
.def(py::init<>(), "Default ctor")
48+
.def("__hash__", hash_impl_2<debug_symbolizer>)
49+
.def_property("mode",
50+
&get<debug_symbolizer_mode_enum, mapnik::keys::mode>,
51+
&set_enum_property<debug_symbolizer, debug_symbolizer_mode_enum, mapnik::keys::mode>)
52+
;
53+
54+
}

src/mapnik_expression.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
//pybind11
3636
#include <pybind11/pybind11.h>
37+
#include <pybind11/stl.h>
38+
#include <pybind11/stl_bind.h>
3739

3840
using mapnik::expression_ptr;
3941
using mapnik::parse_expression;
@@ -42,6 +44,8 @@ using mapnik::path_expression_ptr;
4244

4345
namespace py = pybind11;
4446

47+
PYBIND11_MAKE_OPAQUE(mapnik::path_expression);
48+
4549
// expression
4650
expression_ptr parse_expression_(std::string const& wkt)
4751
{
@@ -82,7 +86,7 @@ std::string path_evaluate_(mapnik::path_expression const& expr, mapnik::feature_
8286
return mapnik::path_processor_type::evaluate(expr, f);
8387
}
8488

85-
void export_expression(py::module & m)
89+
void export_expression(py::module const& m)
8690
{
8791
py::class_<mapnik::expr_node, mapnik::expression_ptr>(m, "Expression")
8892
.def(py::init([] (std::string const& wkt) { return parse_expression_(wkt);}))

src/mapnik_fontset.cpp

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* This file is part of Mapnik (c++ mapping toolkit)
44
*
5-
* Copyright (C) 2015 Artem Pavlenko
5+
* Copyright (C) 2024 Artem Pavlenko
66
*
77
* This library is free software; you can redistribute it and/or
88
* modify it under the terms of the GNU Lesser General Public
@@ -20,42 +20,34 @@
2020
*
2121
*****************************************************************************/
2222

23-
#include <mapnik/config.hpp>
24-
25-
26-
#pragma GCC diagnostic push
27-
#include <mapnik/warning_ignore.hpp>
28-
#include <boost/python.hpp>
29-
#include <boost/noncopyable.hpp>
30-
#pragma GCC diagnostic pop
31-
3223
//mapnik
24+
#include <mapnik/config.hpp>
3325
#include <mapnik/font_set.hpp>
26+
//pybind11
27+
#include <pybind11/pybind11.h>
3428

29+
namespace py = pybind11;
3530

3631
using mapnik::font_set;
3732

38-
void export_fontset ()
33+
void export_fontset (py::module const& m)
3934
{
40-
using namespace boost::python;
41-
class_<font_set>("FontSet", init<std::string const&>("default fontset constructor")
42-
)
43-
.add_property("name",
44-
make_function(&font_set::get_name,return_value_policy<copy_const_reference>()),
35+
py::class_<font_set>(m, "FontSet")
36+
.def(py::init<std::string const&>(), "default fontset constructor")
37+
.def_property("name",
38+
&font_set::get_name,
4539
&font_set::set_name,
4640
"Get/Set the name of the FontSet.\n"
4741
)
48-
.def("add_face_name",&font_set::add_face_name,
49-
(arg("name")),
42+
.def("add_face_name", &font_set::add_face_name,
5043
"Add a face-name to the fontset.\n"
5144
"\n"
5245
"Example:\n"
5346
">>> fs = Fontset('book-fonts')\n"
54-
">>> fs.add_face_name('DejaVu Sans Book')\n")
55-
.add_property("names",make_function
56-
(&font_set::get_face_names,
57-
return_value_policy<reference_existing_object>()),
58-
"List of face names belonging to a FontSet.\n"
59-
)
47+
">>> fs.add_face_name('DejaVu Sans Book')\n",
48+
py::arg("name"))
49+
.def_property_readonly("names",
50+
&font_set::get_face_names,
51+
"List of face names belonging to a FontSet.\n")
6052
;
6153
}

src/mapnik_grid.cpp

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* This file is part of Mapnik (c++ mapping toolkit)
44
*
5-
* Copyright (C) 2015 Artem Pavlenko
5+
* Copyright (C) 2024 Artem Pavlenko
66
*
77
* This library is free software; you can redistribute it and/or
88
* modify it under the terms of the GNU Lesser General Public
@@ -21,25 +21,18 @@
2121
*****************************************************************************/
2222

2323
#if defined(GRID_RENDERER)
24-
25-
#include <mapnik/config.hpp>
26-
27-
28-
#pragma GCC diagnostic push
29-
#include <mapnik/warning_ignore.hpp>
30-
#include <boost/python.hpp>
31-
#include <boost/python/module.hpp>
32-
#include <boost/python/def.hpp>
33-
#pragma GCC diagnostic pop
34-
3524
// mapnik
25+
#include <mapnik/config.hpp>
3626
#include <mapnik/grid/grid.hpp>
3727
#include "python_grid_utils.hpp"
3828

39-
using namespace boost::python;
29+
//pybind11
30+
#include <pybind11/pybind11.h>
31+
32+
namespace py = pybind11;
4033

4134
// help compiler see template definitions
42-
static dict (*encode)( mapnik::grid const&, std::string const& , bool, unsigned int) = mapnik::grid_encode;
35+
static py::dict (*encode)( mapnik::grid const&, std::string const& , bool, unsigned int) = mapnik::grid_encode;
4336

4437
bool painted(mapnik::grid const& grid)
4538
{
@@ -53,32 +46,27 @@ mapnik::grid::value_type get_pixel(mapnik::grid const& grid, int x, int y)
5346
mapnik::grid::data_type const & data = grid.data();
5447
return data(x,y);
5548
}
56-
PyErr_SetString(PyExc_IndexError, "invalid x,y for grid dimensions");
57-
boost::python::throw_error_already_set();
58-
return 0;
49+
throw py::index_error("invalid x,y for grid dimensions");
5950
}
6051

61-
void export_grid()
52+
void export_grid(py::module const& m)
6253
{
63-
class_<mapnik::grid,std::shared_ptr<mapnik::grid> >(
64-
"Grid",
65-
"This class represents a feature hitgrid.",
66-
init<int,int,std::string>(
67-
( boost::python::arg("width"), boost::python::arg("height"),boost::python::arg("key")="__id__"),
68-
"Create a mapnik.Grid object\n"
69-
))
54+
py::class_<mapnik::grid, std::shared_ptr<mapnik::grid>>
55+
(m, "Grid", "This class represents a feature hitgrid.")
56+
.def(py::init<int,int,std::string>(),
57+
"Create a mapnik.Grid object\n",
58+
py::arg("width"), py::arg("height"), py::arg("key")="__id__")
7059
.def("painted",&painted)
7160
.def("width",&mapnik::grid::width)
7261
.def("height",&mapnik::grid::height)
7362
.def("view",&mapnik::grid::get_view)
7463
.def("get_pixel",&get_pixel)
7564
.def("clear",&mapnik::grid::clear)
76-
.def("encode",encode,
77-
( boost::python::arg("encoding")="utf", boost::python::arg("features")=true,boost::python::arg("resolution")=4 ),
78-
"Encode the grid as as optimized json\n"
79-
)
80-
.add_property("key",
81-
make_function(&mapnik::grid::get_key,return_value_policy<copy_const_reference>()),
65+
.def("encode", encode,
66+
"Encode the grid as as optimized json\n",
67+
py::arg("encoding") = "utf", py::arg("features") = true, py::arg("resolution") = 4)
68+
.def_property("key",
69+
&mapnik::grid::get_key,
8270
&mapnik::grid::set_key,
8371
"Get/Set key to be used as unique indentifier for features\n"
8472
"The value should either be __id__ to refer to the feature.id()\n"

src/mapnik_grid_view.cpp

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* This file is part of Mapnik (c++ mapping toolkit)
44
*
5-
* Copyright (C) 2015 Artem Pavlenko
5+
* Copyright (C) 2024 Artem Pavlenko
66
*
77
* This library is free software; you can redistribute it and/or
88
* modify it under the terms of the GNU Lesser General Public
@@ -21,39 +21,25 @@
2121
*****************************************************************************/
2222

2323
#if defined(GRID_RENDERER)
24-
25-
#include <mapnik/config.hpp>
26-
27-
28-
#pragma GCC diagnostic push
29-
#include <mapnik/warning_ignore.hpp>
30-
#include <boost/python.hpp>
31-
#include <boost/python/module.hpp>
32-
#include <boost/python/def.hpp>
33-
#pragma GCC diagnostic pop
34-
3524
// mapnik
25+
#include <mapnik/config.hpp>
3626
#include <string>
3727
#include <mapnik/grid/grid_view.hpp>
3828
#include <mapnik/grid/grid.hpp>
3929
#include "python_grid_utils.hpp"
4030

41-
using namespace boost::python;
42-
4331
// help compiler see template definitions
44-
static dict (*encode)( mapnik::grid_view const&, std::string const& , bool, unsigned int) = mapnik::grid_encode;
32+
static py::dict (*encode)( mapnik::grid_view const&, std::string const& , bool, unsigned int) = mapnik::grid_encode;
4533

46-
void export_grid_view()
34+
void export_grid_view(py::module const& m)
4735
{
48-
class_<mapnik::grid_view,
49-
std::shared_ptr<mapnik::grid_view> >("GridView",
50-
"This class represents a feature hitgrid subset.",no_init)
36+
py::class_<mapnik::grid_view, std::shared_ptr<mapnik::grid_view>>
37+
(m, "GridView", "This class represents a feature hitgrid subset.")
5138
.def("width",&mapnik::grid_view::width)
5239
.def("height",&mapnik::grid_view::height)
5340
.def("encode",encode,
54-
( boost::python::arg("encoding")="utf",boost::python::arg("add_features")=true,boost::python::arg("resolution")=4 ),
55-
"Encode the grid as as optimized json\n"
56-
)
41+
"Encode the grid as as optimized json\n",
42+
py::arg("encoding")="utf",py::arg("add_features")=true,py::arg("resolution")=4)
5743
;
5844
}
5945

0 commit comments

Comments
 (0)