Skip to content

Commit 0f0b048

Browse files
committed
Reflect font_engine,gamma_method + test/python_tests/datasource_test.py:ds.all_features() --> iter(ds)
Remove boost::python namespace
1 parent 50cc443 commit 0f0b048

File tree

5 files changed

+40
-44
lines changed

5 files changed

+40
-44
lines changed

setup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ def check_output(args):
6363
"src/mapnik_composite_modes.cpp",
6464
"src/mapnik_coord.cpp",
6565
"src/mapnik_envelope.cpp",
66-
"src/mapnik_geometry.cpp",
67-
"src/mapnik_feature.cpp",
68-
"src/mapnik_featureset.cpp",
6966
"src/mapnik_expression.cpp",
7067
"src/mapnik_datasource.cpp",
7168
"src/mapnik_datasource_cache.cpp",
69+
"src/mapnik_gamma_method.cpp",
70+
"src/mapnik_geometry.cpp",
71+
"src/mapnik_feature.cpp",
72+
"src/mapnik_featureset.cpp",
73+
"src/mapnik_font_engine.cpp",
7274
"src/mapnik_image.cpp",
7375
"src/mapnik_projection.cpp",
7476
"src/mapnik_proj_transform.cpp",

src/mapnik_font_engine.cpp

Lines changed: 13 additions & 17 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
@@ -20,25 +20,21 @@
2020
*
2121
*****************************************************************************/
2222

23+
//mapnik
2324
#include <mapnik/config.hpp>
24-
25-
#pragma GCC diagnostic push
26-
#include <mapnik/warning_ignore.hpp>
27-
#include <boost/python.hpp>
28-
#include <boost/noncopyable.hpp>
29-
#pragma GCC diagnostic pop
30-
3125
#include <mapnik/font_engine_freetype.hpp>
26+
//pybind11
27+
#include <pybind11/pybind11.h>
3228

33-
void export_font_engine()
29+
namespace py = pybind11;
30+
31+
void export_font_engine(py::module const& m)
3432
{
3533
using mapnik::freetype_engine;
36-
using namespace boost::python;
37-
class_<freetype_engine, boost::noncopyable>("FontEngine", no_init)
38-
.def("register_font", &freetype_engine::register_font)
39-
.def("register_fonts", &freetype_engine::register_fonts)
40-
.def("face_names", &freetype_engine::face_names)
41-
.staticmethod("register_font")
42-
.staticmethod("register_fonts")
43-
.staticmethod("face_names");
34+
35+
py::class_<freetype_engine>(m, "FontEngine")
36+
.def_static("register_font", &freetype_engine::register_font)
37+
.def_static("register_fonts", &freetype_engine::register_fonts)
38+
.def_static("face_names", &freetype_engine::face_names)
39+
;
4440
}

src/mapnik_gamma_method.cpp

Lines changed: 8 additions & 13 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
@@ -20,22 +20,17 @@
2020
*
2121
*****************************************************************************/
2222

23+
// mapnik
2324
#include <mapnik/config.hpp>
24-
25-
#pragma GCC diagnostic push
26-
#include <mapnik/warning_ignore.hpp>
27-
#include <boost/python.hpp>
28-
#include <boost/noncopyable.hpp>
29-
#pragma GCC diagnostic pop
30-
3125
#include <mapnik/symbolizer_enumerations.hpp>
32-
#include "mapnik_enumeration.hpp"
26+
//pybind11
27+
#include <pybind11/pybind11.h>
3328

34-
void export_gamma_method()
35-
{
36-
using namespace boost::python;
29+
namespace py = pybind11;
3730

38-
mapnik::enumeration_<mapnik::gamma_method_e>("gamma_method")
31+
void export_gamma_method(py::module const& m)
32+
{
33+
py::enum_<mapnik::gamma_method_enum>(m, "gamma_method")
3934
.value("POWER", mapnik::gamma_method_enum::GAMMA_POWER)
4035
.value("LINEAR",mapnik::gamma_method_enum::GAMMA_LINEAR)
4136
.value("NONE", mapnik::gamma_method_enum::GAMMA_NONE)

src/mapnik_python.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,11 @@ void export_color(py::module const&);
113113
void export_composite_modes(py::module const&);
114114
void export_coord(py::module const&);
115115
void export_envelope(py::module const&);
116+
void export_gamma_method(py::module const&);
116117
void export_geometry(py::module const&);
117118
void export_feature(py::module const&);
118119
void export_featureset(py::module const&);
120+
void export_font_engine(py::module const&);
119121
void export_expression(py::module&);
120122
void export_datasource(py::module&);
121123
void export_datasource_cache(py::module const&);
@@ -129,8 +131,10 @@ PYBIND11_MODULE(_mapnik, m) {
129131
export_coord(m);
130132
export_envelope(m);
131133
export_geometry(m);
134+
export_gamma_method(m);
132135
export_feature(m);
133136
export_featureset(m);
137+
export_font_engine(m);
134138
export_expression(m);
135139
export_datasource(m);
136140
export_datasource_cache(m);

test/python_tests/datasource_test.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_field_listing():
7171
def test_total_feature_count_shp():
7272
if 'shape' in mapnik.DatasourceCache.plugin_names():
7373
ds = mapnik.Shapefile(file='../data/shp/poly.shp')
74-
features = ds.all_features()
74+
features = iter(ds)
7575
num_feats = len(list(features))
7676
assert num_feats == 10
7777

@@ -83,7 +83,7 @@ def test_total_feature_count_json():
8383
assert desc['name'] == 'ogr'
8484
assert desc['type'] == mapnik.DataType.Vector
8585
assert desc['encoding'] == 'utf-8'
86-
features = ds.all_features()
86+
features = iter(ds)
8787
num_feats = len(list(features))
8888
assert num_feats == 5
8989

@@ -98,7 +98,7 @@ def test_sqlite_reading():
9898
assert desc['name'] == 'sqlite'
9999
assert desc['type'] == mapnik.DataType.Vector
100100
assert desc['encoding'] == 'utf-8'
101-
features = ds.all_features()
101+
features = iter(ds)
102102
num_feats = len(list(features))
103103
assert num_feats == 245
104104

@@ -108,16 +108,15 @@ def test_reading_json_from_string():
108108
json = f.read()
109109
if 'ogr' in mapnik.DatasourceCache.plugin_names():
110110
ds = mapnik.Ogr(file=json, layer_by_index=0)
111-
features = ds.all_features()
111+
features = iter(ds)
112112
num_feats = len(list(features))
113113
assert num_feats == 5
114114

115115

116116
def test_feature_envelope():
117117
if 'shape' in mapnik.DatasourceCache.plugin_names():
118118
ds = mapnik.Shapefile(file='../data/shp/poly.shp')
119-
features = ds.all_features()
120-
for feat in features:
119+
for feat in ds:
121120
env = feat.envelope()
122121
contains = ds.envelope().contains(env)
123122
assert contains == True
@@ -128,19 +127,19 @@ def test_feature_envelope():
128127
def test_feature_attributes():
129128
if 'shape' in mapnik.DatasourceCache.plugin_names():
130129
ds = mapnik.Shapefile(file='../data/shp/poly.shp')
131-
features = list(ds.all_features())
130+
features = list(iter(ds))
132131
feat = features[0]
133-
attrs = {'PRFEDEA': u'35043411', 'EAS_ID': 168, 'AREA': 215229.266}
132+
attrs = {'AREA': 215229.266, 'EAS_ID': 168, 'PRFEDEA': '35043411'}
134133
assert feat.attributes == attrs
135-
assert ds.fields(), ['AREA', 'EAS_ID' == 'PRFEDEA']
136-
assert ds.field_types(), ['float', 'int' == 'str']
134+
assert ds.fields(), ['AREA', 'EAS_ID', 'PRFEDEA']
135+
assert ds.field_types(), ['float', 'int', 'str']
137136

138137

139138
def test_ogr_layer_by_sql():
140139
if 'ogr' in mapnik.DatasourceCache.plugin_names():
141140
ds = mapnik.Ogr(file='../data/shp/poly.shp',
142141
layer_by_sql='SELECT * FROM poly WHERE EAS_ID = 168')
143-
features = ds.all_features()
142+
features = iter(ds)
144143
num_feats = len(list(features))
145144
assert num_feats == 1
146145

0 commit comments

Comments
 (0)