This is an automated email from the git hooks/post-receive script. sebastic pushed a commit to branch master in repository python-mapnik.
commit d2fe6aaf9365fb94b4ab5d6f61cef51635ee978f Author: Bas Couwenberg <[email protected]> Date: Mon Jun 5 20:13:10 2017 +0200 Imported Upstream version 0.0~20170602-1635afe --- mapnik/__init__.py | 2 +- setup.py | 2 ++ src/mapnik_font_engine.cpp | 22 ++++----------- src/mapnik_geometry.cpp | 6 ++-- test/python_tests/geometry_io_test.py | 52 +++++++++++++++++++---------------- test/python_tests/postgis_test.py | 9 ++---- 6 files changed, 42 insertions(+), 51 deletions(-) diff --git a/mapnik/__init__.py b/mapnik/__init__.py index 1d28848..4d99ad1 100644 --- a/mapnik/__init__.py +++ b/mapnik/__init__.py @@ -1065,7 +1065,7 @@ def register_fonts(path=None, valid_extensions=[ for dirpath, _, filenames in os.walk(path): for filename in filenames: if os.path.splitext(filename.lower())[1] in valid_extensions: - FontEngine.instance().register_font(os.path.join(dirpath, filename)) + FontEngine.register_font(os.path.join(dirpath, filename)) # auto-register known plugins and fonts register_plugins() diff --git a/setup.py b/setup.py index 9d9e665..a0654de 100755 --- a/setup.py +++ b/setup.py @@ -227,6 +227,8 @@ if mason_build: extra_comp_args = check_output([mapnik_config, '--cflags']).split(' ') +extra_comp_args = list(filter(lambda arg: arg != "-fvisibility=hidden", extra_comp_args)) + if os.environ.get("PYCAIRO", "false") == "true": try: extra_comp_args.append('-DHAVE_PYCAIRO') diff --git a/src/mapnik_font_engine.cpp b/src/mapnik_font_engine.cpp index 629618a..c539938 100644 --- a/src/mapnik_font_engine.cpp +++ b/src/mapnik_font_engine.cpp @@ -21,7 +21,6 @@ *****************************************************************************/ #include <mapnik/config.hpp> -#include "boost_std_shared_shim.hpp" #pragma GCC diagnostic push #include <mapnik/warning_ignore.hpp> @@ -30,27 +29,16 @@ #pragma GCC diagnostic pop #include <mapnik/font_engine_freetype.hpp> -#include <mapnik/util/singleton.hpp> void export_font_engine() { using mapnik::freetype_engine; - using mapnik::singleton; - using mapnik::CreateStatic; using namespace boost::python; - class_<singleton<freetype_engine,CreateStatic>,boost::noncopyable>("Singleton",no_init) - .def("instance",&singleton<freetype_engine,CreateStatic>::instance, - return_value_policy<reference_existing_object>()) - .staticmethod("instance") - ; - - class_<freetype_engine,bases<singleton<freetype_engine,CreateStatic> >, - boost::noncopyable>("FontEngine",no_init) - .def("register_font",&freetype_engine::register_font) - .def("register_fonts",&freetype_engine::register_fonts) - .def("face_names",&freetype_engine::face_names) + class_<freetype_engine, boost::noncopyable>("FontEngine", no_init) + .def("register_font", &freetype_engine::register_font) + .def("register_fonts", &freetype_engine::register_fonts) + .def("face_names", &freetype_engine::face_names) .staticmethod("register_font") .staticmethod("register_fonts") - .staticmethod("face_names") - ; + .staticmethod("face_names"); } diff --git a/src/mapnik_geometry.cpp b/src/mapnik_geometry.cpp index 1181c06..688f5de 100644 --- a/src/mapnik_geometry.cpp +++ b/src/mapnik_geometry.cpp @@ -117,12 +117,12 @@ PyObject* to_wkb_impl(mapnik::geometry::geometry<double> const& geom, mapnik::wk std::string to_geojson_impl(mapnik::geometry::geometry<double> const& geom) { - std::string wkt; - if (!mapnik::util::to_geojson(wkt, geom)) + std::string json; + if (!mapnik::util::to_geojson(json, geom)) { throw std::runtime_error("Generate JSON failed"); } - return wkt; + return json; } std::string to_wkt_impl(mapnik::geometry::geometry<double> const& geom) diff --git a/test/python_tests/geometry_io_test.py b/test/python_tests/geometry_io_test.py index e51686c..f1bac0b 100644 --- a/test/python_tests/geometry_io_test.py +++ b/test/python_tests/geometry_io_test.py @@ -3,7 +3,7 @@ import os from binascii import unhexlify -from nose.tools import eq_ +from nose.tools import eq_, assert_raises import mapnik @@ -101,23 +101,25 @@ geojson_reversed = [ '{"coordinates":[[[[-178.32319,71.518365],[-178.321586,71.518439],[-178.259635,71.510688],[-178.304862,71.513129],[-178.32319,71.518365]]],[[[-178.32319,71.518365],[-178.341544,71.517524],[-178.32244,71.505439],[-178.215323,71.478034],[-178.193473,71.47663],[-178.147757,71.485175],[-178.124442,71.481879],[-178.005729,71.448615],[-178.017203,71.441413],[-178.054191,71.428778],[-178.047049,71.425727],[-178.033439,71.417792],[-178.026236,71.415107],[-178.030082,71.413459],[-178.039908,7 [...] ] -geojson_nulls = [ - '{ "type": "Feature", "properties": { }, "geometry": null }', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [] ] ] } }', - '{ "type": "Feature", "properties": { }, "geometry": { "coordinates": [], "type": "Point" }}', - '{ "type": "Feature", "properties": { }, "geometry": { "coordinates": [ [] ], "type": "LineString" }}', - '{ "type": "Feature", "properties": { }, "geometry": { "coordinates": [ [ [] ] ], "type": "Polygon" } }', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPoint", "coordinates": [ [] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPoint", "coordinates": [ [],[] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiLineString", "coordinates": [ [] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiLineString", "coordinates": [ [ [] ] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPolygon", "coordinates": [ [] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [] ] ] }}', - '{ "type": "Feature", "properties": { }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [] ] ] ] }}', +valid_empty_geometries = [ + 'null', # Point can't be empty + '{ "type": "LineString" , "coordinates": []}', + '{ "type": "Polygon" , "coordinates": [[]]}', + '{ "type": "MultiPoint" , "coordinates": []}', + '{ "type": "MultiLineString" , "coordinates": [[]]}', + '{ "type": "MultiPolygon" , "coordinates": [[[]]]}', ] +invalid_empty_geometries = [ + '{ "type": "Point" , "coordinates": []}', # Point can't be empty + '{ "type": "LineString" , "coordinates": [[]]}', + '{ "type": "Polygon" , "coordinates": [[[]]]}', + '{ "type": "MultiPoint" , "coordinates": [[]]}', + '{ "type": "MultiLineString" , "coordinates": [[[]]]}', + '{ "type": "MultiPolygon" , "coordinates": [[[[]]]]}', +] + + # valid, but empty wkb's # (http://trac.osgeo.org/postgis/wiki/DevWikiEmptyGeometry) empty_wkbs = [ @@ -329,15 +331,17 @@ def test_creating_feature_from_geojson(): eq_(feat['name'], u'value') -def test_handling_geojson_null_geoms(): - for j in geojson_nulls: - ctx = mapnik.Context() - out_json = mapnik.Feature.from_geojson(j, ctx).to_geojson() - expected = '{"type":"Feature","id":1,"geometry":null,"properties":{}}' - eq_(out_json, expected) - # ensure it round trips - eq_(mapnik.Feature.from_geojson(out_json, ctx).to_geojson(), expected) +def test_handling_valid_geojson_empty_geometries(): + for json in valid_empty_geometries: + geom = mapnik.Geometry.from_geojson(json) + out_json = geom.to_geojson() + # check round trip + eq_(json.replace(" ",""), out_json) + +def test_handling_invalid_geojson_empty_geometries(): + for json in invalid_empty_geometries: + assert_raises(RuntimeError, mapnik.Geometry.from_geojson, json) if __name__ == "__main__": setup() diff --git a/test/python_tests/postgis_test.py b/test/python_tests/postgis_test.py index bafda20..a03d3a1 100644 --- a/test/python_tests/postgis_test.py +++ b/test/python_tests/postgis_test.py @@ -728,7 +728,7 @@ if 'postgis' in mapnik.DatasourceCache.plugin_names() \ table='test', max_size=20, geometry_field='geom') - fs = ds.all_features() + fs = list(ds.all_features()) eq_(len(fs), 8) meta = ds.describe() @@ -967,8 +967,7 @@ if 'postgis' in mapnik.DatasourceCache.plugin_names() \ failed = False try: fs = ds_bad.featureset() - for feature in fs.features: - pass + count = sum(1 for f in fs) except RuntimeError as e: assert 'invalid input syntax for integer' in str(e) failed = True @@ -977,9 +976,7 @@ if 'postgis' in mapnik.DatasourceCache.plugin_names() \ # Should be ok fs = ds_good.featureset() - count = 0 - for feature in fs.features: - count += 1 + count = sum(1 for f in fs) eq_(count, 8) def test_psql_error_should_give_back_connections_opened_for_lower_layers_to_the_pool(): -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/python-mapnik.git _______________________________________________ Pkg-grass-devel mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

