commit
7ecff4b693
7 changed files with 9923 additions and 8096 deletions
37
SConstruct
37
SConstruct
|
@ -56,8 +56,9 @@ ICU_LIBS_DEFAULT='/usr/'
|
|||
|
||||
DEFAULT_CC = "cc"
|
||||
DEFAULT_CXX = "c++"
|
||||
DEFAULT_CXX14_CXXFLAGS = " -std=c++14 -DU_USING_ICU_NAMESPACE=0"
|
||||
DEFAULT_CXX14_LINKFLAGS = ""
|
||||
DEFAULT_CXX_STD = "14"
|
||||
DEFAULT_CXX_CXXFLAGS = " -DU_USING_ICU_NAMESPACE=0"
|
||||
DEFAULT_CXX_LINKFLAGS = ""
|
||||
if sys.platform == 'darwin':
|
||||
# homebrew default
|
||||
ICU_INCLUDES_DEFAULT='/usr/local/opt/icu4c/include/'
|
||||
|
@ -355,6 +356,7 @@ opts = Variables()
|
|||
opts.AddVariables(
|
||||
# Compiler options
|
||||
('CXX', 'The C++ compiler to use to compile mapnik', DEFAULT_CXX),
|
||||
('CXX_STD', 'The C++ compiler standard (string).', DEFAULT_CXX_STD),
|
||||
('CC', 'The C compiler used for configure checks of C libs.', DEFAULT_CC),
|
||||
('CUSTOM_CXXFLAGS', 'Custom C++ flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir>', ''),
|
||||
('CUSTOM_DEFINES', 'Custom Compiler DEFINES, e.g. -DENABLE_THIS', ''),
|
||||
|
@ -487,6 +489,7 @@ opts.AddVariables(
|
|||
pickle_store = [# Scons internal variables
|
||||
'CC', # compiler user to check if c deps compile during configure
|
||||
'CXX', # C++ compiler to compile mapnik
|
||||
'CXX_STD', # C++ standard e.g 17 (as in -std=c++17)
|
||||
'CFLAGS',
|
||||
'CPPDEFINES',
|
||||
'CPPFLAGS', # c preprocessor flags
|
||||
|
@ -1227,28 +1230,29 @@ int main()
|
|||
context.Result(ret)
|
||||
return ret
|
||||
|
||||
def supports_cxx14(context,silent=False):
|
||||
__cplusplus = {'14':'201402L', '17':'201703L'}
|
||||
|
||||
def supports_cxx_std (context, silent=False):
|
||||
cplusplus_string = __cplusplus[env['CXX_STD']]
|
||||
if not silent:
|
||||
context.Message('Checking if compiler (%s) supports -std=c++14 flag... ' % context.env.get('CXX','CXX'))
|
||||
context.Message('Checking if compiler (%s) supports -std=c++%s flag... ' % (context.env.get('CXX','CXX'), env['CXX_STD']))
|
||||
ret, out = context.TryRun("""
|
||||
|
||||
int main()
|
||||
{
|
||||
#if __cplusplus >= 201402L
|
||||
#if __cplusplus >= %s
|
||||
return 0;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
""", '.cpp')
|
||||
""" % cplusplus_string ,'.cpp')
|
||||
if silent:
|
||||
context.did_show_result=1
|
||||
context.Result(ret)
|
||||
return ret
|
||||
|
||||
|
||||
|
||||
conf_tests = { 'prioritize_paths' : prioritize_paths,
|
||||
'CheckPKGConfig' : CheckPKGConfig,
|
||||
'CheckPKG' : CheckPKG,
|
||||
|
@ -1270,7 +1274,7 @@ conf_tests = { 'prioritize_paths' : prioritize_paths,
|
|||
'harfbuzz_with_freetype_support': harfbuzz_with_freetype_support,
|
||||
'boost_regex_has_icu' : boost_regex_has_icu,
|
||||
'sqlite_has_rtree' : sqlite_has_rtree,
|
||||
'supports_cxx14' : supports_cxx14,
|
||||
'supports_cxx_std' : supports_cxx_std,
|
||||
'CheckBoostScopedEnum' : CheckBoostScopedEnum,
|
||||
}
|
||||
|
||||
|
@ -1414,13 +1418,13 @@ if not preconfigured:
|
|||
|
||||
# set any custom cxxflags and ldflags to come first
|
||||
if sys.platform == 'darwin' and not env['HOST']:
|
||||
DEFAULT_CXX14_CXXFLAGS += ' -stdlib=libc++'
|
||||
DEFAULT_CXX14_LINKFLAGS = ' -stdlib=libc++'
|
||||
DEFAULT_CXX_CXXFLAGS += ' -stdlib=libc++'
|
||||
DEFAULT_CXX_LINKFLAGS = ' -stdlib=libc++'
|
||||
env.Append(CPPDEFINES = env['CUSTOM_DEFINES'])
|
||||
env.Append(CXXFLAGS = DEFAULT_CXX14_CXXFLAGS)
|
||||
env.Append(CXXFLAGS = "-std=c++%s %s" % (env['CXX_STD'], DEFAULT_CXX_CXXFLAGS))
|
||||
env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS'])
|
||||
env.Append(CFLAGS = env['CUSTOM_CFLAGS'])
|
||||
env.Append(LINKFLAGS = DEFAULT_CXX14_LINKFLAGS)
|
||||
env.Append(LINKFLAGS = DEFAULT_CXX_LINKFLAGS)
|
||||
|
||||
custom_ldflags = env.ParseFlags(env['CUSTOM_LDFLAGS'])
|
||||
env.Append(LINKFLAGS = custom_ldflags.pop('LINKFLAGS'),
|
||||
|
@ -1600,9 +1604,10 @@ if not preconfigured:
|
|||
if env['PRIORITIZE_LINKING']:
|
||||
conf.prioritize_paths(silent=True)
|
||||
|
||||
# test for C++14 support, which is required
|
||||
if not env['HOST'] and not conf.supports_cxx14():
|
||||
color_print(1,"C++ compiler does not support C++14 standard (-std=c++14), which is required. Please upgrade your compiler")
|
||||
# test for CXX_STD support, which is required
|
||||
if not env['HOST'] and not conf.supports_cxx_std():
|
||||
color_print(1,"C++ compiler does not support C++%s standard (-std=c++%s), which is required."
|
||||
" Please upgrade your compiler" % (env['CXX_STD'], env['CXX_STD']))
|
||||
Exit(1)
|
||||
|
||||
if not env['HOST']:
|
||||
|
|
|
@ -53,6 +53,10 @@
|
|||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
#include <execution>
|
||||
#endif
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
|
@ -420,19 +424,18 @@ struct is_solid_visitor
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator() (T const & data) const
|
||||
bool operator() (image_view<T> const& view) const
|
||||
{
|
||||
using pixel_type = typename T::pixel_type;
|
||||
if (data.width() > 0 && data.height() > 0)
|
||||
if (view.width() > 0 && view.height() > 0)
|
||||
{
|
||||
pixel_type const* first_row = data.get_row(0);
|
||||
pixel_type const* first_row = view.get_row(0);
|
||||
pixel_type const first_pixel = first_row[0];
|
||||
for (std::size_t y = 0; y < data.height(); ++y)
|
||||
for (std::size_t y = 0; y < view.height(); ++y)
|
||||
{
|
||||
pixel_type const * row = data.get_row(y);
|
||||
for (std::size_t x = 0; x < data.width(); ++x)
|
||||
pixel_type const * row = view.get_row(y);
|
||||
for (std::size_t x = 0; x < view.width(); ++x)
|
||||
{
|
||||
if (first_pixel != row[x])
|
||||
{
|
||||
|
@ -443,6 +446,24 @@ struct is_solid_visitor
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator() (T const& image) const
|
||||
{
|
||||
using pixel_type = typename T::pixel_type;
|
||||
if (image.size() > 0)
|
||||
{
|
||||
pixel_type const first_p = *image.begin();
|
||||
auto itr = std::find_if(/*std::execution::par_unseq,*/ // still missing on ubuntu with
|
||||
// clang++10/libc++ (!)
|
||||
image.begin(), image.end(),
|
||||
[first_p](pixel_type const p) {
|
||||
return first_p != p;
|
||||
});
|
||||
return (itr == image.end());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // end detail ns
|
||||
|
|
17864
test/catch.hpp
17864
test/catch.hpp
File diff suppressed because it is too large
Load diff
|
@ -67,6 +67,16 @@ std::pair<mapnik::datasource_ptr,mapnik::feature_ptr> fetch_first_feature(std::s
|
|||
return std::make_pair(ds,feature);
|
||||
}
|
||||
|
||||
|
||||
void iterate_over_features(mapnik::featureset_ptr features)
|
||||
{
|
||||
auto feature = features->next();
|
||||
while (feature != nullptr)
|
||||
{
|
||||
feature = features->next();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("geojson") {
|
||||
|
@ -673,12 +683,7 @@ TEST_CASE("geojson") {
|
|||
auto fields = ds->get_descriptor().get_descriptors();
|
||||
mapnik::query query(ds->envelope());
|
||||
auto features = ds->features(query);
|
||||
REQUIRE_THROWS(
|
||||
auto feature = features->next();
|
||||
while (feature != nullptr)
|
||||
{
|
||||
feature = features->next();
|
||||
});
|
||||
REQUIRE_THROWS(iterate_over_features(features));
|
||||
}
|
||||
|
||||
// cleanup
|
||||
|
|
|
@ -19,16 +19,14 @@ SECTION("test bad filter input") {
|
|||
mapnik::fill(im,mapnik::color("blue"));
|
||||
mapnik::set_pixel(im, 1, 1, mapnik::color("red"));
|
||||
|
||||
REQUIRE_THROWS( mapnik::filter::filter_image(im, "foo,asdfasdf()"); );
|
||||
REQUIRE_THROWS( mapnik::filter::filter_image(im, "colorize-alpha("); );
|
||||
REQUIRE_THROWS( mapnik::filter::filter_image(im, "color-to-alpha(blue"); );
|
||||
REQUIRE_THROWS( mapnik::filter::filter_image(im, "color-to-alpha(,blue)"); );
|
||||
REQUIRE_THROWS( mapnik::filter::filter_image(im, "colorize-alpha()"); );
|
||||
REQUIRE_THROWS( mapnik::filter::filter_image(im, "foo,asdfasdf()"));
|
||||
REQUIRE_THROWS( mapnik::filter::filter_image(im, "colorize-alpha("));
|
||||
REQUIRE_THROWS( mapnik::filter::filter_image(im, "color-to-alpha(blue"));
|
||||
REQUIRE_THROWS( mapnik::filter::filter_image(im, "color-to-alpha(,blue)"));
|
||||
REQUIRE_THROWS( mapnik::filter::filter_image(im, "colorize-alpha()"));
|
||||
|
||||
REQUIRE_THROWS(
|
||||
mapnik::image_rgba8 const& im2 = im;
|
||||
mapnik::image_rgba8 new_im = mapnik::filter::filter_image(im2, "foo");
|
||||
);
|
||||
mapnik::image_rgba8 const& im2 = im;
|
||||
REQUIRE_THROWS(mapnik::filter::filter_image(im2, "foo"));
|
||||
|
||||
CHECK(im(0,0) == 0xffff0000);
|
||||
CHECK(im(0,1) == 0xffff0000);
|
||||
|
@ -158,7 +156,7 @@ SECTION("test scale-hsla 2") {
|
|||
|
||||
// Should not throw on values out of [0, 1]
|
||||
// https://github.com/mapnik/mapnik/issues/3052
|
||||
REQUIRE_NOTHROW(mapnik::filter::filter_image(im, "scale-hsla(0.0,1.5,-1.0,1.0,-1.0,2.0,1.0,1.0)"););
|
||||
REQUIRE_NOTHROW(mapnik::filter::filter_image(im, "scale-hsla(0.0,1.5,-1.0,1.0,-1.0,2.0,1.0,1.0)"));
|
||||
|
||||
CHECK(im(0,0) == 0xff0000ff);
|
||||
CHECK(im(0,1) == 0xffefeff4);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/filesystem/convenience.hpp>
|
||||
#include <boost/optional/optional_io.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
inline void make_directory(std::string const& dir) {
|
||||
|
@ -65,7 +66,7 @@ SECTION("readers") {
|
|||
REQUIRE( mapnik::util::exists( should_throw ) );
|
||||
type = mapnik::type_from_filename(should_throw);
|
||||
REQUIRE( type );
|
||||
REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
|
||||
REQUIRE_THROWS(mapnik::get_image_reader(should_throw,*type));
|
||||
|
||||
// actually a png so jpeg reader should throw
|
||||
should_throw = "./test/data/images/landusepattern.jpg";
|
||||
|
@ -84,7 +85,7 @@ SECTION("readers") {
|
|||
|
||||
#endif
|
||||
|
||||
REQUIRE_THROWS(mapnik::image_rgba8 im(-10,-10)); // should throw rather than overflow
|
||||
REQUIRE_THROWS(mapnik::image_rgba8(-10,-10)); // should throw rather than overflow
|
||||
|
||||
#if defined(HAVE_CAIRO)
|
||||
mapnik::cairo_surface_ptr image_surface(
|
||||
|
@ -103,13 +104,13 @@ SECTION("readers") {
|
|||
REQUIRE( mapnik::util::exists( should_throw ) );
|
||||
type = mapnik::type_from_filename(should_throw);
|
||||
REQUIRE( type );
|
||||
REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
|
||||
REQUIRE_THROWS(mapnik::get_image_reader(should_throw,*type));
|
||||
|
||||
should_throw = "./test/data/images/xcode-CgBI.png";
|
||||
REQUIRE( mapnik::util::exists( should_throw ) );
|
||||
type = mapnik::type_from_filename(should_throw);
|
||||
REQUIRE( type );
|
||||
REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
|
||||
REQUIRE_THROWS(mapnik::get_image_reader(should_throw,*type));
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_TIFF)
|
||||
|
@ -117,7 +118,7 @@ SECTION("readers") {
|
|||
REQUIRE( mapnik::util::exists( should_throw ) );
|
||||
type = mapnik::type_from_filename(should_throw);
|
||||
REQUIRE( type );
|
||||
REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
|
||||
REQUIRE_THROWS(mapnik::get_image_reader(should_throw,*type));
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_WEBP)
|
||||
|
@ -125,7 +126,7 @@ SECTION("readers") {
|
|||
REQUIRE( mapnik::util::exists( should_throw ) );
|
||||
type = mapnik::type_from_filename(should_throw);
|
||||
REQUIRE( type );
|
||||
REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
|
||||
REQUIRE_THROWS(mapnik::get_image_reader(should_throw,*type));
|
||||
#endif
|
||||
}
|
||||
catch (std::exception const & ex)
|
||||
|
|
|
@ -8,33 +8,22 @@
|
|||
|
||||
#include "cleanup.hpp" // run_cleanup()
|
||||
|
||||
std::string plugin_path;
|
||||
|
||||
inline void set_plugin_path(Catch::ConfigData&, std::string const& _plugin_path ) {
|
||||
plugin_path = _plugin_path;
|
||||
}
|
||||
|
||||
std::string working_dir;
|
||||
|
||||
inline void set_working_dir(Catch::ConfigData&, std::string const& _working_dir ) {
|
||||
working_dir = _working_dir;
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char* const argv[])
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
Catch::Session session;
|
||||
std::string plugin_path;
|
||||
std::string working_dir;
|
||||
auto cli = session.cli()
|
||||
|
|
||||
Catch::clara::Opt(plugin_path, "plugins")
|
||||
["-p"]["--plugins"] ("path to mapnik plugins")
|
||||
|
|
||||
Catch::clara::Opt(working_dir, "working directory")
|
||||
["-C"]["--working-directory"] ("change working directory")
|
||||
;
|
||||
|
||||
auto & cli = session.cli();
|
||||
|
||||
cli["-p"]["--plugins"]
|
||||
.describe("path to mapnik plugins")
|
||||
.bind(&set_plugin_path, "plugins");
|
||||
|
||||
cli["-C"]["--working-directory"]
|
||||
.describe("change working directory")
|
||||
.bind(&set_working_dir, "working directory");
|
||||
|
||||
session.cli(cli);
|
||||
int result = session.applyCommandLine(argc, argv);
|
||||
|
||||
if (!plugin_path.empty())
|
||||
|
|
Loading…
Reference in a new issue