Merge branch 'master' into harfbuzz

This commit is contained in:
Hermann Kraus 2013-03-28 12:22:31 +01:00
commit b4e10cfb77
16 changed files with 195 additions and 71 deletions

View file

@ -275,6 +275,7 @@ opts.AddVariables(
('WARNING_CXXFLAGS', 'Compiler flags you can set to reduce warning levels which are placed after -Wall.', ''), ('WARNING_CXXFLAGS', 'Compiler flags you can set to reduce warning levels which are placed after -Wall.', ''),
# SCons build behavior options # SCons build behavior options
('HOST', 'Set the target host for cross compiling"', ''),
('CONFIG', "The path to the python file in which to save user configuration options. Currently : '%s'" % SCONS_LOCAL_CONFIG,SCONS_LOCAL_CONFIG), ('CONFIG', "The path to the python file in which to save user configuration options. Currently : '%s'" % SCONS_LOCAL_CONFIG,SCONS_LOCAL_CONFIG),
BoolVariable('USE_CONFIG', "Use SCons user '%s' file (will also write variables after successful configuration)", 'True'), BoolVariable('USE_CONFIG', "Use SCons user '%s' file (will also write variables after successful configuration)", 'True'),
# http://www.scons.org/wiki/GoFastButton # http://www.scons.org/wiki/GoFastButton
@ -354,7 +355,7 @@ PathVariable.PathAccept),
# Variables for logging and statistics # Variables for logging and statistics
BoolVariable('ENABLE_LOG', 'Enable logging, which is enabled by default when building in *debug*', 'False'), BoolVariable('ENABLE_LOG', 'Enable logging, which is enabled by default when building in *debug*', 'False'),
BoolVariable('ENABLE_STATS', 'Enable global statistics during map processing', 'False'), BoolVariable('ENABLE_STATS', 'Enable global statistics during map processing', 'False'),
('DEFAULT_LOG_SEVERITY', 'The default severity of the logger (eg. ' + ', '.join(severities), 'error'), ('DEFAULT_LOG_SEVERITY', 'The default severity of the logger (eg. ' + ', '.join(severities) + ')', 'error'),
# Other variables # Other variables
BoolVariable('SHAPE_MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'), BoolVariable('SHAPE_MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'),
@ -1192,6 +1193,7 @@ if not preconfigured:
if env['PRIORITIZE_LINKING']: if env['PRIORITIZE_LINKING']:
conf.prioritize_paths(silent=False) conf.prioritize_paths(silent=False)
if not env['HOST']:
for libname, headers, required, lang in LIBSHEADERS: for libname, headers, required, lang in LIBSHEADERS:
if not conf.CheckLibWithHeader(libname, headers, lang): if not conf.CheckLibWithHeader(libname, headers, lang):
if required: if required:
@ -1201,6 +1203,7 @@ if not preconfigured:
color_print(4, 'Could not find optional header or shared library for %s' % libname) color_print(4, 'Could not find optional header or shared library for %s' % libname)
env['SKIPPED_DEPS'].append(libname) env['SKIPPED_DEPS'].append(libname)
if not env['HOST']:
if env['ICU_LIB_NAME'] not in env['MISSING_DEPS']: if env['ICU_LIB_NAME'] not in env['MISSING_DEPS']:
if not conf.icu_at_least_four_two(): if not conf.icu_at_least_four_two():
# expression_string.cpp and map.cpp use fromUTF* function only available in >= ICU 4.2 # expression_string.cpp and map.cpp use fromUTF* function only available in >= ICU 4.2
@ -1239,6 +1242,7 @@ if not preconfigured:
if env['PRIORITIZE_LINKING']: if env['PRIORITIZE_LINKING']:
conf.prioritize_paths() conf.prioritize_paths()
if not env['HOST']:
# if the user is not setting custom boost configuration # if the user is not setting custom boost configuration
# enforce boost version greater than or equal to BOOST_MIN_VERSION # enforce boost version greater than or equal to BOOST_MIN_VERSION
if not conf.CheckBoost(BOOST_MIN_VERSION): if not conf.CheckBoost(BOOST_MIN_VERSION):
@ -1249,6 +1253,7 @@ if not preconfigured:
else: else:
color_print(4,'Found boost lib version... %s' % env.get('BOOST_LIB_VERSION_FROM_HEADER') ) color_print(4,'Found boost lib version... %s' % env.get('BOOST_LIB_VERSION_FROM_HEADER') )
if not env['HOST']:
for count, libinfo in enumerate(BOOST_LIBSHEADERS): for count, libinfo in enumerate(BOOST_LIBSHEADERS):
if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++'): if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++'):
if libinfo[2]: if libinfo[2]:
@ -1484,6 +1489,7 @@ if not preconfigured:
env['BOOST_PYTHON_LIB'] = 'boost_python3%s' % env['BOOST_APPEND'] env['BOOST_PYTHON_LIB'] = 'boost_python3%s' % env['BOOST_APPEND']
elif env['BOOST_PYTHON_LIB'] == 'boost_python': elif env['BOOST_PYTHON_LIB'] == 'boost_python':
env['BOOST_PYTHON_LIB'] = 'boost_python%s' % env['BOOST_APPEND'] env['BOOST_PYTHON_LIB'] = 'boost_python%s' % env['BOOST_APPEND']
if not env['HOST']:
if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'): if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'):
color_print(1,'Could not find required header files for boost python') color_print(1,'Could not find required header files for boost python')
env['MISSING_DEPS'].append('boost python') env['MISSING_DEPS'].append('boost python')
@ -1558,9 +1564,9 @@ if not preconfigured:
# Common debugging flags. # Common debugging flags.
# http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html # http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html
debug_flags = '-g -fno-omit-frame-pointer' debug_flags = ['-g', '-fno-omit-frame-pointer']
debug_defines = '-DDEBUG -DMAPNIK_DEBUG' debug_defines = ['-DDEBUG', '-DMAPNIK_DEBUG']
ndebug_defines = '-DNDEBUG' ndebug_defines = ['-DNDEBUG']
# Enable logging in debug mode (always) and release mode (when specified) # Enable logging in debug mode (always) and release mode (when specified)
if env['DEFAULT_LOG_SEVERITY']: if env['DEFAULT_LOG_SEVERITY']:
@ -1575,7 +1581,7 @@ if not preconfigured:
color_print(1,"No logger severity specified, available options are %s." % severities_list) color_print(1,"No logger severity specified, available options are %s." % severities_list)
Exit(1) Exit(1)
log_enabled = ' -DMAPNIK_LOG -DMAPNIK_DEFAULT_LOG_SEVERITY=%d' % log_severity log_enabled = ['-DMAPNIK_LOG', '-DMAPNIK_DEFAULT_LOG_SEVERITY=%d' % log_severity]
if env['DEBUG']: if env['DEBUG']:
debug_defines += log_enabled debug_defines += log_enabled
@ -1585,8 +1591,8 @@ if not preconfigured:
# Enable statistics reporting # Enable statistics reporting
if env['ENABLE_STATS']: if env['ENABLE_STATS']:
debug_defines += ' -DMAPNIK_STATS' debug_defines.append('-DMAPNIK_STATS')
ndebug_defines += ' -DMAPNIK_STATS' ndebug_defines.append('-DMAPNIK_STATS')
# Add rdynamic to allow using statics between application and plugins # Add rdynamic to allow using statics between application and plugins
# http://stackoverflow.com/questions/8623657/multiple-instances-of-singleton-across-shared-libraries-on-linux # http://stackoverflow.com/questions/8623657/multiple-instances-of-singleton-across-shared-libraries-on-linux

View file

@ -76,6 +76,15 @@ private:
mutable void * proj_ctx_; mutable void * proj_ctx_;
}; };
template <typename charT, typename traits>
std::basic_ostream<charT, traits> &
operator << ( std::basic_ostream<charT, traits> & s, mapnik::projection const& p )
{
s << "projection(\"" << p.params() << "\")";
return s;
}
} }
#endif // MAPNIK_PROJECTION_HPP #endif // MAPNIK_PROJECTION_HPP

View file

@ -24,6 +24,7 @@
#define MAPNIK_SQLITE_PREPARED_HPP #define MAPNIK_SQLITE_PREPARED_HPP
// mapnik // mapnik
#include <mapnik/debug.hpp>
#include <mapnik/datasource.hpp> #include <mapnik/datasource.hpp>
#include <mapnik/params.hpp> #include <mapnik/params.hpp>
#include <mapnik/box2d.hpp> #include <mapnik/box2d.hpp>
@ -77,11 +78,13 @@ public:
{ {
if (*(*ds_)) if (*(*ds_))
{ {
std::cerr << "ERR:" << sqlite3_errmsg(*(*ds_)) << "\n"; MAPNIK_LOG_ERROR(sqlite) << "~prepared_index_statement:"
<< sqlite3_errmsg(*(*ds_));
} }
else else
{ {
std::cerr << "SQLite Plugin: " << res << "\n"; MAPNIK_LOG_ERROR(sqlite) << "~prepared_index_statement:"
<< res;
} }
} }
} }

View file

@ -24,6 +24,7 @@
#define MAPNIK_SQLITE_RESULTSET_HPP #define MAPNIK_SQLITE_RESULTSET_HPP
// mapnik // mapnik
#include <mapnik/debug.hpp>
#include <mapnik/datasource.hpp> #include <mapnik/datasource.hpp>
#include <mapnik/params.hpp> #include <mapnik/params.hpp>

View file

@ -29,6 +29,7 @@
#include <algorithm> #include <algorithm>
// mapnik // mapnik
#include <mapnik/debug.hpp>
#include <mapnik/datasource.hpp> #include <mapnik/datasource.hpp>
#include <mapnik/params.hpp> #include <mapnik/params.hpp>
#include <mapnik/geometry.hpp> #include <mapnik/geometry.hpp>
@ -556,7 +557,7 @@ public:
} }
catch (std::exception const& ex) catch (std::exception const& ex)
{ {
//std::clog << "no: " << ex.what() << "\n"; MAPNIK_LOG_DEBUG(sqlite) << "has_rtree returned:" << ex.what();
return false; return false;
} }
return false; return false;
@ -609,9 +610,7 @@ public:
break; break;
default: default:
#ifdef MAPNIK_DEBUG MAPNIK_LOG_DEBUG(sqlite) << "detect_types_from_subquery: unknown type_oid=" << type_oid;
std::clog << "Sqlite Plugin: unknown type_oid=" << type_oid << std::endl;
#endif
break; break;
} }
} }
@ -691,22 +690,24 @@ public:
desc.add_descriptor(mapnik::attribute_descriptor(fld_name, mapnik::String)); desc.add_descriptor(mapnik::attribute_descriptor(fld_name, mapnik::String));
} }
} }
#ifdef MAPNIK_DEBUG
else else
{ {
// "Column Affinity" says default to "Numeric" but for now we pass.. // "Column Affinity" says default to "Numeric" but for now we pass..
//desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Double)); //desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Double));
// TODO - this should not fail when we specify geometry_field in XML file #ifdef MAPNIK_LOG
// Do not fail when we specify geometry_field in XML file
std::clog << "Sqlite Plugin: column '" if (field.empty())
{
MAPNIK_LOG_DEBUG(sqlite) << "Column '"
<< std::string(fld_name) << std::string(fld_name)
<< "' unhandled due to unknown type: " << "' unhandled due to unknown type: "
<< fld_type << std::endl; << fld_type;
} }
#endif #endif
} }
} }
}
return found_table; return found_table;
} }

View file

@ -27,7 +27,7 @@
#include <ctime> #include <ctime>
#ifndef MAPNIK_LOG_FORMAT #ifndef MAPNIK_LOG_FORMAT
#define MAPNIK_LOG_FORMAT "Mapnik LOG> %Y-%m-%d %H:%M:%S:" #define MAPNIK_LOG_FORMAT Mapnik LOG> %Y-%m-%d %H:%M:%S:
#endif #endif
#ifndef MAPNIK_DEFAULT_LOG_SEVERITY #ifndef MAPNIK_DEFAULT_LOG_SEVERITY

View file

@ -45,6 +45,9 @@ private:
std::string fileName_; std::string fileName_;
unsigned width_; unsigned width_;
unsigned height_; unsigned height_;
jpeg_decompress_struct cinfo;
jpeg_error_mgr jerr;
FILE *fp;
public: public:
explicit JpegReader(std::string const& fileName); explicit JpegReader(std::string const& fileName);
~JpegReader(); ~JpegReader();
@ -54,6 +57,8 @@ public:
void read(unsigned x,unsigned y,image_data_32& image); void read(unsigned x,unsigned y,image_data_32& image);
private: private:
void init(); void init();
static void on_error(j_common_ptr cinfo);
static void on_error_message(j_common_ptr cinfo);
}; };
namespace namespace
@ -68,27 +73,43 @@ const bool registered = register_image_reader("jpeg",createJpegReader);
JpegReader::JpegReader(std::string const& fileName) JpegReader::JpegReader(std::string const& fileName)
: fileName_(fileName), : fileName_(fileName),
width_(0), width_(0),
height_(0) height_(0),
fp(NULL)
{ {
init(); init();
} }
JpegReader::~JpegReader() {} JpegReader::~JpegReader() {
if (fp)
{
fclose(fp);
}
jpeg_destroy_decompress(&cinfo);
}
void JpegReader::on_error(j_common_ptr cinfo)
{
(*cinfo->err->output_message)(cinfo);
jpeg_destroy(cinfo);
throw image_reader_exception("JPEG Reader: libjpeg could not read image");
}
void JpegReader::on_error_message(j_common_ptr cinfo)
{
// used to supress jpeg from printing to stderr
}
void JpegReader::init() void JpegReader::init()
{ {
FILE *fp = fopen(fileName_.c_str(),"rb"); fp = fopen(fileName_.c_str(),"rb");
if (!fp) throw image_reader_exception("JPEG Reader: cannot open image file " + fileName_); if (!fp) throw image_reader_exception("JPEG Reader: cannot open image file " + fileName_);
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
cinfo.err = jpeg_std_error(&jerr); cinfo.err = jpeg_std_error(&jerr);
jerr.error_exit = on_error;
jerr.output_message = on_error_message;
jpeg_create_decompress(&cinfo); jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, fp); jpeg_stdio_src(&cinfo, fp);
jpeg_read_header(&cinfo, TRUE); jpeg_read_header(&cinfo, TRUE);
jpeg_start_decompress(&cinfo); jpeg_start_decompress(&cinfo);
width_ = cinfo.output_width; width_ = cinfo.output_width;
height_ = cinfo.output_height; height_ = cinfo.output_height;
@ -110,12 +131,9 @@ unsigned JpegReader::height() const
void JpegReader::read(unsigned x0, unsigned y0, image_data_32& image) void JpegReader::read(unsigned x0, unsigned y0, image_data_32& image)
{ {
struct jpeg_decompress_struct cinfo; fp = fopen(fileName_.c_str(),"rb");
FILE *fp = fopen(fileName_.c_str(),"rb");
if (!fp) throw image_reader_exception("JPEG Reader: cannot open image file " + fileName_); if (!fp) throw image_reader_exception("JPEG Reader: cannot open image file " + fileName_);
struct jpeg_error_mgr jerr;
cinfo.err = jpeg_std_error(&jerr); cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo); jpeg_create_decompress(&cinfo);
@ -129,7 +147,6 @@ void JpegReader::read(unsigned x0, unsigned y0, image_data_32& image)
if (cinfo.output_width == 0) { if (cinfo.output_width == 0) {
jpeg_destroy_decompress (&cinfo); jpeg_destroy_decompress (&cinfo);
fclose(fp);
throw image_reader_exception("JPEG Reader: failed to read image size of " + fileName_); throw image_reader_exception("JPEG Reader: failed to read image size of " + fileName_);
} }
@ -168,6 +185,5 @@ void JpegReader::read(unsigned x0, unsigned y0, image_data_32& image)
} }
jpeg_finish_decompress(&cinfo); jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo); jpeg_destroy_decompress(&cinfo);
fclose(fp);
} }
} }

View file

@ -264,8 +264,8 @@ void Map::set_height(unsigned height)
void Map::resize(unsigned width,unsigned height) void Map::resize(unsigned width,unsigned height)
{ {
if (width != width_ && if ((width != width_ ||
height != height_ && height != height_) &&
width >= MIN_MAPSIZE && width >= MIN_MAPSIZE &&
width <= MAX_MAPSIZE && width <= MAX_MAPSIZE &&
height >= MIN_MAPSIZE && height >= MIN_MAPSIZE &&

View file

@ -68,13 +68,16 @@ projection::projection(projection const& rhs)
proj_(NULL), proj_(NULL),
proj_ctx_(NULL) proj_ctx_(NULL)
{ {
if (!rhs.defer_proj_init_) init_proj4(); if (!defer_proj_init_) init_proj4();
} }
projection& projection::operator=(projection const& rhs) projection& projection::operator=(projection const& rhs)
{ {
projection tmp(rhs); projection tmp(rhs);
swap(tmp); swap(tmp);
proj_ctx_ = 0;
proj_ = 0;
if (!defer_proj_init_) init_proj4();
return *this; return *this;
} }
@ -210,6 +213,8 @@ std::string projection::expanded() const
void projection::swap(projection& rhs) void projection::swap(projection& rhs)
{ {
std::swap(params_,rhs.params_); std::swap(params_,rhs.params_);
std::swap(defer_proj_init_,rhs.defer_proj_init_);
std::swap(is_geographic_,rhs.is_geographic_);
} }
} }

View file

@ -82,6 +82,7 @@ private:
void read_stripped(unsigned x,unsigned y,image_data_32& image); void read_stripped(unsigned x,unsigned y,image_data_32& image);
void read_tiled(unsigned x,unsigned y,image_data_32& image); void read_tiled(unsigned x,unsigned y,image_data_32& image);
TIFF* load_if_exists(std::string const& filename); TIFF* load_if_exists(std::string const& filename);
static void on_error(const char* /*module*/, const char* fmt, va_list argptr);
}; };
namespace namespace
@ -107,11 +108,18 @@ tiff_reader::tiff_reader(std::string const& file_name)
init(); init();
} }
void tiff_reader::on_error(const char* /*module*/, const char* fmt, va_list argptr)
{
char msg[10240];
vsprintf(msg, fmt, argptr);
throw image_reader_exception(msg);
}
void tiff_reader::init() void tiff_reader::init()
{ {
// TODO: error handling // TODO: error handling
TIFFSetWarningHandler(0); TIFFSetWarningHandler(0);
TIFFSetErrorHandler(on_error);
TIFF* tif = load_if_exists(file_name_); TIFF* tif = load_if_exists(file_name_);
if (!tif) throw image_reader_exception( std::string("Can't load tiff file: '") + file_name_ + "'"); if (!tif) throw image_reader_exception( std::string("Can't load tiff file: '") + file_name_ + "'");

View file

View file

View file

View file

@ -0,0 +1,75 @@
#include <boost/version.hpp>
#include <boost/filesystem/convenience.hpp>
namespace fs = boost::filesystem;
using fs::path;
namespace sys = boost::system;
#include <boost/detail/lightweight_test.hpp>
#include <iostream>
#include <mapnik/image_reader.hpp>
#include <mapnik/image_util.hpp>
int main( int, char*[] )
{
std::string blank;
boost::optional<std::string> type;
try
{
blank = "./tests/cpp_tests/data/blank.jpg";
BOOST_TEST( fs::exists( blank ) );
type = mapnik::type_from_filename(blank);
BOOST_TEST( type );
try
{
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(blank,*type));
BOOST_TEST( false );
}
catch (std::exception const&)
{
BOOST_TEST( true );
}
blank = "./tests/cpp_tests/data/blank.png";
BOOST_TEST( fs::exists( blank ) );
type = mapnik::type_from_filename(blank);
BOOST_TEST( type );
try
{
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(blank,*type));
BOOST_TEST( false );
}
catch (std::exception const&)
{
BOOST_TEST( true );
}
blank = "./tests/cpp_tests/data/blank.tiff";
BOOST_TEST( fs::exists( blank ) );
type = mapnik::type_from_filename(blank);
BOOST_TEST( type );
try
{
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(blank,*type));
BOOST_TEST( false );
}
catch (std::exception const&)
{
BOOST_TEST( true );
}
}
catch (std::exception const & ex)
{
std::clog << "C++ image i/o problem: " << ex.what() << "\n";
BOOST_TEST(false);
}
if (!::boost::detail::test_errors()) {
std::clog << "C++ image i/o: \x1b[1;32m✓ \x1b[0m\n";
#if BOOST_VERSION >= 104600
::boost::detail::report_errors_remind().called_report_errors_function = true;
#endif
} else {
return ::boost::report_errors();
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB