From 438bfad732a0ddcb3bc5fa9df8fcdb07edb6b38f Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 12 Apr 2013 12:46:40 +0100 Subject: [PATCH 001/122] + factory : variadic templates based implementation ( requires c++11) + image_reader : stream based reading interface (boost::iostreams) + register additional png and jpeg readers with following sigs : ``` std::auto_ptr reader(mapnik::get_image_reader(buffer,size)); // buffer - char const* // size - size_t ``` + initial type_from_bytes implementation (TODO: add more types) + python : mapnik.Image.fromstring(str) mapnik.Image.frombuffer(buf) --- bindings/python/mapnik_image.cpp | 34 ++++++ include/mapnik/factory.hpp | 33 ++---- include/mapnik/image_reader.hpp | 13 ++- src/build.py | 3 +- src/image_reader.cpp | 41 +++++-- src/jpeg_reader.cpp | 179 ++++++++++++++++++++++++------- src/png_reader.cpp | 125 ++++++++++++--------- 7 files changed, 305 insertions(+), 123 deletions(-) diff --git a/bindings/python/mapnik_image.cpp b/bindings/python/mapnik_image.cpp index 32384a034..f6c0550d0 100644 --- a/bindings/python/mapnik_image.cpp +++ b/bindings/python/mapnik_image.cpp @@ -164,6 +164,36 @@ boost::shared_ptr open_from_file(std::string const& filename) throw mapnik::image_reader_exception("Unsupported image format:" + filename); } +boost::shared_ptr fromstring(std::string const& str) +{ + std::auto_ptr reader(get_image_reader(str.c_str(),str.size())); + if (reader.get()) + { + boost::shared_ptr image_ptr = boost::make_shared(reader->width(),reader->height()); + reader->read(0,0,image_ptr->data()); + return image_ptr; + } + throw mapnik::image_reader_exception("Failed to load image from buffer" ); +} + +boost::shared_ptr frombuffer(PyObject * obj) +{ + void const* buffer=0; + Py_ssize_t buffer_len; + if (PyObject_AsReadBuffer(obj, &buffer, &buffer_len) == 0) + { + std::auto_ptr reader(get_image_reader(reinterpret_cast(buffer),buffer_len)); + if (reader.get()) + { + boost::shared_ptr image_ptr = boost::make_shared(reader->width(),reader->height()); + reader->read(0,0,image_ptr->data()); + return image_ptr; + } + throw mapnik::image_reader_exception("Failed to load image from buffer" ); + } +} + + void blend (image_32 & im, unsigned x, unsigned y, image_32 const& im2, float opacity) { im.set_rectangle_alpha2(im2.data(),x,y,opacity); @@ -257,6 +287,10 @@ void export_image() .def("save", &save_to_file3) .def("open",open_from_file) .staticmethod("open") + .def("frombuffer",&frombuffer) + .staticmethod("frombuffer") + .def("fromstring",&fromstring) + .staticmethod("fromstring") #if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO) .def("from_cairo",&from_cairo) .staticmethod("from_cairo") diff --git a/include/mapnik/factory.hpp b/include/mapnik/factory.hpp index 012c5de84..343460792 100644 --- a/include/mapnik/factory.hpp +++ b/include/mapnik/factory.hpp @@ -31,42 +31,23 @@ #include namespace mapnik { -template -class default_factory_error -{ -public: - struct factory_exception : public std::exception - { - const char* what() const throw() - { - return "uknown object type"; - } - }; - static product_type* on_unknown_type(const key_type&) - { - return 0; - } -}; template < typename product_type, typename key_type, -typename product_creator=product_type* (*)(), -template class factory_error_policy=default_factory_error -> +typename ...Args > class factory : public singleton >, - factory_error_policy + Args...> > { private: + typedef product_type* (*product_creator)(Args...); typedef std::map product_map; product_map map_; public: - bool register_product(const key_type& key,product_creator creator) + bool register_product(const key_type& key, product_creator creator) { return map_.insert(typename product_map::value_type(key,creator)).second; } @@ -76,14 +57,14 @@ public: return map_.erase(key)==1; } - product_type* create_object(const key_type& key,std::string const& file) + product_type* create_object(const key_type& key, Args const&...args) { typename product_map::const_iterator pos=map_.find(key); if (pos!=map_.end()) { - return (pos->second)(file); + return (pos->second)(args...); } - return factory_error_policy::on_unknown_type(key); + return 0; } }; } diff --git a/include/mapnik/image_reader.hpp b/include/mapnik/image_reader.hpp index dff902653..a3a6545e7 100644 --- a/include/mapnik/image_reader.hpp +++ b/include/mapnik/image_reader.hpp @@ -27,13 +27,16 @@ #include #include #include - +#include +// boost +#include // stl #include #include namespace mapnik { + class image_reader_exception : public std::exception { private: @@ -59,9 +62,15 @@ struct MAPNIK_DECL image_reader : private mapnik::noncopyable virtual ~image_reader() {} }; -bool register_image_reader(std::string const& type,image_reader* (*)(std::string const&)); +template +bool register_image_reader(std::string const& type, image_reader* (* fun)(Args...)) +{ + return factory::instance().register_product(type, fun); +} + MAPNIK_DECL image_reader* get_image_reader(std::string const& file,std::string const& type); MAPNIK_DECL image_reader* get_image_reader(std::string const& file); +MAPNIK_DECL image_reader* get_image_reader(char const* data, size_t size); } diff --git a/src/build.py b/src/build.py index e6b9b9b8f..1c45abf1a 100644 --- a/src/build.py +++ b/src/build.py @@ -55,9 +55,10 @@ ABI_VERSION = env['ABI_VERSION'] filesystem = 'boost_filesystem%s' % env['BOOST_APPEND'] regex = 'boost_regex%s' % env['BOOST_APPEND'] system = 'boost_system%s' % env['BOOST_APPEND'] +iostreams = 'boost_iostreams%s' % env['BOOST_APPEND'] # clear out and re-set libs for this env -lib_env['LIBS'] = ['freetype','z',env['ICU_LIB_NAME'],filesystem,system,regex] +lib_env['LIBS'] = ['freetype','z',env['ICU_LIB_NAME'],filesystem,system,regex,iostreams] if env['PROJ']: lib_env['LIBS'].append('proj') diff --git a/src/image_reader.cpp b/src/image_reader.cpp index 22e476e27..3bacd7cac 100644 --- a/src/image_reader.cpp +++ b/src/image_reader.cpp @@ -27,18 +27,45 @@ namespace mapnik { -typedef factory ImageReaderFactory; - -bool register_image_reader(std::string const& type,image_reader* (* fun)(std::string const&)) +inline boost::optional type_from_bytes(char const* data, size_t size) { - return ImageReaderFactory::instance().register_product(type,fun); + typedef boost::optional result_type; + if (size >= 4) + { + unsigned int magic = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; + if (magic == 0x89504E47U) + { + return result_type("png"); + } + else if (magic == 0x49492A00 || magic == 0x4D4D002A) + { + return result_type("tiff"); + } + } + if (size>=2) + { + unsigned int magic = ((data[0] << 8) | data[1]) & 0xffff; + if (magic == 0xffd8) + { + return result_type("jpeg"); + } + } + + return result_type(); +} + +image_reader* get_image_reader(char const* data, size_t size) +{ + boost::optional type = type_from_bytes(data,size); + if (type) + return factory::instance().create_object(*type, data,size); + return 0; } image_reader* get_image_reader(std::string const& filename,std::string const& type) { - return ImageReaderFactory::instance().create_object(type,filename); + return factory::instance().create_object(type,filename); } image_reader* get_image_reader(std::string const& filename) @@ -46,7 +73,7 @@ image_reader* get_image_reader(std::string const& filename) boost::optional type = type_from_filename(filename); if (type) { - return ImageReaderFactory::instance().create_object(*type,filename); + return factory::instance().create_object(*type,filename); } return 0; } diff --git a/src/jpeg_reader.cpp b/src/jpeg_reader.cpp index 169db9a6b..c90f31df4 100644 --- a/src/jpeg_reader.cpp +++ b/src/jpeg_reader.cpp @@ -23,7 +23,6 @@ // mapnik #include #include -#include // jpeg extern "C" @@ -34,24 +33,29 @@ extern "C" // boost #include #include +#include +#include +#include // std #include namespace mapnik { + +template class jpeg_reader : public image_reader { - struct jpeg_file_guard +public: + typedef T source_type; + typedef boost::iostreams::stream input_stream; + const static unsigned BUF_SIZE = 4096; +private: + struct jpeg_stream_wrapper { - jpeg_file_guard(FILE * fd) - : fd_(fd) {} - - ~jpeg_file_guard() - { - if (fd_) fclose(fd_); - } - FILE * fd_; + jpeg_source_mgr manager; + input_stream * stream; + JOCTET buffer[BUF_SIZE]; }; struct jpeg_info_guard @@ -67,11 +71,13 @@ class jpeg_reader : public image_reader }; private: - std::string file_name_; + source_type source_; + input_stream stream_; unsigned width_; unsigned height_; public: - explicit jpeg_reader(std::string const& fileName); + explicit jpeg_reader(std::string const& file_name); + explicit jpeg_reader(char const* data, size_t size); ~jpeg_reader(); unsigned width() const; unsigned height() const; @@ -81,44 +87,135 @@ private: void init(); static void on_error(j_common_ptr cinfo); static void on_error_message(j_common_ptr cinfo); + static void init_source(j_decompress_ptr cinfo); + static boolean fill_input_buffer(j_decompress_ptr cinfo); + static void skip(j_decompress_ptr cinfo, long count); + static void term(j_decompress_ptr cinfo); + static void attach_stream(j_decompress_ptr cinfo, input_stream* in); }; namespace { image_reader* create_jpeg_reader(std::string const& file) { - return new jpeg_reader(file); -} -const bool registered = register_image_reader("jpeg",create_jpeg_reader); + return new jpeg_reader(file); } -jpeg_reader::jpeg_reader(std::string const& fileName) - : file_name_(fileName), +image_reader* create_jpeg_reader2(char const* data, size_t size) +{ + return new jpeg_reader(data, size); +} + +const bool registered = register_image_reader("jpeg",create_jpeg_reader); +const bool registered2 = register_image_reader("jpeg",create_jpeg_reader2); +} + +// ctors +template +jpeg_reader::jpeg_reader(std::string const& file_name) + : source_(file_name,std::ios_base::in | std::ios_base::binary), + stream_(source_), width_(0), height_(0) { + if (!stream_) throw image_reader_exception("cannot open image file "+ file_name); init(); } -jpeg_reader::~jpeg_reader() {} - -void jpeg_reader::on_error(j_common_ptr cinfo) +template +jpeg_reader::jpeg_reader(char const* data, size_t size) + : source_(data, size), + stream_(source_), + width_(0), + height_(0) +{ + if (!stream_) throw image_reader_exception("cannot open image stream"); + init(); +} + +// dtor +template +jpeg_reader::~jpeg_reader() {} + +// jpeg stream wrapper +template +void jpeg_reader::init_source (j_decompress_ptr cinfo) +{ + jpeg_stream_wrapper* wrap = reinterpret_cast(cinfo->src); + wrap->stream->seekg(0,std::ios_base::beg); +} + +template +boolean jpeg_reader::fill_input_buffer (j_decompress_ptr cinfo) +{ + jpeg_stream_wrapper* wrap = reinterpret_cast(cinfo->src); + wrap->stream->read(reinterpret_cast(&wrap->buffer[0]),BUF_SIZE); + std::streamsize size = wrap->stream->gcount(); + wrap->manager.next_input_byte = wrap->buffer; + wrap->manager.bytes_in_buffer = BUF_SIZE; + return (size > 0) ? TRUE : FALSE; +} + +template +void jpeg_reader::skip(j_decompress_ptr cinfo, long count) +{ + if (count <= 0) return; //A zero or negative skip count should be treated as a no-op. + jpeg_stream_wrapper* wrap = reinterpret_cast(cinfo->src); + + if (wrap->manager.bytes_in_buffer > 0 && count < wrap->manager.bytes_in_buffer) + { + wrap->manager.bytes_in_buffer -= count; + wrap->manager.next_input_byte = &wrap->buffer[BUF_SIZE - wrap->manager.bytes_in_buffer]; + } + else + { + wrap->stream->seekg(count, std::ios_base::cur); + // trigger buffer fill + wrap->manager.next_input_byte = 0; + wrap->manager.bytes_in_buffer = 0; //bytes_in_buffer may be zero on return. + } +} + +template +void jpeg_reader::term (j_decompress_ptr cinfo) +{ +// no-op +} + +template +void jpeg_reader::attach_stream (j_decompress_ptr cinfo, input_stream* in) +{ + if (cinfo->src == 0) + { + cinfo->src = (struct jpeg_source_mgr *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(jpeg_stream_wrapper)); + } + jpeg_reader::jpeg_stream_wrapper * src = reinterpret_cast (cinfo->src); + src->manager.init_source = init_source; + src->manager.fill_input_buffer = fill_input_buffer; + src->manager.skip_input_data = skip; + src->manager.resync_to_restart = jpeg_resync_to_restart; + src->manager.term_source = term; + src->manager.bytes_in_buffer = 0; + src->manager.next_input_byte = 0; + src->stream = in; +} + +template +void jpeg_reader::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 jpeg_reader::on_error_message(j_common_ptr cinfo) +template +void jpeg_reader::on_error_message(j_common_ptr cinfo) { // used to supress jpeg from printing to stderr } -void jpeg_reader::init() +template +void jpeg_reader::init() { - FILE * fp = fopen(file_name_.c_str(),"rb"); - if (!fp) throw image_reader_exception("JPEG Reader: cannot open image file " + file_name_); - jpeg_file_guard guard(fp); jpeg_decompress_struct cinfo; jpeg_info_guard iguard(&cinfo); jpeg_error_mgr jerr; @@ -126,38 +223,42 @@ void jpeg_reader::init() jerr.error_exit = on_error; jerr.output_message = on_error_message; jpeg_create_decompress(&cinfo); - jpeg_stdio_src(&cinfo, fp); + attach_stream(&cinfo, &stream_); int ret = jpeg_read_header(&cinfo, TRUE); - if (ret != JPEG_HEADER_OK) throw image_reader_exception("JPEG Reader: failed to read header in " + file_name_); + if (ret != JPEG_HEADER_OK) + throw image_reader_exception("JPEG Reader: failed to read header"); jpeg_start_decompress(&cinfo); width_ = cinfo.output_width; height_ = cinfo.output_height; if (cinfo.out_color_space == JCS_UNKNOWN) { - throw image_reader_exception("JPEG Reader: failed to read unknown color space in " + file_name_); + throw image_reader_exception("JPEG Reader: failed to read unknown color space"); } if (cinfo.output_width == 0 || cinfo.output_height == 0) { - throw image_reader_exception("JPEG Reader: failed to read image size of " + file_name_); + throw image_reader_exception("JPEG Reader: failed to read image size of"); } } -unsigned jpeg_reader::width() const +template +unsigned jpeg_reader::width() const { return width_; } -unsigned jpeg_reader::height() const +template +unsigned jpeg_reader::height() const { return height_; } -void jpeg_reader::read(unsigned x0, unsigned y0, image_data_32& image) +template +void jpeg_reader::read(unsigned x0, unsigned y0, image_data_32& image) { - FILE * fp = fopen(file_name_.c_str(),"rb"); - if (!fp) throw image_reader_exception("JPEG Reader: cannot open image file " + file_name_); - jpeg_file_guard guard(fp); + stream_.clear(); + stream_.seekg(0, std::ios_base::beg); + jpeg_decompress_struct cinfo; jpeg_info_guard iguard(&cinfo); jpeg_error_mgr jerr; @@ -165,9 +266,9 @@ void jpeg_reader::read(unsigned x0, unsigned y0, image_data_32& image) jerr.error_exit = on_error; jerr.output_message = on_error_message; jpeg_create_decompress(&cinfo); - jpeg_stdio_src(&cinfo, fp); + attach_stream(&cinfo, &stream_); int ret = jpeg_read_header(&cinfo, TRUE); - if (ret != JPEG_HEADER_OK) throw image_reader_exception("JPEG Reader: failed to read header in " + file_name_); + if (ret != JPEG_HEADER_OK) throw image_reader_exception("JPEG Reader read(): failed to read header"); jpeg_start_decompress(&cinfo); JSAMPARRAY buffer; int row_stride; diff --git a/src/png_reader.cpp b/src/png_reader.cpp index 324c33e7d..67a873f65 100644 --- a/src/png_reader.cpp +++ b/src/png_reader.cpp @@ -20,32 +20,29 @@ * *****************************************************************************/ +// mapnik #include #include -#include extern "C" { #include } - +// boost #include +#include +#include +//#include +#include namespace mapnik { + +template class png_reader : public image_reader { - struct png_file_guard - { - png_file_guard(FILE * fd) - : fd_(fd) {} - - ~png_file_guard() - { - if (fd_) fclose(fd_); - } - FILE * fd_; - }; + typedef T source_type; + typedef boost::iostreams::stream ifstream; struct png_struct_guard { @@ -62,13 +59,16 @@ class png_reader : public image_reader }; private: - std::string fileName_; + + source_type source_; + ifstream stream_; unsigned width_; unsigned height_; int bit_depth_; int color_type_; public: - explicit png_reader(std::string const& fileName); + explicit png_reader(std::string const& file_name); + explicit png_reader(char const* data, std::size_t size); ~png_reader(); unsigned width() const; unsigned height() const; @@ -76,28 +76,26 @@ public: void read(unsigned x,unsigned y,image_data_32& image); private: void init(); + static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length); }; namespace { + image_reader* create_png_reader(std::string const& file) { - return new png_reader(file); -} -const bool registered = register_image_reader("png",create_png_reader); + return new png_reader(file); } -png_reader::png_reader(std::string const& fileName) - : fileName_(fileName), - width_(0), - height_(0), - bit_depth_(0), - color_type_(0) +image_reader* create_png_reader2(char const * data, std::size_t size) { - init(); + return new png_reader(data, size); +} + +const bool registered = register_image_reader("png",create_png_reader); +const bool registered2 = register_image_reader("png", create_png_reader2); } -png_reader::~png_reader() {} void user_error_fn(png_structp png_ptr, png_const_charp error_msg) { @@ -109,35 +107,64 @@ void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg) MAPNIK_LOG_DEBUG(png_reader) << "libpng warning: '" << warning_msg << "'"; } -static void -png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +template +void png_reader::png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { - png_size_t check; - check = (png_size_t)fread(data, (png_size_t)1, length, - (FILE *)png_get_io_ptr(png_ptr)); - - if (check != length) + ifstream * fin = reinterpret_cast(png_get_io_ptr(png_ptr)); + fin->read(reinterpret_cast(data), length); + if (fin->gcount() != length) { png_error(png_ptr, "Read Error"); } } -void png_reader::init() +template +png_reader::png_reader(std::string const& file_name) + : source_(file_name,std::ios_base::in | std::ios_base::binary), + stream_(source_), + width_(0), + height_(0), + bit_depth_(0), + color_type_(0) { - FILE *fp=fopen(fileName_.c_str(),"rb"); - if (!fp) throw image_reader_exception("cannot open image file "+fileName_); - png_file_guard guard(fp); + if (!stream_) throw image_reader_exception("cannot open image file "+ file_name); + init(); +} + +template +png_reader::png_reader(char const* data, std::size_t size) + : source_(data,size), + stream_(source_), + width_(0), + height_(0), + bit_depth_(0), + color_type_(0) +{ + + if (!stream_) throw image_reader_exception("cannot open image stream"); + init(); +} + + +template +png_reader::~png_reader() {} + + +template +void png_reader::init() +{ png_byte header[8]; memset(header,0,8); - if ( fread(header,1,8,fp) != 8) + stream_.read(reinterpret_cast(header),8); + if ( stream_.gcount() != 8) { - throw image_reader_exception("Could not read " + fileName_); + throw image_reader_exception("Could not read image"); } int is_png=!png_sig_cmp(header,0,8); if (!is_png) { - throw image_reader_exception(fileName_ + " is not a png file"); + throw image_reader_exception(" File or steam is not a png"); } png_structp png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,0,0,0); @@ -155,7 +182,7 @@ void png_reader::init() info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) throw image_reader_exception("failed to create info_ptr"); - png_set_read_fn(png_ptr, (png_voidp)fp, png_read_data); + png_set_read_fn(png_ptr, (png_voidp)&stream_, png_read_data); png_set_sig_bytes(png_ptr,8); png_read_info(png_ptr, info_ptr); @@ -169,21 +196,23 @@ void png_reader::init() MAPNIK_LOG_DEBUG(png_reader) << "png_reader: bit_depth=" << bit_depth_ << ",color_type=" << color_type_; } -unsigned png_reader::width() const +template +unsigned png_reader::width() const { return width_; } -unsigned png_reader::height() const +template +unsigned png_reader::height() const { return height_; } -void png_reader::read(unsigned x0, unsigned y0,image_data_32& image) +template +void png_reader::read(unsigned x0, unsigned y0,image_data_32& image) { - FILE *fp=fopen(fileName_.c_str(),"rb"); - if (!fp) throw image_reader_exception("cannot open image file "+fileName_); - png_file_guard guard(fp); + stream_.clear(); + stream_.seekg(0, std::ios_base::beg); png_structp png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,0,0,0); @@ -201,7 +230,7 @@ void png_reader::read(unsigned x0, unsigned y0,image_data_32& image) info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) throw image_reader_exception("failed to create info_ptr"); - png_set_read_fn(png_ptr, (png_voidp)fp, png_read_data); + png_set_read_fn(png_ptr, (png_voidp)&stream_, png_read_data); png_read_info(png_ptr, info_ptr); if (color_type_ == PNG_COLOR_TYPE_PALETTE) From 28ea89fe1c6ac950e2883ec828c253b03eb58184 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 12 Apr 2013 16:03:08 +0100 Subject: [PATCH 002/122] + remove const& qualifier --- include/mapnik/factory.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/factory.hpp b/include/mapnik/factory.hpp index 343460792..656b0cdca 100644 --- a/include/mapnik/factory.hpp +++ b/include/mapnik/factory.hpp @@ -57,7 +57,7 @@ public: return map_.erase(key)==1; } - product_type* create_object(const key_type& key, Args const&...args) + product_type* create_object(const key_type& key, Args...args) { typename product_map::const_iterator pos=map_.find(key); if (pos!=map_.end()) From 9584b3634f5389ef23fbc38ea13c969d9cd78c38 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 12 Apr 2013 16:10:09 +0100 Subject: [PATCH 003/122] + no iostreams lib dependency version --- src/build.py | 3 +-- src/jpeg_reader.cpp | 5 +++-- src/png_reader.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/build.py b/src/build.py index 1c45abf1a..e6b9b9b8f 100644 --- a/src/build.py +++ b/src/build.py @@ -55,10 +55,9 @@ ABI_VERSION = env['ABI_VERSION'] filesystem = 'boost_filesystem%s' % env['BOOST_APPEND'] regex = 'boost_regex%s' % env['BOOST_APPEND'] system = 'boost_system%s' % env['BOOST_APPEND'] -iostreams = 'boost_iostreams%s' % env['BOOST_APPEND'] # clear out and re-set libs for this env -lib_env['LIBS'] = ['freetype','z',env['ICU_LIB_NAME'],filesystem,system,regex,iostreams] +lib_env['LIBS'] = ['freetype','z',env['ICU_LIB_NAME'],filesystem,system,regex] if env['PROJ']: lib_env['LIBS'].append('proj') diff --git a/src/jpeg_reader.cpp b/src/jpeg_reader.cpp index c90f31df4..09f16f33d 100644 --- a/src/jpeg_reader.cpp +++ b/src/jpeg_reader.cpp @@ -33,7 +33,8 @@ extern "C" // boost #include #include -#include +#include +//#include #include #include @@ -98,7 +99,7 @@ namespace { image_reader* create_jpeg_reader(std::string const& file) { - return new jpeg_reader(file); + return new jpeg_reader(file); } image_reader* create_jpeg_reader2(char const* data, size_t size) diff --git a/src/png_reader.cpp b/src/png_reader.cpp index 67a873f65..4facf9a84 100644 --- a/src/png_reader.cpp +++ b/src/png_reader.cpp @@ -31,7 +31,7 @@ extern "C" // boost #include #include -#include +//#include //#include #include @@ -84,7 +84,7 @@ namespace image_reader* create_png_reader(std::string const& file) { - return new png_reader(file); + return new png_reader(file); } image_reader* create_png_reader2(char const * data, std::size_t size) From e59bf22fbdafbc2aefa434b06318067a83160bfd Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 15 Apr 2013 14:00:41 +0100 Subject: [PATCH 004/122] WEBP image reader + add initial support --- SConstruct | 16 ++++++ src/build.py | 10 ++++ src/image_reader.cpp | 8 +++ src/webp_reader.cpp | 131 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 165 insertions(+) create mode 100644 src/webp_reader.cpp diff --git a/SConstruct b/SConstruct index 1f85a2847..ae8b322b4 100644 --- a/SConstruct +++ b/SConstruct @@ -67,6 +67,7 @@ pretty_dep_names = { 'jpeg':'JPEG C library | configure with JPEG_LIBS & JPEG_INCLUDES', 'tiff':'TIFF C library | configure with TIFF_LIBS & TIFF_INCLUDES', 'png':'PNG C library | configure with PNG_LIBS & PNG_INCLUDES', + 'webp':'WEBP C library | configure with WEBP_LIBS & WEBP_INCLUDES', 'icuuc':'ICU C++ library | configure with ICU_LIBS & ICU_INCLUDES or use ICU_LIB_NAME to specify custom lib name | more info: http://site.icu-project.org/', 'z':'Z compression library | more info: http://www.zlib.net/', 'm':'Basic math library, part of C++ stlib', @@ -317,6 +318,9 @@ PathVariable.PathAccept), BoolVariable('TIFF', 'Build Mapnik with TIFF read and write support', 'True'), PathVariable('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include', PathVariable.PathAccept), PathVariable('TIFF_LIBS', 'Search path for libtiff library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), + BoolVariable('WEBP', 'Build Mapnik with WEBP read', 'False'), + PathVariable('WEBP_INCLUDES', 'Search path for libwebp include files', '/usr/include', PathVariable.PathAccept), + PathVariable('WEBP_LIBS','Search path for libwebp library files','/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), BoolVariable('PROJ', 'Build Mapnik with proj4 support to enable transformations between many different projections', 'True'), PathVariable('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/include', PathVariable.PathAccept), PathVariable('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), @@ -1170,6 +1174,18 @@ if not preconfigured: else: env['SKIPPED_DEPS'].extend(['png']) + if env['WEBP']: + env.Append(CPPDEFINES = '-DHAVE_WEBP') + LIBSHEADERS.append(['webp', 'webp/decode.h', True,'C']) + LIBSHEADERS.append(['webp', 'webp/encode.h', True,'C']) + inc_path = env['%s_INCLUDES' % 'WEBP'] + lib_path = env['%s_LIBS' % 'WEBP'] + env.AppendUnique(CPPPATH = os.path.realpath(inc_path)) + env.AppendUnique(LIBPATH = os.path.realpath(lib_path)) + else: + env['SKIPPED_DEPS'].extend(['png']) + + if env['TIFF']: env.Append(CPPDEFINES = '-DHAVE_TIFF') LIBSHEADERS.append(['tiff', 'tiff.h', True,'C']) diff --git a/src/build.py b/src/build.py index e6b9b9b8f..73d9d3b5e 100644 --- a/src/build.py +++ b/src/build.py @@ -71,6 +71,9 @@ if env['JPEG']: if env['TIFF']: lib_env['LIBS'].append('tiff') +if env['WEBP']: + lib_env['LIBS'].append('webp') + if len(env['EXTRA_FREETYPE_LIBS']): lib_env['LIBS'].extend(copy(env['EXTRA_FREETYPE_LIBS'])) @@ -234,6 +237,13 @@ if env['PNG']: png_reader.cpp """) +if env['WEBP']: + source += Split( + """ + webp_reader.cpp + """) + + # agg backend source += Split( """ diff --git a/src/image_reader.cpp b/src/image_reader.cpp index 3bacd7cac..1ae83b42a 100644 --- a/src/image_reader.cpp +++ b/src/image_reader.cpp @@ -52,6 +52,14 @@ inline boost::optional type_from_bytes(char const* data, size_t siz } } + if (size>=12) + { + if (data[0] == 'R' && data[1] == 'I' && data[2] == 'F' && data[3] == 'F' && + data[8] == 'W' && data[9] == 'E' && data[10] == 'B' && data[11] == 'P') + { + return result_type("webp"); + } + } return result_type(); } diff --git a/src/webp_reader.cpp b/src/webp_reader.cpp new file mode 100644 index 000000000..755198f3d --- /dev/null +++ b/src/webp_reader.cpp @@ -0,0 +1,131 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2013 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +// mapnik +#include +#include + +extern "C" +{ +#include +#include +} + +// boost +#include +#include +#include + +namespace mapnik +{ + +class webp_reader : public image_reader +{ +private: + uint8_t const* data_; + size_t size_; + unsigned width_; + unsigned height_; +public: + explicit webp_reader(char const* data, std::size_t size); + ~webp_reader(); + unsigned width() const; + unsigned height() const; + bool premultiplied_alpha() const { return false; } + void read(unsigned x,unsigned y,image_data_32& image); +private: + void init(); +}; + +namespace +{ +image_reader* create_webp_reader(char const * data, std::size_t size) +{ + return new webp_reader(data, size); +} + +const bool registered = register_image_reader("webp", create_webp_reader); + +} + +// ctor +webp_reader::webp_reader(char const* data, std::size_t size) + : data_(reinterpret_cast(data)), + size_(size), + width_(0), + height_(0) +{ + init(); +} + +// dtor +webp_reader::~webp_reader() +{ + // +} + +void webp_reader::init() +{ + WebPDecoderConfig config; + if (!WebPGetFeatures(data_, size_, &config.input) == VP8_STATUS_OK) + { + throw image_reader_exception("WEBP: can't open image"); + } + width_ = config.input.width; + height_ = config.input.height; +} + +unsigned webp_reader::width() const +{ + return width_; +} + +unsigned webp_reader::height() const +{ + return height_; +} + +void webp_reader::read(unsigned x0, unsigned y0,image_data_32& image) +{ + WebPDecoderConfig config; + config.options.use_cropping = 1; + config.options.crop_left = x0; + config.options.crop_top = y0; + config.options.crop_width = image.width(); + config.options.crop_height = image.height(); + + if (WebPGetFeatures(data_, size_, &config.input) != VP8_STATUS_OK) + { + throw image_reader_exception("WEBP reader: WebPGetFeatures failed"); + } + + config.output.colorspace = MODE_RGBA; + config.output.u.RGBA.rgba = (uint8_t*)image.getBytes(); + config.output.u.RGBA.stride = 4 * image.width(); + config.output.u.RGBA.size = image.width()*image.height()*4; + if (WebPDecode(data_, size_, &config) != VP8_STATUS_OK) + { + throw image_reader_exception("WEBP reader: WebPDecode failed"); + } +} + +} From 1eb2ec5ce7a4ae0a68d7a7acbc6ca6110317ee91 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 15 Apr 2013 14:01:33 +0100 Subject: [PATCH 005/122] + cleanup include directives --- src/jpeg_reader.cpp | 1 - src/png_reader.cpp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/jpeg_reader.cpp b/src/jpeg_reader.cpp index 09f16f33d..f7a491307 100644 --- a/src/jpeg_reader.cpp +++ b/src/jpeg_reader.cpp @@ -34,7 +34,6 @@ extern "C" #include #include #include -//#include #include #include diff --git a/src/png_reader.cpp b/src/png_reader.cpp index 4facf9a84..73a3a5ec7 100644 --- a/src/png_reader.cpp +++ b/src/png_reader.cpp @@ -30,9 +30,9 @@ extern "C" } // boost #include +// iostreams #include -//#include -//#include +#include #include namespace mapnik From 77a8a6c8ee8d4480fc6dcf0a08b778c3087f6c8c Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 15 Apr 2013 17:54:10 +0100 Subject: [PATCH 006/122] + fixes and improved error handling --- src/webp_reader.cpp | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/webp_reader.cpp b/src/webp_reader.cpp index 755198f3d..52941fd2c 100644 --- a/src/webp_reader.cpp +++ b/src/webp_reader.cpp @@ -41,6 +41,19 @@ namespace mapnik class webp_reader : public image_reader { private: + + struct config_guard + { + config_guard(WebPDecoderConfig & config) + : config_(config) {} + + ~config_guard() + { + WebPFreeDecBuffer(&config_.output); + } + WebPDecoderConfig & config_; + }; + uint8_t const* data_; size_t size_; unsigned width_; @@ -85,13 +98,13 @@ webp_reader::~webp_reader() void webp_reader::init() { - WebPDecoderConfig config; - if (!WebPGetFeatures(data_, size_, &config.input) == VP8_STATUS_OK) + int width, height; + if (!WebPGetInfo(data_, size_, &width, &height)) { - throw image_reader_exception("WEBP: can't open image"); + throw image_reader_exception("WEBP reader: WebPGetInfo failed"); } - width_ = config.input.width; - height_ = config.input.height; + width_ = width; + height_ = height; } unsigned webp_reader::width() const @@ -107,6 +120,12 @@ unsigned webp_reader::height() const void webp_reader::read(unsigned x0, unsigned y0,image_data_32& image) { WebPDecoderConfig config; + config_guard guard(config); + if (!WebPInitDecoderConfig(&config)) + { + throw image_reader_exception("WEBP reader: WebPInitDecoderConfig failed"); + } + config.options.use_cropping = 1; config.options.crop_left = x0; config.options.crop_top = y0; @@ -119,9 +138,10 @@ void webp_reader::read(unsigned x0, unsigned y0,image_data_32& image) } config.output.colorspace = MODE_RGBA; - config.output.u.RGBA.rgba = (uint8_t*)image.getBytes(); + config.output.u.RGBA.rgba = (uint8_t *)image.getBytes(); config.output.u.RGBA.stride = 4 * image.width(); - config.output.u.RGBA.size = image.width()*image.height()*4; + config.output.u.RGBA.size = image.width() * image.height() * 4; + config.output.is_external_memory = 1; if (WebPDecode(data_, size_, &config) != VP8_STATUS_OK) { throw image_reader_exception("WEBP reader: WebPDecode failed"); From b8637a900e0d85edf7eeacc7898995740fedb313 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 15 Apr 2013 18:04:27 +0100 Subject: [PATCH 007/122] + fix crop width/height calc --- src/webp_reader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/webp_reader.cpp b/src/webp_reader.cpp index 52941fd2c..1b0ffe6f3 100644 --- a/src/webp_reader.cpp +++ b/src/webp_reader.cpp @@ -129,8 +129,8 @@ void webp_reader::read(unsigned x0, unsigned y0,image_data_32& image) config.options.use_cropping = 1; config.options.crop_left = x0; config.options.crop_top = y0; - config.options.crop_width = image.width(); - config.options.crop_height = image.height(); + config.options.crop_width = std::min(width_ - x0, image.width()); + config.options.crop_height = std::min(height_ - y0, image.height()); if (WebPGetFeatures(data_, size_, &config.input) != VP8_STATUS_OK) { From 1b90879d120ac5049e454fc939653139a857ff46 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 16 Apr 2013 10:48:21 +0100 Subject: [PATCH 008/122] webp_reader : implement reading from file --- src/webp_reader.cpp | 119 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 104 insertions(+), 15 deletions(-) diff --git a/src/webp_reader.cpp b/src/webp_reader.cpp index 1b0ffe6f3..1c4cc3ddd 100644 --- a/src/webp_reader.cpp +++ b/src/webp_reader.cpp @@ -34,14 +34,63 @@ extern "C" #include #include #include +// stl +#include namespace mapnik { +struct external_buffer_policy +{ + external_buffer_policy( uint8_t const* data, std::size_t size) + : data_(data), + size_(size) {} + + uint8_t const* data() const + { + return data_; + } + + std::size_t size() const + { + return size_; + } + + uint8_t const* data_; + std::size_t size_; +}; + +struct internal_buffer_policy +{ + internal_buffer_policy(std::size_t size) + : data_((size!=0) ? static_cast(::operator new(sizeof(uint8_t) * size)) : 0), + size_(size) + {} + + uint8_t * data() const + { + return data_; + } + + std::size_t size() const + { + return size_; + } + + ~internal_buffer_policy() + { + ::operator delete(data_), data_=0; + } + + uint8_t * data_; + std::size_t size_; +}; + +template class webp_reader : public image_reader { + typedef T buffer_policy_type; private: - struct config_guard { config_guard(WebPDecoderConfig & config) @@ -53,13 +102,13 @@ private: } WebPDecoderConfig & config_; }; - - uint8_t const* data_; + std::unique_ptr buffer_; size_t size_; unsigned width_; unsigned height_; public: explicit webp_reader(char const* data, std::size_t size); + explicit webp_reader(std::string const& filename); ~webp_reader(); unsigned width() const; unsigned height() const; @@ -73,33 +122,70 @@ namespace { image_reader* create_webp_reader(char const * data, std::size_t size) { - return new webp_reader(data, size); + return new webp_reader(data, size); } +image_reader* create_webp_reader2(std::string const& filename) +{ + return new webp_reader(filename); +} + + const bool registered = register_image_reader("webp", create_webp_reader); +const bool registered2 = register_image_reader("webp", create_webp_reader2); } // ctor -webp_reader::webp_reader(char const* data, std::size_t size) - : data_(reinterpret_cast(data)), - size_(size), +template +webp_reader::webp_reader(char const* data, std::size_t size) + : buffer_(new buffer_policy_type(reinterpret_cast(data), size)), width_(0), height_(0) { init(); } +template +webp_reader::webp_reader(std::string const& filename) + : buffer_(0), + size_(0), + width_(0), + height_(0) +{ + std::ifstream file(filename.c_str(), std::ios::binary); + if (!file) + { + throw image_reader_exception("WEBP: Can't read file:" + filename); + } + std::streampos beg = file.tellg(); + file.seekg (0, std::ios::end); + std::streampos end = file.tellg(); + std::size_t file_size = end - beg; + file.seekg (0, std::ios::beg); + std::unique_ptr buffer(new buffer_policy_type(file_size)); + file.read(reinterpret_cast(buffer->data()), buffer->size()); + if (!file) + { + throw image_reader_exception("WEBP: Failed to read:" + filename); + } + buffer_ = std::move(buffer); + init(); +} + + // dtor -webp_reader::~webp_reader() +template +webp_reader::~webp_reader() { // } -void webp_reader::init() +template +void webp_reader::init() { int width, height; - if (!WebPGetInfo(data_, size_, &width, &height)) + if (!WebPGetInfo(buffer_->data(), buffer_->size(), &width, &height)) { throw image_reader_exception("WEBP reader: WebPGetInfo failed"); } @@ -107,17 +193,20 @@ void webp_reader::init() height_ = height; } -unsigned webp_reader::width() const +template +unsigned webp_reader::width() const { return width_; } -unsigned webp_reader::height() const +template +unsigned webp_reader::height() const { return height_; } -void webp_reader::read(unsigned x0, unsigned y0,image_data_32& image) +template +void webp_reader::read(unsigned x0, unsigned y0,image_data_32& image) { WebPDecoderConfig config; config_guard guard(config); @@ -132,7 +221,7 @@ void webp_reader::read(unsigned x0, unsigned y0,image_data_32& image) config.options.crop_width = std::min(width_ - x0, image.width()); config.options.crop_height = std::min(height_ - y0, image.height()); - if (WebPGetFeatures(data_, size_, &config.input) != VP8_STATUS_OK) + if (WebPGetFeatures(buffer_->data(), buffer_->size(), &config.input) != VP8_STATUS_OK) { throw image_reader_exception("WEBP reader: WebPGetFeatures failed"); } @@ -142,7 +231,7 @@ void webp_reader::read(unsigned x0, unsigned y0,image_data_32& image) config.output.u.RGBA.stride = 4 * image.width(); config.output.u.RGBA.size = image.width() * image.height() * 4; config.output.is_external_memory = 1; - if (WebPDecode(data_, size_, &config) != VP8_STATUS_OK) + if (WebPDecode(buffer_->data(), buffer_->size(), &config) != VP8_STATUS_OK) { throw image_reader_exception("WEBP reader: WebPDecode failed"); } From 9020e6f4398b7fc51fa921d862b0d09e5ef8d0f9 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 16 Apr 2013 10:56:10 +0100 Subject: [PATCH 009/122] type_from_filename : add webp support --- include/mapnik/image_util.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/mapnik/image_util.hpp b/include/mapnik/image_util.hpp index 513a06416..b8eded589 100644 --- a/include/mapnik/image_util.hpp +++ b/include/mapnik/image_util.hpp @@ -145,6 +145,11 @@ inline bool is_ps (std::string const& filename) return boost::algorithm::iends_with(filename,std::string(".ps")); } +inline bool is_webp (std::string const& filename) +{ + return boost::algorithm::iends_with(filename,std::string(".webp")); +} + inline boost::optional type_from_filename(std::string const& filename) { @@ -155,6 +160,7 @@ inline boost::optional type_from_filename(std::string const& filena if (is_pdf(filename)) return result_type("pdf"); if (is_svg(filename)) return result_type("svg"); if (is_ps(filename)) return result_type("ps"); + if (is_webp(filename)) return result_type("webp"); return result_type(); } From b9e66c82de1928603177db05fda653896b229324 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 16 Apr 2013 11:36:23 +0100 Subject: [PATCH 010/122] + update image_io test to support WEBP --- tests/cpp_tests/data/blank.webp | 0 tests/cpp_tests/image_io_test.cpp | 14 ++++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/cpp_tests/data/blank.webp diff --git a/tests/cpp_tests/data/blank.webp b/tests/cpp_tests/data/blank.webp new file mode 100644 index 000000000..e69de29bb diff --git a/tests/cpp_tests/image_io_test.cpp b/tests/cpp_tests/image_io_test.cpp index ea51b1d70..42363a3d2 100644 --- a/tests/cpp_tests/image_io_test.cpp +++ b/tests/cpp_tests/image_io_test.cpp @@ -44,6 +44,20 @@ int main( int, char*[] ) BOOST_TEST( true ); } + should_throw = "./tests/cpp_tests/data/blank.webp"; + BOOST_TEST( fs::exists( should_throw ) ); + type = mapnik::type_from_filename(should_throw); + BOOST_TEST( type ); + try + { + std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + BOOST_TEST( false ); + } + catch (std::exception const&) + { + BOOST_TEST( true ); + } + should_throw = "./tests/cpp_tests/data/blank.tiff"; BOOST_TEST( fs::exists( should_throw ) ); type = mapnik::type_from_filename(should_throw); From c5170290f8e222baeadaa4cec6279e3b5a9b1520 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 16 Apr 2013 17:30:17 +0100 Subject: [PATCH 011/122] + image_reader : consistent error handling - throw image_reader_exception rather than returning 0 pointer. --- src/image_reader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/image_reader.cpp b/src/image_reader.cpp index 1ae83b42a..afa572b5d 100644 --- a/src/image_reader.cpp +++ b/src/image_reader.cpp @@ -68,7 +68,8 @@ image_reader* get_image_reader(char const* data, size_t size) boost::optional type = type_from_bytes(data,size); if (type) return factory::instance().create_object(*type, data,size); - return 0; + else + throw image_reader_exception("image_reader: can't determine type from input data"); } image_reader* get_image_reader(std::string const& filename,std::string const& type) From 868d60d765856596dea0cb5262d1c054782562b4 Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 17 Apr 2013 14:46:11 +0100 Subject: [PATCH 012/122] + add getBytes() method ( needed by webp i/o) --- include/mapnik/image_view.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/mapnik/image_view.hpp b/include/mapnik/image_view.hpp index 135125f79..946714368 100644 --- a/include/mapnik/image_view.hpp +++ b/include/mapnik/image_view.hpp @@ -88,6 +88,12 @@ public: { return data_.getRow(row + y_) + x_; } + + inline char const* getBytes() const + { + return reinterpret_cast(&data_); + } + inline T& data() { return data_; @@ -107,4 +113,3 @@ private: } #endif // MAPNIK_IMAGE_VIEW_HPP - From da6c630db90a8ac58803ab1ea612cb6fe81f3f86 Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 17 Apr 2013 14:50:35 +0100 Subject: [PATCH 013/122] + add webp writing support --- include/mapnik/webp_io.hpp | 108 +++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 include/mapnik/webp_io.hpp diff --git a/include/mapnik/webp_io.hpp b/include/mapnik/webp_io.hpp new file mode 100644 index 000000000..e2499dde1 --- /dev/null +++ b/include/mapnik/webp_io.hpp @@ -0,0 +1,108 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2013 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_WEBP_IO_HPP +#define MAPNIK_WEBP_IO_HPP + +#include + +#include +#include +#include + + +namespace mapnik { + +template +int webp_stream_write(const uint8_t* data, size_t data_size, const WebPPicture* picture) +{ + T* out = static_cast(picture->custom_ptr); + out->write(reinterpret_cast(data), data_size); + return true; +} + +std::string webp_encoding_error(WebPEncodingError error) { + std::ostringstream os; + switch (error) { + case VP8_ENC_ERROR_OUT_OF_MEMORY: os << "memory error allocating objects"; break; + case VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY: os << "memory error while flushing bits"; break; + case VP8_ENC_ERROR_NULL_PARAMETER: os << "a pointer parameter is NULL"; break; + case VP8_ENC_ERROR_INVALID_CONFIGURATION: os << "configuration is invalid"; break; + case VP8_ENC_ERROR_BAD_DIMENSION: os << "picture has invalid width/height"; break; + case VP8_ENC_ERROR_PARTITION0_OVERFLOW: os << "partition is bigger than 512k"; break; + case VP8_ENC_ERROR_PARTITION_OVERFLOW: os << "partition is bigger than 16M"; break; + case VP8_ENC_ERROR_BAD_WRITE: os << "error while flushing bytes"; break; + case VP8_ENC_ERROR_FILE_TOO_BIG: os << "file is bigger than 4G"; break; + default: os << "unknown error (" << error << ")"; break; + } + os << " during encoding"; + return os.str(); +} + +template +void save_as_webp(T1& file, int quality, int compression, T2 const& image) +{ + WebPConfig config; + if (!WebPConfigPreset(&config, WEBP_PRESET_DEFAULT, quality)) + { + throw std::runtime_error("version mismatch"); + } + + // Add additional tuning + if (compression >= 0) config.method = compression; + + bool valid = WebPValidateConfig(&config); + if (!valid) { + throw std::runtime_error("Invalid configuration"); + } + + WebPPicture pic; + if (!WebPPictureInit(&pic)) + { + throw std::runtime_error("version mismatch"); + } + pic.width = image.width(); + pic.height = image.height(); + if (!WebPPictureAlloc(&pic)) + { + throw std::runtime_error("memory error"); + } + + int stride = sizeof(typename T2::pixel_type) * image.width(); + uint8_t const* bytes = reinterpret_cast(image.getBytes()); + int ok = WebPPictureImportRGBA(&pic, bytes, stride); + + pic.writer = webp_stream_write; + pic.custom_ptr = &file; + + ok = WebPEncode(&config, &pic); + WebPPictureFree(&pic); + if (!ok) + { + throw std::runtime_error(webp_encoding_error(pic.error_code)); + } + + file.flush(); +} +} + +#endif // MAPNIK_WEBP_IO_HPP From 77e71d726b87d1c48790dc485ffa964c7284b904 Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 17 Apr 2013 14:51:20 +0100 Subject: [PATCH 014/122] + add webp support --- src/image_util.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/image_util.cpp b/src/image_util.cpp index 8738493f9..2e74e6e83 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -40,6 +40,10 @@ extern "C" #include #endif +#if defined(HAVE_WEBP) +#include +#endif + #include #include #include @@ -358,7 +362,7 @@ void save_to_stream(T const& image, { #if defined(HAVE_JPEG) int quality = 85; - std::string const& val = t.substr(4); + std::string val = t.substr(4); if (!val.empty()) { if (!mapnik::util::string2int(val,quality) || quality < 0 || quality > 100) @@ -369,6 +373,24 @@ void save_to_stream(T const& image, save_as_jpeg(stream, quality, image); #else throw ImageWriterException("jpeg output is not enabled in your build of Mapnik"); +#endif + } + else if (boost::algorithm::starts_with(t, "webp")) + { +#if defined(HAVE_WEBP) + int quality = 100; + std::string val = t.substr(4); + if (!val.empty()) + { + if (!mapnik::util::string2int(val,quality) || quality < 0 || quality > 100) + { + throw ImageWriterException("invalid webp quality: '" + val + "'"); + } + } + int compression = 0; + save_as_webp(stream, quality, compression, image); +#else + throw ImageWriterException("webp output is not enabled in your build of Mapnik"); #endif } else throw ImageWriterException("unknown file type: " + type); From bd3423a8225fc2aa6b38ccc29b80d1f7a5fcfee7 Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 17 Apr 2013 14:52:01 +0100 Subject: [PATCH 015/122] + output webp quality=100 -> demo.webp quality=80 -> demo-med.webp qiality=50 -> demo-low.webp TODO: support other webp writing options --- demo/python/rundemo.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/demo/python/rundemo.py b/demo/python/rundemo.py index 78ec494fd..edfda31e8 100644 --- a/demo/python/rundemo.py +++ b/demo/python/rundemo.py @@ -352,6 +352,16 @@ images_.append('demo_low.jpg') im.save('demo.tif', 'tiff') images_.append('demo.tif') +im.save('demo.webp', 'webp') +images_.append('demo.webp') + +im.save('demo_med.webp', 'webp80') +images_.append('demo_med.webp') + +im.save('demo_low.webp', 'webp50') +images_.append('demo_low.webp') + + # Render cairo examples if HAS_PYCAIRO_MODULE and mapnik.has_pycairo(): From 21b93272c08eb2abe5ff7d22457fcf64a1148dac Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 18 Apr 2013 16:07:12 +0100 Subject: [PATCH 016/122] + use nullptr --- src/webp_reader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webp_reader.cpp b/src/webp_reader.cpp index 1c4cc3ddd..bac459789 100644 --- a/src/webp_reader.cpp +++ b/src/webp_reader.cpp @@ -148,7 +148,7 @@ webp_reader::webp_reader(char const* data, std::size_t size) template webp_reader::webp_reader(std::string const& filename) - : buffer_(0), + : buffer_(nullptr), size_(0), width_(0), height_(0) From da16de55de736223d1c28719ae822982d6a2377f Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 09:37:41 +0100 Subject: [PATCH 017/122] + fix : output file_name --- src/debug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug.cpp b/src/debug.cpp index bebacb4b3..19ba4b7cc 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -136,7 +136,7 @@ void logger::use_file(std::string const& filepath) else { std::stringstream s; - s << "cannot redirect log to file " << file_output_; + s << "cannot redirect log to file " << file_name_; throw std::runtime_error(s.str()); } } From a41c83fbceb84813e62ec03a35ecdc93b58cb9a0 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 09:41:42 +0100 Subject: [PATCH 018/122] + png_io: disble miniz for now --- include/mapnik/png_io.hpp | 10 ++++++---- src/build.py | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/mapnik/png_io.hpp b/include/mapnik/png_io.hpp index a1719e278..7f828faea 100644 --- a/include/mapnik/png_io.hpp +++ b/include/mapnik/png_io.hpp @@ -27,7 +27,7 @@ #include #include #include -#include +//#include #include // zlib @@ -71,7 +71,8 @@ void save_as_png(T1 & file, bool use_miniz = false) { - if (use_miniz) +#if 0 + if (use_miniz) { MiniZ::PNGWriter writer(compression,strategy); if (trans_mode == 0) @@ -88,7 +89,7 @@ void save_as_png(T1 & file, writer.toStream(file); return; } - +#endif png_voidp error_ptr=0; png_structp png_ptr=png_create_write_struct(PNG_LIBPNG_VER_STRING, error_ptr,0, 0); @@ -262,6 +263,7 @@ void save_as_png(T & file, std::vector const& palette, std::vector const&alpha, bool use_miniz) { +#if 0 if (use_miniz) { MiniZ::PNGWriter writer(compression,strategy); @@ -275,7 +277,7 @@ void save_as_png(T & file, std::vector const& palette, writer.toStream(file); return; } - +#endif png_voidp error_ptr=0; png_structp png_ptr=png_create_write_struct(PNG_LIBPNG_VER_STRING, error_ptr,0, 0); diff --git a/src/build.py b/src/build.py index 73d9d3b5e..dbadb71cb 100644 --- a/src/build.py +++ b/src/build.py @@ -117,7 +117,6 @@ source = Split( well_known_srs.cpp params.cpp image_filter_types.cpp - miniz_png.cpp color.cpp css_color_grammar.cpp conversions.cpp From 7cd8c63656bfccdcd7bae6212ac285e6e816817b Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 09:42:24 +0100 Subject: [PATCH 019/122] + remove "-ansi" compile flags to avoid clashung with -std=c++11 --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index ae8b322b4..529a792f9 100644 --- a/SConstruct +++ b/SConstruct @@ -1614,7 +1614,7 @@ if not preconfigured: if not env['SUNCC']: # Common flags for GCC. - gcc_cxx_flags = '-ansi -Wall %s %s -ftemplate-depth-300 ' % (env['WARNING_CXXFLAGS'], pthread) + gcc_cxx_flags = '-Wall %s %s -ftemplate-depth-300 ' % (env['WARNING_CXXFLAGS'], pthread) if env['DEBUG']: env.Append(CXXFLAGS = gcc_cxx_flags + '-O0 -fno-inline') else: From c73e48fa589223ff3760d2bb8dfdc4f972fd1de5 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 09:50:50 +0100 Subject: [PATCH 020/122] + use std::unique_ptr instead of std::auto_ptr (deprecated!) --- benchmark/run.cpp | 17 +++++------ bindings/python/mapnik_geometry.cpp | 7 +++-- bindings/python/mapnik_image.cpp | 8 +++--- include/mapnik/css_color_grammar.hpp | 2 ++ include/mapnik/css_color_grammar_def.hpp | 2 ++ include/mapnik/expression_grammar.hpp | 2 ++ .../mapnik/feature_style_processor_impl.hpp | 22 ++++++++------- include/mapnik/image_filter_grammar.hpp | 1 + .../json/feature_collection_grammar.hpp | 21 +++++++------- .../mapnik/json/feature_generator_grammar.hpp | 2 ++ include/mapnik/json/feature_grammar.hpp | 1 + .../json/geometry_generator_grammar.hpp | 3 +- include/mapnik/json/geometry_grammar.hpp | 2 ++ include/mapnik/path_expression_grammar.hpp | 1 + include/mapnik/placement_finder.hpp | 4 +-- include/mapnik/rule_cache.hpp | 10 +++---- include/mapnik/svg/svg_path_grammar.hpp | 1 + .../mapnik/transform_expression_grammar.hpp | 1 + include/mapnik/util/dasharray_parser.hpp | 12 ++++---- .../mapnik/util/geometry_svg_generator.hpp | 3 +- include/mapnik/util/geometry_to_svg.hpp | 2 ++ .../mapnik/util/geometry_wkt_generator.hpp | 6 +++- include/mapnik/wkt/wkt_grammar.hpp | 2 ++ plugins/input/ogr/ogr_converter.cpp | 12 ++++---- plugins/input/raster/raster_datasource.cpp | 2 +- plugins/input/raster/raster_featureset.cpp | 2 +- plugins/input/shape/shape_featureset.cpp | 8 +++--- .../input/shape/shape_index_featureset.cpp | 8 +++--- plugins/input/shape/shape_io.cpp | 12 ++++---- src/conversions.cpp | 2 ++ src/expression_grammar.cpp | 4 ++- src/json/feature_collection_parser.cpp | 6 ++-- src/json/feature_grammar.cpp | 1 + src/json/geojson_generator.cpp | 16 +++++++---- src/json/geometry_grammar.cpp | 2 ++ src/json/geometry_parser.cpp | 2 ++ src/marker_cache.cpp | 2 +- src/placement_finder.cpp | 28 +++++++++---------- src/text_placements/simple.cpp | 2 ++ src/transform_expression_grammar.cpp | 1 + src/wkb.cpp | 24 ++++++++-------- tests/cpp_tests/conversions_test.cpp | 2 ++ tests/cpp_tests/geometry_converters_test.cpp | 6 ++-- tests/cpp_tests/image_io_test.cpp | 10 +++---- tests/cpp_tests/map_request_test.cpp | 4 +-- 45 files changed, 167 insertions(+), 121 deletions(-) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index c20c153d3..38612f55d 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -12,6 +12,7 @@ #include #include #include +#include // boost #include @@ -92,7 +93,7 @@ void benchmark(T & test_runner, std::string const& name) bool compare_images(std::string const& src_fn,std::string const& dest_fn) { - std::auto_ptr reader1(mapnik::get_image_reader(dest_fn,"png")); + std::unique_ptr reader1(mapnik::get_image_reader(dest_fn,"png")); if (!reader1.get()) { throw mapnik::image_reader_exception("Failed to load: " + dest_fn); @@ -100,7 +101,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn) boost::shared_ptr image_ptr1 = boost::make_shared(reader1->width(),reader1->height()); reader1->read(0,0,image_ptr1->data()); - std::auto_ptr reader2(mapnik::get_image_reader(src_fn,"png")); + std::unique_ptr reader2(mapnik::get_image_reader(src_fn,"png")); if (!reader2.get()) { throw mapnik::image_reader_exception("Failed to load: " + src_fn); @@ -162,7 +163,7 @@ struct test2 im_() { std::string filename("./benchmark/data/multicolor.png"); - std::auto_ptr reader(mapnik::get_image_reader(filename,"png")); + std::unique_ptr reader(mapnik::get_image_reader(filename,"png")); if (!reader.get()) { throw mapnik::image_reader_exception("Failed to load: " + filename); @@ -410,8 +411,8 @@ struct test8 #include #if BOOST_VERSION >= 105300 -#include -#include +//#include +//#include class rule_cache_move { @@ -593,13 +594,13 @@ struct test10 void operator()() { for (unsigned i=0;i rule_caches; + std::vector > rule_caches; for (unsigned i=0;i rc(new rule_cache_heap); + std::unique_ptr rc(new rule_cache_heap); for (unsigned i=0;iadd_rule(rules_[i]); } - rule_caches.push_back(rc); + rule_caches.push_back(std::move(rc)); } } } diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index 1a949c6aa..0b7a344fb 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -40,7 +40,7 @@ #if BOOST_VERSION >= 104700 #include #include -#include +//#include #endif namespace { @@ -229,7 +229,8 @@ std::string to_geojson( path_type const& geom) std::string to_svg( geometry_type const& geom) { -#if BOOST_VERSION >= 104700 + +#if 0 // BOOST_VERSION >= 104700 std::string svg; // Use Python String directly ? bool result = mapnik::util::to_svg(svg,geom); if (!result) @@ -280,7 +281,7 @@ void export_geometry() #endif using mapnik::geometry_type; - class_, boost::noncopyable>("Geometry2d",no_init) + class_, boost::noncopyable>("Geometry2d",no_init) .def("envelope",&geometry_type::envelope) // .def("__str__",&geometry_type::to_string) .def("type",&geometry_type::type) diff --git a/bindings/python/mapnik_image.cpp b/bindings/python/mapnik_image.cpp index f6c0550d0..c916bde3b 100644 --- a/bindings/python/mapnik_image.cpp +++ b/bindings/python/mapnik_image.cpp @@ -151,7 +151,7 @@ boost::shared_ptr open_from_file(std::string const& filename) boost::optional type = type_from_filename(filename); if (type) { - std::auto_ptr reader(get_image_reader(filename,*type)); + std::unique_ptr reader(get_image_reader(filename,*type)); if (reader.get()) { @@ -166,7 +166,7 @@ boost::shared_ptr open_from_file(std::string const& filename) boost::shared_ptr fromstring(std::string const& str) { - std::auto_ptr reader(get_image_reader(str.c_str(),str.size())); + std::unique_ptr reader(get_image_reader(str.c_str(),str.size())); if (reader.get()) { boost::shared_ptr image_ptr = boost::make_shared(reader->width(),reader->height()); @@ -182,15 +182,15 @@ boost::shared_ptr frombuffer(PyObject * obj) Py_ssize_t buffer_len; if (PyObject_AsReadBuffer(obj, &buffer, &buffer_len) == 0) { - std::auto_ptr reader(get_image_reader(reinterpret_cast(buffer),buffer_len)); + std::unique_ptr reader(get_image_reader(reinterpret_cast(buffer),buffer_len)); if (reader.get()) { boost::shared_ptr image_ptr = boost::make_shared(reader->width(),reader->height()); reader->read(0,0,image_ptr->data()); return image_ptr; } - throw mapnik::image_reader_exception("Failed to load image from buffer" ); } + throw mapnik::image_reader_exception("Failed to load image from buffer" ); } diff --git a/include/mapnik/css_color_grammar.hpp b/include/mapnik/css_color_grammar.hpp index a15f0fa87..51d498428 100644 --- a/include/mapnik/css_color_grammar.hpp +++ b/include/mapnik/css_color_grammar.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_CSS_COLOR_GRAMMAR_HPP #define MAPNIK_CSS_COLOR_GRAMMAR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // mapnik #include diff --git a/include/mapnik/css_color_grammar_def.hpp b/include/mapnik/css_color_grammar_def.hpp index 028411ba1..57768e895 100644 --- a/include/mapnik/css_color_grammar_def.hpp +++ b/include/mapnik/css_color_grammar_def.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_CSS_COLOR_GRAMMAR_DEF_HPP #define MAPNIK_CSS_COLOR_GRAMMAR_DEF_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // boost #include diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp index 2702048a3..50ac37ded 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_EXPRESSIONS_GRAMMAR_HPP #define MAPNIK_EXPRESSIONS_GRAMMAR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // mapnik #include #include diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index eade195b3..f1a893d71 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -54,7 +54,7 @@ // stl #include - +#include #if defined(RENDERING_STATS) #include @@ -400,7 +400,9 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces attribute_collector collector(names); double filt_factor = 1.0; directive_collector d_collector(filt_factor); - boost::ptr_vector rule_caches; + + std::vector > rule_caches; + //boost::ptr_vector rule_caches; // iterate through all named styles collecting active styles and attribute names BOOST_FOREACH(std::string const& style_name, style_names) @@ -417,12 +419,12 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces std::vector const& rules = style->get_rules(); bool active_rules = false; - std::auto_ptr rc(new rule_cache); - BOOST_FOREACH(rule const& r, rules) + std::unique_ptr rc_ptr(new rule_cache); + for (auto const& r : rules) { if (r.active(scale_denom)) { - rc->add_rule(r); + rc_ptr->add_rule(r); active_rules = true; if (ds->type() == datasource::Vector) { @@ -433,7 +435,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces } if (active_rules) { - rule_caches.push_back(rc); + rule_caches.push_back(std::move(rc_ptr)); active_styles.push_back(&(*style)); } } @@ -505,7 +507,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces int i = 0; BOOST_FOREACH (feature_type_style const* style, active_styles) { - render_style(lay, p, style, rule_caches[i], style_names[i], + render_style(lay, p, style, *rule_caches[i], style_names[i], cache.features(q), prj_trans); i++; } @@ -518,7 +520,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces int i = 0; BOOST_FOREACH (feature_type_style const* style, active_styles) { - render_style(lay, p, style, rule_caches[i], style_names[i], + render_style(lay, p, style, *rule_caches[i], style_names[i], cache.features(q), prj_trans); i++; } @@ -539,7 +541,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces int i = 0; BOOST_FOREACH (feature_type_style const* style, active_styles) { - render_style(lay, p, style, rule_caches[i], style_names[i], + render_style(lay, p, style, *rule_caches[i], style_names[i], cache.features(q), prj_trans); i++; } @@ -550,7 +552,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces int i = 0; BOOST_FOREACH (feature_type_style const* style, active_styles) { - render_style(lay, p, style, rule_caches[i], style_names[i], + render_style(lay, p, style, *rule_caches[i], style_names[i], ds->features(q), prj_trans); i++; } diff --git a/include/mapnik/image_filter_grammar.hpp b/include/mapnik/image_filter_grammar.hpp index 4f4523278..919b2b9d4 100644 --- a/include/mapnik/image_filter_grammar.hpp +++ b/include/mapnik/image_filter_grammar.hpp @@ -23,6 +23,7 @@ #ifndef MAPNIK_IMAGE_FILITER_GRAMMAR_HPP #define MAPNIK_IMAGE_FILITER_GRAMMAR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // boost #include #include diff --git a/include/mapnik/json/feature_collection_grammar.hpp b/include/mapnik/json/feature_collection_grammar.hpp index 43b8db635..29ca15f34 100644 --- a/include/mapnik/json/feature_collection_grammar.hpp +++ b/include/mapnik/json/feature_collection_grammar.hpp @@ -28,6 +28,7 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit::qi #include #include @@ -42,14 +43,14 @@ using standard_wide::space_type; struct generate_id { typedef int result_type; - + generate_id(int start) : id_(start) {} - + int operator() () const { return id_++; - } + } mutable int id_; }; @@ -76,7 +77,7 @@ struct feature_collection_grammar : feature_collection = lit('{') >> (type | features) % lit(",") >> lit('}') ; - + type = lit("\"type\"") > lit(":") > lit("\"FeatureCollection\"") ; @@ -86,29 +87,29 @@ struct feature_collection_grammar : > -(feature(_val) % lit(',')) > lit(']') ; - + feature = eps[_a = phoenix::construct(new_(ctx_,generate_id_()))] >> feature_g(*_a)[push_back(_r1,_a)] ; - + type.name("type"); features.name("features"); feature.name("feature"); feature_g.name("feature-grammar"); - + qi::on_error ( feature_collection , std::clog << phoenix::val("Error parsing GeoJSON ") - << qi::_4 + << qi::_4 << phoenix::val(" here: \"") - << construct(qi::_3, qi::_2) + << construct(qi::_3, qi::_2) << phoenix::val("\"") << std::endl ); } - + context_ptr ctx_; qi::rule(), space_type> feature_collection; // START qi::rule type; diff --git a/include/mapnik/json/feature_generator_grammar.hpp b/include/mapnik/json/feature_generator_grammar.hpp index d5d16c47d..3f0f16c96 100644 --- a/include/mapnik/json/feature_generator_grammar.hpp +++ b/include/mapnik/json/feature_generator_grammar.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_JSON_FEATURE_GENERATOR_GRAMMAR_HPP #define MAPNIK_JSON_FEATURE_GENERATOR_GRAMMAR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // mapnik #include #include diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index 18c2125e2..e26fc4342 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -30,6 +30,7 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit::qi #include #include diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index 47974c201..a54253e01 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -23,6 +23,7 @@ #ifndef MAPNIK_JSON_GEOMETRY_GENERATOR_GRAMMAR_HPP #define MAPNIK_JSON_GEOMETRY_GENERATOR_GRAMMAR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // mapnik #include #include @@ -42,8 +43,6 @@ #include // trunc to avoid needing C++11 -//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - namespace boost { namespace spirit { namespace traits { // make gcc and darwin toolsets happy. diff --git a/include/mapnik/json/geometry_grammar.hpp b/include/mapnik/json/geometry_grammar.hpp index 32b05ec3d..308f0048a 100644 --- a/include/mapnik/json/geometry_grammar.hpp +++ b/include/mapnik/json/geometry_grammar.hpp @@ -27,6 +27,8 @@ #include // for geometry_type #include // for CommandType +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // spirit::qi #include #include diff --git a/include/mapnik/path_expression_grammar.hpp b/include/mapnik/path_expression_grammar.hpp index a03511215..68f6e93da 100644 --- a/include/mapnik/path_expression_grammar.hpp +++ b/include/mapnik/path_expression_grammar.hpp @@ -26,6 +26,7 @@ // mapnik #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit2 #include #include diff --git a/include/mapnik/placement_finder.hpp b/include/mapnik/placement_finder.hpp index 1c5f67c10..7b6e73369 100644 --- a/include/mapnik/placement_finder.hpp +++ b/include/mapnik/placement_finder.hpp @@ -103,14 +103,14 @@ private: // otherwise it will autodetect the orientation. // If >= 50% of the characters end up upside down, it will be retried the other way. // RETURN: 1/-1 depending which way up the string ends up being. - std::auto_ptr get_placement_offset(std::vector const& path_positions, + std::unique_ptr get_placement_offset(std::vector const& path_positions, std::vector const& path_distances, int & orientation, unsigned index, double distance); ///Tests whether the given text_path be placed without a collision // Returns true if it can // NOTE: This edits p.envelopes so it can be used afterwards (you must clear it otherwise) - bool test_placement(std::auto_ptr const& current_placement, int orientation); + bool test_placement(std::unique_ptr const& current_placement, int orientation); ///Does a line-circle intersect calculation // NOTE: Follow the strict pre conditions diff --git a/include/mapnik/rule_cache.hpp b/include/mapnik/rule_cache.hpp index 4a805b990..920b40334 100644 --- a/include/mapnik/rule_cache.hpp +++ b/include/mapnik/rule_cache.hpp @@ -41,9 +41,9 @@ class rule_cache public: typedef std::vector rule_ptrs; rule_cache() - : if_rules_(), - else_rules_(), - also_rules_() {} + : if_rules_(), + else_rules_(), + also_rules_() {} void add_rule(rule const& r) { @@ -65,12 +65,12 @@ public: { return if_rules_; } - + rule_ptrs const& get_else_rules() const { return else_rules_; } - + rule_ptrs const& get_also_rules() const { return also_rules_; diff --git a/include/mapnik/svg/svg_path_grammar.hpp b/include/mapnik/svg/svg_path_grammar.hpp index 851a501c2..940cdbc76 100644 --- a/include/mapnik/svg/svg_path_grammar.hpp +++ b/include/mapnik/svg/svg_path_grammar.hpp @@ -26,6 +26,7 @@ // mapnik #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit #include #include diff --git a/include/mapnik/transform_expression_grammar.hpp b/include/mapnik/transform_expression_grammar.hpp index 886ffaa1f..fb113f07a 100644 --- a/include/mapnik/transform_expression_grammar.hpp +++ b/include/mapnik/transform_expression_grammar.hpp @@ -27,6 +27,7 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit #include diff --git a/include/mapnik/util/dasharray_parser.hpp b/include/mapnik/util/dasharray_parser.hpp index e1e4c1271..ba2534bd6 100644 --- a/include/mapnik/util/dasharray_parser.hpp +++ b/include/mapnik/util/dasharray_parser.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_UTIL_DASHARRAY_PARSER_HPP #define MAPNIK_UTIL_DASHARRAY_PARSER_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + #include #include #include @@ -44,10 +46,10 @@ bool parse_dasharray(Iterator first, Iterator last, std::vector& dasharr using qi::lexeme; #endif using phoenix::push_back; - // SVG + // SVG // dasharray ::= (length | percentage) (comma-wsp dasharray)? // no support for 'percentage' as viewport is unknown at load_map - // + // bool r = phrase_parse(first, last, (double_[push_back(phoenix::ref(dasharray), _1)] % #if BOOST_VERSION > 104200 @@ -57,10 +59,10 @@ bool parse_dasharray(Iterator first, Iterator last, std::vector& dasharr #endif | lit("none")), qi::ascii::space); - - if (first != last) + + if (first != last) return false; - + return r; } diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index 070521031..d6b8726cb 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_GEOMETRY_SVG_GENERATOR_HPP #define MAPNIK_GEOMETRY_SVG_GENERATOR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // mapnik #include #include // for container stuff @@ -41,7 +43,6 @@ #include #include -//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 /*! * adapted to conform to the concepts diff --git a/include/mapnik/util/geometry_to_svg.hpp b/include/mapnik/util/geometry_to_svg.hpp index d7294d878..b24a666b7 100644 --- a/include/mapnik/util/geometry_to_svg.hpp +++ b/include/mapnik/util/geometry_to_svg.hpp @@ -28,6 +28,8 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // boost #include diff --git a/include/mapnik/util/geometry_wkt_generator.hpp b/include/mapnik/util/geometry_wkt_generator.hpp index 79f9fe1fd..2fb8a77bb 100644 --- a/include/mapnik/util/geometry_wkt_generator.hpp +++ b/include/mapnik/util/geometry_wkt_generator.hpp @@ -23,11 +23,15 @@ #ifndef MAPNIK_GEOMETRY_WKT_GENERATOR_HPP #define MAPNIK_GEOMETRY_WKT_GENERATOR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // mapnik #include #include #include // for CommandType::SEG_MOVETO +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // boost #include #include @@ -40,7 +44,7 @@ #include #include // trunc to avoid needing C++11 -//#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + namespace boost { namespace spirit { namespace traits { diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index e7e986f59..1d09cda62 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_WKT_GRAMMAR_HPP #define MAPNIK_WKT_GRAMMAR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + #include #include // spirit::qi diff --git a/plugins/input/ogr/ogr_converter.cpp b/plugins/input/ogr/ogr_converter.cpp index 8892ef1f9..cce0336e5 100644 --- a/plugins/input/ogr/ogr_converter.cpp +++ b/plugins/input/ogr/ogr_converter.cpp @@ -79,21 +79,21 @@ void ogr_converter::convert_geometry(OGRGeometry* geom, feature_ptr feature) void ogr_converter::convert_point(OGRPoint* geom, feature_ptr feature) { - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::Point)); point->move_to(geom->getX(), geom->getY()); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); } void ogr_converter::convert_linestring(OGRLineString* geom, feature_ptr feature) { int num_points = geom->getNumPoints(); - std::auto_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::LineString)); line->move_to(geom->getX(0), geom->getY(0)); for (int i = 1; i < num_points; ++i) { line->line_to (geom->getX(i), geom->getY(i)); } - feature->paths().push_back(line); + feature->paths().push_back(line.release()); } void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature) @@ -108,7 +108,7 @@ void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature) capacity += interior->getNumPoints(); } - std::auto_ptr poly(new geometry_type(mapnik::Polygon)); + std::unique_ptr poly(new geometry_type(mapnik::Polygon)); poly->move_to(exterior->getX(0), exterior->getY(0)); for (int i = 1; i < num_points; ++i) @@ -127,7 +127,7 @@ void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature) } poly->close_path(); } - feature->paths().push_back(poly); + feature->paths().push_back(poly.release()); } void ogr_converter::convert_multipoint(OGRMultiPoint* geom, feature_ptr feature) diff --git a/plugins/input/raster/raster_datasource.cpp b/plugins/input/raster/raster_datasource.cpp index 25541857d..9bce16e31 100644 --- a/plugins/input/raster/raster_datasource.cpp +++ b/plugins/input/raster/raster_datasource.cpp @@ -118,7 +118,7 @@ raster_datasource::raster_datasource(parameters const& params) try { - std::auto_ptr reader(mapnik::get_image_reader(filename_, format_)); + std::unique_ptr reader(mapnik::get_image_reader(filename_, format_)); if (reader.get()) { width_ = reader->width(); diff --git a/plugins/input/raster/raster_featureset.cpp b/plugins/input/raster/raster_featureset.cpp index 729052df5..62e5c6401 100644 --- a/plugins/input/raster/raster_featureset.cpp +++ b/plugins/input/raster/raster_featureset.cpp @@ -70,7 +70,7 @@ feature_ptr raster_featureset::next() try { - std::auto_ptr reader(mapnik::get_image_reader(curIter_->file(),curIter_->format())); + std::unique_ptr reader(mapnik::get_image_reader(curIter_->file(),curIter_->format())); MAPNIK_LOG_DEBUG(raster) << "raster_featureset: Reader=" << curIter_->format() << "," << curIter_->file() << ",size(" << curIter_->width() << "," << curIter_->height() << ")"; diff --git a/plugins/input/shape/shape_featureset.cpp b/plugins/input/shape/shape_featureset.cpp index 4550d832b..01176bc48 100644 --- a/plugins/input/shape/shape_featureset.cpp +++ b/plugins/input/shape/shape_featureset.cpp @@ -89,9 +89,9 @@ feature_ptr shape_featureset::next() double y = record.read_double(); if (!filter_.pass(mapnik::box2d(x,y,x,y))) continue; - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::Point)); point->move_to(x, y); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); break; } case shape_io::shape_multipoint: @@ -105,9 +105,9 @@ feature_ptr shape_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::Point)); point->move_to(x, y); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); } break; } diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index 78836a030..73871f9e9 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -99,9 +99,9 @@ feature_ptr shape_index_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::Point)); point->move_to(x, y); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); break; } case shape_io::shape_multipoint: @@ -115,9 +115,9 @@ feature_ptr shape_index_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::Point)); point->move_to(x, y); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); } break; } diff --git a/plugins/input/shape/shape_io.cpp b/plugins/input/shape/shape_io.cpp index 538d59b29..6493ef248 100644 --- a/plugins/input/shape/shape_io.cpp +++ b/plugins/input/shape/shape_io.cpp @@ -97,7 +97,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry int num_points = record.read_ndr_integer(); if (num_parts == 1) { - std::auto_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::LineString)); record.skip(4); double x = record.read_double(); double y = record.read_double(); @@ -108,7 +108,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry y = record.read_double(); line->line_to(x, y); } - geom.push_back(line); + geom.push_back(line.release()); } else { @@ -121,7 +121,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry int start, end; for (int k = 0; k < num_parts; ++k) { - std::auto_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::LineString)); start = parts[k]; if (k == num_parts - 1) { @@ -142,7 +142,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry y = record.read_double(); line->line_to(x, y); } - geom.push_back(line); + geom.push_back(line.release()); } } } @@ -160,7 +160,7 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c for (int k = 0; k < num_parts; ++k) { - std::auto_ptr poly(new geometry_type(mapnik::Polygon)); + std::unique_ptr poly(new geometry_type(mapnik::Polygon)); int start = parts[k]; int end; if (k == num_parts - 1) @@ -182,6 +182,6 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c poly->line_to(x, y); } poly->close_path(); - geom.push_back(poly); + geom.push_back(poly.release()); } } diff --git a/src/conversions.cpp b/src/conversions.cpp index c4abfff54..f7d6d67e6 100644 --- a/src/conversions.cpp +++ b/src/conversions.cpp @@ -26,6 +26,8 @@ #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + #include #if _MSC_VER diff --git a/src/expression_grammar.cpp b/src/expression_grammar.cpp index 0894be1c3..3c90f8777 100644 --- a/src/expression_grammar.cpp +++ b/src/expression_grammar.cpp @@ -20,6 +20,8 @@ * *****************************************************************************/ +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // mapnik #include #include @@ -142,7 +144,7 @@ expression_grammar::expression_grammar(mapnik::transcoder const& tr) multiplicative_expr = unary_expr [_val = _1] >> *( '*' >> unary_expr [_val *= _1] | '/' >> unary_expr [_val /= _1] - | '%' >> unary_expr [_val %= _1] +// | '%' >> unary_expr [_val %= _1] --> FIXME | regex_match_expr[_val = regex_match_(_val, _1)] | regex_replace_expr(_val) [_val = _1] ) diff --git a/src/json/feature_collection_parser.cpp b/src/json/feature_collection_parser.cpp index 97b753480..1daeba75c 100644 --- a/src/json/feature_collection_parser.cpp +++ b/src/json/feature_collection_parser.cpp @@ -22,9 +22,8 @@ // TODO https://github.com/mapnik/mapnik/issues/1658 #include -#if BOOST_VERSION >= 105200 -#define BOOST_SPIRIT_USE_PHOENIX_V3 -#endif + +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // mapnik #include @@ -65,4 +64,3 @@ namespace mapnik { namespace json { template class feature_collection_parser > >; }} - diff --git a/src/json/feature_grammar.cpp b/src/json/feature_grammar.cpp index aa83162bc..0c517072a 100644 --- a/src/json/feature_grammar.cpp +++ b/src/json/feature_grammar.cpp @@ -27,6 +27,7 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // boost #include diff --git a/src/json/geojson_generator.cpp b/src/json/geojson_generator.cpp index d178fe8d3..34ec5e811 100644 --- a/src/json/geojson_generator.cpp +++ b/src/json/geojson_generator.cpp @@ -25,6 +25,8 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + #if BOOST_VERSION >= 104700 #include @@ -34,26 +36,28 @@ namespace mapnik { namespace json { feature_generator::feature_generator() - : grammar_(new feature_generator_grammar()) {} + : grammar_(0) {} // new feature_generator_grammar()) {} feature_generator::~feature_generator() {} bool feature_generator::generate(std::string & geojson, mapnik::feature_impl const& f) { - sink_type sink(geojson); - return karma::generate(sink, *grammar_,f); + //sink_type sink(geojson); + //return karma::generate(sink, *grammar_,f); + return false; } geometry_generator::geometry_generator() - : grammar_(new multi_geometry_generator_grammar()) {} + : grammar_(0) {} //new multi_geometry_generator_grammar()) {} geometry_generator::~geometry_generator() {} bool geometry_generator::generate(std::string & geojson, mapnik::geometry_container const& g) { - sink_type sink(geojson); - return karma::generate(sink, *grammar_,g); +//sink_type sink(geojson); +// return karma::generate(sink, *grammar_,g); +return false; } }} diff --git a/src/json/geometry_grammar.cpp b/src/json/geometry_grammar.cpp index 84700633b..4ea45350e 100644 --- a/src/json/geometry_grammar.cpp +++ b/src/json/geometry_grammar.cpp @@ -26,6 +26,8 @@ // mapnik #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // boost #include #include diff --git a/src/json/geometry_parser.cpp b/src/json/geometry_parser.cpp index 53c48ff73..f38690f1e 100644 --- a/src/json/geometry_parser.cpp +++ b/src/json/geometry_parser.cpp @@ -21,6 +21,8 @@ *****************************************************************************/ // mapnik +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + #include #include diff --git a/src/marker_cache.cpp b/src/marker_cache.cpp index a0971d035..a5feb4201 100644 --- a/src/marker_cache.cpp +++ b/src/marker_cache.cpp @@ -192,7 +192,7 @@ boost::optional marker_cache::find(std::string const& uri, else { // TODO - support reading images from string - std::auto_ptr reader(mapnik::get_image_reader(uri)); + std::unique_ptr reader(mapnik::get_image_reader(uri)); if (reader.get()) { unsigned width = reader->width(); diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index 0f7a3906e..0ad39f5c5 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -387,7 +387,7 @@ void placement_finder::find_point_placement(double label_x, double sina = std::sin(rad); double x, y; - std::auto_ptr current_placement(new text_path(label_x, label_y)); + std::unique_ptr current_placement(new text_path(label_x, label_y)); adjust_position(current_placement.get()); @@ -640,10 +640,10 @@ void placement_finder::find_line_placements(PathT & shape_path) { //Record details for the start of the string placement int orientation = 0; - std::auto_ptr current_placement = get_placement_offset(path_positions, path_distances, orientation, index, segment_length - (distance - target_distance) + (diff*dir)); + std::unique_ptr current_placement = get_placement_offset(path_positions, path_distances, orientation, index, segment_length - (distance - target_distance) + (diff*dir)); //We were unable to place here - if (current_placement.get() == NULL) + if (current_placement.get() == nullptr) continue; //Apply displacement @@ -710,7 +710,7 @@ void placement_finder::find_line_placements(PathT & shape_path) } template -std::auto_ptr placement_finder::get_placement_offset(std::vector const& path_positions, +std::unique_ptr placement_finder::get_placement_offset(std::vector const& path_positions, std::vector const& path_distances, int & orientation, unsigned index, @@ -723,7 +723,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: distance += path_distances[index]; } if (index <= 1 && distance < 0) //We've gone off the start, fail out - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); //Same thing, checking if we go off the end while (index < path_distances.size() && distance > path_distances[index]) @@ -732,7 +732,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: index++; } if (index >= path_distances.size()) - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); //Keep track of the initial index,distance incase we need to re-call get_placement_offset const unsigned initial_index = index; @@ -750,10 +750,10 @@ std::auto_ptr placement_finder::get_placement_offset(std:: double segment_length = path_distances[index]; if (segment_length == 0) { // Not allowed to place across on 0 length segments or discontinuities - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } - std::auto_ptr current_placement( + std::unique_ptr current_placement( new text_path((old_x + dx*distance/segment_length), (old_y + dy*distance/segment_length) ) @@ -778,7 +778,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: //Coordinates this character will start at if (segment_length == 0) { // Not allowed to place across on 0 length segments or discontinuities - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } double start_x = old_x + dx*distance/segment_length; double start_y = old_y + dy*distance/segment_length; @@ -806,7 +806,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: if (index >= path_positions.size()) //Bail out if we run off the end of the shape { //MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Out of space"; - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } new_x = path_positions[index].x; new_y = path_positions[index].y; @@ -843,7 +843,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: std::fabs(angle_delta) > p.max_char_angle_delta) { //MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Too Bendy!"; - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } double render_angle = angle; @@ -897,15 +897,15 @@ std::auto_ptr placement_finder::get_placement_offset(std:: { //Otherwise we have failed to find a placement //MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Double upside-down!"; - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } } - return current_placement; + return std::move(current_placement); } template -bool placement_finder::test_placement(std::auto_ptr const& current_placement, +bool placement_finder::test_placement(std::unique_ptr const& current_placement, int orientation) { //Create and test envelopes diff --git a/src/text_placements/simple.cpp b/src/text_placements/simple.cpp index ec5f812d0..25bd9d662 100644 --- a/src/text_placements/simple.cpp +++ b/src/text_placements/simple.cpp @@ -26,6 +26,8 @@ #include #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // boost #include #include diff --git a/src/transform_expression_grammar.cpp b/src/transform_expression_grammar.cpp index 4c5ab6d0a..d707bab65 100644 --- a/src/transform_expression_grammar.cpp +++ b/src/transform_expression_grammar.cpp @@ -20,6 +20,7 @@ * *****************************************************************************/ +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // mapnik #include diff --git a/src/wkb.cpp b/src/wkb.cpp index ed8c627c3..cdfa3182e 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -250,9 +250,9 @@ private: { double x = read_double(); double y = read_double(); - std::auto_ptr pt(new geometry_type(Point)); + std::unique_ptr pt(new geometry_type(Point)); pt->move_to(x, y); - paths.push_back(pt); + paths.push_back(pt.release()); } void read_multipoint(boost::ptr_vector & paths) @@ -269,10 +269,10 @@ private: { double x = read_double(); double y = read_double(); - std::auto_ptr pt(new geometry_type(Point)); + std::unique_ptr pt(new geometry_type(Point)); pos_ += 8; // double z = read_double(); pt->move_to(x, y); - paths.push_back(pt); + paths.push_back(pt.release()); } void read_multipoint_xyz(boost::ptr_vector & paths) @@ -292,13 +292,13 @@ private: { CoordinateArray ar(num_points); read_coords(ar); - std::auto_ptr line(new geometry_type(LineString)); + std::unique_ptr line(new geometry_type(LineString)); line->move_to(ar[0].x, ar[0].y); for (int i = 1; i < num_points; ++i) { line->line_to(ar[i].x, ar[i].y); } - paths.push_back(line); + paths.push_back(line.release()); } } @@ -319,13 +319,13 @@ private: { CoordinateArray ar(num_points); read_coords_xyz(ar); - std::auto_ptr line(new geometry_type(LineString)); + std::unique_ptr line(new geometry_type(LineString)); line->move_to(ar[0].x, ar[0].y); for (int i = 1; i < num_points; ++i) { line->line_to(ar[i].x, ar[i].y); } - paths.push_back(line); + paths.push_back(line.release()); } } @@ -345,7 +345,7 @@ private: int num_rings = read_integer(); if (num_rings > 0) { - std::auto_ptr poly(new geometry_type(Polygon)); + std::unique_ptr poly(new geometry_type(Polygon)); for (int i = 0; i < num_rings; ++i) { int num_points = read_integer(); @@ -362,7 +362,7 @@ private: } } if (poly->size() > 3) // ignore if polygon has less than (3 + close_path) vertices - paths.push_back(poly); + paths.push_back(poly.release()); } } @@ -381,7 +381,7 @@ private: int num_rings = read_integer(); if (num_rings > 0) { - std::auto_ptr poly(new geometry_type(Polygon)); + std::unique_ptr poly(new geometry_type(Polygon)); for (int i = 0; i < num_rings; ++i) { int num_points = read_integer(); @@ -398,7 +398,7 @@ private: } } if (poly->size() > 2) // ignore if polygon has less than 3 vertices - paths.push_back(poly); + paths.push_back(poly.release()); } } diff --git a/tests/cpp_tests/conversions_test.cpp b/tests/cpp_tests/conversions_test.cpp index 023d7f703..e4fc02b22 100644 --- a/tests/cpp_tests/conversions_test.cpp +++ b/tests/cpp_tests/conversions_test.cpp @@ -1,3 +1,5 @@ +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + #include #include #include diff --git a/tests/cpp_tests/geometry_converters_test.cpp b/tests/cpp_tests/geometry_converters_test.cpp index fbf60a5c0..fc7423c5e 100644 --- a/tests/cpp_tests/geometry_converters_test.cpp +++ b/tests/cpp_tests/geometry_converters_test.cpp @@ -12,7 +12,7 @@ #if BOOST_VERSION >= 104700 #include #include -#include +//#include #endif #include @@ -29,14 +29,14 @@ struct output_geometry_backend { mapnik::vertex2d vtx(mapnik::vertex2d::no_init); path.rewind(0); - std::auto_ptr geom_ptr(new mapnik::geometry_type(type_)); + std::unique_ptr geom_ptr(new mapnik::geometry_type(type_)); while ((vtx.cmd = path.vertex(&vtx.x, &vtx.y)) != mapnik::SEG_END) { //std::cerr << vtx.x << "," << vtx.y << " cmd=" << vtx.cmd << std::endl; geom_ptr->push_vertex(vtx.x, vtx.y, (mapnik::CommandType)vtx.cmd); } - paths_.push_back(geom_ptr); + paths_.push_back(geom_ptr.release()); } boost::ptr_vector & paths_; mapnik::eGeomType type_; diff --git a/tests/cpp_tests/image_io_test.cpp b/tests/cpp_tests/image_io_test.cpp index 42363a3d2..401f5ce91 100644 --- a/tests/cpp_tests/image_io_test.cpp +++ b/tests/cpp_tests/image_io_test.cpp @@ -22,7 +22,7 @@ int main( int, char*[] ) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); BOOST_TEST( false ); } catch (std::exception const&) @@ -36,7 +36,7 @@ int main( int, char*[] ) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); BOOST_TEST( false ); } catch (std::exception const&) @@ -50,7 +50,7 @@ int main( int, char*[] ) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); BOOST_TEST( false ); } catch (std::exception const&) @@ -64,7 +64,7 @@ int main( int, char*[] ) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); BOOST_TEST( false ); } catch (std::exception const&) @@ -78,7 +78,7 @@ int main( int, char*[] ) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); BOOST_TEST( false ); } catch (std::exception const&) diff --git a/tests/cpp_tests/map_request_test.cpp b/tests/cpp_tests/map_request_test.cpp index d14474750..716e41a3b 100644 --- a/tests/cpp_tests/map_request_test.cpp +++ b/tests/cpp_tests/map_request_test.cpp @@ -22,7 +22,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn) { using namespace mapnik; - std::auto_ptr reader1(mapnik::get_image_reader(dest_fn,"png")); + std::unique_ptr reader1(mapnik::get_image_reader(dest_fn,"png")); if (!reader1.get()) { throw mapnik::image_reader_exception("Failed to load: " + dest_fn); @@ -30,7 +30,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn) boost::shared_ptr image_ptr1 = boost::make_shared(reader1->width(),reader1->height()); reader1->read(0,0,image_ptr1->data()); - std::auto_ptr reader2(mapnik::get_image_reader(src_fn,"png")); + std::unique_ptr reader2(mapnik::get_image_reader(src_fn,"png")); if (!reader2.get()) { throw mapnik::image_reader_exception("Failed to load: " + src_fn); From 8bb6bb1d68afe7ae3da4c85bf77e5f9bba4d9519 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 11:59:16 +0100 Subject: [PATCH 021/122] + fix grammar to work with phoenix v3/c++11 --- include/mapnik/json/geometry_generator_grammar.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index a54253e01..dc99d98d3 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -42,7 +42,6 @@ #include #include // trunc to avoid needing C++11 - namespace boost { namespace spirit { namespace traits { // make gcc and darwin toolsets happy. @@ -234,6 +233,7 @@ struct multi_geometry_generator_grammar : using boost::spirit::karma::_1; using boost::spirit::karma::_a; using boost::spirit::karma::_r1; + using boost::spirit::karma::string; geometry_types.add (mapnik::Point,"\"Point\"") @@ -257,9 +257,9 @@ struct multi_geometry_generator_grammar : geometry = (lit("{\"type\":") << geometry_types[_1 = phoenix::at_c<0>(_a)][_a = _multi_type(_val)] << lit(",\"coordinates\":") - << karma::string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = '[']] + << string[ phoenix::if_ (phoenix::at_c<0>(_a) > 3) [_1 = '['].else_[_1 = ""]] << coordinates - << karma::string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = ']']] + << string[ phoenix::if_ (phoenix::at_c<0>(_a) > 3) [_1 = ']'].else_[_1 = ""]] << lit('}')) | lit("null") ; From 11bc9a03116565e9de5bee6395c8a9577baef2df Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 11:59:58 +0100 Subject: [PATCH 022/122] + re-enable geojson generator --- src/json/geojson_generator.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/json/geojson_generator.cpp b/src/json/geojson_generator.cpp index 34ec5e811..38ffb3d2a 100644 --- a/src/json/geojson_generator.cpp +++ b/src/json/geojson_generator.cpp @@ -20,13 +20,13 @@ * *****************************************************************************/ +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // boost #include #include #include -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - #if BOOST_VERSION >= 104700 #include @@ -36,28 +36,25 @@ namespace mapnik { namespace json { feature_generator::feature_generator() - : grammar_(0) {} // new feature_generator_grammar()) {} + : grammar_(new feature_generator_grammar()) {} feature_generator::~feature_generator() {} bool feature_generator::generate(std::string & geojson, mapnik::feature_impl const& f) { - //sink_type sink(geojson); - //return karma::generate(sink, *grammar_,f); - return false; + sink_type sink(geojson); + return karma::generate(sink, *grammar_,f); } - geometry_generator::geometry_generator() - : grammar_(0) {} //new multi_geometry_generator_grammar()) {} + : grammar_(new multi_geometry_generator_grammar()) {} geometry_generator::~geometry_generator() {} bool geometry_generator::generate(std::string & geojson, mapnik::geometry_container const& g) { -//sink_type sink(geojson); -// return karma::generate(sink, *grammar_,g); -return false; + sink_type sink(geojson); + return karma::generate(sink, *grammar_,g); } }} From 3a2b1dc0277f25fcfacf024beea011df302730b4 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 12:00:25 +0100 Subject: [PATCH 023/122] + move preprocessor directive to the top --- include/mapnik/json/feature_grammar.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index e26fc4342..84b6926ae 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -23,6 +23,7 @@ #ifndef MAPNIK_FEATURE_GRAMMAR_HPP #define MAPNIK_FEATURE_GRAMMAR_HPP +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // mapnik #include #include @@ -30,7 +31,6 @@ #include #include -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit::qi #include #include From d8fcf265609b56e16034c9ebca9519679c2bef86 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 12:00:58 +0100 Subject: [PATCH 024/122] + use std::move in tests --- benchmark/run.cpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index 38612f55d..658df8adf 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -410,14 +410,11 @@ struct test8 #include -#if BOOST_VERSION >= 105300 -//#include -//#include - class rule_cache_move { private: - BOOST_MOVABLE_BUT_NOT_COPYABLE(rule_cache_move) + rule_cache_move(rule_cache_move const& other) = delete; // no copy ctor + rule_cache_move& operator=(rule_cache_move const& other) = delete; // no assignment op public: typedef std::vector rule_ptrs; rule_cache_move() @@ -425,13 +422,13 @@ public: else_rules_(), also_rules_() {} - rule_cache_move(BOOST_RV_REF(rule_cache_move) rhs) // move ctor - : if_rules_(boost::move(rhs.if_rules_)), - else_rules_(boost::move(rhs.else_rules_)), - also_rules_(boost::move(rhs.also_rules_)) + rule_cache_move(rule_cache_move && rhs) // move ctor + : if_rules_(std::move(rhs.if_rules_)), + else_rules_(std::move(rhs.else_rules_)), + also_rules_(std::move(rhs.also_rules_)) {} - rule_cache_move& operator=(BOOST_RV_REF(rule_cache_move) rhs) // move assign + rule_cache_move& operator=(rule_cache_move && rhs) // move assign { std::swap(if_rules_, rhs.if_rules_); std::swap(else_rules_,rhs.else_rules_); @@ -491,9 +488,11 @@ struct test9 threads_(threads), num_rules_(num_rules), num_styles_(num_styles), - rules_() { + rules_() + { mapnik::rule r("test"); - for (unsigned i=0;i rule_caches; - for (unsigned i=0;i rule_caches; + for (unsigned i=0;i= 105300 test9 runner(1000,10,200,50); - benchmark(runner,"rule caching using boost::move"); + benchmark(runner,"rule caching using move semantics"); #else - std::clog << "not running: 'rule caching using boost::move'\n"; + std::clog << "not running: 'rule caching using move semantics'\n"; #endif } From b1ea547fa9f84b6a0bdf5baa5aa76eabc0ab8200 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 12:10:34 +0100 Subject: [PATCH 025/122] + fix grammar to work with phoenix v3 and c++11 --- include/mapnik/util/geometry_svg_generator.hpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index d6b8726cb..e8b31954b 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -170,12 +170,9 @@ namespace mapnik { namespace util { ; svg_path %= ((&uint_(mapnik::SEG_MOVETO) << lit("d=\"") << lit('M') - | &uint_(mapnik::SEG_LINETO) [_a +=1] << karma::string [if_(_a == 1) [_1 = "L" ] ]) + | &uint_(mapnik::SEG_LINETO) [_a +=1] << karma::string [if_(_a == 1) [_1 = "L" ].else_[_1 =""]]) << lit(' ') << coordinate << lit(' ') << coordinate) % lit(' ') ; - - - } // rules karma::rule svg; From 8908a4bd1b9b6ecb6d33e46f505db2dbcf8b103a Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 12:11:18 +0100 Subject: [PATCH 026/122] + re-enable svg generator --- bindings/python/mapnik_geometry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index 0b7a344fb..a24491ded 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -40,7 +40,7 @@ #if BOOST_VERSION >= 104700 #include #include -//#include +#include #endif namespace { @@ -230,7 +230,7 @@ std::string to_geojson( path_type const& geom) std::string to_svg( geometry_type const& geom) { -#if 0 // BOOST_VERSION >= 104700 +#if BOOST_VERSION >= 104700 std::string svg; // Use Python String directly ? bool result = mapnik::util::to_svg(svg,geom); if (!result) From c1b25607db2ca42c6a68083bfd07ccbd03336a14 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 13:49:16 +0100 Subject: [PATCH 027/122] + fix compiling miniz codec in c++11 mode FIXME: we should compile legacy "C" code with special flags.. --- src/build.py | 1 + src/miniz.c | 8 ++++---- src/miniz_png.cpp | 10 +++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/build.py b/src/build.py index dbadb71cb..73d9d3b5e 100644 --- a/src/build.py +++ b/src/build.py @@ -117,6 +117,7 @@ source = Split( well_known_srs.cpp params.cpp image_filter_types.cpp + miniz_png.cpp color.cpp css_color_grammar.cpp conversions.cpp diff --git a/src/miniz.c b/src/miniz.c index 03be47f2f..34a3c537b 100644 --- a/src/miniz.c +++ b/src/miniz.c @@ -789,7 +789,7 @@ size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void // Compresses an image to a compressed PNG file in memory. // On entry: -// pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4. +// pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4. // The image pitch in bytes per scanline will be w*num_chans. The leftmost pixel on the top scanline is stored first in memory. // On return: // Function returns a pointer to the compressed data, or NULL on failure. @@ -2778,8 +2778,8 @@ void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, *pLen_out = out_buf.m_size-41; { mz_uint8 pnghdr[41]={0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, - 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8,"\0\0\04\02\06"[num_chans],0,0,0,0,0,0,0, - (mz_uint8)(*pLen_out>>24),(mz_uint8)(*pLen_out>>16),(mz_uint8)(*pLen_out>>8),(mz_uint8)*pLen_out,0x49,0x44,0x41,0x54}; + 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8, (mz_uint8)"\0\0\04\02\06"[num_chans],0,0,0,0,0,0,0, + (mz_uint8)(*pLen_out>>24),(mz_uint8)(*pLen_out>>16),(mz_uint8)(*pLen_out>>8),(mz_uint8)*pLen_out,0x49,0x44,0x41,0x54}; c=(mz_uint32)mz_crc32(MZ_CRC32_INIT,pnghdr+12,17); for (i=0; i<4; ++i, c<<=8) ((mz_uint8*)(pnghdr+29))[i]=(mz_uint8)(c>>24); memcpy(out_buf.m_pBuf, pnghdr, 41); } @@ -4831,4 +4831,4 @@ void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to -*/ \ No newline at end of file +*/ diff --git a/src/miniz_png.cpp b/src/miniz_png.cpp index ec445d0ba..8278032d0 100644 --- a/src/miniz_png.cpp +++ b/src/miniz_png.cpp @@ -30,8 +30,10 @@ #define MINIZ_NO_ARCHIVE_APIS #define MINIZ_NO_STDIO #define MINIZ_NO_ZLIB_COMPATIBLE_NAMES -#include "miniz.c" +extern "C" { +#include "miniz.c" +} // zlib #include @@ -142,7 +144,10 @@ void PNGWriter::finishChunk(size_t start) // Write CRC32 checksum. Don't include the 4-byte length, but /do/ include // the 4-byte chunk name. mz_uint32 crc = mz_crc32(MZ_CRC32_INIT, buffer->m_pBuf + start + 4, payloadLength + 4); - mz_uint8 checksum[] = { crc >> 24, crc >> 16, crc >> 8, crc }; + mz_uint8 checksum[] = { static_cast(crc >> 24), + static_cast(crc >> 16), + static_cast(crc >> 8), + static_cast(crc) }; mz_bool status = tdefl_output_buffer_putter(checksum, 4, buffer); if (status != MZ_TRUE) { @@ -362,4 +367,3 @@ template void PNGWriter::writeIDATStripAlpha(image_data_32 const& template void PNGWriter::writeIDATStripAlpha >(image_view const& image); }} - From ae9b51861894b9bb4c5ebbf17290cea378418360 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 14:13:18 +0100 Subject: [PATCH 028/122] + fix coords precision --- include/mapnik/json/geometry_generator_grammar.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index dc99d98d3..207b5856d 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -40,7 +40,6 @@ #include #include #include -#include // trunc to avoid needing C++11 namespace boost { namespace spirit { namespace traits { @@ -121,7 +120,7 @@ struct json_coordinate_policy : karma::real_policies { if (n == 0.0) return 0; using namespace boost::spirit; - return static_cast(15 - boost::math::trunc(log10(traits::get_absolute_value(n)))); + return static_cast(14 - std::trunc(log10(traits::get_absolute_value(n)))); } template From d215c097625304116bd23397b1a54191b5962d32 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 19 Apr 2013 14:21:12 +0100 Subject: [PATCH 029/122] + json-generator : don't output coordinates from SEG_CLOSE command --- include/mapnik/json/geometry_generator_grammar.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index 207b5856d..c653e37b2 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -184,7 +184,10 @@ struct geometry_generator_grammar : polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1] << karma::string[ if_ (_r1 > 1) [_1 = "],["] - .else_[_1 = '[' ]] | &uint_ << lit(',')) + .else_[_1 = '[' ]] + | + &uint_(mapnik::SEG_LINETO)) + << lit(',') << lit('[') << coord_type << lit(',') << coord_type << lit(']') From 800ee1f0dd0f3804c10057dcade2f9202ecbd35b Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 22 Apr 2013 09:56:48 +0100 Subject: [PATCH 030/122] + c++ style --- include/mapnik/factory.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mapnik/factory.hpp b/include/mapnik/factory.hpp index 656b0cdca..8b1c938fa 100644 --- a/include/mapnik/factory.hpp +++ b/include/mapnik/factory.hpp @@ -47,7 +47,7 @@ private: product_map map_; public: - bool register_product(const key_type& key, product_creator creator) + bool register_product(key_type const& key, product_creator creator) { return map_.insert(typename product_map::value_type(key,creator)).second; } @@ -57,7 +57,7 @@ public: return map_.erase(key)==1; } - product_type* create_object(const key_type& key, Args...args) + product_type* create_object(key_type const& key, Args...args) { typename product_map::const_iterator pos=map_.find(key); if (pos!=map_.end()) From e38ce37ed33c54ebc44f1a43acdbd28bf375a113 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 22 Apr 2013 15:24:47 +0100 Subject: [PATCH 031/122] * use move semantics * use light weight wkb_stream wrapper to avoid locale/formatting locking --- include/mapnik/util/geometry_to_wkb.hpp | 65 ++++++++++++++++--------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/include/mapnik/util/geometry_to_wkb.hpp b/include/mapnik/util/geometry_to_wkb.hpp index ef7f0784c..f3a0ac5e8 100644 --- a/include/mapnik/util/geometry_to_wkb.hpp +++ b/include/mapnik/util/geometry_to_wkb.hpp @@ -27,15 +27,10 @@ #include #include -// boost -#include -#include -#include -#include - // stl #include #include +#include namespace mapnik { namespace util { @@ -73,6 +68,29 @@ inline void reverse_bytes(char size, char *address) } } +struct wkb_stream +{ + wkb_stream(char * buffer, std::size_t size) + : buffer_(buffer), + size_(size), + pos_(0) {} + + void write(char const* data, std::size_t size) + { + std::memcpy(buffer_ + pos_, data, size); + pos_ += size; + } + + bool good() + { + return (pos_ <= size_) ? true : false; + } + + char * buffer_; + std::streamsize size_; + std::streamsize pos_; +}; + template inline void write (S & stream, T val, std::size_t size, wkbByteOrder byte_order) { @@ -115,15 +133,15 @@ struct wkb_buffer char * data_; }; -typedef boost::shared_ptr wkb_buffer_ptr; +typedef std::unique_ptr wkb_buffer_ptr; template wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order) { assert(g.size() == 1); std::size_t size = 1 + 4 + 8*2 ; // byteOrder + wkbType + Point - wkb_buffer_ptr wkb = boost::make_shared(size); - boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary); + wkb_buffer_ptr wkb(new wkb_buffer(size)); + wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); int type = static_cast(mapnik::Point); write(ss,type,4,byte_order); @@ -133,7 +151,7 @@ wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order) write(ss,x,8,byte_order); write(ss,y,8,byte_order); assert(ss.good()); - return wkb; + return std::move(wkb); } template @@ -142,8 +160,8 @@ wkb_buffer_ptr to_line_string_wkb( GeometryType const& g, wkbByteOrder byte_orde unsigned num_points = g.size(); assert(num_points > 1); std::size_t size = 1 + 4 + 4 + 8*2*num_points ; // byteOrder + wkbType + numPoints + Point*numPoints - wkb_buffer_ptr wkb = boost::make_shared(size); - boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary); + wkb_buffer_ptr wkb(new wkb_buffer(size)); + wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); int type = static_cast(mapnik::LineString); write(ss,type,4,byte_order); @@ -157,7 +175,7 @@ wkb_buffer_ptr to_line_string_wkb( GeometryType const& g, wkbByteOrder byte_orde write(ss,y,8,byte_order); } assert(ss.good()); - return wkb; + return std::move(wkb); } template @@ -190,19 +208,18 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) } } unsigned num_rings = rings.size(); - wkb_buffer_ptr wkb = boost::make_shared(size); - boost::interprocess::bufferstream ss(wkb->buffer(), wkb->size(), std::ios::out | std::ios::binary); - + wkb_buffer_ptr wkb(new wkb_buffer(size)); + wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); int type = static_cast(mapnik::Polygon); write(ss,type,4,byte_order); write(ss,num_rings,4,byte_order); - BOOST_FOREACH ( linear_ring const& ring, rings) + for ( linear_ring const& ring : rings) { unsigned num_ring_points = ring.size(); write(ss,num_ring_points,4,byte_order); - BOOST_FOREACH ( point_type const& pt, ring) + for ( point_type const& pt : ring) { write(ss,pt.first,8,byte_order); write(ss,pt.second,8,byte_order); @@ -210,7 +227,7 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) } assert(ss.good()); - return wkb; + return std::move(wkb); } template @@ -260,21 +277,21 @@ wkb_buffer_ptr to_wkb(geometry_container const& paths, wkbByteOrder byte_order ) if (multi_type > 0 && multi_type != itr->type()) collection = true; multi_type = type; - wkb_cont.push_back(wkb); + wkb_cont.push_back(std::move(wkb)); } - wkb_buffer_ptr multi_wkb = boost::make_shared(multi_size); - boost::interprocess::bufferstream ss(multi_wkb->buffer(), multi_wkb->size(), std::ios::out | std::ios::binary); + wkb_buffer_ptr multi_wkb( new wkb_buffer(multi_size)); + wkb_stream ss(multi_wkb->buffer(), multi_wkb->size()); ss.write(reinterpret_cast(&byte_order),1); multi_type = collection ? 7 : multi_type + 3; write(ss,multi_type, 4, byte_order); write(ss,paths.size(),4,byte_order); - BOOST_FOREACH ( wkb_buffer_ptr const& wkb, wkb_cont) + for ( wkb_buffer_ptr const& wkb : wkb_cont) { ss.write(wkb->buffer(),wkb->size()); } - return multi_wkb; + return std::move(multi_wkb); } return wkb_buffer_ptr(); From 2b9ce8322634bc8e1f6cf90e0345fdd7fbf88e53 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 23 Apr 2013 12:29:43 +0100 Subject: [PATCH 032/122] + fix typo --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 217931e78..d01f876c0 100644 --- a/SConstruct +++ b/SConstruct @@ -1179,7 +1179,7 @@ if not preconfigured: env.AppendUnique(CPPPATH = os.path.realpath(inc_path)) env.AppendUnique(LIBPATH = os.path.realpath(lib_path)) else: - env['SKIPPED_DEPS'].extend(['png']) + env['SKIPPED_DEPS'].extend(['webp']) if env['TIFF']: From 80c54521303b7802c41c9beab9998c680b05dc7d Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 23 Apr 2013 14:00:08 +0100 Subject: [PATCH 033/122] + fix phoenix functions to compile on ubuntu 12.04/c++11 + cleanups --- include/mapnik/css_color_grammar.hpp | 28 +- include/mapnik/css_color_grammar_def.hpp | 2 - include/mapnik/expression_grammar.hpp | 23 +- include/mapnik/json/feature_grammar.hpp | 22 +- .../json/geometry_generator_grammar.hpp | 20 +- include/mapnik/json/geometry_grammar.hpp | 25 +- .../mapnik/util/geometry_svg_generator.hpp | 13 +- include/mapnik/wkt/wkt_grammar.hpp | 275 +++++++++--------- 8 files changed, 169 insertions(+), 239 deletions(-) diff --git a/include/mapnik/css_color_grammar.hpp b/include/mapnik/css_color_grammar.hpp index 51d498428..8778d8e10 100644 --- a/include/mapnik/css_color_grammar.hpp +++ b/include/mapnik/css_color_grammar.hpp @@ -23,11 +23,11 @@ #ifndef MAPNIK_CSS_COLOR_GRAMMAR_HPP #define MAPNIK_CSS_COLOR_GRAMMAR_HPP -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // mapnik #include +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + // spirit2 #include #include @@ -99,13 +99,9 @@ inline int clip_int(int val) struct percent_conv_impl { - template - struct result - { - typedef unsigned type; - }; + typedef unsigned result_type; - unsigned operator() (double val) const + result_type operator() (double val) const { return clip_int<0,255>(int((255.0 * val)/100.0 + 0.5)); } @@ -113,13 +109,9 @@ struct percent_conv_impl struct alpha_conv_impl { - template - struct result - { - typedef unsigned type; - }; + typedef unsigned result_type; - unsigned operator() (double val) const + result_type operator() (double val) const { return clip_int<0,255>(int((255.0 * val) + 0.5)); } @@ -127,14 +119,10 @@ struct alpha_conv_impl struct hsl_conv_impl { - template - struct result - { - typedef void type; - }; + typedef void result_type; template - void operator() (T0 & c, T1 h, T2 s, T3 l) const + result_type operator() (T0 & c, T1 h, T2 s, T3 l) const { double m1,m2; // normalize values diff --git a/include/mapnik/css_color_grammar_def.hpp b/include/mapnik/css_color_grammar_def.hpp index 57768e895..028411ba1 100644 --- a/include/mapnik/css_color_grammar_def.hpp +++ b/include/mapnik/css_color_grammar_def.hpp @@ -23,8 +23,6 @@ #ifndef MAPNIK_CSS_COLOR_GRAMMAR_DEF_HPP #define MAPNIK_CSS_COLOR_GRAMMAR_DEF_HPP -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // boost #include diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp index 50ac37ded..8b82e53fb 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -47,11 +47,7 @@ using standard_wide::space_type; struct unicode_impl { - template - struct result - { - typedef UnicodeString type; - }; + typedef UnicodeString result_type; explicit unicode_impl(mapnik::transcoder const& tr) : tr_(tr) {} @@ -66,34 +62,27 @@ struct unicode_impl struct regex_match_impl { - template - struct result - { - typedef expr_node type; - }; + + typedef expr_node result_type; explicit regex_match_impl(mapnik::transcoder const& tr) : tr_(tr) {} template - expr_node operator() (T0 & node, T1 const& pattern) const; + result_type operator() (T0 & node, T1 const& pattern) const; mapnik::transcoder const& tr_; }; struct regex_replace_impl { - template - struct result - { - typedef expr_node type; - }; + typedef expr_node result_type; explicit regex_replace_impl(mapnik::transcoder const& tr) : tr_(tr) {} template - expr_node operator() (T0 & node, T1 const& pattern, T2 const& format) const; + result_type operator() (T0 & node, T1 const& pattern, T2 const& format) const; mapnik::transcoder const& tr_; }; diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index 84b6926ae..780dc34ba 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -69,16 +69,14 @@ public: struct put_property { - template - struct result - { - typedef void type; - }; + + typedef void result_type; + explicit put_property(mapnik::transcoder const& tr) : tr_(tr) {} template - void operator() (T0 & feature, T1 const& key, T2 const& val) const + result_type operator() (T0 & feature, T1 const& key, T2 const& val) const { mapnik::value v = boost::apply_visitor(attribute_value_visitor(tr_),val); // TODO: optimize feature.put_new(key, v); @@ -89,14 +87,10 @@ struct put_property struct extract_geometry { - template - struct result - { - typedef boost::ptr_vector& type; - }; + typedef boost::ptr_vector& result_type; template - boost::ptr_vector& operator() (T & feature) const + result_type operator() (T & feature) const { return feature.paths(); } @@ -104,8 +98,8 @@ struct extract_geometry template struct feature_grammar : - qi::grammar + qi::grammar { feature_grammar(mapnik::transcoder const& tr); diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index c653e37b2..dbd8e6a17 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -60,10 +60,8 @@ namespace { struct get_type { - template - struct result { typedef int type; }; - - int operator() (geometry_type const& geom) const + typedef int result_type; + result_type operator() (geometry_type const& geom) const { return static_cast(geom.type()); } @@ -71,10 +69,8 @@ struct get_type struct get_first { - template - struct result { typedef geometry_type::value_type const type; }; - - geometry_type::value_type const operator() (geometry_type const& geom) const + typedef geometry_type::value_type const result_type; + result_type operator() (geometry_type const& geom) const { geometry_type::value_type coord; boost::get<0>(coord) = geom.vertex(0,&boost::get<1>(coord),&boost::get<2>(coord)); @@ -84,10 +80,8 @@ struct get_first struct multi_geometry_type { - template - struct result { typedef boost::tuple type; }; - - boost::tuple operator() (geometry_container const& geom) const + typedef boost::tuple result_type; + result_type operator() (geometry_container const& geom) const { unsigned type = 0u; bool collection = false; @@ -132,7 +126,7 @@ struct json_coordinate_policy : karma::real_policies template static bool fraction_part(OutputIterator& sink, T n - , unsigned adjprec, unsigned precision) + , unsigned adjprec, unsigned precision) { if (n == 0) return true; return base_type::fraction_part(sink, n, adjprec, precision); diff --git a/include/mapnik/json/geometry_grammar.hpp b/include/mapnik/json/geometry_grammar.hpp index 308f0048a..42e3fe92f 100644 --- a/include/mapnik/json/geometry_grammar.hpp +++ b/include/mapnik/json/geometry_grammar.hpp @@ -41,14 +41,10 @@ using standard_wide::space_type; struct push_vertex { - template - struct result - { - typedef void type; - }; + typedef void result_type; template - void operator() (T0 c, T1 path, T2 x, T3 y) const + result_type operator() (T0 c, T1 path, T2 x, T3 y) const { BOOST_ASSERT( path!=0 ); path->push_vertex(x,y,c); @@ -57,14 +53,10 @@ struct push_vertex struct close_path { - template - struct result - { - typedef void type; - }; + typedef void result_type; template - void operator() (T path) const + result_type operator() (T path) const { BOOST_ASSERT( path!=0 ); path->close_path(); @@ -73,12 +65,7 @@ struct close_path struct cleanup { - template - struct result - { - typedef void type; - }; - + typedef void result_type; template void operator() (T0 & path) const { @@ -89,7 +76,7 @@ struct cleanup template struct geometry_grammar : qi::grammar, void(boost::ptr_vector& ) - , space_type> + , space_type> { geometry_grammar(); qi::rule, void(boost::ptr_vector& ),space_type> geometry; diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index e8b31954b..a818a423b 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -96,10 +96,8 @@ namespace mapnik { namespace util { template struct get_type { - template - struct result { typedef int type; }; - - int operator() (Geometry const& geom) const + typedef int result_type; + result_type operator() (Geometry const& geom) const { return static_cast(geom.type()); } @@ -109,11 +107,8 @@ namespace mapnik { namespace util { struct get_first { typedef T geometry_type; - - template - struct result { typedef typename geometry_type::value_type const type; }; - - typename geometry_type::value_type const operator() (geometry_type const& geom) const + typedef typename geometry_type::value_type const result_type; + result_type const operator() (geometry_type const& geom) const { typename geometry_type::value_type coord; geom.rewind(0); diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index 1d09cda62..b657cb90e 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -41,179 +41,164 @@ namespace mapnik { namespace wkt { - using namespace boost::spirit; - using namespace boost::fusion; - using namespace boost::phoenix; +using namespace boost::spirit; +using namespace boost::fusion; +using namespace boost::phoenix; - struct push_vertex +struct push_vertex +{ + typedef void result_type; + template + result_type operator() (T0 c, T1 path, T2 x, T3 y) const { - template - struct result - { - typedef void type; - }; + BOOST_ASSERT( path!=0 ); + path->push_vertex(x,y,c); + } +}; - template - void operator() (T0 c, T1 path, T2 x, T3 y) const - { - BOOST_ASSERT( path!=0 ); - path->push_vertex(x,y,c); - } - }; - - struct close_path +struct close_path +{ + typedef void result_type; + template + result_type operator() (T path) const { - template - struct result - { - typedef void type; - }; + BOOST_ASSERT( path!=0 ); + path->close_path(); + } +}; - template - void operator() (T path) const - { - BOOST_ASSERT( path!=0 ); - path->close_path(); - } - }; - - struct cleanup +struct cleanup +{ + typedef void result_type; + template + void operator() (T0 & path) const { - template - struct result - { - typedef void type; - }; + if (path) delete path,path=0; + } +}; - template - void operator() (T0 & path) const - { - if (path) delete path,path=0; - } - }; - - template - struct wkt_grammar : qi::grammar() , ascii::space_type> +template +struct wkt_grammar : qi::grammar() , ascii::space_type> +{ + wkt_grammar() + : wkt_grammar::base_type(geometry_tagged_text) { - wkt_grammar() - : wkt_grammar::base_type(geometry_tagged_text) - { - using qi::no_case; - using qi::_1; - using qi::_2; - using boost::phoenix::push_back; + using qi::no_case; + using qi::_1; + using qi::_2; + using boost::phoenix::push_back; - geometry_tagged_text = point_tagged_text - | linestring_tagged_text - | polygon_tagged_text - | multipoint_tagged_text - | multilinestring_tagged_text - | multipolygon_tagged_text - ; + geometry_tagged_text = point_tagged_text + | linestring_tagged_text + | polygon_tagged_text + | multipoint_tagged_text + | multilinestring_tagged_text + | multipolygon_tagged_text + ; - // ::= point - point_tagged_text = no_case[lit("POINT")] [ _a = new_(Point) ] - >> ( point_text(_a) [push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) - ; + // ::= point + point_tagged_text = no_case[lit("POINT")] [ _a = new_(Point) ] + >> ( point_text(_a) [push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) + ; - // ::= | - point_text = (lit("(") >> point(SEG_MOVETO,_r1) >> lit(')')) - | empty_set - ; + // ::= | + point_text = (lit("(") >> point(SEG_MOVETO,_r1) >> lit(')')) + | empty_set + ; - // ::= linestring - linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(LineString) ] - >> (linestring_text(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) - ; + // ::= linestring + linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(LineString) ] + >> (linestring_text(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) + ; - // ::= | { }* - linestring_text = points(_r1) | empty_set - ; + // ::= | { }* + linestring_text = points(_r1) | empty_set + ; - // ::= polygon - polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(Polygon) ] - >> ( polygon_text(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) - ; + // ::= polygon + polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(Polygon) ] + >> ( polygon_text(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) + ; - // ::= | { }* - polygon_text = (lit('(') >> linestring_text(_r1)[close_path_(_r1)] % lit(',') >> lit(')')) | empty_set; + // ::= | { }* + polygon_text = (lit('(') >> linestring_text(_r1)[close_path_(_r1)] % lit(',') >> lit(')')) | empty_set; - // ::= multipoint - multipoint_tagged_text = no_case[lit("MULTIPOINT")] - >> multipoint_text - ; + // ::= multipoint + multipoint_tagged_text = no_case[lit("MULTIPOINT")] + >> multipoint_text + ; - // ::= | { }* - multipoint_text = (lit('(') - >> ((eps[_a = new_(Point)] - >> (point_text(_a) | empty_set) [push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) % lit(',')) - >> lit(')')) | empty_set - ; + // ::= | { }* + multipoint_text = (lit('(') + >> ((eps[_a = new_(Point)] + >> (point_text(_a) | empty_set) [push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) % lit(',')) + >> lit(')')) | empty_set + ; - // ::= multilinestring - multilinestring_tagged_text = no_case[lit("MULTILINESTRING")] - >> multilinestring_text ; + // ::= multilinestring + multilinestring_tagged_text = no_case[lit("MULTILINESTRING")] + >> multilinestring_text ; - // ::= | { }* - multilinestring_text = (lit('(') - >> ((eps[_a = new_(LineString)] - >> ( points(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false])) - % lit(',')) - >> lit(')')) | empty_set; + // ::= | { }* + multilinestring_text = (lit('(') + >> ((eps[_a = new_(LineString)] + >> ( points(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false])) + % lit(',')) + >> lit(')')) | empty_set; - // ::= multipolygon - multipolygon_tagged_text = no_case[lit("MULTIPOLYGON")] - >> multipolygon_text ; + // ::= multipolygon + multipolygon_tagged_text = no_case[lit("MULTIPOLYGON")] + >> multipolygon_text ; - // ::= | { }* + // ::= | { }* - multipolygon_text = (lit('(') - >> ((eps[_a = new_(Polygon)] - >> ( polygon_text(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false])) - % lit(',')) - >> lit(')')) | empty_set; + multipolygon_text = (lit('(') + >> ((eps[_a = new_(Polygon)] + >> ( polygon_text(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false])) + % lit(',')) + >> lit(')')) | empty_set; - // points - points = lit('(')[_a = SEG_MOVETO] >> point (_a,_r1) % lit(',') [_a = SEG_LINETO] >> lit(')'); - // point - point = (double_ >> double_) [push_vertex_(_r1,_r2,_1,_2)]; + // points + points = lit('(')[_a = SEG_MOVETO] >> point (_a,_r1) % lit(',') [_a = SEG_LINETO] >> lit(')'); + // point + point = (double_ >> double_) [push_vertex_(_r1,_r2,_1,_2)]; - // - empty_set = no_case[lit("EMPTY")]; + // + empty_set = no_case[lit("EMPTY")]; - } + } - // start - qi::rule(),ascii::space_type> geometry_tagged_text; + // start + qi::rule(),ascii::space_type> geometry_tagged_text; - qi::rule,boost::ptr_vector(),ascii::space_type> point_tagged_text; - qi::rule,boost::ptr_vector(),ascii::space_type> linestring_tagged_text; - qi::rule,boost::ptr_vector(),ascii::space_type> polygon_tagged_text; - qi::rule(),ascii::space_type> multipoint_tagged_text; - qi::rule(),ascii::space_type> multilinestring_tagged_text; - qi::rule(),ascii::space_type> multipolygon_tagged_text; - // - qi::rule point_text; - qi::rule linestring_text; - qi::rule polygon_text; - qi::rule, boost::ptr_vector(),ascii::space_type> multipoint_text; - qi::rule, boost::ptr_vector(),ascii::space_type> multilinestring_text; - qi::rule, boost::ptr_vector(),ascii::space_type> multipolygon_text; - // - qi::rule point; - qi::rule,void(geometry_type*),ascii::space_type> points; - qi::rule empty_set; - boost::phoenix::function push_vertex_; - boost::phoenix::function close_path_; - boost::phoenix::function cleanup_; - }; + qi::rule,boost::ptr_vector(),ascii::space_type> point_tagged_text; + qi::rule,boost::ptr_vector(),ascii::space_type> linestring_tagged_text; + qi::rule,boost::ptr_vector(),ascii::space_type> polygon_tagged_text; + qi::rule(),ascii::space_type> multipoint_tagged_text; + qi::rule(),ascii::space_type> multilinestring_tagged_text; + qi::rule(),ascii::space_type> multipolygon_tagged_text; + // + qi::rule point_text; + qi::rule linestring_text; + qi::rule polygon_text; + qi::rule, boost::ptr_vector(),ascii::space_type> multipoint_text; + qi::rule, boost::ptr_vector(),ascii::space_type> multilinestring_text; + qi::rule, boost::ptr_vector(),ascii::space_type> multipolygon_text; + // + qi::rule point; + qi::rule,void(geometry_type*),ascii::space_type> points; + qi::rule empty_set; + boost::phoenix::function push_vertex_; + boost::phoenix::function close_path_; + boost::phoenix::function cleanup_; +}; template From f897a54445fe73e4558fe286459d8635c6d8e955 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 23 Apr 2013 15:10:06 +0100 Subject: [PATCH 034/122] + reflect wkt_parser in python ```python import mapnik reader = mapnik.WKTReader() geometry = reader.read("Point(123 123)") ``` --- bindings/python/mapnik_python.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bindings/python/mapnik_python.cpp b/bindings/python/mapnik_python.cpp index 4ef560c23..9caf993c5 100644 --- a/bindings/python/mapnik_python.cpp +++ b/bindings/python/mapnik_python.cpp @@ -69,6 +69,7 @@ void export_view_transform(); void export_raster_colorizer(); void export_label_collision_detector(); void export_logger(); +void export_wkt_reader(); #include #include @@ -479,6 +480,7 @@ BOOST_PYTHON_MODULE(_mapnik) export_raster_colorizer(); export_label_collision_detector(); export_logger(); + export_wkt_reader(); def("clear_cache", &clear_cache, "\n" From 03d08799e085d647844551b7e3cd3d412b8768e7 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 23 Apr 2013 18:18:03 +0100 Subject: [PATCH 035/122] + add missing .cpp file --- bindings/python/mapnik_wkt_reader.cpp | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 bindings/python/mapnik_wkt_reader.cpp diff --git a/bindings/python/mapnik_wkt_reader.cpp b/bindings/python/mapnik_wkt_reader.cpp new file mode 100644 index 000000000..3e9fa9be4 --- /dev/null +++ b/bindings/python/mapnik_wkt_reader.cpp @@ -0,0 +1,55 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2013 Artem Pavlenko, Jean-Francois Doyon + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +// boost +#include +#include +#include +#include +#include +// mapnik +#include +#include + +namespace impl { + +typedef boost::ptr_vector path_type; + +boost::shared_ptr from_wkt(mapnik::wkt_parser & p, std::string const& wkt) +{ + boost::shared_ptr paths = boost::make_shared(); + if (!p.parse(wkt, *paths)) + throw std::runtime_error("Failed to parse WKT"); + return paths; +} + +} + +void export_wkt_reader() +{ + using mapnik::wkt_parser; + using namespace boost::python; + + class_("WKTReader",init<>()) + .def("read",&impl::from_wkt) + ; +} From 49fe99ac4fd1a5b04ac5559309858119e2020621 Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 24 Apr 2013 10:08:10 +0100 Subject: [PATCH 036/122] + make rule_cache movable + use rule_cache move semantics in feature processor --- .../mapnik/feature_style_processor_impl.hpp | 18 ++++++++--------- include/mapnik/rule_cache.hpp | 20 ++++++++++++++++--- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index f1a893d71..ec6b1a5c0 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -401,9 +401,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces double filt_factor = 1.0; directive_collector d_collector(filt_factor); - std::vector > rule_caches; - //boost::ptr_vector rule_caches; - + std::vector rule_caches; // iterate through all named styles collecting active styles and attribute names BOOST_FOREACH(std::string const& style_name, style_names) { @@ -419,12 +417,12 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces std::vector const& rules = style->get_rules(); bool active_rules = false; - std::unique_ptr rc_ptr(new rule_cache); + rule_cache cache; for (auto const& r : rules) { if (r.active(scale_denom)) { - rc_ptr->add_rule(r); + cache.add_rule(r); active_rules = true; if (ds->type() == datasource::Vector) { @@ -435,7 +433,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces } if (active_rules) { - rule_caches.push_back(std::move(rc_ptr)); + rule_caches.push_back(std::move(cache)); active_styles.push_back(&(*style)); } } @@ -507,7 +505,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces int i = 0; BOOST_FOREACH (feature_type_style const* style, active_styles) { - render_style(lay, p, style, *rule_caches[i], style_names[i], + render_style(lay, p, style, rule_caches[i], style_names[i], cache.features(q), prj_trans); i++; } @@ -520,7 +518,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces int i = 0; BOOST_FOREACH (feature_type_style const* style, active_styles) { - render_style(lay, p, style, *rule_caches[i], style_names[i], + render_style(lay, p, style, rule_caches[i], style_names[i], cache.features(q), prj_trans); i++; } @@ -541,7 +539,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces int i = 0; BOOST_FOREACH (feature_type_style const* style, active_styles) { - render_style(lay, p, style, *rule_caches[i], style_names[i], + render_style(lay, p, style, rule_caches[i], style_names[i], cache.features(q), prj_trans); i++; } @@ -552,7 +550,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces int i = 0; BOOST_FOREACH (feature_type_style const* style, active_styles) { - render_style(lay, p, style, *rule_caches[i], style_names[i], + render_style(lay, p, style, rule_caches[i], style_names[i], ds->features(q), prj_trans); i++; } diff --git a/include/mapnik/rule_cache.hpp b/include/mapnik/rule_cache.hpp index 920b40334..b9a6b5a25 100644 --- a/include/mapnik/rule_cache.hpp +++ b/include/mapnik/rule_cache.hpp @@ -27,9 +27,6 @@ #include #include -// boost -#include - // stl #include @@ -38,6 +35,9 @@ namespace mapnik class rule_cache { +private: + rule_cache(rule_cache const& other) = delete; // no copy ctor + rule_cache& operator=(rule_cache const& other) = delete; // no assignment op public: typedef std::vector rule_ptrs; rule_cache() @@ -45,6 +45,20 @@ public: else_rules_(), also_rules_() {} + rule_cache(rule_cache && rhs) // move ctor + : if_rules_(std::move(rhs.if_rules_)), + else_rules_(std::move(rhs.else_rules_)), + also_rules_(std::move(rhs.also_rules_)) + {} + + rule_cache& operator=(rule_cache && rhs) // move assign + { + std::swap(if_rules_, rhs.if_rules_); + std::swap(else_rules_,rhs.else_rules_); + std::swap(also_rules_, rhs.also_rules_); + return *this; + } + void add_rule(rule const& r) { if (r.has_else_filter()) From 58927b404c8028d566debd64a88b963837f76539 Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 24 Apr 2013 16:40:35 +0100 Subject: [PATCH 037/122] c++11 + replace BOOST_FOREACH with for( : ) + remove boost/foreach.hpp + fix benchmarks (17,18) --- benchmark/run.cpp | 126 ++---------------- bindings/python/mapnik_geometry.cpp | 2 +- bindings/python/mapnik_query.cpp | 7 +- bindings/python/python_grid_utils.cpp | 8 +- include/mapnik/cairo_context.hpp | 2 +- .../mapnik/feature_style_processor_impl.hpp | 39 +++--- include/mapnik/font_engine_freetype.hpp | 4 +- include/mapnik/hit_test_filter.hpp | 4 +- include/mapnik/image_filter.hpp | 4 +- include/mapnik/marker_helpers.hpp | 4 +- include/mapnik/polygon_clipper.hpp | 10 +- include/mapnik/svg/svg_renderer_agg.hpp | 4 +- include/mapnik/transform_processor.hpp | 8 +- include/mapnik/vertex_converters.hpp | 2 +- plugins/input/geojson/geojson_datasource.cpp | 4 +- plugins/input/python/python_datasource.cpp | 6 +- src/agg/agg_renderer.cpp | 4 +- src/agg/process_line_pattern_symbolizer.cpp | 4 +- src/agg/process_line_symbolizer.cpp | 6 +- .../process_polygon_pattern_symbolizer.cpp | 4 +- src/agg/process_polygon_symbolizer.cpp | 4 +- src/cairo_renderer.cpp | 6 +- src/deepcopy.cpp | 8 +- src/feature_type_style.cpp | 4 +- src/font_engine_freetype.cpp | 6 +- src/formatting/list.cpp | 13 +- src/grid/process_line_symbolizer.cpp | 5 +- .../process_polygon_pattern_symbolizer.cpp | 5 +- src/grid/process_polygon_symbolizer.cpp | 5 +- src/image_util.cpp | 4 +- src/parse_path.cpp | 12 +- src/placement_finder.cpp | 4 +- src/svg/output/process_symbolizers.cpp | 2 +- src/svg/svg_parser.cpp | 78 +++++------ src/transform_expression.cpp | 4 +- tests/cpp_tests/clipping_test.cpp | 4 +- tests/cpp_tests/geometry_converters_test.cpp | 4 +- tests/cpp_tests/map_request_test.cpp | 4 +- utils/geometry_to_wkb/main.cpp | 6 +- 39 files changed, 157 insertions(+), 273 deletions(-) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index 658df8adf..ece56bde4 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -410,69 +410,6 @@ struct test8 #include -class rule_cache_move -{ -private: - rule_cache_move(rule_cache_move const& other) = delete; // no copy ctor - rule_cache_move& operator=(rule_cache_move const& other) = delete; // no assignment op -public: - typedef std::vector rule_ptrs; - rule_cache_move() - : if_rules_(), - else_rules_(), - also_rules_() {} - - rule_cache_move(rule_cache_move && rhs) // move ctor - : if_rules_(std::move(rhs.if_rules_)), - else_rules_(std::move(rhs.else_rules_)), - also_rules_(std::move(rhs.also_rules_)) - {} - - rule_cache_move& operator=(rule_cache_move && rhs) // move assign - { - std::swap(if_rules_, rhs.if_rules_); - std::swap(else_rules_,rhs.else_rules_); - std::swap(also_rules_, rhs.also_rules_); - return *this; - } - - void add_rule(rule const& r) - { - if (r.has_else_filter()) - { - else_rules_.push_back(&r); - } - else if (r.has_also_filter()) - { - also_rules_.push_back(&r); - } - else - { - if_rules_.push_back(&r); - } - } - - rule_ptrs const& get_if_rules() const - { - return if_rules_; - } - - rule_ptrs const& get_else_rules() const - { - return else_rules_; - } - - rule_ptrs const& get_also_rules() const - { - return also_rules_; - } - -private: - rule_ptrs if_rules_; - rule_ptrs else_rules_; - rule_ptrs also_rules_; -}; - struct test9 { unsigned iter_; @@ -504,10 +441,10 @@ struct test9 void operator()() { for (unsigned i=0;i rule_caches; + std::vector rule_caches; for (unsigned i=0;i rule_ptrs; - rule_cache_heap() - : if_rules_(), - else_rules_(), - also_rules_() {} - - void add_rule(rule const& r) - { - if (r.has_else_filter()) - { - else_rules_.push_back(&r); - } - else if (r.has_also_filter()) - { - also_rules_.push_back(&r); - } - else - { - if_rules_.push_back(&r); - } - } - - rule_ptrs const& get_if_rules() const - { - return if_rules_; - } - - rule_ptrs const& get_else_rules() const - { - return else_rules_; - } - - rule_ptrs const& get_also_rules() const - { - return also_rules_; - } - -private: - rule_ptrs if_rules_; - rule_ptrs else_rules_; - rule_ptrs also_rules_; -}; - struct test10 { unsigned iter_; @@ -593,9 +484,9 @@ struct test10 void operator()() { for (unsigned i=0;i > rule_caches; + std::vector > rule_caches; for (unsigned i=0;i rc(new rule_cache_heap); + std::unique_ptr rc(new rule_cache); for (unsigned i=0;iadd_rule(rules_[i]); } @@ -646,8 +537,9 @@ struct test11 ps.line_to(extent_.maxx(), extent_.maxy()); ps.line_to(extent_.maxx(), extent_.miny()); ps.close_polygon(); - for (unsigned i=0;i envelope_impl(path_type & p) { mapnik::box2d b; bool first = true; - BOOST_FOREACH(mapnik::geometry_type const& geom, p) + for (mapnik::geometry_type const& geom : p) { if (first) { diff --git a/bindings/python/mapnik_query.cpp b/bindings/python/mapnik_query.cpp index 3c6138a23..a991f2e12 100644 --- a/bindings/python/mapnik_query.cpp +++ b/bindings/python/mapnik_query.cpp @@ -22,7 +22,7 @@ // boost #include -#include + // mapnik #include @@ -55,7 +55,7 @@ struct names_to_list static PyObject* convert(std::set const& names) { boost::python::list l; - BOOST_FOREACH( std::string const& name, names ) + for ( std::string const& name : names ) { l.append(name); } @@ -86,6 +86,3 @@ void export_query() return_value_policy()) ) .def("add_property_name", &query::add_property_name); } - - - diff --git a/bindings/python/python_grid_utils.cpp b/bindings/python/python_grid_utils.cpp index 952f5ce36..0ab20048e 100644 --- a/bindings/python/python_grid_utils.cpp +++ b/bindings/python/python_grid_utils.cpp @@ -23,7 +23,7 @@ // boost #include #include -#include + // mapnik #include @@ -240,7 +240,7 @@ void write_features(T const& grid_type, std::set const& attributes = grid_type.property_names(); typename T::feature_type::const_iterator feat_end = g_features.end(); - BOOST_FOREACH ( std::string const& key_item, key_order ) + for ( std::string const& key_item :key_order ) { if (key_item.empty()) { @@ -256,7 +256,7 @@ void write_features(T const& grid_type, bool found = false; boost::python::dict feat; mapnik::feature_ptr feature = feat_itr->second; - BOOST_FOREACH ( std::string const& attr, attributes ) + for ( std::string const& attr : attributes ) { if (attr == "__id__") { @@ -300,7 +300,7 @@ void grid_encode_utf(T const& grid_type, // convert key order to proper python list boost::python::list keys_a; - BOOST_FOREACH ( typename T::lookup_type const& key_id, key_order ) + for ( typename T::lookup_type const& key_id : key_order ) { keys_a.append(key_id); } diff --git a/include/mapnik/cairo_context.hpp b/include/mapnik/cairo_context.hpp index db4e8b1e3..daa6a3e7e 100644 --- a/include/mapnik/cairo_context.hpp +++ b/include/mapnik/cairo_context.hpp @@ -211,7 +211,7 @@ public: units_ = grad.get_units(); - BOOST_FOREACH ( mapnik::stop_pair const& st, grad.get_stop_array() ) + for ( mapnik::stop_pair const& st : grad.get_stop_array() ) { mapnik::color const& stop_color = st.second; double r= static_cast (stop_color.red())/255.0; diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index ec6b1a5c0..39cfcfab4 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -49,7 +49,6 @@ // boost #include #include -#include #include // stl @@ -167,7 +166,7 @@ void feature_style_processor::apply(double scale_denom) scale_denom = mapnik::scale_denominator(m_.scale(),proj.is_geographic()); scale_denom *= scale_factor_; - BOOST_FOREACH ( layer const& lyr, m_.layers() ) + for ( layer const& lyr : m_.layers() ) { if (lyr.visible(scale_denom)) { @@ -341,7 +340,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces { // check for styles needing compositing operations applied // https://github.com/mapnik/mapnik/issues/1477 - BOOST_FOREACH(std::string const& style_name, style_names) + for (std::string const& style_name : style_names) { boost::optional style=m_.find_style(style_name); if (!style) @@ -403,7 +402,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces std::vector rule_caches; // iterate through all named styles collecting active styles and attribute names - BOOST_FOREACH(std::string const& style_name, style_names) + for (std::string const& style_name : style_names) { boost::optional style=m_.find_style(style_name); if (!style) @@ -444,29 +443,29 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces if (p.attribute_collection_policy() == COLLECT_ALL) { layer_descriptor lay_desc = ds->get_descriptor(); - BOOST_FOREACH(attribute_descriptor const& desc, lay_desc.get_descriptors()) + for (attribute_descriptor const& desc : lay_desc.get_descriptors()) { q.add_property_name(desc.get_name()); } } else { - BOOST_FOREACH(std::string const& name, names) + for (std::string const& name : names) { q.add_property_name(name); } } // Update filter_factor for all enabled raster layers. - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { - BOOST_FOREACH(rule const& r, style->get_rules()) + for (rule const& r : style->get_rules()) { if (r.active(scale_denom) && ds->type() == datasource::Raster && ds->params().get("filter_factor",0.0) == 0.0) { - BOOST_FOREACH (rule::symbolizers::value_type sym, r.get_symbolizers()) + for (rule::symbolizers::value_type sym : r.get_symbolizers()) { // if multiple raster symbolizers, last will be respected // should we warn or throw? @@ -503,7 +502,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces // We're at a value boundary, so render what we have // up to this point. int i = 0; - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { render_style(lay, p, style, rule_caches[i], style_names[i], cache.features(q), prj_trans); @@ -516,7 +515,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces } int i = 0; - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { render_style(lay, p, style, rule_caches[i], style_names[i], cache.features(q), prj_trans); @@ -537,18 +536,18 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces } } int i = 0; - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { render_style(lay, p, style, rule_caches[i], style_names[i], cache.features(q), prj_trans); - i++; + ++i; } } // We only have a single style and no grouping. else { int i = 0; - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { render_style(lay, p, style, rule_caches[i], style_names[i], ds->features(q), prj_trans); @@ -603,7 +602,7 @@ void feature_style_processor::render_style( bool do_else = true; bool do_also = false; - BOOST_FOREACH(rule const* r, rc.get_if_rules() ) + for (rule const* r : rc.get_if_rules() ) { expression_ptr const& expr=r->get_filter(); value_type result = boost::apply_visitor(evaluate(*feature),*expr); @@ -624,7 +623,7 @@ void feature_style_processor::render_style( if(!p.process(symbols,*feature,prj_trans)) { - BOOST_FOREACH (symbolizer const& sym, symbols) + for (symbolizer const& sym : symbols) { boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym); } @@ -639,7 +638,7 @@ void feature_style_processor::render_style( } if (do_else) { - BOOST_FOREACH( rule const* r, rc.get_else_rules() ) + for (rule const* r : rc.get_else_rules() ) { #if defined(RENDERING_STATS) feat_processed = true; @@ -652,7 +651,7 @@ void feature_style_processor::render_style( // process one by one. if(!p.process(symbols,*feature,prj_trans)) { - BOOST_FOREACH (symbolizer const& sym, symbols) + for (symbolizer const& sym : symbols) { boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym); } @@ -661,7 +660,7 @@ void feature_style_processor::render_style( } if (do_also) { - BOOST_FOREACH( rule const* r, rc.get_also_rules() ) + for ( rule const* r : rc.get_also_rules() ) { #if defined(RENDERING_STATS) feat_processed = true; @@ -674,7 +673,7 @@ void feature_style_processor::render_style( // process one by one. if(!p.process(symbols,*feature,prj_trans)) { - BOOST_FOREACH (symbolizer const& sym, symbols) + for (symbolizer const& sym : symbols) { boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym); } diff --git a/include/mapnik/font_engine_freetype.hpp b/include/mapnik/font_engine_freetype.hpp index 5d4736125..c3e6af289 100644 --- a/include/mapnik/font_engine_freetype.hpp +++ b/include/mapnik/font_engine_freetype.hpp @@ -42,7 +42,7 @@ #include #include #include -#include + #ifdef MAPNIK_THREADSAFE #include #endif @@ -194,7 +194,7 @@ public: { std::vector const& names = fset.get_face_names(); face_set_ptr face_set = boost::make_shared(); - BOOST_FOREACH( std::string const& name, names) + for ( std::string const& name : names) { face_ptr face = get_face(name); if (face) diff --git a/include/mapnik/hit_test_filter.hpp b/include/mapnik/hit_test_filter.hpp index 792c8c12e..18a644a33 100644 --- a/include/mapnik/hit_test_filter.hpp +++ b/include/mapnik/hit_test_filter.hpp @@ -27,7 +27,7 @@ #include #include // boost -#include + namespace mapnik { class hit_test_filter @@ -40,7 +40,7 @@ public: bool pass(Feature & feature) { - BOOST_FOREACH(geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (label::hit_test(geom, x_,y_,tol_)) return true; diff --git a/include/mapnik/image_filter.hpp b/include/mapnik/image_filter.hpp index c11bd2e66..18e6a3e38 100644 --- a/include/mapnik/image_filter.hpp +++ b/include/mapnik/image_filter.hpp @@ -32,7 +32,7 @@ #include #include #include -#include + // agg #include "agg_basics.h" @@ -417,7 +417,7 @@ void apply_filter(Src & src, colorize_alpha const& op) double step = 1.0/(size-1); double offset = 0.0; - BOOST_FOREACH( mapnik::filter::color_stop const& stop, op) + for ( mapnik::filter::color_stop const& stop : op) { mapnik::color const& c = stop.color; double stop_offset = stop.offset; diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index 41431a177..6940a7b47 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -490,7 +490,7 @@ void apply_markers_multi(feature_impl & feature, Converter& converter, markers_s // TODO: consider using true area for polygon types double maxarea = 0; geometry_type* largest = 0; - BOOST_FOREACH(geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { const box2d& env = geom.envelope(); double area = env.width() * env.height(); @@ -511,7 +511,7 @@ void apply_markers_multi(feature_impl & feature, Converter& converter, markers_s { MAPNIK_LOG_WARN(marker_symbolizer) << "marker_multi_policy != 'each' has no effect with marker_placement != 'point'"; } - BOOST_FOREACH(geometry_type & path, feature.paths()) + for (geometry_type & path : feature.paths()) { converter.apply(path); } diff --git a/include/mapnik/polygon_clipper.hpp b/include/mapnik/polygon_clipper.hpp index 7bcb65b85..8d4284a4d 100644 --- a/include/mapnik/polygon_clipper.hpp +++ b/include/mapnik/polygon_clipper.hpp @@ -31,7 +31,7 @@ #include // boost -#include + #include #include #include @@ -189,10 +189,10 @@ private: std::cerr << ex.what() << std::endl; } - BOOST_FOREACH(polygon_2d const& poly, clipped_polygons) + for (polygon_2d const& poly : clipped_polygons) { bool move_to = true; - BOOST_FOREACH(point_2d const& c, boost::geometry::exterior_ring(poly)) + for (point_2d const& c : boost::geometry::exterior_ring(poly)) { if (move_to) { @@ -206,10 +206,10 @@ private: } output_.close_path(); // interior rings - BOOST_FOREACH(polygon_2d::inner_container_type::value_type const& ring, boost::geometry::interior_rings(poly)) + for (polygon_2d::inner_container_type::value_type const& ring : boost::geometry::interior_rings(poly)) { move_to = true; - BOOST_FOREACH(point_2d const& c, ring) + for (point_2d const& c : ring) { if (move_to) { diff --git a/include/mapnik/svg/svg_renderer_agg.hpp b/include/mapnik/svg/svg_renderer_agg.hpp index 778e726ca..90bb636a1 100644 --- a/include/mapnik/svg/svg_renderer_agg.hpp +++ b/include/mapnik/svg/svg_renderer_agg.hpp @@ -31,7 +31,7 @@ #include // boost -#include + // agg #include "agg_path_storage.h" @@ -138,7 +138,7 @@ public: grad.get_control_points(x1,y1,x2,y2,radius); m_gradient_lut.remove_all(); - BOOST_FOREACH ( mapnik::stop_pair const& st, grad.get_stop_array() ) + for ( mapnik::stop_pair const& st : grad.get_stop_array() ) { mapnik::color const& stop_color = st.second; unsigned r = stop_color.red(); diff --git a/include/mapnik/transform_processor.hpp b/include/mapnik/transform_processor.hpp index d720c4350..71cfb42e0 100644 --- a/include/mapnik/transform_processor.hpp +++ b/include/mapnik/transform_processor.hpp @@ -33,10 +33,10 @@ #include // boost -#include + #include #include - +#include // agg #include @@ -190,7 +190,7 @@ struct transform_processor { attribute_collector collect(names); - BOOST_FOREACH (transform_node const& node, list) + for (transform_node const& node : list) { boost::apply_visitor(collect, *node); } @@ -205,7 +205,7 @@ struct transform_processor MAPNIK_LOG_DEBUG(transform) << "transform: begin with " << to_string(matrix_node(tr)); #endif - BOOST_REVERSE_FOREACH (transform_node const& node, list) + for (transform_node const& node : boost::adaptors::reverse(list)) { boost::apply_visitor(eval, *node); #ifdef MAPNIK_LOG diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index a21d9befc..67c62210a 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -43,7 +43,7 @@ #include #include -#include + #include // mapnik diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index 153597cda..c16be6c1f 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -31,7 +31,7 @@ #include #include #include -#include + #include #include #include @@ -123,7 +123,7 @@ geojson_datasource::geojson_datasource(parameters const& params) bool first = true; std::size_t count=0; - BOOST_FOREACH (mapnik::feature_ptr f, features_) + for (mapnik::feature_ptr f : features_) { mapnik::box2d const& box = f->envelope(); if (first) diff --git a/plugins/input/python/python_datasource.cpp b/plugins/input/python/python_datasource.cpp index 3c8795503..ac8c04fc5 100644 --- a/plugins/input/python/python_datasource.cpp +++ b/plugins/input/python/python_datasource.cpp @@ -7,7 +7,7 @@ #include // boost -#include + #include #include #include @@ -26,7 +26,7 @@ python_datasource::python_datasource(parameters const& params) factory_(*params.get("factory", "")) { // extract any remaining parameters as keyword args for the factory - BOOST_FOREACH(const mapnik::parameters::value_type& kv, params) + for (const mapnik::parameters::value_type& kv : params) { if((kv.first != "type") && (kv.first != "factory")) { @@ -73,7 +73,7 @@ python_datasource::python_datasource(parameters const& params) // prepare the arguments boost::python::dict kwargs; typedef std::map::value_type kv_type; - BOOST_FOREACH(const kv_type& kv, kwargs_) + for (kv_type const& kv : kwargs_) { kwargs[boost::python::str(kv.first)] = boost::python::str(kv.second); } diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index f3e6cea3a..f2dd04e65 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -265,7 +265,7 @@ void agg_renderer::end_style_processing(feature_type_style const& st) { blend_from = true; mapnik::filter::filter_visitor visitor(*current_buffer_); - BOOST_FOREACH(mapnik::filter::filter_type const& filter_tag, st.image_filters()) + for (mapnik::filter::filter_type const& filter_tag : st.image_filters()) { boost::apply_visitor(visitor, filter_tag); } @@ -282,7 +282,7 @@ void agg_renderer::end_style_processing(feature_type_style const& st) } // apply any 'direct' image filters mapnik::filter::filter_visitor visitor(pixmap_); - BOOST_FOREACH(mapnik::filter::filter_type const& filter_tag, st.direct_image_filters()) + for (mapnik::filter::filter_type const& filter_tag : st.direct_image_filters()) { boost::apply_visitor(visitor, filter_tag); } diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp index 1f9f679fd..cc9ff6b0e 100644 --- a/src/agg/process_line_pattern_symbolizer.cpp +++ b/src/agg/process_line_pattern_symbolizer.cpp @@ -49,7 +49,7 @@ #include "agg_conv_clip_polyline.h" // boost -#include + namespace { @@ -150,7 +150,7 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH(geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index e32b9b257..d540b227b 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -44,7 +44,7 @@ #include "agg_rasterizer_outline_aa.h" // boost -#include + // stl #include @@ -129,7 +129,7 @@ void agg_renderer::process(line_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { @@ -152,7 +152,7 @@ void agg_renderer::process(line_symbolizer const& sym, if (stroke_.has_dash()) converter.set(); converter.set(); //always stroke - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index da43f91b3..915fe4124 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ // boost -#include + // mapnik #include @@ -157,7 +157,7 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index febd2a514..962ebe4f8 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ // boost -#include + // mapnik #include @@ -68,7 +68,7 @@ void agg_renderer::process(polygon_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 2) { diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 16d331421..1a649799f 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -332,7 +332,7 @@ void cairo_renderer_base::process(polygon_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { @@ -495,7 +495,7 @@ void cairo_renderer_base::process(line_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { @@ -869,7 +869,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { diff --git a/src/deepcopy.cpp b/src/deepcopy.cpp index 3460da544..39a947c15 100644 --- a/src/deepcopy.cpp +++ b/src/deepcopy.cpp @@ -44,7 +44,7 @@ // boost #include -#include + namespace mapnik { namespace util { @@ -98,12 +98,12 @@ namespace mapnik { namespace util { // fontsets typedef std::map fontsets; - BOOST_FOREACH ( fontsets::value_type const& kv,map_in.fontsets()) + for (fontsets::value_type const& kv : map_in.fontsets()) { map_out.insert_fontset(kv.first,kv.second); } - BOOST_FOREACH ( layer const& lyr_in, map_in.layers()) + for ( layer const& lyr_in : map_in.layers()) { layer lyr_out(lyr_in); datasource_ptr ds_in = lyr_in.datasource(); @@ -124,7 +124,7 @@ namespace mapnik { namespace util { typedef style_cont::value_type value_type; style_cont const& styles = map_in.styles(); - BOOST_FOREACH ( value_type const& kv, styles ) + for ( value_type const& kv : styles ) { feature_type_style const& style_in = kv.second; feature_type_style style_out(style_in,true); // deep copy diff --git a/src/feature_type_style.cpp b/src/feature_type_style.cpp index f041b714f..87bbad984 100644 --- a/src/feature_type_style.cpp +++ b/src/feature_type_style.cpp @@ -24,7 +24,7 @@ #include // boost -#include + namespace mapnik { @@ -91,7 +91,7 @@ rules& feature_type_style::get_rules_nonconst() bool feature_type_style::active(double scale_denom) const { - BOOST_FOREACH(rule const& r, rules_) + for (rule const& r : rules_) { if (r.active(scale_denom)) { diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 97bdba91e..c5e681328 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -280,7 +280,7 @@ font_face_set::size_type font_face_set::size() const glyph_ptr font_face_set::get_glyph(unsigned c) const { - BOOST_FOREACH ( face_ptr const& face, faces_) + for ( face_ptr const& face : faces_) { FT_UInt g = face->get_char(c); if (g) return boost::make_shared(face, g); @@ -387,7 +387,7 @@ void font_face_set::get_string_info(string_info & info, UnicodeString const& ust void font_face_set::set_pixel_sizes(unsigned size) { - BOOST_FOREACH ( face_ptr const& face, faces_) + for ( face_ptr const& face : faces_) { face->set_pixel_sizes(size); } @@ -395,7 +395,7 @@ void font_face_set::set_pixel_sizes(unsigned size) void font_face_set::set_character_sizes(double size) { - BOOST_FOREACH ( face_ptr const& face, faces_) + for ( face_ptr const& face : faces_) { face->set_character_sizes(size); } diff --git a/src/formatting/list.cpp b/src/formatting/list.cpp index d9ac17374..777e78b85 100644 --- a/src/formatting/list.cpp +++ b/src/formatting/list.cpp @@ -25,7 +25,7 @@ #include // boost -#include + #include namespace mapnik { @@ -36,7 +36,7 @@ namespace formatting { void list_node::to_xml(boost::property_tree::ptree & xml) const { - BOOST_FOREACH(node_ptr const& node, children_) + for (node_ptr const& node : children_) { node->to_xml(xml); } @@ -44,17 +44,17 @@ void list_node::to_xml(boost::property_tree::ptree & xml) const void list_node::apply(char_properties const& p, feature_impl const& feature, processed_text &output) const -{ - BOOST_FOREACH(node_ptr const& node, children_) +{ + for (node_ptr const& node : children_) { node->apply(p, feature, output); - } + } } void list_node::add_expressions(expression_set &output) const { - BOOST_FOREACH(node_ptr const& node, children_) + for (node_ptr const& node : children_) { node->add_expressions(output); } @@ -81,4 +81,3 @@ std::vector const& list_node::get_children() const } } // ns mapnik } // ns formatting - diff --git a/src/grid/process_line_symbolizer.cpp b/src/grid/process_line_symbolizer.cpp index c188b6473..502a85c24 100644 --- a/src/grid/process_line_symbolizer.cpp +++ b/src/grid/process_line_symbolizer.cpp @@ -38,7 +38,7 @@ #include "agg_conv_dash.h" // boost -#include + // stl #include @@ -96,7 +96,7 @@ void grid_renderer::process(line_symbolizer const& sym, if (stroke_.has_dash()) converter.set(); converter.set(); //always stroke - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 1) { @@ -119,4 +119,3 @@ template void grid_renderer::process(line_symbolizer const&, proj_transform const&); } - diff --git a/src/grid/process_polygon_pattern_symbolizer.cpp b/src/grid/process_polygon_pattern_symbolizer.cpp index 38145858f..956458f18 100644 --- a/src/grid/process_polygon_pattern_symbolizer.cpp +++ b/src/grid/process_polygon_pattern_symbolizer.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ // boost -#include + // mapnik #include @@ -64,7 +64,7 @@ void grid_renderer::process(polygon_pattern_symbolizer const& sym, if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { @@ -96,4 +96,3 @@ template void grid_renderer::process(polygon_pattern_symbolizer const&, proj_transform const&); } - diff --git a/src/grid/process_polygon_symbolizer.cpp b/src/grid/process_polygon_symbolizer.cpp index 5195760f9..ffa79fc6d 100644 --- a/src/grid/process_polygon_symbolizer.cpp +++ b/src/grid/process_polygon_symbolizer.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ // boost -#include + // mapnik #include @@ -69,7 +69,7 @@ void grid_renderer::process(polygon_symbolizer const& sym, if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { @@ -98,4 +98,3 @@ template void grid_renderer::process(polygon_symbolizer const&, proj_transform const&); } - diff --git a/src/image_util.cpp b/src/image_util.cpp index 2e74e6e83..ce4d026da 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -68,7 +68,7 @@ extern "C" #endif // boost -#include + #include // stl @@ -149,7 +149,7 @@ void handle_png_options(std::string const& type, if (type.length() > 6){ boost::char_separator sep(":"); boost::tokenizer< boost::char_separator > tokens(type, sep); - BOOST_FOREACH(std::string t, tokens) + for (std::string const& t : tokens) { if (t == "png" || t == "png24" || t == "png32") { diff --git a/src/parse_path.cpp b/src/parse_path.cpp index b502128e4..6cdfabd37 100644 --- a/src/parse_path.cpp +++ b/src/parse_path.cpp @@ -30,7 +30,7 @@ // boost #include -#include + #include namespace mapnik { @@ -44,8 +44,8 @@ path_expression_ptr parse_path(std::string const& str) path_expression_ptr parse_path(std::string const& str, path_expression_grammar const& g) { - path_expression path; - + path_expression path; + std::string::const_iterator itr = str.begin(); std::string::const_iterator end = str.end(); bool r = qi::phrase_parse(itr, end, g, boost::spirit::standard_wide::space, path); @@ -125,7 +125,7 @@ std::string path_processor::evaluate(path_expression const& path,feature_impl co { std::string out; path_processor_detail::path_visitor_ eval(out,f); - BOOST_FOREACH( mapnik::path_component const& token, path) + for ( mapnik::path_component const& token : path) boost::apply_visitor(eval,token); return out; } @@ -134,7 +134,7 @@ std::string path_processor::to_string(path_expression const& path) { std::string str; path_processor_detail::to_string_ visitor(str); - BOOST_FOREACH( mapnik::path_component const& token, path) + for ( mapnik::path_component const& token : path) boost::apply_visitor(visitor,token); return str; } @@ -142,7 +142,7 @@ std::string path_processor::to_string(path_expression const& path) void path_processor::collect_attributes(path_expression const& path, std::set& names) { path_processor_detail::collect_ visitor(names); - BOOST_FOREACH( mapnik::path_component const& token, path) + for ( mapnik::path_component const& token : path) boost::apply_visitor(visitor,token); } diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index 0ad39f5c5..4532f224c 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -36,7 +36,7 @@ #include #include #include -#include + //stl #include @@ -501,7 +501,7 @@ void placement_finder::find_point_placement(double label_x, // check the placement of any additional envelopes if (!p.allow_overlap && !additional_boxes_.empty()) { - BOOST_FOREACH(box2d const& box, additional_boxes_) + for (box2d const& box : additional_boxes_) { box2d pt(box.minx() + current_placement->center.x, box.miny() + current_placement->center.y, diff --git a/src/svg/output/process_symbolizers.cpp b/src/svg/output/process_symbolizers.cpp index c6db3ea62..088e38b55 100644 --- a/src/svg/output/process_symbolizers.cpp +++ b/src/svg/output/process_symbolizers.cpp @@ -36,7 +36,7 @@ bool svg_renderer::process(rule::symbolizers const& syms, // process each symbolizer to collect its (path) information. // path information (attributes from line_ and polygon_ symbolizers) // is collected with the path_attributes_ data member. - BOOST_FOREACH(symbolizer const& sym, syms) + for (symbolizer const& sym : syms) { boost::apply_visitor(symbol_dispatch(*this, feature, prj_trans), sym); } diff --git a/src/svg/svg_parser.cpp b/src/svg/svg_parser.cpp index 266c8cdb6..a48a65bb0 100644 --- a/src/svg/svg_parser.cpp +++ b/src/svg/svg_parser.cpp @@ -34,7 +34,7 @@ #include #include #include -#include + #include #include @@ -213,7 +213,7 @@ void start_element(svg_parser & parser, xmlTextReaderPtr reader) if (xmlStrEqual(name, BAD_CAST "path")) { parse_path(parser,reader); - } + } else if (xmlStrEqual(name, BAD_CAST "polygon") ) { parse_polygon(parser,reader); @@ -227,7 +227,7 @@ void start_element(svg_parser & parser, xmlTextReaderPtr reader) parse_line(parser,reader); } else if (xmlStrEqual(name, BAD_CAST "rect")) - { + { parse_rect(parser,reader); } else if (xmlStrEqual(name, BAD_CAST "circle")) @@ -416,7 +416,7 @@ void parse_attr(svg_parser & parser, const xmlChar * name, const xmlChar * value void parse_attr(svg_parser & parser, xmlTextReaderPtr reader) { const xmlChar *name, *value; - + if (xmlTextReaderMoveToFirstAttribute(reader) == 1) { do @@ -430,7 +430,7 @@ void parse_attr(svg_parser & parser, xmlTextReaderPtr reader) typedef cont_type::value_type value_type; cont_type vec; parse_style((const char*)value, vec); - BOOST_FOREACH(value_type kv , vec ) + for (value_type kv : vec ) { parse_attr(parser,BAD_CAST kv.first.c_str(),BAD_CAST kv.second.c_str()); } @@ -550,33 +550,33 @@ void parse_line(svg_parser & parser, xmlTextReaderPtr reader) double y2 = 0.0; value = xmlTextReaderGetAttribute(reader, BAD_CAST "x1"); - if (value) + if (value) { x1 = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "y1"); - if (value) + if (value) { y1 = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "x2"); - if (value) + if (value) { x2 = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "y2"); - if (value) + if (value) { y2 = parse_double((const char*)value); xmlFree(value); } - + parser.path_.begin_path(); parser.path_.move_to(x1, y1); parser.path_.line_to(x2, y2); @@ -591,26 +591,26 @@ void parse_circle(svg_parser & parser, xmlTextReaderPtr reader) double cy = 0.0; double r = 0.0; value = xmlTextReaderGetAttribute(reader, BAD_CAST "cx"); - if (value) + if (value) { cx = parse_double((const char*)value); xmlFree(value); } value = xmlTextReaderGetAttribute(reader, BAD_CAST "cy"); - if (value) + if (value) { cy = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "r"); - if (value) + if (value) { r = parse_double((const char*)value); xmlFree(value); } - + parser.path_.begin_path(); if(r != 0.0) @@ -632,33 +632,33 @@ void parse_ellipse(svg_parser & parser, xmlTextReaderPtr reader) double ry = 0.0; value = xmlTextReaderGetAttribute(reader, BAD_CAST "cx"); - if (value) + if (value) { cx = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "cy"); - if (value) + if (value) { cy = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "rx"); - if (value) + if (value) { rx = parse_double((const char*)value); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "ry"); - if (value) + if (value) { ry = parse_double((const char*)value); xmlFree(value); } - + parser.path_.begin_path(); if(rx != 0.0 && ry != 0.0) @@ -742,7 +742,7 @@ void parse_rect(svg_parser & parser, xmlTextReaderPtr reader) if(rx < 0.0) throw std::runtime_error("parse_rect: Invalid rx"); if(ry < 0.0) throw std::runtime_error("parse_rect: Invalid ry"); parser.path_.begin_path(); - + if(rounded) { agg::rounded_rect r; @@ -778,7 +778,7 @@ void parse_gradient_stop(svg_parser & parser, xmlTextReaderPtr reader) double opacity = 1.0; value = xmlTextReaderGetAttribute(reader, BAD_CAST "offset"); - if (value) + if (value) { offset = parse_double((const char*)value); xmlFree(value); @@ -792,7 +792,7 @@ void parse_gradient_stop(svg_parser & parser, xmlTextReaderPtr reader) cont_type vec; parse_style((const char*)value, vec); - BOOST_FOREACH(value_type kv , vec ) + for (value_type kv : vec ) { if (kv.first == "stop-color") { @@ -870,7 +870,7 @@ bool parse_common_gradient(svg_parser & parser, xmlTextReaderPtr reader) // check if we should inherit from another tag value = xmlTextReaderGetAttribute(reader, BAD_CAST "xlink:href"); - if (value) + if (value) { if (value[0] == '#') { @@ -886,7 +886,7 @@ bool parse_common_gradient(svg_parser & parser, xmlTextReaderPtr reader) } xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "gradientUnits"); if (value) { @@ -900,7 +900,7 @@ bool parse_common_gradient(svg_parser & parser, xmlTextReaderPtr reader) } xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "gradientTransform"); if (value) { @@ -939,14 +939,14 @@ void parse_radial_gradient(svg_parser & parser, xmlTextReaderPtr reader) bool has_percent=true; value = xmlTextReaderGetAttribute(reader, BAD_CAST "cx"); - if (value) + if (value) { cx = parse_double_optional_percent((const char*)value, has_percent); xmlFree(value); } value = xmlTextReaderGetAttribute(reader, BAD_CAST "cy"); - if (value) + if (value) { cy = parse_double_optional_percent((const char*)value, has_percent); xmlFree(value); @@ -1003,28 +1003,28 @@ void parse_linear_gradient(svg_parser & parser, xmlTextReaderPtr reader) bool has_percent=true; value = xmlTextReaderGetAttribute(reader, BAD_CAST "x1"); - if (value) + if (value) { x1 = parse_double_optional_percent((const char*)value, has_percent); xmlFree(value); } value = xmlTextReaderGetAttribute(reader, BAD_CAST "x2"); - if (value) + if (value) { x2 = parse_double_optional_percent((const char*)value, has_percent); xmlFree(value); } value = xmlTextReaderGetAttribute(reader, BAD_CAST "y1"); - if (value) + if (value) { y1 = parse_double_optional_percent((const char*)value, has_percent); xmlFree(value); } - + value = xmlTextReaderGetAttribute(reader, BAD_CAST "y2"); - if (value) + if (value) { y2 = parse_double_optional_percent((const char*)value, has_percent); xmlFree(value); diff --git a/src/transform_expression.cpp b/src/transform_expression.cpp index 157dee202..0bf3b8ec2 100644 --- a/src/transform_expression.cpp +++ b/src/transform_expression.cpp @@ -25,7 +25,7 @@ #include // boost -#include + // stl #include @@ -132,7 +132,7 @@ std::string to_expression_string(transform_list const& list) std::streamsize first = 1; transform_node_to_expression_string to_string(os); - BOOST_FOREACH (transform_node const& node, list) + for (transform_node const& node : list) { os.write(" ", first ? (first = 0) : 1); boost::apply_visitor(to_string, *node); diff --git a/tests/cpp_tests/clipping_test.cpp b/tests/cpp_tests/clipping_test.cpp index 457cacfec..5e37f8f8a 100644 --- a/tests/cpp_tests/clipping_test.cpp +++ b/tests/cpp_tests/clipping_test.cpp @@ -6,7 +6,7 @@ // boost #include #include -#include + // stl #include @@ -52,7 +52,7 @@ void parse_geom(mapnik::geometry_type & geom, std::string const& geom_string) { std::vector vertices; boost::split(vertices, geom_string, boost::is_any_of(",")); - BOOST_FOREACH(std::string const& vert, vertices) + for (std::string const& vert : vertices) { std::vector commands; boost::split(commands, vert, boost::is_any_of(" ")); diff --git a/tests/cpp_tests/geometry_converters_test.cpp b/tests/cpp_tests/geometry_converters_test.cpp index fc7423c5e..90b5c99d4 100644 --- a/tests/cpp_tests/geometry_converters_test.cpp +++ b/tests/cpp_tests/geometry_converters_test.cpp @@ -68,7 +68,7 @@ boost::optional linestring_bbox_clipping(mapnik::box2d bbox throw std::runtime_error("Failed to parse WKT"); } - BOOST_FOREACH( geometry_type & geom, p) + for (geometry_type & geom : p) { converter.apply(geom); } @@ -108,7 +108,7 @@ boost::optional polygon_bbox_clipping(mapnik::box2d bbox, throw std::runtime_error("Failed to parse WKT"); } - BOOST_FOREACH( geometry_type & geom, p) + for (geometry_type & geom : p) { converter.apply(geom); } diff --git a/tests/cpp_tests/map_request_test.cpp b/tests/cpp_tests/map_request_test.cpp index 716e41a3b..05f031993 100644 --- a/tests/cpp_tests/map_request_test.cpp +++ b/tests/cpp_tests/map_request_test.cpp @@ -17,7 +17,7 @@ #include #include #include -#include + bool compare_images(std::string const& src_fn,std::string const& dest_fn) { @@ -100,7 +100,7 @@ int main( int, char*[] ) mapnik::projection map_proj(m.srs(),true); double scale_denom = mapnik::scale_denominator(req.scale(),map_proj.is_geographic()); scale_denom *= scale_factor; - BOOST_FOREACH ( mapnik::layer const& lyr, m.layers() ) + for (mapnik::layer const& lyr : m.layers() ) { if (lyr.visible(scale_denom)) { diff --git a/utils/geometry_to_wkb/main.cpp b/utils/geometry_to_wkb/main.cpp index 5dd23aa32..b8048f283 100644 --- a/utils/geometry_to_wkb/main.cpp +++ b/utils/geometry_to_wkb/main.cpp @@ -29,7 +29,7 @@ #include #include -#include + int main (int argc, char ** argv ) @@ -70,7 +70,7 @@ int main (int argc, char ** argv ) mapnik::query q(ds->envelope()); mapnik::layer_descriptor layer_desc = ds->get_descriptor(); - BOOST_FOREACH ( mapnik::attribute_descriptor const& attr_desc, layer_desc.get_descriptors()) + for (mapnik::attribute_descriptor const& attr_desc : layer_desc.get_descriptors()) { q.add_property_name(attr_desc.get_name()); } @@ -82,7 +82,7 @@ int main (int argc, char ** argv ) { std::cerr << *f << std::endl; boost::ptr_vector & paths = f->paths(); - BOOST_FOREACH ( mapnik::geometry_type const& geom, paths) + for (mapnik::geometry_type const& geom : paths) { // NDR { From abd42357d643333240477843c9532a491468e69e Mon Sep 17 00:00:00 2001 From: "artem@windows" Date: Mon, 29 Apr 2013 04:21:28 -0700 Subject: [PATCH 038/122] + add header to keep cl.exe happy --- include/mapnik/global.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/mapnik/global.hpp b/include/mapnik/global.hpp index 22efed271..f4e200da8 100644 --- a/include/mapnik/global.hpp +++ b/include/mapnik/global.hpp @@ -2,7 +2,7 @@ * * This file is part of Mapnik (c++ mapping toolkit) * - * Copyright (C) 2011 Artem Pavlenko + * Copyright (C) 2013 Artem Pavlenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -29,6 +29,7 @@ // stl #include +#include namespace mapnik { From 95e3c87f05251c3cc2525344cdaf58d333e29072 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 30 Apr 2013 09:32:22 +0100 Subject: [PATCH 039/122] + revert to using boost::math::trunc + and mapnik::noncopyable vc++ (*) doesn't support std::trunc and deleting methods in class/struct definition * - vc++ 2012 November CTP --- include/mapnik/json/geometry_generator_grammar.hpp | 3 ++- include/mapnik/rule_cache.hpp | 9 +++++---- include/mapnik/util/geometry_wkt_generator.hpp | 9 +++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index dbd8e6a17..effc887a1 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -40,6 +40,7 @@ #include #include #include +#include // for vc++ namespace boost { namespace spirit { namespace traits { @@ -114,7 +115,7 @@ struct json_coordinate_policy : karma::real_policies { if (n == 0.0) return 0; using namespace boost::spirit; - return static_cast(14 - std::trunc(log10(traits::get_absolute_value(n)))); + return static_cast(14 - boost::math::trunc(log10(traits::get_absolute_value(n)))); } template diff --git a/include/mapnik/rule_cache.hpp b/include/mapnik/rule_cache.hpp index b9a6b5a25..32f7b4423 100644 --- a/include/mapnik/rule_cache.hpp +++ b/include/mapnik/rule_cache.hpp @@ -26,18 +26,19 @@ // mapnik #include #include - +#include // stl #include namespace mapnik { -class rule_cache +class rule_cache : private noncopyable { private: - rule_cache(rule_cache const& other) = delete; // no copy ctor - rule_cache& operator=(rule_cache const& other) = delete; // no assignment op + //latest MS compiler (VC++ 2012 november CTP) doesn't support deleting functions + //rule_cache(rule_cache const& other) = delete; // no copy ctor + //rule_cache& operator=(rule_cache const& other) = delete; // no assignment op public: typedef std::vector rule_ptrs; rule_cache() diff --git a/include/mapnik/util/geometry_wkt_generator.hpp b/include/mapnik/util/geometry_wkt_generator.hpp index 2fb8a77bb..76a7300ec 100644 --- a/include/mapnik/util/geometry_wkt_generator.hpp +++ b/include/mapnik/util/geometry_wkt_generator.hpp @@ -42,9 +42,7 @@ #include #include #include - -#include // trunc to avoid needing C++11 - +#include // for vc++ namespace boost { namespace spirit { namespace traits { @@ -153,9 +151,8 @@ struct wkt_coordinate_policy : karma::real_policies static unsigned precision(T n) { if (n == 0.0) return 0; - return 6; - //using namespace boost::spirit; // for traits - //return std::max(6u, static_cast(15 - boost::math::trunc(log10(traits::get_absolute_value(n))))); + using namespace boost::spirit; + return static_cast(14 - boost::math::trunc(std::log10(traits::get_absolute_value(n)))); } template From 231e4ab907e91dd2b488e4e612c599ea086d3429 Mon Sep 17 00:00:00 2001 From: "artem@windows" Date: Tue, 30 Apr 2013 09:37:30 -0700 Subject: [PATCH 040/122] output supported image formats in rundemo c++ --- demo/c++/rundemo.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/demo/c++/rundemo.cpp b/demo/c++/rundemo.cpp index 1d57495d0..d63298648 100644 --- a/demo/c++/rundemo.cpp +++ b/demo/c++/rundemo.cpp @@ -264,11 +264,16 @@ int main ( int argc , char** argv) image_32 buf(m.width(),m.height()); agg_renderer ren(m,buf); ren.apply(); - +#ifdef HAVE_JPEG save_to_file(buf,"demo.jpg","jpeg"); +#endif +#ifdef HAVE_PNG save_to_file(buf,"demo.png","png"); save_to_file(buf,"demo256.png","png8"); +#endif +#ifdef HAVE_TIFF save_to_file(buf,"demo.tif","tiff"); +#endif std::cout << "Three maps have been rendered using AGG in the current directory:\n" "- demo.jpg\n" From 16c0b578bc562f8cb59a6666c115b57ed0cddfc2 Mon Sep 17 00:00:00 2001 From: "artem@windows" Date: Tue, 30 Apr 2013 09:46:06 -0700 Subject: [PATCH 041/122] c++11 + use std::size_t + re-implement envelope() method in terms of c++11 --- include/mapnik/feature.hpp | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index 352a463c1..4d1c84556 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -211,17 +211,17 @@ public: geom_cont_.push_back(geom); } - unsigned num_geometries() const + std::size_t num_geometries() const { return geom_cont_.size(); } - geometry_type const& get_geometry(unsigned index) const + geometry_type const& get_geometry(std::size_t index) const { return geom_cont_[index]; } - geometry_type& get_geometry(unsigned index) + geometry_type& get_geometry(std::size_t index) { return geom_cont_[index]; } @@ -230,22 +230,23 @@ public: { // TODO - cache this box2d result; - for (unsigned i=0;i box = geom.envelope(); - result.init(box.minx(),box.miny(),box.maxx(),box.maxy()); - } - else - { - result.expand_to_include(geom.envelope()); - } - } + bool first = true; + for (auto const& geom : geom_cont_) + { + if (first) + { + first = false; + box2d box = geom.envelope(); + result.init(box.minx(),box.miny(),box.maxx(),box.maxy()); + } + else + { + result.expand_to_include(geom.envelope()); + } + } return result; } - + raster_ptr const& get_raster() const { return raster_; From 9a64415a036525bfdedfd2936d7558fd23d15ee9 Mon Sep 17 00:00:00 2001 From: "artem@windows" Date: Tue, 30 Apr 2013 10:06:47 -0700 Subject: [PATCH 042/122] use std::size_t to avoid conversion warnings --- include/mapnik/placement_finder.hpp | 2 +- include/mapnik/processed_text.hpp | 2 +- include/mapnik/text_path.hpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/mapnik/placement_finder.hpp b/include/mapnik/placement_finder.hpp index 7b6e73369..d57987298 100644 --- a/include/mapnik/placement_finder.hpp +++ b/include/mapnik/placement_finder.hpp @@ -149,7 +149,7 @@ private: vertical_alignment_e valign_; horizontal_alignment_e halign_; justify_alignment_e jalign_; - std::vector line_breaks_; + std::vector line_breaks_; std::vector > line_sizes_; std::queue< box2d > envelopes_; /** Used to return all placements found. */ diff --git a/include/mapnik/processed_text.hpp b/include/mapnik/processed_text.hpp index 581742520..3f56a2184 100644 --- a/include/mapnik/processed_text.hpp +++ b/include/mapnik/processed_text.hpp @@ -51,7 +51,7 @@ public: public: processed_text(face_manager & font_manager, double scale_factor); void push_back(char_properties const& properties, UnicodeString const& text); - unsigned size() const { return expr_list_.size(); } + std::size_t size() const { return expr_list_.size(); } unsigned empty() const { return expr_list_.empty(); } void clear(); typedef std::list expression_list; diff --git a/include/mapnik/text_path.hpp b/include/mapnik/text_path.hpp index b08c1e567..c8761c271 100644 --- a/include/mapnik/text_path.hpp +++ b/include/mapnik/text_path.hpp @@ -74,7 +74,7 @@ public: text_ += text; } - unsigned num_characters() const + std::size_t num_characters() const { return characters_.size(); } @@ -89,12 +89,12 @@ public: return is_rtl; } - char_info const& at(unsigned i) const + char_info const& at(std::size_t i) const { return characters_[i]; } - char_info const& operator[](unsigned i) const + char_info const& operator[](std::size_t i) const { return at(i); } @@ -184,7 +184,7 @@ public: } /** Number of nodes. */ - int num_nodes() const + std::size_t num_nodes() const { return nodes_.size(); } From a8376d2a4bb5d64ed2f7c7e93db4b8bdd5875178 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 30 Apr 2013 18:46:34 +0100 Subject: [PATCH 043/122] + fix method signature --- bindings/python/mapnik_feature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index 0c7e6745e..196b30f03 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -48,7 +48,7 @@ using mapnik::context_type; using mapnik::context_ptr; using mapnik::feature_kv_iterator; -mapnik::geometry_type const& (mapnik::Feature::*get_geometry_by_const_ref)(unsigned) const = &mapnik::Feature::get_geometry; +mapnik::geometry_type const& (mapnik::Feature::*get_geometry_by_const_ref)(std::size_t) const = &mapnik::Feature::get_geometry; boost::ptr_vector const& (mapnik::Feature::*get_paths_by_const_ref)() const = &mapnik::Feature::paths; void feature_add_geometries_from_wkb(Feature &feature, std::string wkb) From 43968b6c5073f1829c5bbddfa12c12528299f742 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 30 Apr 2013 18:47:17 +0100 Subject: [PATCH 044/122] + c++ style : formatting --- include/mapnik/feature.hpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index 4d1c84556..4cf33f2dd 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -230,23 +230,23 @@ public: { // TODO - cache this box2d result; - bool first = true; - for (auto const& geom : geom_cont_) - { - if (first) - { - first = false; - box2d box = geom.envelope(); - result.init(box.minx(),box.miny(),box.maxx(),box.maxy()); - } - else - { - result.expand_to_include(geom.envelope()); - } - } + bool first = true; + for (auto const& geom : geom_cont_) + { + if (first) + { + first = false; + box2d box = geom.envelope(); + result.init(box.minx(),box.miny(),box.maxx(),box.maxy()); + } + else + { + result.expand_to_include(geom.envelope()); + } + } return result; } - + raster_ptr const& get_raster() const { return raster_; From f611892915c44a8b6e5d9a713f83ac32c9e220a1 Mon Sep 17 00:00:00 2001 From: "artem@windows" Date: Thu, 2 May 2013 12:02:13 -0700 Subject: [PATCH 045/122] remove redundant header --- include/mapnik/image_filter_types.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/mapnik/image_filter_types.hpp b/include/mapnik/image_filter_types.hpp index d464a30ce..ac9017215 100644 --- a/include/mapnik/image_filter_types.hpp +++ b/include/mapnik/image_filter_types.hpp @@ -27,7 +27,6 @@ #include #include // boost -#include #include // stl #include From ffc7a088a472b7760b51caef9581d38ea20370cb Mon Sep 17 00:00:00 2001 From: "artem@windows" Date: Thu, 2 May 2013 12:03:16 -0700 Subject: [PATCH 046/122] use std::move msvc : temp fix https://svn.boost.org/trac/boost/ticket/2839 --- bindings/python/mapnik_style.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bindings/python/mapnik_style.cpp b/bindings/python/mapnik_style.cpp index 7eb9e449b..cbf032bf3 100644 --- a/bindings/python/mapnik_style.cpp +++ b/bindings/python/mapnik_style.cpp @@ -45,13 +45,17 @@ std::string get_image_filters(feature_type_style & style) void set_image_filters(feature_type_style & style, std::string const& filters) { std::vector new_filters; - bool result = parse_image_filters(filters, new_filters); if (!result) { throw mapnik::value_error("failed to parse image-filters: '" + filters + "'"); } - style.image_filters().swap(new_filters); +#ifdef _WINDOWS + style.image_filters() = new_filters; + // FIXME : https://svn.boost.org/trac/boost/ticket/2839 +#else + style.image_filters() = std::move(new_filters); +#endif } void export_style() From 29f9273d3e0a85f99f8c012b527672087ab2c118 Mon Sep 17 00:00:00 2001 From: "artem@windows" Date: Thu, 2 May 2013 14:07:06 -0700 Subject: [PATCH 047/122] + msvc : fix warnings (TODO: work-in-progress) --- include/mapnik/hextree.hpp | 10 +++++----- include/mapnik/octree.hpp | 2 +- include/mapnik/placement_finder.hpp | 2 +- include/mapnik/png_io.hpp | 15 ++++++--------- include/mapnik/svg/svg_path_adapter.hpp | 2 +- src/box2d.cpp | 16 +++++++++------- src/expression_string.cpp | 6 ++++-- src/font_engine_freetype.cpp | 12 ++++++------ src/miniz.c | 4 ++-- src/miniz_png.cpp | 3 +-- src/palette.cpp | 7 ++++--- src/placement_finder.cpp | 2 +- src/svg/svg_parser.cpp | 5 ++--- src/symbolizer_helpers.cpp | 4 ++-- src/wkb.cpp | 8 ++++---- 15 files changed, 49 insertions(+), 49 deletions(-) diff --git a/include/mapnik/hextree.hpp b/include/mapnik/hextree.hpp index b64aef1fa..bb8bc3794 100644 --- a/include/mapnik/hextree.hpp +++ b/include/mapnik/hextree.hpp @@ -351,19 +351,19 @@ public: pal_remap_.resize(sorted_pal_.size()); palette.clear(); palette.reserve(sorted_pal_.size()); - for (unsigned i=0; i(palette.size()); palette.push_back(sorted_pal_[i]); } } - for (unsigned i=0; i(palette.size()); palette.push_back(sorted_pal_[i]); } } diff --git a/include/mapnik/octree.hpp b/include/mapnik/octree.hpp index be09d98dd..e8c66f4af 100644 --- a/include/mapnik/octree.hpp +++ b/include/mapnik/octree.hpp @@ -300,7 +300,7 @@ public: palette.push_back(rgb(byte(itr->reds/float(count)), byte(itr->greens/float(count)), byte(itr->blues/float(count)))); - itr->index = palette.size() - 1; + itr->index = static_cast(palette.size()) - 1; } for (unsigned i=0; i < 8 ;++i) { diff --git a/include/mapnik/placement_finder.hpp b/include/mapnik/placement_finder.hpp index d57987298..7b6e73369 100644 --- a/include/mapnik/placement_finder.hpp +++ b/include/mapnik/placement_finder.hpp @@ -149,7 +149,7 @@ private: vertical_alignment_e valign_; horizontal_alignment_e halign_; justify_alignment_e jalign_; - std::vector line_breaks_; + std::vector line_breaks_; std::vector > line_sizes_; std::queue< box2d > envelopes_; /** Used to return all placements found. */ diff --git a/include/mapnik/png_io.hpp b/include/mapnik/png_io.hpp index 7f828faea..b0960fa37 100644 --- a/include/mapnik/png_io.hpp +++ b/include/mapnik/png_io.hpp @@ -318,8 +318,8 @@ void save_as_png(T & file, std::vector const& palette, PNG_COMPRESSION_TYPE_DEFAULT,PNG_FILTER_TYPE_DEFAULT); png_color* pal = const_cast(reinterpret_cast(&palette[0])); - png_set_PLTE(png_ptr, info_ptr, pal, palette.size()); - + png_set_PLTE(png_ptr, info_ptr, pal, static_cast(palette.size())); + // make transparent lowest indexes, so tRNS is small if (alpha.size()>0) { @@ -533,15 +533,12 @@ void save_as_png8_oct(T1 & file, leftovers = 0; } std::vector pal; - trees[j].setOffset(palette.size()); + trees[j].setOffset( static_cast(palette.size())); trees[j].create_palette(pal); assert(pal.size() <= max_colors); - leftovers = cols[j]-pal.size(); - cols[j] = pal.size(); - for(unsigned i=0; i(pal.size()); + cols[j] = static_cast(pal.size()); + palette.insert(palette.begin(), pal.begin(), pal.end()); assert(palette.size() <= 256); } } diff --git a/include/mapnik/svg/svg_path_adapter.hpp b/include/mapnik/svg/svg_path_adapter.hpp index 04f24c1a1..e606a088b 100644 --- a/include/mapnik/svg/svg_path_adapter.hpp +++ b/include/mapnik/svg/svg_path_adapter.hpp @@ -919,7 +919,7 @@ public: return vertices_.size() ? vertices_[vertices_.size() - 1].y : 0.0; } - unsigned total_vertices() const + std::size_t total_vertices() const { return vertices_.size(); } diff --git a/src/box2d.cpp b/src/box2d.cpp index b7fbdb3b2..0b4ea60fa 100644 --- a/src/box2d.cpp +++ b/src/box2d.cpp @@ -65,7 +65,7 @@ box2d::box2d(const box2d &rhs) }*/ template -box2d::box2d(const box2d_type &rhs, const agg::trans_affine& tr) +box2d::box2d(box2d_type const& rhs, const agg::trans_affine& tr) { double x0 = rhs.minx_, y0 = rhs.miny_; double x1 = rhs.maxx_, y1 = rhs.miny_; @@ -75,9 +75,10 @@ box2d::box2d(const box2d_type &rhs, const agg::trans_affine& tr) tr.transform(&x1, &y1); tr.transform(&x2, &y2); tr.transform(&x3, &y3); - init(x0, y0, x2, y2); - expand_to_include(x1, y1); - expand_to_include(x3, y3); + init(static_cast(x0), static_cast(y0), + static_cast(x2), static_cast(y2)); + expand_to_include(static_cast(x1), static_cast(y1)); + expand_to_include(static_cast(x3), static_cast(y3)); } template @@ -511,9 +512,10 @@ box2d& box2d::operator*=(agg::trans_affine const& tr) tr.transform(&x1, &y1); tr.transform(&x2, &y2); tr.transform(&x3, &y3); - init(x0, y0, x2, y2); - expand_to_include(x1, y1); - expand_to_include(x3, y3); + init(static_cast(x0), static_cast(y0), + static_cast(x2), static_cast(y2)); + expand_to_include(static_cast(x1), static_cast(y1)); + expand_to_include(static_cast(x3), static_cast(y3)); return *this; } diff --git a/src/expression_string.cpp b/src/expression_string.cpp index f42d5f6cc..492eeef2a 100644 --- a/src/expression_string.cpp +++ b/src/expression_string.cpp @@ -96,7 +96,8 @@ struct expression_string : boost::static_visitor str_ +=".match('"; #if defined(BOOST_REGEX_HAS_ICU) std::string utf8; - UnicodeString ustr = UnicodeString::fromUTF32( &x.pattern.str()[0] ,x.pattern.str().length()); + UnicodeString ustr = UnicodeString::fromUTF32(x.pattern.str().data(), + static_cast(x.pattern.str().length())); to_utf8(ustr,utf8); str_ += utf8; #else @@ -112,7 +113,8 @@ struct expression_string : boost::static_visitor str_ += "'"; #if defined(BOOST_REGEX_HAS_ICU) std::string utf8; - UnicodeString ustr = UnicodeString::fromUTF32( &x.pattern.str()[0] ,x.pattern.str().length()); + UnicodeString ustr = UnicodeString::fromUTF32(x.pattern.str().data(), + static_cast(x.pattern.str().length())); to_utf8(ustr,utf8); str_ += utf8; str_ +="','"; diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index c5e681328..85f1dc15a 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -221,8 +221,8 @@ face_ptr freetype_engine::create_face(std::string const& family_name) if (mem_font_itr != memory_fonts_.end()) // memory font { FT_Error error = FT_New_Memory_Face(library_, - (FT_Byte const*) mem_font_itr->second.c_str(), //buffer - mem_font_itr->second.size(), // size + reinterpret_cast(mem_font_itr->second.c_str()), + static_cast(mem_font_itr->second.size()), // size itr->second.first, // face index &face); @@ -241,8 +241,8 @@ face_ptr freetype_engine::create_face(std::string const& family_name) = memory_fonts_.insert(std::make_pair(itr->second.second, buffer)); FT_Error error = FT_New_Memory_Face (library_, - (FT_Byte const*) result.first->second.c_str(), - buffer.size(), + reinterpret_cast(result.first->second.c_str()), + static_cast(buffer.size()), itr->second.first, &face); if (!error) return boost::make_shared(face); @@ -623,7 +623,7 @@ void text_renderer::render(pixel_position const& pos) itr->properties->halo_fill.rgba(), bit->left, height - bit->top, - halo_radius, + static_cast(halo_radius), itr->properties->text_opacity, comp_op_); } @@ -679,7 +679,7 @@ void text_renderer::render_id(mapnik::value_integer feature_id, feature_id, bit->left, height - bit->top, - itr->properties->halo_radius); + static_cast(itr->properties->halo_radius)); } } } diff --git a/src/miniz.c b/src/miniz.c index 34a3c537b..d9c3a18ae 100644 --- a/src/miniz.c +++ b/src/miniz.c @@ -798,7 +798,7 @@ size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out); // Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. -typedef mz_bool (*tdefl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser); +typedef mz_bool (*tdefl_put_buf_func_ptr)(const void* pBuf, size_t len, void *pUser); // tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally. mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); @@ -2704,7 +2704,7 @@ struct tdefl_output_buffer mz_bool m_expandable; }; -static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, void *pUser) +static mz_bool tdefl_output_buffer_putter(const void *pBuf, size_t len, void *pUser) { tdefl_output_buffer *p = (tdefl_output_buffer *)pUser; size_t new_size = p->m_size + len; diff --git a/src/miniz_png.cpp b/src/miniz_png.cpp index 8278032d0..dba97c373 100644 --- a/src/miniz_png.cpp +++ b/src/miniz_png.cpp @@ -139,8 +139,7 @@ void PNGWriter::finishChunk(size_t start) { // Write chunk length at the beginning of the chunk. size_t payloadLength = buffer->m_size - start - 4 - 4; - writeUInt32BE(buffer->m_pBuf + start, payloadLength); - + writeUInt32BE(buffer->m_pBuf + start, static_cast(payloadLength)); // Write CRC32 checksum. Don't include the 4-byte length, but /do/ include // the 4-byte chunk name. mz_uint32 crc = mz_crc32(MZ_CRC32_INIT, buffer->m_pBuf + start + 4, payloadLength + 4); diff --git a/src/palette.cpp b/src/palette.cpp index f85725962..282386575 100644 --- a/src/palette.cpp +++ b/src/palette.cpp @@ -26,6 +26,7 @@ // stl #include #include +#include namespace mapnik { @@ -81,8 +82,8 @@ bool rgba_palette::valid() const std::string rgba_palette::to_string() const { - unsigned length = rgb_pal_.size(); - unsigned alphaLength = alpha_pal_.size(); + size_t length = rgb_pal_.size(); + size_t alphaLength = alpha_pal_.size(); std::ostringstream str(""); str << "[Palette " << length; if (length == 1) @@ -125,7 +126,7 @@ unsigned char rgba_palette::quantize(unsigned val) const // find closest match based on mean of r,g,b,a std::vector::const_iterator pit = std::lower_bound(sorted_pal_.begin(), sorted_pal_.end(), c, rgba::mean_sort_cmp()); - index = pit - sorted_pal_.begin(); + index = std::distance(sorted_pal_.begin(),pit); if (index == sorted_pal_.size()) index--; dr = sorted_pal_[index].r - c.r; diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index 4532f224c..0d8a50b43 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -286,7 +286,7 @@ void placement_finder::find_line_breaks() //No linebreaks line_sizes_.push_back(std::make_pair(string_width_, string_height_)); } - line_breaks_.push_back(info_.num_characters()); + line_breaks_.push_back(static_cast(info_.num_characters())); } template diff --git a/src/svg/svg_parser.cpp b/src/svg/svg_parser.cpp index a48a65bb0..1b80b756e 100644 --- a/src/svg/svg_parser.cpp +++ b/src/svg/svg_parser.cpp @@ -160,7 +160,7 @@ bool parse_reader(svg_parser & parser, xmlTextReaderPtr reader) catch (std::exception const& ex) { xmlFreeTextReader(reader); - throw; + throw ex; } xmlFreeTextReader(reader); if (ret != 0) @@ -835,8 +835,7 @@ void parse_gradient_stop(svg_parser & parser, xmlTextReaderPtr reader) } - stop_color.set_alpha(opacity*255); - + stop_color.set_alpha(static_cast(opacity * 255)); parser.temporary_gradient_.second.add_stop(offset, stop_color); /* diff --git a/src/symbolizer_helpers.cpp b/src/symbolizer_helpers.cpp index 65c020c56..42003bf23 100644 --- a/src/symbolizer_helpers.cpp +++ b/src/symbolizer_helpers.cpp @@ -175,8 +175,8 @@ template void text_symbolizer_helper::initialize_geometries() { bool largest_box_only = false; - unsigned num_geom = feature_.num_geometries(); - for (unsigned i=0; i& paths, unsigned size, wkbFormat format) { - unsigned geom_count = paths.size(); + std::size_t geom_count = paths.size(); wkb_reader reader(wkb, size, format); reader.read(paths); if (paths.size() > geom_count) From 1847ce581d84e88d9143fb3e7584b3032406ca3b Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 3 May 2013 11:41:43 +0100 Subject: [PATCH 048/122] box2d + re-implement from_string avoiding tokenizer (~10x faster) --- include/mapnik/box2d.hpp | 2 +- src/box2d.cpp | 76 ++++++++++++++-------------------------- 2 files changed, 27 insertions(+), 51 deletions(-) diff --git a/include/mapnik/box2d.hpp b/include/mapnik/box2d.hpp index 41909e677..128828f78 100644 --- a/include/mapnik/box2d.hpp +++ b/include/mapnik/box2d.hpp @@ -92,7 +92,7 @@ public: void init(T x0,T y0,T x1,T y1); void clip(const box2d_type &other); void pad(T padding); - bool from_string(std::string const& s); + bool from_string(std::string const& str); bool valid() const; // define some operators diff --git a/src/box2d.cpp b/src/box2d.cpp index 0b4ea60fa..2ed9c7aa9 100644 --- a/src/box2d.cpp +++ b/src/box2d.cpp @@ -28,12 +28,23 @@ #include // boost -#include +// fusion +#include +// spirit #include +#include // agg #include "agg_trans_affine.h" +BOOST_FUSION_ADAPT_TPL_ADT( + (T), + (mapnik::box2d)(T), + (T, T, obj.minx(), obj.set_minx(val)) + (T, T, obj.miny(), obj.set_miny(val)) + (T, T, obj.maxx(), obj.set_maxx(val)) + (T, T, obj.maxy(), obj.set_maxy(val))) + namespace mapnik { template @@ -58,11 +69,6 @@ box2d::box2d(const box2d &rhs) miny_(rhs.miny_), maxx_(rhs.maxx_), maxy_(rhs.maxy_) {} -// copy rather than init so dfl ctor (0,0,-1,-1) is not modified -// https://github.com/mapnik/mapnik/issues/749 -/*{ - init(rhs.minx_,rhs.miny_,rhs.maxx_,rhs.maxy_); - }*/ template box2d::box2d(box2d_type const& rhs, const agg::trans_affine& tr) @@ -76,7 +82,7 @@ box2d::box2d(box2d_type const& rhs, const agg::trans_affine& tr) tr.transform(&x2, &y2); tr.transform(&x3, &y3); init(static_cast(x0), static_cast(y0), - static_cast(x2), static_cast(y2)); + static_cast(x2), static_cast(y2)); expand_to_include(static_cast(x1), static_cast(y1)); expand_to_include(static_cast(x3), static_cast(y3)); } @@ -381,49 +387,19 @@ void box2d::pad(T padding) maxy_ += padding; } + template -#if !defined(__SUNPRO_CC) -inline -#endif -bool box2d::from_string(std::string const& s) +inline bool box2d::from_string(std::string const& str) { - unsigned i = 0; - double d[4]; - bool success = false; - boost::char_separator sep(", "); - boost::tokenizer > tok(s, sep); - for (boost::tokenizer >::iterator beg = tok.begin(); - beg != tok.end(); ++beg) - { - std::string item = mapnik::util::trim_copy(*beg); - // note: we intentionally do not use mapnik::util::conversions::string2double - // here to ensure that shapeindex can statically compile mapnik::box2d without - // needing to link to libmapnik - std::string::const_iterator str_beg = item.begin(); - std::string::const_iterator str_end = item.end(); - bool r = boost::spirit::qi::phrase_parse(str_beg, - str_end, - boost::spirit::qi::double_, - boost::spirit::ascii::space, - d[i]); - if (!(r && (str_beg == str_end))) - { - break; - } - if (i == 3) - { - success = true; - break; - } - ++i; - } - - if (success) - { - init(static_cast(d[0]),static_cast(d[1]),static_cast(d[2]),static_cast(d[3])); - } - - return success; + using boost::spirit::qi::double_; + using boost::spirit::ascii::space; + bool r = boost::spirit::qi::phrase_parse(str.begin(), + str.end(), + double_ >> ',' >> double_ >> ',' + >> double_ >> ',' >> double_, + space, + *this); + return r; } template @@ -512,8 +488,8 @@ box2d& box2d::operator*=(agg::trans_affine const& tr) tr.transform(&x1, &y1); tr.transform(&x2, &y2); tr.transform(&x3, &y3); - init(static_cast(x0), static_cast(y0), - static_cast(x2), static_cast(y2)); + init(static_cast(x0), static_cast(y0), + static_cast(x2), static_cast(y2)); expand_to_include(static_cast(x1), static_cast(y1)); expand_to_include(static_cast(x3), static_cast(y3)); return *this; From b6d24c6b35e6734d6009e9b841a66f81bc3d0423 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 3 May 2013 11:44:43 +0100 Subject: [PATCH 049/122] remove cruft --- src/box2d.cpp | 75 --------------------------------------------------- 1 file changed, 75 deletions(-) diff --git a/src/box2d.cpp b/src/box2d.cpp index 2ed9c7aa9..3ce491153 100644 --- a/src/box2d.cpp +++ b/src/box2d.cpp @@ -88,9 +88,6 @@ box2d::box2d(box2d_type const& rhs, const agg::trans_affine& tr) } template -#if !defined(__SUNPRO_CC) -inline -#endif bool box2d::operator==(const box2d& other) const { return minx_==other.minx_ && @@ -100,36 +97,24 @@ bool box2d::operator==(const box2d& other) const } template -#if !defined(__SUNPRO_CC) -inline -#endif T box2d::minx() const { return minx_; } template -#if !defined(__SUNPRO_CC) -inline -#endif T box2d::maxx() const { return maxx_; } template -#if !defined(__SUNPRO_CC) -inline -#endif T box2d::miny() const { return miny_; } template -#if !defined(__SUNPRO_CC) -inline -#endif T box2d::maxy() const { return maxy_; @@ -160,27 +145,18 @@ void box2d::set_maxy(T v) } template -#if !defined(__SUNPRO_CC) -inline -#endif T box2d::width() const { return maxx_-minx_; } template -#if !defined(__SUNPRO_CC) -inline -#endif T box2d::height() const { return maxy_-miny_; } template -#if !defined(__SUNPRO_CC) -inline -#endif void box2d::width(T w) { T cx=center().x; @@ -189,9 +165,6 @@ void box2d::width(T w) } template -#if !defined(__SUNPRO_CC) -inline -#endif void box2d::height(T h) { T cy=center().y; @@ -200,9 +173,6 @@ void box2d::height(T h) } template -#if !defined(__SUNPRO_CC) -inline -#endif coord box2d::center() const { return coord(static_cast(0.5*(minx_+maxx_)), @@ -210,18 +180,12 @@ coord box2d::center() const } template -#if !defined(__SUNPRO_CC) -inline -#endif void box2d::expand_to_include(const coord& c) { expand_to_include(c.x,c.y); } template -#if !defined(__SUNPRO_CC) -inline -#endif void box2d::expand_to_include(T x,T y) { if (x::expand_to_include(const box2d &other) } template -#if !defined(__SUNPRO_CC) -inline -#endif bool box2d::contains(const coord &c) const { return contains(c.x,c.y); } template -#if !defined(__SUNPRO_CC) -inline -#endif bool box2d::contains(T x,T y) const { return x>=minx_ && x<=maxx_ && y>=miny_ && y<=maxy_; } template -#if !defined(__SUNPRO_CC) -inline -#endif bool box2d::contains(const box2d &other) const { return other.minx_>=minx_ && @@ -270,27 +225,18 @@ bool box2d::contains(const box2d &other) const } template -#if !defined(__SUNPRO_CC) -inline -#endif bool box2d::intersects(const coord &c) const { return intersects(c.x,c.y); } template -#if !defined(__SUNPRO_CC) -inline -#endif bool box2d::intersects(T x,T y) const { return !(x>maxx_ || xmaxy_ || y -#if !defined(__SUNPRO_CC) -inline -#endif bool box2d::intersects(const box2d &other) const { return !(other.minx_>maxx_ || other.maxx_::intersects(const box2d &other) const } template -#if !defined(__SUNPRO_CC) -inline -#endif box2d box2d::intersect(const box2d_type& other) const { if (intersects(other)) { @@ -317,9 +260,6 @@ box2d box2d::intersect(const box2d_type& other) const } template -#if !defined(__SUNPRO_CC) -inline -#endif void box2d::re_center(T cx,T cy) { T dx=cx-center().x; @@ -331,18 +271,12 @@ void box2d::re_center(T cx,T cy) } template -#if !defined(__SUNPRO_CC) -inline -#endif void box2d::re_center(const coord &c) { re_center(c.x,c.y); } template -#if !defined(__SUNPRO_CC) -inline -#endif void box2d::init(T x0,T y0,T x1,T y1) { if (x0::init(T x0,T y0,T x1,T y1) } template -#if !defined(__SUNPRO_CC) -inline -#endif void box2d::clip(const box2d_type& other) { minx_ = std::max(minx_,other.minx()); @@ -376,9 +307,6 @@ void box2d::clip(const box2d_type& other) } template -#if !defined(__SUNPRO_CC) -inline -#endif void box2d::pad(T padding) { minx_ -= padding; @@ -403,9 +331,6 @@ inline bool box2d::from_string(std::string const& str) } template -#if !defined(__SUNPRO_CC) -inline -#endif bool box2d::valid() const { return (minx_ <= maxx_ && miny_ <= maxy_) ; From 64902452183d6152b60da99e80ecbdce75deec86 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 3 May 2013 14:21:34 +0100 Subject: [PATCH 050/122] + remove more cruft --- include/mapnik/utils.hpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/include/mapnik/utils.hpp b/include/mapnik/utils.hpp index 24a5d3d54..f8e5426e6 100644 --- a/include/mapnik/utils.hpp +++ b/include/mapnik/utils.hpp @@ -81,12 +81,8 @@ public: static MaxAlign staticMemory; return new(&staticMemory) T; } -#ifdef __SUNPRO_CC - // Sun C++ Compiler doesn't handle `volatile` keyword same as GCC. - static void destroy(T* obj) -#else + static void destroy(volatile T* obj) -#endif { obj->~T(); } @@ -95,15 +91,7 @@ public: template class CreatePolicy=CreateStatic> class singleton { -#ifdef __SUNPRO_CC - /* Sun's C++ compiler will issue the following errors if CreatePolicy is used: - Error: A class template name was expected instead of mapnik::CreatePolicy - Error: A "friend" declaration must specify a class or function. - */ - friend class CreatePolicy; -#else friend class CreatePolicy; -#endif static T* pInstance_; static bool destroyed_; singleton(const singleton &rhs); From f70e39c1e6dbb6789a30dfb40557a50c655e8e03 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 3 May 2013 16:06:51 +0100 Subject: [PATCH 051/122] + make comma separator optional (preserve space delimitted syntax) --- src/box2d.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/box2d.cpp b/src/box2d.cpp index 3ce491153..483e9342b 100644 --- a/src/box2d.cpp +++ b/src/box2d.cpp @@ -319,12 +319,13 @@ void box2d::pad(T padding) template inline bool box2d::from_string(std::string const& str) { + using boost::spirit::qi::lit; using boost::spirit::qi::double_; using boost::spirit::ascii::space; bool r = boost::spirit::qi::phrase_parse(str.begin(), str.end(), - double_ >> ',' >> double_ >> ',' - >> double_ >> ',' >> double_, + double_ >> -lit(',') >> double_ >> -lit(',') + >> double_ >> -lit(',') >> double_, space, *this); return r; From 1635834f605b2fee8aa6c8e25218991295c67e2a Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 3 May 2013 16:38:55 +0100 Subject: [PATCH 052/122] + remove inline qualifier --- src/box2d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/box2d.cpp b/src/box2d.cpp index 483e9342b..ea49d272a 100644 --- a/src/box2d.cpp +++ b/src/box2d.cpp @@ -317,7 +317,7 @@ void box2d::pad(T padding) template -inline bool box2d::from_string(std::string const& str) +bool box2d::from_string(std::string const& str) { using boost::spirit::qi::lit; using boost::spirit::qi::double_; From b29fe11e35bc1d4fbd39196f1b0c60835239021e Mon Sep 17 00:00:00 2001 From: "artem@windows" Date: Fri, 3 May 2013 16:43:25 -0700 Subject: [PATCH 053/122] + fix font_set::size return type --- include/mapnik/font_set.hpp | 2 +- src/font_set.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mapnik/font_set.hpp b/include/mapnik/font_set.hpp index 426d60b06..7e21dcffc 100644 --- a/include/mapnik/font_set.hpp +++ b/include/mapnik/font_set.hpp @@ -38,7 +38,7 @@ public: font_set(std::string const& name); font_set(font_set const& rhs); font_set& operator=(font_set const& rhs); - unsigned size() const; + std::size_t size() const; void set_name(std::string const& name); std::string const& get_name() const; void add_face_name(std::string); diff --git a/src/font_set.cpp b/src/font_set.cpp index fdd04229a..d319a2158 100644 --- a/src/font_set.cpp +++ b/src/font_set.cpp @@ -48,14 +48,14 @@ font_set& font_set::operator=(font_set const& other) font_set::~font_set() {} -unsigned font_set::size() const +std::size_t font_set::size() const { return face_names_.size(); } void font_set::add_face_name(std::string face_name) { - face_names_.push_back(face_name); + face_names_.push_back(std::move(face_name)); } void font_set::set_name(std::string const& name) From 31a506f3cb5782b7074d5d2cf752b2987d26af1d Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 6 May 2013 15:52:04 +0100 Subject: [PATCH 054/122] + use more consise c++11 syntax --- plugins/input/osm/osm_datasource.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/input/osm/osm_datasource.cpp b/plugins/input/osm/osm_datasource.cpp index 0a18b4975..6b46bef05 100644 --- a/plugins/input/osm/osm_datasource.cpp +++ b/plugins/input/osm/osm_datasource.cpp @@ -99,14 +99,13 @@ osm_datasource::osm_datasource(const parameters& params) // Add the attributes to the datasource descriptor - assume they are // all of type String - for (std::set::iterator i = keys.begin(); i != keys.end(); i++) + for (auto const& key : keys) { - desc_.add_descriptor(attribute_descriptor(*i, tagtypes.get_type(*i))); + desc_.add_descriptor(attribute_descriptor(key, tagtypes.get_type(key))); } - // Get the bounds of the data and set extent_ accordingly bounds b = osm_data_->get_bounds(); - extent_ = box2d(b.w, b.s, b.e, b.n); + extent_ = box2d(b.w,b.s,b.e,b.n); } osm_datasource::~osm_datasource() From 42d8dfa322624f19607caedc64f4603b0c9cd42a Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 6 May 2013 15:54:17 +0100 Subject: [PATCH 055/122] + add move ctor and 'canonical' assignment operator --- include/mapnik/box2d.hpp | 29 ++++++++++++----------- src/box2d.cpp | 50 +++++++++++++++++++++++++++++----------- 2 files changed, 53 insertions(+), 26 deletions(-) diff --git a/include/mapnik/box2d.hpp b/include/mapnik/box2d.hpp index 128828f78..6133ffbe5 100644 --- a/include/mapnik/box2d.hpp +++ b/include/mapnik/box2d.hpp @@ -57,12 +57,15 @@ private: T miny_; T maxx_; T maxy_; + void swap(box2d_type & rhs); public: box2d(); box2d(T minx,T miny,T maxx,T maxy); - box2d(const coord& c0,const coord& c1); - box2d(const box2d_type& rhs); - box2d(const box2d_type& rhs, const agg::trans_affine& tr); + box2d(coord const& c0, coord const& c1); + box2d(box2d_type const& rhs); + box2d(box2d_type const& rhs, agg::trans_affine const& tr); + box2d(box2d_type&& rhs); + box2d_type& operator=(box2d_type other); T minx() const; T miny() const; T maxx() const; @@ -77,20 +80,20 @@ public: void height(T h); coord center() const; void expand_to_include(T x,T y); - void expand_to_include(const coord& c); - void expand_to_include(const box2d_type& other); - bool contains(const coord &c) const; + void expand_to_include(coord const& c); + void expand_to_include(box2d_type const& other); + bool contains(coord const& c) const; bool contains(T x,T y) const; - bool contains(const box2d_type &other) const; - bool intersects(const coord &c) const; + bool contains(box2d_type const& other) const; + bool intersects(coord const& c) const; bool intersects(T x,T y) const; - bool intersects(const box2d_type &other) const; - box2d_type intersect(const box2d_type& other) const; - bool operator==(const box2d_type &other) const; + bool intersects(box2d_type const& other) const; + box2d_type intersect(box2d_type const& other) const; + bool operator==(box2d_type const& other) const; void re_center(T cx,T cy); - void re_center(const coord& c); + void re_center(coord const& c); void init(T x0,T y0,T x1,T y1); - void clip(const box2d_type &other); + void clip(box2d_type const& other); void pad(T padding); bool from_string(std::string const& str); bool valid() const; diff --git a/src/box2d.cpp b/src/box2d.cpp index ea49d272a..7f1805899 100644 --- a/src/box2d.cpp +++ b/src/box2d.cpp @@ -58,20 +58,44 @@ box2d::box2d(T minx,T miny,T maxx,T maxy) } template -box2d::box2d(const coord &c0,const coord &c1) +box2d::box2d(coord const& c0, coord const& c1) { init(c0.x,c0.y,c1.x,c1.y); } template -box2d::box2d(const box2d &rhs) +box2d::box2d(box2d_type const& rhs) : minx_(rhs.minx_), miny_(rhs.miny_), maxx_(rhs.maxx_), maxy_(rhs.maxy_) {} + template -box2d::box2d(box2d_type const& rhs, const agg::trans_affine& tr) +box2d::box2d(box2d_type && rhs) + : minx_(std::move(rhs.minx_)), + miny_(std::move(rhs.miny_)), + maxx_(std::move(rhs.maxx_)), + maxy_(std::move(rhs.maxy_)) {} + +template +box2d& box2d::operator=(box2d_type other) +{ + swap(other); + return *this; +} + +template +void box2d::swap(box2d_type & other) +{ + std::swap(minx_, other.minx_); + std::swap(miny_, other.miny_); + std::swap(maxx_, other.maxx_); + std::swap(maxy_, other.maxy_); +} + +template +box2d::box2d(box2d_type const& rhs, agg::trans_affine const& tr) { double x0 = rhs.minx_, y0 = rhs.miny_; double x1 = rhs.maxx_, y1 = rhs.miny_; @@ -88,7 +112,7 @@ box2d::box2d(box2d_type const& rhs, const agg::trans_affine& tr) } template -bool box2d::operator==(const box2d& other) const +bool box2d::operator==(box2d const& other) const { return minx_==other.minx_ && miny_==other.miny_ && @@ -180,7 +204,7 @@ coord box2d::center() const } template -void box2d::expand_to_include(const coord& c) +void box2d::expand_to_include(coord const& c) { expand_to_include(c.x,c.y); } @@ -195,7 +219,7 @@ void box2d::expand_to_include(T x,T y) } template -void box2d::expand_to_include(const box2d &other) +void box2d::expand_to_include(box2d const& other) { if (other.minx_maxx_) maxx_=other.maxx_; @@ -204,7 +228,7 @@ void box2d::expand_to_include(const box2d &other) } template -bool box2d::contains(const coord &c) const +bool box2d::contains(coord const& c) const { return contains(c.x,c.y); } @@ -216,7 +240,7 @@ bool box2d::contains(T x,T y) const } template -bool box2d::contains(const box2d &other) const +bool box2d::contains(box2d const& other) const { return other.minx_>=minx_ && other.maxx_<=maxx_ && @@ -225,7 +249,7 @@ bool box2d::contains(const box2d &other) const } template -bool box2d::intersects(const coord &c) const +bool box2d::intersects(coord const& c) const { return intersects(c.x,c.y); } @@ -237,14 +261,14 @@ bool box2d::intersects(T x,T y) const } template -bool box2d::intersects(const box2d &other) const +bool box2d::intersects(box2d const& other) const { return !(other.minx_>maxx_ || other.maxx_maxy_ || other.maxy_ -box2d box2d::intersect(const box2d_type& other) const +box2d box2d::intersect(box2d_type const& other) const { if (intersects(other)) { T x0=std::max(minx_,other.minx_); @@ -271,7 +295,7 @@ void box2d::re_center(T cx,T cy) } template -void box2d::re_center(const coord &c) +void box2d::re_center(coord const& c) { re_center(c.x,c.y); } @@ -298,7 +322,7 @@ void box2d::init(T x0,T y0,T x1,T y1) } template -void box2d::clip(const box2d_type& other) +void box2d::clip(box2d_type const& other) { minx_ = std::max(minx_,other.minx()); miny_ = std::max(miny_,other.miny()); From 4915bf138eae3e3bd7e9a92be3d8757fcbab38e6 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 7 May 2013 12:04:06 +0100 Subject: [PATCH 056/122] mapnik::value + add move ctor mapnik::feature + pass attributes by r-value. --- include/mapnik/feature.hpp | 52 ++++++++++---------- include/mapnik/value.hpp | 16 +++++- plugins/input/postgis/postgis_featureset.cpp | 2 +- 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index 4cf33f2dd..d2a9046bd 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -114,24 +114,24 @@ public: inline void set_id(mapnik::value_integer id) { id_ = id;} template - void put(context_type::key_type const& key, T const& val) + inline void put(context_type::key_type const& key, T const& val) { - put(key,value(val)); + put(key, std::move(value(val))); } template - void put_new(context_type::key_type const& key, T const& val) + inline void put_new(context_type::key_type const& key, T const& val) { - put_new(key,value(val)); + put_new(key,std::move(value(val))); } - void put(context_type::key_type const& key, value const& val) + inline void put(context_type::key_type const& key, value && val) { context_type::map_type::const_iterator itr = ctx_->mapping_.find(key); if (itr != ctx_->mapping_.end() && itr->second < data_.size()) { - data_[itr->second] = val; + data_[itr->second] = std::move(val); } else { @@ -139,28 +139,28 @@ public: } } - void put_new(context_type::key_type const& key, value const& val) + inline void put_new(context_type::key_type const& key, value && val) { context_type::map_type::const_iterator itr = ctx_->mapping_.find(key); if (itr != ctx_->mapping_.end() && itr->second < data_.size()) { - data_[itr->second] = val; + data_[itr->second] = std::move(val); } else { cont_type::size_type index = ctx_->push(key); if (index == data_.size()) - data_.push_back(val); + data_.push_back(std::move(val)); } } - bool has_key(context_type::key_type const& key) const + inline bool has_key(context_type::key_type const& key) const { return (ctx_->mapping_.find(key) != ctx_->mapping_.end()); } - value_type const& get(context_type::key_type const& key) const + inline value_type const& get(context_type::key_type const& key) const { context_type::map_type::const_iterator itr = ctx_->mapping_.find(key); if (itr != ctx_->mapping_.end()) @@ -169,59 +169,59 @@ public: return default_value; } - value_type const& get(std::size_t index) const + inline value_type const& get(std::size_t index) const { if (index < data_.size()) return data_[index]; return default_value; } - std::size_t size() const + inline std::size_t size() const { return data_.size(); } - cont_type const& get_data() const + inline cont_type const& get_data() const { return data_; } - void set_data(cont_type const& data) + inline void set_data(cont_type const& data) { data_ = data; } - context_ptr context() + inline context_ptr context() { return ctx_; } - boost::ptr_vector const& paths() const + inline boost::ptr_vector const& paths() const { return geom_cont_; } - boost::ptr_vector & paths() + inline boost::ptr_vector & paths() { return geom_cont_; } - void add_geometry(geometry_type * geom) + inline void add_geometry(geometry_type * geom) { geom_cont_.push_back(geom); } - std::size_t num_geometries() const + inline std::size_t num_geometries() const { return geom_cont_.size(); } - geometry_type const& get_geometry(std::size_t index) const + inline geometry_type const& get_geometry(std::size_t index) const { return geom_cont_[index]; } - geometry_type& get_geometry(std::size_t index) + inline geometry_type& get_geometry(std::size_t index) { return geom_cont_[index]; } @@ -247,22 +247,22 @@ public: return result; } - raster_ptr const& get_raster() const + inline raster_ptr const& get_raster() const { return raster_; } - void set_raster(raster_ptr const& raster) + inline void set_raster(raster_ptr const& raster) { raster_ = raster; } - feature_kv_iterator begin() const + inline feature_kv_iterator begin() const { return feature_kv_iterator(*this,true); } - feature_kv_iterator end() const + inline feature_kv_iterator end() const { return feature_kv_iterator(*this); } diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index 7ed21948e..fe67c798b 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -792,9 +792,23 @@ public: value () : base_(value_null()) {} - template value(T _val_) + template value(T const& _val_) : base_(_val_) {} + value (value const& other) + : base_(other.base_) {} + + value( value && other) + : base_(std::move(other.base_)) {} + + value & operator=( value const& other) + { + if (this == &other) + return *this; + base_ = other.base_; + return *this; + } + bool operator==(value const& other) const { return boost::apply_visitor(impl::equals(),base_,other.base_); diff --git a/plugins/input/postgis/postgis_featureset.cpp b/plugins/input/postgis/postgis_featureset.cpp index 6ca97d660..1303a268d 100644 --- a/plugins/input/postgis/postgis_featureset.cpp +++ b/plugins/input/postgis/postgis_featureset.cpp @@ -107,7 +107,7 @@ feature_ptr postgis_featureset::next() // TODO - extend feature class to know // that its id is also an attribute to avoid // this duplication - feature->put(name,val); + feature->put(name,std::move(val)); ++pos; } else From b086e2d20cf3e5d0241d37e63f6a0f9c79c683c8 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 7 May 2013 16:12:57 +0100 Subject: [PATCH 057/122] + small optimization - pass and return const ref --- include/mapnik/expression_evaluator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/expression_evaluator.hpp b/include/mapnik/expression_evaluator.hpp index 5da143a1d..6d231aa0e 100644 --- a/include/mapnik/expression_evaluator.hpp +++ b/include/mapnik/expression_evaluator.hpp @@ -47,7 +47,7 @@ struct evaluate : boost::static_visitor explicit evaluate(feature_type const& f) : feature_(f) {} - value_type operator() (value_type x) const + value_type const& operator() (value_type const& x) const { return x; } From 4138a70a520a22150981f50ee7824857a702cb7d Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 8 May 2013 16:51:28 +0100 Subject: [PATCH 058/122] mapnik::value to_expression_string - add missing specialization for mapnik::value_integer and remove usage of std::stringstream --- include/mapnik/value.hpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index fe67c798b..6e9e894fa 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -40,8 +40,6 @@ #include "hash_variant.hpp" // stl -#include -#include #include #include @@ -670,6 +668,13 @@ struct to_expression_string : public boost::static_visitor return "'" + utf8 + "'"; } + std::string operator() (value_integer val) const + { + std::string output; + util::to_string(output,val); + return output; + } + std::string operator() (value_double val) const { std::string output; @@ -687,14 +692,6 @@ struct to_expression_string : public boost::static_visitor boost::ignore_unused_variable_warning(val); return "null"; } - - template - std::string operator() (T val) const - { - std::stringstream ss; - ss << val; - return ss.str(); - } }; struct to_double : public boost::static_visitor From 75aa6e94d861753d0976b5a549f8165b4df942b3 Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 8 May 2013 16:54:25 +0100 Subject: [PATCH 059/122] + expression_optimizer (experimental) at the moment very basic ops are supported e.g ``` expr = 1+1+1 ---> expr = 3 expr = 1+1+[ATTR] ---> 2+[ATTR] expr = [ATTR] + 1 + 1 ---> ([ATTR] + 1) + 1 ### stays unchaged expr = [ATTR] + 1/3.14159 + 1 ---> ([ATTR] + 0.31831) + 1 ``` --- include/mapnik/expression_optimizer.hpp | 125 ++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 include/mapnik/expression_optimizer.hpp diff --git a/include/mapnik/expression_optimizer.hpp b/include/mapnik/expression_optimizer.hpp new file mode 100644 index 000000000..3507a4a36 --- /dev/null +++ b/include/mapnik/expression_optimizer.hpp @@ -0,0 +1,125 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2013 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_EXPRESSION_OPTIMIZER_HPP +#define MAPNIK_EXPRESSION_OPTIMIZER_HPP + +// mapnik +#include +#include +#include + +// boost +#include +#include +#include +#include + +namespace mapnik +{ + + +template +struct optimize : boost::static_visitor< std::tuple > +{ + typedef T node_type; + typedef std::tuple return_type; + + return_type operator() (value const& v) const + { + return std::make_tuple(node_type(v),true); + } + + return_type operator() (attribute const& attr) const + { + return std::make_tuple(node_type(attr),false); + } + + return_type operator() (geometry_type_attribute const& attr) const + { + return return_type(node_type(attr),false); + } + + return_type operator() (binary_node const & x) const + { + return return_type(node_type(x),false); +// return (boost::apply_visitor(optimize(),x.left).to_bool()) + // && (boost::apply_visitor(optimize(),x.right).to_bool()); + } + + return_type operator() (binary_node const & x) const + { + return return_type(node_type(x),false); +// return (boost::apply_visitor(optimize(),x.left).to_bool()) + // || (boost::apply_visitor(optimize(),x.right).to_bool()); + } + + template + return_type operator() (binary_node const& x) const + { + auto left = boost::apply_visitor(optimize(),x.left); + auto right = boost::apply_visitor(optimize(),x.right); + if (std::get<1>(left) && std::get<1>(right)) + { + // evaluate + typename make_op::type operation; + auto lv = boost::get(std::get<0>(left)); + auto rv = boost::get(std::get<0>(right)); + return return_type(node_type(operation(lv,rv)),true); + } + else + return return_type(node_type(binary_node(std::get<0>(left), + std::get<0>(right))),false); + } + + template + return_type operator() (unary_node const& x) const + { + //typename make_op::type func; + //return func(boost::apply_visitor(*this, x.expr)); +// return node_type(x); + return return_type(node_type(x),false); + } + + return_type operator() (unary_node const& x) const + { +// return node_type(x); + return return_type(node_type(x),false); + //return ! (boost::apply_visitor(optimize(),x.expr).to_bool()); + } + + return_type operator() (regex_match_node const& x) const + { + return return_type(node_type(x),false); +// return boost::apply_visitor(optimize(),x.expr); + } + + return_type operator() (regex_replace_node const& x) const + { + return return_type(node_type(x),false); + //return boost::apply_visitor(optimize(),x.expr); + } +}; + +} + +#endif // MAPNIK_EXPRESSION_OPTIMIZER_HPP From 656c9e724f38cea8c6dfbdad8947ddaa375400bb Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 8 May 2013 17:21:34 +0100 Subject: [PATCH 060/122] + re-arrange expression --- include/mapnik/expression_optimizer.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/mapnik/expression_optimizer.hpp b/include/mapnik/expression_optimizer.hpp index 3507a4a36..bad499ff5 100644 --- a/include/mapnik/expression_optimizer.hpp +++ b/include/mapnik/expression_optimizer.hpp @@ -86,9 +86,18 @@ struct optimize : boost::static_visitor< std::tuple > auto rv = boost::get(std::get<0>(right)); return return_type(node_type(operation(lv,rv)),true); } - else + + if (std::get<1>(right)) + { + return return_type(node_type(binary_node(std::get<0>(right), + std::get<0>(left))), false); + } + if (std::get<1>(left)) + { return return_type(node_type(binary_node(std::get<0>(left), - std::get<0>(right))),false); + std::get<0>(right))), false); + } + return return_type(node_type(x),false); } template From 6bfb92811e31f232217920ec97291a7a79b21652 Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 9 May 2013 13:46:09 +0100 Subject: [PATCH 061/122] + make default ctor nothrow --- include/mapnik/value.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index 6e9e894fa..a7b900f9d 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -786,7 +786,7 @@ class value friend const value operator%(value const&,value const&); public: - value () + value () noexcept : base_(value_null()) {} template value(T const& _val_) From 0fb7898e5e6ce5258fbdf44812834d7fba0c8999 Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 9 May 2013 13:46:51 +0100 Subject: [PATCH 062/122] + format --- src/expression_string.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/expression_string.cpp b/src/expression_string.cpp index 492eeef2a..e6eb5c13a 100644 --- a/src/expression_string.cpp +++ b/src/expression_string.cpp @@ -96,8 +96,8 @@ struct expression_string : boost::static_visitor str_ +=".match('"; #if defined(BOOST_REGEX_HAS_ICU) std::string utf8; - UnicodeString ustr = UnicodeString::fromUTF32(x.pattern.str().data(), - static_cast(x.pattern.str().length())); + UnicodeString ustr = UnicodeString::fromUTF32(x.pattern.str().data(), + static_cast(x.pattern.str().length())); to_utf8(ustr,utf8); str_ += utf8; #else @@ -114,7 +114,7 @@ struct expression_string : boost::static_visitor #if defined(BOOST_REGEX_HAS_ICU) std::string utf8; UnicodeString ustr = UnicodeString::fromUTF32(x.pattern.str().data(), - static_cast(x.pattern.str().length())); + static_cast(x.pattern.str().length())); to_utf8(ustr,utf8); str_ += utf8; str_ +="','"; From dc2ab8506fe6b826a5667a8a752a7e3c1fe06577 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 8 May 2013 20:13:20 -0700 Subject: [PATCH 063/122] Add test for image.fromstring - refs #1805 --- tests/python_tests/image_test.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/python_tests/image_test.py diff --git a/tests/python_tests/image_test.py b/tests/python_tests/image_test.py new file mode 100644 index 000000000..d83a41ac4 --- /dev/null +++ b/tests/python_tests/image_test.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import sys +import os, mapnik +from timeit import Timer, time +from nose.tools import * +from utilities import execution_path + +def setup(): + # All of the paths used are relative, if we run the tests + # from another directory we need to chdir() + os.chdir(execution_path('.')) + + +def test_image_open_from_string(): + filepath = '../data/images/dummy.png' + im1 = mapnik.Image.open(filepath) + im2 = mapnik.Image.fromstring(open(filepath,'rb').read()) + eq_(im1.width(),im2.width()) + length = len(im1.tostring()) + eq_(length,len(im2.tostring())) + eq_(len(mapnik.Image.fromstring(im1.tostring('png')).tostring()),length) + eq_(len(mapnik.Image.fromstring(im1.tostring('jpeg')).tostring()),length) + eq_(len(mapnik.Image.fromstring(im1.tostring('tiff')).tostring()),length) + +if __name__ == "__main__": + setup() + [eval(run)() for run in dir() if 'test_' in run] From dd0c4701c5404ee89b452d76428b4fe09d631c2f Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 9 May 2013 15:15:02 +0100 Subject: [PATCH 064/122] + hold actual values in expressions tree (experimental) (result gets converted to mapnik::value) --- include/mapnik/expression_evaluator.hpp | 24 ++++++++++++++++++-- include/mapnik/expression_node_types.hpp | 29 ++++++++++++------------ 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/include/mapnik/expression_evaluator.hpp b/include/mapnik/expression_evaluator.hpp index 6d231aa0e..8dedcb10c 100644 --- a/include/mapnik/expression_evaluator.hpp +++ b/include/mapnik/expression_evaluator.hpp @@ -47,9 +47,29 @@ struct evaluate : boost::static_visitor explicit evaluate(feature_type const& f) : feature_(f) {} - value_type const& operator() (value_type const& x) const + value_integer operator() (value_integer val) const { - return x; + return val; + } + + value_double operator() (value_double val) const + { + return val; + } + + value_bool operator() (value_bool val) const + { + return val; + } + + value_null operator() (value_null val) const + { + return val; + } + + value_unicode_string const& operator() (value_unicode_string const& str) const + { + return str; } value_type operator() (attribute const& attr) const diff --git a/include/mapnik/expression_node_types.hpp b/include/mapnik/expression_node_types.hpp index 6c1af39e6..53a998453 100644 --- a/include/mapnik/expression_node_types.hpp +++ b/include/mapnik/expression_node_types.hpp @@ -24,24 +24,17 @@ #define MAPNIK_EXPRESSION_NODE_TYPES_HPP // mapnik -//#include -//#include +#include +#include +#include // boost -#include - -namespace boost { template class recursive_wrapper; } +#include +#include namespace mapnik { -struct attribute; -struct geometry_type_attribute; -namespace value_adl_barrier { - class value; -} -using value_adl_barrier::value; - namespace tags { struct negate { @@ -174,8 +167,12 @@ struct regex_replace_node; typedef mapnik::value value_type; -typedef boost::variant < -value_type, +typedef boost::mpl::vector24< +value_null, +value_bool, +value_integer, +value_double, +value_unicode_string, attribute, geometry_type_attribute, boost::recursive_wrapper >, @@ -195,7 +192,9 @@ boost::recursive_wrapper >, boost::recursive_wrapper >, boost::recursive_wrapper, boost::recursive_wrapper -> expr_node; +>::type expr_types; + +typedef boost::make_recursive_variant_over::type expr_node; } From 8897b2b85227086d0eb01b30902706dc2ed68865 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 9 May 2013 14:54:29 -0700 Subject: [PATCH 065/122] reduce libary size by passing -fvisibility-inlines-hidden - closes #1832 - refs #1826 --- SConstruct | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index d01f876c0..8e2448e3b 100644 --- a/SConstruct +++ b/SConstruct @@ -1609,7 +1609,7 @@ if not preconfigured: if env['DEBUG']: env.Append(CXXFLAGS = gcc_cxx_flags + '-O0 -fno-inline') else: - env.Append(CXXFLAGS = gcc_cxx_flags + '-O%s -fno-strict-aliasing -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts' % (env['OPTIMIZATION'])) + env.Append(CXXFLAGS = gcc_cxx_flags + '-O%s -fvisibility-inlines-hidden -fno-strict-aliasing -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts' % (env['OPTIMIZATION'])) if env['DEBUG_UNDEFINED']: env.Append(CXXFLAGS = '-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error -ftrapv -fwrapv') @@ -1728,9 +1728,6 @@ if not HELP_REQUESTED: Export('env') plugin_base = env.Clone() - # for this to work you need: - # if __GNUC__ >= 4 - # define MAPNIK_EXP __attribute__ ((visibility ("default"))) #plugin_base.Append(CXXFLAGS='-fvisibility=hidden') #plugin_base.Append(CXXFLAGS='-fvisibility-inlines-hidden') From 32238368748b7d2185faf93057b0e5e547251a57 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 10 May 2013 16:45:54 +0100 Subject: [PATCH 066/122] + potential boost::variant optimization --- include/mapnik/value.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index a7b900f9d..cb72592e8 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -47,6 +47,15 @@ #include #include +namespace boost { + + template <> + struct has_nothrow_copy + : mpl::true_ + { + }; + +} namespace mapnik { From e9733d8a9bfa430d91505640558bb9c952a981a0 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 10 May 2013 16:50:28 +0100 Subject: [PATCH 067/122] + fix writing to std::stringstream * if seeking pass the end - grow buffer (stringstream!) * seekp beyond current buffer size doesn't set failbit (clang/libcxx) --- include/mapnik/tiff_io.hpp | 95 ++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 20 deletions(-) diff --git a/include/mapnik/tiff_io.hpp b/include/mapnik/tiff_io.hpp index 8d6dc8833..18b666180 100644 --- a/include/mapnik/tiff_io.hpp +++ b/include/mapnik/tiff_io.hpp @@ -24,8 +24,7 @@ #define MAPNIK_TIFF_IO_HPP #include - -#include +#include extern "C" { @@ -45,37 +44,89 @@ namespace mapnik { static tsize_t tiff_write_proc(thandle_t fd, tdata_t buf, tsize_t size) { - std::ostream* out = (std::ostream*)fd; + std::ostream* out = reinterpret_cast(fd); + std::ios::pos_type pos = out->tellp(); + std::streamsize request_size = size; + if (static_cast(request_size) != size) + return static_cast(-1); + out->write(reinterpret_cast(buf), size); - out->write((const char*)buf, size); - - return size; + if( static_cast(pos) == -1 ) + { + return size; + } + else + { + return static_cast(out->tellp()-pos); + } } static toff_t tiff_seek_proc(thandle_t fd, toff_t off, int whence) { - if (off == 0xFFFFFFFF) - { - return 0xFFFFFFFF; - } + std::ostream* out = reinterpret_cast(fd); - std::ostream* out = (std::ostream*)fd; + if( out->fail() ) + return static_cast(-1); + + if( static_cast(out->tellp()) == -1) + return static_cast< toff_t >( 0 ); switch(whence) { + case SEEK_SET: + out->seekp(off, std::ios_base::beg); + break; case SEEK_CUR: out->seekp(off, std::ios_base::cur); break; case SEEK_END: out->seekp(off, std::ios_base::end); break; - case SEEK_SET: - default: - out->seekp(off, std::ios_base::beg); - break; } + // grow std::stringstream buffer (re: libtiff/tif_stream.cxx) + std::ios::pos_type pos = out->tellp(); + // second check needed for clang (libcxx doesn't set failbit when seeking beyond the current buffer size + if( out->fail() || off != pos) + { + std::ios::iostate old_state; + std::ios::pos_type origin; + old_state = out->rdstate(); + // reset the fail bit or else tellp() won't work below + out->clear(out->rdstate() & ~std::ios::failbit); + switch( whence ) + { + case SEEK_SET: + default: + origin = 0L; + break; + case SEEK_CUR: + origin = out->tellp(); + break; + case SEEK_END: + out->seekp(0, std::ios::end); + origin = out->tellp(); + break; + } + // restore original stream state + out->clear(old_state); - return (toff_t)out->tellp(); + // only do something if desired seek position is valid + if( (static_cast(origin) + off) > 0L) + { + uint64_t num_fill; + // clear the fail bit + out->clear(out->rdstate() & ~std::ios::failbit); + // extend the stream to the expected size + out->seekp(0, std::ios::end); + num_fill = (static_cast(origin)) + off - out->tellp(); + for( uint64_t i = 0; i < num_fill; ++i) + out->put('\0'); + + // retry the seek + out->seekp(static_cast(static_cast(origin) + off), std::ios::beg); + } + } + return static_cast(out->tellp()); } static int tiff_close_proc(thandle_t fd) @@ -87,8 +138,12 @@ static int tiff_close_proc(thandle_t fd) static toff_t tiff_size_proc(thandle_t fd) { - std::ostream* out = (std::ostream*)fd; - return (toff_t)out->tellp(); + std::ostream* out = reinterpret_cast(fd); + std::ios::pos_type pos = out->tellp(); + out->seekp(0, std::ios::end); + std::ios::pos_type len = out->tellp(); + out->seekp(pos); + return (toff_t)len; } static tsize_t tiff_dummy_read_proc(thandle_t fd, tdata_t buf, tsize_t size) @@ -113,7 +168,7 @@ void save_as_tiff(T1 & file, T2 const& image) const int scanline_size = sizeof(unsigned char) * width * 3; TIFF* output = RealTIFFOpen("mapnik_tiff_stream", - "w", + "wm", (thandle_t)&file, tiff_dummy_read_proc, tiff_write_proc, @@ -124,7 +179,7 @@ void save_as_tiff(T1 & file, T2 const& image) tiff_dummy_unmap_proc); if (! output) { - // throw ? + throw ImageWriterException("Could not write TIFF"); } TIFFSetField(output, TIFFTAG_IMAGEWIDTH, width); From 677a0a68c65abd2d6e57989cce3756dd4b41dfd1 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 13 May 2013 10:25:09 +0100 Subject: [PATCH 068/122] TIFF I/O + use c++ casts + better naming --- include/mapnik/tiff_io.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mapnik/tiff_io.hpp b/include/mapnik/tiff_io.hpp index 18b666180..a4ac7b83d 100644 --- a/include/mapnik/tiff_io.hpp +++ b/include/mapnik/tiff_io.hpp @@ -143,7 +143,7 @@ static toff_t tiff_size_proc(thandle_t fd) out->seekp(0, std::ios::end); std::ios::pos_type len = out->tellp(); out->seekp(pos); - return (toff_t)len; + return static_cast(len); } static tsize_t tiff_dummy_read_proc(thandle_t fd, tdata_t buf, tsize_t size) @@ -167,7 +167,7 @@ void save_as_tiff(T1 & file, T2 const& image) const int height = image.height(); const int scanline_size = sizeof(unsigned char) * width * 3; - TIFF* output = RealTIFFOpen("mapnik_tiff_stream", + TIFF* output = RealTIFFOpen("tiff_output_stream", "wm", (thandle_t)&file, tiff_dummy_read_proc, From dbcffe61791850d32682334e3e8ef1eb57c3660f Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 13 May 2013 10:26:04 +0100 Subject: [PATCH 069/122] + better naming --- src/png_reader.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/png_reader.cpp b/src/png_reader.cpp index 73a3a5ec7..1185a33f8 100644 --- a/src/png_reader.cpp +++ b/src/png_reader.cpp @@ -42,7 +42,7 @@ template class png_reader : public image_reader { typedef T source_type; - typedef boost::iostreams::stream ifstream; + typedef boost::iostreams::stream input_stream; struct png_struct_guard { @@ -61,14 +61,14 @@ class png_reader : public image_reader private: source_type source_; - ifstream stream_; + input_stream stream_; unsigned width_; unsigned height_; int bit_depth_; int color_type_; public: explicit png_reader(std::string const& file_name); - explicit png_reader(char const* data, std::size_t size); + png_reader(char const* data, std::size_t size); ~png_reader(); unsigned width() const; unsigned height() const; @@ -110,7 +110,7 @@ void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg) template void png_reader::png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { - ifstream * fin = reinterpret_cast(png_get_io_ptr(png_ptr)); + input_stream * fin = reinterpret_cast(png_get_io_ptr(png_ptr)); fin->read(reinterpret_cast(data), length); if (fin->gcount() != length) { @@ -128,7 +128,7 @@ png_reader::png_reader(std::string const& file_name) color_type_(0) { - if (!stream_) throw image_reader_exception("cannot open image file "+ file_name); + if (!stream_) throw image_reader_exception("PNG reader: cannot open file "+ file_name); init(); } From 245e71d7352c02c126e1d861c46627bdf7d12eaf Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 13 May 2013 10:26:28 +0100 Subject: [PATCH 070/122] TIFF I/O + use generic std::istream + add open from char const* and size factory method --- src/tiff_reader.cpp | 196 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 152 insertions(+), 44 deletions(-) diff --git a/src/tiff_reader.cpp b/src/tiff_reader.cpp index a62c42e24..1085943a7 100644 --- a/src/tiff_reader.cpp +++ b/src/tiff_reader.cpp @@ -26,6 +26,10 @@ // boost #include #include +// iostreams +#include +#include +#include extern "C" { @@ -35,12 +39,75 @@ extern "C" namespace mapnik { -using std::min; -using std::max; +namespace impl { +static toff_t tiff_seek_proc(thandle_t fd, toff_t off, int whence) +{ + std::istream* in = reinterpret_cast(fd); + + switch(whence) + { + case SEEK_SET: + in->seekg(off, std::ios_base::beg); + break; + case SEEK_CUR: + in->seekg(off, std::ios_base::cur); + break; + case SEEK_END: + in->seekg(off, std::ios_base::end); + break; + } + return static_cast(in->tellg()); +} + +static int tiff_close_proc(thandle_t fd) +{ + return 0; +} + +static toff_t tiff_size_proc(thandle_t fd) +{ + std::istream* in = reinterpret_cast(fd); + std::ios::pos_type pos = in->tellg(); + in->seekg(0, std::ios::end); + std::ios::pos_type len = in->tellg(); + in->seekg(pos); + return static_cast(len); +} + +static tsize_t tiff_read_proc(thandle_t fd, tdata_t buf, tsize_t size) +{ + std::istream * in = reinterpret_cast(fd); + std::streamsize request_size = size; + if (static_cast(request_size) != size) + return static_cast(-1); + in->read(reinterpret_cast(buf), request_size); + return static_cast(in->gcount()); +} + +static tsize_t tiff_write_proc(thandle_t fd, tdata_t buf, tsize_t size) +{ + return 0; +} + +static void tiff_unmap_proc(thandle_t fd, tdata_t base, toff_t size) +{ +} + +static int tiff_map_proc(thandle_t fd, tdata_t* pbase, toff_t* psize) +{ + return 0; +} + +} + +template class tiff_reader : public image_reader { typedef boost::shared_ptr tiff_ptr; + typedef T source_type; + typedef boost::iostreams::stream input_stream; + struct tiff_closer { void operator() (TIFF * tif) @@ -53,10 +120,11 @@ class tiff_reader : public image_reader }; private: - std::string file_name_; + source_type source_; + input_stream stream_; int read_method_; - unsigned width_; - unsigned height_; + std::size_t width_; + std::size_t height_; int rows_per_strip_; int tile_width_; int tile_height_; @@ -69,6 +137,7 @@ public: tiled }; explicit tiff_reader(std::string const& file_name); + tiff_reader(char const* data, std::size_t size); virtual ~tiff_reader(); unsigned width() const; unsigned height() const; @@ -81,22 +150,32 @@ private: void read_generic(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); - TIFF* load_if_exists(std::string const& filename); + TIFF* open(std::istream & input); static void on_error(const char* /*module*/, const char* fmt, va_list argptr); }; namespace { + image_reader* create_tiff_reader(std::string const& file) { - return new tiff_reader(file); + return new tiff_reader(file); +} + +image_reader* create_tiff_reader2(char const * data, std::size_t size) +{ + return new tiff_reader(data, size); } const bool registered = register_image_reader("tiff",create_tiff_reader); +const bool registered2 = register_image_reader("tiff", create_tiff_reader2); + } -tiff_reader::tiff_reader(std::string const& file_name) - : file_name_(file_name), +template +tiff_reader::tiff_reader(std::string const& file_name) + : source_(file_name, std::ios_base::in | std::ios_base::binary), + stream_(source_), read_method_(generic), width_(0), height_(0), @@ -105,25 +184,48 @@ tiff_reader::tiff_reader(std::string const& file_name) tile_height_(0), premultiplied_alpha_(false) { + if (!stream_) throw image_reader_exception("TIFF reader: cannot open file "+ file_name); init(); } -void tiff_reader::on_error(const char* /*module*/, const char* fmt, va_list argptr) +template +tiff_reader::tiff_reader(char const* data, std::size_t size) + : source_(data, size), + stream_(source_), + read_method_(generic), + width_(0), + height_(0), + rows_per_strip_(0), + tile_width_(0), + tile_height_(0), + premultiplied_alpha_(false) +{ + if (!stream_) throw image_reader_exception("TIFF reader: cannot open image stream "); + stream_.seekg(0, std::ios::beg); + init(); +} + +template +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() +template +void tiff_reader::init() { TIFFSetWarningHandler(0); // Note - we intentially set the error handling to null // when opening the image for the first time to avoid // leaking in TiffOpen: https://github.com/mapnik/mapnik/issues/1783 TIFFSetErrorHandler(0); - TIFF* tif = load_if_exists(file_name_); - if (!tif) throw image_reader_exception( std::string("Can't load tiff file: '") + file_name_ + "'"); + + TIFF* tif = open(stream_); + + if (!tif) throw image_reader_exception("Can't open tiff file"); + TIFFSetErrorHandler(on_error); char msg[1024]; @@ -159,29 +261,31 @@ void tiff_reader::init() } } - -tiff_reader::~tiff_reader() +template +tiff_reader::~tiff_reader() { } - -unsigned tiff_reader::width() const +template +unsigned tiff_reader::width() const { return width_; } - -unsigned tiff_reader::height() const +template +unsigned tiff_reader::height() const { return height_; } -bool tiff_reader::premultiplied_alpha() const +template +bool tiff_reader::premultiplied_alpha() const { return premultiplied_alpha_; } -void tiff_reader::read(unsigned x,unsigned y,image_data_32& image) +template +void tiff_reader::read(unsigned x,unsigned y,image_data_32& image) { if (read_method_==stripped) { @@ -197,20 +301,20 @@ void tiff_reader::read(unsigned x,unsigned y,image_data_32& image) } } - -void tiff_reader::read_generic(unsigned /*x*/,unsigned /*y*/,image_data_32& /*image*/) +template +void tiff_reader::read_generic(unsigned /*x*/,unsigned /*y*/,image_data_32& /*image*/) { - TIFF* tif = load_if_exists(file_name_); + TIFF* tif = open(stream_); if (tif) { MAPNIK_LOG_DEBUG(tiff_reader) << "tiff_reader: TODO - tiff is not stripped or tiled"; } } - -void tiff_reader::read_tiled(unsigned x0,unsigned y0,image_data_32& image) +template +void tiff_reader::read_tiled(unsigned x0,unsigned y0,image_data_32& image) { - TIFF* tif = load_if_exists(file_name_); + TIFF* tif = open(stream_); if (tif) { uint32* buf = (uint32*)_TIFFmalloc(tile_width_*tile_height_*sizeof(uint32)); @@ -226,8 +330,8 @@ void tiff_reader::read_tiled(unsigned x0,unsigned y0,image_data_32& image) for (int y=start_y;y=n0;--n) { @@ -251,10 +355,10 @@ void tiff_reader::read_tiled(unsigned x0,unsigned y0,image_data_32& image) } } - -void tiff_reader::read_stripped(unsigned x0,unsigned y0,image_data_32& image) +template +void tiff_reader::read_stripped(unsigned x0,unsigned y0,image_data_32& image) { - TIFF* tif = load_if_exists(file_name_); + TIFF* tif = open(stream_); if (tif) { uint32* buf = (uint32*)_TIFFmalloc(width_*rows_per_strip_*sizeof(uint32)); @@ -268,12 +372,12 @@ void tiff_reader::read_stripped(unsigned x0,unsigned y0,image_data_32& image) int row,tx0,tx1,ty0,ty1; tx0=x0; - tx1=min(width+x0,(unsigned)width_); + tx1=std::min(width+x0,(unsigned)width_); for (unsigned y=start_y; y < end_y; y+=rows_per_strip_) { - ty0 = max(y0,y)-y; - ty1 = min(height+y0,y+rows_per_strip_)-y; + ty0 = std::max(y0,y)-y; + ty1 = std::min(height+y0,y+rows_per_strip_)-y; if (!TIFFReadRGBAStrip(tif,y,buf)) break; @@ -291,16 +395,20 @@ void tiff_reader::read_stripped(unsigned x0,unsigned y0,image_data_32& image) } } -TIFF* tiff_reader::load_if_exists(std::string const& filename) +template +TIFF* tiff_reader::open(std::istream & input) { if (!tif_) { - boost::filesystem::path path(file_name_); - if (boost::filesystem::is_regular(path)) // exists and regular file - { - // File path is a full file path and does exist - tif_ = tiff_ptr(TIFFOpen(filename.c_str(), "rb"), tiff_closer()); - } + tif_ = tiff_ptr(TIFFClientOpen("tiff_input_stream", "rm", + reinterpret_cast(&input), + impl::tiff_read_proc, + impl::tiff_write_proc, + impl::tiff_seek_proc, + impl::tiff_close_proc, + impl::tiff_size_proc, + impl::tiff_map_proc, + impl::tiff_unmap_proc), tiff_closer()); } return tif_.get(); } From abc5d39dbd5cfafd716ef768a065c28b64a03362 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 14 May 2013 12:06:55 +0100 Subject: [PATCH 071/122] + comment out as msvc++ doesn't support 'noexcept' --- include/mapnik/value.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index cb72592e8..98be593b1 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -795,7 +795,7 @@ class value friend const value operator%(value const&,value const&); public: - value () noexcept + value () //noexcept -- comment out for VC++11 : base_(value_null()) {} template value(T const& _val_) From d83935a8e00ccb5bd57fb7b6e1b0a9f36aaf7297 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 14 May 2013 12:28:13 +0100 Subject: [PATCH 072/122] * restore operator%= support - explicit pnoenix::construct on rhs * move fwd decl into main mapnik namespace * c++ style formatting --- src/expression_grammar.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/expression_grammar.cpp b/src/expression_grammar.cpp index 3c90f8777..f1d699f2a 100644 --- a/src/expression_grammar.cpp +++ b/src/expression_grammar.cpp @@ -34,15 +34,13 @@ #include #include -// fwd declare -namespace mapnik { - struct attribute; - struct geometry_type_attribute; -} - namespace mapnik { +// fwd declare +struct attribute; +struct geometry_type_attribute; + template expr_node regex_match_impl::operator() (T0 & node, T1 const& pattern) const { @@ -144,7 +142,7 @@ expression_grammar::expression_grammar(mapnik::transcoder const& tr) multiplicative_expr = unary_expr [_val = _1] >> *( '*' >> unary_expr [_val *= _1] | '/' >> unary_expr [_val /= _1] -// | '%' >> unary_expr [_val %= _1] --> FIXME + | '%' >> unary_expr [_val %= construct(_1)] //needed by clang++ | regex_match_expr[_val = regex_match_(_val, _1)] | regex_replace_expr(_val) [_val = _1] ) From 1e1e2d1e795709af47d67ee41d17203ab51e2f2f Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 14 May 2013 12:31:05 +0100 Subject: [PATCH 073/122] + prefer ```const& ``` style (mapnik c++ style) --- include/mapnik/expression_node.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/mapnik/expression_node.hpp b/include/mapnik/expression_node.hpp index e344f62ce..b8ec1b31b 100644 --- a/include/mapnik/expression_node.hpp +++ b/include/mapnik/expression_node.hpp @@ -138,27 +138,27 @@ inline expr_node& operator- (expr_node& expr) return expr = unary_node(expr); } -inline expr_node & operator += ( expr_node &left ,const expr_node &right) +inline expr_node & operator += ( expr_node &left, expr_node const& right) { return left = binary_node(left,right); } -inline expr_node & operator -= ( expr_node &left ,const expr_node &right) +inline expr_node & operator -= ( expr_node &left, expr_node const& right) { return left = binary_node(left,right); } -inline expr_node & operator *= ( expr_node &left ,const expr_node &right) +inline expr_node & operator *= ( expr_node &left , expr_node const& right) { return left = binary_node(left,right); } -inline expr_node & operator /= ( expr_node &left ,const expr_node &right) +inline expr_node & operator /= ( expr_node &left , expr_node const& right) { return left = binary_node(left,right); } -inline expr_node & operator %= ( expr_node &left ,const expr_node &right) +inline expr_node & operator %= ( expr_node &left , expr_node const& right) { return left = binary_node(left,right); } From 5d0c36fb65a128142e89bc6e59336ed0ed9060f8 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 14 May 2013 14:51:28 +0100 Subject: [PATCH 074/122] Geometry/Feature parsers -truncate 'where' message in on_error handler (currently 16 chars max) --- include/mapnik/json/feature_grammar.hpp | 1 + include/mapnik/json/geometry_grammar.hpp | 16 ++++++++++++++++ src/json/feature_grammar.cpp | 7 +++++-- src/json/geometry_grammar.cpp | 9 +++++++-- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index 780dc34ba..3bda5e577 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -128,6 +128,7 @@ struct feature_grammar : phoenix::function put_property_; phoenix::function extract_geometry_; + boost::phoenix::function where_message_; geometry_grammar geometry_grammar_; }; diff --git a/include/mapnik/json/geometry_grammar.hpp b/include/mapnik/json/geometry_grammar.hpp index 42e3fe92f..f21ad5e9b 100644 --- a/include/mapnik/json/geometry_grammar.hpp +++ b/include/mapnik/json/geometry_grammar.hpp @@ -73,6 +73,21 @@ struct cleanup } }; +struct where_message +{ + typedef std::string result_type; + + template + std::string operator() (Iterator first, Iterator last, std::size_t size) const + { + std::string str(first, last); + if (str.length() > size) + return str.substr(0, size) + "..." ; + return str; + } +}; + + template struct geometry_grammar : qi::grammar, void(boost::ptr_vector& ) @@ -107,6 +122,7 @@ struct geometry_grammar : boost::phoenix::function push_vertex_; boost::phoenix::function close_path_; boost::phoenix::function cleanup_; + boost::phoenix::function where_message_; }; }} diff --git a/src/json/feature_grammar.cpp b/src/json/feature_grammar.cpp index 0c517072a..f859ced4e 100644 --- a/src/json/feature_grammar.cpp +++ b/src/json/feature_grammar.cpp @@ -135,15 +135,18 @@ feature_grammar::feature_grammar(mapnik::transcoder const& attribute_value %= number | string_ ; + feature.name("Feature"); + properties.name("Properties"); + attributes.name("Attributes"); on_error ( feature , std::clog << phoenix::val("Error! Expecting ") - << _4 // what failed? + << _4 // what failed? << phoenix::val(" here: \"") - << construct(_3, _2) // iterators to error-pos, end + << where_message_(_3, _2, 16) // where? 16 is max chars to output << phoenix::val("\"") << std::endl ); diff --git a/src/json/geometry_grammar.cpp b/src/json/geometry_grammar.cpp index 4ea45350e..dba2589c4 100644 --- a/src/json/geometry_grammar.cpp +++ b/src/json/geometry_grammar.cpp @@ -146,15 +146,20 @@ geometry_grammar::geometry_grammar() // points points = lit('[')[_a = SEG_MOVETO] > -(point (_a,_r1) % lit(',')[_a = SEG_LINETO]) > lit(']'); + // give some rules names + geometry.name("Geometry"); + geometry_collection.name("GeometryCollection"); + geometry_dispatch.name("Geometry dispatch"); + coordinates.name("Coordinates"); // error handler on_error ( geometry , std::clog << boost::phoenix::val("Error! Expecting ") - << _4 // what failed? + << _4 // what failed? << boost::phoenix::val(" here: \"") - << construct(_3, _2) // iterators to error-pos, end + << where_message_(_3, _2, 16) // max 16 chars << boost::phoenix::val("\"") << std::endl ); From 4948fd8992ce3cddb83ae643ad6a1ecfdf9be3bb Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 14 May 2013 14:52:58 +0100 Subject: [PATCH 075/122] + add feature_parser.cpp --- src/build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/build.py b/src/build.py index 73d9d3b5e..abc3d5976 100644 --- a/src/build.py +++ b/src/build.py @@ -189,6 +189,7 @@ source = Split( json/geometry_grammar.cpp json/geometry_parser.cpp json/feature_grammar.cpp + json/feature_parser.cpp json/feature_collection_parser.cpp json/geojson_generator.cpp processed_text.cpp From 417ac21529df82f12d6681136b64a05b581f1b35 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 14 May 2013 14:53:27 +0100 Subject: [PATCH 076/122] + cleaup old comment --- src/json/feature_collection_parser.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/json/feature_collection_parser.cpp b/src/json/feature_collection_parser.cpp index 1daeba75c..77834bcef 100644 --- a/src/json/feature_collection_parser.cpp +++ b/src/json/feature_collection_parser.cpp @@ -20,7 +20,6 @@ * *****************************************************************************/ -// TODO https://github.com/mapnik/mapnik/issues/1658 #include #define BOOST_SPIRIT_USE_PHOENIX_V3 1 From 26302e19af9d0c3862dce8b4679c82ffa0235ff5 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 14 May 2013 14:53:52 +0100 Subject: [PATCH 077/122] + add from_geojson static method TODO: better handling of feature.id() and transcoder --- bindings/python/mapnik_feature.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index 196b30f03..e27152ae3 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -33,10 +33,12 @@ // mapnik #include +#include #include #include #include #include +#include #include namespace { @@ -62,6 +64,18 @@ void feature_add_geometries_from_wkt(Feature &feature, std::string wkt) if (!result) throw std::runtime_error("Failed to parse WKT"); } +mapnik::feature_ptr from_geojson_impl(std::string const& json, mapnik::context_ptr const& ctx) +{ + mapnik::transcoder tr("utf8"); + mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,1)); + mapnik::json::feature_parser parser(tr); + if (!parser.parse(json.begin(), json.end(), *feature)) + { + throw std::runtime_error("Failed to parse geojson feature"); + } + return feature; +} + std::string feature_to_geojson(Feature const& feature) { std::string json; @@ -231,5 +245,7 @@ void export_feature() .def("__len__", &Feature::size) .def("context",&Feature::context) .def("to_geojson",&feature_to_geojson) + .def("from_geojson",from_geojson_impl) + .staticmethod("from_geojson") ; } From 0e5013fb03abbfbef43a9605136af4850afa776f Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 14 May 2013 14:55:08 +0100 Subject: [PATCH 078/122] + add feature_parser implementation --- include/mapnik/json/feature_parser.hpp | 57 +++++++++++++++++++++++ src/json/feature_parser.cpp | 63 ++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 include/mapnik/json/feature_parser.hpp create mode 100644 src/json/feature_parser.cpp diff --git a/include/mapnik/json/feature_parser.hpp b/include/mapnik/json/feature_parser.hpp new file mode 100644 index 000000000..3e1a6d3aa --- /dev/null +++ b/include/mapnik/json/feature_parser.hpp @@ -0,0 +1,57 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2012 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_FEATURE_PARSER_HPP +#define MAPNIK_FEATURE_PARSER_HPP + +// mapnik +#include +#include +#include +#include + +// boost +#include + +// stl +#include + +namespace mapnik { namespace json { + +template struct feature_grammar; + +template +class feature_parser : private mapnik::noncopyable +{ + typedef Iterator iterator_type; + typedef mapnik::feature_impl feature_type; +public: + feature_parser(mapnik::transcoder const& tr); + ~feature_parser(); + bool parse(iterator_type first, iterator_type last, mapnik::feature_impl & f); +private: + boost::scoped_ptr > grammar_; +}; + +}} + +#endif //MAPNIK_FEATURE_PARSER_HPP diff --git a/src/json/feature_parser.cpp b/src/json/feature_parser.cpp new file mode 100644 index 000000000..688f0fe52 --- /dev/null +++ b/src/json/feature_parser.cpp @@ -0,0 +1,63 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2013 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#include + +#define BOOST_SPIRIT_USE_PHOENIX_V3 1 + +// mapnik +#include +#include + +// boost +#include +#include + +namespace mapnik { namespace json { + +#if BOOST_VERSION >= 104700 + + template + feature_parser::feature_parser(mapnik::transcoder const& tr) + : grammar_(new feature_grammar(tr)) {} + + template + feature_parser::~feature_parser() {} +#endif + + template + bool feature_parser::parse(iterator_type first, iterator_type last, mapnik::feature_impl & f) + { +#if BOOST_VERSION >= 104700 + using namespace boost::spirit; + return qi::phrase_parse(first, last, (*grammar_)(boost::phoenix::ref(f)), standard_wide::space); +#else + std::ostringstream s; + s << BOOST_VERSION/100000 << "." << BOOST_VERSION/100 % 1000 << "." << BOOST_VERSION % 100; + throw std::runtime_error("mapnik::feature_parser::parse() requires at least boost 1.47 while your build was compiled against boost " + s.str()); + return false; +#endif + } + +template class feature_parser; + +}} From 86aeee1ea1d7f80b849d542fb41096eaf12bd81d Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 15 May 2013 14:31:57 +0100 Subject: [PATCH 079/122] + remove an empty line at the begining --- plugins/input/postgis/postgis_featureset.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/input/postgis/postgis_featureset.hpp b/plugins/input/postgis/postgis_featureset.hpp index e4ead4ab6..69f1963f1 100644 --- a/plugins/input/postgis/postgis_featureset.hpp +++ b/plugins/input/postgis/postgis_featureset.hpp @@ -1,4 +1,3 @@ - /***************************************************************************** * * This file is part of Mapnik (c++ mapping toolkit) From 4dd1189ac86c816cc0d0358bfb79262edb5d43d5 Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 15 May 2013 14:32:52 +0100 Subject: [PATCH 080/122] + check if geometry record (WKB) is not Null before attempting to parse --- plugins/input/postgis/postgis_featureset.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/input/postgis/postgis_featureset.cpp b/plugins/input/postgis/postgis_featureset.cpp index 1303a268d..cc76b4cd1 100644 --- a/plugins/input/postgis/postgis_featureset.cpp +++ b/plugins/input/postgis/postgis_featureset.cpp @@ -117,14 +117,16 @@ feature_ptr postgis_featureset::next() ++feature_id_; } - // parse geometry + if (rs_->isNull(0)) + continue; + int size = rs_->getFieldLength(0); const char *data = rs_->getValue(0); - if (!geometry_utils::from_wkb(feature->paths(), data, size)) + // parse geometry + if (geometry_utils::from_wkb(feature->paths(), data, size)) continue; totalGeomSize_ += size; - unsigned num_attrs = ctx_->size() + 1; for (; pos < num_attrs; ++pos) { From c698079f5e92d377b8151b0ad32d019e735c209f Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 15 May 2013 15:07:17 +0100 Subject: [PATCH 081/122] + log Null geometry case ( via @TomH ) --- plugins/input/postgis/postgis_featureset.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/input/postgis/postgis_featureset.cpp b/plugins/input/postgis/postgis_featureset.cpp index cc76b4cd1..617938523 100644 --- a/plugins/input/postgis/postgis_featureset.cpp +++ b/plugins/input/postgis/postgis_featureset.cpp @@ -117,12 +117,17 @@ feature_ptr postgis_featureset::next() ++feature_id_; } + // null geometry is not acceptable if (rs_->isNull(0)) + { + MAPNIK_LOG_WARN(postgis) << "postgis_featureset: null value encountered for geometry"; continue; + } + // parse geometry int size = rs_->getFieldLength(0); const char *data = rs_->getValue(0); - // parse geometry + if (geometry_utils::from_wkb(feature->paths(), data, size)) continue; From 682b85b27dfa26f1088a45fdcd3cfa5dec305662 Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 15 May 2013 15:12:28 +0100 Subject: [PATCH 082/122] + fix accidental typo :) --- plugins/input/postgis/postgis_featureset.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/input/postgis/postgis_featureset.cpp b/plugins/input/postgis/postgis_featureset.cpp index 617938523..c9c336f22 100644 --- a/plugins/input/postgis/postgis_featureset.cpp +++ b/plugins/input/postgis/postgis_featureset.cpp @@ -128,7 +128,7 @@ feature_ptr postgis_featureset::next() int size = rs_->getFieldLength(0); const char *data = rs_->getValue(0); - if (geometry_utils::from_wkb(feature->paths(), data, size)) + if (!geometry_utils::from_wkb(feature->paths(), data, size)) continue; totalGeomSize_ += size; From d416d17ae96d024e53deb06d1403f83559d2b52f Mon Sep 17 00:00:00 2001 From: Hermann Kraus Date: Wed, 15 May 2013 11:31:32 +0300 Subject: [PATCH 083/122] Reenable Cairo and grid tests. --- tests/visual_tests/test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/visual_tests/test.py b/tests/visual_tests/test.py index 2eaf44a76..076f2d1ae 100755 --- a/tests/visual_tests/test.py +++ b/tests/visual_tests/test.py @@ -19,8 +19,8 @@ defaults = { 'sizes': [(500, 100)], 'scales':[1.0,2.0], 'agg': True, - 'cairo': False, - 'grid': False, + 'cairo': True, + 'grid': True, } sizes_many_in_big_range = [(800, 100), (600, 100), (400, 100), From eaef041c855fe907f7692e9db83d6ec7d10dfd72 Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 16 May 2013 16:24:18 +0100 Subject: [PATCH 084/122] + move to QT 5.x (requirement!) --- demo/viewer/main.cpp | 2 +- demo/viewer/mainwindow.cpp | 5 ++++- demo/viewer/mainwindow.hpp | 2 -- demo/viewer/mapwidget.cpp | 38 +------------------------------------- demo/viewer/viewer.pro | 2 ++ 5 files changed, 8 insertions(+), 41 deletions(-) diff --git a/demo/viewer/main.cpp b/demo/viewer/main.cpp index 73af0c95c..6d83c46a9 100644 --- a/demo/viewer/main.cpp +++ b/demo/viewer/main.cpp @@ -19,7 +19,7 @@ // qt -#include +#include #include #include #include diff --git a/demo/viewer/mainwindow.cpp b/demo/viewer/mainwindow.cpp index 996138678..e87e7a0d4 100644 --- a/demo/viewer/mainwindow.cpp +++ b/demo/viewer/mainwindow.cpp @@ -32,7 +32,10 @@ #include #include #include - +#include +#include +#include +#include // mapnik #ifndef Q_MOC_RUN // QT moc chokes on BOOST_JOIN diff --git a/demo/viewer/mainwindow.hpp b/demo/viewer/mainwindow.hpp index 99936da73..f5f01863f 100644 --- a/demo/viewer/mainwindow.hpp +++ b/demo/viewer/mainwindow.hpp @@ -22,7 +22,6 @@ #define MAINWINDOW_HPP #include -#include #include #include #include @@ -78,7 +77,6 @@ private: LayerTab *layerTab_; StyleTab * styleTab_; MapWidget * mapWidget_; - QPrinter printer; //actions QList exportAsActs; QActionGroup *toolsGroup; diff --git a/demo/viewer/mapwidget.cpp b/demo/viewer/mapwidget.cpp index 0b8753e44..93be08351 100644 --- a/demo/viewer/mapwidget.cpp +++ b/demo/viewer/mapwidget.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -528,42 +527,7 @@ void render_agg(mapnik::Map const& map, double scaling_factor, QPixmap & pix) void render_grid(mapnik::Map const& map, double scaling_factor, QPixmap & pix) { - unsigned width=map.width(); - unsigned height=map.height(); - - mapnik::grid buf(width,height,"F_CODE", 1); - mapnik::grid_renderer ren(map,buf,scaling_factor); - - try - { - ren.apply(); - mapnik::value_integer * imdata = static_cast(buf.raw_data()); - - // Not sure how to display long long values ?? - //QImage image(width,height,QImage::Format_RGB32); - //for (unsigned i = 0 ; i < height ; ++i) - //{ - // for (unsigned j = 0 ; j < width ; ++j) - // { - // image.setPixel(j,i,qRgb((uint8_t)(imdata[i*width+j]>>8), - // (uint8_t)(imdata[i*width+j+1]>>8), - // (uint8_t)(imdata[i*width+j+2]>>8))); - // } - //} - //pix = QPixmap::fromImage(image); - } - catch (mapnik::config_error & ex) - { - std::cerr << ex.what() << std::endl; - } - catch (const std::exception & ex) - { - std::cerr << "exception: " << ex.what() << std::endl; - } - catch (...) - { - std::cerr << "Unknown exception caught!\n"; - } + std::cerr << "Not supported" << std::endl; } diff --git a/demo/viewer/viewer.pro b/demo/viewer/viewer.pro index adf2a46be..a19bc9c95 100644 --- a/demo/viewer/viewer.pro +++ b/demo/viewer/viewer.pro @@ -2,8 +2,10 @@ # Mapnik viewer - Copyright (C) 2007 Artem Pavlenko ###################################################################### TEMPLATE = app +QT += core gui widgets QMAKE_CXX = clang++ QMAKE_CXXFLAGS += $$system(mapnik-config --cxxflags) +QMAKE_CXXFLAGS += $$system(mapnik-config --includes --dep-includes) QMAKE_LFLAGS += $$system(mapnik-config --libs) QMAKE_LFLAGS += $$system(mapnik-config --ldflags --dep-libs) QMAKE_LFLAGS += -lboost_timer From 293d4829a8af8b97acdce3aa1270fa484f053276 Mon Sep 17 00:00:00 2001 From: "artem@windows" Date: Fri, 17 May 2013 16:20:01 -0700 Subject: [PATCH 085/122] MAPNIK_DECL feature_parser --- include/mapnik/json/feature_parser.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/json/feature_parser.hpp b/include/mapnik/json/feature_parser.hpp index 3e1a6d3aa..e3c3ed8d6 100644 --- a/include/mapnik/json/feature_parser.hpp +++ b/include/mapnik/json/feature_parser.hpp @@ -40,7 +40,7 @@ namespace mapnik { namespace json { template struct feature_grammar; template -class feature_parser : private mapnik::noncopyable +class MAPNIK_DECL feature_parser : private mapnik::noncopyable { typedef Iterator iterator_type; typedef mapnik::feature_impl feature_type; From e57f5f9547e6382c970de94458cf42a788090c0f Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 20 May 2013 12:21:37 +0100 Subject: [PATCH 086/122] cherry picking.. --- bindings/python/mapnik_raster_symbolizer.cpp | 13 +-- bindings/python/python_optional.hpp | 101 ++++++++++++++++++- 2 files changed, 99 insertions(+), 15 deletions(-) diff --git a/bindings/python/mapnik_raster_symbolizer.cpp b/bindings/python/mapnik_raster_symbolizer.cpp index 54f66a554..20a04a3f3 100644 --- a/bindings/python/mapnik_raster_symbolizer.cpp +++ b/bindings/python/mapnik_raster_symbolizer.cpp @@ -28,18 +28,7 @@ #include #include -namespace { -// https://github.com/mapnik/mapnik/issues/1367 -PyObject* get_premultiplied_impl(mapnik::raster_symbolizer & sym) -{ - boost::optional premultiplied = sym.premultiplied(); - if (premultiplied) - return ::PyBool_FromLong(*premultiplied); - Py_RETURN_NONE; -} - -} using mapnik::raster_symbolizer; void export_raster_symbolizer() @@ -132,7 +121,7 @@ void export_raster_symbolizer() ">>> r.mesh_size = 32\n" ) .add_property("premultiplied", - &get_premultiplied_impl, + &raster_symbolizer::premultiplied, &raster_symbolizer::set_premultiplied, "Get/Set premultiplied status of the source image.\n" "Can be used to override what the source data reports (when in error)\n" diff --git a/bindings/python/python_optional.hpp b/bindings/python/python_optional.hpp index 0d785b0f3..3d9f4825d 100644 --- a/bindings/python/python_optional.hpp +++ b/bindings/python/python_optional.hpp @@ -100,10 +100,105 @@ struct python_optional : public boost::noncopyable } }; -/** This class works around a bug in boost python. +// to/from boost::optional +template <> +struct python_optional : public mapnik::noncopyable +{ + struct optional_to_python + { + static PyObject * convert(const boost::optional& value) + { + return (value ? PyFloat_FromDouble(*value) : + boost::python::detail::none()); + } + }; + + struct optional_from_python + { + static void * convertible(PyObject * source) + { + using namespace boost::python::converter; + + if (source == Py_None || PyFloat_Check(source)) + return source; + return 0; + } + + static void construct(PyObject * source, + boost::python::converter::rvalue_from_python_stage1_data * data) + { + using namespace boost::python::converter; + void * const storage = ((rvalue_from_python_storage > *) + data)->storage.bytes; + if (source == Py_None) // == None + new (storage) boost::optional(); // A Boost uninitialized value + else + new (storage) boost::optional(PyFloat_AsDouble(source)); + data->convertible = storage; + } + }; + + explicit python_optional() + { + register_python_conversion, + optional_to_python, optional_from_python>(); + } +}; + +// to/from boost::optional +template <> +struct python_optional : public mapnik::noncopyable +{ + struct optional_to_python + { + static PyObject * convert(const boost::optional& value) + { + if (value) + { + if (*value) Py_RETURN_TRUE; + else Py_RETURN_FALSE; + } + else return boost::python::detail::none(); + } + }; + struct optional_from_python + { + static void * convertible(PyObject * source) + { + using namespace boost::python::converter; + + if (source == Py_None || PyBool_Check(source)) + return source; + return 0; + } + + static void construct(PyObject * source, + boost::python::converter::rvalue_from_python_stage1_data * data) + { + using namespace boost::python::converter; + void * const storage = ((rvalue_from_python_storage > *) + data)->storage.bytes; + if (source == Py_None) // == None + new (storage) boost::optional(); // A Boost uninitialized value + else + { + new (storage) boost::optional(source == Py_True ? true : false); + } + data->convertible = storage; + } + }; + + explicit python_optional() + { + register_python_conversion, + optional_to_python, optional_from_python>(); + } +}; + + +// This class works around a feature in boost python. +// See http://osdir.com/ml/python.c++/2003-11/msg00158.html - See http://osdir.com/ml/python.c++/2003-11/msg00158.html -*/ template class class_with_converter : public boost::python::class_ { From 9348fffa8ddb4f3a8224c1b6bfe8f139680f9eb2 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 17 May 2013 16:22:04 +0100 Subject: [PATCH 087/122] + filter_at_point - cache inflated bbox --- include/mapnik/geom_util.hpp | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/include/mapnik/geom_util.hpp b/include/mapnik/geom_util.hpp index 36f030174..350c797ab 100644 --- a/include/mapnik/geom_util.hpp +++ b/include/mapnik/geom_util.hpp @@ -200,10 +200,10 @@ inline bool point_on_path(double x,double y,Iter start,Iter end, double tol) struct filter_in_box { box2d box_; - explicit filter_in_box(const box2d& box) + explicit filter_in_box(box2d const& box) : box_(box) {} - bool pass(const box2d& extent) const + bool pass(box2d const& extent) const { return extent.intersects(box_); } @@ -211,23 +211,16 @@ struct filter_in_box struct filter_at_point { - coord2d pt_; - double tol_; - explicit filter_at_point(const coord2d& pt, double tol=0) - : pt_(pt), - tol_(tol) {} - bool pass(const box2d& extent) const + box2d box_; + explicit filter_at_point(coord2d const& pt, double tol=0) + : box_(pt,pt) { - if (tol_ == 0) - { - return extent.contains(pt_); - } - else - { - box2d extent2 = extent; - extent2.pad(tol_); - return extent2.contains(pt_); - } + box_.pad(tol); + } + + bool pass(box2d const& extent) const + { + return extent.intersects(box_); } }; From f2132fa7bb8357d247af77f0c7c524cea58762e8 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 17 May 2013 16:24:32 +0100 Subject: [PATCH 088/122] + use tol in feature_at_point --- plugins/input/ogr/ogr_datasource.cpp | 4 ++-- plugins/input/ogr/ogr_index_featureset.cpp | 6 +++++- plugins/input/ogr/ogr_index_featureset.hpp | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp index b629d1e3d..8385598f4 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -82,7 +82,7 @@ void ogr_datasource::init(mapnik::parameters const& params) // initialize ogr formats OGRRegisterAll(); - + boost::optional file = params.get("file"); boost::optional string = params.get("string"); if (! file && ! string) @@ -525,7 +525,7 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) if (indexed_) { - filter_at_point filter(pt); + filter_at_point filter(pt, tol); return featureset_ptr(new ogr_index_featureset (ctx, *layer, diff --git a/plugins/input/ogr/ogr_index_featureset.cpp b/plugins/input/ogr/ogr_index_featureset.cpp index cf95c5899..1f6c62939 100644 --- a/plugins/input/ogr/ogr_index_featureset.cpp +++ b/plugins/input/ogr/ogr_index_featureset.cpp @@ -59,7 +59,8 @@ ogr_index_featureset::ogr_index_featureset(mapnik::context_ptr const & layerdef_(layer.GetLayerDefn()), filter_(filter), tr_(new transcoder(encoding)), - fidcolumn_(layer_.GetFIDColumn()) + fidcolumn_(layer_.GetFIDColumn()), + feature_envelope_() { boost::optional memory = mapnik::mapped_memory_cache::instance().find(index_file, true); @@ -104,6 +105,9 @@ feature_ptr ogr_index_featureset::next() OGRGeometry* geom=poFeature->GetGeometryRef(); if (geom && !geom->IsEmpty()) { + geom->getEnvelope(&feature_envelope_); + if (!filter_.pass(mapnik::box2d(feature_envelope_.MinX,feature_envelope_.MinY, + feature_envelope_.MaxX,feature_envelope_.MaxY))) continue; ogr_converter::convert_geometry (geom, feature); } else diff --git a/plugins/input/ogr/ogr_index_featureset.hpp b/plugins/input/ogr/ogr_index_featureset.hpp index 5e4c6cbc5..9972935e4 100644 --- a/plugins/input/ogr/ogr_index_featureset.hpp +++ b/plugins/input/ogr/ogr_index_featureset.hpp @@ -50,6 +50,7 @@ private: std::vector::iterator itr_; boost::scoped_ptr tr_; const char* fidcolumn_; + OGREnvelope feature_envelope_; }; #endif // OGR_INDEX_FEATURESET_HPP From ae2e33de340d295d8f3a49051a5a9b1954b8a19b Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 17 May 2013 13:16:36 -0700 Subject: [PATCH 089/122] msvc on windows breaks with singleton declared but gcc needs default visibility to avoid double singleton registration across dlls when using -fvisiblity=hidden Conflicts: include/mapnik/utils.hpp --- include/mapnik/utils.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/mapnik/utils.hpp b/include/mapnik/utils.hpp index f8e5426e6..36c1d1ed2 100644 --- a/include/mapnik/utils.hpp +++ b/include/mapnik/utils.hpp @@ -88,9 +88,23 @@ public: } }; +#ifdef __GNUC__ +template class CreatePolicy=CreateStatic> class MAPNIK_DECL singleton +{ +#else template class CreatePolicy=CreateStatic> class singleton { +#endif + +#ifdef __SUNPRO_CC + /* Sun's C++ compiler will issue the following errors if CreatePolicy is used: + Error: A class template name was expected instead of mapnik::CreatePolicy + Error: A "friend" declaration must specify a class or function. + */ + friend class CreatePolicy; +#else friend class CreatePolicy; static T* pInstance_; static bool destroyed_; From 7a119a5b9e5122cf2f148cfcbe66b10a9de4f258 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 20 May 2013 11:48:13 +0100 Subject: [PATCH 090/122] + mapnik_datasource parameters : handle unicode objects - convert to internal UTF8 representation --- bindings/python/mapnik_datasource.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bindings/python/mapnik_datasource.cpp b/bindings/python/mapnik_datasource.cpp index 95c495aec..07383b372 100644 --- a/bindings/python/mapnik_datasource.cpp +++ b/bindings/python/mapnik_datasource.cpp @@ -48,14 +48,26 @@ namespace { //user-friendly wrapper that uses Python dictionary using namespace boost::python; -boost::shared_ptr create_datasource(const dict& d) +boost::shared_ptr create_datasource(dict const& d) { mapnik::parameters params; boost::python::list keys=d.keys(); - for (int i=0; i(keys[i]); object obj = d[key]; + if (PyUnicode_Check(obj.ptr())) + { + PyObject* temp = PyUnicode_AsUTF8String(obj.ptr()); + if (temp) + { + char* c_str = PyString_AsString(temp); + params[key] = std::string(c_str); + Py_DecRef(temp); + } + continue; + } + extract ex0(obj); extract ex1(obj); extract ex2(obj); From 6e4169d2b98604a062191cda9d31d3844dcf0da7 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 20 May 2013 12:05:22 +0100 Subject: [PATCH 091/122] + utf8 to/from utf16 implementation Conflicts: include/mapnik/utils.hpp --- include/mapnik/utils.hpp | 147 +++++++++++++++++++++++---------------- 1 file changed, 88 insertions(+), 59 deletions(-) diff --git a/include/mapnik/utils.hpp b/include/mapnik/utils.hpp index 36c1d1ed2..239a9e722 100644 --- a/include/mapnik/utils.hpp +++ b/include/mapnik/utils.hpp @@ -29,6 +29,7 @@ #endif // stl +#include #include #include #include @@ -38,6 +39,7 @@ namespace mapnik { + #ifdef MAPNIK_THREADSAFE using boost::mutex; #endif @@ -89,81 +91,108 @@ public: }; #ifdef __GNUC__ -template class CreatePolicy=CreateStatic> class MAPNIK_DECL singleton -{ + template class CreatePolicy=CreateStatic> class MAPNIK_DECL singleton + { #else -template class CreatePolicy=CreateStatic> class singleton -{ + template class CreatePolicy=CreateStatic> class singleton + { #endif + friend class CreatePolicy; + static T* pInstance_; + static bool destroyed_; + singleton(const singleton &rhs); + singleton& operator=(const singleton&); -#ifdef __SUNPRO_CC - /* Sun's C++ compiler will issue the following errors if CreatePolicy is used: - Error: A class template name was expected instead of mapnik::CreatePolicy - Error: A "friend" declaration must specify a class or function. - */ - friend class CreatePolicy; -#else - friend class CreatePolicy; - static T* pInstance_; - static bool destroyed_; - singleton(const singleton &rhs); - singleton& operator=(const singleton&); - - static void onDeadReference() - { - throw std::runtime_error("dead reference!"); - } - - static void DestroySingleton() - { - CreatePolicy::destroy(pInstance_); - pInstance_ = 0; - destroyed_ = true; - } - -protected: -#ifdef MAPNIK_THREADSAFE - static mutex mutex_; -#endif - singleton() {} -public: - static T& instance() - { - if (! pInstance_) + static void onDeadReference() { + throw std::runtime_error("dead reference!"); + } + + static void DestroySingleton() + { + CreatePolicy::destroy(pInstance_); + pInstance_ = 0; + destroyed_ = true; + } + + protected: #ifdef MAPNIK_THREADSAFE - mutex::scoped_lock lock(mutex_); + static mutex mutex_; #endif + singleton() {} + public: + static T& instance() + { if (! pInstance_) { - if (destroyed_) +#ifdef MAPNIK_THREADSAFE + mutex::scoped_lock lock(mutex_); +#endif + if (! pInstance_) { - destroyed_ = false; - onDeadReference(); - } - else - { - pInstance_ = CreatePolicy::create(); + if (destroyed_) + { + destroyed_ = false; + onDeadReference(); + } + else + { + pInstance_ = CreatePolicy::create(); - // register destruction - std::atexit(&DestroySingleton); + // register destruction + std::atexit(&DestroySingleton); + } } } + return *pInstance_; } - return *pInstance_; - } -}; + }; #ifdef MAPNIK_THREADSAFE -template class CreatePolicy> mutex singleton::mutex_; + template class CreatePolicy> mutex singleton::mutex_; #endif -template class CreatePolicy> T* singleton::pInstance_=0; -template class CreatePolicy> bool singleton::destroyed_=false; + template class CreatePolicy> T* singleton::pInstance_=0; + template class CreatePolicy> bool singleton::destroyed_=false; + + +#ifdef _WINDOWS + +#include + + // UTF8 <--> UTF16 conversion routines + + std::string utf16_to_utf8(std::wstring const& wstr) + { + std::string str; + int size = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, 0, 0, 0, 0); + if(size > 0) + { + std::vector buffer(size); + WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &buffer[0], size, 0, 0); + str.assign(buffer.begin(), buffer.end() - 1); + } + return str; + } + + std::wstring utf8_to_utf16 (std::string const& str) + { + std::wstring wstr; + int size = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, 0, 0); + if (size > 0) + { + std::vector buffer(size); + MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &buffer[0], size); + wstr.assign(buffer.begin(), buffer.end() - 1); + } + return wstr; + } + +#endif // _WINDOWS } From fa9975715469d2f7210c132e534dc5063e492c09 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 20 May 2013 13:56:34 +0100 Subject: [PATCH 092/122] + add accidentally removed config.hpp --- include/mapnik/utils.hpp | 147 ++++++++++++++++++++------------------- 1 file changed, 76 insertions(+), 71 deletions(-) diff --git a/include/mapnik/utils.hpp b/include/mapnik/utils.hpp index 239a9e722..2a23e9214 100644 --- a/include/mapnik/utils.hpp +++ b/include/mapnik/utils.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_UTILS_HPP #define MAPNIK_UTILS_HPP +#include + // boost #ifdef MAPNIK_THREADSAFE #include @@ -91,106 +93,109 @@ public: }; #ifdef __GNUC__ - template class CreatePolicy=CreateStatic> class MAPNIK_DECL singleton - { +template class CreatePolicy=CreateStatic> class MAPNIK_DECL singleton +{ #else - template class CreatePolicy=CreateStatic> class singleton + + +template class CreatePolicy=CreateStatic> class singleton +{ +#endif + friend class CreatePolicy; + static T* pInstance_; + static bool destroyed_; + singleton(const singleton &rhs); + singleton& operator=(const singleton&); + + static void onDeadReference() { -#endif - friend class CreatePolicy; - static T* pInstance_; - static bool destroyed_; - singleton(const singleton &rhs); - singleton& operator=(const singleton&); + throw std::runtime_error("dead reference!"); + } - static void onDeadReference() - { - throw std::runtime_error("dead reference!"); - } + static void DestroySingleton() + { + CreatePolicy::destroy(pInstance_); + pInstance_ = 0; + destroyed_ = true; + } - static void DestroySingleton() - { - CreatePolicy::destroy(pInstance_); - pInstance_ = 0; - destroyed_ = true; - } - - protected: +protected: #ifdef MAPNIK_THREADSAFE - static mutex mutex_; + static mutex mutex_; #endif - singleton() {} - public: - static T& instance() + singleton() {} +public: + static T& instance() + { + if (! pInstance_) { +#ifdef MAPNIK_THREADSAFE + mutex::scoped_lock lock(mutex_); +#endif if (! pInstance_) { -#ifdef MAPNIK_THREADSAFE - mutex::scoped_lock lock(mutex_); -#endif - if (! pInstance_) + if (destroyed_) { - if (destroyed_) - { - destroyed_ = false; - onDeadReference(); - } - else - { - pInstance_ = CreatePolicy::create(); + destroyed_ = false; + onDeadReference(); + } + else + { + pInstance_ = CreatePolicy::create(); - // register destruction - std::atexit(&DestroySingleton); - } + // register destruction + std::atexit(&DestroySingleton); } } - return *pInstance_; } - }; + return *pInstance_; + } +}; + #ifdef MAPNIK_THREADSAFE - template class CreatePolicy> mutex singleton::mutex_; +template class CreatePolicy> mutex singleton::mutex_; #endif - template class CreatePolicy> T* singleton::pInstance_=0; - template class CreatePolicy> bool singleton::destroyed_=false; +template class CreatePolicy> T* singleton::pInstance_=0; +template class CreatePolicy> bool singleton::destroyed_=false; #ifdef _WINDOWS #include - // UTF8 <--> UTF16 conversion routines +// UTF8 <--> UTF16 conversion routines - std::string utf16_to_utf8(std::wstring const& wstr) +std::string utf16_to_utf8(std::wstring const& wstr) +{ + std::string str; + int size = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, 0, 0, 0, 0); + if(size > 0) { - std::string str; - int size = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, 0, 0, 0, 0); - if(size > 0) - { - std::vector buffer(size); - WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &buffer[0], size, 0, 0); - str.assign(buffer.begin(), buffer.end() - 1); - } - return str; + std::vector buffer(size); + WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &buffer[0], size, 0, 0); + str.assign(buffer.begin(), buffer.end() - 1); } + return str; +} - std::wstring utf8_to_utf16 (std::string const& str) +std::wstring utf8_to_utf16 (std::string const& str) +{ + std::wstring wstr; + int size = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, 0, 0); + if (size > 0) { - std::wstring wstr; - int size = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, 0, 0); - if (size > 0) - { - std::vector buffer(size); - MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &buffer[0], size); - wstr.assign(buffer.begin(), buffer.end() - 1); - } - return wstr; + std::vector buffer(size); + MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &buffer[0], size); + wstr.assign(buffer.begin(), buffer.end() - 1); } + return wstr; +} #endif // _WINDOWS From 35a8582043f32af3d54b5d004e71aa9633670d40 Mon Sep 17 00:00:00 2001 From: "artem@windows" Date: Mon, 20 May 2013 13:43:31 -0700 Subject: [PATCH 093/122] put implementatio into .cpp to avoid exposing --- include/mapnik/utils.hpp | 32 ++------------------- src/utils.cpp | 61 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 29 deletions(-) create mode 100644 src/utils.cpp diff --git a/include/mapnik/utils.hpp b/include/mapnik/utils.hpp index 2a23e9214..92dc4f12d 100644 --- a/include/mapnik/utils.hpp +++ b/include/mapnik/utils.hpp @@ -29,9 +29,8 @@ #ifdef MAPNIK_THREADSAFE #include #endif - + // stl -#include #include #include #include @@ -167,35 +166,10 @@ template - // UTF8 <--> UTF16 conversion routines -std::string utf16_to_utf8(std::wstring const& wstr) -{ - std::string str; - int size = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, 0, 0, 0, 0); - if(size > 0) - { - std::vector buffer(size); - WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &buffer[0], size, 0, 0); - str.assign(buffer.begin(), buffer.end() - 1); - } - return str; -} - -std::wstring utf8_to_utf16 (std::string const& str) -{ - std::wstring wstr; - int size = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, 0, 0); - if (size > 0) - { - std::vector buffer(size); - MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &buffer[0], size); - wstr.assign(buffer.begin(), buffer.end() - 1); - } - return wstr; -} +MAPNIK_DECL std::string utf16_to_utf8(std::wstring const& wstr); +MAPNIK_DECL std::wstring utf8_to_utf16(std::string const& str); #endif // _WINDOWS diff --git a/src/utils.cpp b/src/utils.cpp new file mode 100644 index 000000000..a10102889 --- /dev/null +++ b/src/utils.cpp @@ -0,0 +1,61 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2013 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifdef _WINDOWS +// windows specific methods for UTF8 from/to UTF16 +#include +#include +#include + +#include + +namespace mapnik { + +std::string utf16_to_utf8(std::wstring const& wstr) +{ + std::string str; + int size = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, 0, 0, 0, 0); + if(size > 0) + { + std::vector buffer(size); + WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &buffer[0], size, 0, 0); + str.assign(buffer.begin(), buffer.end() - 1); + } + return str; +} + +std::wstring utf8_to_utf16 (std::string const& str) +{ + std::wstring wstr; + int size = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, 0, 0); + if (size > 0) + { + std::vector buffer(size); + MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &buffer[0], size); + wstr.assign(buffer.begin(), buffer.end() - 1); + } + return wstr; +} + +} // namespace mapnik + +#endif // _WINDOWS From 154c93017acece13d6b451286db12d6a16135b71 Mon Sep 17 00:00:00 2001 From: "artem@windows" Date: Tue, 21 May 2013 09:42:55 -0700 Subject: [PATCH 094/122] * add support for unicode (utf16) paths on windows --- plugins/input/shape/dbfile.cpp | 2 ++ plugins/input/shape/shape_datasource.cpp | 17 ++++++++++++++--- plugins/input/shape/shapefile.hpp | 3 +++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/plugins/input/shape/dbfile.cpp b/plugins/input/shape/dbfile.cpp index 7902eb4ab..b6014da2e 100644 --- a/plugins/input/shape/dbfile.cpp +++ b/plugins/input/shape/dbfile.cpp @@ -50,6 +50,8 @@ dbf_file::dbf_file(std::string const& file_name) record_length_(0), #ifdef SHAPE_MEMORY_MAPPED_FILE file_(), +#elif defined(_WINDOWS) + file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary), #else file_(file_name.c_str() ,std::ios::in | std::ios::binary), #endif diff --git a/plugins/input/shape/shape_datasource.cpp b/plugins/input/shape/shape_datasource.cpp index a98121ec8..391d9cb8b 100644 --- a/plugins/input/shape/shape_datasource.cpp +++ b/plugins/input/shape/shape_datasource.cpp @@ -2,7 +2,7 @@ * * This file is part of Mapnik (c++ mapping toolkit) * - * Copyright (C) 2011 Artem Pavlenko + * Copyright (C) 2013 Artem Pavlenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -34,6 +34,7 @@ // mapnik #include #include +#include #include #include #include @@ -76,18 +77,28 @@ shape_datasource::shape_datasource(const parameters ¶ms) shape_name_ = *file; boost::algorithm::ireplace_last(shape_name_,".shp",""); - +#ifdef _WINDOWS + if (!boost::filesystem::exists(mapnik::utf8_to_utf16(shape_name_) + L".shp")) +#else if (!boost::filesystem::exists(shape_name_ + ".shp")) +#endif { throw datasource_exception("Shape Plugin: shapefile '" + shape_name_ + ".shp' does not exist"); } - +#ifdef _WINDOWS + if (boost::filesystem::is_directory(mapnik::utf8_to_utf16(shape_name_) + L".shp")) +#else if (boost::filesystem::is_directory(shape_name_ + ".shp")) +#endif { throw datasource_exception("Shape Plugin: shapefile '" + shape_name_ + ".shp' appears to be a directory not a file"); } +#ifdef _WINDOWS + if (!boost::filesystem::exists(mapnik::utf8_to_utf16(shape_name_) + L".dbf")) +#else if (!boost::filesystem::exists(shape_name_ + ".dbf")) +#endif { throw datasource_exception("Shape Plugin: shapefile '" + shape_name_ + ".dbf' does not exist"); } diff --git a/plugins/input/shape/shapefile.hpp b/plugins/input/shape/shapefile.hpp index c082b09d4..9df691119 100644 --- a/plugins/input/shape/shapefile.hpp +++ b/plugins/input/shape/shapefile.hpp @@ -29,6 +29,7 @@ // mapnik #include +#include #include #include #include @@ -149,6 +150,8 @@ public: shape_file(std::string const& file_name) : #ifdef SHAPE_MEMORY_MAPPED_FILE file_() +#elif defined (_WINDOWS) + file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary) #else file_(file_name.c_str(), std::ios::in | std::ios::binary) #endif From 386f6a5b243a8887cc806af13906c7bbbaeec82c Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 17 Jun 2013 10:47:53 +0100 Subject: [PATCH 095/122] + use auto --- include/mapnik/feature_style_processor_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index 39cfcfab4..9d74dc40d 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -166,7 +166,7 @@ void feature_style_processor::apply(double scale_denom) scale_denom = mapnik::scale_denominator(m_.scale(),proj.is_geographic()); scale_denom *= scale_factor_; - for ( layer const& lyr : m_.layers() ) + for (auto const& lyr : m_.layers() ) { if (lyr.visible(scale_denom)) { From 1de0a7eec18d3f740046157cf2cf19a6a7c13494 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 17 Jun 2013 10:48:15 +0100 Subject: [PATCH 096/122] + fix compilation (temp) --- demo/viewer/styles_model.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/viewer/styles_model.cpp b/demo/viewer/styles_model.cpp index 236e0808e..1555eabad 100644 --- a/demo/viewer/styles_model.cpp +++ b/demo/viewer/styles_model.cpp @@ -264,7 +264,7 @@ public: { mapnik::expression_ptr filter = rule_.get_filter(); - return QString(mapnik::to_expression_string(*filter).c_str()); + return QString("FIXME");//mapnik::to_expression_string((*filter)).c_str()); } QIcon icon() const From 4a2f59d9d1df8de37999735e5af8cbab86c73d50 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 30 Aug 2013 09:49:44 +0100 Subject: [PATCH 097/122] + replace auto_ptr with unique_ptr --- tests/cpp_tests/image_io_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cpp_tests/image_io_test.cpp b/tests/cpp_tests/image_io_test.cpp index e41eebf8b..592b1a28c 100644 --- a/tests/cpp_tests/image_io_test.cpp +++ b/tests/cpp_tests/image_io_test.cpp @@ -75,8 +75,8 @@ int main(int argc, char** argv) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); - if (reader.get()) BOOST_TEST( false ); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); + BOOST_TEST( false ); } catch (std::exception const&) { From d4b9a48cb15aeec0f5e538bbe796f9c56f4c55a9 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 3 Sep 2013 12:15:31 +0100 Subject: [PATCH 098/122] + geometry::types Exterior/Interior polygon loops --- bindings/python/mapnik_geometry.cpp | 8 ++-- include/mapnik/geometry.hpp | 37 +++++++++++------- include/mapnik/grid/grid_marker_helpers.hpp | 9 ++--- .../json/geometry_generator_grammar.hpp | 18 ++++----- include/mapnik/marker_helpers.hpp | 10 ++--- include/mapnik/symbolizer_hash.hpp | 4 +- .../mapnik/util/geometry_svg_generator.hpp | 6 +-- include/mapnik/util/geometry_to_wkb.hpp | 12 +++--- include/mapnik/vertex_vector.hpp | 16 ++++---- include/mapnik/wkt/wkt_grammar.hpp | 12 +++--- plugins/input/csv/csv_datasource.cpp | 2 +- plugins/input/gdal/gdal_featureset.cpp | 2 +- plugins/input/occi/occi_featureset.cpp | 4 +- plugins/input/occi/occi_featureset.hpp | 2 +- plugins/input/ogr/ogr_converter.cpp | 6 +-- plugins/input/osm/osm_featureset.cpp | 6 +-- plugins/input/shape/shape_featureset.cpp | 4 +- .../input/shape/shape_index_featureset.cpp | 4 +- plugins/input/shape/shape_io.cpp | 6 +-- src/agg/process_building_symbolizer.cpp | 6 +-- src/agg/process_markers_symbolizer.cpp | 16 ++++---- src/cairo_renderer.cpp | 38 +++++++++---------- src/grid/process_building_symbolizer.cpp | 6 +-- src/grid/process_markers_symbolizer.cpp | 12 +++--- src/json/geometry_grammar.cpp | 6 +-- src/symbolizer_helpers.cpp | 6 +-- src/wkb.cpp | 12 +++--- src/wkt/wkt_generator.cpp | 12 +++--- tests/cpp_tests/fontset_runtime_test.cpp | 2 +- tests/cpp_tests/geometry_converters_test.cpp | 8 ++-- tests/cpp_tests/label_algo_test.cpp | 4 +- 31 files changed, 152 insertions(+), 144 deletions(-) diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index c7c1d5462..9b7c3fb14 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -270,10 +270,10 @@ void export_geometry() { using namespace boost::python; - enum_("GeometryType") - .value("Point",mapnik::Point) - .value("LineString",mapnik::LineString) - .value("Polygon",mapnik::Polygon) + enum_("GeometryType") + .value("Point",mapnik::geometry_type::types::Point) + .value("LineString",mapnik::geometry_type::types::LineString) + .value("Polygon",mapnik::geometry_type::types::Polygon) ; #if BOOST_VERSION >= 104700 diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index c3f616f5f..1db96e0c6 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -34,25 +34,29 @@ namespace mapnik { -enum eGeomType { - Unknown = 0, - Point = 1, - LineString = 2, - Polygon = 3 -}; - template class Container=vertex_vector> class geometry : private mapnik::noncopyable { + public: + static const std::uint8_t geometry_bits = 7; + enum types : std::uint8_t + { + Unknown = 0x00, + Point = 0x01, + LineString = 0x02, + Polygon = 0x03, + PolygonExterior = Polygon, + PolygonInterior = Polygon | ( 1 << geometry_bits) + }; typedef T coord_type; typedef Container container_type; typedef typename container_type::value_type value_type; typedef typename container_type::size_type size_type; private: container_type cont_; - eGeomType type_; - mutable unsigned itr_; + types type_; + mutable size_type itr_; public: geometry() @@ -60,17 +64,22 @@ public: itr_(0) {} - explicit geometry(eGeomType type) + explicit geometry(types type) : type_(type), itr_(0) {} - eGeomType type() const + types type() const { - return type_; + return static_cast(type_ & types::Polygon); } - void set_type(eGeomType type) + bool interior() const + { + return static_cast(type_ >> geometry_bits); + } + + void set_type(types type) { type_ = type; } @@ -91,7 +100,7 @@ public: double x = 0; double y = 0; rewind(0); - for (unsigned i=0; i < size(); ++i) + for (size_type i = 0; i < size(); ++i) { unsigned cmd = vertex(&x,&y); if (cmd == SEG_CLOSE) continue; diff --git a/include/mapnik/grid/grid_marker_helpers.hpp b/include/mapnik/grid/grid_marker_helpers.hpp index 5acb73a5d..0d1b0bb2e 100644 --- a/include/mapnik/grid/grid_marker_helpers.hpp +++ b/include/mapnik/grid/grid_marker_helpers.hpp @@ -79,11 +79,11 @@ struct raster_markers_rasterizer_dispatch_grid marker_placement_e placement_method = sym_.get_marker_placement(); box2d bbox_(0,0, src_.width(),src_.height()); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -216,11 +216,11 @@ struct vector_markers_rasterizer_dispatch_grid { marker_placement_e placement_method = sym_.get_marker_placement(); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -294,4 +294,3 @@ private: } #endif - diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index 63d3a1f9e..407d8ff76 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -202,17 +202,17 @@ struct geometry_generator_grammar : coordinates = point | linestring | polygon ; - point = &uint_(mapnik::Point)[_1 = _type(_val)] + point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)] << point_coord [_1 = _first(_val)] ; - linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] + linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)] << lit('[') << coords << lit(']') ; - polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)] + polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)] << lit('[') << coords2 << lit("]]") @@ -280,12 +280,12 @@ struct multi_geometry_generator_grammar : using boost::spirit::karma::string; geometry_types.add - (mapnik::Point,"\"Point\"") - (mapnik::LineString,"\"LineString\"") - (mapnik::Polygon,"\"Polygon\"") - (mapnik::Point + 3,"\"MultiPoint\"") - (mapnik::LineString + 3,"\"MultiLineString\"") - (mapnik::Polygon + 3,"\"MultiPolygon\"") + (mapnik::geometry_type::types::Point,"\"Point\"") + (mapnik::geometry_type::types::LineString,"\"LineString\"") + (mapnik::geometry_type::types::Polygon,"\"Polygon\"") + (mapnik::geometry_type::types::Point + 3,"\"MultiPoint\"") + (mapnik::geometry_type::types::LineString + 3,"\"MultiLineString\"") + (mapnik::geometry_type::types::Polygon + 3,"\"MultiPolygon\"") ; start %= ( eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)] diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index 44e33e6e4..008386552 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -94,11 +94,11 @@ struct vector_markers_rasterizer_dispatch marker_placement_e placement_method = sym_.get_marker_placement(); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == mapnik::geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == mapnik::geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -206,11 +206,11 @@ struct raster_markers_rasterizer_dispatch box2d bbox_(0,0, src_.width(),src_.height()); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == mapnik::geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == mapnik::geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -477,7 +477,7 @@ void apply_markers_multi(feature_impl & feature, Converter& converter, markers_s double x, y; if (label::centroid_geoms(feature.paths().begin(), feature.paths().end(), x, y)) { - geometry_type pt(Point); + geometry_type pt(geometry_type::types::Point); pt.move_to(x, y); // unset any clipping since we're now dealing with a point converter.template unset(); diff --git a/include/mapnik/symbolizer_hash.hpp b/include/mapnik/symbolizer_hash.hpp index db89ff8a9..2b34f4b44 100644 --- a/include/mapnik/symbolizer_hash.hpp +++ b/include/mapnik/symbolizer_hash.hpp @@ -41,7 +41,7 @@ struct symbolizer_hash // specialisation for polygon_symbolizer static std::size_t value(polygon_symbolizer const& sym) { - std::size_t seed = Polygon; + std::size_t seed = geometry_type::types::Polygon; boost::hash_combine(seed, sym.get_fill().rgba()); boost::hash_combine(seed, sym.get_opacity()); return seed; @@ -50,7 +50,7 @@ struct symbolizer_hash // specialisation for line_symbolizer static std::size_t value(line_symbolizer const& sym) { - std::size_t seed = LineString; + std::size_t seed = geometry_type::types::LineString; boost::hash_combine(seed, sym.get_stroke().get_color().rgba()); boost::hash_combine(seed, sym.get_stroke().get_width()); boost::hash_combine(seed, sym.get_stroke().get_opacity()); diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index 1ffff0d8b..e6db2f80a 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -171,7 +171,7 @@ namespace mapnik { namespace util { svg = point | linestring | polygon ; - point = &uint_(mapnik::Point)[_1 = _type(_val)] + point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)] << svg_point [_1 = _first(_val)] ; @@ -181,11 +181,11 @@ namespace mapnik { namespace util { << lit('\"') ; - linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] + linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)] << lit("d=\"") << svg_path << lit("\"") ; - polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)] + polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)] << lit("d=\"") << svg_path << lit("\"") ; diff --git a/include/mapnik/util/geometry_to_wkb.hpp b/include/mapnik/util/geometry_to_wkb.hpp index f3a0ac5e8..6aaeb629a 100644 --- a/include/mapnik/util/geometry_to_wkb.hpp +++ b/include/mapnik/util/geometry_to_wkb.hpp @@ -143,7 +143,7 @@ wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order) wkb_buffer_ptr wkb(new wkb_buffer(size)); wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); - int type = static_cast(mapnik::Point); + int type = static_cast(mapnik::geometry_type::types::Point); write(ss,type,4,byte_order); double x = 0; double y = 0; @@ -163,7 +163,7 @@ wkb_buffer_ptr to_line_string_wkb( GeometryType const& g, wkbByteOrder byte_orde wkb_buffer_ptr wkb(new wkb_buffer(size)); wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); - int type = static_cast(mapnik::LineString); + int type = static_cast(mapnik::geometry_type::types::LineString); write(ss,type,4,byte_order); write(ss,num_points,4,byte_order); double x = 0; @@ -211,7 +211,7 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) wkb_buffer_ptr wkb(new wkb_buffer(size)); wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); - int type = static_cast(mapnik::Polygon); + int type = static_cast(mapnik::geometry_type::types::Polygon); write(ss,type,4,byte_order); write(ss,num_rings,4,byte_order); @@ -237,13 +237,13 @@ wkb_buffer_ptr to_wkb(GeometryType const& g, wkbByteOrder byte_order ) switch (g.type()) { - case mapnik::Point: + case mapnik::geometry_type::types::Point: wkb = to_point_wkb(g, byte_order); break; - case mapnik::LineString: + case mapnik::geometry_type::types::LineString: wkb = to_line_string_wkb(g, byte_order); break; - case mapnik::Polygon: + case mapnik::geometry_type::types::Polygon: wkb = to_polygon_wkb(g, byte_order); break; default: diff --git a/include/mapnik/vertex_vector.hpp b/include/mapnik/vertex_vector.hpp index 44fbd7884..82b878f7a 100644 --- a/include/mapnik/vertex_vector.hpp +++ b/include/mapnik/vertex_vector.hpp @@ -55,12 +55,12 @@ public: // required for iterators support typedef boost::tuple value_type; typedef std::size_t size_type; - + typedef std::uint8_t command_size; private: unsigned num_blocks_; unsigned max_blocks_; coord_type** vertices_; - unsigned char** commands_; + command_size** commands_; size_type pos_; public: @@ -90,7 +90,7 @@ public: return pos_; } - void push_back (coord_type x,coord_type y,unsigned command) + void push_back (coord_type x,coord_type y,command_size command) { unsigned block = pos_ >> block_shift; if (block >= num_blocks_) @@ -98,9 +98,9 @@ public: allocate_block(block); } coord_type* vertex = vertices_[block] + ((pos_ & block_mask) << 1); - unsigned char* cmd= commands_[block] + (pos_ & block_mask); + command_size* cmd= commands_[block] + (pos_ & block_mask); - *cmd = static_cast(command); + *cmd = static_cast(command); *vertex++ = x; *vertex = y; ++pos_; @@ -130,11 +130,11 @@ private: { coord_type** new_vertices = static_cast(::operator new (sizeof(coord_type*)*((max_blocks_ + grow_by) * 2))); - unsigned char** new_commands = (unsigned char**)(new_vertices + max_blocks_ + grow_by); + command_size** new_commands = (command_size**)(new_vertices + max_blocks_ + grow_by); if (vertices_) { std::memcpy(new_vertices,vertices_,max_blocks_ * sizeof(coord_type*)); - std::memcpy(new_commands,commands_,max_blocks_ * sizeof(unsigned char*)); + std::memcpy(new_commands,commands_,max_blocks_ * sizeof(command_size*)); ::operator delete(vertices_); } vertices_ = new_vertices; @@ -144,7 +144,7 @@ private: vertices_[block] = static_cast (::operator new(sizeof(coord_type)*(block_size * 2 + block_size / (sizeof(coord_type))))); - commands_[block] = (unsigned char*)(vertices_[block] + block_size*2); + commands_[block] = (command_size*)(vertices_[block] + block_size*2); ++num_blocks_; } }; diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index b657cb90e..47e7e8e84 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -97,7 +97,7 @@ struct wkt_grammar : qi::grammar ::= point - point_tagged_text = no_case[lit("POINT")] [ _a = new_(Point) ] + point_tagged_text = no_case[lit("POINT")] [ _a = new_(geometry_type::types::Point) ] >> ( point_text(_a) [push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false]) ; @@ -108,7 +108,7 @@ struct wkt_grammar : qi::grammar ::= linestring - linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(LineString) ] + linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(geometry_type::types::LineString) ] >> (linestring_text(_a)[push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false]) ; @@ -118,7 +118,7 @@ struct wkt_grammar : qi::grammar ::= polygon - polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(Polygon) ] + polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(geometry_type::types::Polygon) ] >> ( polygon_text(_a)[push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false]) ; @@ -134,7 +134,7 @@ struct wkt_grammar : qi::grammar ::= | { }* multipoint_text = (lit('(') - >> ((eps[_a = new_(Point)] + >> ((eps[_a = new_(geometry_type::types::Point)] >> (point_text(_a) | empty_set) [push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false]) % lit(',')) >> lit(')')) | empty_set @@ -146,7 +146,7 @@ struct wkt_grammar : qi::grammar ::= | { }* multilinestring_text = (lit('(') - >> ((eps[_a = new_(LineString)] + >> ((eps[_a = new_(geometry_type::types::LineString)] >> ( points(_a)[push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false])) % lit(',')) @@ -159,7 +159,7 @@ struct wkt_grammar : qi::grammar ::= | { }* multipolygon_text = (lit('(') - >> ((eps[_a = new_(Polygon)] + >> ((eps[_a = new_(geometry_type::types::Polygon)] >> ( polygon_text(_a)[push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false])) % lit(',')) diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index e1478cd36..db6521115 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -773,7 +773,7 @@ void csv_datasource::parse_csv(T & stream, { if (parsed_x && parsed_y) { - mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point); + mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::geometry_type::types::Point); pt->move_to(x,y); feature->add_geometry(pt); features_.push_back(feature); diff --git a/plugins/input/gdal/gdal_featureset.cpp b/plugins/input/gdal/gdal_featureset.cpp index b87555add..f0804fcbd 100644 --- a/plugins/input/gdal/gdal_featureset.cpp +++ b/plugins/input/gdal/gdal_featureset.cpp @@ -523,7 +523,7 @@ feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt) { // construct feature feature_ptr feature = feature_factory::create(ctx_,1); - geometry_type * point = new geometry_type(mapnik::Point); + geometry_type * point = new geometry_type(mapnik::geometry_type::types::Point); point->move_to(pt.x, pt.y); feature->add_geometry(point); feature->put("value",value); diff --git a/plugins/input/occi/occi_featureset.cpp b/plugins/input/occi/occi_featureset.cpp index fe0455742..1cb0cf4cc 100644 --- a/plugins/input/occi/occi_featureset.cpp +++ b/plugins/input/occi/occi_featureset.cpp @@ -377,7 +377,7 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature) } void occi_featureset::convert_ordinates(mapnik::feature_ptr feature, - const mapnik::eGeomType& geom_type, + const mapnik::geometry::types& geom_type, const std::vector& elem_info, const std::vector& ordinates, const int dimensions, @@ -404,7 +404,7 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature, int next_interp = elem_info[i + 2]; bool is_linear_element = true; bool is_unknown_etype = false; - mapnik::eGeomType gtype = mapnik::Point; + mapnik::geometry::types gtype = mapnik::Point; switch (etype) { diff --git a/plugins/input/occi/occi_featureset.hpp b/plugins/input/occi/occi_featureset.hpp index cb4e7cb9e..e81e24071 100644 --- a/plugins/input/occi/occi_featureset.hpp +++ b/plugins/input/occi/occi_featureset.hpp @@ -55,7 +55,7 @@ public: private: void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature); void convert_ordinates (mapnik::feature_ptr feature, - const mapnik::eGeomType& geom_type, + const mapnik::geometry::types& geom_type, const std::vector& elem_info, const std::vector& ordinates, const int dimensions, diff --git a/plugins/input/ogr/ogr_converter.cpp b/plugins/input/ogr/ogr_converter.cpp index cce0336e5..19beeae1d 100644 --- a/plugins/input/ogr/ogr_converter.cpp +++ b/plugins/input/ogr/ogr_converter.cpp @@ -79,7 +79,7 @@ void ogr_converter::convert_geometry(OGRGeometry* geom, feature_ptr feature) void ogr_converter::convert_point(OGRPoint* geom, feature_ptr feature) { - std::unique_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(geom->getX(), geom->getY()); feature->paths().push_back(point.release()); } @@ -87,7 +87,7 @@ void ogr_converter::convert_point(OGRPoint* geom, feature_ptr feature) void ogr_converter::convert_linestring(OGRLineString* geom, feature_ptr feature) { int num_points = geom->getNumPoints(); - std::unique_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::geometry_type::types::LineString)); line->move_to(geom->getX(0), geom->getY(0)); for (int i = 1; i < num_points; ++i) { @@ -108,7 +108,7 @@ void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature) capacity += interior->getNumPoints(); } - std::unique_ptr poly(new geometry_type(mapnik::Polygon)); + std::unique_ptr poly(new geometry_type(mapnik::geometry_type::types::Polygon)); poly->move_to(exterior->getX(0), exterior->getY(0)); for (int i = 1; i < num_points; ++i) diff --git a/plugins/input/osm/osm_featureset.cpp b/plugins/input/osm/osm_featureset.cpp index e72c597ff..db0f62255 100644 --- a/plugins/input/osm/osm_featureset.cpp +++ b/plugins/input/osm/osm_featureset.cpp @@ -65,7 +65,7 @@ feature_ptr osm_featureset::next() feature = feature_factory::create(ctx_, cur_item->id); double lat = static_cast(cur_item)->lat; double lon = static_cast(cur_item)->lon; - geometry_type* point = new geometry_type(mapnik::Point); + geometry_type* point = new geometry_type(mapnik::geometry_type::types::Point); point->move_to(lon, lat); feature->add_geometry(point); } @@ -86,11 +86,11 @@ feature_ptr osm_featureset::next() geometry_type* geom; if (static_cast(cur_item)->is_polygon()) { - geom = new geometry_type(mapnik::Polygon); + geom = new geometry_type(mapnik::geometry_type::types::Polygon); } else { - geom = new geometry_type(mapnik::LineString); + geom = new geometry_type(mapnik::geometry_type::types::LineString); } geom->move_to(static_cast(cur_item)->nodes[0]->lon, diff --git a/plugins/input/shape/shape_featureset.cpp b/plugins/input/shape/shape_featureset.cpp index 01176bc48..cce768704 100644 --- a/plugins/input/shape/shape_featureset.cpp +++ b/plugins/input/shape/shape_featureset.cpp @@ -89,7 +89,7 @@ feature_ptr shape_featureset::next() double y = record.read_double(); if (!filter_.pass(mapnik::box2d(x,y,x,y))) continue; - std::unique_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(x, y); feature->paths().push_back(point.release()); break; @@ -105,7 +105,7 @@ feature_ptr shape_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::unique_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(x, y); feature->paths().push_back(point.release()); } diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index aab9b188c..c896b9208 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -101,7 +101,7 @@ feature_ptr shape_index_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::unique_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(x, y); feature->paths().push_back(point.release()); break; @@ -117,7 +117,7 @@ feature_ptr shape_index_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::unique_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(x, y); feature->paths().push_back(point.release()); } diff --git a/plugins/input/shape/shape_io.cpp b/plugins/input/shape/shape_io.cpp index 858e54ef3..cceb7198e 100644 --- a/plugins/input/shape/shape_io.cpp +++ b/plugins/input/shape/shape_io.cpp @@ -96,7 +96,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry int num_points = record.read_ndr_integer(); if (num_parts == 1) { - std::unique_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::geometry_type::types::LineString)); record.skip(4); double x = record.read_double(); double y = record.read_double(); @@ -120,7 +120,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry int start, end; for (int k = 0; k < num_parts; ++k) { - std::unique_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::geometry_type::types::LineString)); start = parts[k]; if (k == num_parts - 1) { @@ -159,7 +159,7 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c for (int k = 0; k < num_parts; ++k) { - std::unique_ptr poly(new geometry_type(mapnik::Polygon)); + std::unique_ptr poly(new geometry_type(mapnik::geometry_type::types::Polygon)); int start = parts[k]; int end; if (k == num_parts - 1) diff --git a/src/agg/process_building_symbolizer.cpp b/src/agg/process_building_symbolizer.cpp index d4d7dae05..65f1e6b79 100644 --- a/src/agg/process_building_symbolizer.cpp +++ b/src/agg/process_building_symbolizer.cpp @@ -91,8 +91,8 @@ void agg_renderer::process(building_symbolizer const& sym, geometry_type const& geom = feature.get_geometry(i); if (geom.size() > 2) { - boost::scoped_ptr frame(new geometry_type(LineString)); - boost::scoped_ptr roof(new geometry_type(Polygon)); + boost::scoped_ptr frame(new geometry_type(geometry_type::types::LineString)); + boost::scoped_ptr roof(new geometry_type(geometry_type::types::Polygon)); std::deque face_segments; double x0 = 0; double y0 = 0; @@ -124,7 +124,7 @@ void agg_renderer::process(building_symbolizer const& sym, for (; itr!=end; ++itr) { - boost::scoped_ptr faces(new geometry_type(Polygon)); + boost::scoped_ptr faces(new geometry_type(geometry_type::types::Polygon)); faces->move_to(itr->get<0>(),itr->get<1>()); faces->line_to(itr->get<2>(),itr->get<3>()); faces->line_to(itr->get<2>(),itr->get<3>() + height); diff --git a/src/agg/process_markers_symbolizer.cpp b/src/agg/process_markers_symbolizer.cpp index 2e8b5469d..33e207413 100644 --- a/src/agg/process_markers_symbolizer.cpp +++ b/src/agg/process_markers_symbolizer.cpp @@ -142,8 +142,8 @@ void agg_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) @@ -182,8 +182,8 @@ void agg_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) @@ -220,13 +220,13 @@ void agg_renderer::process(markers_symbolizer const& sym, if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 - //else if (type == LineString) + //else if (type == geometry_type::types::LineString) // converter.template set(); - // don't clip if type==Point + // don't clip if type==geometry_type::types::Point } converter.template set(); //always transform if (sym.smooth() > 0.0) converter.template set(); // optional smooth converter diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 4da8ef52c..d74977285 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -360,8 +360,8 @@ void cairo_renderer_base::process(building_symbolizer const& sym, if (geom.size() > 2) { - boost::scoped_ptr frame(new geometry_type(LineString)); - boost::scoped_ptr roof(new geometry_type(Polygon)); + boost::scoped_ptr frame(new geometry_type(geometry_type::types::LineString)); + boost::scoped_ptr roof(new geometry_type(geometry_type::types::Polygon)); std::deque face_segments; double x0 = 0; double y0 = 0; @@ -392,7 +392,7 @@ void cairo_renderer_base::process(building_symbolizer const& sym, std::deque::const_iterator end=face_segments.end(); for (; itr != end; ++itr) { - boost::scoped_ptr faces(new geometry_type(Polygon)); + boost::scoped_ptr faces(new geometry_type(geometry_type::types::Polygon)); faces->move_to(itr->get<0>(), itr->get<1>()); faces->line_to(itr->get<2>(), itr->get<3>()); faces->line_to(itr->get<2>(), itr->get<3>() + height); @@ -987,11 +987,11 @@ struct markers_dispatch marker_placement_e placement_method = sym_.get_marker_placement(); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -1076,11 +1076,11 @@ struct markers_dispatch_2 marker_placement_e placement_method = sym_.get_marker_placement(); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -1200,13 +1200,13 @@ void cairo_renderer_base::process(markers_symbolizer const& sym, if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 - //else if (type == LineString) + //else if (type == geometry_type::types::LineString) // converter.template set(); - // don't clip if type==Point + // don't clip if type==geometry_type::types::Point } converter.set(); //always transform if (sym.smooth() > 0.0) converter.set(); // optional smooth converter @@ -1225,13 +1225,13 @@ void cairo_renderer_base::process(markers_symbolizer const& sym, if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 - //else if (type == LineString) + //else if (type == geometry_type::types::LineString) // converter.template set(); - // don't clip if type==Point + // don't clip if type==geometry_type::types::Point } converter.set(); //always transform if (sym.smooth() > 0.0) converter.set(); // optional smooth converter @@ -1255,13 +1255,13 @@ void cairo_renderer_base::process(markers_symbolizer const& sym, if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 - //else if (type == LineString) + //else if (type == geometry_type::types::LineString) // converter.template set(); - // don't clip if type==Point + // don't clip if type==geometry_type::types::Point } converter.set(); //always transform if (sym.smooth() > 0.0) converter.set(); // optional smooth converter diff --git a/src/grid/process_building_symbolizer.cpp b/src/grid/process_building_symbolizer.cpp index 5e089d272..941917fda 100644 --- a/src/grid/process_building_symbolizer.cpp +++ b/src/grid/process_building_symbolizer.cpp @@ -78,8 +78,8 @@ void grid_renderer::process(building_symbolizer const& sym, geometry_type & geom = feature.get_geometry(i); if (geom.size() > 2) { - boost::scoped_ptr frame(new geometry_type(LineString)); - boost::scoped_ptr roof(new geometry_type(Polygon)); + boost::scoped_ptr frame(new geometry_type(geometry_type::types::LineString)); + boost::scoped_ptr roof(new geometry_type(geometry_type::types::Polygon)); std::deque face_segments; double x0(0); double y0(0); @@ -106,7 +106,7 @@ void grid_renderer::process(building_symbolizer const& sym, std::deque::const_iterator itr=face_segments.begin(); for (;itr!=face_segments.end();++itr) { - boost::scoped_ptr faces(new geometry_type(Polygon)); + boost::scoped_ptr faces(new geometry_type(geometry_type::types::Polygon)); faces->move_to(itr->get<0>(),itr->get<1>()); faces->line_to(itr->get<2>(),itr->get<3>()); faces->line_to(itr->get<2>(),itr->get<3>() + height); diff --git a/src/grid/process_markers_symbolizer.cpp b/src/grid/process_markers_symbolizer.cpp index 81180f481..1f274f10c 100644 --- a/src/grid/process_markers_symbolizer.cpp +++ b/src/grid/process_markers_symbolizer.cpp @@ -150,8 +150,8 @@ void grid_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) @@ -192,8 +192,8 @@ void grid_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) @@ -237,8 +237,8 @@ void grid_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) diff --git a/src/json/geometry_grammar.cpp b/src/json/geometry_grammar.cpp index dba2589c4..70172f7c2 100644 --- a/src/json/geometry_grammar.cpp +++ b/src/json/geometry_grammar.cpp @@ -107,16 +107,16 @@ geometry_grammar::geometry_grammar() | (eps(_r2 == 6) > multipolygon_coordinates(_r1)) ; - point_coordinates = eps[ _a = new_(Point) ] + point_coordinates = eps[ _a = new_(geometry_type::types::Point) ] > ( point(SEG_MOVETO,_a) [push_back(_r1,_a)] | eps[cleanup_(_a)][_pass = false] ) ; - linestring_coordinates = eps[ _a = new_(LineString)] + linestring_coordinates = eps[ _a = new_(geometry_type::types::LineString)] > -(points(_a) [push_back(_r1,_a)] | eps[cleanup_(_a)][_pass = false]) ; - polygon_coordinates = eps[ _a = new_(Polygon) ] + polygon_coordinates = eps[ _a = new_(geometry_type::types::Polygon) ] > ((lit('[') > -(points(_a)[close_path_(_a)] % lit(',')) > lit(']')) [push_back(_r1,_a)] diff --git a/src/symbolizer_helpers.cpp b/src/symbolizer_helpers.cpp index 5f1693c44..91abab87d 100644 --- a/src/symbolizer_helpers.cpp +++ b/src/symbolizer_helpers.cpp @@ -219,8 +219,8 @@ void text_symbolizer_helper::initialize_geometries() // don't bother with empty geometries if (geom.size() == 0) continue; - eGeomType type = geom.type(); - if (type == Polygon) + geometry_type::types type = geom.type(); + if (type == geometry_type::types::Polygon) { largest_box_only = sym_.largest_bbox_only(); if (sym_.get_minimum_path_length() > 0) @@ -284,7 +284,7 @@ void text_symbolizer_helper::initialize_points() // https://github.com/mapnik/mapnik/issues/1423 bool success = false; // https://github.com/mapnik/mapnik/issues/1350 - if (geom.type() == LineString) + if (geom.type() == geometry_type::types::LineString) { success = label::middle_point(geom, label_x,label_y); } diff --git a/src/wkb.cpp b/src/wkb.cpp index 838d43de7..caf5aaeec 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -250,7 +250,7 @@ private: { double x = read_double(); double y = read_double(); - std::unique_ptr pt(new geometry_type(Point)); + std::unique_ptr pt(new geometry_type(geometry_type::types::Point)); pt->move_to(x, y); paths.push_back(pt.release()); } @@ -269,7 +269,7 @@ private: { double x = read_double(); double y = read_double(); - std::unique_ptr pt(new geometry_type(Point)); + std::unique_ptr pt(new geometry_type(geometry_type::types::Point)); pos_ += 8; // double z = read_double(); pt->move_to(x, y); paths.push_back(pt.release()); @@ -292,7 +292,7 @@ private: { CoordinateArray ar(num_points); read_coords(ar); - std::unique_ptr line(new geometry_type(LineString)); + std::unique_ptr line(new geometry_type(geometry_type::types::LineString)); line->move_to(ar[0].x, ar[0].y); for (int i = 1; i < num_points; ++i) { @@ -319,7 +319,7 @@ private: { CoordinateArray ar(num_points); read_coords_xyz(ar); - std::unique_ptr line(new geometry_type(LineString)); + std::unique_ptr line(new geometry_type(geometry_type::types::LineString)); line->move_to(ar[0].x, ar[0].y); for (int i = 1; i < num_points; ++i) { @@ -345,7 +345,7 @@ private: int num_rings = read_integer(); if (num_rings > 0) { - std::unique_ptr poly(new geometry_type(Polygon)); + std::unique_ptr poly(new geometry_type(geometry_type::types::Polygon)); for (int i = 0; i < num_rings; ++i) { int num_points = read_integer(); @@ -381,7 +381,7 @@ private: int num_rings = read_integer(); if (num_rings > 0) { - std::unique_ptr poly(new geometry_type(Polygon)); + std::unique_ptr poly(new geometry_type(geometry_type::types::Polygon)); for (int i = 0; i < num_rings; ++i) { int num_points = read_integer(); diff --git a/src/wkt/wkt_generator.cpp b/src/wkt/wkt_generator.cpp index 16f81bfe5..5b7e57407 100644 --- a/src/wkt/wkt_generator.cpp +++ b/src/wkt/wkt_generator.cpp @@ -72,20 +72,20 @@ wkt_generator::wkt_generator(bool single) wkt = point | linestring | polygon ; - point = &uint_(mapnik::Point)[_1 = _type(_val)] + point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)] << string[ phoenix::if_ (single) [_1 = "Point("] .else_[_1 = "("]] << point_coord [_1 = _first(_val)] << lit(')') ; - linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] + linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)] << string[ phoenix::if_ (single) [_1 = "LineString("] .else_[_1 = "("]] << coords << lit(')') ; - polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)] + polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)] << string[ phoenix::if_ (single) [_1 = "Polygon("] .else_[_1 = "("]] << coords2 @@ -126,9 +126,9 @@ wkt_multi_generator::wkt_multi_generator() using boost::spirit::karma::_a; geometry_types.add - (mapnik::Point,"Point") - (mapnik::LineString,"LineString") - (mapnik::Polygon,"Polygon") + (mapnik::geometry_type::types::Point,"Point") + (mapnik::geometry_type::types::LineString,"LineString") + (mapnik::geometry_type::types::Polygon,"Polygon") ; wkt = eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)] diff --git a/tests/cpp_tests/fontset_runtime_test.cpp b/tests/cpp_tests/fontset_runtime_test.cpp index 4e287296a..14ec2d83a 100644 --- a/tests/cpp_tests/fontset_runtime_test.cpp +++ b/tests/cpp_tests/fontset_runtime_test.cpp @@ -43,7 +43,7 @@ int main(int argc, char** argv) mapnik::transcoder tr("utf-8"); mapnik::value_unicode_string ustr = tr.transcode("hello world!"); feature->put("name",ustr); - mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point); + mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::geometry_type::types::Point); pt->move_to(128,128); feature->add_geometry(pt); boost::shared_ptr ds = boost::make_shared(); diff --git a/tests/cpp_tests/geometry_converters_test.cpp b/tests/cpp_tests/geometry_converters_test.cpp index 9e9f59b85..26986259b 100644 --- a/tests/cpp_tests/geometry_converters_test.cpp +++ b/tests/cpp_tests/geometry_converters_test.cpp @@ -23,7 +23,7 @@ struct output_geometry_backend { - output_geometry_backend(boost::ptr_vector & paths, mapnik::eGeomType type) + output_geometry_backend(boost::ptr_vector & paths, mapnik::geometry_type::types type) : paths_(paths), type_(type) {} @@ -42,7 +42,7 @@ struct output_geometry_backend paths_.push_back(geom_ptr.release()); } boost::ptr_vector & paths_; - mapnik::eGeomType type_; + mapnik::geometry_type::types type_; }; boost::optional linestring_bbox_clipping(mapnik::box2d bbox, @@ -56,7 +56,7 @@ boost::optional linestring_bbox_clipping(mapnik::box2d bbox line_symbolizer sym; CoordTransform t(bbox.width(),bbox.height(), bbox); boost::ptr_vector output_paths; - output_geometry_backend backend(output_paths, mapnik::LineString); + output_geometry_backend backend(output_paths, mapnik::geometry_type::types::LineString); typedef boost::mpl::vector conv_types; vertex_converter, output_geometry_backend, line_symbolizer, @@ -96,7 +96,7 @@ boost::optional polygon_bbox_clipping(mapnik::box2d bbox, polygon_symbolizer sym; CoordTransform t(bbox.width(),bbox.height(), bbox); boost::ptr_vector output_paths; - output_geometry_backend backend(output_paths, mapnik::Polygon); + output_geometry_backend backend(output_paths, mapnik::geometry_type::types::Polygon); typedef boost::mpl::vector conv_types; vertex_converter, output_geometry_backend, polygon_symbolizer, diff --git a/tests/cpp_tests/label_algo_test.cpp b/tests/cpp_tests/label_algo_test.cpp index d997d19b9..268f63595 100644 --- a/tests/cpp_tests/label_algo_test.cpp +++ b/tests/cpp_tests/label_algo_test.cpp @@ -19,7 +19,7 @@ int main(int argc, char** argv) double x,y; // single point - mapnik::geometry_type pt(mapnik::Point); + mapnik::geometry_type pt(mapnik::geometry_type::types::Point); pt.move_to(10,10); BOOST_TEST( mapnik::label::centroid(pt, x, y) ); BOOST_TEST( x == 10 ); @@ -32,7 +32,7 @@ int main(int argc, char** argv) BOOST_TEST_EQ( y, 15 ); // line with two verticies - mapnik::geometry_type line(mapnik::LineString); + mapnik::geometry_type line(mapnik::geometry_type::types::LineString); line.move_to(0,0); line.move_to(50,50); BOOST_TEST( mapnik::label::centroid(line, x, y) ); From c6a093f55a8d489627cfe9847fde1b03347eb9f7 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 16 Sep 2013 15:02:58 +0100 Subject: [PATCH 099/122] + fix bench : iterate over clipped path --- benchmark/run.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index 0e5110b86..3bfc3715a 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -549,7 +549,7 @@ struct test11 clipped.rewind(0); unsigned cmd; double x,y; - while ((cmd = geom.vertex(&x, &y)) != SEG_END) {} + while ((cmd = clipped.vertex(&x, &y)) != SEG_END) {} } } } @@ -594,7 +594,7 @@ struct test12 poly_clipper clipped(extent_, geom); unsigned cmd; double x,y; - while ((cmd = geom.vertex(&x, &y)) != SEG_END) {} + while ((cmd = clipped.vertex(&x, &y)) != SEG_END) {} } } } From 4143d52c161ef37bad711aae3c6237911b101ede Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 17 Sep 2013 11:59:38 +0100 Subject: [PATCH 100/122] + more realistic clipping benchmark --- benchmark/data/polygon.wkt | 2 +- benchmark/run.cpp | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/benchmark/data/polygon.wkt b/benchmark/data/polygon.wkt index 2fe5b480a..b31735f6a 100644 --- a/benchmark/data/polygon.wkt +++ b/benchmark/data/polygon.wkt @@ -1 +1 @@ -MULTIPOLYGON (((30 20, 10 40, 45 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5))) \ No newline at end of file +POLYGON ((155 203, 233 454, 315 340, 421 446, 463 324, 559 466, 665 253, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 155 203),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190)) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index 3bfc3715a..86a8b14d6 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -542,10 +542,10 @@ struct test11 for (geometry_type & geom : paths) { poly_clipper clipped(geom,ps, - agg::clipper_and, - agg::clipper_non_zero, - agg::clipper_non_zero, - 1); + agg::clipper_and, + agg::clipper_non_zero, + agg::clipper_non_zero, + 1); clipped.rewind(0); unsigned cmd; double x,y; @@ -762,6 +762,13 @@ int main( int argc, char** argv) benchmark(runner,"rule caching using heap allocation"); } + // polygon/rect clipping + // IN : POLYGON ((155 203, 233 454, 315 340, 421 446, 463 324, 559 466, 665 253, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 155 203),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190)) + // RECT : POLYGON ((181 106, 181 470, 631 470, 631 106, 181 106)) + // OUT (expected) + // POLYGON ((181 286.6666666666667, 233 454, 315 340, 421 446, 463 324, 559 466, 631 321.3207547169811, 631 234.38686131386862, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 181 238.24444444444444, 181 286.6666666666667),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190)) + + mapnik::box2d clipping_box(181,106,631,470); { std::string filename_("benchmark/data/polygon.wkt"); std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary); @@ -769,23 +776,19 @@ int main( int argc, char** argv) throw std::runtime_error("could not open: '" + filename_ + "'"); std::string wkt_in( (std::istreambuf_iterator(in) ), (std::istreambuf_iterator()) ); - mapnik::box2d clipping_box(0,0,40,40); - - test11 runner(100000,10,wkt_in,clipping_box); + test11 runner(10000,10,wkt_in,clipping_box); benchmark(runner,"clipping polygon with agg_conv_clipper"); } { - std::string filename_("benchmark/data/polygon.wkt"); std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary); if (!in.is_open()) throw std::runtime_error("could not open: '" + filename_ + "'"); std::string wkt_in( (std::istreambuf_iterator(in) ), (std::istreambuf_iterator()) ); - mapnik::box2d clipping_box(0,0,40,40); - test12 runner(100000,10,wkt_in,clipping_box); + test12 runner(10000,10,wkt_in,clipping_box); benchmark(runner,"clipping polygon with mapnik::polygon_clipper"); } From d4d5b617d2ed4805316247abf5f7dfa86331ba77 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 18 Sep 2013 14:06:46 -0700 Subject: [PATCH 101/122] re-enable miniz --- include/mapnik/png_io.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/png_io.hpp b/include/mapnik/png_io.hpp index 74f6a9bfa..622034057 100644 --- a/include/mapnik/png_io.hpp +++ b/include/mapnik/png_io.hpp @@ -27,7 +27,7 @@ #include #include #include -//#include +#include #include // zlib From d2f50a015891ce6632d9ce8bf92555590df7f5a9 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 18 Sep 2013 18:27:04 -0700 Subject: [PATCH 102/122] no need to define BOOST_SPIRIT_USE_PHOENIX_V3 in each header, it is now set in SConstruct --- include/mapnik/css_color_grammar.hpp | 2 -- include/mapnik/expression_grammar.hpp | 2 -- include/mapnik/image_filter_grammar.hpp | 1 - include/mapnik/json/feature_collection_grammar.hpp | 1 - include/mapnik/json/feature_generator_grammar.hpp | 2 -- include/mapnik/json/feature_grammar.hpp | 1 - include/mapnik/json/geometry_generator_grammar.hpp | 1 - include/mapnik/json/geometry_grammar.hpp | 2 -- include/mapnik/path_expression_grammar.hpp | 1 - include/mapnik/svg/svg_path_grammar.hpp | 1 - include/mapnik/transform_expression_grammar.hpp | 1 - include/mapnik/util/dasharray_parser.hpp | 2 -- include/mapnik/util/geometry_svg_generator.hpp | 2 -- include/mapnik/util/geometry_to_svg.hpp | 2 -- include/mapnik/util/geometry_wkt_generator.hpp | 4 ---- include/mapnik/wkt/wkt_grammar.hpp | 2 -- src/conversions.cpp | 2 -- src/json/feature_grammar.cpp | 1 - src/json/geojson_generator.cpp | 2 -- src/json/geometry_grammar.cpp | 2 -- src/json/geometry_parser.cpp | 2 -- src/text_placements/simple.cpp | 2 -- src/transform_expression_grammar.cpp | 1 - tests/cpp_tests/conversions_test.cpp | 2 -- 24 files changed, 41 deletions(-) diff --git a/include/mapnik/css_color_grammar.hpp b/include/mapnik/css_color_grammar.hpp index 28217adcb..58e2f0c70 100644 --- a/include/mapnik/css_color_grammar.hpp +++ b/include/mapnik/css_color_grammar.hpp @@ -27,8 +27,6 @@ #include #include -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // spirit2 #include #include diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp index d9c457f4f..97e619041 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -23,8 +23,6 @@ #ifndef MAPNIK_EXPRESSIONS_GRAMMAR_HPP #define MAPNIK_EXPRESSIONS_GRAMMAR_HPP -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // mapnik #include #include diff --git a/include/mapnik/image_filter_grammar.hpp b/include/mapnik/image_filter_grammar.hpp index e873489ba..26156fbf1 100644 --- a/include/mapnik/image_filter_grammar.hpp +++ b/include/mapnik/image_filter_grammar.hpp @@ -23,7 +23,6 @@ #ifndef MAPNIK_IMAGE_FILITER_GRAMMAR_HPP #define MAPNIK_IMAGE_FILITER_GRAMMAR_HPP -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // boost #include #include diff --git a/include/mapnik/json/feature_collection_grammar.hpp b/include/mapnik/json/feature_collection_grammar.hpp index 29ca15f34..ef8b8aadd 100644 --- a/include/mapnik/json/feature_collection_grammar.hpp +++ b/include/mapnik/json/feature_collection_grammar.hpp @@ -28,7 +28,6 @@ #include #include -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit::qi #include #include diff --git a/include/mapnik/json/feature_generator_grammar.hpp b/include/mapnik/json/feature_generator_grammar.hpp index 57612fc72..7c7666ddb 100644 --- a/include/mapnik/json/feature_generator_grammar.hpp +++ b/include/mapnik/json/feature_generator_grammar.hpp @@ -23,8 +23,6 @@ #ifndef MAPNIK_JSON_FEATURE_GENERATOR_GRAMMAR_HPP #define MAPNIK_JSON_FEATURE_GENERATOR_GRAMMAR_HPP -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // mapnik #include #include diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index b44b41bc3..119c5d063 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -23,7 +23,6 @@ #ifndef MAPNIK_FEATURE_GRAMMAR_HPP #define MAPNIK_FEATURE_GRAMMAR_HPP -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // mapnik #include #include diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index 407d8ff76..f79f9decf 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -23,7 +23,6 @@ #ifndef MAPNIK_JSON_GEOMETRY_GENERATOR_GRAMMAR_HPP #define MAPNIK_JSON_GEOMETRY_GENERATOR_GRAMMAR_HPP -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // mapnik #include #include diff --git a/include/mapnik/json/geometry_grammar.hpp b/include/mapnik/json/geometry_grammar.hpp index c297d0e79..a0e2c9580 100644 --- a/include/mapnik/json/geometry_grammar.hpp +++ b/include/mapnik/json/geometry_grammar.hpp @@ -27,8 +27,6 @@ #include // for geometry_type #include // for CommandType -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // spirit::qi #include #include diff --git a/include/mapnik/path_expression_grammar.hpp b/include/mapnik/path_expression_grammar.hpp index 68f6e93da..a03511215 100644 --- a/include/mapnik/path_expression_grammar.hpp +++ b/include/mapnik/path_expression_grammar.hpp @@ -26,7 +26,6 @@ // mapnik #include -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit2 #include #include diff --git a/include/mapnik/svg/svg_path_grammar.hpp b/include/mapnik/svg/svg_path_grammar.hpp index 940cdbc76..851a501c2 100644 --- a/include/mapnik/svg/svg_path_grammar.hpp +++ b/include/mapnik/svg/svg_path_grammar.hpp @@ -26,7 +26,6 @@ // mapnik #include -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit #include #include diff --git a/include/mapnik/transform_expression_grammar.hpp b/include/mapnik/transform_expression_grammar.hpp index fb113f07a..886ffaa1f 100644 --- a/include/mapnik/transform_expression_grammar.hpp +++ b/include/mapnik/transform_expression_grammar.hpp @@ -27,7 +27,6 @@ #include #include -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // spirit #include diff --git a/include/mapnik/util/dasharray_parser.hpp b/include/mapnik/util/dasharray_parser.hpp index ad5b64ef7..a422b53d1 100644 --- a/include/mapnik/util/dasharray_parser.hpp +++ b/include/mapnik/util/dasharray_parser.hpp @@ -23,8 +23,6 @@ #ifndef MAPNIK_UTIL_DASHARRAY_PARSER_HPP #define MAPNIK_UTIL_DASHARRAY_PARSER_HPP -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - #include #include #include diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index e6db2f80a..b3521d3db 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -23,8 +23,6 @@ #ifndef MAPNIK_GEOMETRY_SVG_GENERATOR_HPP #define MAPNIK_GEOMETRY_SVG_GENERATOR_HPP -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // mapnik #include #include // for container stuff diff --git a/include/mapnik/util/geometry_to_svg.hpp b/include/mapnik/util/geometry_to_svg.hpp index b24a666b7..d7294d878 100644 --- a/include/mapnik/util/geometry_to_svg.hpp +++ b/include/mapnik/util/geometry_to_svg.hpp @@ -28,8 +28,6 @@ #include #include -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // boost #include diff --git a/include/mapnik/util/geometry_wkt_generator.hpp b/include/mapnik/util/geometry_wkt_generator.hpp index e53370e3f..74dd1be70 100644 --- a/include/mapnik/util/geometry_wkt_generator.hpp +++ b/include/mapnik/util/geometry_wkt_generator.hpp @@ -23,15 +23,11 @@ #ifndef MAPNIK_GEOMETRY_WKT_GENERATOR_HPP #define MAPNIK_GEOMETRY_WKT_GENERATOR_HPP -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // mapnik #include #include #include // for CommandType::SEG_MOVETO -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // boost #include #include diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index 47e7e8e84..b70943997 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -23,8 +23,6 @@ #ifndef MAPNIK_WKT_GRAMMAR_HPP #define MAPNIK_WKT_GRAMMAR_HPP -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - #include #include // spirit::qi diff --git a/src/conversions.cpp b/src/conversions.cpp index f7d6d67e6..c4abfff54 100644 --- a/src/conversions.cpp +++ b/src/conversions.cpp @@ -26,8 +26,6 @@ #include -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - #include #if _MSC_VER diff --git a/src/json/feature_grammar.cpp b/src/json/feature_grammar.cpp index f859ced4e..2930490be 100644 --- a/src/json/feature_grammar.cpp +++ b/src/json/feature_grammar.cpp @@ -27,7 +27,6 @@ #include #include -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // boost #include diff --git a/src/json/geojson_generator.cpp b/src/json/geojson_generator.cpp index e58b5a17e..6e98a4d6f 100644 --- a/src/json/geojson_generator.cpp +++ b/src/json/geojson_generator.cpp @@ -20,8 +20,6 @@ * *****************************************************************************/ -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // boost #include #include diff --git a/src/json/geometry_grammar.cpp b/src/json/geometry_grammar.cpp index 70172f7c2..7708ab17c 100644 --- a/src/json/geometry_grammar.cpp +++ b/src/json/geometry_grammar.cpp @@ -26,8 +26,6 @@ // mapnik #include -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // boost #include #include diff --git a/src/json/geometry_parser.cpp b/src/json/geometry_parser.cpp index f55945103..f88177765 100644 --- a/src/json/geometry_parser.cpp +++ b/src/json/geometry_parser.cpp @@ -21,8 +21,6 @@ *****************************************************************************/ // mapnik -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - #include #include diff --git a/src/text_placements/simple.cpp b/src/text_placements/simple.cpp index 25bd9d662..ec5f812d0 100644 --- a/src/text_placements/simple.cpp +++ b/src/text_placements/simple.cpp @@ -26,8 +26,6 @@ #include #include -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - // boost #include #include diff --git a/src/transform_expression_grammar.cpp b/src/transform_expression_grammar.cpp index d707bab65..4c5ab6d0a 100644 --- a/src/transform_expression_grammar.cpp +++ b/src/transform_expression_grammar.cpp @@ -20,7 +20,6 @@ * *****************************************************************************/ -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 // mapnik #include diff --git a/tests/cpp_tests/conversions_test.cpp b/tests/cpp_tests/conversions_test.cpp index 89bbca77b..687f2ba4a 100644 --- a/tests/cpp_tests/conversions_test.cpp +++ b/tests/cpp_tests/conversions_test.cpp @@ -1,5 +1,3 @@ -#define BOOST_SPIRIT_USE_PHOENIX_V3 1 - #include #include #include From 7a6ab9b0ed21ef0adc5e19d2d197280a5d434a5e Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 18 Sep 2013 18:47:44 -0700 Subject: [PATCH 103/122] sync a few files with master --- benchmark/run.cpp | 104 +------------------------- bindings/python/mapnik_datasource.cpp | 1 - demo/c++/rundemo.cpp | 18 +++-- demo/python/rundemo.py | 46 ++++++------ 4 files changed, 38 insertions(+), 131 deletions(-) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index 86a8b14d6..061bcb6e6 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -408,95 +408,6 @@ struct test8 } }; -#include - -struct test9 -{ - unsigned iter_; - unsigned threads_; - unsigned num_rules_; - unsigned num_styles_; - std::vector rules_; - explicit test9(unsigned iterations, - unsigned threads, - unsigned num_rules, - unsigned num_styles) : - iter_(iterations), - threads_(threads), - num_rules_(num_rules), - num_styles_(num_styles), - rules_() - { - mapnik::rule r("test"); - for (unsigned i=0;i rule_caches; - for (unsigned i=0;i rules_; - explicit test10(unsigned iterations, - unsigned threads, - unsigned num_rules, - unsigned num_styles) : - iter_(iterations), - threads_(threads), - num_rules_(num_rules), - num_styles_(num_styles), - rules_() { - mapnik::rule r("test"); - for (unsigned i=0;i > rule_caches; - for (unsigned i=0;i rc(new rule_cache); - for (unsigned i=0;iadd_rule(rules_[i]); - } - rule_caches.push_back(std::move(rc)); - } - } - } -}; - - #include #include "agg_conv_clipper.h" #include "agg_path_storage.h" @@ -748,19 +659,8 @@ int main( int argc, char** argv) benchmark(runner,"expression parsing by re-using grammar"); } - { -#if BOOST_VERSION >= 105300 - test9 runner(1000,10,200,50); - benchmark(runner,"rule caching using move semantics"); -#else - std::clog << "not running: 'rule caching using move semantics'\n"; -#endif - } - - { - test10 runner(1000,10,200,50); - benchmark(runner,"rule caching using heap allocation"); - } + // TODO - consider bring back rule cache benchmarks after c++11 is in master + // previously test 9/10 // polygon/rect clipping // IN : POLYGON ((155 203, 233 454, 315 340, 421 446, 463 324, 559 466, 665 253, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 155 203),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190)) diff --git a/bindings/python/mapnik_datasource.cpp b/bindings/python/mapnik_datasource.cpp index 2b34458a9..85e2ff721 100644 --- a/bindings/python/mapnik_datasource.cpp +++ b/bindings/python/mapnik_datasource.cpp @@ -61,7 +61,6 @@ boost::shared_ptr create_datasource(dict const& d) PyObject* temp = PyUnicode_AsUTF8String(obj.ptr()); if (temp) { - #if PY_VERSION_HEX >= 0x03000000 char* c_str = PyBytes_AsString(temp); #else diff --git a/demo/c++/rundemo.cpp b/demo/c++/rundemo.cpp index bfc71615b..20416c8a3 100644 --- a/demo/c++/rundemo.cpp +++ b/demo/c++/rundemo.cpp @@ -263,23 +263,27 @@ int main ( int argc , char** argv) image_32 buf(m.width(),m.height()); agg_renderer ren(m,buf); ren.apply(); + std::string msg("These maps have been rendered using AGG in the current directory:\n"); #ifdef HAVE_JPEG save_to_file(buf,"demo.jpg","jpeg"); + msg += "- demo.jpg\n"; #endif #ifdef HAVE_PNG save_to_file(buf,"demo.png","png"); save_to_file(buf,"demo256.png","png8"); + msg += "- demo.png\n"; + msg += "- demo256.png\n"; #endif #ifdef HAVE_TIFF save_to_file(buf,"demo.tif","tiff"); + msg += "- demo.tif\n"; #endif - - std::cout << "Three maps have been rendered using AGG in the current directory:\n" - "- demo.jpg\n" - "- demo.png\n" - "- demo256.png\n" - "- demo.tif\n" - "Have a look!\n"; +#ifdef HAVE_WEBP + save_to_file(buf,"demo.webp","webp"); + msg += "- demo.webp\n"; +#endif + msg += "Have a look!\n"; + std::cout << msg; #if defined(HAVE_CAIRO) // save to pdf/svg files diff --git a/demo/python/rundemo.py b/demo/python/rundemo.py index edfda31e8..aaaae439a 100644 --- a/demo/python/rundemo.py +++ b/demo/python/rundemo.py @@ -330,36 +330,40 @@ mapnik.render(m, im) # Save image to files images_ = [] -im.save('demo.png', 'png') # true-colour RGBA -images_.append('demo.png') +if mapnik.has_png(): + im.save('demo.png', 'png') # true-colour RGBA + images_.append('demo.png') -# old behavior, now can do 'png8:c=256' -im.save('demo256.png', 'png256') # save to palette based (max 256 colours) png -images_.append('demo256.png') + # old behavior, now can do 'png8:c=256' + im.save('demo256.png', 'png256') # save to palette based (max 256 colours) png + images_.append('demo256.png') -im.save('demo64_binary_transparency.png', 'png8:c=64:t=1') -images_.append('demo64_binary_transparency.png') + im.save('demo64_binary_transparency.png', 'png8:c=64:t=1') + images_.append('demo64_binary_transparency.png') -im.save('demo128_colors_hextree_no_alpha.png', 'png8:c=100:m=h:t=0') -images_.append('demo128_colors_hextree_no_alpha.png') + im.save('demo128_colors_hextree_no_alpha.png', 'png8:c=100:m=h:t=0') + images_.append('demo128_colors_hextree_no_alpha.png') -im.save('demo_high.jpg', 'jpeg100') -images_.append('demo_high.jpg') +if mapnik.has_jpeg(): + im.save('demo_high.jpg', 'jpeg100') + images_.append('demo_high.jpg') -im.save('demo_low.jpg', 'jpeg50') -images_.append('demo_low.jpg') + im.save('demo_low.jpg', 'jpeg50') + images_.append('demo_low.jpg') -im.save('demo.tif', 'tiff') -images_.append('demo.tif') +if mapnik.has_tiff(): + im.save('demo.tif', 'tiff') + images_.append('demo.tif') -im.save('demo.webp', 'webp') -images_.append('demo.webp') +if mapnik.has_webp(): + im.save('demo.webp', 'webp') # default quality is 90 + images_.append('demo.webp') -im.save('demo_med.webp', 'webp80') -images_.append('demo_med.webp') + im.save('demo_highest.webp', 'webp:quality=100') + images_.append('demo_med.webp') -im.save('demo_low.webp', 'webp50') -images_.append('demo_low.webp') + im.save('demo_low.webp', 'webp:quality=50') + images_.append('demo_low.webp') # Render cairo examples From 30c8ca5f66f4089e31e6b8915c6c851c89cced62 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 18 Sep 2013 19:04:44 -0700 Subject: [PATCH 104/122] minor formatting to sync cleaner with master --- bindings/python/python_optional.hpp | 1 - include/mapnik/png_io.hpp | 3 ++- include/mapnik/util/geometry_svg_generator.hpp | 17 +++++++++++++---- src/json/feature_collection_parser.cpp | 2 +- src/miniz.c | 6 +++--- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/bindings/python/python_optional.hpp b/bindings/python/python_optional.hpp index 2d3c44901..3b41ff757 100644 --- a/bindings/python/python_optional.hpp +++ b/bindings/python/python_optional.hpp @@ -201,7 +201,6 @@ struct python_optional : public mapnik::noncopyable // This class works around a feature in boost python. // See http://osdir.com/ml/python.c++/2003-11/msg00158.html - template const& palette, png_color* pal = const_cast(reinterpret_cast(&palette[0])); png_set_PLTE(png_ptr, info_ptr, pal, static_cast(palette.size())); + // make transparent lowest indexes, so tRNS is small if (alpha.size()>0) { diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index b3521d3db..150bf6ccf 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -23,6 +23,7 @@ #ifndef MAPNIK_GEOMETRY_SVG_GENERATOR_HPP #define MAPNIK_GEOMETRY_SVG_GENERATOR_HPP + // mapnik #include #include // for container stuff @@ -118,8 +119,10 @@ namespace mapnik { namespace util { template struct get_type { - typedef int result_type; - result_type operator() (Geometry const& geom) const + template + struct result { typedef int type; }; + + int operator() (Geometry const& geom) const { return static_cast(geom.type()); } @@ -129,8 +132,11 @@ namespace mapnik { namespace util { struct get_first { typedef T geometry_type; - typedef typename geometry_type::value_type const result_type; - result_type const operator() (geometry_type const& geom) const + + template + struct result { typedef typename geometry_type::value_type const type; }; + + typename geometry_type::value_type operator() (geometry_type const& geom) const { typename geometry_type::value_type coord; geom.rewind(0); @@ -191,6 +197,9 @@ namespace mapnik { namespace util { | &uint_(mapnik::SEG_LINETO) [_a +=1] << karma::string [if_(_a == 1) [_1 = "L" ].else_[_1 =""]]) << lit(' ') << coordinate << lit(' ') << coordinate) % lit(' ') ; + + + } // rules karma::rule svg; diff --git a/src/json/feature_collection_parser.cpp b/src/json/feature_collection_parser.cpp index 85c7283be..9eb317879 100644 --- a/src/json/feature_collection_parser.cpp +++ b/src/json/feature_collection_parser.cpp @@ -20,8 +20,8 @@ * *****************************************************************************/ +// TODO https://github.com/mapnik/mapnik/issues/1658 #include - #if BOOST_VERSION >= 105200 #ifndef BOOST_SPIRIT_USE_PHOENIX_V3 #define BOOST_SPIRIT_USE_PHOENIX_V3 diff --git a/src/miniz.c b/src/miniz.c index d9c3a18ae..02aa52c8b 100644 --- a/src/miniz.c +++ b/src/miniz.c @@ -789,7 +789,7 @@ size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void // Compresses an image to a compressed PNG file in memory. // On entry: -// pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4. +// pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4. // The image pitch in bytes per scanline will be w*num_chans. The leftmost pixel on the top scanline is stored first in memory. // On return: // Function returns a pointer to the compressed data, or NULL on failure. @@ -2778,8 +2778,8 @@ void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, *pLen_out = out_buf.m_size-41; { mz_uint8 pnghdr[41]={0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, - 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8, (mz_uint8)"\0\0\04\02\06"[num_chans],0,0,0,0,0,0,0, - (mz_uint8)(*pLen_out>>24),(mz_uint8)(*pLen_out>>16),(mz_uint8)(*pLen_out>>8),(mz_uint8)*pLen_out,0x49,0x44,0x41,0x54}; + 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8, (mz_uint8)"\0\0\04\02\06"[num_chans],0,0,0,0,0,0,0, + (mz_uint8)(*pLen_out>>24),(mz_uint8)(*pLen_out>>16),(mz_uint8)(*pLen_out>>8),(mz_uint8)*pLen_out,0x49,0x44,0x41,0x54}; c=(mz_uint32)mz_crc32(MZ_CRC32_INIT,pnghdr+12,17); for (i=0; i<4; ++i, c<<=8) ((mz_uint8*)(pnghdr+29))[i]=(mz_uint8)(c>>24); memcpy(out_buf.m_pBuf, pnghdr, 41); } From b2d1363011f192a5fe84c50e3e4eb9fb30a47c4c Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 18 Sep 2013 19:19:41 -0700 Subject: [PATCH 105/122] remove expression optimizer for now since it is currently unused - refs #1002 --- include/mapnik/expression_optimizer.hpp | 134 ------------------------ 1 file changed, 134 deletions(-) delete mode 100644 include/mapnik/expression_optimizer.hpp diff --git a/include/mapnik/expression_optimizer.hpp b/include/mapnik/expression_optimizer.hpp deleted file mode 100644 index bad499ff5..000000000 --- a/include/mapnik/expression_optimizer.hpp +++ /dev/null @@ -1,134 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2013 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -#ifndef MAPNIK_EXPRESSION_OPTIMIZER_HPP -#define MAPNIK_EXPRESSION_OPTIMIZER_HPP - -// mapnik -#include -#include -#include - -// boost -#include -#include -#include -#include - -namespace mapnik -{ - - -template -struct optimize : boost::static_visitor< std::tuple > -{ - typedef T node_type; - typedef std::tuple return_type; - - return_type operator() (value const& v) const - { - return std::make_tuple(node_type(v),true); - } - - return_type operator() (attribute const& attr) const - { - return std::make_tuple(node_type(attr),false); - } - - return_type operator() (geometry_type_attribute const& attr) const - { - return return_type(node_type(attr),false); - } - - return_type operator() (binary_node const & x) const - { - return return_type(node_type(x),false); -// return (boost::apply_visitor(optimize(),x.left).to_bool()) - // && (boost::apply_visitor(optimize(),x.right).to_bool()); - } - - return_type operator() (binary_node const & x) const - { - return return_type(node_type(x),false); -// return (boost::apply_visitor(optimize(),x.left).to_bool()) - // || (boost::apply_visitor(optimize(),x.right).to_bool()); - } - - template - return_type operator() (binary_node const& x) const - { - auto left = boost::apply_visitor(optimize(),x.left); - auto right = boost::apply_visitor(optimize(),x.right); - if (std::get<1>(left) && std::get<1>(right)) - { - // evaluate - typename make_op::type operation; - auto lv = boost::get(std::get<0>(left)); - auto rv = boost::get(std::get<0>(right)); - return return_type(node_type(operation(lv,rv)),true); - } - - if (std::get<1>(right)) - { - return return_type(node_type(binary_node(std::get<0>(right), - std::get<0>(left))), false); - } - if (std::get<1>(left)) - { - return return_type(node_type(binary_node(std::get<0>(left), - std::get<0>(right))), false); - } - return return_type(node_type(x),false); - } - - template - return_type operator() (unary_node const& x) const - { - //typename make_op::type func; - //return func(boost::apply_visitor(*this, x.expr)); -// return node_type(x); - return return_type(node_type(x),false); - } - - return_type operator() (unary_node const& x) const - { -// return node_type(x); - return return_type(node_type(x),false); - //return ! (boost::apply_visitor(optimize(),x.expr).to_bool()); - } - - return_type operator() (regex_match_node const& x) const - { - return return_type(node_type(x),false); -// return boost::apply_visitor(optimize(),x.expr); - } - - return_type operator() (regex_replace_node const& x) const - { - return return_type(node_type(x),false); - //return boost::apply_visitor(optimize(),x.expr); - } -}; - -} - -#endif // MAPNIK_EXPRESSION_OPTIMIZER_HPP From 5cd2152866406cc416e93f0997eb33c39680f957 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 18 Sep 2013 19:50:30 -0700 Subject: [PATCH 106/122] fix failing halo rendering visual tests --- src/font_engine_freetype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index d6ba8e6f4..92e143348 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -660,7 +660,7 @@ void text_renderer::render(pixel_position const& pos) itr->properties->halo_fill.rgba(), bit->left, height - bit->top, - static_cast(halo_radius), + halo_radius, itr->properties->text_opacity, comp_op_); } From 111bdccebc9c14bd8d059d5426343db258c9661e Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 18 Sep 2013 19:51:14 -0700 Subject: [PATCH 107/122] various post-merge fixes --- include/mapnik/css_color_grammar.hpp | 28 +- include/mapnik/expression_grammar.hpp | 33 ++- include/mapnik/feature.hpp | 1 - include/mapnik/json/feature_grammar.hpp | 18 +- .../json/geometry_generator_grammar.hpp | 23 +- include/mapnik/json/geometry_grammar.hpp | 32 +- include/mapnik/utils.hpp | 5 - include/mapnik/vertex_converters.hpp | 1 + include/mapnik/webp_io.hpp | 2 +- include/mapnik/wkt/wkt_grammar.hpp | 278 ++++++++++-------- plugins/input/shape/shape_datasource.cpp | 1 - src/build.py | 10 - 12 files changed, 249 insertions(+), 183 deletions(-) diff --git a/include/mapnik/css_color_grammar.hpp b/include/mapnik/css_color_grammar.hpp index 58e2f0c70..e5dd849b1 100644 --- a/include/mapnik/css_color_grammar.hpp +++ b/include/mapnik/css_color_grammar.hpp @@ -80,9 +80,13 @@ inline int clip_int(int val) struct percent_conv_impl { - typedef unsigned result_type; + template + struct result + { + typedef unsigned type; + }; - result_type operator() (double val) const + unsigned operator() (double val) const { return clip_int<0,255>(int((255.0 * val)/100.0 + 0.5)); } @@ -90,9 +94,13 @@ struct percent_conv_impl struct alpha_conv_impl { - typedef unsigned result_type; + template + struct result + { + typedef unsigned type; + }; - result_type operator() (double val) const + unsigned operator() (double val) const { return clip_int<0,255>(int((255.0 * val) + 0.5)); } @@ -100,10 +108,18 @@ struct alpha_conv_impl struct hsl_conv_impl { - typedef void result_type; +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else + template +#endif + struct result + { + typedef void type; + }; template - result_type operator() (T0 & c, T1 h, T2 s, T3 l) const + void operator() (T0 & c, T1 h, T2 s, T3 l) const { double m1,m2; // normalize values diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp index 97e619041..b0da07f76 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -46,12 +46,16 @@ using standard_wide::space_type; struct unicode_impl { - typedef mapnik::value_unicode_string result_type; + template + struct result + { + typedef mapnik::value_unicode_string type; + }; explicit unicode_impl(mapnik::transcoder const& tr) : tr_(tr) {} - result_type operator()(std::string const& str) const + mapnik::value_unicode_string operator()(std::string const& str) const { return tr_.transcode(str.c_str()); } @@ -61,26 +65,43 @@ struct unicode_impl struct regex_match_impl { - typedef expr_node result_type; +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else + template +#endif + struct result + { + typedef expr_node type; + }; explicit regex_match_impl(mapnik::transcoder const& tr) : tr_(tr) {} template - result_type operator() (T0 & node, T1 const& pattern) const; + expr_node operator() (T0 & node, T1 const& pattern) const; mapnik::transcoder const& tr_; }; struct regex_replace_impl { - typedef expr_node result_type; + +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else + template +#endif + struct result + { + typedef expr_node type; + }; explicit regex_replace_impl(mapnik::transcoder const& tr) : tr_(tr) {} template - result_type operator() (T0 & node, T1 const& pattern, T2 const& format) const; + expr_node operator() (T0 & node, T1 const& pattern, T2 const& format) const; mapnik::transcoder const& tr_; }; diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index 1484c86b0..067b34cff 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -235,7 +235,6 @@ public: { if (first) { - first = false; box2d box = geom.envelope(); result.init(box.minx(),box.miny(),box.maxx(),box.maxy()); first = false; diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index 119c5d063..38bba2453 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -93,14 +93,16 @@ struct extract_geometry #else struct put_property { - - typedef void result_type; - + template + struct result + { + typedef void type; + }; explicit put_property(mapnik::transcoder const& tr) : tr_(tr) {} template - result_type operator() (T0 & feature, T1 const& key, T2 const& val) const + void operator() (T0 & feature, T1 const& key, T2 const& val) const { mapnik::value v = boost::apply_visitor(attribute_value_visitor(tr_),val); // TODO: optimize feature.put_new(key, v); @@ -111,10 +113,14 @@ struct put_property struct extract_geometry { - typedef boost::ptr_vector& result_type; + template + struct result + { + typedef boost::ptr_vector& type; + }; template - result_type operator() (T & feature) const + boost::ptr_vector& operator() (T & feature) const { return feature.paths(); } diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index f79f9decf..27d5acab0 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -106,8 +106,10 @@ struct multi_geometry_type #else struct get_type { - typedef int result_type; - result_type operator() (geometry_type const& geom) const + template + struct result { typedef int type; }; + + int operator() (geometry_type const& geom) const { return static_cast(geom.type()); } @@ -115,8 +117,10 @@ struct get_type struct get_first { - typedef geometry_type::value_type const result_type; - result_type operator() (geometry_type const& geom) const + template + struct result { typedef geometry_type::value_type const type; }; + + geometry_type::value_type const operator() (geometry_type const& geom) const { geometry_type::value_type coord; boost::get<0>(coord) = geom.vertex(0,&boost::get<1>(coord),&boost::get<2>(coord)); @@ -126,8 +130,10 @@ struct get_first struct multi_geometry_type { - typedef boost::tuple result_type; - result_type operator() (geometry_container const& geom) const + template + struct result { typedef boost::tuple type; }; + + boost::tuple operator() (geometry_container const& geom) const { unsigned type = 0u; bool collection = false; @@ -276,7 +282,6 @@ struct multi_geometry_generator_grammar : using boost::spirit::karma::_1; using boost::spirit::karma::_a; using boost::spirit::karma::_r1; - using boost::spirit::karma::string; geometry_types.add (mapnik::geometry_type::types::Point,"\"Point\"") @@ -300,9 +305,9 @@ struct multi_geometry_generator_grammar : geometry = (lit("{\"type\":") << geometry_types[_1 = phoenix::at_c<0>(_a)][_a = _multi_type(_val)] << lit(",\"coordinates\":") - << string[ phoenix::if_ (phoenix::at_c<0>(_a) > 3) [_1 = '['].else_[_1 = ""]] + << karma::string[ phoenix::if_ (phoenix::at_c<0>(_a) > 3) [_1 = '['].else_[_1 = ""]] << coordinates - << string[ phoenix::if_ (phoenix::at_c<0>(_a) > 3) [_1 = ']'].else_[_1 = ""]] + << karma::string[ phoenix::if_ (phoenix::at_c<0>(_a) > 3) [_1 = ']'].else_[_1 = ""]] << lit('}')) | lit("null") ; diff --git a/include/mapnik/json/geometry_grammar.hpp b/include/mapnik/json/geometry_grammar.hpp index a0e2c9580..821ab9646 100644 --- a/include/mapnik/json/geometry_grammar.hpp +++ b/include/mapnik/json/geometry_grammar.hpp @@ -88,10 +88,14 @@ struct where_message #else struct push_vertex { - typedef void result_type; + template + struct result + { + typedef void type; + }; template - result_type operator() (T0 c, T1 path, T2 x, T3 y) const + void operator() (T0 c, T1 path, T2 x, T3 y) const { BOOST_ASSERT( path!=0 ); path->push_vertex(x,y,c); @@ -100,10 +104,14 @@ struct push_vertex struct close_path { - typedef void result_type; + template + struct result + { + typedef void type; + }; template - result_type operator() (T path) const + void operator() (T path) const { BOOST_ASSERT( path!=0 ); path->close_path(); @@ -112,7 +120,12 @@ struct close_path struct cleanup { - typedef void result_type; + template + struct result + { + typedef void type; + }; + template void operator() (T0 & path) const { @@ -122,8 +135,11 @@ struct cleanup struct where_message { - - typedef std::string result_type; + template + struct result + { + typedef std::string type; + }; template std::string operator() (Iterator first, Iterator last, std::size_t size) const @@ -134,8 +150,8 @@ struct where_message return str; } }; +#endif -#endif // PHOENIX_V3 template struct geometry_grammar : diff --git a/include/mapnik/utils.hpp b/include/mapnik/utils.hpp index b820b3cef..0dbe28b6d 100644 --- a/include/mapnik/utils.hpp +++ b/include/mapnik/utils.hpp @@ -164,11 +164,6 @@ protected: MAPNIK_DECL std::string utf16_to_utf8(std::wstring const& wstr); MAPNIK_DECL std::wstring utf8_to_utf16(std::string const& str); -// UTF8 <--> UTF16 conversion routines - -MAPNIK_DECL std::string utf16_to_utf8(std::wstring const& wstr); -MAPNIK_DECL std::wstring utf8_to_utf16(std::string const& str); - #endif // _WINDOWS } diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index 2817e4baf..1d7d4b26f 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -43,6 +43,7 @@ #include #include #include + #include // mapnik diff --git a/include/mapnik/webp_io.hpp b/include/mapnik/webp_io.hpp index f3ed036c7..a697b39c9 100644 --- a/include/mapnik/webp_io.hpp +++ b/include/mapnik/webp_io.hpp @@ -36,6 +36,7 @@ // boost #include + namespace mapnik { template @@ -83,7 +84,6 @@ void save_as_webp(T1& file, } // Add additional tuning - if (method >= 0) config.method = method; #if (WEBP_ENCODER_ABI_VERSION >> 8) >= 1 config.lossless = !!lossless; diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index b70943997..09d634531 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -39,164 +39,182 @@ namespace mapnik { namespace wkt { -using namespace boost::spirit; -using namespace boost::fusion; -using namespace boost::phoenix; + using namespace boost::spirit; + using namespace boost::phoenix; -struct push_vertex -{ - typedef void result_type; - template - result_type operator() (T0 c, T1 path, T2 x, T3 y) const + struct push_vertex { - BOOST_ASSERT( path!=0 ); - path->push_vertex(x,y,c); - } -}; +#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 + template +#else + template +#endif + struct result + { + typedef void type; + }; -struct close_path -{ - typedef void result_type; - template - result_type operator() (T path) const + template + void operator() (T0 c, T1 path, T2 x, T3 y) const + { + BOOST_ASSERT( path!=0 ); + path->push_vertex(x,y,c); + } + }; + + struct close_path { - BOOST_ASSERT( path!=0 ); - path->close_path(); - } -}; + template + struct result + { + typedef void type; + }; -struct cleanup -{ - typedef void result_type; - template - void operator() (T0 & path) const + template + void operator() (T path) const + { + BOOST_ASSERT( path!=0 ); + path->close_path(); + } + }; + + struct cleanup { - if (path) delete path,path=0; - } -}; + template + struct result + { + typedef void type; + }; -template -struct wkt_grammar : qi::grammar() , ascii::space_type> -{ - wkt_grammar() - : wkt_grammar::base_type(geometry_tagged_text) + template + void operator() (T0 & path) const + { + if (path) delete path,path=0; + } + }; + + template + struct wkt_grammar : qi::grammar() , ascii::space_type> { - using qi::no_case; - using qi::_1; - using qi::_2; - using boost::phoenix::push_back; + wkt_grammar() + : wkt_grammar::base_type(geometry_tagged_text) + { + using qi::no_case; + using qi::_1; + using qi::_2; + using boost::phoenix::push_back; - geometry_tagged_text = point_tagged_text - | linestring_tagged_text - | polygon_tagged_text - | multipoint_tagged_text - | multilinestring_tagged_text - | multipolygon_tagged_text - ; + geometry_tagged_text = point_tagged_text + | linestring_tagged_text + | polygon_tagged_text + | multipoint_tagged_text + | multilinestring_tagged_text + | multipolygon_tagged_text + ; - // ::= point - point_tagged_text = no_case[lit("POINT")] [ _a = new_(geometry_type::types::Point) ] - >> ( point_text(_a) [push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) - ; + // ::= point + point_tagged_text = no_case[lit("POINT")] [ _a = new_(geometry_type::types::Point) ] + >> ( point_text(_a) [push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) + ; - // ::= | - point_text = (lit("(") >> point(SEG_MOVETO,_r1) >> lit(')')) - | empty_set - ; + // ::= | + point_text = (lit("(") >> point(SEG_MOVETO,_r1) >> lit(')')) + | empty_set + ; - // ::= linestring - linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(geometry_type::types::LineString) ] - >> (linestring_text(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) - ; + // ::= linestring + linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(geometry_type::types::LineString) ] + >> (linestring_text(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) + ; - // ::= | { }* - linestring_text = points(_r1) | empty_set - ; + // ::= | { }* + linestring_text = points(_r1) | empty_set + ; - // ::= polygon - polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(geometry_type::types::Polygon) ] - >> ( polygon_text(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) - ; + // ::= polygon + polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(geometry_type::types::Polygon) ] + >> ( polygon_text(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) + ; - // ::= | { }* - polygon_text = (lit('(') >> linestring_text(_r1)[close_path_(_r1)] % lit(',') >> lit(')')) | empty_set; + // ::= | { }* + polygon_text = (lit('(') >> linestring_text(_r1)[close_path_(_r1)] % lit(',') >> lit(')')) | empty_set; - // ::= multipoint - multipoint_tagged_text = no_case[lit("MULTIPOINT")] - >> multipoint_text - ; + // ::= multipoint + multipoint_tagged_text = no_case[lit("MULTIPOINT")] + >> multipoint_text + ; - // ::= | { }* - multipoint_text = (lit('(') - >> ((eps[_a = new_(geometry_type::types::Point)] - >> (point_text(_a) | empty_set) [push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false]) % lit(',')) - >> lit(')')) | empty_set - ; + // ::= | { }* + multipoint_text = (lit('(') + >> ((eps[_a = new_(geometry_type::types::Point)] + >> (point_text(_a) | empty_set) [push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false]) % lit(',')) + >> lit(')')) | empty_set + ; - // ::= multilinestring - multilinestring_tagged_text = no_case[lit("MULTILINESTRING")] - >> multilinestring_text ; + // ::= multilinestring + multilinestring_tagged_text = no_case[lit("MULTILINESTRING")] + >> multilinestring_text ; - // ::= | { }* - multilinestring_text = (lit('(') - >> ((eps[_a = new_(geometry_type::types::LineString)] - >> ( points(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false])) - % lit(',')) - >> lit(')')) | empty_set; + // ::= | { }* + multilinestring_text = (lit('(') + >> ((eps[_a = new_(geometry_type::types::LineString)] + >> ( points(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false])) + % lit(',')) + >> lit(')')) | empty_set; - // ::= multipolygon - multipolygon_tagged_text = no_case[lit("MULTIPOLYGON")] - >> multipolygon_text ; + // ::= multipolygon + multipolygon_tagged_text = no_case[lit("MULTIPOLYGON")] + >> multipolygon_text ; - // ::= | { }* + // ::= | { }* - multipolygon_text = (lit('(') - >> ((eps[_a = new_(geometry_type::types::Polygon)] - >> ( polygon_text(_a)[push_back(_val,_a)] - | eps[cleanup_(_a)][_pass = false])) - % lit(',')) - >> lit(')')) | empty_set; + multipolygon_text = (lit('(') + >> ((eps[_a = new_(geometry_type::types::Polygon)] + >> ( polygon_text(_a)[push_back(_val,_a)] + | eps[cleanup_(_a)][_pass = false])) + % lit(',')) + >> lit(')')) | empty_set; - // points - points = lit('(')[_a = SEG_MOVETO] >> point (_a,_r1) % lit(',') [_a = SEG_LINETO] >> lit(')'); - // point - point = (double_ >> double_) [push_vertex_(_r1,_r2,_1,_2)]; + // points + points = lit('(')[_a = SEG_MOVETO] >> point (_a,_r1) % lit(',') [_a = SEG_LINETO] >> lit(')'); + // point + point = (double_ >> double_) [push_vertex_(_r1,_r2,_1,_2)]; - // - empty_set = no_case[lit("EMPTY")]; + // + empty_set = no_case[lit("EMPTY")]; - } + } - // start - qi::rule(),ascii::space_type> geometry_tagged_text; + // start + qi::rule(),ascii::space_type> geometry_tagged_text; - qi::rule,boost::ptr_vector(),ascii::space_type> point_tagged_text; - qi::rule,boost::ptr_vector(),ascii::space_type> linestring_tagged_text; - qi::rule,boost::ptr_vector(),ascii::space_type> polygon_tagged_text; - qi::rule(),ascii::space_type> multipoint_tagged_text; - qi::rule(),ascii::space_type> multilinestring_tagged_text; - qi::rule(),ascii::space_type> multipolygon_tagged_text; - // - qi::rule point_text; - qi::rule linestring_text; - qi::rule polygon_text; - qi::rule, boost::ptr_vector(),ascii::space_type> multipoint_text; - qi::rule, boost::ptr_vector(),ascii::space_type> multilinestring_text; - qi::rule, boost::ptr_vector(),ascii::space_type> multipolygon_text; - // - qi::rule point; - qi::rule,void(geometry_type*),ascii::space_type> points; - qi::rule empty_set; - boost::phoenix::function push_vertex_; - boost::phoenix::function close_path_; - boost::phoenix::function cleanup_; -}; + qi::rule,boost::ptr_vector(),ascii::space_type> point_tagged_text; + qi::rule,boost::ptr_vector(),ascii::space_type> linestring_tagged_text; + qi::rule,boost::ptr_vector(),ascii::space_type> polygon_tagged_text; + qi::rule(),ascii::space_type> multipoint_tagged_text; + qi::rule(),ascii::space_type> multilinestring_tagged_text; + qi::rule(),ascii::space_type> multipolygon_tagged_text; + // + qi::rule point_text; + qi::rule linestring_text; + qi::rule polygon_text; + qi::rule, boost::ptr_vector(),ascii::space_type> multipoint_text; + qi::rule, boost::ptr_vector(),ascii::space_type> multilinestring_text; + qi::rule, boost::ptr_vector(),ascii::space_type> multipolygon_text; + // + qi::rule point; + qi::rule,void(geometry_type*),ascii::space_type> points; + qi::rule empty_set; + boost::phoenix::function push_vertex_; + boost::phoenix::function close_path_; + boost::phoenix::function cleanup_; + }; template diff --git a/plugins/input/shape/shape_datasource.cpp b/plugins/input/shape/shape_datasource.cpp index d4911a4a2..f147bb5a9 100644 --- a/plugins/input/shape/shape_datasource.cpp +++ b/plugins/input/shape/shape_datasource.cpp @@ -77,7 +77,6 @@ shape_datasource::shape_datasource(const parameters ¶ms) shape_name_ = *file; boost::algorithm::ireplace_last(shape_name_,".shp",""); - if (!mapnik::util::exists(shape_name_ + ".shp")) { throw datasource_exception("Shape Plugin: shapefile '" + shape_name_ + ".shp' does not exist"); diff --git a/src/build.py b/src/build.py index 292d779f8..0dba64a0e 100644 --- a/src/build.py +++ b/src/build.py @@ -80,9 +80,6 @@ if '-DHAVE_JPEG' in env['CPPDEFINES']: lib_env['LIBS'].append('jpeg') enabled_imaging_libraries.append('jpeg_reader.cpp') -if env['WEBP']: - lib_env['LIBS'].append('webp') - if len(env['EXTRA_FREETYPE_LIBS']): lib_env['LIBS'].extend(copy(env['EXTRA_FREETYPE_LIBS'])) @@ -269,13 +266,6 @@ if env['HAS_CAIRO']: for cpp in enabled_imaging_libraries: source.append(cpp) -if env['WEBP']: - source += Split( - """ - webp_reader.cpp - """) - - # agg backend source += Split( """ From a8d49b811219cb14ae7dc42d0901c0b4b6f17f20 Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 19 Sep 2013 09:08:45 +0100 Subject: [PATCH 108/122] + use mapnik::polygon_clipper by default --- include/mapnik/vertex_converters.hpp | 33 +++++----------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index 1d7d4b26f..65d85bfa7 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -51,6 +51,7 @@ #include #include #include +#include // agg #include "agg_conv_clip_polygon.h" @@ -60,7 +61,6 @@ #include "agg_conv_stroke.h" #include "agg_conv_dash.h" #include "agg_conv_transform.h" -#include "agg_conv_clipper.h" #include "agg_path_storage.h" // stl @@ -71,7 +71,6 @@ namespace mapnik { struct transform_tag {}; struct clip_line_tag {}; struct clip_poly_tag {}; -struct clipper_tag {}; struct close_poly_tag {}; struct smooth_tag {}; struct simplify_tag {}; @@ -88,7 +87,7 @@ struct converter_traits typedef T0 geometry_type; typedef geometry_type conv_type; template - static void setup(geometry_type & /*geom*/, Args const& /*args*/) + static void setup(geometry_type & , Args const& ) { throw std::runtime_error("invalid call to setup"); } @@ -183,32 +182,12 @@ template struct converter_traits { typedef T geometry_type; - typedef typename agg::conv_clip_polygon conv_type; + typedef mapnik::polygon_clipper conv_type; template static void setup(geometry_type & geom, Args const& args) { typename boost::mpl::at >::type box = boost::fusion::at_c<0>(args); - geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy()); - } -}; - -template -struct converter_traits -{ - typedef T geometry_type; - typedef typename agg::conv_clipper conv_type; - template - static void setup(geometry_type & geom, Args const& args) - { - typename boost::mpl::at >::type box = boost::fusion::at_c<0>(args); - agg::path_storage * ps = new agg::path_storage(); // FIXME: this will leak memory! - ps->move_to(box.minx(),box.miny()); - ps->line_to(box.minx(),box.maxy()); - ps->line_to(box.maxx(),box.maxy()); - ps->line_to(box.maxx(),box.miny()); - ps->close_polygon(); - geom.attach2(*ps, agg::clipper_non_zero); - //geom.reverse(true); + geom.set_clip_box(box); } }; @@ -218,7 +197,7 @@ struct converter_traits typedef T geometry_type; typedef typename agg::conv_close_polygon conv_type; template - static void setup(geometry_type & /*geom*/, Args const& /*args*/) + static void setup(geometry_type & , Args const&) { // no-op } @@ -293,7 +272,7 @@ template <> struct converter_fwd { template - static void forward(Base& base, T0 & geom,T1 const& /*args*/) + static void forward(Base& base, T0 & geom,T1 const& args) { base.template dispatch(geom, typename boost::is_same::type()); } From d216aa97713be4e616303355da96e584142ac8ee Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 19 Sep 2013 18:30:28 -0700 Subject: [PATCH 109/122] fix compile of styles_model.cpp/mapnik::to_expression_string() by ensuring compile defines are present --- demo/viewer/styles_model.cpp | 3 +-- demo/viewer/viewer.pro | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/demo/viewer/styles_model.cpp b/demo/viewer/styles_model.cpp index 1555eabad..208669ac0 100644 --- a/demo/viewer/styles_model.cpp +++ b/demo/viewer/styles_model.cpp @@ -263,8 +263,7 @@ public: QString name() const { mapnik::expression_ptr filter = rule_.get_filter(); - - return QString("FIXME");//mapnik::to_expression_string((*filter)).c_str()); + return QString(mapnik::to_expression_string(*filter).c_str()); } QIcon icon() const diff --git a/demo/viewer/viewer.pro b/demo/viewer/viewer.pro index 588336387..6607f39ef 100644 --- a/demo/viewer/viewer.pro +++ b/demo/viewer/viewer.pro @@ -6,7 +6,7 @@ QT += core gui widgets QMAKE_CXX = $$system(mapnik-config --cxx) QMAKE_LINK = $$system(mapnik-config --cxx) QMAKE_CXXFLAGS += $$system(mapnik-config --cxxflags) -QMAKE_CXXFLAGS += $$system(mapnik-config --includes --dep-includes) +QMAKE_CXXFLAGS += $$system(mapnik-config --includes --dep-includes --defines) QMAKE_LFLAGS += $$system(mapnik-config --libs) QMAKE_LFLAGS += $$system(mapnik-config --ldflags --dep-libs) QMAKE_LFLAGS += -lboost_timer From f00e85b46f1e9c7b9a9c84315e39cae46e8f41c7 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 19 Sep 2013 18:31:03 -0700 Subject: [PATCH 110/122] QtWidgets is not available in latest release --- demo/viewer/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/viewer/main.cpp b/demo/viewer/main.cpp index 7bd6b3de8..c085d4295 100644 --- a/demo/viewer/main.cpp +++ b/demo/viewer/main.cpp @@ -19,7 +19,7 @@ // qt -#include +#include #include #include #include From 5d12a345aeffc194577ca34cf9ac27fa342ffb0a Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 19 Sep 2013 20:19:01 -0700 Subject: [PATCH 111/122] start using c++11 features: auto/for/unique_ptr/variadic args - refs #1972 --- benchmark/run.cpp | 12 ++--- bindings/python/mapnik_geometry.cpp | 13 ++--- bindings/python/mapnik_image.cpp | 6 +-- bindings/python/mapnik_query.cpp | 7 +-- bindings/python/mapnik_style.cpp | 8 ++- bindings/python/python_grid_utils.cpp | 8 +-- include/mapnik/box2d.hpp | 1 + include/mapnik/cairo_context.hpp | 2 +- include/mapnik/factory.hpp | 41 +++------------- include/mapnik/feature.hpp | 17 +++---- .../mapnik/feature_style_processor_impl.hpp | 49 +++++++++---------- include/mapnik/font_engine_freetype.hpp | 4 +- include/mapnik/geometry.hpp | 37 ++++++++------ include/mapnik/grid/grid_marker_helpers.hpp | 9 ++-- include/mapnik/hit_test_filter.hpp | 4 +- include/mapnik/image_filter.hpp | 4 +- include/mapnik/image_reader.hpp | 7 ++- .../json/geometry_generator_grammar.hpp | 18 +++---- include/mapnik/marker_helpers.hpp | 14 +++--- include/mapnik/placement_finder.hpp | 4 +- include/mapnik/polygon_clipper.hpp | 10 ++-- include/mapnik/rule_cache.hpp | 32 ++++++++---- include/mapnik/svg/svg_renderer_agg.hpp | 4 +- include/mapnik/symbolizer_hash.hpp | 4 +- include/mapnik/transform_processor.hpp | 8 +-- .../mapnik/util/geometry_svg_generator.hpp | 6 +-- include/mapnik/util/geometry_to_wkb.hpp | 44 ++++++++--------- .../mapnik/util/geometry_wkt_generator.hpp | 7 +-- include/mapnik/value.hpp | 17 ++++++- include/mapnik/vertex_converters.hpp | 33 +++---------- include/mapnik/vertex_vector.hpp | 2 +- include/mapnik/wkt/wkt_grammar.hpp | 12 ++--- plugins/input/csv/csv_datasource.cpp | 2 +- plugins/input/gdal/gdal_featureset.cpp | 2 +- plugins/input/geojson/geojson_datasource.cpp | 4 +- plugins/input/occi/occi_featureset.cpp | 4 +- plugins/input/occi/occi_featureset.hpp | 2 +- plugins/input/ogr/ogr_converter.cpp | 12 ++--- plugins/input/osm/osm_datasource.cpp | 7 ++- plugins/input/osm/osm_featureset.cpp | 6 +-- plugins/input/postgis/postgis_featureset.hpp | 1 - plugins/input/python/python_datasource.cpp | 6 +-- plugins/input/raster/raster_datasource.cpp | 2 +- plugins/input/raster/raster_featureset.cpp | 2 +- plugins/input/shape/shape_featureset.cpp | 8 +-- .../input/shape/shape_index_featureset.cpp | 8 +-- plugins/input/shape/shape_io.cpp | 12 ++--- src/agg/agg_renderer.cpp | 4 +- src/agg/process_building_symbolizer.cpp | 6 +-- src/agg/process_line_pattern_symbolizer.cpp | 4 +- src/agg/process_line_symbolizer.cpp | 6 +-- src/agg/process_markers_symbolizer.cpp | 16 +++--- .../process_polygon_pattern_symbolizer.cpp | 4 +- src/agg/process_polygon_symbolizer.cpp | 4 +- src/box2d.cpp | 7 +++ src/cairo_renderer.cpp | 44 ++++++++--------- src/deepcopy.cpp | 8 +-- src/feature_type_style.cpp | 4 +- src/font_engine_freetype.cpp | 6 +-- src/font_set.cpp | 2 +- src/formatting/list.cpp | 13 +++-- src/grid/process_building_symbolizer.cpp | 6 +-- src/grid/process_line_symbolizer.cpp | 5 +- src/grid/process_markers_symbolizer.cpp | 12 ++--- .../process_polygon_pattern_symbolizer.cpp | 5 +- src/grid/process_polygon_symbolizer.cpp | 5 +- src/image_reader.cpp | 26 ++-------- src/image_util.cpp | 6 +-- src/json/geometry_grammar.cpp | 6 +-- src/marker_cache.cpp | 2 +- src/parse_path.cpp | 12 ++--- src/placement_finder.cpp | 34 ++++++------- src/svg/output/process_symbolizers.cpp | 2 +- src/svg/svg_parser.cpp | 6 +-- src/symbolizer_helpers.cpp | 6 +-- src/transform_expression.cpp | 4 +- src/webp_reader.cpp | 12 +++-- src/wkb.cpp | 24 ++++----- src/wkt/wkt_generator.cpp | 12 ++--- tests/cpp_tests/clipping_test.cpp | 4 +- tests/cpp_tests/fontset_runtime_test.cpp | 2 +- tests/cpp_tests/geometry_converters_test.cpp | 16 +++--- tests/cpp_tests/image_io_test.cpp | 20 ++++---- tests/cpp_tests/label_algo_test.cpp | 4 +- tests/cpp_tests/map_request_test.cpp | 8 +-- utils/geometry_to_wkb/main.cpp | 6 +-- 86 files changed, 431 insertions(+), 464 deletions(-) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index 29b4ba235..061bcb6e6 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -93,7 +93,7 @@ void benchmark(T & test_runner, std::string const& name) bool compare_images(std::string const& src_fn,std::string const& dest_fn) { - std::auto_ptr reader1(mapnik::get_image_reader(dest_fn,"png")); + std::unique_ptr reader1(mapnik::get_image_reader(dest_fn,"png")); if (!reader1.get()) { throw mapnik::image_reader_exception("Failed to load: " + dest_fn); @@ -101,7 +101,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn) boost::shared_ptr image_ptr1 = boost::make_shared(reader1->width(),reader1->height()); reader1->read(0,0,image_ptr1->data()); - std::auto_ptr reader2(mapnik::get_image_reader(src_fn,"png")); + std::unique_ptr reader2(mapnik::get_image_reader(src_fn,"png")); if (!reader2.get()) { throw mapnik::image_reader_exception("Failed to load: " + src_fn); @@ -163,7 +163,7 @@ struct test2 im_() { std::string filename("./benchmark/data/multicolor.png"); - std::auto_ptr reader(mapnik::get_image_reader(filename,"png")); + std::unique_ptr reader(mapnik::get_image_reader(filename,"png")); if (!reader.get()) { throw mapnik::image_reader_exception("Failed to load: " + filename); @@ -450,7 +450,7 @@ struct test11 ps.close_polygon(); for (unsigned i=0;i envelope_impl(path_type & p) { mapnik::box2d b; bool first = true; - BOOST_FOREACH(mapnik::geometry_type const& geom, p) + for (mapnik::geometry_type const& geom : p) { if (first) { @@ -232,6 +232,7 @@ std::string to_geojson( path_type const& geom) std::string to_svg( geometry_type const& geom) { + #if BOOST_VERSION >= 104700 std::string svg; // Use Python String directly ? bool result = mapnik::util::to_svg(svg,geom); @@ -269,10 +270,10 @@ void export_geometry() { using namespace boost::python; - enum_("GeometryType") - .value("Point",mapnik::Point) - .value("LineString",mapnik::LineString) - .value("Polygon",mapnik::Polygon) + enum_("GeometryType") + .value("Point",mapnik::geometry_type::types::Point) + .value("LineString",mapnik::geometry_type::types::LineString) + .value("Polygon",mapnik::geometry_type::types::Polygon) ; #if BOOST_VERSION >= 104700 @@ -283,7 +284,7 @@ void export_geometry() #endif using mapnik::geometry_type; - class_, boost::noncopyable>("Geometry2d",no_init) + class_, boost::noncopyable>("Geometry2d",no_init) .def("envelope",&geometry_type::envelope) // .def("__str__",&geometry_type::to_string) .def("type",&geometry_type::type) diff --git a/bindings/python/mapnik_image.cpp b/bindings/python/mapnik_image.cpp index 5b3db5e9e..884f1324a 100644 --- a/bindings/python/mapnik_image.cpp +++ b/bindings/python/mapnik_image.cpp @@ -151,7 +151,7 @@ boost::shared_ptr open_from_file(std::string const& filename) boost::optional type = type_from_filename(filename); if (type) { - std::auto_ptr reader(get_image_reader(filename,*type)); + std::unique_ptr reader(get_image_reader(filename,*type)); if (reader.get()) { @@ -166,7 +166,7 @@ boost::shared_ptr open_from_file(std::string const& filename) boost::shared_ptr fromstring(std::string const& str) { - std::auto_ptr reader(get_image_reader(str.c_str(),str.size())); + std::unique_ptr reader(get_image_reader(str.c_str(),str.size())); if (reader.get()) { boost::shared_ptr image_ptr = boost::make_shared(reader->width(),reader->height()); @@ -182,7 +182,7 @@ boost::shared_ptr frombuffer(PyObject * obj) Py_ssize_t buffer_len; if (PyObject_AsReadBuffer(obj, &buffer, &buffer_len) == 0) { - std::auto_ptr reader(get_image_reader(reinterpret_cast(buffer),buffer_len)); + std::unique_ptr reader(get_image_reader(reinterpret_cast(buffer),buffer_len)); if (reader.get()) { boost::shared_ptr image_ptr = boost::make_shared(reader->width(),reader->height()); diff --git a/bindings/python/mapnik_query.cpp b/bindings/python/mapnik_query.cpp index 3c6138a23..a991f2e12 100644 --- a/bindings/python/mapnik_query.cpp +++ b/bindings/python/mapnik_query.cpp @@ -22,7 +22,7 @@ // boost #include -#include + // mapnik #include @@ -55,7 +55,7 @@ struct names_to_list static PyObject* convert(std::set const& names) { boost::python::list l; - BOOST_FOREACH( std::string const& name, names ) + for ( std::string const& name : names ) { l.append(name); } @@ -86,6 +86,3 @@ void export_query() return_value_policy()) ) .def("add_property_name", &query::add_property_name); } - - - diff --git a/bindings/python/mapnik_style.cpp b/bindings/python/mapnik_style.cpp index 7eb9e449b..cbf032bf3 100644 --- a/bindings/python/mapnik_style.cpp +++ b/bindings/python/mapnik_style.cpp @@ -45,13 +45,17 @@ std::string get_image_filters(feature_type_style & style) void set_image_filters(feature_type_style & style, std::string const& filters) { std::vector new_filters; - bool result = parse_image_filters(filters, new_filters); if (!result) { throw mapnik::value_error("failed to parse image-filters: '" + filters + "'"); } - style.image_filters().swap(new_filters); +#ifdef _WINDOWS + style.image_filters() = new_filters; + // FIXME : https://svn.boost.org/trac/boost/ticket/2839 +#else + style.image_filters() = std::move(new_filters); +#endif } void export_style() diff --git a/bindings/python/python_grid_utils.cpp b/bindings/python/python_grid_utils.cpp index 7e9e1e52f..d2b03275c 100644 --- a/bindings/python/python_grid_utils.cpp +++ b/bindings/python/python_grid_utils.cpp @@ -25,7 +25,7 @@ // boost #include #include -#include + // mapnik #include @@ -245,7 +245,7 @@ void write_features(T const& grid_type, std::set const& attributes = grid_type.property_names(); typename T::feature_type::const_iterator feat_end = g_features.end(); - BOOST_FOREACH ( std::string const& key_item, key_order ) + for ( std::string const& key_item :key_order ) { if (key_item.empty()) { @@ -261,7 +261,7 @@ void write_features(T const& grid_type, bool found = false; boost::python::dict feat; mapnik::feature_ptr feature = feat_itr->second; - BOOST_FOREACH ( std::string const& attr, attributes ) + for ( std::string const& attr : attributes ) { if (attr == "__id__") { @@ -305,7 +305,7 @@ void grid_encode_utf(T const& grid_type, // convert key order to proper python list boost::python::list keys_a; - BOOST_FOREACH ( typename T::lookup_type const& key_id, key_order ) + for ( typename T::lookup_type const& key_id : key_order ) { keys_a.append(key_id); } diff --git a/include/mapnik/box2d.hpp b/include/mapnik/box2d.hpp index d37cd81ab..6133ffbe5 100644 --- a/include/mapnik/box2d.hpp +++ b/include/mapnik/box2d.hpp @@ -64,6 +64,7 @@ public: box2d(coord const& c0, coord const& c1); box2d(box2d_type const& rhs); box2d(box2d_type const& rhs, agg::trans_affine const& tr); + box2d(box2d_type&& rhs); box2d_type& operator=(box2d_type other); T minx() const; T miny() const; diff --git a/include/mapnik/cairo_context.hpp b/include/mapnik/cairo_context.hpp index 369edaf94..1011c1b3d 100644 --- a/include/mapnik/cairo_context.hpp +++ b/include/mapnik/cairo_context.hpp @@ -210,7 +210,7 @@ public: units_ = grad.get_units(); - BOOST_FOREACH ( mapnik::stop_pair const& st, grad.get_stop_array() ) + for ( mapnik::stop_pair const& st : grad.get_stop_array() ) { mapnik::color const& stop_color = st.second; double r= static_cast (stop_color.red())/255.0; diff --git a/include/mapnik/factory.hpp b/include/mapnik/factory.hpp index 775329c09..8b1c938fa 100644 --- a/include/mapnik/factory.hpp +++ b/include/mapnik/factory.hpp @@ -31,42 +31,23 @@ #include namespace mapnik { -template -class default_factory_error -{ -public: - struct factory_exception : public std::exception - { - const char* what() const throw() - { - return "unknown object type"; - } - }; - static product_type* on_unknown_type(const key_type&) - { - return 0; - } -}; template < typename product_type, typename key_type, -typename product_creator=product_type* (*)(), -template class factory_error_policy=default_factory_error -> +typename ...Args > class factory : public singleton >, - factory_error_policy + Args...> > { private: + typedef product_type* (*product_creator)(Args...); typedef std::map product_map; product_map map_; public: - bool register_product(const key_type& key,product_creator creator) + bool register_product(key_type const& key, product_creator creator) { return map_.insert(typename product_map::value_type(key,creator)).second; } @@ -76,22 +57,12 @@ public: return map_.erase(key)==1; } - product_type* create_object(const key_type& key,std::string const& file) + product_type* create_object(key_type const& key, Args...args) { typename product_map::const_iterator pos=map_.find(key); if (pos!=map_.end()) { - return (pos->second)(file); - } - return 0; - } - - product_type* create_object(const key_type& key, char const* data, std::size_t size) - { - typename product_map::const_iterator pos=map_.find(key); - if (pos!=map_.end()) - { - return (pos->second)(data, size); + return (pos->second)(args...); } return 0; } diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index ebe5f77e5..067b34cff 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -116,22 +116,22 @@ public: template inline void put(context_type::key_type const& key, T const& val) { - put(key,value(val)); + put(key, std::move(value(val))); } template inline void put_new(context_type::key_type const& key, T const& val) { - put_new(key,value(val)); + put_new(key,std::move(value(val))); } - inline void put(context_type::key_type const& key, value const& val) + inline void put(context_type::key_type const& key, value && val) { context_type::map_type::const_iterator itr = ctx_->mapping_.find(key); if (itr != ctx_->mapping_.end() && itr->second < data_.size()) { - data_[itr->second] = val; + data_[itr->second] = std::move(val); } else { @@ -139,19 +139,19 @@ public: } } - inline void put_new(context_type::key_type const& key, value const& val) + inline void put_new(context_type::key_type const& key, value && val) { context_type::map_type::const_iterator itr = ctx_->mapping_.find(key); if (itr != ctx_->mapping_.end() && itr->second < data_.size()) { - data_[itr->second] = val; + data_[itr->second] = std::move(val); } else { cont_type::size_type index = ctx_->push(key); if (index == data_.size()) - data_.push_back(val); + data_.push_back(std::move(val)); } } @@ -231,9 +231,8 @@ public: // TODO - cache this box2d result; bool first = true; - for (unsigned i=0;i box = geom.envelope(); diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index 76f4f190c..b1c1f4702 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -48,7 +48,7 @@ // boost #include #include -#include +#include // stl #include @@ -148,7 +148,7 @@ void feature_style_processor::apply(double scale_denom) scale_denom = mapnik::scale_denominator(m_.scale(),proj.is_geographic()); scale_denom *= p.scale_factor(); - BOOST_FOREACH ( layer const& lyr, m_.layers() ) + for (auto const& lyr : m_.layers() ) { if (lyr.visible(scale_denom)) { @@ -292,7 +292,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces { // check for styles needing compositing operations applied // https://github.com/mapnik/mapnik/issues/1477 - BOOST_FOREACH(std::string const& style_name, style_names) + for (std::string const& style_name : style_names) { boost::optional style=m_.find_style(style_name); if (!style) @@ -346,10 +346,9 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces query q(layer_ext,res,scale_denom,extent); std::vector active_styles; attribute_collector collector(names); - boost::ptr_vector rule_caches; - + std::vector rule_caches; // iterate through all named styles collecting active styles and attribute names - BOOST_FOREACH(std::string const& style_name, style_names) + for (std::string const& style_name : style_names) { boost::optional style=m_.find_style(style_name); if (!style) @@ -363,19 +362,19 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces std::vector const& rules = style->get_rules(); bool active_rules = false; - std::auto_ptr rc(new rule_cache); - BOOST_FOREACH(rule const& r, rules) + rule_cache cache; + for (auto const& r : rules) { if (r.active(scale_denom)) { - rc->add_rule(r); + cache.add_rule(r); active_rules = true; collector(r); } } if (active_rules) { - rule_caches.push_back(rc); + rule_caches.push_back(std::move(cache)); active_styles.push_back(&(*style)); } } @@ -386,14 +385,14 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces if (p.attribute_collection_policy() == COLLECT_ALL) { layer_descriptor lay_desc = ds->get_descriptor(); - BOOST_FOREACH(attribute_descriptor const& desc, lay_desc.get_descriptors()) + for (attribute_descriptor const& desc : lay_desc.get_descriptors()) { q.add_property_name(desc.get_name()); } } else { - BOOST_FOREACH(std::string const& name, names) + for (std::string const& name : names) { q.add_property_name(name); } @@ -424,7 +423,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces // We're at a value boundary, so render what we have // up to this point. int i = 0; - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { cache->prepare(); render_style(p, style, rule_caches[i], cache, prj_trans); @@ -437,7 +436,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces } int i = 0; - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { cache->prepare(); render_style(p, style, rule_caches[i], cache, prj_trans); @@ -458,11 +457,10 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces } } int i = 0; - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { cache->prepare(); - render_style(p, style, rule_caches[i], cache, prj_trans); - i++; + render_style(p, style, rule_caches[i++], cache, prj_trans); } cache->clear(); } @@ -470,10 +468,9 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces else { int i = 0; - BOOST_FOREACH (feature_type_style const* style, active_styles) + for (feature_type_style const* style : active_styles) { - render_style(p, style, rule_caches[i], ds->features(q), prj_trans); - i++; + render_style(p, style, rule_caches[i++], ds->features(q), prj_trans); } } } @@ -501,7 +498,7 @@ void feature_style_processor::render_style( { bool do_else = true; bool do_also = false; - BOOST_FOREACH(rule const* r, rc.get_if_rules() ) + for (rule const* r : rc.get_if_rules() ) { expression_ptr const& expr=r->get_filter(); value_type result = boost::apply_visitor(evaluate(*feature),*expr); @@ -513,7 +510,7 @@ void feature_style_processor::render_style( rule::symbolizers const& symbols = r->get_symbolizers(); if(!p.process(symbols,*feature,prj_trans)) { - BOOST_FOREACH (symbolizer const& sym, symbols) + for (symbolizer const& sym : symbols) { boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym); } @@ -528,13 +525,13 @@ void feature_style_processor::render_style( } if (do_else) { - BOOST_FOREACH( rule const* r, rc.get_else_rules() ) + for (rule const* r : rc.get_else_rules() ) { was_painted = true; rule::symbolizers const& symbols = r->get_symbolizers(); if(!p.process(symbols,*feature,prj_trans)) { - BOOST_FOREACH (symbolizer const& sym, symbols) + for (symbolizer const& sym : symbols) { boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym); } @@ -543,13 +540,13 @@ void feature_style_processor::render_style( } if (do_also) { - BOOST_FOREACH( rule const* r, rc.get_also_rules() ) + for ( rule const* r : rc.get_also_rules() ) { was_painted = true; rule::symbolizers const& symbols = r->get_symbolizers(); if(!p.process(symbols,*feature,prj_trans)) { - BOOST_FOREACH (symbolizer const& sym, symbols) + for (symbolizer const& sym : symbols) { boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym); } diff --git a/include/mapnik/font_engine_freetype.hpp b/include/mapnik/font_engine_freetype.hpp index 8e0e846ee..29a0bae12 100644 --- a/include/mapnik/font_engine_freetype.hpp +++ b/include/mapnik/font_engine_freetype.hpp @@ -42,7 +42,7 @@ #include #include #include -#include + #ifdef MAPNIK_THREADSAFE #include #endif @@ -191,7 +191,7 @@ public: { std::vector const& names = fset.get_face_names(); face_set_ptr face_set = boost::make_shared(); - BOOST_FOREACH( std::string const& name, names) + for ( std::string const& name : names) { face_ptr face = get_face(name); if (face) diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index c3f616f5f..1db96e0c6 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -34,25 +34,29 @@ namespace mapnik { -enum eGeomType { - Unknown = 0, - Point = 1, - LineString = 2, - Polygon = 3 -}; - template class Container=vertex_vector> class geometry : private mapnik::noncopyable { + public: + static const std::uint8_t geometry_bits = 7; + enum types : std::uint8_t + { + Unknown = 0x00, + Point = 0x01, + LineString = 0x02, + Polygon = 0x03, + PolygonExterior = Polygon, + PolygonInterior = Polygon | ( 1 << geometry_bits) + }; typedef T coord_type; typedef Container container_type; typedef typename container_type::value_type value_type; typedef typename container_type::size_type size_type; private: container_type cont_; - eGeomType type_; - mutable unsigned itr_; + types type_; + mutable size_type itr_; public: geometry() @@ -60,17 +64,22 @@ public: itr_(0) {} - explicit geometry(eGeomType type) + explicit geometry(types type) : type_(type), itr_(0) {} - eGeomType type() const + types type() const { - return type_; + return static_cast(type_ & types::Polygon); } - void set_type(eGeomType type) + bool interior() const + { + return static_cast(type_ >> geometry_bits); + } + + void set_type(types type) { type_ = type; } @@ -91,7 +100,7 @@ public: double x = 0; double y = 0; rewind(0); - for (unsigned i=0; i < size(); ++i) + for (size_type i = 0; i < size(); ++i) { unsigned cmd = vertex(&x,&y); if (cmd == SEG_CLOSE) continue; diff --git a/include/mapnik/grid/grid_marker_helpers.hpp b/include/mapnik/grid/grid_marker_helpers.hpp index 5acb73a5d..0d1b0bb2e 100644 --- a/include/mapnik/grid/grid_marker_helpers.hpp +++ b/include/mapnik/grid/grid_marker_helpers.hpp @@ -79,11 +79,11 @@ struct raster_markers_rasterizer_dispatch_grid marker_placement_e placement_method = sym_.get_marker_placement(); box2d bbox_(0,0, src_.width(),src_.height()); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -216,11 +216,11 @@ struct vector_markers_rasterizer_dispatch_grid { marker_placement_e placement_method = sym_.get_marker_placement(); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -294,4 +294,3 @@ private: } #endif - diff --git a/include/mapnik/hit_test_filter.hpp b/include/mapnik/hit_test_filter.hpp index b9c1f6a6b..cb9c6f1ec 100644 --- a/include/mapnik/hit_test_filter.hpp +++ b/include/mapnik/hit_test_filter.hpp @@ -27,7 +27,7 @@ #include #include // boost -#include + namespace mapnik { class hit_test_filter @@ -40,7 +40,7 @@ public: bool pass(feature_impl & feature) { - BOOST_FOREACH(geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (label::hit_test(geom, x_,y_,tol_)) return true; diff --git a/include/mapnik/image_filter.hpp b/include/mapnik/image_filter.hpp index 4d41ea4a6..0b349cf85 100644 --- a/include/mapnik/image_filter.hpp +++ b/include/mapnik/image_filter.hpp @@ -32,7 +32,7 @@ #include #include #include -#include + // agg #include "agg_basics.h" @@ -418,7 +418,7 @@ void apply_filter(Src & src, colorize_alpha const& op) double step = 1.0/(size-1); double offset = 0.0; - BOOST_FOREACH( mapnik::filter::color_stop const& stop, op) + for ( mapnik::filter::color_stop const& stop : op) { mapnik::color const& c = stop.color; double stop_offset = stop.offset; diff --git a/include/mapnik/image_reader.hpp b/include/mapnik/image_reader.hpp index c30d1da6f..a3a6545e7 100644 --- a/include/mapnik/image_reader.hpp +++ b/include/mapnik/image_reader.hpp @@ -62,8 +62,11 @@ struct MAPNIK_DECL image_reader : private mapnik::noncopyable virtual ~image_reader() {} }; -bool register_image_reader(std::string const& type,image_reader* (*)(std::string const&)); -bool register_image_reader(std::string const& type,image_reader* (*)(char const*, std::size_t)); +template +bool register_image_reader(std::string const& type, image_reader* (* fun)(Args...)) +{ + return factory::instance().register_product(type, fun); +} MAPNIK_DECL image_reader* get_image_reader(std::string const& file,std::string const& type); MAPNIK_DECL image_reader* get_image_reader(std::string const& file); diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index 3a57b1a78..27d5acab0 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -207,17 +207,17 @@ struct geometry_generator_grammar : coordinates = point | linestring | polygon ; - point = &uint_(mapnik::Point)[_1 = _type(_val)] + point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)] << point_coord [_1 = _first(_val)] ; - linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] + linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)] << lit('[') << coords << lit(']') ; - polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)] + polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)] << lit('[') << coords2 << lit("]]") @@ -284,12 +284,12 @@ struct multi_geometry_generator_grammar : using boost::spirit::karma::_r1; geometry_types.add - (mapnik::Point,"\"Point\"") - (mapnik::LineString,"\"LineString\"") - (mapnik::Polygon,"\"Polygon\"") - (mapnik::Point + 3,"\"MultiPoint\"") - (mapnik::LineString + 3,"\"MultiLineString\"") - (mapnik::Polygon + 3,"\"MultiPolygon\"") + (mapnik::geometry_type::types::Point,"\"Point\"") + (mapnik::geometry_type::types::LineString,"\"LineString\"") + (mapnik::geometry_type::types::Polygon,"\"Polygon\"") + (mapnik::geometry_type::types::Point + 3,"\"MultiPoint\"") + (mapnik::geometry_type::types::LineString + 3,"\"MultiLineString\"") + (mapnik::geometry_type::types::Polygon + 3,"\"MultiPolygon\"") ; start %= ( eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)] diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index f5bcce8fe..008386552 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -94,11 +94,11 @@ struct vector_markers_rasterizer_dispatch marker_placement_e placement_method = sym_.get_marker_placement(); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == mapnik::geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == mapnik::geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -206,11 +206,11 @@ struct raster_markers_rasterizer_dispatch box2d bbox_(0,0, src_.width(),src_.height()); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == mapnik::geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == mapnik::geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -477,7 +477,7 @@ void apply_markers_multi(feature_impl & feature, Converter& converter, markers_s double x, y; if (label::centroid_geoms(feature.paths().begin(), feature.paths().end(), x, y)) { - geometry_type pt(Point); + geometry_type pt(geometry_type::types::Point); pt.move_to(x, y); // unset any clipping since we're now dealing with a point converter.template unset(); @@ -491,7 +491,7 @@ void apply_markers_multi(feature_impl & feature, Converter& converter, markers_s // TODO: consider using true area for polygon types double maxarea = 0; geometry_type* largest = 0; - BOOST_FOREACH(geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { const box2d& env = geom.envelope(); double area = env.width() * env.height(); @@ -512,7 +512,7 @@ void apply_markers_multi(feature_impl & feature, Converter& converter, markers_s { MAPNIK_LOG_WARN(marker_symbolizer) << "marker_multi_policy != 'each' has no effect with marker_placement != 'point'"; } - BOOST_FOREACH(geometry_type & path, feature.paths()) + for (geometry_type & path : feature.paths()) { converter.apply(path); } diff --git a/include/mapnik/placement_finder.hpp b/include/mapnik/placement_finder.hpp index 8caa3ef70..7f43fab7c 100644 --- a/include/mapnik/placement_finder.hpp +++ b/include/mapnik/placement_finder.hpp @@ -100,14 +100,14 @@ private: // otherwise it will autodetect the orientation. // If >= 50% of the characters end up upside down, it will be retried the other way. // RETURN: 1/-1 depending which way up the string ends up being. - std::auto_ptr get_placement_offset(std::vector const& path_positions, + std::unique_ptr get_placement_offset(std::vector const& path_positions, std::vector const& path_distances, int & orientation, std::size_t index, double distance); ///Tests whether the given text_path be placed without a collision // Returns true if it can // NOTE: This edits p.envelopes so it can be used afterwards (you must clear it otherwise) - bool test_placement(std::auto_ptr const& current_placement, int orientation); + bool test_placement(std::unique_ptr const& current_placement, int orientation); ///Does a line-circle intersect calculation // NOTE: Follow the strict pre conditions diff --git a/include/mapnik/polygon_clipper.hpp b/include/mapnik/polygon_clipper.hpp index 7bcb65b85..8d4284a4d 100644 --- a/include/mapnik/polygon_clipper.hpp +++ b/include/mapnik/polygon_clipper.hpp @@ -31,7 +31,7 @@ #include // boost -#include + #include #include #include @@ -189,10 +189,10 @@ private: std::cerr << ex.what() << std::endl; } - BOOST_FOREACH(polygon_2d const& poly, clipped_polygons) + for (polygon_2d const& poly : clipped_polygons) { bool move_to = true; - BOOST_FOREACH(point_2d const& c, boost::geometry::exterior_ring(poly)) + for (point_2d const& c : boost::geometry::exterior_ring(poly)) { if (move_to) { @@ -206,10 +206,10 @@ private: } output_.close_path(); // interior rings - BOOST_FOREACH(polygon_2d::inner_container_type::value_type const& ring, boost::geometry::interior_rings(poly)) + for (polygon_2d::inner_container_type::value_type const& ring : boost::geometry::interior_rings(poly)) { move_to = true; - BOOST_FOREACH(point_2d const& c, ring) + for (point_2d const& c : ring) { if (move_to) { diff --git a/include/mapnik/rule_cache.hpp b/include/mapnik/rule_cache.hpp index cff26b82b..32f7b4423 100644 --- a/include/mapnik/rule_cache.hpp +++ b/include/mapnik/rule_cache.hpp @@ -27,10 +27,6 @@ #include #include #include - -// boost -#include - // stl #include @@ -39,12 +35,30 @@ namespace mapnik class rule_cache : private noncopyable { +private: + //latest MS compiler (VC++ 2012 november CTP) doesn't support deleting functions + //rule_cache(rule_cache const& other) = delete; // no copy ctor + //rule_cache& operator=(rule_cache const& other) = delete; // no assignment op public: typedef std::vector rule_ptrs; rule_cache() - : if_rules_(), - else_rules_(), - also_rules_() {} + : if_rules_(), + else_rules_(), + also_rules_() {} + + rule_cache(rule_cache && rhs) // move ctor + : if_rules_(std::move(rhs.if_rules_)), + else_rules_(std::move(rhs.else_rules_)), + also_rules_(std::move(rhs.also_rules_)) + {} + + rule_cache& operator=(rule_cache && rhs) // move assign + { + std::swap(if_rules_, rhs.if_rules_); + std::swap(else_rules_,rhs.else_rules_); + std::swap(also_rules_, rhs.also_rules_); + return *this; + } void add_rule(rule const& r) { @@ -66,12 +80,12 @@ public: { return if_rules_; } - + rule_ptrs const& get_else_rules() const { return else_rules_; } - + rule_ptrs const& get_also_rules() const { return also_rules_; diff --git a/include/mapnik/svg/svg_renderer_agg.hpp b/include/mapnik/svg/svg_renderer_agg.hpp index cf76e0a99..9ddd0e7b2 100644 --- a/include/mapnik/svg/svg_renderer_agg.hpp +++ b/include/mapnik/svg/svg_renderer_agg.hpp @@ -35,7 +35,7 @@ #include // boost -#include + // agg #include "agg_path_storage.h" @@ -142,7 +142,7 @@ public: grad.get_control_points(x1,y1,x2,y2,radius); m_gradient_lut.remove_all(); - BOOST_FOREACH ( mapnik::stop_pair const& st, grad.get_stop_array() ) + for ( mapnik::stop_pair const& st : grad.get_stop_array() ) { mapnik::color const& stop_color = st.second; unsigned r = stop_color.red(); diff --git a/include/mapnik/symbolizer_hash.hpp b/include/mapnik/symbolizer_hash.hpp index db89ff8a9..2b34f4b44 100644 --- a/include/mapnik/symbolizer_hash.hpp +++ b/include/mapnik/symbolizer_hash.hpp @@ -41,7 +41,7 @@ struct symbolizer_hash // specialisation for polygon_symbolizer static std::size_t value(polygon_symbolizer const& sym) { - std::size_t seed = Polygon; + std::size_t seed = geometry_type::types::Polygon; boost::hash_combine(seed, sym.get_fill().rgba()); boost::hash_combine(seed, sym.get_opacity()); return seed; @@ -50,7 +50,7 @@ struct symbolizer_hash // specialisation for line_symbolizer static std::size_t value(line_symbolizer const& sym) { - std::size_t seed = LineString; + std::size_t seed = geometry_type::types::LineString; boost::hash_combine(seed, sym.get_stroke().get_color().rgba()); boost::hash_combine(seed, sym.get_stroke().get_width()); boost::hash_combine(seed, sym.get_stroke().get_opacity()); diff --git a/include/mapnik/transform_processor.hpp b/include/mapnik/transform_processor.hpp index d720c4350..71cfb42e0 100644 --- a/include/mapnik/transform_processor.hpp +++ b/include/mapnik/transform_processor.hpp @@ -33,10 +33,10 @@ #include // boost -#include + #include #include - +#include // agg #include @@ -190,7 +190,7 @@ struct transform_processor { attribute_collector collect(names); - BOOST_FOREACH (transform_node const& node, list) + for (transform_node const& node : list) { boost::apply_visitor(collect, *node); } @@ -205,7 +205,7 @@ struct transform_processor MAPNIK_LOG_DEBUG(transform) << "transform: begin with " << to_string(matrix_node(tr)); #endif - BOOST_REVERSE_FOREACH (transform_node const& node, list) + for (transform_node const& node : boost::adaptors::reverse(list)) { boost::apply_visitor(eval, *node); #ifdef MAPNIK_LOG diff --git a/include/mapnik/util/geometry_svg_generator.hpp b/include/mapnik/util/geometry_svg_generator.hpp index 9fec4ae65..150bf6ccf 100644 --- a/include/mapnik/util/geometry_svg_generator.hpp +++ b/include/mapnik/util/geometry_svg_generator.hpp @@ -175,7 +175,7 @@ namespace mapnik { namespace util { svg = point | linestring | polygon ; - point = &uint_(mapnik::Point)[_1 = _type(_val)] + point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)] << svg_point [_1 = _first(_val)] ; @@ -185,11 +185,11 @@ namespace mapnik { namespace util { << lit('\"') ; - linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] + linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)] << lit("d=\"") << svg_path << lit("\"") ; - polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)] + polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)] << lit("d=\"") << svg_path << lit("\"") ; diff --git a/include/mapnik/util/geometry_to_wkb.hpp b/include/mapnik/util/geometry_to_wkb.hpp index 78cff90b3..6aaeb629a 100644 --- a/include/mapnik/util/geometry_to_wkb.hpp +++ b/include/mapnik/util/geometry_to_wkb.hpp @@ -27,14 +27,10 @@ #include #include -// boost -#include -#include -#include - // stl #include #include +#include namespace mapnik { namespace util { @@ -137,17 +133,17 @@ struct wkb_buffer char * data_; }; -typedef boost::shared_ptr wkb_buffer_ptr; +typedef std::unique_ptr wkb_buffer_ptr; template wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order) { assert(g.size() == 1); std::size_t size = 1 + 4 + 8*2 ; // byteOrder + wkbType + Point - wkb_buffer_ptr wkb = boost::make_shared(size); + wkb_buffer_ptr wkb(new wkb_buffer(size)); wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); - int type = static_cast(mapnik::Point); + int type = static_cast(mapnik::geometry_type::types::Point); write(ss,type,4,byte_order); double x = 0; double y = 0; @@ -155,7 +151,7 @@ wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order) write(ss,x,8,byte_order); write(ss,y,8,byte_order); assert(ss.good()); - return wkb; + return std::move(wkb); } template @@ -164,10 +160,10 @@ wkb_buffer_ptr to_line_string_wkb( GeometryType const& g, wkbByteOrder byte_orde unsigned num_points = g.size(); assert(num_points > 1); std::size_t size = 1 + 4 + 4 + 8*2*num_points ; // byteOrder + wkbType + numPoints + Point*numPoints - wkb_buffer_ptr wkb = boost::make_shared(size); + wkb_buffer_ptr wkb(new wkb_buffer(size)); wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); - int type = static_cast(mapnik::LineString); + int type = static_cast(mapnik::geometry_type::types::LineString); write(ss,type,4,byte_order); write(ss,num_points,4,byte_order); double x = 0; @@ -179,7 +175,7 @@ wkb_buffer_ptr to_line_string_wkb( GeometryType const& g, wkbByteOrder byte_orde write(ss,y,8,byte_order); } assert(ss.good()); - return wkb; + return std::move(wkb); } template @@ -212,18 +208,18 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) } } unsigned num_rings = rings.size(); - wkb_buffer_ptr wkb = boost::make_shared(size); + wkb_buffer_ptr wkb(new wkb_buffer(size)); wkb_stream ss(wkb->buffer(), wkb->size()); ss.write(reinterpret_cast(&byte_order),1); - int type = static_cast(mapnik::Polygon); + int type = static_cast(mapnik::geometry_type::types::Polygon); write(ss,type,4,byte_order); write(ss,num_rings,4,byte_order); - BOOST_FOREACH ( linear_ring const& ring, rings) + for ( linear_ring const& ring : rings) { unsigned num_ring_points = ring.size(); write(ss,num_ring_points,4,byte_order); - BOOST_FOREACH ( point_type const& pt, ring) + for ( point_type const& pt : ring) { write(ss,pt.first,8,byte_order); write(ss,pt.second,8,byte_order); @@ -231,7 +227,7 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) } assert(ss.good()); - return wkb; + return std::move(wkb); } template @@ -241,13 +237,13 @@ wkb_buffer_ptr to_wkb(GeometryType const& g, wkbByteOrder byte_order ) switch (g.type()) { - case mapnik::Point: + case mapnik::geometry_type::types::Point: wkb = to_point_wkb(g, byte_order); break; - case mapnik::LineString: + case mapnik::geometry_type::types::LineString: wkb = to_line_string_wkb(g, byte_order); break; - case mapnik::Polygon: + case mapnik::geometry_type::types::Polygon: wkb = to_polygon_wkb(g, byte_order); break; default: @@ -281,21 +277,21 @@ wkb_buffer_ptr to_wkb(geometry_container const& paths, wkbByteOrder byte_order ) if (multi_type > 0 && multi_type != itr->type()) collection = true; multi_type = type; - wkb_cont.push_back(wkb); + wkb_cont.push_back(std::move(wkb)); } - wkb_buffer_ptr multi_wkb = boost::make_shared(multi_size); + wkb_buffer_ptr multi_wkb( new wkb_buffer(multi_size)); wkb_stream ss(multi_wkb->buffer(), multi_wkb->size()); ss.write(reinterpret_cast(&byte_order),1); multi_type = collection ? 7 : multi_type + 3; write(ss,multi_type, 4, byte_order); write(ss,paths.size(),4,byte_order); - BOOST_FOREACH ( wkb_buffer_ptr const& wkb, wkb_cont) + for ( wkb_buffer_ptr const& wkb : wkb_cont) { ss.write(wkb->buffer(),wkb->size()); } - return multi_wkb; + return std::move(multi_wkb); } return wkb_buffer_ptr(); diff --git a/include/mapnik/util/geometry_wkt_generator.hpp b/include/mapnik/util/geometry_wkt_generator.hpp index d1ee75902..74dd1be70 100644 --- a/include/mapnik/util/geometry_wkt_generator.hpp +++ b/include/mapnik/util/geometry_wkt_generator.hpp @@ -39,8 +39,6 @@ #include #include -#include // trunc to avoid needing C++11 - namespace boost { namespace spirit { namespace traits { // make gcc and darwin toolsets happy. @@ -148,9 +146,8 @@ struct wkt_coordinate_policy : karma::real_policies static unsigned precision(T n) { if (n == 0.0) return 0; - return 6; - //using namespace boost::spirit; // for traits - //return std::max(6u, static_cast(15 - boost::math::trunc(log10(traits::get_absolute_value(n))))); + using namespace boost::spirit; + return static_cast(14 - std::trunc(std::log10(traits::get_absolute_value(n)))); } template diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index 18979d8df..0c939498a 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -47,6 +47,15 @@ #include #include +namespace boost { + + template <> + struct has_nothrow_copy + : mpl::true_ + { + }; + +} namespace mapnik { @@ -183,8 +192,9 @@ struct not_equals // back compatibility shim to equate empty string with null for != test // https://github.com/mapnik/mapnik/issues/1859 // TODO - consider removing entire specialization at Mapnik 3.x - bool operator() (value_null /*lhs*/, value_unicode_string const& rhs) const + bool operator() (value_null lhs, value_unicode_string const& rhs) const { + boost::ignore_unused_variable_warning(lhs); if (rhs.isEmpty()) return false; return true; } @@ -811,7 +821,7 @@ class value friend const value operator%(value const&,value const&); public: - value () + value () noexcept //-- comment out for VC++11 : base_(value_null()) {} value(value_integer val) @@ -840,6 +850,9 @@ public: return *this; } + value( value && other) noexcept + : base_(std::move(other.base_)) {} + bool operator==(value const& other) const { return boost::apply_visitor(impl::equals(),base_,other.base_); diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index 1d7d4b26f..65d85bfa7 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -51,6 +51,7 @@ #include #include #include +#include // agg #include "agg_conv_clip_polygon.h" @@ -60,7 +61,6 @@ #include "agg_conv_stroke.h" #include "agg_conv_dash.h" #include "agg_conv_transform.h" -#include "agg_conv_clipper.h" #include "agg_path_storage.h" // stl @@ -71,7 +71,6 @@ namespace mapnik { struct transform_tag {}; struct clip_line_tag {}; struct clip_poly_tag {}; -struct clipper_tag {}; struct close_poly_tag {}; struct smooth_tag {}; struct simplify_tag {}; @@ -88,7 +87,7 @@ struct converter_traits typedef T0 geometry_type; typedef geometry_type conv_type; template - static void setup(geometry_type & /*geom*/, Args const& /*args*/) + static void setup(geometry_type & , Args const& ) { throw std::runtime_error("invalid call to setup"); } @@ -183,32 +182,12 @@ template struct converter_traits { typedef T geometry_type; - typedef typename agg::conv_clip_polygon conv_type; + typedef mapnik::polygon_clipper conv_type; template static void setup(geometry_type & geom, Args const& args) { typename boost::mpl::at >::type box = boost::fusion::at_c<0>(args); - geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy()); - } -}; - -template -struct converter_traits -{ - typedef T geometry_type; - typedef typename agg::conv_clipper conv_type; - template - static void setup(geometry_type & geom, Args const& args) - { - typename boost::mpl::at >::type box = boost::fusion::at_c<0>(args); - agg::path_storage * ps = new agg::path_storage(); // FIXME: this will leak memory! - ps->move_to(box.minx(),box.miny()); - ps->line_to(box.minx(),box.maxy()); - ps->line_to(box.maxx(),box.maxy()); - ps->line_to(box.maxx(),box.miny()); - ps->close_polygon(); - geom.attach2(*ps, agg::clipper_non_zero); - //geom.reverse(true); + geom.set_clip_box(box); } }; @@ -218,7 +197,7 @@ struct converter_traits typedef T geometry_type; typedef typename agg::conv_close_polygon conv_type; template - static void setup(geometry_type & /*geom*/, Args const& /*args*/) + static void setup(geometry_type & , Args const&) { // no-op } @@ -293,7 +272,7 @@ template <> struct converter_fwd { template - static void forward(Base& base, T0 & geom,T1 const& /*args*/) + static void forward(Base& base, T0 & geom,T1 const& args) { base.template dispatch(geom, typename boost::is_same::type()); } diff --git a/include/mapnik/vertex_vector.hpp b/include/mapnik/vertex_vector.hpp index 836628cd6..82b878f7a 100644 --- a/include/mapnik/vertex_vector.hpp +++ b/include/mapnik/vertex_vector.hpp @@ -55,7 +55,7 @@ public: // required for iterators support typedef boost::tuple value_type; typedef std::size_t size_type; - typedef unsigned char command_size; + typedef std::uint8_t command_size; private: unsigned num_blocks_; unsigned max_blocks_; diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index ff233d65d..09d634531 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -113,7 +113,7 @@ namespace mapnik { namespace wkt { ; // ::= point - point_tagged_text = no_case[lit("POINT")] [ _a = new_(Point) ] + point_tagged_text = no_case[lit("POINT")] [ _a = new_(geometry_type::types::Point) ] >> ( point_text(_a) [push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false]) ; @@ -124,7 +124,7 @@ namespace mapnik { namespace wkt { ; // ::= linestring - linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(LineString) ] + linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_(geometry_type::types::LineString) ] >> (linestring_text(_a)[push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false]) ; @@ -134,7 +134,7 @@ namespace mapnik { namespace wkt { ; // ::= polygon - polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(Polygon) ] + polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_(geometry_type::types::Polygon) ] >> ( polygon_text(_a)[push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false]) ; @@ -150,7 +150,7 @@ namespace mapnik { namespace wkt { // ::= | { }* multipoint_text = (lit('(') - >> ((eps[_a = new_(Point)] + >> ((eps[_a = new_(geometry_type::types::Point)] >> (point_text(_a) | empty_set) [push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false]) % lit(',')) >> lit(')')) | empty_set @@ -162,7 +162,7 @@ namespace mapnik { namespace wkt { // ::= | { }* multilinestring_text = (lit('(') - >> ((eps[_a = new_(LineString)] + >> ((eps[_a = new_(geometry_type::types::LineString)] >> ( points(_a)[push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false])) % lit(',')) @@ -175,7 +175,7 @@ namespace mapnik { namespace wkt { // ::= | { }* multipolygon_text = (lit('(') - >> ((eps[_a = new_(Polygon)] + >> ((eps[_a = new_(geometry_type::types::Polygon)] >> ( polygon_text(_a)[push_back(_val,_a)] | eps[cleanup_(_a)][_pass = false])) % lit(',')) diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index e1478cd36..db6521115 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -773,7 +773,7 @@ void csv_datasource::parse_csv(T & stream, { if (parsed_x && parsed_y) { - mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point); + mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::geometry_type::types::Point); pt->move_to(x,y); feature->add_geometry(pt); features_.push_back(feature); diff --git a/plugins/input/gdal/gdal_featureset.cpp b/plugins/input/gdal/gdal_featureset.cpp index b87555add..f0804fcbd 100644 --- a/plugins/input/gdal/gdal_featureset.cpp +++ b/plugins/input/gdal/gdal_featureset.cpp @@ -523,7 +523,7 @@ feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt) { // construct feature feature_ptr feature = feature_factory::create(ctx_,1); - geometry_type * point = new geometry_type(mapnik::Point); + geometry_type * point = new geometry_type(mapnik::geometry_type::types::Point); point->move_to(pt.x, pt.y); feature->add_geometry(point); feature->put("value",value); diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index 10e320ef9..62c93a8ea 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -31,7 +31,7 @@ #include #include #include -#include + #include #include #include @@ -140,7 +140,7 @@ geojson_datasource::geojson_datasource(parameters const& params) bool first = true; std::size_t count=0; - BOOST_FOREACH (mapnik::feature_ptr f, features_) + for (mapnik::feature_ptr f : features_) { mapnik::box2d const& box = f->envelope(); if (first) diff --git a/plugins/input/occi/occi_featureset.cpp b/plugins/input/occi/occi_featureset.cpp index fe0455742..1cb0cf4cc 100644 --- a/plugins/input/occi/occi_featureset.cpp +++ b/plugins/input/occi/occi_featureset.cpp @@ -377,7 +377,7 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature) } void occi_featureset::convert_ordinates(mapnik::feature_ptr feature, - const mapnik::eGeomType& geom_type, + const mapnik::geometry::types& geom_type, const std::vector& elem_info, const std::vector& ordinates, const int dimensions, @@ -404,7 +404,7 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature, int next_interp = elem_info[i + 2]; bool is_linear_element = true; bool is_unknown_etype = false; - mapnik::eGeomType gtype = mapnik::Point; + mapnik::geometry::types gtype = mapnik::Point; switch (etype) { diff --git a/plugins/input/occi/occi_featureset.hpp b/plugins/input/occi/occi_featureset.hpp index cb4e7cb9e..e81e24071 100644 --- a/plugins/input/occi/occi_featureset.hpp +++ b/plugins/input/occi/occi_featureset.hpp @@ -55,7 +55,7 @@ public: private: void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature); void convert_ordinates (mapnik::feature_ptr feature, - const mapnik::eGeomType& geom_type, + const mapnik::geometry::types& geom_type, const std::vector& elem_info, const std::vector& ordinates, const int dimensions, diff --git a/plugins/input/ogr/ogr_converter.cpp b/plugins/input/ogr/ogr_converter.cpp index 8892ef1f9..19beeae1d 100644 --- a/plugins/input/ogr/ogr_converter.cpp +++ b/plugins/input/ogr/ogr_converter.cpp @@ -79,21 +79,21 @@ void ogr_converter::convert_geometry(OGRGeometry* geom, feature_ptr feature) void ogr_converter::convert_point(OGRPoint* geom, feature_ptr feature) { - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(geom->getX(), geom->getY()); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); } void ogr_converter::convert_linestring(OGRLineString* geom, feature_ptr feature) { int num_points = geom->getNumPoints(); - std::auto_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::geometry_type::types::LineString)); line->move_to(geom->getX(0), geom->getY(0)); for (int i = 1; i < num_points; ++i) { line->line_to (geom->getX(i), geom->getY(i)); } - feature->paths().push_back(line); + feature->paths().push_back(line.release()); } void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature) @@ -108,7 +108,7 @@ void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature) capacity += interior->getNumPoints(); } - std::auto_ptr poly(new geometry_type(mapnik::Polygon)); + std::unique_ptr poly(new geometry_type(mapnik::geometry_type::types::Polygon)); poly->move_to(exterior->getX(0), exterior->getY(0)); for (int i = 1; i < num_points; ++i) @@ -127,7 +127,7 @@ void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature) } poly->close_path(); } - feature->paths().push_back(poly); + feature->paths().push_back(poly.release()); } void ogr_converter::convert_multipoint(OGRMultiPoint* geom, feature_ptr feature) diff --git a/plugins/input/osm/osm_datasource.cpp b/plugins/input/osm/osm_datasource.cpp index 0a18b4975..6b46bef05 100644 --- a/plugins/input/osm/osm_datasource.cpp +++ b/plugins/input/osm/osm_datasource.cpp @@ -99,14 +99,13 @@ osm_datasource::osm_datasource(const parameters& params) // Add the attributes to the datasource descriptor - assume they are // all of type String - for (std::set::iterator i = keys.begin(); i != keys.end(); i++) + for (auto const& key : keys) { - desc_.add_descriptor(attribute_descriptor(*i, tagtypes.get_type(*i))); + desc_.add_descriptor(attribute_descriptor(key, tagtypes.get_type(key))); } - // Get the bounds of the data and set extent_ accordingly bounds b = osm_data_->get_bounds(); - extent_ = box2d(b.w, b.s, b.e, b.n); + extent_ = box2d(b.w,b.s,b.e,b.n); } osm_datasource::~osm_datasource() diff --git a/plugins/input/osm/osm_featureset.cpp b/plugins/input/osm/osm_featureset.cpp index e72c597ff..db0f62255 100644 --- a/plugins/input/osm/osm_featureset.cpp +++ b/plugins/input/osm/osm_featureset.cpp @@ -65,7 +65,7 @@ feature_ptr osm_featureset::next() feature = feature_factory::create(ctx_, cur_item->id); double lat = static_cast(cur_item)->lat; double lon = static_cast(cur_item)->lon; - geometry_type* point = new geometry_type(mapnik::Point); + geometry_type* point = new geometry_type(mapnik::geometry_type::types::Point); point->move_to(lon, lat); feature->add_geometry(point); } @@ -86,11 +86,11 @@ feature_ptr osm_featureset::next() geometry_type* geom; if (static_cast(cur_item)->is_polygon()) { - geom = new geometry_type(mapnik::Polygon); + geom = new geometry_type(mapnik::geometry_type::types::Polygon); } else { - geom = new geometry_type(mapnik::LineString); + geom = new geometry_type(mapnik::geometry_type::types::LineString); } geom->move_to(static_cast(cur_item)->nodes[0]->lon, diff --git a/plugins/input/postgis/postgis_featureset.hpp b/plugins/input/postgis/postgis_featureset.hpp index e4ead4ab6..69f1963f1 100644 --- a/plugins/input/postgis/postgis_featureset.hpp +++ b/plugins/input/postgis/postgis_featureset.hpp @@ -1,4 +1,3 @@ - /***************************************************************************** * * This file is part of Mapnik (c++ mapping toolkit) diff --git a/plugins/input/python/python_datasource.cpp b/plugins/input/python/python_datasource.cpp index 45a461b7c..904027de8 100644 --- a/plugins/input/python/python_datasource.cpp +++ b/plugins/input/python/python_datasource.cpp @@ -7,7 +7,7 @@ #include // boost -#include + #include #include #include @@ -26,7 +26,7 @@ python_datasource::python_datasource(parameters const& params) factory_(*params.get("factory", "")) { // extract any remaining parameters as keyword args for the factory - BOOST_FOREACH(const mapnik::parameters::value_type& kv, params) + for (const mapnik::parameters::value_type& kv : params) { if((kv.first != "type") && (kv.first != "factory")) { @@ -73,7 +73,7 @@ python_datasource::python_datasource(parameters const& params) // prepare the arguments boost::python::dict kwargs; typedef std::map::value_type kv_type; - BOOST_FOREACH(const kv_type& kv, kwargs_) + for (kv_type const& kv : kwargs_) { kwargs[boost::python::str(kv.first)] = boost::python::str(kv.second); } diff --git a/plugins/input/raster/raster_datasource.cpp b/plugins/input/raster/raster_datasource.cpp index 5c1779836..3248b527a 100644 --- a/plugins/input/raster/raster_datasource.cpp +++ b/plugins/input/raster/raster_datasource.cpp @@ -118,7 +118,7 @@ raster_datasource::raster_datasource(parameters const& params) try { - std::auto_ptr reader(mapnik::get_image_reader(filename_, format_)); + std::unique_ptr reader(mapnik::get_image_reader(filename_, format_)); if (reader.get()) { width_ = reader->width(); diff --git a/plugins/input/raster/raster_featureset.cpp b/plugins/input/raster/raster_featureset.cpp index 6a337cfd8..0e565a9d0 100644 --- a/plugins/input/raster/raster_featureset.cpp +++ b/plugins/input/raster/raster_featureset.cpp @@ -71,7 +71,7 @@ feature_ptr raster_featureset::next() try { - std::auto_ptr reader(mapnik::get_image_reader(curIter_->file(),curIter_->format())); + std::unique_ptr reader(mapnik::get_image_reader(curIter_->file(),curIter_->format())); MAPNIK_LOG_DEBUG(raster) << "raster_featureset: Reader=" << curIter_->format() << "," << curIter_->file() << ",size(" << curIter_->width() << "," << curIter_->height() << ")"; diff --git a/plugins/input/shape/shape_featureset.cpp b/plugins/input/shape/shape_featureset.cpp index 4550d832b..cce768704 100644 --- a/plugins/input/shape/shape_featureset.cpp +++ b/plugins/input/shape/shape_featureset.cpp @@ -89,9 +89,9 @@ feature_ptr shape_featureset::next() double y = record.read_double(); if (!filter_.pass(mapnik::box2d(x,y,x,y))) continue; - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(x, y); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); break; } case shape_io::shape_multipoint: @@ -105,9 +105,9 @@ feature_ptr shape_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(x, y); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); } break; } diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index 6c1b0f46b..c896b9208 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -101,9 +101,9 @@ feature_ptr shape_index_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(x, y); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); break; } case shape_io::shape_multipoint: @@ -117,9 +117,9 @@ feature_ptr shape_index_featureset::next() { double x = record.read_double(); double y = record.read_double(); - std::auto_ptr point(new geometry_type(mapnik::Point)); + std::unique_ptr point(new geometry_type(mapnik::geometry_type::types::Point)); point->move_to(x, y); - feature->paths().push_back(point); + feature->paths().push_back(point.release()); } break; } diff --git a/plugins/input/shape/shape_io.cpp b/plugins/input/shape/shape_io.cpp index bbeb14276..cceb7198e 100644 --- a/plugins/input/shape/shape_io.cpp +++ b/plugins/input/shape/shape_io.cpp @@ -96,7 +96,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry int num_points = record.read_ndr_integer(); if (num_parts == 1) { - std::auto_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::geometry_type::types::LineString)); record.skip(4); double x = record.read_double(); double y = record.read_double(); @@ -107,7 +107,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry y = record.read_double(); line->line_to(x, y); } - geom.push_back(line); + geom.push_back(line.release()); } else { @@ -120,7 +120,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry int start, end; for (int k = 0; k < num_parts; ++k) { - std::auto_ptr line(new geometry_type(mapnik::LineString)); + std::unique_ptr line(new geometry_type(mapnik::geometry_type::types::LineString)); start = parts[k]; if (k == num_parts - 1) { @@ -141,7 +141,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry y = record.read_double(); line->line_to(x, y); } - geom.push_back(line); + geom.push_back(line.release()); } } } @@ -159,7 +159,7 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c for (int k = 0; k < num_parts; ++k) { - std::auto_ptr poly(new geometry_type(mapnik::Polygon)); + std::unique_ptr poly(new geometry_type(mapnik::geometry_type::types::Polygon)); int start = parts[k]; int end; if (k == num_parts - 1) @@ -181,6 +181,6 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c poly->line_to(x, y); } poly->close_path(); - geom.push_back(poly); + geom.push_back(poly.release()); } } diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index 8bfd79c4a..f270555cb 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -264,7 +264,7 @@ void agg_renderer::end_style_processing(feature_type_style const& st) { blend_from = true; mapnik::filter::filter_visitor visitor(*current_buffer_); - BOOST_FOREACH(mapnik::filter::filter_type const& filter_tag, st.image_filters()) + for (mapnik::filter::filter_type const& filter_tag : st.image_filters()) { boost::apply_visitor(visitor, filter_tag); } @@ -281,7 +281,7 @@ void agg_renderer::end_style_processing(feature_type_style const& st) } // apply any 'direct' image filters mapnik::filter::filter_visitor visitor(pixmap_); - BOOST_FOREACH(mapnik::filter::filter_type const& filter_tag, st.direct_image_filters()) + for (mapnik::filter::filter_type const& filter_tag : st.direct_image_filters()) { boost::apply_visitor(visitor, filter_tag); } diff --git a/src/agg/process_building_symbolizer.cpp b/src/agg/process_building_symbolizer.cpp index d4d7dae05..65f1e6b79 100644 --- a/src/agg/process_building_symbolizer.cpp +++ b/src/agg/process_building_symbolizer.cpp @@ -91,8 +91,8 @@ void agg_renderer::process(building_symbolizer const& sym, geometry_type const& geom = feature.get_geometry(i); if (geom.size() > 2) { - boost::scoped_ptr frame(new geometry_type(LineString)); - boost::scoped_ptr roof(new geometry_type(Polygon)); + boost::scoped_ptr frame(new geometry_type(geometry_type::types::LineString)); + boost::scoped_ptr roof(new geometry_type(geometry_type::types::Polygon)); std::deque face_segments; double x0 = 0; double y0 = 0; @@ -124,7 +124,7 @@ void agg_renderer::process(building_symbolizer const& sym, for (; itr!=end; ++itr) { - boost::scoped_ptr faces(new geometry_type(Polygon)); + boost::scoped_ptr faces(new geometry_type(geometry_type::types::Polygon)); faces->move_to(itr->get<0>(),itr->get<1>()); faces->line_to(itr->get<2>(),itr->get<3>()); faces->line_to(itr->get<2>(),itr->get<3>() + height); diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp index 80c29f421..43a9044bd 100644 --- a/src/agg/process_line_pattern_symbolizer.cpp +++ b/src/agg/process_line_pattern_symbolizer.cpp @@ -50,7 +50,7 @@ #include "agg_conv_clip_polyline.h" // boost -#include + namespace { @@ -153,7 +153,7 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, if (fabs(sym.offset()) > 0.0) converter.set(); // parallel offset if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH(geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index bf7dcd2fb..00e5ce200 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -45,7 +45,7 @@ #include "agg_rasterizer_outline_aa.h" // boost -#include + // stl #include @@ -129,7 +129,7 @@ void agg_renderer::process(line_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { @@ -152,7 +152,7 @@ void agg_renderer::process(line_symbolizer const& sym, if (stroke_.has_dash()) converter.set(); converter.set(); //always stroke - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { diff --git a/src/agg/process_markers_symbolizer.cpp b/src/agg/process_markers_symbolizer.cpp index 2e8b5469d..33e207413 100644 --- a/src/agg/process_markers_symbolizer.cpp +++ b/src/agg/process_markers_symbolizer.cpp @@ -142,8 +142,8 @@ void agg_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) @@ -182,8 +182,8 @@ void agg_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) @@ -220,13 +220,13 @@ void agg_renderer::process(markers_symbolizer const& sym, if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 - //else if (type == LineString) + //else if (type == geometry_type::types::LineString) // converter.template set(); - // don't clip if type==Point + // don't clip if type==geometry_type::types::Point } converter.template set(); //always transform if (sym.smooth() > 0.0) converter.template set(); // optional smooth converter diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index 71e5b0def..a38cbb093 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ // boost -#include + // mapnik #include @@ -157,7 +157,7 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index 25e2f09a2..360b41783 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ // boost -#include + // mapnik #include @@ -70,7 +70,7 @@ void agg_renderer::process(polygon_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 2) { diff --git a/src/box2d.cpp b/src/box2d.cpp index bb04615f4..6f7001feb 100644 --- a/src/box2d.cpp +++ b/src/box2d.cpp @@ -70,6 +70,13 @@ box2d::box2d(box2d_type const& rhs) maxx_(rhs.maxx_), maxy_(rhs.maxy_) {} +template +box2d::box2d(box2d_type && rhs) + : minx_(std::move(rhs.minx_)), + miny_(std::move(rhs.miny_)), + maxx_(std::move(rhs.maxx_)), + maxy_(std::move(rhs.maxy_)) {} + template box2d& box2d::operator=(box2d_type other) { diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 9d58202e0..d74977285 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -327,7 +327,7 @@ void cairo_renderer_base::process(polygon_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { @@ -360,8 +360,8 @@ void cairo_renderer_base::process(building_symbolizer const& sym, if (geom.size() > 2) { - boost::scoped_ptr frame(new geometry_type(LineString)); - boost::scoped_ptr roof(new geometry_type(Polygon)); + boost::scoped_ptr frame(new geometry_type(geometry_type::types::LineString)); + boost::scoped_ptr roof(new geometry_type(geometry_type::types::Polygon)); std::deque face_segments; double x0 = 0; double y0 = 0; @@ -392,7 +392,7 @@ void cairo_renderer_base::process(building_symbolizer const& sym, std::deque::const_iterator end=face_segments.end(); for (; itr != end; ++itr) { - boost::scoped_ptr faces(new geometry_type(Polygon)); + boost::scoped_ptr faces(new geometry_type(geometry_type::types::Polygon)); faces->move_to(itr->get<0>(), itr->get<1>()); faces->line_to(itr->get<2>(), itr->get<3>()); faces->line_to(itr->get<2>(), itr->get<3>() + height); @@ -490,7 +490,7 @@ void cairo_renderer_base::process(line_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { @@ -865,7 +865,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym, if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { @@ -987,11 +987,11 @@ struct markers_dispatch marker_placement_e placement_method = sym_.get_marker_placement(); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -1076,11 +1076,11 @@ struct markers_dispatch_2 marker_placement_e placement_method = sym_.get_marker_placement(); if (placement_method != MARKER_LINE_PLACEMENT || - path.type() == Point) + path.type() == geometry_type::types::Point) { double x = 0; double y = 0; - if (path.type() == LineString) + if (path.type() == geometry_type::types::LineString) { if (!label::middle_point(path, x, y)) return; @@ -1200,13 +1200,13 @@ void cairo_renderer_base::process(markers_symbolizer const& sym, if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 - //else if (type == LineString) + //else if (type == geometry_type::types::LineString) // converter.template set(); - // don't clip if type==Point + // don't clip if type==geometry_type::types::Point } converter.set(); //always transform if (sym.smooth() > 0.0) converter.set(); // optional smooth converter @@ -1225,13 +1225,13 @@ void cairo_renderer_base::process(markers_symbolizer const& sym, if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 - //else if (type == LineString) + //else if (type == geometry_type::types::LineString) // converter.template set(); - // don't clip if type==Point + // don't clip if type==geometry_type::types::Point } converter.set(); //always transform if (sym.smooth() > 0.0) converter.set(); // optional smooth converter @@ -1255,13 +1255,13 @@ void cairo_renderer_base::process(markers_symbolizer const& sym, if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 - //else if (type == LineString) + //else if (type == geometry_type::types::LineString) // converter.template set(); - // don't clip if type==Point + // don't clip if type==geometry_type::types::Point } converter.set(); //always transform if (sym.smooth() > 0.0) converter.set(); // optional smooth converter diff --git a/src/deepcopy.cpp b/src/deepcopy.cpp index e34b7f36a..9ba0b9662 100644 --- a/src/deepcopy.cpp +++ b/src/deepcopy.cpp @@ -44,7 +44,7 @@ // boost #include -#include + namespace mapnik { namespace util { @@ -100,12 +100,12 @@ namespace mapnik { namespace util { // fontsets typedef std::map fontsets; - BOOST_FOREACH ( fontsets::value_type const& kv,map_in.fontsets()) + for (fontsets::value_type const& kv : map_in.fontsets()) { map_out.insert_fontset(kv.first,kv.second); } - BOOST_FOREACH ( layer const& lyr_in, map_in.layers()) + for ( layer const& lyr_in : map_in.layers()) { layer lyr_out(lyr_in); datasource_ptr ds_in = lyr_in.datasource(); @@ -126,7 +126,7 @@ namespace mapnik { namespace util { typedef style_cont::value_type value_type; style_cont const& styles = map_in.styles(); - BOOST_FOREACH ( value_type const& kv, styles ) + for ( value_type const& kv : styles ) { feature_type_style const& style_in = kv.second; feature_type_style style_out(style_in,true); // deep copy diff --git a/src/feature_type_style.cpp b/src/feature_type_style.cpp index f850a86f8..733a73d8e 100644 --- a/src/feature_type_style.cpp +++ b/src/feature_type_style.cpp @@ -25,7 +25,7 @@ #include // boost -#include + namespace mapnik { @@ -92,7 +92,7 @@ rules& feature_type_style::get_rules_nonconst() bool feature_type_style::active(double scale_denom) const { - BOOST_FOREACH(rule const& r, rules_) + for (rule const& r : rules_) { if (r.active(scale_denom)) { diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 9917de86c..8250e1a27 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -292,7 +292,7 @@ font_face_set::size_type font_face_set::size() const glyph_ptr font_face_set::get_glyph(unsigned c) const { - BOOST_FOREACH ( face_ptr const& face, faces_) + for ( face_ptr const& face : faces_) { FT_UInt g = face->get_char(c); if (g) return boost::make_shared(face, g); @@ -399,7 +399,7 @@ void font_face_set::get_string_info(string_info & info, mapnik::value_unicode_st void font_face_set::set_pixel_sizes(unsigned size) { - BOOST_FOREACH ( face_ptr const& face, faces_) + for ( face_ptr const& face : faces_) { face->set_pixel_sizes(size); } @@ -407,7 +407,7 @@ void font_face_set::set_pixel_sizes(unsigned size) void font_face_set::set_character_sizes(double size) { - BOOST_FOREACH ( face_ptr const& face, faces_) + for ( face_ptr const& face : faces_) { face->set_character_sizes(size); } diff --git a/src/font_set.cpp b/src/font_set.cpp index 7bc404021..3ae8e1df2 100644 --- a/src/font_set.cpp +++ b/src/font_set.cpp @@ -55,7 +55,7 @@ std::size_t font_set::size() const void font_set::add_face_name(std::string const& face_name) { - face_names_.push_back(face_name); + face_names_.push_back(std::move(face_name)); } void font_set::set_name(std::string const& name) diff --git a/src/formatting/list.cpp b/src/formatting/list.cpp index d9ac17374..777e78b85 100644 --- a/src/formatting/list.cpp +++ b/src/formatting/list.cpp @@ -25,7 +25,7 @@ #include // boost -#include + #include namespace mapnik { @@ -36,7 +36,7 @@ namespace formatting { void list_node::to_xml(boost::property_tree::ptree & xml) const { - BOOST_FOREACH(node_ptr const& node, children_) + for (node_ptr const& node : children_) { node->to_xml(xml); } @@ -44,17 +44,17 @@ void list_node::to_xml(boost::property_tree::ptree & xml) const void list_node::apply(char_properties const& p, feature_impl const& feature, processed_text &output) const -{ - BOOST_FOREACH(node_ptr const& node, children_) +{ + for (node_ptr const& node : children_) { node->apply(p, feature, output); - } + } } void list_node::add_expressions(expression_set &output) const { - BOOST_FOREACH(node_ptr const& node, children_) + for (node_ptr const& node : children_) { node->add_expressions(output); } @@ -81,4 +81,3 @@ std::vector const& list_node::get_children() const } } // ns mapnik } // ns formatting - diff --git a/src/grid/process_building_symbolizer.cpp b/src/grid/process_building_symbolizer.cpp index 5e089d272..941917fda 100644 --- a/src/grid/process_building_symbolizer.cpp +++ b/src/grid/process_building_symbolizer.cpp @@ -78,8 +78,8 @@ void grid_renderer::process(building_symbolizer const& sym, geometry_type & geom = feature.get_geometry(i); if (geom.size() > 2) { - boost::scoped_ptr frame(new geometry_type(LineString)); - boost::scoped_ptr roof(new geometry_type(Polygon)); + boost::scoped_ptr frame(new geometry_type(geometry_type::types::LineString)); + boost::scoped_ptr roof(new geometry_type(geometry_type::types::Polygon)); std::deque face_segments; double x0(0); double y0(0); @@ -106,7 +106,7 @@ void grid_renderer::process(building_symbolizer const& sym, std::deque::const_iterator itr=face_segments.begin(); for (;itr!=face_segments.end();++itr) { - boost::scoped_ptr faces(new geometry_type(Polygon)); + boost::scoped_ptr faces(new geometry_type(geometry_type::types::Polygon)); faces->move_to(itr->get<0>(),itr->get<1>()); faces->line_to(itr->get<2>(),itr->get<3>()); faces->line_to(itr->get<2>(),itr->get<3>() + height); diff --git a/src/grid/process_line_symbolizer.cpp b/src/grid/process_line_symbolizer.cpp index c188b6473..502a85c24 100644 --- a/src/grid/process_line_symbolizer.cpp +++ b/src/grid/process_line_symbolizer.cpp @@ -38,7 +38,7 @@ #include "agg_conv_dash.h" // boost -#include + // stl #include @@ -96,7 +96,7 @@ void grid_renderer::process(line_symbolizer const& sym, if (stroke_.has_dash()) converter.set(); converter.set(); //always stroke - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 1) { @@ -119,4 +119,3 @@ template void grid_renderer::process(line_symbolizer const&, proj_transform const&); } - diff --git a/src/grid/process_markers_symbolizer.cpp b/src/grid/process_markers_symbolizer.cpp index 81180f481..1f274f10c 100644 --- a/src/grid/process_markers_symbolizer.cpp +++ b/src/grid/process_markers_symbolizer.cpp @@ -150,8 +150,8 @@ void grid_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) @@ -192,8 +192,8 @@ void grid_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) @@ -237,8 +237,8 @@ void grid_renderer::process(markers_symbolizer const& sym, converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_); if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) + geometry_type::types type = feature.paths()[0].type(); + if (type == geometry_type::types::Polygon) converter.template set(); // line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426 //else if (type == LineString) diff --git a/src/grid/process_polygon_pattern_symbolizer.cpp b/src/grid/process_polygon_pattern_symbolizer.cpp index 38145858f..956458f18 100644 --- a/src/grid/process_polygon_pattern_symbolizer.cpp +++ b/src/grid/process_polygon_pattern_symbolizer.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ // boost -#include + // mapnik #include @@ -64,7 +64,7 @@ void grid_renderer::process(polygon_pattern_symbolizer const& sym, if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { @@ -96,4 +96,3 @@ template void grid_renderer::process(polygon_pattern_symbolizer const&, proj_transform const&); } - diff --git a/src/grid/process_polygon_symbolizer.cpp b/src/grid/process_polygon_symbolizer.cpp index 5195760f9..ffa79fc6d 100644 --- a/src/grid/process_polygon_symbolizer.cpp +++ b/src/grid/process_polygon_symbolizer.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ // boost -#include + // mapnik #include @@ -69,7 +69,7 @@ void grid_renderer::process(polygon_symbolizer const& sym, if (sym.smooth() > 0.0) converter.set(); // optional smooth converter - BOOST_FOREACH( geometry_type & geom, feature.paths()) + for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { @@ -98,4 +98,3 @@ template void grid_renderer::process(polygon_symbolizer const&, proj_transform const&); } - diff --git a/src/image_reader.cpp b/src/image_reader.cpp index 539221040..afa572b5d 100644 --- a/src/image_reader.cpp +++ b/src/image_reader.cpp @@ -28,13 +28,6 @@ namespace mapnik { -typedef factory ImageReaderFactory; - -typedef factory MemImageReaderFactory; - - inline boost::optional type_from_bytes(char const* data, size_t size) { typedef boost::optional result_type; @@ -70,27 +63,18 @@ inline boost::optional type_from_bytes(char const* data, size_t siz return result_type(); } -bool register_image_reader(std::string const& type,image_reader* (* fun)(std::string const&)) -{ - return ImageReaderFactory::instance().register_product(type,fun); -} - -bool register_image_reader(std::string const& type,image_reader* (* fun)(char const*, std::size_t)) -{ - return MemImageReaderFactory::instance().register_product(type,fun); -} - image_reader* get_image_reader(char const* data, size_t size) { boost::optional type = type_from_bytes(data,size); if (type) - return MemImageReaderFactory::instance().create_object(*type, data,size); - return 0; + return factory::instance().create_object(*type, data,size); + else + throw image_reader_exception("image_reader: can't determine type from input data"); } image_reader* get_image_reader(std::string const& filename,std::string const& type) { - return ImageReaderFactory::instance().create_object(type,filename); + return factory::instance().create_object(type,filename); } image_reader* get_image_reader(std::string const& filename) @@ -98,7 +82,7 @@ image_reader* get_image_reader(std::string const& filename) boost::optional type = type_from_filename(filename); if (type) { - return ImageReaderFactory::instance().create_object(*type,filename); + return factory::instance().create_object(*type,filename); } return 0; } diff --git a/src/image_util.cpp b/src/image_util.cpp index 8cee4dd7d..1dd1adc88 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -68,7 +68,7 @@ extern "C" #endif // boost -#include + #include // stl @@ -149,7 +149,7 @@ void handle_png_options(std::string const& type, if (type.length() > 6){ boost::char_separator sep(":"); boost::tokenizer< boost::char_separator > tokens(type, sep); - BOOST_FOREACH(std::string t, tokens) + for (std::string const& t : tokens) { if (t == "png" || t == "png24" || t == "png32") { @@ -258,7 +258,7 @@ void handle_webp_options(std::string const& type, if (type.length() > 4){ boost::char_separator sep(":"); boost::tokenizer< boost::char_separator > tokens(type, sep); - BOOST_FOREACH(std::string t, tokens) + for (auto const& t : tokens) { if (boost::algorithm::starts_with(t, "quality=")) { diff --git a/src/json/geometry_grammar.cpp b/src/json/geometry_grammar.cpp index 797ef79f2..7708ab17c 100644 --- a/src/json/geometry_grammar.cpp +++ b/src/json/geometry_grammar.cpp @@ -105,16 +105,16 @@ geometry_grammar::geometry_grammar() | (eps(_r2 == 6) > multipolygon_coordinates(_r1)) ; - point_coordinates = eps[ _a = new_(Point) ] + point_coordinates = eps[ _a = new_(geometry_type::types::Point) ] > ( point(SEG_MOVETO,_a) [push_back(_r1,_a)] | eps[cleanup_(_a)][_pass = false] ) ; - linestring_coordinates = eps[ _a = new_(LineString)] + linestring_coordinates = eps[ _a = new_(geometry_type::types::LineString)] > -(points(_a) [push_back(_r1,_a)] | eps[cleanup_(_a)][_pass = false]) ; - polygon_coordinates = eps[ _a = new_(Polygon) ] + polygon_coordinates = eps[ _a = new_(geometry_type::types::Polygon) ] > ((lit('[') > -(points(_a)[close_path_(_a)] % lit(',')) > lit(']')) [push_back(_r1,_a)] diff --git a/src/marker_cache.cpp b/src/marker_cache.cpp index d550457c6..53004a219 100644 --- a/src/marker_cache.cpp +++ b/src/marker_cache.cpp @@ -191,7 +191,7 @@ boost::optional marker_cache::find(std::string const& uri, else { // TODO - support reading images from string - std::auto_ptr reader(mapnik::get_image_reader(uri)); + std::unique_ptr reader(mapnik::get_image_reader(uri)); if (reader.get()) { unsigned width = reader->width(); diff --git a/src/parse_path.cpp b/src/parse_path.cpp index 90265b9ab..c5cae5553 100644 --- a/src/parse_path.cpp +++ b/src/parse_path.cpp @@ -30,7 +30,7 @@ // boost #include -#include + #include // stl @@ -48,8 +48,8 @@ path_expression_ptr parse_path(std::string const& str) path_expression_ptr parse_path(std::string const& str, path_expression_grammar const& g) { - path_expression path; - + path_expression path; + std::string::const_iterator itr = str.begin(); std::string::const_iterator end = str.end(); bool r = qi::phrase_parse(itr, end, g, boost::spirit::standard_wide::space, path); @@ -129,7 +129,7 @@ std::string path_processor::evaluate(path_expression const& path,feature_impl co { std::string out; path_processor_detail::path_visitor_ eval(out,f); - BOOST_FOREACH( mapnik::path_component const& token, path) + for ( mapnik::path_component const& token : path) boost::apply_visitor(eval,token); return out; } @@ -138,7 +138,7 @@ std::string path_processor::to_string(path_expression const& path) { std::string str; path_processor_detail::to_string_ visitor(str); - BOOST_FOREACH( mapnik::path_component const& token, path) + for ( mapnik::path_component const& token : path) boost::apply_visitor(visitor,token); return str; } @@ -146,7 +146,7 @@ std::string path_processor::to_string(path_expression const& path) void path_processor::collect_attributes(path_expression const& path, std::set& names) { path_processor_detail::collect_ visitor(names); - BOOST_FOREACH( mapnik::path_component const& token, path) + for ( mapnik::path_component const& token : path) boost::apply_visitor(visitor,token); } diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index 41b5f7823..9a9089450 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -36,7 +36,7 @@ #include #include #include -#include + //stl #include @@ -285,7 +285,7 @@ void placement_finder::find_line_breaks() //No linebreaks line_sizes_.push_back(std::make_pair(string_width_, string_height_)); } - line_breaks_.push_back(info_.num_characters()); + line_breaks_.push_back(static_cast(info_.num_characters())); } template @@ -386,7 +386,7 @@ void placement_finder::find_point_placement(double label_x, double sina = std::sin(rad); double x, y; - std::auto_ptr current_placement(new text_path(label_x, label_y)); + std::unique_ptr current_placement(new text_path(label_x, label_y)); adjust_position(current_placement.get()); @@ -500,7 +500,7 @@ void placement_finder::find_point_placement(double label_x, // check the placement of any additional envelopes if (!p.allow_overlap && !additional_boxes_.empty()) { - BOOST_FOREACH(box2d const& box, additional_boxes_) + for (box2d const& box : additional_boxes_) { box2d pt(box.minx() + current_placement->center.x, box.miny() + current_placement->center.y, @@ -639,10 +639,10 @@ void placement_finder::find_line_placements(PathT & shape_path) { //Record details for the start of the string placement int orientation = 0; - std::auto_ptr current_placement = get_placement_offset(path_positions, path_distances, orientation, index, segment_length - (distance - target_distance) + (diff*dir)); + std::unique_ptr current_placement = get_placement_offset(path_positions, path_distances, orientation, index, segment_length - (distance - target_distance) + (diff*dir)); //We were unable to place here - if (current_placement.get() == NULL) + if (current_placement.get() == nullptr) continue; //Apply displacement @@ -709,7 +709,7 @@ void placement_finder::find_line_placements(PathT & shape_path) } template -std::auto_ptr placement_finder::get_placement_offset(std::vector const& path_positions, +std::unique_ptr placement_finder::get_placement_offset(std::vector const& path_positions, std::vector const& path_distances, int & orientation, std::size_t index, @@ -722,7 +722,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: distance += path_distances[index]; } if (index <= 1 && distance < 0) //We've gone off the start, fail out - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); //Same thing, checking if we go off the end while (index < path_distances.size() && distance > path_distances[index]) @@ -731,7 +731,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: index++; } if (index >= path_distances.size()) - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); //Keep track of the initial index,distance incase we need to re-call get_placement_offset const std::size_t initial_index = index; @@ -749,10 +749,10 @@ std::auto_ptr placement_finder::get_placement_offset(std:: double segment_length = path_distances[index]; if (segment_length == 0) { // Not allowed to place across on 0 length segments or discontinuities - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } - std::auto_ptr current_placement( + std::unique_ptr current_placement( new text_path((old_x + dx*distance/segment_length), (old_y + dy*distance/segment_length) ) @@ -777,7 +777,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: //Coordinates this character will start at if (segment_length == 0) { // Not allowed to place across on 0 length segments or discontinuities - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } double start_x = old_x + dx*distance/segment_length; double start_y = old_y + dy*distance/segment_length; @@ -805,7 +805,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: if (index >= path_positions.size()) //Bail out if we run off the end of the shape { //MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Out of space"; - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } new_x = path_positions[index].x; new_y = path_positions[index].y; @@ -842,7 +842,7 @@ std::auto_ptr placement_finder::get_placement_offset(std:: std::fabs(angle_delta) > p.max_char_angle_delta) { //MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Too Bendy!"; - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } double render_angle = angle; @@ -896,15 +896,15 @@ std::auto_ptr placement_finder::get_placement_offset(std:: { //Otherwise we have failed to find a placement //MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Double upside-down!"; - return std::auto_ptr(NULL); + return std::unique_ptr(nullptr); } } - return current_placement; + return std::move(current_placement); } template -bool placement_finder::test_placement(std::auto_ptr const& current_placement, +bool placement_finder::test_placement(std::unique_ptr const& current_placement, int orientation) { //Create and test envelopes diff --git a/src/svg/output/process_symbolizers.cpp b/src/svg/output/process_symbolizers.cpp index ca38a082f..10de95982 100644 --- a/src/svg/output/process_symbolizers.cpp +++ b/src/svg/output/process_symbolizers.cpp @@ -59,7 +59,7 @@ bool svg_renderer::process(rule::symbolizers const& syms, // process each symbolizer to collect its (path) information. // path information (attributes from line_ and polygon_ symbolizers) // is collected with the path_attributes_ data member. - BOOST_FOREACH(symbolizer const& sym, syms) + for (symbolizer const& sym : syms) { if (is_path_based(sym)) { diff --git a/src/svg/svg_parser.cpp b/src/svg/svg_parser.cpp index 0fbf12bf0..0aa5d42b2 100644 --- a/src/svg/svg_parser.cpp +++ b/src/svg/svg_parser.cpp @@ -35,8 +35,6 @@ #include #include #include -#include - #include #include @@ -434,7 +432,7 @@ void parse_attr(svg_parser & parser, xmlTextReaderPtr reader) typedef cont_type::value_type value_type; cont_type vec; parse_style((const char*)value, vec); - BOOST_FOREACH(value_type kv , vec ) + for (value_type kv : vec ) { parse_attr(parser,BAD_CAST kv.first.c_str(),BAD_CAST kv.second.c_str()); } @@ -796,7 +794,7 @@ void parse_gradient_stop(svg_parser & parser, xmlTextReaderPtr reader) cont_type vec; parse_style((const char*)value, vec); - BOOST_FOREACH(value_type kv , vec ) + for (value_type kv : vec ) { if (kv.first == "stop-color") { diff --git a/src/symbolizer_helpers.cpp b/src/symbolizer_helpers.cpp index 5f1693c44..91abab87d 100644 --- a/src/symbolizer_helpers.cpp +++ b/src/symbolizer_helpers.cpp @@ -219,8 +219,8 @@ void text_symbolizer_helper::initialize_geometries() // don't bother with empty geometries if (geom.size() == 0) continue; - eGeomType type = geom.type(); - if (type == Polygon) + geometry_type::types type = geom.type(); + if (type == geometry_type::types::Polygon) { largest_box_only = sym_.largest_bbox_only(); if (sym_.get_minimum_path_length() > 0) @@ -284,7 +284,7 @@ void text_symbolizer_helper::initialize_points() // https://github.com/mapnik/mapnik/issues/1423 bool success = false; // https://github.com/mapnik/mapnik/issues/1350 - if (geom.type() == LineString) + if (geom.type() == geometry_type::types::LineString) { success = label::middle_point(geom, label_x,label_y); } diff --git a/src/transform_expression.cpp b/src/transform_expression.cpp index 157dee202..0bf3b8ec2 100644 --- a/src/transform_expression.cpp +++ b/src/transform_expression.cpp @@ -25,7 +25,7 @@ #include // boost -#include + // stl #include @@ -132,7 +132,7 @@ std::string to_expression_string(transform_list const& list) std::streamsize first = 1; transform_node_to_expression_string to_string(os); - BOOST_FOREACH (transform_node const& node, list) + for (transform_node const& node : list) { os.write(" ", first ? (first = 0) : 1); boost::apply_visitor(to_string, *node); diff --git a/src/webp_reader.cpp b/src/webp_reader.cpp index 29f87dbd2..3042b82da 100644 --- a/src/webp_reader.cpp +++ b/src/webp_reader.cpp @@ -102,7 +102,8 @@ private: } WebPDecoderConfig & config_; }; - std::auto_ptr buffer_; + + std::unique_ptr buffer_; size_t size_; unsigned width_; unsigned height_; @@ -148,7 +149,7 @@ webp_reader::webp_reader(char const* data, std::size_t size) template webp_reader::webp_reader(std::string const& filename) - : buffer_(), + : buffer_(nullptr), size_(0), width_(0), height_(0) @@ -163,12 +164,15 @@ webp_reader::webp_reader(std::string const& filename) std::streampos end = file.tellg(); std::size_t file_size = end - beg; file.seekg (0, std::ios::beg); - buffer_ = std::auto_ptr(new buffer_policy_type(file_size)); - file.read(reinterpret_cast(buffer_->data()), buffer_->size()); + + std::unique_ptr buffer(new buffer_policy_type(file_size)); + file.read(reinterpret_cast(buffer->data()), buffer->size()); if (!file) { throw image_reader_exception("WEBP: Failed to read:" + filename); } + + buffer_ = std::move(buffer); init(); } diff --git a/src/wkb.cpp b/src/wkb.cpp index 65f6145df..88b791efe 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -250,9 +250,9 @@ private: { double x = read_double(); double y = read_double(); - std::auto_ptr pt(new geometry_type(Point)); + std::unique_ptr pt(new geometry_type(geometry_type::types::Point)); pt->move_to(x, y); - paths.push_back(pt); + paths.push_back(pt.release()); } void read_multipoint(boost::ptr_vector & paths) @@ -269,10 +269,10 @@ private: { double x = read_double(); double y = read_double(); - std::auto_ptr pt(new geometry_type(Point)); + std::unique_ptr pt(new geometry_type(geometry_type::types::Point)); pos_ += 8; // double z = read_double(); pt->move_to(x, y); - paths.push_back(pt); + paths.push_back(pt.release()); } void read_multipoint_xyz(boost::ptr_vector & paths) @@ -292,13 +292,13 @@ private: { CoordinateArray ar(num_points); read_coords(ar); - std::auto_ptr line(new geometry_type(LineString)); + std::unique_ptr line(new geometry_type(geometry_type::types::LineString)); line->move_to(ar[0].x, ar[0].y); for (int i = 1; i < num_points; ++i) { line->line_to(ar[i].x, ar[i].y); } - paths.push_back(line); + paths.push_back(line.release()); } } @@ -319,13 +319,13 @@ private: { CoordinateArray ar(num_points); read_coords_xyz(ar); - std::auto_ptr line(new geometry_type(LineString)); + std::unique_ptr line(new geometry_type(geometry_type::types::LineString)); line->move_to(ar[0].x, ar[0].y); for (int i = 1; i < num_points; ++i) { line->line_to(ar[i].x, ar[i].y); } - paths.push_back(line); + paths.push_back(line.release()); } } @@ -345,7 +345,7 @@ private: int num_rings = read_integer(); if (num_rings > 0) { - std::auto_ptr poly(new geometry_type(Polygon)); + std::unique_ptr poly(new geometry_type(geometry_type::types::Polygon)); for (int i = 0; i < num_rings; ++i) { int num_points = read_integer(); @@ -362,7 +362,7 @@ private: } } if (poly->size() > 3) // ignore if polygon has less than (3 + close_path) vertices - paths.push_back(poly); + paths.push_back(poly.release()); } } @@ -381,7 +381,7 @@ private: int num_rings = read_integer(); if (num_rings > 0) { - std::auto_ptr poly(new geometry_type(Polygon)); + std::unique_ptr poly(new geometry_type(geometry_type::types::Polygon)); for (int i = 0; i < num_rings; ++i) { int num_points = read_integer(); @@ -398,7 +398,7 @@ private: } } if (poly->size() > 2) // ignore if polygon has less than 3 vertices - paths.push_back(poly); + paths.push_back(poly.release()); } } diff --git a/src/wkt/wkt_generator.cpp b/src/wkt/wkt_generator.cpp index 16f81bfe5..5b7e57407 100644 --- a/src/wkt/wkt_generator.cpp +++ b/src/wkt/wkt_generator.cpp @@ -72,20 +72,20 @@ wkt_generator::wkt_generator(bool single) wkt = point | linestring | polygon ; - point = &uint_(mapnik::Point)[_1 = _type(_val)] + point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)] << string[ phoenix::if_ (single) [_1 = "Point("] .else_[_1 = "("]] << point_coord [_1 = _first(_val)] << lit(')') ; - linestring = &uint_(mapnik::LineString)[_1 = _type(_val)] + linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)] << string[ phoenix::if_ (single) [_1 = "LineString("] .else_[_1 = "("]] << coords << lit(')') ; - polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)] + polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)] << string[ phoenix::if_ (single) [_1 = "Polygon("] .else_[_1 = "("]] << coords2 @@ -126,9 +126,9 @@ wkt_multi_generator::wkt_multi_generator() using boost::spirit::karma::_a; geometry_types.add - (mapnik::Point,"Point") - (mapnik::LineString,"LineString") - (mapnik::Polygon,"Polygon") + (mapnik::geometry_type::types::Point,"Point") + (mapnik::geometry_type::types::LineString,"LineString") + (mapnik::geometry_type::types::Polygon,"Polygon") ; wkt = eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)] diff --git a/tests/cpp_tests/clipping_test.cpp b/tests/cpp_tests/clipping_test.cpp index 6e6c6ca6e..907d75147 100644 --- a/tests/cpp_tests/clipping_test.cpp +++ b/tests/cpp_tests/clipping_test.cpp @@ -6,7 +6,7 @@ // boost #include #include -#include + // stl #include @@ -54,7 +54,7 @@ void parse_geom(mapnik::geometry_type & geom, std::string const& geom_string) { std::vector vertices; boost::split(vertices, geom_string, boost::is_any_of(",")); - BOOST_FOREACH(std::string const& vert, vertices) + for (std::string const& vert : vertices) { std::vector commands; boost::split(commands, vert, boost::is_any_of(" ")); diff --git a/tests/cpp_tests/fontset_runtime_test.cpp b/tests/cpp_tests/fontset_runtime_test.cpp index 4e287296a..14ec2d83a 100644 --- a/tests/cpp_tests/fontset_runtime_test.cpp +++ b/tests/cpp_tests/fontset_runtime_test.cpp @@ -43,7 +43,7 @@ int main(int argc, char** argv) mapnik::transcoder tr("utf-8"); mapnik::value_unicode_string ustr = tr.transcode("hello world!"); feature->put("name",ustr); - mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point); + mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::geometry_type::types::Point); pt->move_to(128,128); feature->add_geometry(pt); boost::shared_ptr ds = boost::make_shared(); diff --git a/tests/cpp_tests/geometry_converters_test.cpp b/tests/cpp_tests/geometry_converters_test.cpp index 2444371cd..26986259b 100644 --- a/tests/cpp_tests/geometry_converters_test.cpp +++ b/tests/cpp_tests/geometry_converters_test.cpp @@ -23,7 +23,7 @@ struct output_geometry_backend { - output_geometry_backend(boost::ptr_vector & paths, mapnik::eGeomType type) + output_geometry_backend(boost::ptr_vector & paths, mapnik::geometry_type::types type) : paths_(paths), type_(type) {} @@ -32,17 +32,17 @@ struct output_geometry_backend { mapnik::vertex2d vtx(mapnik::vertex2d::no_init); path.rewind(0); - std::auto_ptr geom_ptr(new mapnik::geometry_type(type_)); + std::unique_ptr geom_ptr(new mapnik::geometry_type(type_)); while ((vtx.cmd = path.vertex(&vtx.x, &vtx.y)) != mapnik::SEG_END) { //std::cerr << vtx.x << "," << vtx.y << " cmd=" << vtx.cmd << std::endl; geom_ptr->push_vertex(vtx.x, vtx.y, (mapnik::CommandType)vtx.cmd); } - paths_.push_back(geom_ptr); + paths_.push_back(geom_ptr.release()); } boost::ptr_vector & paths_; - mapnik::eGeomType type_; + mapnik::geometry_type::types type_; }; boost::optional linestring_bbox_clipping(mapnik::box2d bbox, @@ -56,7 +56,7 @@ boost::optional linestring_bbox_clipping(mapnik::box2d bbox line_symbolizer sym; CoordTransform t(bbox.width(),bbox.height(), bbox); boost::ptr_vector output_paths; - output_geometry_backend backend(output_paths, mapnik::LineString); + output_geometry_backend backend(output_paths, mapnik::geometry_type::types::LineString); typedef boost::mpl::vector conv_types; vertex_converter, output_geometry_backend, line_symbolizer, @@ -71,7 +71,7 @@ boost::optional linestring_bbox_clipping(mapnik::box2d bbox throw std::runtime_error("Failed to parse WKT"); } - BOOST_FOREACH( geometry_type & geom, p) + for (geometry_type & geom : p) { converter.apply(geom); } @@ -96,7 +96,7 @@ boost::optional polygon_bbox_clipping(mapnik::box2d bbox, polygon_symbolizer sym; CoordTransform t(bbox.width(),bbox.height(), bbox); boost::ptr_vector output_paths; - output_geometry_backend backend(output_paths, mapnik::Polygon); + output_geometry_backend backend(output_paths, mapnik::geometry_type::types::Polygon); typedef boost::mpl::vector conv_types; vertex_converter, output_geometry_backend, polygon_symbolizer, @@ -111,7 +111,7 @@ boost::optional polygon_bbox_clipping(mapnik::box2d bbox, throw std::runtime_error("Failed to parse WKT"); } - BOOST_FOREACH( geometry_type & geom, p) + for (geometry_type & geom : p) { converter.apply(geom); } diff --git a/tests/cpp_tests/image_io_test.cpp b/tests/cpp_tests/image_io_test.cpp index c4b374d72..cc55cb99d 100644 --- a/tests/cpp_tests/image_io_test.cpp +++ b/tests/cpp_tests/image_io_test.cpp @@ -25,7 +25,6 @@ int main(int argc, char** argv) { BOOST_TEST(set_working_dir(args)); - #if defined(HAVE_JPEG) should_throw = "./tests/cpp_tests/data/blank.jpg"; BOOST_TEST( mapnik::util::exists( should_throw ) ); @@ -33,8 +32,8 @@ int main(int argc, char** argv) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); - if (reader.get()) BOOST_TEST( false ); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); + BOOST_TEST( false ); } catch (std::exception const&) { @@ -49,21 +48,22 @@ int main(int argc, char** argv) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); - if (reader.get()) BOOST_TEST( false ); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); + BOOST_TEST( false ); } catch (std::exception const&) { BOOST_TEST( true ); } + should_throw = "./tests/data/images/xcode-CgBI.png"; BOOST_TEST( mapnik::util::exists( should_throw ) ); type = mapnik::type_from_filename(should_throw); BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); - if (reader.get()) BOOST_TEST( false ); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); + BOOST_TEST( false ); } catch (std::exception const&) { @@ -78,8 +78,8 @@ int main(int argc, char** argv) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); - if (reader.get()) BOOST_TEST( false ); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); + BOOST_TEST( false ); } catch (std::exception const&) { @@ -94,7 +94,7 @@ int main(int argc, char** argv) BOOST_TEST( type ); try { - std::auto_ptr reader(mapnik::get_image_reader(should_throw,*type)); + std::unique_ptr reader(mapnik::get_image_reader(should_throw,*type)); BOOST_TEST( false ); } catch (std::exception const&) diff --git a/tests/cpp_tests/label_algo_test.cpp b/tests/cpp_tests/label_algo_test.cpp index d997d19b9..268f63595 100644 --- a/tests/cpp_tests/label_algo_test.cpp +++ b/tests/cpp_tests/label_algo_test.cpp @@ -19,7 +19,7 @@ int main(int argc, char** argv) double x,y; // single point - mapnik::geometry_type pt(mapnik::Point); + mapnik::geometry_type pt(mapnik::geometry_type::types::Point); pt.move_to(10,10); BOOST_TEST( mapnik::label::centroid(pt, x, y) ); BOOST_TEST( x == 10 ); @@ -32,7 +32,7 @@ int main(int argc, char** argv) BOOST_TEST_EQ( y, 15 ); // line with two verticies - mapnik::geometry_type line(mapnik::LineString); + mapnik::geometry_type line(mapnik::geometry_type::types::LineString); line.move_to(0,0); line.move_to(50,50); BOOST_TEST( mapnik::label::centroid(line, x, y) ); diff --git a/tests/cpp_tests/map_request_test.cpp b/tests/cpp_tests/map_request_test.cpp index fabfd34ab..610f9f12c 100644 --- a/tests/cpp_tests/map_request_test.cpp +++ b/tests/cpp_tests/map_request_test.cpp @@ -17,16 +17,16 @@ #include #include #include + #include #include #include - #include "utils.hpp" bool compare_images(std::string const& src_fn,std::string const& dest_fn) { using namespace mapnik; - std::auto_ptr reader1(mapnik::get_image_reader(dest_fn,"png")); + std::unique_ptr reader1(mapnik::get_image_reader(dest_fn,"png")); if (!reader1.get()) { throw mapnik::image_reader_exception("Failed to load: " + dest_fn); @@ -34,7 +34,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn) boost::shared_ptr image_ptr1 = boost::make_shared(reader1->width(),reader1->height()); reader1->read(0,0,image_ptr1->data()); - std::auto_ptr reader2(mapnik::get_image_reader(src_fn,"png")); + std::unique_ptr reader2(mapnik::get_image_reader(src_fn,"png")); if (!reader2.get()) { throw mapnik::image_reader_exception("Failed to load: " + src_fn); @@ -116,7 +116,7 @@ int main(int argc, char** argv) mapnik::projection map_proj(m.srs(),true); double scale_denom = mapnik::scale_denominator(req.scale(),map_proj.is_geographic()); scale_denom *= scale_factor; - BOOST_FOREACH ( mapnik::layer const& lyr, m.layers() ) + for (mapnik::layer const& lyr : m.layers() ) { if (lyr.visible(scale_denom)) { diff --git a/utils/geometry_to_wkb/main.cpp b/utils/geometry_to_wkb/main.cpp index 5dd23aa32..b8048f283 100644 --- a/utils/geometry_to_wkb/main.cpp +++ b/utils/geometry_to_wkb/main.cpp @@ -29,7 +29,7 @@ #include #include -#include + int main (int argc, char ** argv ) @@ -70,7 +70,7 @@ int main (int argc, char ** argv ) mapnik::query q(ds->envelope()); mapnik::layer_descriptor layer_desc = ds->get_descriptor(); - BOOST_FOREACH ( mapnik::attribute_descriptor const& attr_desc, layer_desc.get_descriptors()) + for (mapnik::attribute_descriptor const& attr_desc : layer_desc.get_descriptors()) { q.add_property_name(attr_desc.get_name()); } @@ -82,7 +82,7 @@ int main (int argc, char ** argv ) { std::cerr << *f << std::endl; boost::ptr_vector & paths = f->paths(); - BOOST_FOREACH ( mapnik::geometry_type const& geom, paths) + for (mapnik::geometry_type const& geom : paths) { // NDR { From 6e6cff46131bcb1cd18405bf5f13e8ac7757dd90 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 20 Sep 2013 12:47:43 +0100 Subject: [PATCH 112/122] remove has_nothrow_copy as it was triggering requirement for move ctor in UnicodeString which is not _yet_ available --- include/mapnik/value.hpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index 0c939498a..f4f6927b4 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -47,16 +47,6 @@ #include #include -namespace boost { - - template <> - struct has_nothrow_copy - : mpl::true_ - { - }; - -} - namespace mapnik { inline void to_utf8(mapnik::value_unicode_string const& input, std::string & target) From b315eb2167b08a302ef4c8b20db69d23e9cc070c Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 20 Sep 2013 14:00:11 +0100 Subject: [PATCH 113/122] + use std::shared_ptr and std::make_shared --- benchmark/run.cpp | 8 ++--- bindings/python/mapnik_datasource.cpp | 10 +++--- bindings/python/mapnik_datasource_cache.cpp | 2 +- bindings/python/mapnik_feature.cpp | 2 +- bindings/python/mapnik_featureset.cpp | 2 +- bindings/python/mapnik_geometry.cpp | 14 ++++---- bindings/python/mapnik_grid.cpp | 2 +- bindings/python/mapnik_grid_view.cpp | 2 +- bindings/python/mapnik_image.cpp | 18 +++++----- .../mapnik_label_collision_detector.cpp | 13 ++++--- bindings/python/mapnik_palette.cpp | 6 ++-- bindings/python/mapnik_parameters.cpp | 10 +++--- bindings/python/mapnik_python.cpp | 10 +++--- bindings/python/mapnik_text_placement.cpp | 32 ++++++++--------- bindings/python/mapnik_wkt_reader.cpp | 4 +-- .../geometry/extensions/index/rtree/rtree.hpp | 5 ++- .../extensions/index/rtree/rtree_leaf.hpp | 3 +- .../extensions/index/rtree/rtree_node.hpp | 4 +-- demo/viewer/layerlistmodel.cpp | 7 +--- demo/viewer/layerlistmodel.hpp | 4 +-- demo/viewer/mainwindow.cpp | 6 ++-- demo/viewer/mapwidget.cpp | 4 +-- demo/viewer/mapwidget.hpp | 6 ++-- demo/viewer/styles_model.cpp | 8 ++--- demo/viewer/styles_model.hpp | 4 +-- include/mapnik/agg_renderer.hpp | 6 ++-- include/mapnik/cairo_context.hpp | 16 ++++----- include/mapnik/cairo_renderer.hpp | 8 ++--- include/mapnik/datasource.hpp | 4 +-- include/mapnik/datasource_cache.hpp | 4 +-- include/mapnik/expression.hpp | 2 +- include/mapnik/expression_string.hpp | 2 +- include/mapnik/feature.hpp | 6 ++-- include/mapnik/feature_factory.hpp | 4 +-- .../mapnik/feature_style_processor_impl.hpp | 4 +-- include/mapnik/font_engine_freetype.hpp | 12 +++---- include/mapnik/formatting/base.hpp | 2 +- include/mapnik/geometry.hpp | 2 +- include/mapnik/grid/grid_renderer.hpp | 2 +- include/mapnik/mapped_memory_cache.hpp | 2 +- include/mapnik/marker.hpp | 6 ++-- include/mapnik/marker_cache.hpp | 2 +- include/mapnik/path_expression.hpp | 2 +- include/mapnik/pool.hpp | 2 +- include/mapnik/raster_colorizer.hpp | 4 +-- include/mapnik/shield_symbolizer.hpp | 2 +- .../mapnik/svg/output/svg_path_iterator.hpp | 6 ++-- include/mapnik/svg/output/svg_renderer.hpp | 2 +- include/mapnik/symbolizer.hpp | 2 +- include/mapnik/text_path.hpp | 2 +- include/mapnik/text_placements/base.hpp | 4 +-- include/mapnik/text_symbolizer.hpp | 2 +- include/mapnik/transform_expression.hpp | 2 +- plugins/input/csv/csv_datasource.cpp | 4 +-- plugins/input/gdal/gdal_datasource.cpp | 4 +-- plugins/input/gdal/gdal_featureset.cpp | 4 +-- plugins/input/geojson/geojson_datasource.cpp | 4 +-- plugins/input/geojson/geojson_datasource.hpp | 4 +-- plugins/input/occi/occi_datasource.cpp | 8 ++--- plugins/input/ogr/ogr_datasource.cpp | 4 +-- plugins/input/osm/osm_datasource.cpp | 4 +-- plugins/input/osm/osm_featureset.cpp | 2 +- plugins/input/postgis/connection.hpp | 4 +-- plugins/input/postgis/connection_manager.hpp | 10 +++--- plugins/input/postgis/cursorresultset.hpp | 6 ++-- plugins/input/postgis/postgis_datasource.cpp | 18 +++++----- plugins/input/postgis/postgis_datasource.hpp | 2 +- plugins/input/postgis/postgis_featureset.cpp | 2 +- plugins/input/postgis/postgis_featureset.hpp | 4 +-- plugins/input/python/python_datasource.cpp | 4 +-- plugins/input/raster/raster_datasource.cpp | 6 ++-- plugins/input/raster/raster_featureset.cpp | 4 +-- .../rasterlite/rasterlite_datasource.cpp | 5 ++- .../rasterlite/rasterlite_featureset.cpp | 4 +-- plugins/input/shape/shape_datasource.cpp | 10 +++--- plugins/input/shape/shape_datasource.hpp | 2 +- plugins/input/shape/shape_featureset.cpp | 2 +- .../input/shape/shape_index_featureset.cpp | 4 +-- plugins/input/shape/shape_io.cpp | 2 +- plugins/input/shape/shape_io.hpp | 4 +-- plugins/input/sqlite/sqlite_connection.hpp | 4 +-- plugins/input/sqlite/sqlite_datasource.cpp | 18 +++++----- plugins/input/sqlite/sqlite_datasource.hpp | 2 +- plugins/input/sqlite/sqlite_featureset.cpp | 2 +- plugins/input/sqlite/sqlite_featureset.hpp | 4 +-- plugins/input/sqlite/sqlite_prepared.hpp | 4 +-- plugins/input/sqlite/sqlite_utils.hpp | 36 +++++++++---------- .../templates/helloworld/hello_datasource.cpp | 2 +- .../templates/helloworld/hello_featureset.cpp | 3 +- src/agg/agg_renderer.cpp | 8 ++--- src/agg/process_point_symbolizer.cpp | 2 +- src/cairo_context.cpp | 2 +- src/cairo_renderer.cpp | 22 ++++++------ src/datasource_cache.cpp | 6 ++-- src/datasource_cache_static.cpp | 2 +- src/expression.cpp | 2 +- src/font_engine_freetype.cpp | 10 +++--- src/formatting/text.cpp | 2 +- src/grid/grid.cpp | 4 +-- src/grid/grid_renderer.cpp | 4 +-- src/grid/process_point_symbolizer.cpp | 2 +- src/load_map.cpp | 20 +++++------ src/map.cpp | 2 +- src/mapped_memory_cache.cpp | 4 +-- src/marker_cache.cpp | 12 +++---- src/memory_datasource.cpp | 4 +-- src/parse_path.cpp | 2 +- src/parse_transform.cpp | 2 +- src/rule.cpp | 4 +-- src/svg/output/svg_renderer.cpp | 4 +-- src/text_placements/dummy.cpp | 2 +- src/text_placements/list.cpp | 3 +- src/text_placements/simple.cpp | 4 +-- src/text_properties.cpp | 2 +- src/tiff_reader.cpp | 2 +- tests/cpp_tests/fontset_runtime_test.cpp | 4 +-- tests/cpp_tests/map_request_test.cpp | 4 +-- utils/pgsql2sqlite/main.cpp | 2 +- utils/pgsql2sqlite/pgsql2sqlite.hpp | 4 +-- utils/pgsql2sqlite/sqlite.hpp | 3 +- 120 files changed, 322 insertions(+), 334 deletions(-) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index 061bcb6e6..baa21d738 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -98,7 +98,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn) { throw mapnik::image_reader_exception("Failed to load: " + dest_fn); } - boost::shared_ptr image_ptr1 = boost::make_shared(reader1->width(),reader1->height()); + std::shared_ptr image_ptr1 = std::make_shared(reader1->width(),reader1->height()); reader1->read(0,0,image_ptr1->data()); std::unique_ptr reader2(mapnik::get_image_reader(src_fn,"png")); @@ -106,7 +106,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn) { throw mapnik::image_reader_exception("Failed to load: " + src_fn); } - boost::shared_ptr image_ptr2 = boost::make_shared(reader2->width(),reader2->height()); + std::shared_ptr image_ptr2 = std::make_shared(reader2->width(),reader2->height()); reader2->read(0,0,image_ptr2->data()); image_data_32 const& dest = image_ptr1->data(); @@ -156,7 +156,7 @@ struct test2 { unsigned iter_; unsigned threads_; - boost::shared_ptr im_; + std::shared_ptr im_; explicit test2(unsigned iterations, unsigned threads=0) : iter_(iterations), threads_(threads), @@ -168,7 +168,7 @@ struct test2 { throw mapnik::image_reader_exception("Failed to load: " + filename); } - im_ = boost::make_shared(reader->width(),reader->height()); + im_ = std::make_shared(reader->width(),reader->height()); reader->read(0,0,im_->data()); } diff --git a/bindings/python/mapnik_datasource.cpp b/bindings/python/mapnik_datasource.cpp index 85e2ff721..4ed1032d0 100644 --- a/bindings/python/mapnik_datasource.cpp +++ b/bindings/python/mapnik_datasource.cpp @@ -48,7 +48,7 @@ namespace { //user-friendly wrapper that uses Python dictionary using namespace boost::python; -boost::shared_ptr create_datasource(dict const& d) +std::shared_ptr create_datasource(dict const& d) { mapnik::parameters params; boost::python::list keys=d.keys(); @@ -92,7 +92,7 @@ boost::shared_ptr create_datasource(dict const& d) return mapnik::datasource_cache::instance().create(params); } -boost::python::dict describe(boost::shared_ptr const& ds) +boost::python::dict describe(std::shared_ptr const& ds) { boost::python::dict description; mapnik::layer_descriptor ld = ds->get_descriptor(); @@ -103,7 +103,7 @@ boost::python::dict describe(boost::shared_ptr const& ds) return description; } -boost::python::list fields(boost::shared_ptr const& ds) +boost::python::list fields(std::shared_ptr const& ds) { boost::python::list flds; if (ds) @@ -119,7 +119,7 @@ boost::python::list fields(boost::shared_ptr const& ds) } return flds; } -boost::python::list field_types(boost::shared_ptr const& ds) +boost::python::list field_types(std::shared_ptr const& ds) { boost::python::list fld_types; if (ds) @@ -173,7 +173,7 @@ void export_datasource() .value("Collection",mapnik::datasource::Collection) ; - class_, + class_, boost::noncopyable>("Datasource",no_init) .def("type",&datasource::type) .def("geometry_type",&datasource::get_geometry_type) diff --git a/bindings/python/mapnik_datasource_cache.cpp b/bindings/python/mapnik_datasource_cache.cpp index f0230f80b..0ed03fc17 100644 --- a/bindings/python/mapnik_datasource_cache.cpp +++ b/bindings/python/mapnik_datasource_cache.cpp @@ -29,7 +29,7 @@ namespace { using namespace boost::python; -boost::shared_ptr create_datasource(const dict& d) +std::shared_ptr create_datasource(const dict& d) { mapnik::parameters params; boost::python::list keys=d.keys(); diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index d1e7fc272..057d9465e 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -228,7 +228,7 @@ void export_feature() .def("push", &context_type::push) ; - class_, + class_, boost::noncopyable>("Feature",init("Default ctor.")) .def("id",&mapnik::feature_impl::id) .def("__str__",&mapnik::feature_impl::to_string) diff --git a/bindings/python/mapnik_featureset.cpp b/bindings/python/mapnik_featureset.cpp index c1f7eecd4..eadb2b7df 100644 --- a/bindings/python/mapnik_featureset.cpp +++ b/bindings/python/mapnik_featureset.cpp @@ -65,7 +65,7 @@ inline mapnik::feature_ptr next(mapnik::featureset_ptr const& itr) void export_featureset() { using namespace boost::python; - class_, + class_, boost::noncopyable>("Featureset",no_init) .def("__iter__",pass_through) .def("next",next) diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index 9b7c3fb14..6e5127f39 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -79,25 +79,25 @@ void add_geojson_impl(path_type& p, std::string const& json) throw std::runtime_error("Failed to parse geojson geometry"); } -boost::shared_ptr from_wkt_impl(std::string const& wkt) +std::shared_ptr from_wkt_impl(std::string const& wkt) { - boost::shared_ptr paths = boost::make_shared(); + std::shared_ptr paths = std::make_shared(); if (!mapnik::from_wkt(wkt, *paths)) throw std::runtime_error("Failed to parse WKT"); return paths; } -boost::shared_ptr from_wkb_impl(std::string const& wkb) +std::shared_ptr from_wkb_impl(std::string const& wkb) { - boost::shared_ptr paths = boost::make_shared(); + std::shared_ptr paths = std::make_shared(); if (!mapnik::geometry_utils::from_wkb(*paths, wkb.c_str(), wkb.size())) throw std::runtime_error("Failed to parse WKB"); return paths; } -boost::shared_ptr from_geojson_impl(std::string const& json) +std::shared_ptr from_geojson_impl(std::string const& json) { - boost::shared_ptr paths = boost::make_shared(); + std::shared_ptr paths = std::make_shared(); if (! mapnik::json::from_geojson(json, *paths)) throw std::runtime_error("Failed to parse geojson geometry"); return paths; @@ -294,7 +294,7 @@ void export_geometry() // TODO add other geometry_type methods ; - class_, boost::noncopyable>("Path") + class_, boost::noncopyable>("Path") .def("__getitem__", getitem_impl,return_value_policy()) .def("__len__", &path_type::size) .def("envelope",envelope_impl) diff --git a/bindings/python/mapnik_grid.cpp b/bindings/python/mapnik_grid.cpp index 09b21ee3d..b57b162e0 100644 --- a/bindings/python/mapnik_grid.cpp +++ b/bindings/python/mapnik_grid.cpp @@ -55,7 +55,7 @@ mapnik::grid::value_type get_pixel(mapnik::grid const& grid, int x, int y) void export_grid() { - class_ >( + class_ >( "Grid", "This class represents a feature hitgrid.", init( diff --git a/bindings/python/mapnik_grid_view.cpp b/bindings/python/mapnik_grid_view.cpp index 5e9d2745f..82e687ed2 100644 --- a/bindings/python/mapnik_grid_view.cpp +++ b/bindings/python/mapnik_grid_view.cpp @@ -41,7 +41,7 @@ static dict (*encode)( mapnik::grid_view const&, std::string const& , bool, unsi void export_grid_view() { class_ >("GridView", + std::shared_ptr >("GridView", "This class represents a feature hitgrid subset.",no_init) .def("width",&mapnik::grid_view::width) .def("height",&mapnik::grid_view::height) diff --git a/bindings/python/mapnik_image.cpp b/bindings/python/mapnik_image.cpp index 884f1324a..9379037dc 100644 --- a/bindings/python/mapnik_image.cpp +++ b/bindings/python/mapnik_image.cpp @@ -146,7 +146,7 @@ void set_pixel(mapnik::image_32 & im, unsigned x, unsigned y, mapnik::color cons im.setPixel(x, y, c.rgba()); } -boost::shared_ptr open_from_file(std::string const& filename) +std::shared_ptr open_from_file(std::string const& filename) { boost::optional type = type_from_filename(filename); if (type) @@ -155,7 +155,7 @@ boost::shared_ptr open_from_file(std::string const& filename) if (reader.get()) { - boost::shared_ptr image_ptr = boost::make_shared(reader->width(),reader->height()); + std::shared_ptr image_ptr = std::make_shared(reader->width(),reader->height()); reader->read(0,0,image_ptr->data()); return image_ptr; } @@ -164,19 +164,19 @@ boost::shared_ptr open_from_file(std::string const& filename) throw mapnik::image_reader_exception("Unsupported image format:" + filename); } -boost::shared_ptr fromstring(std::string const& str) +std::shared_ptr fromstring(std::string const& str) { std::unique_ptr reader(get_image_reader(str.c_str(),str.size())); if (reader.get()) { - boost::shared_ptr image_ptr = boost::make_shared(reader->width(),reader->height()); + std::shared_ptr image_ptr = std::make_shared(reader->width(),reader->height()); reader->read(0,0,image_ptr->data()); return image_ptr; } throw mapnik::image_reader_exception("Failed to load image from buffer" ); } -boost::shared_ptr frombuffer(PyObject * obj) +std::shared_ptr frombuffer(PyObject * obj) { void const* buffer=0; Py_ssize_t buffer_len; @@ -185,7 +185,7 @@ boost::shared_ptr frombuffer(PyObject * obj) std::unique_ptr reader(get_image_reader(reinterpret_cast(buffer),buffer_len)); if (reader.get()) { - boost::shared_ptr image_ptr = boost::make_shared(reader->width(),reader->height()); + std::shared_ptr image_ptr = std::make_shared(reader->width(),reader->height()); reader->read(0,0,image_ptr->data()); return image_ptr; } @@ -205,10 +205,10 @@ void composite(image_32 & dst, image_32 & src, mapnik::composite_mode_e mode, fl } #if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO) -boost::shared_ptr from_cairo(PycairoSurface* py_surface) +std::shared_ptr from_cairo(PycairoSurface* py_surface) { mapnik::cairo_surface_ptr surface(py_surface->surface, mapnik::cairo_surface_closer()); - boost::shared_ptr image_ptr = boost::make_shared(surface); + std::shared_ptr image_ptr = std::make_shared(surface); return image_ptr; } #endif @@ -253,7 +253,7 @@ void export_image() .value("value", mapnik::_value) ; - class_ >("Image","This class represents a 32 bit RGBA image.",init()) + class_ >("Image","This class represents a 32 bit RGBA image.",init()) .def("width",&image_32::width) .def("height",&image_32::height) .def("view",&image_32::get_view) diff --git a/bindings/python/mapnik_label_collision_detector.cpp b/bindings/python/mapnik_label_collision_detector.cpp index 55747e41f..e3b047d89 100644 --- a/bindings/python/mapnik_label_collision_detector.cpp +++ b/bindings/python/mapnik_label_collision_detector.cpp @@ -35,27 +35,26 @@ using mapnik::label_collision_detector4; using mapnik::box2d; using mapnik::Map; -using boost::make_shared; namespace { -boost::shared_ptr +std::shared_ptr create_label_collision_detector_from_extent(box2d const &extent) { - return make_shared(extent); + return std::make_shared(extent); } -boost::shared_ptr +std::shared_ptr create_label_collision_detector_from_map(Map const &m) { double buffer = m.buffer_size(); box2d extent(-buffer, -buffer, m.width() + buffer, m.height() + buffer); - return make_shared(extent); + return std::make_shared(extent); } boost::python::list -make_label_boxes(boost::shared_ptr det) +make_label_boxes(std::shared_ptr det) { boost::python::list boxes; @@ -77,7 +76,7 @@ void export_label_collision_detector() // for overload resolution void (label_collision_detector4::*insert_box)(box2d const &) = &label_collision_detector4::insert; - class_, boost::noncopyable> + class_, boost::noncopyable> ("LabelCollisionDetector", "Object to detect collisions between labels, used in the rendering process.", no_init) diff --git a/bindings/python/mapnik_palette.cpp b/bindings/python/mapnik_palette.cpp index d28f081c8..203694768 100644 --- a/bindings/python/mapnik_palette.cpp +++ b/bindings/python/mapnik_palette.cpp @@ -31,7 +31,7 @@ // stl #include -static boost::shared_ptr make_palette( std::string const& palette, std::string const& format ) +static std::shared_ptr make_palette( std::string const& palette, std::string const& format ) { mapnik::rgba_palette::palette_type type = mapnik::rgba_palette::PALETTE_RGBA; if (format == "rgb") @@ -40,7 +40,7 @@ static boost::shared_ptr make_palette( std::string const& type = mapnik::rgba_palette::PALETTE_ACT; else throw std::runtime_error("invalid type passed for mapnik.Palette: must be either rgba, rgb, or act"); - return boost::make_shared(palette, type); + return std::make_shared(palette, type); } void export_palette () @@ -48,7 +48,7 @@ void export_palette () using namespace boost::python; class_, + std::shared_ptr, boost::noncopyable >("Palette",no_init) //, init( // ( arg("palette"), arg("type")), diff --git a/bindings/python/mapnik_parameters.cpp b/bindings/python/mapnik_parameters.cpp index eb213e2d1..2a8884374 100644 --- a/bindings/python/mapnik_parameters.cpp +++ b/bindings/python/mapnik_parameters.cpp @@ -176,22 +176,22 @@ mapnik::value_holder get_param(mapnik::parameter const& p, int index) } } -boost::shared_ptr create_parameter(mapnik::value_unicode_string const& key, mapnik::value_holder const& value) +std::shared_ptr create_parameter(mapnik::value_unicode_string const& key, mapnik::value_holder const& value) { std::string key_utf8; mapnik::to_utf8(key, key_utf8); - return boost::make_shared(key_utf8,value); + return std::make_shared(key_utf8,value); } // needed for Python_Unicode to std::string (utf8) conversion -boost::shared_ptr create_parameter_from_string(mapnik::value_unicode_string const& key, mapnik::value_unicode_string const& ustr) +std::shared_ptr create_parameter_from_string(mapnik::value_unicode_string const& key, mapnik::value_unicode_string const& ustr) { std::string key_utf8; std::string ustr_utf8; mapnik::to_utf8(key, key_utf8); mapnik::to_utf8(ustr,ustr_utf8); - return boost::make_shared(key_utf8, ustr_utf8); + return std::make_shared(key_utf8, ustr_utf8); } void export_parameters() @@ -202,7 +202,7 @@ void export_parameters() implicitly_convertible(); implicitly_convertible(); - class_ >("Parameter",no_init) + class_ >("Parameter",no_init) .def("__init__", make_constructor(create_parameter), "Create a mapnik.Parameter from a pair of values, the first being a string\n" "and the second being either a string, and integer, or a float") diff --git a/bindings/python/mapnik_python.cpp b/bindings/python/mapnik_python.cpp index 7a97867f2..b932a98d0 100644 --- a/bindings/python/mapnik_python.cpp +++ b/bindings/python/mapnik_python.cpp @@ -138,7 +138,7 @@ void render(const mapnik::Map& map, void render_with_detector( const mapnik::Map &map, mapnik::image_32 &image, - boost::shared_ptr detector, + std::shared_ptr detector, double scale_factor = 1.0, unsigned offset_x = 0u, unsigned offset_y = 0u) @@ -213,7 +213,7 @@ void render6(const mapnik::Map& map, PycairoContext* py_context) void render_with_detector2( const mapnik::Map& map, PycairoContext* py_context, - boost::shared_ptr detector) + std::shared_ptr detector) { python_unblock_auto_block b; mapnik::cairo_ptr context(py_context->ctx, mapnik::cairo_closer()); @@ -224,7 +224,7 @@ void render_with_detector2( void render_with_detector3( const mapnik::Map& map, PycairoContext* py_context, - boost::shared_ptr detector, + std::shared_ptr detector, double scale_factor = 1.0, unsigned offset_x = 0u, unsigned offset_y = 0u) @@ -238,7 +238,7 @@ void render_with_detector3( void render_with_detector4( const mapnik::Map& map, PycairoSurface* py_surface, - boost::shared_ptr detector) + std::shared_ptr detector) { python_unblock_auto_block b; mapnik::cairo_surface_ptr surface(cairo_surface_reference(py_surface->surface), mapnik::cairo_surface_closer()); @@ -249,7 +249,7 @@ void render_with_detector4( void render_with_detector5( const mapnik::Map& map, PycairoSurface* py_surface, - boost::shared_ptr detector, + std::shared_ptr detector, double scale_factor = 1.0, unsigned offset_x = 0u, unsigned offset_y = 0u) diff --git a/bindings/python/mapnik_text_placement.cpp b/bindings/python/mapnik_text_placement.cpp index c2b08eb50..deaae18bb 100644 --- a/bindings/python/mapnik_text_placement.cpp +++ b/bindings/python/mapnik_text_placement.cpp @@ -432,17 +432,17 @@ void export_text_placement() ; class_, + std::shared_ptr, boost::noncopyable> ("TextPlacements") .def_readwrite("defaults", &text_placements::defaults) .def("get_placement_info", pure_virtual(&text_placements::get_placement_info)) /* TODO: add_expressions() */ ; - register_ptr_to_python >(); + register_ptr_to_python >(); class_, + std::shared_ptr, boost::noncopyable> ("TextPlacementInfo", init()) @@ -453,11 +453,11 @@ void export_text_placement() .def_readwrite("properties", &text_placement_info::properties) .def_readwrite("scale_factor", &text_placement_info::scale_factor) ; - register_ptr_to_python >(); + register_ptr_to_python >(); class_, + std::shared_ptr, boost::noncopyable> ("ProcessedText", no_init) .def("push_back", &processed_text::push_back) @@ -466,7 +466,7 @@ void export_text_placement() class_, + std::shared_ptr, boost::noncopyable> ("ExpressionSet") .def("insert", &insert_expression); @@ -475,7 +475,7 @@ void export_text_placement() //TODO: Python namespace class_, + std::shared_ptr, boost::noncopyable> ("FormattingNode") .def("apply", pure_virtual(&formatting::node::apply)) @@ -483,11 +483,11 @@ void export_text_placement() &formatting::node::add_expressions, &NodeWrap::default_add_expressions) ; - register_ptr_to_python >(); + register_ptr_to_python >(); class_, + std::shared_ptr, bases, boost::noncopyable> ("FormattingText", init()) @@ -497,11 +497,11 @@ void export_text_placement() &formatting::text_node::get_text, &formatting::text_node::set_text) ; - register_ptr_to_python >(); + register_ptr_to_python >(); class_with_converter, + std::shared_ptr, bases, boost::noncopyable> ("FormattingFormat") @@ -522,10 +522,10 @@ void export_text_placement() &formatting::format_node::get_child, &formatting::format_node::set_child) ; - register_ptr_to_python >(); + register_ptr_to_python >(); class_, + std::shared_ptr, bases, boost::noncopyable> ("FormattingList", init<>()) @@ -538,10 +538,10 @@ void export_text_placement() .def("append", &ListNodeWrap::append) ; - register_ptr_to_python >(); + register_ptr_to_python >(); class_, + std::shared_ptr, bases, boost::noncopyable> ("FormattingExpressionFormat") @@ -561,7 +561,7 @@ void export_text_placement() &formatting::expression_format::get_child, &formatting::expression_format::set_child) ; - register_ptr_to_python >(); + register_ptr_to_python >(); //TODO: registry } diff --git a/bindings/python/mapnik_wkt_reader.cpp b/bindings/python/mapnik_wkt_reader.cpp index 3e9fa9be4..2c041412b 100644 --- a/bindings/python/mapnik_wkt_reader.cpp +++ b/bindings/python/mapnik_wkt_reader.cpp @@ -34,9 +34,9 @@ namespace impl { typedef boost::ptr_vector path_type; -boost::shared_ptr from_wkt(mapnik::wkt_parser & p, std::string const& wkt) +std::shared_ptr from_wkt(mapnik::wkt_parser & p, std::string const& wkt) { - boost::shared_ptr paths = boost::make_shared(); + std::shared_ptr paths = std::make_shared(); if (!p.parse(wkt, *paths)) throw std::runtime_error("Failed to parse WKT"); return paths; diff --git a/boost/geometry/extensions/index/rtree/rtree.hpp b/boost/geometry/extensions/index/rtree/rtree.hpp index 372a27d03..4b9c50886 100644 --- a/boost/geometry/extensions/index/rtree/rtree.hpp +++ b/boost/geometry/extensions/index/rtree/rtree.hpp @@ -32,8 +32,8 @@ class rtree { public: - typedef boost::shared_ptr > node_pointer; - typedef boost::shared_ptr > leaf_pointer; + typedef std::shared_ptr > node_pointer; + typedef std::shared_ptr > leaf_pointer; /** * \brief Creates a rtree with 'maximum' elements per node and 'minimum'. @@ -771,4 +771,3 @@ private: }}} // namespace boost::geometry::index #endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_HPP - diff --git a/boost/geometry/extensions/index/rtree/rtree_leaf.hpp b/boost/geometry/extensions/index/rtree/rtree_leaf.hpp index 95d1a86b1..1309c4188 100644 --- a/boost/geometry/extensions/index/rtree/rtree_leaf.hpp +++ b/boost/geometry/extensions/index/rtree/rtree_leaf.hpp @@ -33,7 +33,7 @@ class rtree_leaf : public rtree_node public: /// container type for the leaves - typedef boost::shared_ptr > node_pointer; + typedef std::shared_ptr > node_pointer; typedef std::vector > leaf_map; /** @@ -250,4 +250,3 @@ private: }}} // namespace boost::geometry::index #endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_LEAF_HPP - diff --git a/boost/geometry/extensions/index/rtree/rtree_node.hpp b/boost/geometry/extensions/index/rtree/rtree_node.hpp index de35ef270..f0eaff9c9 100644 --- a/boost/geometry/extensions/index/rtree/rtree_node.hpp +++ b/boost/geometry/extensions/index/rtree/rtree_node.hpp @@ -37,8 +37,8 @@ class rtree_node { public: - typedef boost::shared_ptr > node_pointer; - typedef boost::shared_ptr > leaf_pointer; + typedef std::shared_ptr > node_pointer; + typedef std::shared_ptr > leaf_pointer; /// type for the node map typedef std::vector > node_map; diff --git a/demo/viewer/layerlistmodel.cpp b/demo/viewer/layerlistmodel.cpp index a85645174..4b1a89a8d 100644 --- a/demo/viewer/layerlistmodel.cpp +++ b/demo/viewer/layerlistmodel.cpp @@ -27,7 +27,7 @@ using mapnik::Map; -LayerListModel::LayerListModel(boost::shared_ptr map,QObject *parent) +LayerListModel::LayerListModel(std::shared_ptr map,QObject *parent) : QAbstractListModel(parent), map_(map) {} @@ -117,8 +117,3 @@ boost::optional LayerListModel::map_layer(int i) } return boost::optional(); } - - - - - diff --git a/demo/viewer/layerlistmodel.hpp b/demo/viewer/layerlistmodel.hpp index 7c155d95e..f25a81f59 100644 --- a/demo/viewer/layerlistmodel.hpp +++ b/demo/viewer/layerlistmodel.hpp @@ -34,7 +34,7 @@ class LayerListModel : public QAbstractListModel { Q_OBJECT public: - LayerListModel(boost::shared_ptr map, QObject * parent = 0); + LayerListModel(std::shared_ptr map, QObject * parent = 0); int rowCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role) const; QVariant headerData(int section, Qt::Orientation orientation, @@ -45,7 +45,7 @@ class LayerListModel : public QAbstractListModel boost::optional map_layer(int i); private: - boost::shared_ptr map_; + std::shared_ptr map_; }; #endif //LAYER_LIST_MODEL_HPP diff --git a/demo/viewer/mainwindow.cpp b/demo/viewer/mainwindow.cpp index e87e7a0d4..f2099e4c4 100644 --- a/demo/viewer/mainwindow.cpp +++ b/demo/viewer/mainwindow.cpp @@ -185,7 +185,7 @@ void MainWindow::load_map_file(QString const& filename) std::cout<<"loading "<< filename.toStdString() << std::endl; unsigned width = mapWidget_->width(); unsigned height = mapWidget_->height(); - boost::shared_ptr map(new mapnik::Map(width,height)); + std::shared_ptr map(new mapnik::Map(width,height)); mapWidget_->setMap(map); try { @@ -412,7 +412,7 @@ void MainWindow::set_default_extent(double x0,double y0, double x1, double y1) { try { - boost::shared_ptr map_ptr = mapWidget_->getMap(); + std::shared_ptr map_ptr = mapWidget_->getMap(); if (map_ptr) { mapnik::projection prj(map_ptr->srs()); @@ -433,7 +433,7 @@ void MainWindow::set_scaling_factor(double scaling_factor) void MainWindow::zoom_all() { - boost::shared_ptr map_ptr = mapWidget_->getMap(); + std::shared_ptr map_ptr = mapWidget_->getMap(); if (map_ptr) { map_ptr->zoom_all(); diff --git a/demo/viewer/mapwidget.cpp b/demo/viewer/mapwidget.cpp index dfe4bd682..9364ac8fe 100644 --- a/demo/viewer/mapwidget.cpp +++ b/demo/viewer/mapwidget.cpp @@ -606,12 +606,12 @@ void MapWidget::updateMap() } } -boost::shared_ptr MapWidget::getMap() +std::shared_ptr MapWidget::getMap() { return map_; } -void MapWidget::setMap(boost::shared_ptr map) +void MapWidget::setMap(std::shared_ptr map) { map_ = map; } diff --git a/demo/viewer/mapwidget.hpp b/demo/viewer/mapwidget.hpp index 11026a546..873d659eb 100644 --- a/demo/viewer/mapwidget.hpp +++ b/demo/viewer/mapwidget.hpp @@ -55,7 +55,7 @@ public: }; private: - boost::shared_ptr map_; + std::shared_ptr map_; int selected_; QPixmap pix_; mapnik::box2d extent_; @@ -73,9 +73,9 @@ private: public: MapWidget(QWidget *parent=0); void setTool(eTool tool); - boost::shared_ptr getMap(); + std::shared_ptr getMap(); inline QPixmap const& pixmap() const { return pix_;} - void setMap(boost::shared_ptr map); + void setMap(std::shared_ptr map); void defaultView(); void zoomToBox(mapnik::box2d const& box); void zoomIn(); diff --git a/demo/viewer/styles_model.cpp b/demo/viewer/styles_model.cpp index 208669ac0..229cbdf9f 100644 --- a/demo/viewer/styles_model.cpp +++ b/demo/viewer/styles_model.cpp @@ -199,7 +199,7 @@ struct symbolizer_icon : public boost::static_visitor { // FIXME! /* - boost::shared_ptr symbol = sym.get_image(); + std::shared_ptr symbol = sym.get_image(); if (symbol) { QImage image(symbol->getBytes(), @@ -303,7 +303,7 @@ private: class map_node { public: - explicit map_node(boost::shared_ptr map) + explicit map_node(std::shared_ptr map) : map_(map) {} ~map_node() {} @@ -318,10 +318,10 @@ public: } private: - boost::shared_ptr map_; + std::shared_ptr map_; }; -StyleModel::StyleModel(boost::shared_ptr map, QObject * parent) +StyleModel::StyleModel(std::shared_ptr map, QObject * parent) : QAbstractItemModel(parent), root_(new node(map_node(map))) { diff --git a/demo/viewer/styles_model.hpp b/demo/viewer/styles_model.hpp index 5dfb9190f..b162c92ef 100644 --- a/demo/viewer/styles_model.hpp +++ b/demo/viewer/styles_model.hpp @@ -34,7 +34,7 @@ class StyleModel : public QAbstractItemModel { Q_OBJECT public: - StyleModel(boost::shared_ptr map, QObject * parent=0); + StyleModel(std::shared_ptr map, QObject * parent=0); ~StyleModel(); // interface QModelIndex index (int row, int col, QModelIndex const& parent = QModelIndex()) const; @@ -43,7 +43,7 @@ class StyleModel : public QAbstractItemModel int columnCount( QModelIndex const& parent = QModelIndex()) const; QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; private: - //boost::shared_ptr map_; + //std::shared_ptr map_; boost::scoped_ptr root_; }; diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index be248ea94..adfdb3dd4 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -68,7 +68,7 @@ public: // create with default, empty placement detector agg_renderer(Map const& m, T & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0); // create with external placement detector, possibly non-empty - agg_renderer(Map const &m, T & pixmap, boost::shared_ptr detector, + agg_renderer(Map const &m, T & pixmap, std::shared_ptr detector, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0); // pass in mapnik::request object to provide the mutable things per render agg_renderer(Map const& m, request const& req, T & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0); @@ -147,7 +147,7 @@ protected: private: buffer_type & pixmap_; - boost::shared_ptr internal_buffer_; + std::shared_ptr internal_buffer_; mutable buffer_type * current_buffer_; mutable bool style_level_compositing_; unsigned width_; @@ -156,7 +156,7 @@ private: CoordTransform t_; freetype_engine font_engine_; face_manager font_manager_; - boost::shared_ptr detector_; + std::shared_ptr detector_; boost::scoped_ptr ras_ptr; box2d query_extent_; gamma_method_e gamma_method_; diff --git a/include/mapnik/cairo_context.hpp b/include/mapnik/cairo_context.hpp index 1011c1b3d..e71d200df 100644 --- a/include/mapnik/cairo_context.hpp +++ b/include/mapnik/cairo_context.hpp @@ -78,18 +78,18 @@ void check_object_status_and_throw_exception(T const& object) class cairo_face : private mapnik::noncopyable { public: - cairo_face(boost::shared_ptr const& engine, face_ptr const& face); + cairo_face(std::shared_ptr const& engine, face_ptr const& face); ~cairo_face(); cairo_font_face_t * face() const; private: class handle { public: - handle(boost::shared_ptr const& engine, face_ptr const& face) + handle(std::shared_ptr const& engine, face_ptr const& face) : engine_(engine), face_(face) {} private: - boost::shared_ptr engine_; + std::shared_ptr engine_; face_ptr face_; }; @@ -104,17 +104,17 @@ private: cairo_font_face_t *c_face_; }; -typedef boost::shared_ptr cairo_face_ptr; +typedef std::shared_ptr cairo_face_ptr; class cairo_face_manager : private mapnik::noncopyable { public: - cairo_face_manager(boost::shared_ptr engine); + cairo_face_manager(std::shared_ptr engine); cairo_face_ptr get_face(face_ptr face); private: typedef std::map cairo_face_cache; - boost::shared_ptr font_engine_; + std::shared_ptr font_engine_; cairo_face_cache cache_; }; @@ -268,8 +268,8 @@ struct cairo_surface_closer } }; -typedef boost::shared_ptr cairo_ptr; -typedef boost::shared_ptr cairo_surface_ptr; +typedef std::shared_ptr cairo_ptr; +typedef std::shared_ptr cairo_surface_ptr; inline cairo_ptr create_context(cairo_surface_ptr const& surface) { diff --git a/include/mapnik/cairo_renderer.hpp b/include/mapnik/cairo_renderer.hpp index c2278231d..5cbab623d 100644 --- a/include/mapnik/cairo_renderer.hpp +++ b/include/mapnik/cairo_renderer.hpp @@ -67,7 +67,7 @@ protected: unsigned offset_y=0); cairo_renderer_base(Map const& m, cairo_ptr const& cairo, - boost::shared_ptr detector, + std::shared_ptr detector, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0); @@ -143,10 +143,10 @@ protected: unsigned height_; double scale_factor_; CoordTransform t_; - boost::shared_ptr font_engine_; + std::shared_ptr font_engine_; face_manager font_manager_; cairo_face_manager face_manager_; - boost::shared_ptr detector_; + std::shared_ptr detector_; box2d query_extent_; void setup(Map const& m); }; @@ -170,7 +170,7 @@ public: unsigned offset_y=0); cairo_renderer(Map const& m, T const& obj, - boost::shared_ptr detector, + std::shared_ptr detector, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0); diff --git a/include/mapnik/datasource.hpp b/include/mapnik/datasource.hpp index b2edb91d4..ee205e186 100644 --- a/include/mapnik/datasource.hpp +++ b/include/mapnik/datasource.hpp @@ -47,7 +47,7 @@ struct MAPNIK_DECL Featureset : private mapnik::noncopyable virtual ~Featureset() {} }; -typedef boost::shared_ptr featureset_ptr; +typedef std::shared_ptr featureset_ptr; class MAPNIK_DECL datasource_exception : public std::exception { @@ -132,7 +132,7 @@ public: } }; -typedef boost::shared_ptr datasource_ptr; +typedef std::shared_ptr datasource_ptr; #ifdef MAPNIK_STATIC_PLUGINS #define DATASOURCE_PLUGIN(classname) diff --git a/include/mapnik/datasource_cache.hpp b/include/mapnik/datasource_cache.hpp index 74a70c992..b42a1985c 100644 --- a/include/mapnik/datasource_cache.hpp +++ b/include/mapnik/datasource_cache.hpp @@ -49,11 +49,11 @@ public: std::string plugin_directories(); void register_datasources(std::string const& path); bool register_datasource(std::string const& path); - boost::shared_ptr create(parameters const& params); + std::shared_ptr create(parameters const& params); private: datasource_cache(); ~datasource_cache(); - std::map > plugins_; + std::map > plugins_; bool registered_; std::vector plugin_directories_; }; diff --git a/include/mapnik/expression.hpp b/include/mapnik/expression.hpp index 8672074ee..25eccc863 100644 --- a/include/mapnik/expression.hpp +++ b/include/mapnik/expression.hpp @@ -39,7 +39,7 @@ namespace mapnik // fwd declare to reduce compile time template struct expression_grammar; -typedef boost::shared_ptr expression_ptr; +typedef std::shared_ptr expression_ptr; typedef std::set expression_set; diff --git a/include/mapnik/expression_string.hpp b/include/mapnik/expression_string.hpp index 565bc13f4..2f445755d 100644 --- a/include/mapnik/expression_string.hpp +++ b/include/mapnik/expression_string.hpp @@ -56,7 +56,7 @@ std::string to_expression_string(T const* expr_node_ptr) } template -std::string to_expression_string(boost::shared_ptr const& expr_node_ptr) +std::string to_expression_string(std::shared_ptr const& expr_node_ptr) { throw std::logic_error("to_expression_string() called with pointer argument"); // compile error intended here; comment on the next line shows in clang output diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index 067b34cff..46192cefd 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -48,7 +48,7 @@ namespace mapnik { class raster; class feature_impl; -typedef boost::shared_ptr raster_ptr; +typedef std::shared_ptr raster_ptr; template class context : private mapnik::noncopyable @@ -88,7 +88,7 @@ private: }; typedef context > context_type; -typedef boost::shared_ptr context_ptr; +typedef std::shared_ptr context_ptr; static const value default_value; @@ -310,7 +310,7 @@ inline std::ostream& operator<< (std::ostream & out,feature_impl const& f) // TODO - remove at Mapnik 3.x typedef feature_impl Feature; -typedef boost::shared_ptr feature_ptr; +typedef std::shared_ptr feature_ptr; } diff --git a/include/mapnik/feature_factory.hpp b/include/mapnik/feature_factory.hpp index 7896ef04b..f939c4f8f 100644 --- a/include/mapnik/feature_factory.hpp +++ b/include/mapnik/feature_factory.hpp @@ -35,11 +35,11 @@ namespace mapnik { struct feature_factory { - static boost::shared_ptr create (context_ptr const& ctx, mapnik::value_integer fid) + static std::shared_ptr create (context_ptr const& ctx, mapnik::value_integer fid) { //return boost::allocate_shared(boost::pool_allocator(),fid); //return boost::allocate_shared(boost::fast_pool_allocator(),fid); - return boost::make_shared(ctx,fid); + return std::make_shared(ctx,fid); } }; } diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index b1c1f4702..c7a8133f3 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -414,7 +414,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces featureset_ptr features = ds->features(q); if (features) { - boost::shared_ptr cache = boost::make_shared(); + std::shared_ptr cache = std::make_shared(); feature_ptr feature, prev; while ((feature = features->next())) { @@ -447,7 +447,7 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces else if (cache_features) { featureset_ptr features = ds->features(q); - boost::shared_ptr cache = boost::make_shared(); + std::shared_ptr cache = std::make_shared(); if (features) { feature_ptr feature; diff --git a/include/mapnik/font_engine_freetype.hpp b/include/mapnik/font_engine_freetype.hpp index 29a0bae12..85bd2c881 100644 --- a/include/mapnik/font_engine_freetype.hpp +++ b/include/mapnik/font_engine_freetype.hpp @@ -63,7 +63,7 @@ struct char_properties; class stroker; struct glyph_t; -typedef boost::shared_ptr face_ptr; +typedef std::shared_ptr face_ptr; class MAPNIK_DECL font_glyph : private mapnik::noncopyable { @@ -85,7 +85,7 @@ private: unsigned index_; }; -typedef boost::shared_ptr glyph_ptr; +typedef std::shared_ptr glyph_ptr; @@ -111,8 +111,8 @@ private: std::map dimension_cache_; }; -typedef boost::shared_ptr face_set_ptr; -typedef boost::shared_ptr stroker_ptr; +typedef std::shared_ptr face_set_ptr; +typedef std::shared_ptr stroker_ptr; class MAPNIK_DECL freetype_engine { @@ -179,7 +179,7 @@ public: face_set_ptr get_face_set(std::string const& name) { - face_set_ptr face_set = boost::make_shared(); + face_set_ptr face_set = std::make_shared(); if (face_ptr face = get_face(name)) { face_set->add(face); @@ -190,7 +190,7 @@ public: face_set_ptr get_face_set(font_set const& fset) { std::vector const& names = fset.get_face_names(); - face_set_ptr face_set = boost::make_shared(); + face_set_ptr face_set = std::make_shared(); for ( std::string const& name : names) { face_ptr face = get_face(name); diff --git a/include/mapnik/formatting/base.hpp b/include/mapnik/formatting/base.hpp index 023917326..ccb699f5e 100644 --- a/include/mapnik/formatting/base.hpp +++ b/include/mapnik/formatting/base.hpp @@ -38,7 +38,7 @@ struct char_properties; namespace formatting { class node; -typedef boost::shared_ptr node_ptr; +typedef std::shared_ptr node_ptr; class MAPNIK_DECL node { diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index 1db96e0c6..073439cee 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -153,7 +153,7 @@ public: }; typedef geometry geometry_type; -typedef boost::shared_ptr geometry_ptr; +typedef std::shared_ptr geometry_ptr; typedef boost::ptr_vector geometry_container; } diff --git a/include/mapnik/grid/grid_renderer.hpp b/include/mapnik/grid/grid_renderer.hpp index 8abf326be..fc8ad08b6 100644 --- a/include/mapnik/grid/grid_renderer.hpp +++ b/include/mapnik/grid/grid_renderer.hpp @@ -135,7 +135,7 @@ private: CoordTransform t_; freetype_engine font_engine_; face_manager font_manager_; - boost::shared_ptr detector_; + std::shared_ptr detector_; boost::scoped_ptr ras_ptr; box2d query_extent_; void setup(Map const& m); diff --git a/include/mapnik/mapped_memory_cache.hpp b/include/mapnik/mapped_memory_cache.hpp index 2526e5855..b6260d12d 100644 --- a/include/mapnik/mapped_memory_cache.hpp +++ b/include/mapnik/mapped_memory_cache.hpp @@ -37,7 +37,7 @@ namespace mapnik { -typedef boost::shared_ptr mapped_region_ptr; +typedef std::shared_ptr mapped_region_ptr; class MAPNIK_DECL mapped_memory_cache : public singleton, diff --git a/include/mapnik/marker.hpp b/include/mapnik/marker.hpp index 568f56550..c5371ef30 100644 --- a/include/mapnik/marker.hpp +++ b/include/mapnik/marker.hpp @@ -49,8 +49,8 @@ namespace mapnik typedef agg::pod_bvector attr_storage; typedef mapnik::svg::svg_storage svg_storage_type; -typedef boost::shared_ptr svg_path_ptr; -typedef boost::shared_ptr image_ptr; +typedef std::shared_ptr svg_path_ptr; +typedef std::shared_ptr image_ptr; /** * A class to hold either vector or bitmap marker data. This allows these to be treated equally * in the image caches and most of the render paths. @@ -61,7 +61,7 @@ public: marker() { // create default OGC 4x4 black pixel - bitmap_data_ = boost::optional(boost::make_shared(4,4)); + bitmap_data_ = boost::optional(std::make_shared(4,4)); (*bitmap_data_)->set(0xff000000); } diff --git a/include/mapnik/marker_cache.hpp b/include/mapnik/marker_cache.hpp index eca2decd3..00ce350bb 100644 --- a/include/mapnik/marker_cache.hpp +++ b/include/mapnik/marker_cache.hpp @@ -38,7 +38,7 @@ namespace mapnik class marker; -typedef boost::shared_ptr marker_ptr; +typedef std::shared_ptr marker_ptr; class MAPNIK_DECL marker_cache : diff --git a/include/mapnik/path_expression.hpp b/include/mapnik/path_expression.hpp index b031f4512..c13e54b50 100644 --- a/include/mapnik/path_expression.hpp +++ b/include/mapnik/path_expression.hpp @@ -38,7 +38,7 @@ struct attribute; typedef boost::variant path_component; typedef std::vector path_expression; -typedef boost::shared_ptr path_expression_ptr; +typedef std::shared_ptr path_expression_ptr; } diff --git a/include/mapnik/pool.hpp b/include/mapnik/pool.hpp index ba22cd7fa..7ed6b841f 100644 --- a/include/mapnik/pool.hpp +++ b/include/mapnik/pool.hpp @@ -45,7 +45,7 @@ namespace mapnik template class Creator> class Pool : private mapnik::noncopyable { - typedef boost::shared_ptr HolderType; + typedef std::shared_ptr HolderType; typedef std::deque ContType; Creator creator_; diff --git a/include/mapnik/raster_colorizer.hpp b/include/mapnik/raster_colorizer.hpp index 76c09fd94..2628348ef 100644 --- a/include/mapnik/raster_colorizer.hpp +++ b/include/mapnik/raster_colorizer.hpp @@ -200,7 +200,7 @@ public: //! //! \param[in, out] raster A raster stored in float32 single channel format, which gets colorized in place. //! \param[in] f The feature used to find 'NODATA' information if available - void colorize(boost::shared_ptr const& raster, feature_impl const& f) const; + void colorize(std::shared_ptr const& raster, feature_impl const& f) const; //! \brief Perform the translation of input to output @@ -227,7 +227,7 @@ private: }; -typedef boost::shared_ptr raster_colorizer_ptr; +typedef std::shared_ptr raster_colorizer_ptr; } // mapnik namespace diff --git a/include/mapnik/shield_symbolizer.hpp b/include/mapnik/shield_symbolizer.hpp index be2af2926..6b28826f2 100644 --- a/include/mapnik/shield_symbolizer.hpp +++ b/include/mapnik/shield_symbolizer.hpp @@ -38,7 +38,7 @@ namespace mapnik struct MAPNIK_DECL shield_symbolizer : public text_symbolizer, public symbolizer_with_image { - // Note - we do not use boost::make_shared below as VC2008 and VC2010 are + // Note - we do not use std::make_shared below as VC2008 and VC2010 are // not able to compile make_shared used within a constructor shield_symbolizer(text_placements_ptr placements = text_placements_ptr(new text_placements_dummy)); shield_symbolizer(expression_ptr name, diff --git a/include/mapnik/svg/output/svg_path_iterator.hpp b/include/mapnik/svg/output/svg_path_iterator.hpp index c58c2ef7a..4e7f69db9 100644 --- a/include/mapnik/svg/output/svg_path_iterator.hpp +++ b/include/mapnik/svg/output/svg_path_iterator.hpp @@ -74,7 +74,7 @@ public: path_iterator(Container const& path) : path_iterator::iterator_adaptor_(0), path_(path), - first_value_(boost::make_shared(0,0,0)) + first_value_(std::make_shared(0,0,0)) {} /*! @@ -91,7 +91,7 @@ public: explicit path_iterator(Value* first_element, Container const& path) : path_iterator::iterator_adaptor_(first_element), path_(path), - first_value_(boost::make_shared(0,0,0)) + first_value_(std::make_shared(0,0,0)) { this->increment(); } @@ -165,7 +165,7 @@ private: } Container const& path_; - boost::shared_ptr first_value_; + std::shared_ptr first_value_; }; /*! diff --git a/include/mapnik/svg/output/svg_renderer.hpp b/include/mapnik/svg/output/svg_renderer.hpp index 1e98fee09..c82078d53 100644 --- a/include/mapnik/svg/output/svg_renderer.hpp +++ b/include/mapnik/svg/output/svg_renderer.hpp @@ -161,7 +161,7 @@ private: svg::path_output_attributes path_attributes_; freetype_engine font_engine_; face_manager font_manager_; - boost::shared_ptr detector_; + std::shared_ptr detector_; svg::svg_generator generator_; box2d query_extent_; bool painted_; diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp index 3e9f58fd3..9b6cfd2f4 100644 --- a/include/mapnik/symbolizer.hpp +++ b/include/mapnik/symbolizer.hpp @@ -45,7 +45,7 @@ namespace mapnik // TODO - move these transform declares to own header namespace detail { struct transform_node; } typedef std::vector transform_list; -typedef boost::shared_ptr transform_list_ptr; +typedef std::shared_ptr transform_list_ptr; typedef transform_list_ptr transform_type; class feature_impl; diff --git a/include/mapnik/text_path.hpp b/include/mapnik/text_path.hpp index 7ef60c83e..cb565af92 100644 --- a/include/mapnik/text_path.hpp +++ b/include/mapnik/text_path.hpp @@ -195,7 +195,7 @@ public: } }; -typedef boost::shared_ptr text_path_ptr; +typedef std::shared_ptr text_path_ptr; } #endif // MAPNIK_TEXT_PATH_HPP diff --git a/include/mapnik/text_placements/base.hpp b/include/mapnik/text_placements/base.hpp index 99a7f1cd1..df375bc92 100644 --- a/include/mapnik/text_placements/base.hpp +++ b/include/mapnik/text_placements/base.hpp @@ -70,7 +70,7 @@ public: double get_actual_minimum_padding() const { return scale_factor * properties.minimum_padding; } }; -typedef boost::shared_ptr text_placement_info_ptr; +typedef std::shared_ptr text_placement_info_ptr; /** This object handles the management of all TextSymbolizer properties. It can * be used as a base class for own objects which implement new processing @@ -108,7 +108,7 @@ public: }; /** Pointer to object of class text_placements */ -typedef boost::shared_ptr text_placements_ptr; +typedef std::shared_ptr text_placements_ptr; } //ns mapnik diff --git a/include/mapnik/text_symbolizer.hpp b/include/mapnik/text_symbolizer.hpp index 3a8945ded..b2f46ec1f 100644 --- a/include/mapnik/text_symbolizer.hpp +++ b/include/mapnik/text_symbolizer.hpp @@ -57,7 +57,7 @@ DEFINE_ENUM(halo_rasterizer_e, halo_rasterizer_enum); struct MAPNIK_DECL text_symbolizer : public symbolizer_base { - // Note - we do not use boost::make_shared below as VC2008 and VC2010 are + // Note - we do not use std::make_shared below as VC2008 and VC2010 are // not able to compile make_shared used within a constructor text_symbolizer(text_placements_ptr placements = text_placements_ptr(new text_placements_dummy)); text_symbolizer(expression_ptr name, std::string const& face_name, diff --git a/include/mapnik/transform_expression.hpp b/include/mapnik/transform_expression.hpp index 7b5b55c75..5362d5822 100644 --- a/include/mapnik/transform_expression.hpp +++ b/include/mapnik/transform_expression.hpp @@ -193,7 +193,7 @@ inline void clear(transform_node& val) typedef detail::transform_node transform_node; typedef std::vector transform_list; -typedef boost::shared_ptr transform_list_ptr; +typedef std::shared_ptr transform_list_ptr; MAPNIK_DECL std::string to_expression_string(transform_node const& node); MAPNIK_DECL std::string to_expression_string(transform_list const& list); diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index db6521115..9891aa968 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -73,7 +73,7 @@ csv_datasource::csv_datasource(parameters const& params) manual_headers_(mapnik::util::trim_copy(*params.get("headers", ""))), strict_(*params.get("strict", false)), filesize_max_(*params.get("filesize_max", 20.0)), // MB - ctx_(boost::make_shared()) + ctx_(std::make_shared()) { /* TODO: general: @@ -938,7 +938,7 @@ mapnik::featureset_ptr csv_datasource::features(mapnik::query const& q) const } ++pos; } - return boost::make_shared(q.get_bbox(),features_); + return std::make_shared(q.get_bbox(),features_); } mapnik::featureset_ptr csv_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const diff --git a/plugins/input/gdal/gdal_datasource.cpp b/plugins/input/gdal/gdal_datasource.cpp index ceb6fc86d..841d62631 100644 --- a/plugins/input/gdal/gdal_datasource.cpp +++ b/plugins/input/gdal/gdal_datasource.cpp @@ -217,7 +217,7 @@ featureset_ptr gdal_datasource::features(query const& q) const gdal_query gq = q; - // TODO - move to boost::make_shared, but must reduce # of args to <= 9 + // TODO - move to std::make_shared, but must reduce # of args to <= 9 return featureset_ptr(new gdal_featureset(*open_dataset(), band_, gq, @@ -238,7 +238,7 @@ featureset_ptr gdal_datasource::features_at_point(coord2d const& pt, double tol) gdal_query gq = pt; - // TODO - move to boost::make_shared, but must reduce # of args to <= 9 + // TODO - move to std::make_shared, but must reduce # of args to <= 9 return featureset_ptr(new gdal_featureset(*open_dataset(), band_, gq, diff --git a/plugins/input/gdal/gdal_featureset.cpp b/plugins/input/gdal/gdal_featureset.cpp index f0804fcbd..642ca2eda 100644 --- a/plugins/input/gdal/gdal_featureset.cpp +++ b/plugins/input/gdal/gdal_featureset.cpp @@ -63,7 +63,7 @@ gdal_featureset::gdal_featureset(GDALDataset& dataset, double dy, boost::optional const& nodata) : dataset_(dataset), - ctx_(boost::make_shared()), + ctx_(std::make_shared()), band_(band), gquery_(q), raster_extent_(extent), @@ -215,7 +215,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q) if (im_width > 0 && im_height > 0) { - mapnik::raster_ptr raster = boost::make_shared(intersect, im_width, im_height); + mapnik::raster_ptr raster = std::make_shared(intersect, im_width, im_height); feature->set_raster(raster); mapnik::image_data_32 & image = raster->data_; image.set(0xffffffff); diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index 62c93a8ea..87c9185b9 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -130,7 +130,7 @@ geojson_datasource::geojson_datasource(parameters const& params) boost::spirit::multi_pass end = boost::spirit::make_default_multi_pass(base_iterator_type()); - mapnik::context_ptr ctx = boost::make_shared(); + mapnik::context_ptr ctx = std::make_shared(); mapnik::json::feature_collection_parser > p(ctx,*tr_); bool result = p.parse(begin,end, features_); if (!result) @@ -215,7 +215,7 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons { box_type box(point_type(b.minx(),b.miny()),point_type(b.maxx(),b.maxy())); index_array_ = tree_.find(box); - return boost::make_shared(features_, index_array_.begin(), index_array_.end()); + return std::make_shared(features_, index_array_.begin(), index_array_.end()); } // otherwise return an empty featureset pointer return mapnik::featureset_ptr(); diff --git a/plugins/input/geojson/geojson_datasource.hpp b/plugins/input/geojson/geojson_datasource.hpp index 7cad44b08..131750c87 100644 --- a/plugins/input/geojson/geojson_datasource.hpp +++ b/plugins/input/geojson/geojson_datasource.hpp @@ -54,7 +54,7 @@ public: typedef boost::geometry::model::d2::point_xy point_type; typedef boost::geometry::model::box box_type; typedef boost::geometry::index::rtree spatial_index_type; - + // constructor geojson_datasource(mapnik::parameters const& params); virtual ~geojson_datasource (); @@ -71,7 +71,7 @@ private: mapnik::layer_descriptor desc_; std::string file_; mapnik::box2d extent_; - boost::shared_ptr tr_; + std::shared_ptr tr_; std::vector features_; spatial_index_type tree_; mutable std::deque index_array_; diff --git a/plugins/input/occi/occi_datasource.cpp b/plugins/input/occi/occi_datasource.cpp index 6111c7049..1815efbad 100644 --- a/plugins/input/occi/occi_datasource.cpp +++ b/plugins/input/occi/occi_datasource.cpp @@ -523,7 +523,7 @@ featureset_ptr occi_datasource::features(query const& q) const std::set const& props = q.property_names(); std::set::const_iterator pos = props.begin(); std::set::const_iterator end = props.end(); - mapnik::context_ptr ctx = boost::make_shared(); + mapnik::context_ptr ctx = std::make_shared(); for (; pos != end; ++pos) { s << ", " << *pos; @@ -562,7 +562,7 @@ featureset_ptr occi_datasource::features(query const& q) const MAPNIK_LOG_DEBUG(occi) << "occi_datasource: " << s.str(); - return boost::make_shared(pool_, + return std::make_shared(pool_, conn_, ctx, s.str(), @@ -590,7 +590,7 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt, double tol) } std::vector::const_iterator itr = desc_.get_descriptors().begin(); std::vector::const_iterator end = desc_.get_descriptors().end(); - mapnik::context_ptr ctx = boost::make_shared(); + mapnik::context_ptr ctx = std::make_shared(); while (itr != end) { s << ", " << itr->get_name(); @@ -631,7 +631,7 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt, double tol) MAPNIK_LOG_DEBUG(occi) << "occi_datasource: " << s.str(); - return boost::make_shared(pool_, + return std::make_shared(pool_, conn_, ctx, s.str(), diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp index dd8a62307..4d686c407 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -478,7 +478,7 @@ featureset_ptr ogr_datasource::features(query const& q) const std::vector const& desc_ar = desc_.get_descriptors(); // feature context (schema) - mapnik::context_ptr ctx = boost::make_shared(); + mapnik::context_ptr ctx = std::make_shared(); std::vector::const_iterator itr = desc_ar.begin(); std::vector::const_iterator end = desc_ar.end(); @@ -521,7 +521,7 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) { std::vector const& desc_ar = desc_.get_descriptors(); // feature context (schema) - mapnik::context_ptr ctx = boost::make_shared(); + mapnik::context_ptr ctx = std::make_shared(); std::vector::const_iterator itr = desc_ar.begin(); std::vector::const_iterator end = desc_ar.end(); diff --git a/plugins/input/osm/osm_datasource.cpp b/plugins/input/osm/osm_datasource.cpp index 6b46bef05..9db56a458 100644 --- a/plugins/input/osm/osm_datasource.cpp +++ b/plugins/input/osm/osm_datasource.cpp @@ -134,7 +134,7 @@ featureset_ptr osm_datasource::features(const query& q) const filter_in_box filter(q.get_bbox()); // so we need to filter osm features by bbox here... - return boost::make_shared >(filter, + return std::make_shared >(filter, osm_data_, q.property_names(), desc_.get_encoding()); @@ -155,7 +155,7 @@ featureset_ptr osm_datasource::features_at_point(coord2d const& pt, double tol) ++itr; } - return boost::make_shared >(filter, + return std::make_shared >(filter, osm_data_, names, desc_.get_encoding()); diff --git a/plugins/input/osm/osm_featureset.cpp b/plugins/input/osm/osm_featureset.cpp index db0f62255..be60826bc 100644 --- a/plugins/input/osm/osm_featureset.cpp +++ b/plugins/input/osm/osm_featureset.cpp @@ -48,7 +48,7 @@ osm_featureset::osm_featureset(const filterT& filter, tr_(new transcoder(encoding)), dataset_ (dataset), attribute_names_ (attribute_names), - ctx_(boost::make_shared()) + ctx_(std::make_shared()) { dataset_->rewind(); } diff --git a/plugins/input/postgis/connection.hpp b/plugins/input/postgis/connection.hpp index d8726aef0..afab42934 100644 --- a/plugins/input/postgis/connection.hpp +++ b/plugins/input/postgis/connection.hpp @@ -89,7 +89,7 @@ public: return ok; } - boost::shared_ptr executeQuery(std::string const& sql, int type = 0) const + std::shared_ptr executeQuery(std::string const& sql, int type = 0) const { #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, std::string("postgis_connection::execute_query ") + sql); @@ -119,7 +119,7 @@ public: throw mapnik::datasource_exception(err_msg); } - return boost::make_shared(result); + return std::make_shared(result); } std::string status() const diff --git a/plugins/input/postgis/connection_manager.hpp b/plugins/input/postgis/connection_manager.hpp index 4fbcce2d6..30a15abb1 100644 --- a/plugins/input/postgis/connection_manager.hpp +++ b/plugins/input/postgis/connection_manager.hpp @@ -103,8 +103,8 @@ class ConnectionManager : public singleton friend class CreateStatic; typedef Pool PoolType; - typedef std::map > ContType; - typedef boost::shared_ptr HolderType; + typedef std::map > ContType; + typedef std::shared_ptr HolderType; ContType pools_; public: @@ -122,20 +122,20 @@ public: { return pools_.insert( std::make_pair(creator.id(), - boost::make_shared(creator,initialSize,maxSize))).second; + std::make_shared(creator,initialSize,maxSize))).second; } return false; } - boost::shared_ptr getPool(std::string const& key) + std::shared_ptr getPool(std::string const& key) { ContType::const_iterator itr=pools_.find(key); if (itr!=pools_.end()) { return itr->second; } - static const boost::shared_ptr emptyPool; + static const std::shared_ptr emptyPool; return emptyPool; } diff --git a/plugins/input/postgis/cursorresultset.hpp b/plugins/input/postgis/cursorresultset.hpp index 611e394f8..707a7afd5 100644 --- a/plugins/input/postgis/cursorresultset.hpp +++ b/plugins/input/postgis/cursorresultset.hpp @@ -31,7 +31,7 @@ class CursorResultSet : public IResultSet { public: - CursorResultSet(boost::shared_ptr const &conn, std::string cursorName, int fetch_count) + CursorResultSet(std::shared_ptr const &conn, std::string cursorName, int fetch_count) : conn_(conn), cursorName_(cursorName), fetch_size_(fetch_count), @@ -166,9 +166,9 @@ private: MAPNIK_LOG_DEBUG(postgis) << "postgis_cursor_resultset: FETCH result (" << cursorName_ << "): " << rs_->size() << " rows"; } - boost::shared_ptr conn_; + std::shared_ptr conn_; std::string cursorName_; - boost::shared_ptr rs_; + std::shared_ptr rs_; int fetch_size_; bool is_closed_; int *refCount_; diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp index 4b3be44ce..36411c0ae 100644 --- a/plugins/input/postgis/postgis_datasource.cpp +++ b/plugins/input/postgis/postgis_datasource.cpp @@ -51,7 +51,7 @@ const double postgis_datasource::FMAX = std::numeric_limits::max(); const std::string postgis_datasource::GEOMETRY_COLUMNS = "geometry_columns"; const std::string postgis_datasource::SPATIAL_REF_SYS = "spatial_ref_system"; -using boost::shared_ptr; +using std::shared_ptr; using mapnik::attribute_descriptor; postgis_datasource::postgis_datasource(parameters const& params) @@ -557,7 +557,7 @@ std::string postgis_datasource::populate_tokens(std::string const& sql, double s } -boost::shared_ptr postgis_datasource::get_resultset(boost::shared_ptr const &conn, std::string const& sql) const +std::shared_ptr postgis_datasource::get_resultset(std::shared_ptr const &conn, std::string const& sql) const { if (cursor_fetch_size_ > 0) { @@ -573,7 +573,7 @@ boost::shared_ptr postgis_datasource::get_resultset(boost::shared_pt throw mapnik::datasource_exception("Postgis Plugin: error creating cursor for data select." ); } - return boost::make_shared(conn, cursor_name, cursor_fetch_size_); + return std::make_shared(conn, cursor_name, cursor_fetch_size_); } else @@ -643,7 +643,7 @@ featureset_ptr postgis_datasource::features(const query& q) const s << ") AS geom"; - mapnik::context_ptr ctx = boost::make_shared(); + mapnik::context_ptr ctx = std::make_shared(); std::set const& props = q.property_names(); std::set::const_iterator pos = props.begin(); std::set::const_iterator end = props.end(); @@ -680,8 +680,8 @@ featureset_ptr postgis_datasource::features(const query& q) const s << " LIMIT " << row_limit_; } - boost::shared_ptr rs = get_resultset(conn, s.str()); - return boost::make_shared(rs, ctx, desc_.get_encoding(), !key_field_.empty()); + std::shared_ptr rs = get_resultset(conn, s.str()); + return std::make_shared(rs, ctx, desc_.get_encoding(), !key_field_.empty()); } else { @@ -739,7 +739,7 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double t std::ostringstream s; s << "SELECT ST_AsBinary(\"" << geometryColumn_ << "\") AS geom"; - mapnik::context_ptr ctx = boost::make_shared(); + mapnik::context_ptr ctx = std::make_shared(); std::vector::const_iterator itr = desc_.get_descriptors().begin(); std::vector::const_iterator end = desc_.get_descriptors().end(); @@ -775,8 +775,8 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double t s << " LIMIT " << row_limit_; } - boost::shared_ptr rs = get_resultset(conn, s.str()); - return boost::make_shared(rs, ctx, desc_.get_encoding(), !key_field_.empty()); + std::shared_ptr rs = get_resultset(conn, s.str()); + return std::make_shared(rs, ctx, desc_.get_encoding(), !key_field_.empty()); } } diff --git a/plugins/input/postgis/postgis_datasource.hpp b/plugins/input/postgis/postgis_datasource.hpp index d0f5a2beb..3f1ea34ee 100644 --- a/plugins/input/postgis/postgis_datasource.hpp +++ b/plugins/input/postgis/postgis_datasource.hpp @@ -74,7 +74,7 @@ private: std::string sql_bbox(box2d const& env) const; std::string populate_tokens(std::string const& sql, double scale_denom, box2d const& env, double pixel_width, double pixel_height) const; std::string populate_tokens(std::string const& sql) const; - boost::shared_ptr get_resultset(boost::shared_ptr const &conn, std::string const& sql) const; + std::shared_ptr get_resultset(std::shared_ptr const &conn, std::string const& sql) const; static const std::string GEOMETRY_COLUMNS; static const std::string SPATIAL_REF_SYS; diff --git a/plugins/input/postgis/postgis_featureset.cpp b/plugins/input/postgis/postgis_featureset.cpp index d23c8edba..0e1f9e50e 100644 --- a/plugins/input/postgis/postgis_featureset.cpp +++ b/plugins/input/postgis/postgis_featureset.cpp @@ -50,7 +50,7 @@ using mapnik::geometry_utils; using mapnik::feature_factory; using mapnik::context_ptr; -postgis_featureset::postgis_featureset(boost::shared_ptr const& rs, +postgis_featureset::postgis_featureset(std::shared_ptr const& rs, context_ptr const& ctx, std::string const& encoding, bool key_field) diff --git a/plugins/input/postgis/postgis_featureset.hpp b/plugins/input/postgis/postgis_featureset.hpp index 69f1963f1..3ea082394 100644 --- a/plugins/input/postgis/postgis_featureset.hpp +++ b/plugins/input/postgis/postgis_featureset.hpp @@ -43,7 +43,7 @@ class IResultSet; class postgis_featureset : public mapnik::Featureset { public: - postgis_featureset(boost::shared_ptr const& rs, + postgis_featureset(std::shared_ptr const& rs, context_ptr const& ctx, std::string const& encoding, bool key_field = false); @@ -51,7 +51,7 @@ public: ~postgis_featureset(); private: - boost::shared_ptr rs_; + std::shared_ptr rs_; context_ptr ctx_; boost::scoped_ptr tr_; unsigned totalGeomSize_; diff --git a/plugins/input/python/python_datasource.cpp b/plugins/input/python/python_datasource.cpp index 904027de8..bc490384a 100644 --- a/plugins/input/python/python_datasource.cpp +++ b/plugins/input/python/python_datasource.cpp @@ -202,7 +202,7 @@ mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const { return mapnik::featureset_ptr(); } - return boost::make_shared(features); + return std::make_shared(features); } // otherwise return an empty featureset pointer return mapnik::featureset_ptr(); @@ -226,7 +226,7 @@ mapnik::featureset_ptr python_datasource::features_at_point(mapnik::coord2d cons return mapnik::featureset_ptr(); } // otherwise, return a feature set which can iterate over the iterator - return boost::make_shared(features); + return std::make_shared(features); } catch ( boost::python::error_already_set ) { diff --git a/plugins/input/raster/raster_datasource.cpp b/plugins/input/raster/raster_datasource.cpp index 3248b527a..3ba2a43e3 100644 --- a/plugins/input/raster/raster_datasource.cpp +++ b/plugins/input/raster/raster_datasource.cpp @@ -189,7 +189,7 @@ featureset_ptr raster_datasource::features(query const& q) const tiled_multi_file_policy policy(filename_, format_, tile_size_, extent_, q.get_bbox(), width_, height_, tile_stride_); - return boost::make_shared >(policy, extent_, q); + return std::make_shared >(policy, extent_, q); } else if (width * height > static_cast(tile_size_ * tile_size_ << 2)) { @@ -197,7 +197,7 @@ featureset_ptr raster_datasource::features(query const& q) const tiled_file_policy policy(filename_, format_, tile_size_, extent_, q.get_bbox(), width_, height_); - return boost::make_shared >(policy, extent_, q); + return std::make_shared >(policy, extent_, q); } else { @@ -206,7 +206,7 @@ featureset_ptr raster_datasource::features(query const& q) const raster_info info(filename_, format_, extent_, width_, height_); single_file_policy policy(info); - return boost::make_shared >(policy, extent_, q); + return std::make_shared >(policy, extent_, q); } } diff --git a/plugins/input/raster/raster_featureset.cpp b/plugins/input/raster/raster_featureset.cpp index 0e565a9d0..370d497ce 100644 --- a/plugins/input/raster/raster_featureset.cpp +++ b/plugins/input/raster/raster_featureset.cpp @@ -49,7 +49,7 @@ raster_featureset::raster_featureset(LookupPolicy const& policy, query const& q) : policy_(policy), feature_id_(1), - ctx_(boost::make_shared()), + ctx_(std::make_shared()), extent_(extent), bbox_(q.get_bbox()), curIter_(policy_.begin()), @@ -114,7 +114,7 @@ feature_ptr raster_featureset::next() rem.maxy() + y_off + height); intersect = t.backward(feature_raster_extent); - mapnik::raster_ptr raster = boost::make_shared(intersect, width, height); + mapnik::raster_ptr raster = std::make_shared(intersect, width, height); reader->read(x_off, y_off, raster->data_); raster->premultiplied_alpha_ = reader->premultiplied_alpha(); feature->set_raster(raster); diff --git a/plugins/input/rasterlite/rasterlite_datasource.cpp b/plugins/input/rasterlite/rasterlite_datasource.cpp index 7b9d67861..ecc9d9af9 100644 --- a/plugins/input/rasterlite/rasterlite_datasource.cpp +++ b/plugins/input/rasterlite/rasterlite_datasource.cpp @@ -182,12 +182,11 @@ layer_descriptor rasterlite_datasource::get_descriptor() const featureset_ptr rasterlite_datasource::features(query const& q) const { rasterlite_query gq = q; - return boost::make_shared(open_dataset(), gq); + return std::make_shared(open_dataset(), gq); } featureset_ptr rasterlite_datasource::features_at_point(coord2d const& pt, double tol) const { rasterlite_query gq = pt; - return boost::make_shared(open_dataset(), gq); + return std::make_shared(open_dataset(), gq); } - diff --git a/plugins/input/rasterlite/rasterlite_featureset.cpp b/plugins/input/rasterlite/rasterlite_featureset.cpp index 7eb7a0ee7..52554d7aa 100644 --- a/plugins/input/rasterlite/rasterlite_featureset.cpp +++ b/plugins/input/rasterlite/rasterlite_featureset.cpp @@ -48,7 +48,7 @@ rasterlite_featureset::rasterlite_featureset(void* dataset, : dataset_(dataset), gquery_(q), first_(true), - ctx_(boost::make_shared()) + ctx_(std::make_shared()) { rasterliteSetBackgroundColor(dataset_, 255, 0, 255); rasterliteSetTransparentColor(dataset_, 255, 0, 255); @@ -129,7 +129,7 @@ feature_ptr rasterlite_featureset::get_feature(mapnik::query const& q) { if (size > 0) { - mapnik::raster_ptr rasterp = boost::make_shared(intersect, width, height); + mapnik::raster_ptr rasterp = std::make_shared(intersect, width, height); mapnik::image_data_32 & image = rasterp->data_; image.set(0xffffffff); diff --git a/plugins/input/shape/shape_datasource.cpp b/plugins/input/shape/shape_datasource.cpp index f147bb5a9..3077b7440 100644 --- a/plugins/input/shape/shape_datasource.cpp +++ b/plugins/input/shape/shape_datasource.cpp @@ -96,7 +96,7 @@ shape_datasource::shape_datasource(const parameters ¶ms) mapnik::progress_timer __stats2__(std::clog, "shape_datasource::init(get_column_description)"); #endif - boost::shared_ptr shape_ref = boost::make_shared(shape_name_); + std::shared_ptr shape_ref = std::make_shared(shape_name_); init(*shape_ref); for (int i=0;idbf().num_fields();++i) { @@ -237,7 +237,7 @@ featureset_ptr shape_datasource::features(const query& q) const if (indexed_) { shape_->shp().seek(0); - // TODO - use boost::make_shared - #760 + // TODO - use std::make_shared - #760 return featureset_ptr (new shape_index_featureset(filter, *shape_, @@ -248,7 +248,7 @@ featureset_ptr shape_datasource::features(const query& q) const } else { - return boost::make_shared >(filter, + return std::make_shared >(filter, shape_name_, q.property_names(), desc_.get_encoding(), @@ -279,7 +279,7 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt, double tol if (indexed_) { shape_->shp().seek(0); - // TODO - use boost::make_shared - #760 + // TODO - use std::make_shared - #760 return featureset_ptr (new shape_index_featureset(filter, *shape_, @@ -290,7 +290,7 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt, double tol } else { - return boost::make_shared >(filter, + return std::make_shared >(filter, shape_name_, names, desc_.get_encoding(), diff --git a/plugins/input/shape/shape_datasource.hpp b/plugins/input/shape/shape_datasource.hpp index 9f98e3065..acb2cf32f 100644 --- a/plugins/input/shape/shape_datasource.hpp +++ b/plugins/input/shape/shape_datasource.hpp @@ -68,7 +68,7 @@ private: datasource::datasource_t type_; std::string shape_name_; - boost::shared_ptr shape_; + std::shared_ptr shape_; shape_io::shapeType shape_type_; long file_length_; box2d extent_; diff --git a/plugins/input/shape/shape_featureset.cpp b/plugins/input/shape/shape_featureset.cpp index cce768704..540f58d0f 100644 --- a/plugins/input/shape/shape_featureset.cpp +++ b/plugins/input/shape/shape_featureset.cpp @@ -53,7 +53,7 @@ shape_featureset::shape_featureset(filterT const& filter, file_length_(file_length), row_limit_(row_limit), count_(0), - ctx_(boost::make_shared()) + ctx_(std::make_shared()) { shape_.shp().skip(100); setup_attributes(ctx_, attribute_names, shape_name, shape_,attr_ids_); diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index c896b9208..5b402c9f5 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -49,7 +49,7 @@ shape_index_featureset::shape_index_featureset(filterT const& filter, std::string const& shape_name, int row_limit) : filter_(filter), - ctx_(boost::make_shared()), + ctx_(std::make_shared()), shape_(shape), tr_(new mapnik::transcoder(encoding)), row_limit_(row_limit), @@ -59,7 +59,7 @@ shape_index_featureset::shape_index_featureset(filterT const& filter, shape_.shp().skip(100); setup_attributes(ctx_, attribute_names, shape_name, shape_,attr_ids_); - boost::shared_ptr index = shape_.index(); + std::shared_ptr index = shape_.index(); if (index) { #ifdef SHAPE_MEMORY_MAPPED_FILE diff --git a/plugins/input/shape/shape_io.cpp b/plugins/input/shape/shape_io.cpp index cceb7198e..a2c9ce680 100644 --- a/plugins/input/shape/shape_io.cpp +++ b/plugins/input/shape/shape_io.cpp @@ -53,7 +53,7 @@ shape_io::shape_io(std::string const& shape_name, bool open_index) { try { - index_= boost::make_shared(shape_name + INDEX); + index_= std::make_shared(shape_name + INDEX); } catch (...) { diff --git a/plugins/input/shape/shape_io.hpp b/plugins/input/shape/shape_io.hpp index 34d091f8f..3cb5e1831 100644 --- a/plugins/input/shape/shape_io.hpp +++ b/plugins/input/shape/shape_io.hpp @@ -61,7 +61,7 @@ public: shape_file& shp(); dbf_file& dbf(); - inline boost::shared_ptr& index() + inline std::shared_ptr& index() { return index_; } @@ -79,7 +79,7 @@ public: shapeType type_; shape_file shp_; dbf_file dbf_; - boost::shared_ptr index_; + std::shared_ptr index_; unsigned reclength_; unsigned id_; box2d cur_extent_; diff --git a/plugins/input/sqlite/sqlite_connection.hpp b/plugins/input/sqlite/sqlite_connection.hpp index 54908434b..c095bbb85 100644 --- a/plugins/input/sqlite/sqlite_connection.hpp +++ b/plugins/input/sqlite/sqlite_connection.hpp @@ -116,7 +116,7 @@ public: throw mapnik::datasource_exception (s.str()); } - boost::shared_ptr execute_query(std::string const& sql) + std::shared_ptr execute_query(std::string const& sql) { #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, std::string("sqlite_resultset::execute_query ") + sql); @@ -129,7 +129,7 @@ public: throw_sqlite_error(sql); } - return boost::make_shared(stmt); + return std::make_shared(stmt); } void execute(std::string const& sql) diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index f8e6e8da1..a4705e8b4 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -139,7 +139,7 @@ sqlite_datasource::sqlite_datasource(parameters const& params) } // now actually create the connection and start executing setup sql - dataset_ = boost::make_shared(dataset_name_); + dataset_ = std::make_shared(dataset_name_); boost::optional table_by_index = params.get("table_by_index"); @@ -300,7 +300,7 @@ sqlite_datasource::sqlite_datasource(parameters const& params) mapnik::progress_timer __stats2__(std::clog, "sqlite_datasource::init(create_spatial_index)"); #endif - boost::shared_ptr rs = dataset_->execute_query(query.str()); + std::shared_ptr rs = dataset_->execute_query(query.str()); if (sqlite_utils::create_spatial_index(index_db,index_table_,rs)) { //extent_initialized_ = true; @@ -437,7 +437,7 @@ boost::optional sqlite_datasource::get_geometry_ { s << " LIMIT 5"; } - boost::shared_ptr rs = dataset_->execute_query(s.str()); + std::shared_ptr rs = dataset_->execute_query(s.str()); int multi_type = 0; while (rs->is_valid() && rs->step_next()) { @@ -483,7 +483,7 @@ featureset_ptr sqlite_datasource::features(query const& q) const mapnik::box2d const& e = q.get_bbox(); std::ostringstream s; - mapnik::context_ptr ctx = boost::make_shared(); + mapnik::context_ptr ctx = std::make_shared(); s << "SELECT " << geometry_field_; if (!key_field_.empty()) @@ -536,9 +536,9 @@ featureset_ptr sqlite_datasource::features(query const& q) const MAPNIK_LOG_DEBUG(sqlite) << "sqlite_datasource: " << s.str(); - boost::shared_ptr rs(dataset_->execute_query(s.str())); + std::shared_ptr rs(dataset_->execute_query(s.str())); - return boost::make_shared(rs, + return std::make_shared(rs, ctx, desc_.get_encoding(), e, @@ -561,7 +561,7 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double to mapnik::box2d e(pt.x, pt.y, pt.x, pt.y); e.pad(tol); std::ostringstream s; - mapnik::context_ptr ctx = boost::make_shared(); + mapnik::context_ptr ctx = std::make_shared(); s << "SELECT " << geometry_field_; if (!key_field_.empty()) @@ -617,9 +617,9 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double to MAPNIK_LOG_DEBUG(sqlite) << "sqlite_datasource: " << s.str(); - boost::shared_ptr rs(dataset_->execute_query(s.str())); + std::shared_ptr rs(dataset_->execute_query(s.str())); - return boost::make_shared(rs, + return std::make_shared(rs, ctx, desc_.get_encoding(), e, diff --git a/plugins/input/sqlite/sqlite_datasource.hpp b/plugins/input/sqlite/sqlite_datasource.hpp index 516d632f6..27c22ff33 100644 --- a/plugins/input/sqlite/sqlite_datasource.hpp +++ b/plugins/input/sqlite/sqlite_datasource.hpp @@ -68,7 +68,7 @@ private: bool extent_initialized_; mapnik::datasource::datasource_t type_; std::string dataset_name_; - boost::shared_ptr dataset_; + std::shared_ptr dataset_; std::string table_; std::string fields_; std::string metadata_; diff --git a/plugins/input/sqlite/sqlite_featureset.cpp b/plugins/input/sqlite/sqlite_featureset.cpp index 56b59effb..11530809d 100644 --- a/plugins/input/sqlite/sqlite_featureset.cpp +++ b/plugins/input/sqlite/sqlite_featureset.cpp @@ -43,7 +43,7 @@ using mapnik::geometry_utils; using mapnik::transcoder; using mapnik::feature_factory; -sqlite_featureset::sqlite_featureset(boost::shared_ptr rs, +sqlite_featureset::sqlite_featureset(std::shared_ptr rs, mapnik::context_ptr const& ctx, std::string const& encoding, mapnik::box2d const& bbox, diff --git a/plugins/input/sqlite/sqlite_featureset.hpp b/plugins/input/sqlite/sqlite_featureset.hpp index 9fc5356a7..3e52b4e85 100644 --- a/plugins/input/sqlite/sqlite_featureset.hpp +++ b/plugins/input/sqlite/sqlite_featureset.hpp @@ -39,7 +39,7 @@ class sqlite_featureset : public mapnik::Featureset { public: - sqlite_featureset(boost::shared_ptr rs, + sqlite_featureset(std::shared_ptr rs, mapnik::context_ptr const& ctx, std::string const& encoding, mapnik::box2d const& bbox, @@ -50,7 +50,7 @@ public: mapnik::feature_ptr next(); private: - boost::shared_ptr rs_; + std::shared_ptr rs_; mapnik::context_ptr ctx_; boost::scoped_ptr tr_; mapnik::box2d bbox_; diff --git a/plugins/input/sqlite/sqlite_prepared.hpp b/plugins/input/sqlite/sqlite_prepared.hpp index f10ad7288..de7e31c35 100644 --- a/plugins/input/sqlite/sqlite_prepared.hpp +++ b/plugins/input/sqlite/sqlite_prepared.hpp @@ -47,7 +47,7 @@ class prepared_index_statement : mapnik::noncopyable { public: - prepared_index_statement(boost::shared_ptr ds, std::string const& sql) + prepared_index_statement(std::shared_ptr ds, std::string const& sql) : ds_(ds), stmt_(0) { @@ -133,7 +133,7 @@ public: } private: - boost::shared_ptr ds_; + std::shared_ptr ds_; sqlite3_stmt * stmt_; }; diff --git a/plugins/input/sqlite/sqlite_utils.hpp b/plugins/input/sqlite/sqlite_utils.hpp index b3cc4c025..3ccd72202 100644 --- a/plugins/input/sqlite/sqlite_utils.hpp +++ b/plugins/input/sqlite/sqlite_utils.hpp @@ -146,7 +146,7 @@ public: return false; } - static void get_tables(boost::shared_ptr ds, + static void get_tables(std::shared_ptr ds, std::vector & tables) { std::ostringstream sql; @@ -165,7 +165,7 @@ public: const int rc = sqlite3_prepare_v2 (*(*ds), sql.str().c_str(), -1, &stmt, 0); if (rc == SQLITE_OK) { - boost::shared_ptr rs = boost::make_shared(stmt); + std::shared_ptr rs = std::make_shared(stmt); while (rs->is_valid() && rs->step_next()) { const int type_oid = rs->column_type(0); @@ -181,7 +181,7 @@ public: } } - static void query_extent(boost::shared_ptr rs, + static void query_extent(std::shared_ptr rs, mapnik::box2d& extent) { @@ -218,7 +218,7 @@ public: static bool create_spatial_index(std::string const& index_db, std::string const& index_table, - boost::shared_ptr rs) + std::shared_ptr rs) { /* TODO - speedups @@ -236,7 +236,7 @@ public: #endif bool existed = mapnik::util::exists(index_db); - boost::shared_ptr ds = boost::make_shared(index_db,flags); + std::shared_ptr ds = std::make_shared(index_db,flags); bool one_success = false; try @@ -356,7 +356,7 @@ public: mapnik::box2d bbox; } rtree_type; - static void build_tree(boost::shared_ptr rs, + static void build_tree(std::shared_ptr rs, std::vector & rtree_list) { @@ -414,8 +414,8 @@ public: #endif bool existed = mapnik::util::exists(index_db);; - - boost::shared_ptr ds = boost::make_shared(index_db,flags); + + std::shared_ptr ds = std::make_shared(index_db,flags); bool one_success = false; try @@ -484,7 +484,7 @@ public: return false; } - static bool detect_extent(boost::shared_ptr ds, + static bool detect_extent(std::shared_ptr ds, bool has_spatial_index, mapnik::box2d & extent, std::string const& index_table, @@ -501,7 +501,7 @@ public: s << "SELECT xmin, ymin, xmax, ymax FROM " << metadata; s << " WHERE LOWER(f_table_name) = LOWER('" << geometry_table << "')"; MAPNIK_LOG_DEBUG(sqlite) << "sqlite_datasource: executing: '" << s.str() << "'"; - boost::shared_ptr rs(ds->execute_query(s.str())); + std::shared_ptr rs(ds->execute_query(s.str())); if (rs->is_valid() && rs->step_next()) { double xmin = rs->column_double(0); @@ -518,7 +518,7 @@ public: s << "SELECT MIN(xmin), MIN(ymin), MAX(xmax), MAX(ymax) FROM " << index_table; MAPNIK_LOG_DEBUG(sqlite) << "sqlite_datasource: executing: '" << s.str() << "'"; - boost::shared_ptr rs(ds->execute_query(s.str())); + std::shared_ptr rs(ds->execute_query(s.str())); if (rs->is_valid() && rs->step_next()) { if (! rs->column_isnull(0)) @@ -539,20 +539,20 @@ public: s << "SELECT " << geometry_field << "," << key_field << " FROM (" << table << ")"; MAPNIK_LOG_DEBUG(sqlite) << "sqlite_datasource: executing: '" << s.str() << "'"; - boost::shared_ptr rs(ds->execute_query(s.str())); + std::shared_ptr rs(ds->execute_query(s.str())); sqlite_utils::query_extent(rs,extent); return true; } return false; } - static bool has_rtree(std::string const& index_table,boost::shared_ptr ds) + static bool has_rtree(std::string const& index_table,std::shared_ptr ds) { try { std::ostringstream s; s << "SELECT pkid,xmin,xmax,ymin,ymax FROM " << index_table << " LIMIT 1"; - boost::shared_ptr rs = ds->execute_query(s.str()); + std::shared_ptr rs = ds->execute_query(s.str()); if (rs->is_valid() && rs->step_next()) { return true; @@ -569,10 +569,10 @@ public: static bool detect_types_from_subquery(std::string const& query, std::string & geometry_field, mapnik::layer_descriptor & desc, - boost::shared_ptr ds) + std::shared_ptr ds) { bool found = false; - boost::shared_ptr rs(ds->execute_query(query)); + std::shared_ptr rs(ds->execute_query(query)); if (rs->is_valid() && rs->step_next()) { for (int i = 0; i < rs->column_count(); ++i) @@ -627,7 +627,7 @@ public: std::string & field, std::string & table, mapnik::layer_descriptor & desc, - boost::shared_ptr ds) + std::shared_ptr ds) { // http://www.sqlite.org/pragma.html#pragma_table_info @@ -636,7 +636,7 @@ public: // if the subquery-based type detection failed std::ostringstream s; s << "PRAGMA table_info(" << table << ")"; - boost::shared_ptr rs(ds->execute_query(s.str())); + std::shared_ptr rs(ds->execute_query(s.str())); bool found_table = false; bool found_pk = false; while (rs->is_valid() && rs->step_next()) diff --git a/plugins/input/templates/helloworld/hello_datasource.cpp b/plugins/input/templates/helloworld/hello_datasource.cpp index 38b1d0e10..40cddd0d6 100644 --- a/plugins/input/templates/helloworld/hello_datasource.cpp +++ b/plugins/input/templates/helloworld/hello_datasource.cpp @@ -62,7 +62,7 @@ mapnik::featureset_ptr hello_datasource::features(mapnik::query const& q) const // if the query box intersects our world extent then query for features if (extent_.intersects(q.get_bbox())) { - return boost::make_shared(q.get_bbox(),desc_.get_encoding()); + return std::make_shared(q.get_bbox(),desc_.get_encoding()); } // otherwise return an empty featureset pointer diff --git a/plugins/input/templates/helloworld/hello_featureset.cpp b/plugins/input/templates/helloworld/hello_featureset.cpp index deaabdff3..90a122006 100644 --- a/plugins/input/templates/helloworld/hello_featureset.cpp +++ b/plugins/input/templates/helloworld/hello_featureset.cpp @@ -12,7 +12,7 @@ hello_featureset::hello_featureset(mapnik::box2d const& box, std::string : box_(box), feature_id_(1), tr_(new mapnik::transcoder(encoding)), - ctx_(boost::make_shared()) { } + ctx_(std::make_shared()) { } hello_featureset::~hello_featureset() { } @@ -69,4 +69,3 @@ mapnik::feature_ptr hello_featureset::next() // otherwise return an empty feature return mapnik::feature_ptr(); } - diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index f270555cb..ce7769fe1 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -77,7 +77,7 @@ agg_renderer::agg_renderer(Map const& m, T & pixmap, double scale_factor, uns t_(m.width(),m.height(),m.get_current_extent(),offset_x,offset_y), font_engine_(), font_manager_(font_engine_), - detector_(boost::make_shared(box2d(-m.buffer_size(), -m.buffer_size(), m.width() + m.buffer_size() ,m.height() + m.buffer_size()))), + detector_(std::make_shared(box2d(-m.buffer_size(), -m.buffer_size(), m.width() + m.buffer_size() ,m.height() + m.buffer_size()))), ras_ptr(new rasterizer), query_extent_(), gamma_method_(GAMMA_POWER), @@ -99,7 +99,7 @@ agg_renderer::agg_renderer(Map const& m, request const& req, T & pixmap, doub t_(req.width(),req.height(),req.extent(),offset_x,offset_y), font_engine_(), font_manager_(font_engine_), - detector_(boost::make_shared(box2d(-req.buffer_size(), -req.buffer_size(), req.width() + req.buffer_size() ,req.height() + req.buffer_size()))), + detector_(std::make_shared(box2d(-req.buffer_size(), -req.buffer_size(), req.width() + req.buffer_size() ,req.height() + req.buffer_size()))), ras_ptr(new rasterizer), query_extent_(), gamma_method_(GAMMA_POWER), @@ -109,7 +109,7 @@ agg_renderer::agg_renderer(Map const& m, request const& req, T & pixmap, doub } template -agg_renderer::agg_renderer(Map const& m, T & pixmap, boost::shared_ptr detector, +agg_renderer::agg_renderer(Map const& m, T & pixmap, std::shared_ptr detector, double scale_factor, unsigned offset_x, unsigned offset_y) : feature_style_processor(m, scale_factor), pixmap_(pixmap), @@ -240,7 +240,7 @@ void agg_renderer::start_style_processing(feature_type_style const& st) { if (!internal_buffer_) { - internal_buffer_ = boost::make_shared(pixmap_.width(),pixmap_.height()); + internal_buffer_ = std::make_shared(pixmap_.width(),pixmap_.height()); } else { diff --git a/src/agg/process_point_symbolizer.cpp b/src/agg/process_point_symbolizer.cpp index 9046455b5..e7c3631a3 100644 --- a/src/agg/process_point_symbolizer.cpp +++ b/src/agg/process_point_symbolizer.cpp @@ -60,7 +60,7 @@ void agg_renderer::process(point_symbolizer const& sym, } else { - marker.reset(boost::make_shared()); + marker.reset(std::make_shared()); } if (marker) diff --git a/src/cairo_context.cpp b/src/cairo_context.cpp index cf04116f3..e2eebc217 100644 --- a/src/cairo_context.cpp +++ b/src/cairo_context.cpp @@ -31,7 +31,7 @@ #include namespace mapnik { -cairo_face::cairo_face(boost::shared_ptr const& engine, face_ptr const& face) +cairo_face::cairo_face(std::shared_ptr const& engine, face_ptr const& face) : face_(face) { static cairo_user_data_key_t key; diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index d74977285..c589a47df 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -96,7 +96,7 @@ struct cairo_save_restore }; -cairo_face_manager::cairo_face_manager(boost::shared_ptr engine) +cairo_face_manager::cairo_face_manager(std::shared_ptr engine) : font_engine_(engine) { } @@ -112,7 +112,7 @@ cairo_face_ptr cairo_face_manager::get_face(face_ptr face) } else { - entry = boost::make_shared(font_engine_, face); + entry = std::make_shared(font_engine_, face); cache_.insert(std::make_pair(face, entry)); } @@ -131,10 +131,10 @@ cairo_renderer_base::cairo_renderer_base(Map const& m, height_(m.height()), scale_factor_(scale_factor), t_(m.width(),m.height(),m.get_current_extent(),offset_x,offset_y), - font_engine_(boost::make_shared()), + font_engine_(std::make_shared()), font_manager_(*font_engine_), face_manager_(font_engine_), - detector_(boost::make_shared( + detector_(std::make_shared( box2d(-m.buffer_size(), -m.buffer_size(), m.width() + m.buffer_size(), m.height() + m.buffer_size()))) { @@ -153,10 +153,10 @@ cairo_renderer_base::cairo_renderer_base(Map const& m, height_(req.height()), scale_factor_(scale_factor), t_(req.width(),req.height(),req.extent(),offset_x,offset_y), - font_engine_(boost::make_shared()), + font_engine_(std::make_shared()), font_manager_(*font_engine_), face_manager_(font_engine_), - detector_(boost::make_shared( + detector_(std::make_shared( box2d(-req.buffer_size(), -req.buffer_size(), req.width() + req.buffer_size(), req.height() + req.buffer_size()))) { @@ -165,7 +165,7 @@ cairo_renderer_base::cairo_renderer_base(Map const& m, cairo_renderer_base::cairo_renderer_base(Map const& m, cairo_ptr const& cairo, - boost::shared_ptr detector, + std::shared_ptr detector, double scale_factor, unsigned offset_x, unsigned offset_y) @@ -175,7 +175,7 @@ cairo_renderer_base::cairo_renderer_base(Map const& m, height_(m.height()), scale_factor_(scale_factor), t_(m.width(),m.height(),m.get_current_extent(),offset_x,offset_y), - font_engine_(boost::make_shared()), + font_engine_(std::make_shared()), font_manager_(*font_engine_), face_manager_(font_engine_), detector_(detector) @@ -204,12 +204,12 @@ cairo_renderer::cairo_renderer(Map const& m, request const& r cairo_renderer_base(m,req, create_context(surface),scale_factor,offset_x,offset_y) {} template <> -cairo_renderer::cairo_renderer(Map const& m, cairo_ptr const& cairo, boost::shared_ptr detector, double scale_factor, unsigned offset_x, unsigned offset_y) +cairo_renderer::cairo_renderer(Map const& m, cairo_ptr const& cairo, std::shared_ptr detector, double scale_factor, unsigned offset_x, unsigned offset_y) : feature_style_processor(m,scale_factor), cairo_renderer_base(m,cairo,detector,scale_factor,offset_x,offset_y) {} template <> -cairo_renderer::cairo_renderer(Map const& m, cairo_surface_ptr const& surface, boost::shared_ptr detector, double scale_factor, unsigned offset_x, unsigned offset_y) +cairo_renderer::cairo_renderer(Map const& m, cairo_surface_ptr const& surface, std::shared_ptr detector, double scale_factor, unsigned offset_x, unsigned offset_y) : feature_style_processor(m,scale_factor), cairo_renderer_base(m,create_context(surface),detector,scale_factor,offset_x,offset_y) {} @@ -658,7 +658,7 @@ void cairo_renderer_base::process(point_symbolizer const& sym, } else { - marker.reset(boost::make_shared()); + marker.reset(std::make_shared()); } diff --git a/src/datasource_cache.cpp b/src/datasource_cache.cpp index 9773bb2be..57b46547d 100644 --- a/src/datasource_cache.cpp +++ b/src/datasource_cache.cpp @@ -82,7 +82,7 @@ datasource_ptr datasource_cache::create(parameters const& params) mutex::scoped_lock lock(mutex_); #endif - std::map >::iterator itr=plugins_.find(*type); + std::map >::iterator itr=plugins_.find(*type); if (itr == plugins_.end()) { std::string s("Could not create datasource for type: '"); @@ -152,7 +152,7 @@ std::vector datasource_cache::plugin_names() names = get_static_datasource_names(); #endif - std::map >::const_iterator itr; + std::map >::const_iterator itr; for (itr = plugins_.begin(); itr != plugins_.end(); ++itr) { names.push_back(itr->first); @@ -198,7 +198,7 @@ bool datasource_cache::register_datasource(std::string const& filename) bool success = false; try { - boost::shared_ptr plugin = boost::make_shared(filename,"datasource_name"); + std::shared_ptr plugin = std::make_shared(filename,"datasource_name"); if (plugin->valid()) { if (plugin->name().empty()) diff --git a/src/datasource_cache_static.cpp b/src/datasource_cache_static.cpp index 07e178ca4..93305dff4 100644 --- a/src/datasource_cache_static.cpp +++ b/src/datasource_cache_static.cpp @@ -87,7 +87,7 @@ namespace mapnik { template datasource_ptr ds_generator(parameters const& params) { - return boost::make_shared(params); + return std::make_shared(params); } typedef datasource_ptr (*ds_generator_ptr)(parameters const& params); diff --git a/src/expression.cpp b/src/expression.cpp index 44629de63..0de07ff65 100644 --- a/src/expression.cpp +++ b/src/expression.cpp @@ -50,7 +50,7 @@ expression_ptr parse_expression(std::string const& str, bool r = boost::spirit::qi::phrase_parse(itr, end, g, boost::spirit::standard_wide::space, node); if (r && itr == end) { - return boost::make_shared(node); + return std::make_shared(node); } else { diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 8250e1a27..f8b8ad24e 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -238,7 +238,7 @@ face_ptr freetype_engine::create_face(std::string const& family_name) itr->second.first, // face index &face); - if (!error) return boost::make_shared(face); + if (!error) return std::make_shared(face); } else { @@ -257,7 +257,7 @@ face_ptr freetype_engine::create_face(std::string const& family_name) static_cast(buffer.size()), itr->second.first, &face); - if (!error) return boost::make_shared(face); + if (!error) return std::make_shared(face); else { // we can't load font, erase it. @@ -274,7 +274,7 @@ stroker_ptr freetype_engine::create_stroker() FT_Error error = FT_Stroker_New(library_, &s); if (!error) { - return boost::make_shared(s); + return std::make_shared(s); } return stroker_ptr(); } @@ -295,11 +295,11 @@ glyph_ptr font_face_set::get_glyph(unsigned c) const for ( face_ptr const& face : faces_) { FT_UInt g = face->get_char(c); - if (g) return boost::make_shared(face, g); + if (g) return std::make_shared(face, g); } // Final fallback to empty square if nothing better in any font - return boost::make_shared(*faces_.begin(), 0); + return std::make_shared(*faces_.begin(), 0); } char_info font_face_set::character_dimensions(unsigned int c) diff --git a/src/formatting/text.cpp b/src/formatting/text.cpp index 40272f3e5..4c7433c87 100644 --- a/src/formatting/text.cpp +++ b/src/formatting/text.cpp @@ -49,7 +49,7 @@ void text_node::to_xml(ptree &xml) const node_ptr text_node::from_xml(xml_node const& xml) { - return boost::make_shared(xml.get_value()); + return std::make_shared(xml.get_value()); } void text_node::apply(char_properties const& p, feature_impl const& feature, processed_text &output) const diff --git a/src/grid/grid.cpp b/src/grid/grid.cpp index a85ae3076..087ec7747 100644 --- a/src/grid/grid.cpp +++ b/src/grid/grid.cpp @@ -47,7 +47,7 @@ hit_grid::hit_grid(int width, int height, std::string const& key, unsigned in names_(), f_keys_(), features_(), - ctx_(boost::make_shared()) + ctx_(std::make_shared()) { f_keys_[base_mask] = ""; data_.set(base_mask); @@ -80,7 +80,7 @@ void hit_grid::clear() names_.clear(); f_keys_[base_mask] = ""; data_.set(base_mask); - ctx_ = boost::make_shared(); + ctx_ = std::make_shared(); } template diff --git a/src/grid/grid_renderer.cpp b/src/grid/grid_renderer.cpp index 682934aa5..52a86c7b0 100644 --- a/src/grid/grid_renderer.cpp +++ b/src/grid/grid_renderer.cpp @@ -66,7 +66,7 @@ grid_renderer::grid_renderer(Map const& m, T & pixmap, double scale_factor, u t_(pixmap_.width(),pixmap_.height(),m.get_current_extent(),offset_x,offset_y), font_engine_(), font_manager_(font_engine_), - detector_(boost::make_shared(box2d(-m.buffer_size(), -m.buffer_size(), m.width() + m.buffer_size() ,m.height() + m.buffer_size()))), + detector_(std::make_shared(box2d(-m.buffer_size(), -m.buffer_size(), m.width() + m.buffer_size() ,m.height() + m.buffer_size()))), ras_ptr(new grid_rasterizer) { setup(m); @@ -84,7 +84,7 @@ grid_renderer::grid_renderer(Map const& m, request const& req, T & pixmap, do t_(pixmap_.width(),pixmap_.height(),req.extent(),offset_x,offset_y), font_engine_(), font_manager_(font_engine_), - detector_(boost::make_shared(box2d(-req.buffer_size(), -req.buffer_size(), req.width() + req.buffer_size() ,req.height() + req.buffer_size()))), + detector_(std::make_shared(box2d(-req.buffer_size(), -req.buffer_size(), req.width() + req.buffer_size() ,req.height() + req.buffer_size()))), ras_ptr(new grid_rasterizer) { setup(m); diff --git a/src/grid/process_point_symbolizer.cpp b/src/grid/process_point_symbolizer.cpp index 3d0d68f40..8d6e648b4 100644 --- a/src/grid/process_point_symbolizer.cpp +++ b/src/grid/process_point_symbolizer.cpp @@ -60,7 +60,7 @@ void grid_renderer::process(point_symbolizer const& sym, } else { - marker.reset(boost::make_shared()); + marker.reset(std::make_shared()); } if (marker) diff --git a/src/load_map.cpp b/src/load_map.cpp index 36de527d2..1925aa030 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -212,7 +212,7 @@ void map_parser::parse_map(Map & map, xml_node const& pt, std::string const& bas throw config_error("failed to parse background-image-comp-op: '" + *comp_op_name + "'"); } } - + optional opacity = map_node.get_opt_attr("background-image-opacity"); if (opacity) { @@ -730,7 +730,7 @@ void map_parser::parse_layer(Map & map, xml_node const& node) //now we are ready to create datasource try { - boost::shared_ptr ds = + std::shared_ptr ds = datasource_cache::instance().create(params); lyr.set_datasource(ds); } @@ -875,7 +875,7 @@ void map_parser::parse_symbolizer_base(symbolizer_base &sym, xml_node const &pt) optional geometry_transform_wkt = pt.get_opt_attr("geometry-transform"); if (geometry_transform_wkt) { - mapnik::transform_list_ptr tl = boost::make_shared(); + mapnik::transform_list_ptr tl = std::make_shared(); if (!mapnik::parse_transform(*tl, *geometry_transform_wkt, pt.get_tree().transform_expr_grammar)) { std::string ss("Could not parse transform from '"); @@ -958,7 +958,7 @@ void map_parser::parse_point_symbolizer(rule & rule, xml_node const & sym) optional image_transform_wkt = sym.get_opt_attr("transform"); if (image_transform_wkt) { - mapnik::transform_list_ptr tl = boost::make_shared(); + mapnik::transform_list_ptr tl = std::make_shared(); if (!mapnik::parse_transform(*tl, *image_transform_wkt, sym.get_tree().transform_expr_grammar)) { throw mapnik::config_error("Failed to parse transform: '" + *image_transform_wkt + "'"); @@ -1036,7 +1036,7 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& sym) optional image_transform_wkt = sym.get_opt_attr("transform"); if (image_transform_wkt) { - mapnik::transform_list_ptr tl = boost::make_shared(); + mapnik::transform_list_ptr tl = std::make_shared(); if (!mapnik::parse_transform(*tl, *image_transform_wkt, sym.get_tree().transform_expr_grammar)) { throw mapnik::config_error("Failed to parse transform: '" + *image_transform_wkt + "'"); @@ -1188,7 +1188,7 @@ void map_parser::parse_text_symbolizer(rule & rule, xml_node const& sym) if (placement_type) { placement_finder = placements::registry::instance().from_xml(*placement_type, sym, fontsets_); } else { - placement_finder = boost::make_shared(); + placement_finder = std::make_shared(); placement_finder->defaults.from_xml(sym, fontsets_); } if (strict_ && @@ -1220,7 +1220,7 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym) if (placement_type) { placement_finder = placements::registry::instance().from_xml(*placement_type, sym, fontsets_); } else { - placement_finder = boost::make_shared(); + placement_finder = std::make_shared(); } placement_finder->defaults.from_xml(sym, fontsets_); if (strict_ && @@ -1234,7 +1234,7 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym) optional image_transform_wkt = sym.get_opt_attr("transform"); if (image_transform_wkt) { - mapnik::transform_list_ptr tl = boost::make_shared(); + mapnik::transform_list_ptr tl = std::make_shared(); if (!mapnik::parse_transform(*tl, *image_transform_wkt, sym.get_tree().transform_expr_grammar)) { throw mapnik::config_error("Failed to parse transform: '" + *image_transform_wkt + "'"); @@ -1544,7 +1544,7 @@ void map_parser::parse_raster_symbolizer(rule & rule, xml_node const & sym) if (cssIter->is("RasterColorizer")) { found_colorizer = true; - raster_colorizer_ptr colorizer = boost::make_shared(); + raster_colorizer_ptr colorizer = std::make_shared(); raster_sym.set_colorizer(colorizer); if (parse_raster_colorizer(colorizer, *cssIter)) raster_sym.set_colorizer(colorizer); @@ -1554,7 +1554,7 @@ void map_parser::parse_raster_symbolizer(rule & rule, xml_node const & sym) // look for properties one level up if (!found_colorizer) { - raster_colorizer_ptr colorizer = boost::make_shared(); + raster_colorizer_ptr colorizer = std::make_shared(); if (parse_raster_colorizer(colorizer, sym)) raster_sym.set_colorizer(colorizer); } diff --git a/src/map.cpp b/src/map.cpp index 3b6b4fcfa..8c248c975 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -611,7 +611,7 @@ featureset_ptr Map::query_point(unsigned index, double x, double y) const MAPNIK_LOG_DEBUG(map) << "map: Query at point tol=" << tol << "(" << x << "," << y << ")"; if (fs) { - return boost::make_shared >(fs, + return std::make_shared >(fs, hit_test_filter(x,y,tol)); } } diff --git a/src/mapped_memory_cache.cpp b/src/mapped_memory_cache.cpp index 84cd66fde..2f2ace95c 100644 --- a/src/mapped_memory_cache.cpp +++ b/src/mapped_memory_cache.cpp @@ -71,7 +71,7 @@ boost::optional mapped_memory_cache::find(std::string const& try { boost::interprocess::file_mapping mapping(uri.c_str(),boost::interprocess::read_only); - mapped_region_ptr region(boost::make_shared(mapping,boost::interprocess::read_only)); + mapped_region_ptr region(std::make_shared(mapping,boost::interprocess::read_only)); result.reset(region); @@ -99,4 +99,4 @@ boost::optional mapped_memory_cache::find(std::string const& } -#endif \ No newline at end of file +#endif diff --git a/src/marker_cache.cpp b/src/marker_cache.cpp index 53004a219..259341866 100644 --- a/src/marker_cache.cpp +++ b/src/marker_cache.cpp @@ -141,7 +141,7 @@ boost::optional marker_cache::find(std::string const& uri, } std::string known_svg_string = mark_itr->second; using namespace mapnik::svg; - svg_path_ptr marker_path(boost::make_shared()); + svg_path_ptr marker_path(std::make_shared()); vertex_stl_adapter stl_storage(marker_path->source()); svg_path_adapter svg_path(stl_storage); svg_converter_type svg(svg_path, marker_path->attributes()); @@ -152,7 +152,7 @@ boost::optional marker_cache::find(std::string const& uri, svg.bounding_rect(&lox, &loy, &hix, &hiy); marker_path->set_bounding_box(lox,loy,hix,hiy); marker_path->set_dimensions(svg.width(),svg.height()); - marker_ptr mark(boost::make_shared(marker_path)); + marker_ptr mark(std::make_shared(marker_path)); result.reset(mark); if (update_cache) { @@ -170,7 +170,7 @@ boost::optional marker_cache::find(std::string const& uri, if (is_svg(uri)) { using namespace mapnik::svg; - svg_path_ptr marker_path(boost::make_shared()); + svg_path_ptr marker_path(std::make_shared()); vertex_stl_adapter stl_storage(marker_path->source()); svg_path_adapter svg_path(stl_storage); svg_converter_type svg(svg_path, marker_path->attributes()); @@ -181,7 +181,7 @@ boost::optional marker_cache::find(std::string const& uri, svg.bounding_rect(&lox, &loy, &hix, &hiy); marker_path->set_bounding_box(lox,loy,hix,hiy); marker_path->set_dimensions(svg.width(),svg.height()); - marker_ptr mark(boost::make_shared(marker_path)); + marker_ptr mark(std::make_shared(marker_path)); result.reset(mark); if (update_cache) { @@ -197,7 +197,7 @@ boost::optional marker_cache::find(std::string const& uri, unsigned width = reader->width(); unsigned height = reader->height(); BOOST_ASSERT(width > 0 && height > 0); - mapnik::image_ptr image(boost::make_shared(width,height)); + mapnik::image_ptr image(std::make_shared(width,height)); reader->read(0,0,*image); if (!reader->premultiplied_alpha()) { @@ -205,7 +205,7 @@ boost::optional marker_cache::find(std::string const& uri, agg::pixfmt_rgba32 pixf(buffer); pixf.premultiply(); } - marker_ptr mark(boost::make_shared(image)); + marker_ptr mark(std::make_shared(image)); result.reset(mark); if (update_cache) { diff --git a/src/memory_datasource.cpp b/src/memory_datasource.cpp index 3ea949545..8ae97efd1 100644 --- a/src/memory_datasource.cpp +++ b/src/memory_datasource.cpp @@ -83,7 +83,7 @@ datasource::datasource_t memory_datasource::type() const featureset_ptr memory_datasource::features(const query& q) const { - return boost::make_shared(q.get_bbox(),*this,bbox_check_); + return std::make_shared(q.get_bbox(),*this,bbox_check_); } @@ -92,7 +92,7 @@ featureset_ptr memory_datasource::features_at_point(coord2d const& pt, double to box2d box = box2d(pt.x, pt.y, pt.x, pt.y); box.pad(tol); MAPNIK_LOG_DEBUG(memory_datasource) << "memory_datasource: Box=" << box << ", Point x=" << pt.x << ",y=" << pt.y; - return boost::make_shared(box,*this); + return std::make_shared(box,*this); } void memory_datasource::set_envelope(box2d const& box) diff --git a/src/parse_path.cpp b/src/parse_path.cpp index c5cae5553..1359a2d0e 100644 --- a/src/parse_path.cpp +++ b/src/parse_path.cpp @@ -55,7 +55,7 @@ path_expression_ptr parse_path(std::string const& str, bool r = qi::phrase_parse(itr, end, g, boost::spirit::standard_wide::space, path); if (r && itr == end) { - return boost::make_shared(path); //path; + return std::make_shared(path); //path; } else { diff --git a/src/parse_transform.cpp b/src/parse_transform.cpp index b837f906e..f4bded667 100644 --- a/src/parse_transform.cpp +++ b/src/parse_transform.cpp @@ -36,7 +36,7 @@ transform_list_ptr parse_transform(std::string const& str) transform_list_ptr parse_transform(std::string const& str, std::string const& encoding) { - transform_list_ptr tl = boost::make_shared(); + transform_list_ptr tl = std::make_shared(); transcoder tc(encoding); expression_grammar ge(tc); transform_expression_grammar_string gte(ge); diff --git a/src/rule.cpp b/src/rule.cpp index 32ba4d694..f13bfa562 100644 --- a/src/rule.cpp +++ b/src/rule.cpp @@ -107,7 +107,7 @@ rule::rule() min_scale_(0), max_scale_(std::numeric_limits::infinity()), syms_(), - filter_(boost::make_shared(true)), + filter_(std::make_shared(true)), else_filter_(false), also_filter_(false) {} @@ -118,7 +118,7 @@ rule::rule(std::string const& name, min_scale_(min_scale_denominator), max_scale_(max_scale_denominator), syms_(), - filter_(boost::make_shared(true)), + filter_(std::make_shared(true)), else_filter_(false), also_filter_(false) {} diff --git a/src/svg/output/svg_renderer.cpp b/src/svg/output/svg_renderer.cpp index 49ce2b4db..b92347c25 100644 --- a/src/svg/output/svg_renderer.cpp +++ b/src/svg/output/svg_renderer.cpp @@ -44,7 +44,7 @@ svg_renderer::svg_renderer(Map const& m, T & output_iterator, double scale_fa t_(m.width(),m.height(),m.get_current_extent(),offset_x,offset_y), font_engine_(), font_manager_(font_engine_), - detector_(boost::make_shared(box2d(-m.buffer_size(), -m.buffer_size(), m.width() + m.buffer_size() ,m.height() + m.buffer_size()))), + detector_(std::make_shared(box2d(-m.buffer_size(), -m.buffer_size(), m.width() + m.buffer_size() ,m.height() + m.buffer_size()))), generator_(output_iterator), query_extent_(), painted_(false) @@ -60,7 +60,7 @@ svg_renderer::svg_renderer(Map const& m, request const& req, T & output_itera t_(req.width(),req.height(),req.extent(),offset_x,offset_y), font_engine_(), font_manager_(font_engine_), - detector_(boost::make_shared(box2d(-req.buffer_size(), -req.buffer_size(), req.width() + req.buffer_size() ,req.height() + req.buffer_size()))), + detector_(std::make_shared(box2d(-req.buffer_size(), -req.buffer_size(), req.width() + req.buffer_size() ,req.height() + req.buffer_size()))), generator_(output_iterator), query_extent_(), painted_(false) diff --git a/src/text_placements/dummy.cpp b/src/text_placements/dummy.cpp index 989fb542b..02c68318c 100644 --- a/src/text_placements/dummy.cpp +++ b/src/text_placements/dummy.cpp @@ -35,7 +35,7 @@ bool text_placement_info_dummy::next() text_placement_info_ptr text_placements_dummy::get_placement_info( double scale_factor) const { - return boost::make_shared(this, scale_factor); + return std::make_shared(this, scale_factor); } } //ns mapnik diff --git a/src/text_placements/list.cpp b/src/text_placements/list.cpp index bd0dccdc4..d470315d1 100644 --- a/src/text_placements/list.cpp +++ b/src/text_placements/list.cpp @@ -64,7 +64,7 @@ text_symbolizer_properties & text_placements_list::get(unsigned i) text_placement_info_ptr text_placements_list::get_placement_info(double scale_factor) const { - return boost::make_shared(this, scale_factor); + return std::make_shared(this, scale_factor); } text_placements_list::text_placements_list() : text_placements(), list_(0) @@ -109,4 +109,3 @@ text_placements_ptr text_placements_list::from_xml(xml_node const &xml, fontset_ } } //ns mapnik - diff --git a/src/text_placements/simple.cpp b/src/text_placements/simple.cpp index ec5f812d0..5f6c86325 100644 --- a/src/text_placements/simple.cpp +++ b/src/text_placements/simple.cpp @@ -105,7 +105,7 @@ bool text_placement_info_simple::next_position_only() text_placement_info_ptr text_placements_simple::get_placement_info( double scale_factor) const { - return boost::make_shared(this, scale_factor); + return std::make_shared(this, scale_factor); } /** Position string: [POS][SIZE] @@ -173,7 +173,7 @@ std::string text_placements_simple::get_positions() text_placements_ptr text_placements_simple::from_xml(xml_node const &xml, fontset_map const & fontsets) { - text_placements_ptr ptr = boost::make_shared( + text_placements_ptr ptr = std::make_shared( xml.get_attr("placements", "X")); ptr->defaults.from_xml(xml, fontsets); return ptr; diff --git a/src/text_properties.cpp b/src/text_properties.cpp index a695e17d8..836943af7 100644 --- a/src/text_properties.cpp +++ b/src/text_properties.cpp @@ -237,7 +237,7 @@ void text_symbolizer_properties::add_expressions(expression_set &output) const void text_symbolizer_properties::set_old_style_expression(expression_ptr expr) { - tree_ = boost::make_shared(expr); + tree_ = std::make_shared(expr); } char_properties::char_properties() : diff --git a/src/tiff_reader.cpp b/src/tiff_reader.cpp index cc2e32e37..c694181da 100644 --- a/src/tiff_reader.cpp +++ b/src/tiff_reader.cpp @@ -102,7 +102,7 @@ static int tiff_map_proc(thandle_t, tdata_t* , toff_t*) template class tiff_reader : public image_reader { - typedef boost::shared_ptr tiff_ptr; + typedef std::shared_ptr tiff_ptr; typedef T source_type; typedef boost::iostreams::stream input_stream; diff --git a/tests/cpp_tests/fontset_runtime_test.cpp b/tests/cpp_tests/fontset_runtime_test.cpp index 14ec2d83a..e99e46bc3 100644 --- a/tests/cpp_tests/fontset_runtime_test.cpp +++ b/tests/cpp_tests/fontset_runtime_test.cpp @@ -37,7 +37,7 @@ int main(int argc, char** argv) // create a renderable map with a fontset and a text symbolizer // and do not register any fonts, to ensure the error thrown is reasonable - mapnik::context_ptr ctx = boost::make_shared(); + mapnik::context_ptr ctx = std::make_shared(); ctx->push("name"); mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,1)); mapnik::transcoder tr("utf-8"); @@ -46,7 +46,7 @@ int main(int argc, char** argv) mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::geometry_type::types::Point); pt->move_to(128,128); feature->add_geometry(pt); - boost::shared_ptr ds = boost::make_shared(); + std::shared_ptr ds = std::make_shared(); ds->push(feature); mapnik::Map m(256,256); mapnik::font_set fontset("fontset"); diff --git a/tests/cpp_tests/map_request_test.cpp b/tests/cpp_tests/map_request_test.cpp index 610f9f12c..d4dc339b5 100644 --- a/tests/cpp_tests/map_request_test.cpp +++ b/tests/cpp_tests/map_request_test.cpp @@ -31,7 +31,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn) { throw mapnik::image_reader_exception("Failed to load: " + dest_fn); } - boost::shared_ptr image_ptr1 = boost::make_shared(reader1->width(),reader1->height()); + std::shared_ptr image_ptr1 = std::make_shared(reader1->width(),reader1->height()); reader1->read(0,0,image_ptr1->data()); std::unique_ptr reader2(mapnik::get_image_reader(src_fn,"png")); @@ -39,7 +39,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn) { throw mapnik::image_reader_exception("Failed to load: " + src_fn); } - boost::shared_ptr image_ptr2 = boost::make_shared(reader2->width(),reader2->height()); + std::shared_ptr image_ptr2 = std::make_shared(reader2->width(),reader2->height()); reader2->read(0,0,image_ptr2->data()); image_data_32 const& dest = image_ptr1->data(); diff --git a/utils/pgsql2sqlite/main.cpp b/utils/pgsql2sqlite/main.cpp index a5b13f945..204e8e88e 100644 --- a/utils/pgsql2sqlite/main.cpp +++ b/utils/pgsql2sqlite/main.cpp @@ -96,7 +96,7 @@ int main ( int argc, char** argv) ConnectionCreator creator(host,port,dbname,user,password,connect_timeout); try { - boost::shared_ptr conn(creator()); + std::shared_ptr conn(creator()); std::string query = vm["query"].as(); std::string output_table_name = vm.count("table") ? vm["table"].as() : mapnik::sql_utils::table_from_sql(query); diff --git a/utils/pgsql2sqlite/pgsql2sqlite.hpp b/utils/pgsql2sqlite/pgsql2sqlite.hpp index 8962d0f9f..a1370aa85 100644 --- a/utils/pgsql2sqlite/pgsql2sqlite.hpp +++ b/utils/pgsql2sqlite/pgsql2sqlite.hpp @@ -167,7 +167,7 @@ void pgsql2sqlite(Connection conn, namespace sqlite = mapnik::sqlite; sqlite::database db(output_filename); - boost::shared_ptr rs = conn->executeQuery("select * from (" + query + ") as query limit 0;"); + std::shared_ptr rs = conn->executeQuery("select * from (" + query + ") as query limit 0;"); int count = rs->getNumFields(); std::ostringstream select_sql; @@ -234,7 +234,7 @@ void pgsql2sqlite(Connection conn, cursor_sql << "DECLARE " << cursor_name << " BINARY INSENSITIVE NO SCROLL CURSOR WITH HOLD FOR " << select_sql_str << " FOR READ ONLY"; conn->execute(cursor_sql.str()); - boost::shared_ptr cursor(new CursorResultSet(conn,cursor_name,10000)); + std::shared_ptr cursor(new CursorResultSet(conn,cursor_name,10000)); unsigned num_fields = cursor->getNumFields(); diff --git a/utils/pgsql2sqlite/sqlite.hpp b/utils/pgsql2sqlite/sqlite.hpp index 1266a7604..5f4f3041b 100644 --- a/utils/pgsql2sqlite/sqlite.hpp +++ b/utils/pgsql2sqlite/sqlite.hpp @@ -52,7 +52,7 @@ namespace mapnik { namespace sqlite { } }; - typedef boost::shared_ptr sqlite_db; + typedef std::shared_ptr sqlite_db; sqlite_db db_; public: @@ -186,4 +186,3 @@ namespace mapnik { namespace sqlite { }; } } - From 62af2e6765ce4a68fc41d2dcbac8b7198ac8d347 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 20 Sep 2013 14:13:23 +0100 Subject: [PATCH 114/122] + replace with --- benchmark/run.cpp | 2 +- bindings/python/mapnik_wkt_reader.cpp | 2 +- boost/geometry/extensions/index/rtree/rtree.hpp | 2 +- boost/geometry/extensions/index/rtree/rtree_leaf.hpp | 2 +- boost/geometry/extensions/index/rtree/rtree_node.hpp | 2 +- demo/viewer/mapwidget.hpp | 2 +- include/mapnik/agg_renderer.hpp | 2 +- include/mapnik/cairo_context.hpp | 2 +- include/mapnik/char_info.hpp | 2 +- include/mapnik/datasource.hpp | 2 +- include/mapnik/datasource_cache.hpp | 2 +- include/mapnik/expression.hpp | 2 +- include/mapnik/expression_string.hpp | 2 +- include/mapnik/feature.hpp | 2 +- include/mapnik/font_engine_freetype.hpp | 2 +- include/mapnik/geometry.hpp | 2 +- include/mapnik/grid/grid_renderer.hpp | 2 +- include/mapnik/mapped_memory_cache.hpp | 2 +- include/mapnik/marker.hpp | 2 +- include/mapnik/marker_cache.hpp | 2 +- include/mapnik/path_expression.hpp | 2 +- include/mapnik/pool.hpp | 2 +- include/mapnik/raster_colorizer.hpp | 2 +- include/mapnik/svg/output/svg_path_iterator.hpp | 2 +- include/mapnik/svg/output/svg_renderer.hpp | 2 +- include/mapnik/symbolizer.hpp | 2 +- include/mapnik/text_path.hpp | 2 +- include/mapnik/text_symbolizer.hpp | 2 +- include/mapnik/transform_expression.hpp | 2 +- plugins/input/geojson/geojson_datasource.hpp | 2 +- plugins/input/occi/occi_datasource.hpp | 2 +- plugins/input/occi/occi_featureset.hpp | 2 +- plugins/input/ogr/ogr_datasource.hpp | 4 ++-- plugins/input/osm/osm_datasource.hpp | 2 +- plugins/input/postgis/connection_manager.hpp | 2 +- plugins/input/postgis/postgis_datasource.hpp | 2 +- plugins/input/raster/raster_datasource.hpp | 2 +- plugins/input/rasterlite/rasterlite_datasource.hpp | 2 +- plugins/input/shape/shape_datasource.hpp | 2 +- plugins/input/shape/shape_io.hpp | 2 +- plugins/input/sqlite/sqlite_connection.hpp | 2 +- plugins/input/sqlite/sqlite_datasource.hpp | 2 +- plugins/input/sqlite/sqlite_featureset.hpp | 2 +- plugins/input/sqlite/sqlite_prepared.hpp | 2 +- plugins/input/sqlite/sqlite_utils.hpp | 2 +- plugins/input/templates/helloworld/hello_datasource.hpp | 2 +- src/jpeg_reader.cpp | 2 +- src/placement_finder.cpp | 2 +- src/rule.cpp | 2 +- src/tiff_reader.cpp | 2 +- utils/pgsql2sqlite/main.cpp | 2 +- utils/pgsql2sqlite/pgsql2sqlite.hpp | 2 +- utils/pgsql2sqlite/sqlite.hpp | 2 +- 53 files changed, 54 insertions(+), 54 deletions(-) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index baa21d738..03ab9e5f7 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -16,7 +16,7 @@ // boost #include -#include +#include #include #include diff --git a/bindings/python/mapnik_wkt_reader.cpp b/bindings/python/mapnik_wkt_reader.cpp index 2c041412b..14465a0b9 100644 --- a/bindings/python/mapnik_wkt_reader.cpp +++ b/bindings/python/mapnik_wkt_reader.cpp @@ -23,7 +23,7 @@ // boost #include #include -#include +#include #include #include // mapnik diff --git a/boost/geometry/extensions/index/rtree/rtree.hpp b/boost/geometry/extensions/index/rtree/rtree.hpp index 4b9c50886..2cf579658 100644 --- a/boost/geometry/extensions/index/rtree/rtree.hpp +++ b/boost/geometry/extensions/index/rtree/rtree.hpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include diff --git a/boost/geometry/extensions/index/rtree/rtree_leaf.hpp b/boost/geometry/extensions/index/rtree/rtree_leaf.hpp index 1309c4188..733e1819d 100644 --- a/boost/geometry/extensions/index/rtree/rtree_leaf.hpp +++ b/boost/geometry/extensions/index/rtree/rtree_leaf.hpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include diff --git a/boost/geometry/extensions/index/rtree/rtree_node.hpp b/boost/geometry/extensions/index/rtree/rtree_node.hpp index f0eaff9c9..ec9efad98 100644 --- a/boost/geometry/extensions/index/rtree/rtree_node.hpp +++ b/boost/geometry/extensions/index/rtree/rtree_node.hpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include diff --git a/demo/viewer/mapwidget.hpp b/demo/viewer/mapwidget.hpp index 873d659eb..73c8e12e8 100644 --- a/demo/viewer/mapwidget.hpp +++ b/demo/viewer/mapwidget.hpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #ifndef Q_MOC_RUN diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index adfdb3dd4..59005c2f6 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -38,7 +38,7 @@ // boost #include -#include +#include // fwd declaration to avoid depedence on agg headers namespace agg { struct trans_affine; } diff --git a/include/mapnik/cairo_context.hpp b/include/mapnik/cairo_context.hpp index e71d200df..6c9596255 100644 --- a/include/mapnik/cairo_context.hpp +++ b/include/mapnik/cairo_context.hpp @@ -37,7 +37,7 @@ #include // boost -#include +#include // cairo #include diff --git a/include/mapnik/char_info.hpp b/include/mapnik/char_info.hpp index e5a6a5baa..bd21aeab3 100644 --- a/include/mapnik/char_info.hpp +++ b/include/mapnik/char_info.hpp @@ -23,7 +23,7 @@ #ifndef MAPNIK_CHAR_INFO_HPP #define MAPNIK_CHAR_INFO_HPP -#include +#include namespace mapnik { struct char_properties; diff --git a/include/mapnik/datasource.hpp b/include/mapnik/datasource.hpp index ee205e186..cb9cec0e7 100644 --- a/include/mapnik/datasource.hpp +++ b/include/mapnik/datasource.hpp @@ -32,7 +32,7 @@ #include // boost -#include +#include #include // stl diff --git a/include/mapnik/datasource_cache.hpp b/include/mapnik/datasource_cache.hpp index b42a1985c..5e1fbc72e 100644 --- a/include/mapnik/datasource_cache.hpp +++ b/include/mapnik/datasource_cache.hpp @@ -30,7 +30,7 @@ #include // boost -#include +#include // stl #include diff --git a/include/mapnik/expression.hpp b/include/mapnik/expression.hpp index 25eccc863..9f8009b89 100644 --- a/include/mapnik/expression.hpp +++ b/include/mapnik/expression.hpp @@ -28,7 +28,7 @@ #include // boost -#include +#include // stl #include diff --git a/include/mapnik/expression_string.hpp b/include/mapnik/expression_string.hpp index 2f445755d..14a017a38 100644 --- a/include/mapnik/expression_string.hpp +++ b/include/mapnik/expression_string.hpp @@ -28,7 +28,7 @@ #include // boost -#include +#include // stl #include diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index 46192cefd..bf2c547ab 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -33,7 +33,7 @@ #include // boost -#include +#include #include // stl diff --git a/include/mapnik/font_engine_freetype.hpp b/include/mapnik/font_engine_freetype.hpp index 85bd2c881..1e046e4bc 100644 --- a/include/mapnik/font_engine_freetype.hpp +++ b/include/mapnik/font_engine_freetype.hpp @@ -39,7 +39,7 @@ #include // boost -#include +#include #include #include diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index 073439cee..92927a3a5 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -29,7 +29,7 @@ #include // boost -#include +#include #include namespace mapnik { diff --git a/include/mapnik/grid/grid_renderer.hpp b/include/mapnik/grid/grid_renderer.hpp index fc8ad08b6..f56180a2c 100644 --- a/include/mapnik/grid/grid_renderer.hpp +++ b/include/mapnik/grid/grid_renderer.hpp @@ -38,7 +38,7 @@ // boost #include -#include +#include // fwd declaration to avoid depedence on agg headers namespace agg { struct trans_affine; } diff --git a/include/mapnik/mapped_memory_cache.hpp b/include/mapnik/mapped_memory_cache.hpp index b6260d12d..7f876a88e 100644 --- a/include/mapnik/mapped_memory_cache.hpp +++ b/include/mapnik/mapped_memory_cache.hpp @@ -30,7 +30,7 @@ // boost #include -#include +#include #include #include diff --git a/include/mapnik/marker.hpp b/include/mapnik/marker.hpp index c5371ef30..40c418972 100644 --- a/include/mapnik/marker.hpp +++ b/include/mapnik/marker.hpp @@ -36,7 +36,7 @@ // boost #include -#include +#include #include #include diff --git a/include/mapnik/marker_cache.hpp b/include/mapnik/marker_cache.hpp index 00ce350bb..e7f7be267 100644 --- a/include/mapnik/marker_cache.hpp +++ b/include/mapnik/marker_cache.hpp @@ -30,7 +30,7 @@ // boost #include -#include +#include #include namespace mapnik diff --git a/include/mapnik/path_expression.hpp b/include/mapnik/path_expression.hpp index c13e54b50..9fa0767b3 100644 --- a/include/mapnik/path_expression.hpp +++ b/include/mapnik/path_expression.hpp @@ -25,7 +25,7 @@ // boost #include -#include +#include // stl #include diff --git a/include/mapnik/pool.hpp b/include/mapnik/pool.hpp index 7ed6b841f..707103d98 100644 --- a/include/mapnik/pool.hpp +++ b/include/mapnik/pool.hpp @@ -29,7 +29,7 @@ #include // boost -#include +#include #ifdef MAPNIK_THREADSAFE #include #endif diff --git a/include/mapnik/raster_colorizer.hpp b/include/mapnik/raster_colorizer.hpp index 2628348ef..e36d54608 100644 --- a/include/mapnik/raster_colorizer.hpp +++ b/include/mapnik/raster_colorizer.hpp @@ -43,7 +43,7 @@ #include // boost -#include +#include // stl #include diff --git a/include/mapnik/svg/output/svg_path_iterator.hpp b/include/mapnik/svg/output/svg_path_iterator.hpp index 4e7f69db9..c27f61bd9 100644 --- a/include/mapnik/svg/output/svg_path_iterator.hpp +++ b/include/mapnik/svg/output/svg_path_iterator.hpp @@ -30,7 +30,7 @@ // boost #include #include -#include +#include #include namespace mapnik { diff --git a/include/mapnik/svg/output/svg_renderer.hpp b/include/mapnik/svg/output/svg_renderer.hpp index c82078d53..a6f0db439 100644 --- a/include/mapnik/svg/output/svg_renderer.hpp +++ b/include/mapnik/svg/output/svg_renderer.hpp @@ -41,7 +41,7 @@ // boost #include #include -#include +#include // stl #include diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp index 9b6cfd2f4..9d6a7843f 100644 --- a/include/mapnik/symbolizer.hpp +++ b/include/mapnik/symbolizer.hpp @@ -30,7 +30,7 @@ #include // boost -#include +#include // stl #include diff --git a/include/mapnik/text_path.hpp b/include/mapnik/text_path.hpp index cb565af92..b28a3ad19 100644 --- a/include/mapnik/text_path.hpp +++ b/include/mapnik/text_path.hpp @@ -33,7 +33,7 @@ #include // boost -#include +#include namespace mapnik { diff --git a/include/mapnik/text_symbolizer.hpp b/include/mapnik/text_symbolizer.hpp index b2f46ec1f..8aa17848a 100644 --- a/include/mapnik/text_symbolizer.hpp +++ b/include/mapnik/text_symbolizer.hpp @@ -31,7 +31,7 @@ #include // boost -#include +#include #include // stl diff --git a/include/mapnik/transform_expression.hpp b/include/mapnik/transform_expression.hpp index 5362d5822..d36c5bcf3 100644 --- a/include/mapnik/transform_expression.hpp +++ b/include/mapnik/transform_expression.hpp @@ -28,7 +28,7 @@ // boost #include -#include +#include #include // fusion diff --git a/plugins/input/geojson/geojson_datasource.hpp b/plugins/input/geojson/geojson_datasource.hpp index 131750c87..b6314db37 100644 --- a/plugins/input/geojson/geojson_datasource.hpp +++ b/plugins/input/geojson/geojson_datasource.hpp @@ -35,7 +35,7 @@ // boost #include -#include +#include #include #include #include diff --git a/plugins/input/occi/occi_datasource.hpp b/plugins/input/occi/occi_datasource.hpp index 10261f19a..0aa6f3891 100644 --- a/plugins/input/occi/occi_datasource.hpp +++ b/plugins/input/occi/occi_datasource.hpp @@ -35,7 +35,7 @@ // boost #include -#include +#include // stl #include diff --git a/plugins/input/occi/occi_featureset.hpp b/plugins/input/occi/occi_featureset.hpp index e81e24071..c43707c95 100644 --- a/plugins/input/occi/occi_featureset.hpp +++ b/plugins/input/occi/occi_featureset.hpp @@ -31,7 +31,7 @@ // boost #include -#include +#include // oci #include "occi_types.hpp" diff --git a/plugins/input/ogr/ogr_datasource.hpp b/plugins/input/ogr/ogr_datasource.hpp index ebff6c548..7be996c4d 100644 --- a/plugins/input/ogr/ogr_datasource.hpp +++ b/plugins/input/ogr/ogr_datasource.hpp @@ -34,7 +34,7 @@ // boost #include -#include +#include // stl #include @@ -56,7 +56,7 @@ public: mapnik::box2d envelope() const; boost::optional get_geometry_type() const; mapnik::layer_descriptor get_descriptor() const; - + private: void init(mapnik::parameters const& params); mapnik::box2d extent_; diff --git a/plugins/input/osm/osm_datasource.hpp b/plugins/input/osm/osm_datasource.hpp index efdd20d68..fb9fcb3fa 100644 --- a/plugins/input/osm/osm_datasource.hpp +++ b/plugins/input/osm/osm_datasource.hpp @@ -34,7 +34,7 @@ // boost #include -#include +#include // stl #include diff --git a/plugins/input/postgis/connection_manager.hpp b/plugins/input/postgis/connection_manager.hpp index 30a15abb1..f0404d841 100644 --- a/plugins/input/postgis/connection_manager.hpp +++ b/plugins/input/postgis/connection_manager.hpp @@ -30,7 +30,7 @@ #include // boost -#include +#include #include #include diff --git a/plugins/input/postgis/postgis_datasource.hpp b/plugins/input/postgis/postgis_datasource.hpp index 3f1ea34ee..fe93f5525 100644 --- a/plugins/input/postgis/postgis_datasource.hpp +++ b/plugins/input/postgis/postgis_datasource.hpp @@ -36,7 +36,7 @@ // boost #include -#include +#include #include // stl diff --git a/plugins/input/raster/raster_datasource.hpp b/plugins/input/raster/raster_datasource.hpp index 381a6568f..96bcaf16b 100644 --- a/plugins/input/raster/raster_datasource.hpp +++ b/plugins/input/raster/raster_datasource.hpp @@ -34,7 +34,7 @@ // boost #include -#include +#include // stl #include diff --git a/plugins/input/rasterlite/rasterlite_datasource.hpp b/plugins/input/rasterlite/rasterlite_datasource.hpp index f5b46584b..da5257766 100644 --- a/plugins/input/rasterlite/rasterlite_datasource.hpp +++ b/plugins/input/rasterlite/rasterlite_datasource.hpp @@ -34,7 +34,7 @@ // boost #include -#include +#include // stl #include diff --git a/plugins/input/shape/shape_datasource.hpp b/plugins/input/shape/shape_datasource.hpp index acb2cf32f..f4821bde6 100644 --- a/plugins/input/shape/shape_datasource.hpp +++ b/plugins/input/shape/shape_datasource.hpp @@ -35,7 +35,7 @@ // boost #include -#include +#include // stl #include diff --git a/plugins/input/shape/shape_io.hpp b/plugins/input/shape/shape_io.hpp index 3cb5e1831..24111f655 100644 --- a/plugins/input/shape/shape_io.hpp +++ b/plugins/input/shape/shape_io.hpp @@ -29,7 +29,7 @@ #include // boost -#include +#include #include "dbfile.hpp" #include "shapefile.hpp" diff --git a/plugins/input/sqlite/sqlite_connection.hpp b/plugins/input/sqlite/sqlite_connection.hpp index c095bbb85..e508740bd 100644 --- a/plugins/input/sqlite/sqlite_connection.hpp +++ b/plugins/input/sqlite/sqlite_connection.hpp @@ -32,7 +32,7 @@ #include // boost -#include +#include #include #include diff --git a/plugins/input/sqlite/sqlite_datasource.hpp b/plugins/input/sqlite/sqlite_datasource.hpp index 27c22ff33..db0bcfa07 100644 --- a/plugins/input/sqlite/sqlite_datasource.hpp +++ b/plugins/input/sqlite/sqlite_datasource.hpp @@ -36,7 +36,7 @@ // boost #include -#include +#include // stl #include diff --git a/plugins/input/sqlite/sqlite_featureset.hpp b/plugins/input/sqlite/sqlite_featureset.hpp index 3e52b4e85..463063dce 100644 --- a/plugins/input/sqlite/sqlite_featureset.hpp +++ b/plugins/input/sqlite/sqlite_featureset.hpp @@ -30,7 +30,7 @@ // boost #include -#include +#include // sqlite #include "sqlite_resultset.hpp" diff --git a/plugins/input/sqlite/sqlite_prepared.hpp b/plugins/input/sqlite/sqlite_prepared.hpp index de7e31c35..e05e5db62 100644 --- a/plugins/input/sqlite/sqlite_prepared.hpp +++ b/plugins/input/sqlite/sqlite_prepared.hpp @@ -31,7 +31,7 @@ #include // boost -#include +#include // stl #include diff --git a/plugins/input/sqlite/sqlite_utils.hpp b/plugins/input/sqlite/sqlite_utils.hpp index 3ccd72202..bfb511870 100644 --- a/plugins/input/sqlite/sqlite_utils.hpp +++ b/plugins/input/sqlite/sqlite_utils.hpp @@ -38,7 +38,7 @@ #include // boost -#include +#include #include #include diff --git a/plugins/input/templates/helloworld/hello_datasource.hpp b/plugins/input/templates/helloworld/hello_datasource.hpp index 018ff6f2f..432489dbe 100644 --- a/plugins/input/templates/helloworld/hello_datasource.hpp +++ b/plugins/input/templates/helloworld/hello_datasource.hpp @@ -12,7 +12,7 @@ // boost #include -#include +#include // stl #include diff --git a/src/jpeg_reader.cpp b/src/jpeg_reader.cpp index 36aa63ac4..60e7e601d 100644 --- a/src/jpeg_reader.cpp +++ b/src/jpeg_reader.cpp @@ -31,7 +31,7 @@ extern "C" } // boost -#include +#include #include #include #include diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index 9a9089450..d9b3614ce 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -33,7 +33,7 @@ #include "agg_path_length.h" // boost -#include +#include #include #include diff --git a/src/rule.cpp b/src/rule.cpp index f13bfa562..be34121f3 100644 --- a/src/rule.cpp +++ b/src/rule.cpp @@ -41,7 +41,7 @@ #include // boost -#include +#include #include #include diff --git a/src/tiff_reader.cpp b/src/tiff_reader.cpp index c694181da..7b3fad6a3 100644 --- a/src/tiff_reader.cpp +++ b/src/tiff_reader.cpp @@ -25,7 +25,7 @@ #include // boost -#include +#include // iostreams #include diff --git a/utils/pgsql2sqlite/main.cpp b/utils/pgsql2sqlite/main.cpp index 204e8e88e..632500115 100644 --- a/utils/pgsql2sqlite/main.cpp +++ b/utils/pgsql2sqlite/main.cpp @@ -28,7 +28,7 @@ // boost #include -#include +#include #include //stl diff --git a/utils/pgsql2sqlite/pgsql2sqlite.hpp b/utils/pgsql2sqlite/pgsql2sqlite.hpp index a1370aa85..24e34f03e 100644 --- a/utils/pgsql2sqlite/pgsql2sqlite.hpp +++ b/utils/pgsql2sqlite/pgsql2sqlite.hpp @@ -36,7 +36,7 @@ // boost #include #include -#include +#include #include //stl diff --git a/utils/pgsql2sqlite/sqlite.hpp b/utils/pgsql2sqlite/sqlite.hpp index 5f4f3041b..75d711fff 100644 --- a/utils/pgsql2sqlite/sqlite.hpp +++ b/utils/pgsql2sqlite/sqlite.hpp @@ -22,7 +22,7 @@ #include // boost -#include +#include #include //sqlite3 From 09ce29489e2777dac52a476d8f932aa7ad6d52fb Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 20 Sep 2013 14:22:58 +0100 Subject: [PATCH 115/122] use const std::unique_ptr<> instead of boost::scoped_ptr<> --- demo/viewer/mapwidget.hpp | 2 +- demo/viewer/styles_model.cpp | 4 ++-- demo/viewer/styles_model.hpp | 4 ++-- include/mapnik/agg_renderer.hpp | 4 ++-- include/mapnik/cairo_renderer.hpp | 2 +- include/mapnik/grid/grid_renderer.hpp | 4 ++-- include/mapnik/hextree.hpp | 4 ++-- include/mapnik/json/feature_collection_parser.hpp | 4 ++-- include/mapnik/json/feature_parser.hpp | 4 ++-- include/mapnik/json/geojson_generator.hpp | 6 +++--- include/mapnik/json/geometry_parser.hpp | 4 ++-- include/mapnik/svg/output/svg_renderer.hpp | 2 +- include/mapnik/symbolizer_helpers.hpp | 4 ++-- include/mapnik/wkt/wkt_factory.hpp | 4 ++-- plugins/input/occi/occi_featureset.cpp | 2 +- plugins/input/occi/occi_featureset.hpp | 4 ++-- plugins/input/ogr/ogr_featureset.hpp | 4 ++-- plugins/input/ogr/ogr_index_featureset.hpp | 4 ++-- plugins/input/osm/osm_featureset.hpp | 4 ++-- plugins/input/postgis/postgis_datasource.hpp | 2 +- plugins/input/postgis/postgis_featureset.hpp | 4 ++-- plugins/input/shape/shape_featureset.hpp | 4 ++-- plugins/input/shape/shape_index_featureset.hpp | 4 ++-- plugins/input/sqlite/sqlite_featureset.hpp | 4 ++-- plugins/input/templates/helloworld/hello_featureset.hpp | 4 ++-- src/agg/process_building_symbolizer.cpp | 8 ++++---- src/cairo_renderer.cpp | 6 +++--- src/grid/process_building_symbolizer.cpp | 8 ++++---- src/shield_symbolizer.cpp | 2 +- src/symbolizer_helpers.cpp | 2 +- src/text_symbolizer.cpp | 2 +- 31 files changed, 60 insertions(+), 60 deletions(-) diff --git a/demo/viewer/mapwidget.hpp b/demo/viewer/mapwidget.hpp index 73c8e12e8..e3cff1a98 100644 --- a/demo/viewer/mapwidget.hpp +++ b/demo/viewer/mapwidget.hpp @@ -29,7 +29,7 @@ #include #include #include -#include + #ifndef Q_MOC_RUN #include diff --git a/demo/viewer/styles_model.cpp b/demo/viewer/styles_model.cpp index 229cbdf9f..64ec4cc92 100644 --- a/demo/viewer/styles_model.cpp +++ b/demo/viewer/styles_model.cpp @@ -26,7 +26,7 @@ // boost #include -#include + // qt #include #include @@ -114,7 +114,7 @@ public: } private: - boost::scoped_ptr impl_; + const std::unique_ptr impl_; QList children_; node * parent_; }; diff --git a/demo/viewer/styles_model.hpp b/demo/viewer/styles_model.hpp index b162c92ef..17af661ed 100644 --- a/demo/viewer/styles_model.hpp +++ b/demo/viewer/styles_model.hpp @@ -27,7 +27,7 @@ #include #endif -#include + class node; class StyleModel : public QAbstractItemModel @@ -44,7 +44,7 @@ class StyleModel : public QAbstractItemModel QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; private: //std::shared_ptr map_; - boost::scoped_ptr root_; + const std::unique_ptr root_; }; #endif // STYLE_MODEL_HPP diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index 59005c2f6..7d29dc856 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -37,7 +37,7 @@ #include // boost -#include + #include // fwd declaration to avoid depedence on agg headers @@ -157,7 +157,7 @@ private: freetype_engine font_engine_; face_manager font_manager_; std::shared_ptr detector_; - boost::scoped_ptr ras_ptr; + const std::unique_ptr ras_ptr; box2d query_extent_; gamma_method_e gamma_method_; double gamma_; diff --git a/include/mapnik/cairo_renderer.hpp b/include/mapnik/cairo_renderer.hpp index 5cbab623d..1d18bcf28 100644 --- a/include/mapnik/cairo_renderer.hpp +++ b/include/mapnik/cairo_renderer.hpp @@ -41,7 +41,7 @@ #include // boost -#include + namespace agg { struct trans_affine; diff --git a/include/mapnik/grid/grid_renderer.hpp b/include/mapnik/grid/grid_renderer.hpp index f56180a2c..12ed6b1c4 100644 --- a/include/mapnik/grid/grid_renderer.hpp +++ b/include/mapnik/grid/grid_renderer.hpp @@ -37,7 +37,7 @@ #include // boost -#include + #include // fwd declaration to avoid depedence on agg headers @@ -136,7 +136,7 @@ private: freetype_engine font_engine_; face_manager font_manager_; std::shared_ptr detector_; - boost::scoped_ptr ras_ptr; + const std::unique_ptr ras_ptr; box2d query_extent_; void setup(Map const& m); }; diff --git a/include/mapnik/hextree.hpp b/include/mapnik/hextree.hpp index 299945a11..486d98455 100644 --- a/include/mapnik/hextree.hpp +++ b/include/mapnik/hextree.hpp @@ -33,7 +33,7 @@ #if BOOST_VERSION >= 104600 #include #endif -#include + // stl #include @@ -124,7 +124,7 @@ class hextree : private mapnik::noncopyable unsigned colors_; // flag indicating existance of invisible pixels (a < InsertPolicy::MIN_ALPHA) bool has_holes_; - boost::scoped_ptr root_; + const std::unique_ptr root_; // working palette for quantization, sorted on mean(r,g,b,a) for easier searching NN std::vector sorted_pal_; // index remaping of sorted_pal_ indexes to indexes of returned image palette diff --git a/include/mapnik/json/feature_collection_parser.hpp b/include/mapnik/json/feature_collection_parser.hpp index 63473712e..3ce5361bd 100644 --- a/include/mapnik/json/feature_collection_parser.hpp +++ b/include/mapnik/json/feature_collection_parser.hpp @@ -30,7 +30,7 @@ #include // boost -#include + // stl #include @@ -49,7 +49,7 @@ public: ~feature_collection_parser(); bool parse(iterator_type first, iterator_type last, std::vector & features); private: - boost::scoped_ptr > grammar_; + const std::unique_ptr > grammar_; }; }} diff --git a/include/mapnik/json/feature_parser.hpp b/include/mapnik/json/feature_parser.hpp index e3c3ed8d6..e55d757cb 100644 --- a/include/mapnik/json/feature_parser.hpp +++ b/include/mapnik/json/feature_parser.hpp @@ -30,7 +30,7 @@ #include // boost -#include + // stl #include @@ -49,7 +49,7 @@ public: ~feature_parser(); bool parse(iterator_type first, iterator_type last, mapnik::feature_impl & f); private: - boost::scoped_ptr > grammar_; + const std::unique_ptr > grammar_; }; }} diff --git a/include/mapnik/json/geojson_generator.hpp b/include/mapnik/json/geojson_generator.hpp index ac342b6af..b3049e6ca 100644 --- a/include/mapnik/json/geojson_generator.hpp +++ b/include/mapnik/json/geojson_generator.hpp @@ -27,7 +27,7 @@ #include #include -#include + #include #include @@ -46,7 +46,7 @@ public: ~feature_generator(); bool generate(std::string & geojson, mapnik::feature_impl const& f); private: - boost::scoped_ptr > grammar_; + const std::unique_ptr > grammar_; }; class MAPNIK_DECL geometry_generator : private mapnik::noncopyable @@ -57,7 +57,7 @@ public: ~geometry_generator(); bool generate(std::string & geojson, mapnik::geometry_container const& g); private: - boost::scoped_ptr > grammar_; + const std::unique_ptr > grammar_; }; #else diff --git a/include/mapnik/json/geometry_parser.hpp b/include/mapnik/json/geometry_parser.hpp index 76985f9a5..7a617a060 100644 --- a/include/mapnik/json/geometry_parser.hpp +++ b/include/mapnik/json/geometry_parser.hpp @@ -29,7 +29,7 @@ #include // boost -#include + // stl //#include @@ -49,7 +49,7 @@ public: ~geometry_parser(); bool parse(iterator_type first, iterator_type last, boost::ptr_vector&); private: - boost::scoped_ptr > grammar_; + const std::unique_ptr > grammar_; }; }} diff --git a/include/mapnik/svg/output/svg_renderer.hpp b/include/mapnik/svg/output/svg_renderer.hpp index a6f0db439..05e1f931f 100644 --- a/include/mapnik/svg/output/svg_renderer.hpp +++ b/include/mapnik/svg/output/svg_renderer.hpp @@ -40,7 +40,7 @@ // boost #include -#include + #include // stl diff --git a/include/mapnik/symbolizer_helpers.hpp b/include/mapnik/symbolizer_helpers.hpp index 479b02db9..507f81efc 100644 --- a/include/mapnik/symbolizer_helpers.hpp +++ b/include/mapnik/symbolizer_helpers.hpp @@ -30,7 +30,7 @@ #include //boost -#include + // agg #include "agg_trans_affine.h" @@ -112,7 +112,7 @@ protected: bool points_on_line_; text_placement_info_ptr placement_; - boost::scoped_ptr > finder_; + std::unique_ptr > finder_; }; template diff --git a/include/mapnik/wkt/wkt_factory.hpp b/include/mapnik/wkt/wkt_factory.hpp index a35299b9b..20436b843 100644 --- a/include/mapnik/wkt/wkt_factory.hpp +++ b/include/mapnik/wkt/wkt_factory.hpp @@ -31,7 +31,7 @@ // boost #include -#include + #include // stl @@ -50,7 +50,7 @@ public: wkt_parser(); bool parse(std::string const& wkt, boost::ptr_vector & paths); private: - boost::scoped_ptr > grammar_; + const std::unique_ptr > grammar_; }; #endif diff --git a/plugins/input/occi/occi_featureset.cpp b/plugins/input/occi/occi_featureset.cpp index 1cb0cf4cc..393e4ed8b 100644 --- a/plugins/input/occi/occi_featureset.cpp +++ b/plugins/input/occi/occi_featureset.cpp @@ -122,7 +122,7 @@ feature_ptr occi_featureset::next() } else { - boost::scoped_ptr geom(dynamic_cast(rs_->getObject(1))); + const std::unique_ptr geom(dynamic_cast(rs_->getObject(1))); if (geom.get()) { convert_geometry(geom.get(), feature); diff --git a/plugins/input/occi/occi_featureset.hpp b/plugins/input/occi/occi_featureset.hpp index c43707c95..cb879ea04 100644 --- a/plugins/input/occi/occi_featureset.hpp +++ b/plugins/input/occi/occi_featureset.hpp @@ -30,7 +30,7 @@ #include // boost -#include + #include // oci @@ -70,7 +70,7 @@ private: occi_connection_ptr conn_; oracle::occi::ResultSet* rs_; - boost::scoped_ptr tr_; + const std::unique_ptr tr_; mapnik::value_integer feature_id_; mapnik::context_ptr ctx_; bool use_wkb_; diff --git a/plugins/input/ogr/ogr_featureset.hpp b/plugins/input/ogr/ogr_featureset.hpp index 29f707f7f..861ff27fd 100644 --- a/plugins/input/ogr/ogr_featureset.hpp +++ b/plugins/input/ogr/ogr_featureset.hpp @@ -30,7 +30,7 @@ #include // boost -#include + // ogr #include @@ -54,7 +54,7 @@ private: mapnik::context_ptr ctx_; OGRLayer& layer_; OGRFeatureDefn* layerdef_; - boost::scoped_ptr tr_; + const std::unique_ptr tr_; const char* fidcolumn_; mutable int count_; }; diff --git a/plugins/input/ogr/ogr_index_featureset.hpp b/plugins/input/ogr/ogr_index_featureset.hpp index 9972935e4..83645da00 100644 --- a/plugins/input/ogr/ogr_index_featureset.hpp +++ b/plugins/input/ogr/ogr_index_featureset.hpp @@ -25,7 +25,7 @@ #include #include -#include + #include #include "ogr_featureset.hpp" @@ -48,7 +48,7 @@ private: filterT filter_; std::vector ids_; std::vector::iterator itr_; - boost::scoped_ptr tr_; + const std::unique_ptr tr_; const char* fidcolumn_; OGREnvelope feature_envelope_; }; diff --git a/plugins/input/osm/osm_featureset.hpp b/plugins/input/osm/osm_featureset.hpp index bf9510ed9..ebf11c755 100644 --- a/plugins/input/osm/osm_featureset.hpp +++ b/plugins/input/osm/osm_featureset.hpp @@ -27,7 +27,7 @@ #include // boost -#include + // mapnik #include @@ -57,7 +57,7 @@ public: private: filterT filter_; box2d query_ext_; - boost::scoped_ptr tr_; + const std::unique_ptr tr_; std::vector attr_ids_; mutable box2d feature_ext_; mutable int total_geom_size; diff --git a/plugins/input/postgis/postgis_datasource.hpp b/plugins/input/postgis/postgis_datasource.hpp index fe93f5525..cfeca049d 100644 --- a/plugins/input/postgis/postgis_datasource.hpp +++ b/plugins/input/postgis/postgis_datasource.hpp @@ -37,7 +37,7 @@ // boost #include #include -#include + // stl #include diff --git a/plugins/input/postgis/postgis_featureset.hpp b/plugins/input/postgis/postgis_featureset.hpp index 3ea082394..ea13a1824 100644 --- a/plugins/input/postgis/postgis_featureset.hpp +++ b/plugins/input/postgis/postgis_featureset.hpp @@ -30,7 +30,7 @@ #include // boost -#include + using mapnik::Featureset; using mapnik::box2d; @@ -53,7 +53,7 @@ public: private: std::shared_ptr rs_; context_ptr ctx_; - boost::scoped_ptr tr_; + const std::unique_ptr tr_; unsigned totalGeomSize_; mapnik::value_integer feature_id_; bool key_field_; diff --git a/plugins/input/shape/shape_featureset.hpp b/plugins/input/shape/shape_featureset.hpp index cc643a511..a71e59e65 100644 --- a/plugins/input/shape/shape_featureset.hpp +++ b/plugins/input/shape/shape_featureset.hpp @@ -33,7 +33,7 @@ #include "shape_io.hpp" //boost -#include + #include using mapnik::Featureset; @@ -60,7 +60,7 @@ private: shape_io shape_; box2d query_ext_; mutable box2d feature_bbox_; - boost::scoped_ptr tr_; + const std::unique_ptr tr_; long file_length_; std::vector attr_ids_; mapnik::value_integer row_limit_; diff --git a/plugins/input/shape/shape_index_featureset.hpp b/plugins/input/shape/shape_index_featureset.hpp index 5863b3246..0d860792f 100644 --- a/plugins/input/shape/shape_index_featureset.hpp +++ b/plugins/input/shape/shape_index_featureset.hpp @@ -34,7 +34,7 @@ #include // boost -#include + #include #include "shape_datasource.hpp" @@ -62,7 +62,7 @@ private: filterT filter_; context_ptr ctx_; shape_io & shape_; - boost::scoped_ptr tr_; + const std::unique_ptr tr_; std::vector offsets_; std::vector::iterator itr_; std::vector attr_ids_; diff --git a/plugins/input/sqlite/sqlite_featureset.hpp b/plugins/input/sqlite/sqlite_featureset.hpp index 463063dce..6fc53602f 100644 --- a/plugins/input/sqlite/sqlite_featureset.hpp +++ b/plugins/input/sqlite/sqlite_featureset.hpp @@ -29,7 +29,7 @@ #include // boost -#include + #include // sqlite @@ -52,7 +52,7 @@ public: private: std::shared_ptr rs_; mapnik::context_ptr ctx_; - boost::scoped_ptr tr_; + const std::unique_ptr tr_; mapnik::box2d bbox_; mapnik::wkbFormat format_; bool spatial_index_; diff --git a/plugins/input/templates/helloworld/hello_featureset.hpp b/plugins/input/templates/helloworld/hello_featureset.hpp index b73f15070..43f338fad 100644 --- a/plugins/input/templates/helloworld/hello_featureset.hpp +++ b/plugins/input/templates/helloworld/hello_featureset.hpp @@ -7,7 +7,7 @@ #include // boost -#include // needed for wrapping the transcoder + // needed for wrapping the transcoder class hello_featureset : public mapnik::Featureset { @@ -25,7 +25,7 @@ private: // members are up to you, but these are recommended mapnik::box2d box_; mapnik::value_integer feature_id_; - boost::scoped_ptr tr_; + const std::unique_ptr tr_; mapnik::context_ptr ctx_; }; diff --git a/src/agg/process_building_symbolizer.cpp b/src/agg/process_building_symbolizer.cpp index 65f1e6b79..9329c8cc8 100644 --- a/src/agg/process_building_symbolizer.cpp +++ b/src/agg/process_building_symbolizer.cpp @@ -31,7 +31,7 @@ #include // boost -#include + // stl #include @@ -91,8 +91,8 @@ void agg_renderer::process(building_symbolizer const& sym, geometry_type const& geom = feature.get_geometry(i); if (geom.size() > 2) { - boost::scoped_ptr frame(new geometry_type(geometry_type::types::LineString)); - boost::scoped_ptr roof(new geometry_type(geometry_type::types::Polygon)); + const std::unique_ptr frame(new geometry_type(geometry_type::types::LineString)); + const std::unique_ptr roof(new geometry_type(geometry_type::types::Polygon)); std::deque face_segments; double x0 = 0; double y0 = 0; @@ -124,7 +124,7 @@ void agg_renderer::process(building_symbolizer const& sym, for (; itr!=end; ++itr) { - boost::scoped_ptr faces(new geometry_type(geometry_type::types::Polygon)); + const std::unique_ptr faces(new geometry_type(geometry_type::types::Polygon)); faces->move_to(itr->get<0>(),itr->get<1>()); faces->line_to(itr->get<2>(),itr->get<3>()); faces->line_to(itr->get<2>(),itr->get<3>() + height); diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index c589a47df..aa1207256 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -360,8 +360,8 @@ void cairo_renderer_base::process(building_symbolizer const& sym, if (geom.size() > 2) { - boost::scoped_ptr frame(new geometry_type(geometry_type::types::LineString)); - boost::scoped_ptr roof(new geometry_type(geometry_type::types::Polygon)); + const std::unique_ptr frame(new geometry_type(geometry_type::types::LineString)); + const std::unique_ptr roof(new geometry_type(geometry_type::types::Polygon)); std::deque face_segments; double x0 = 0; double y0 = 0; @@ -392,7 +392,7 @@ void cairo_renderer_base::process(building_symbolizer const& sym, std::deque::const_iterator end=face_segments.end(); for (; itr != end; ++itr) { - boost::scoped_ptr faces(new geometry_type(geometry_type::types::Polygon)); + const std::unique_ptr faces(new geometry_type(geometry_type::types::Polygon)); faces->move_to(itr->get<0>(), itr->get<1>()); faces->line_to(itr->get<2>(), itr->get<3>()); faces->line_to(itr->get<2>(), itr->get<3>() + height); diff --git a/src/grid/process_building_symbolizer.cpp b/src/grid/process_building_symbolizer.cpp index 941917fda..b3c8805c5 100644 --- a/src/grid/process_building_symbolizer.cpp +++ b/src/grid/process_building_symbolizer.cpp @@ -32,7 +32,7 @@ #include // boost -#include + // stl #include @@ -78,8 +78,8 @@ void grid_renderer::process(building_symbolizer const& sym, geometry_type & geom = feature.get_geometry(i); if (geom.size() > 2) { - boost::scoped_ptr frame(new geometry_type(geometry_type::types::LineString)); - boost::scoped_ptr roof(new geometry_type(geometry_type::types::Polygon)); + const std::unique_ptr frame(new geometry_type(geometry_type::types::LineString)); + const std::unique_ptr roof(new geometry_type(geometry_type::types::Polygon)); std::deque face_segments; double x0(0); double y0(0); @@ -106,7 +106,7 @@ void grid_renderer::process(building_symbolizer const& sym, std::deque::const_iterator itr=face_segments.begin(); for (;itr!=face_segments.end();++itr) { - boost::scoped_ptr faces(new geometry_type(geometry_type::types::Polygon)); + const std::unique_ptr faces(new geometry_type(geometry_type::types::Polygon)); faces->move_to(itr->get<0>(),itr->get<1>()); faces->line_to(itr->get<2>(),itr->get<3>()); faces->line_to(itr->get<2>(),itr->get<3>() + height); diff --git a/src/shield_symbolizer.cpp b/src/shield_symbolizer.cpp index f7b7d0f53..8ef650fee 100644 --- a/src/shield_symbolizer.cpp +++ b/src/shield_symbolizer.cpp @@ -26,7 +26,7 @@ #include // boost -#include + namespace mapnik { diff --git a/src/symbolizer_helpers.cpp b/src/symbolizer_helpers.cpp index 91abab87d..0490a54fa 100644 --- a/src/symbolizer_helpers.cpp +++ b/src/symbolizer_helpers.cpp @@ -62,7 +62,7 @@ text_symbolizer_helper::text_symbolizer_helper(text_sym angle_(0.0), placement_valid_(false), points_on_line_(false), - finder_(0) + finder_() { initialize_geometries(); if (!geometries_to_process_.size()) return; diff --git a/src/text_symbolizer.cpp b/src/text_symbolizer.cpp index 61ea9f6ac..82e25b960 100644 --- a/src/text_symbolizer.cpp +++ b/src/text_symbolizer.cpp @@ -28,7 +28,7 @@ // boost -#include + namespace mapnik From 0eada708450f68c932bb49a83fb5080c3fcd9f7c Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 20 Sep 2013 15:01:58 +0100 Subject: [PATCH 116/122] + use const std::unique_ptr< []> instead of boost::scoped_array --- bindings/python/python_grid_utils.cpp | 8 ++++---- include/mapnik/png_io.hpp | 4 ++-- include/mapnik/value.hpp | 4 ++-- include/mapnik/webp_io.hpp | 2 +- plugins/input/postgis/postgis_featureset.cpp | 4 ++-- src/fs.cpp | 4 ++-- src/graphics.cpp | 4 ++-- src/jpeg_reader.cpp | 5 ++--- src/png_reader.cpp | 8 +++++--- src/text_symbolizer.cpp | 5 ----- utils/pgsql2sqlite/pgsql2sqlite.hpp | 5 ++--- 11 files changed, 24 insertions(+), 29 deletions(-) diff --git a/bindings/python/python_grid_utils.cpp b/bindings/python/python_grid_utils.cpp index d2b03275c..977206d51 100644 --- a/bindings/python/python_grid_utils.cpp +++ b/bindings/python/python_grid_utils.cpp @@ -24,7 +24,7 @@ // boost #include -#include + // mapnik @@ -67,7 +67,7 @@ void grid2utf(T const& grid_type, for (unsigned y = 0; y < data.height(); ++y) { boost::uint16_t idx = 0; - boost::scoped_array line(new Py_UNICODE[array_size]); + const std::unique_ptr line(new Py_UNICODE[array_size]); typename T::value_type const* row = data.getRow(y); for (unsigned x = 0; x < data.width(); ++x) { @@ -130,7 +130,7 @@ void grid2utf(T const& grid_type, for (unsigned y = 0; y < grid_type.height(); y=y+resolution) { boost::uint16_t idx = 0; - boost::scoped_array line(new Py_UNICODE[array_size]); + const std::unique_ptr line(new Py_UNICODE[array_size]); mapnik::grid::value_type const* row = grid_type.getRow(y); for (unsigned x = 0; x < grid_type.width(); x=x+resolution) { @@ -197,7 +197,7 @@ void grid2utf2(T const& grid_type, for (unsigned y = 0; y < target.height(); ++y) { uint16_t idx = 0; - boost::scoped_array line(new Py_UNICODE[array_size]); + const std::unique_ptr line(new Py_UNICODE[array_size]); mapnik::grid::value_type * row = target.getRow(y); unsigned x; for (x = 0; x < target.width(); ++x) diff --git a/include/mapnik/png_io.hpp b/include/mapnik/png_io.hpp index 3de152960..a1b7095ba 100644 --- a/include/mapnik/png_io.hpp +++ b/include/mapnik/png_io.hpp @@ -34,7 +34,7 @@ #include // for Z_DEFAULT_COMPRESSION // boost -#include + // stl #include @@ -123,7 +123,7 @@ void save_as_png(T1 & file, png_set_IHDR(png_ptr, info_ptr,image.width(),image.height(),8, (trans_mode == 0) ? PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_RGB_ALPHA,PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,PNG_FILTER_TYPE_DEFAULT); - boost::scoped_array row_pointers(new png_bytep[image.height()]); + const std::unique_ptr row_pointers(new png_bytep[image.height()]); for (unsigned int i = 0; i < image.height(); i++) { row_pointers[i] = (png_bytep)image.getRow(i); diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index f4f6927b4..1ad24e0b7 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -34,7 +34,7 @@ #include #include #include -#include + #include #include #include "hash_variant.hpp" @@ -61,7 +61,7 @@ inline void to_utf8(mapnik::value_unicode_string const& input, std::string & tar u_strToUTF8(buf, BUF_SIZE, &len, input.getBuffer(), input.length(), &err); if (err == U_BUFFER_OVERFLOW_ERROR || err == U_STRING_NOT_TERMINATED_WARNING ) { - boost::scoped_array buf_ptr(new char [len+1]); + const std::unique_ptr buf_ptr(new char [len+1]); err = U_ZERO_ERROR; u_strToUTF8(buf_ptr.get() , len + 1, &len, input.getBuffer(), input.length(), &err); target.assign(buf_ptr.get() , static_cast(len)); diff --git a/include/mapnik/webp_io.hpp b/include/mapnik/webp_io.hpp index a697b39c9..de57349a1 100644 --- a/include/mapnik/webp_io.hpp +++ b/include/mapnik/webp_io.hpp @@ -34,7 +34,7 @@ #include // boost -#include + namespace mapnik { diff --git a/plugins/input/postgis/postgis_featureset.cpp b/plugins/input/postgis/postgis_featureset.cpp index 0e1f9e50e..90d4ebea2 100644 --- a/plugins/input/postgis/postgis_featureset.cpp +++ b/plugins/input/postgis/postgis_featureset.cpp @@ -34,7 +34,7 @@ #include #include #include // for int2net -#include + // boost @@ -238,7 +238,7 @@ std::string numeric2string(const char* buf) boost::int16_t sign = int2net(buf+4); boost::int16_t dscale = int2net(buf+6); - boost::scoped_array digits(new boost::int16_t[ndigits]); + const std::unique_ptr digits(new boost::int16_t[ndigits]); for (int n=0; n < ndigits ;++n) { digits[n] = int2net(buf+8+n*2); diff --git a/src/fs.cpp b/src/fs.cpp index 9eb01214b..bd78663e2 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -33,7 +33,7 @@ #include #if (BOOST_FILESYSTEM_VERSION <= 2) -#include + namespace boost { namespace filesystem { @@ -44,7 +44,7 @@ path read_symlink(const path& p) #ifdef BOOST_POSIX_API for (std::size_t path_max = 64;; path_max *= 2)// loop 'til buffer is large enough { - boost::scoped_array buf(new char[path_max]); + const std::unique_ptr buf(new char[path_max]); ssize_t result; if ((result=::readlink(p.string().c_str(), buf.get(), path_max))== -1) { diff --git a/src/graphics.cpp b/src/graphics.cpp index cf55b37c3..bafa04ddb 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -33,7 +33,7 @@ #include "agg_color_rgba.h" // boost -#include + // cairo #ifdef HAVE_CAIRO @@ -72,7 +72,7 @@ image_32::image_32(cairo_surface_ptr const& surface) int stride = cairo_image_surface_get_stride(&*surface) / 4; - boost::scoped_array out_row(new unsigned int[width_]); + const std::unique_ptr out_row(new unsigned int[width_]); const unsigned int *in_row = (const unsigned int *)cairo_image_surface_get_data(&*surface); for (unsigned int row = 0; row < height_; row++, in_row += stride) diff --git a/src/jpeg_reader.cpp b/src/jpeg_reader.cpp index 60e7e601d..254d4601f 100644 --- a/src/jpeg_reader.cpp +++ b/src/jpeg_reader.cpp @@ -31,14 +31,13 @@ extern "C" } // boost -#include -#include #include #include #include // std #include +#include namespace mapnik { @@ -280,7 +279,7 @@ void jpeg_reader::read(unsigned x0, unsigned y0, image_data_32& image) unsigned w = std::min(unsigned(image.width()),width_ - x0); unsigned h = std::min(unsigned(image.height()),height_ - y0); - boost::scoped_array out_row(new unsigned int[w]); + const std::unique_ptr out_row(new unsigned int[w]); unsigned row = 0; while (cinfo.output_scanline < cinfo.output_height) { diff --git a/src/png_reader.cpp b/src/png_reader.cpp index 4a732b109..1762fd524 100644 --- a/src/png_reader.cpp +++ b/src/png_reader.cpp @@ -29,12 +29,14 @@ extern "C" #include } // boost -#include // iostreams #include #include #include +// stl +#include + namespace mapnik { @@ -265,7 +267,7 @@ void png_reader::read(unsigned x0, unsigned y0,image_data_32& image) png_read_update_info(png_ptr, info_ptr); // we can read whole image at once // alloc row pointers - boost::scoped_array rows(new png_bytep[height_]); + const std::unique_ptr rows(new png_bytep[height_]); for (unsigned i=0; i::read(unsigned x0, unsigned y0,image_data_32& image) unsigned w=std::min(unsigned(image.width()),width_ - x0); unsigned h=std::min(unsigned(image.height()),height_ - y0); unsigned rowbytes=png_get_rowbytes(png_ptr, info_ptr); - boost::scoped_array row(new png_byte[rowbytes]); + const std::unique_ptr row(new png_byte[rowbytes]); //START read image rows for (unsigned i = 0;i < height_; ++i) { diff --git a/src/text_symbolizer.cpp b/src/text_symbolizer.cpp index 82e25b960..7b6ce662f 100644 --- a/src/text_symbolizer.cpp +++ b/src/text_symbolizer.cpp @@ -26,11 +26,6 @@ #include #include - -// boost - - - namespace mapnik { diff --git a/utils/pgsql2sqlite/pgsql2sqlite.hpp b/utils/pgsql2sqlite/pgsql2sqlite.hpp index 24e34f03e..08fe6efc2 100644 --- a/utils/pgsql2sqlite/pgsql2sqlite.hpp +++ b/utils/pgsql2sqlite/pgsql2sqlite.hpp @@ -35,13 +35,12 @@ // boost #include -#include -#include #include //stl #include #include +#include static std::string numeric2string(const char* buf) { @@ -50,7 +49,7 @@ static std::string numeric2string(const char* buf) boost::int16_t sign = int2net(buf+4); boost::int16_t dscale = int2net(buf+6); - boost::scoped_array digits(new boost::int16_t[ndigits]); + const std::unique_ptr digits(new boost::int16_t[ndigits]); for (int n=0; n < ndigits ;++n) { digits[n] = int2net(buf+8+n*2); From 153c7cce60c3fff84b1bd0b48966b97dc0a8d7bc Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 23 Sep 2013 11:37:16 -0700 Subject: [PATCH 117/122] fix compile of pgsql2sqlite --- utils/pgsql2sqlite/pgsql2sqlite.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/pgsql2sqlite/pgsql2sqlite.hpp b/utils/pgsql2sqlite/pgsql2sqlite.hpp index 08fe6efc2..a8cd76219 100644 --- a/utils/pgsql2sqlite/pgsql2sqlite.hpp +++ b/utils/pgsql2sqlite/pgsql2sqlite.hpp @@ -248,7 +248,7 @@ void pgsql2sqlite(Connection conn, std::string output_table_insert_sql = "insert into " + output_table_name + " values (?"; - context_ptr ctx = boost::make_shared(); + context_ptr ctx = std::make_shared(); for ( unsigned pos = 0; pos < num_fields ; ++pos) { From f76b020e5ebe8e68f99ec68c76c319daa54bf09f Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 24 Sep 2013 14:41:22 +0100 Subject: [PATCH 118/122] + remove redundant identity matrix and pass 0 to FT_Set_Transform --- src/font_engine_freetype.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index f8b8ad24e..bc69e2756 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -312,7 +312,6 @@ char_info font_face_set::character_dimensions(unsigned int c) return itr->second; } - FT_Matrix matrix; FT_Vector pen; FT_Error error; @@ -325,12 +324,7 @@ char_info font_face_set::character_dimensions(unsigned int c) glyph_ptr glyph = get_glyph(c); FT_Face face = glyph->get_face()->get_face(); - matrix.xx = (FT_Fixed)( 1 * 0x10000L ); - matrix.xy = (FT_Fixed)( 0 * 0x10000L ); - matrix.yx = (FT_Fixed)( 0 * 0x10000L ); - matrix.yy = (FT_Fixed)( 1 * 0x10000L ); - - FT_Set_Transform(face, &matrix, &pen); + FT_Set_Transform(face, 0, &pen); error = FT_Load_Glyph (face, glyph->get_index(), FT_LOAD_NO_HINTING); if ( error ) From 6e4c911bb6dfbeab2504ccc22a02a73e06090f71 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 24 Sep 2013 14:06:16 -0700 Subject: [PATCH 119/122] fix bug in polygon_clipper coincident vertice detection --- include/mapnik/polygon_clipper.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/polygon_clipper.hpp b/include/mapnik/polygon_clipper.hpp index 8d4284a4d..30a37bc86 100644 --- a/include/mapnik/polygon_clipper.hpp +++ b/include/mapnik/polygon_clipper.hpp @@ -166,7 +166,7 @@ private: continue; } prev_x = x; - prev_x = y; + prev_y = y; if (ring_count == 1) { append(subject_poly, make(x,y)); From 8ca8b2c64e9f5523cd8933a31f376d2b6a907014 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 24 Sep 2013 15:24:18 -0700 Subject: [PATCH 120/122] fix winding order, allowing boost::polygon clipper to return exterior/interior rings correctly --- tests/visual_tests/styles/geometry-transform-translate.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/visual_tests/styles/geometry-transform-translate.xml b/tests/visual_tests/styles/geometry-transform-translate.xml index ee0344cd8..e61bf5a81 100644 --- a/tests/visual_tests/styles/geometry-transform-translate.xml +++ b/tests/visual_tests/styles/geometry-transform-translate.xml @@ -48,7 +48,7 @@ csv wkt -"POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1), (2 2, 2 3, 3 3, 3 2, 2 2))" +"POLYGON ((1 1, 1 4, 4 4, 4 1, 1 1), (2 2, 3 2, 3 3, 2 3, 2 2))" From 0b5d70f926d65556c807e46f9188371d7e5c2890 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 24 Sep 2013 21:18:52 -0700 Subject: [PATCH 121/122] polygon_clipper: detect invalid winding order when in debug mode --- include/mapnik/polygon_clipper.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/mapnik/polygon_clipper.hpp b/include/mapnik/polygon_clipper.hpp index 30a37bc86..470f06fbc 100644 --- a/include/mapnik/polygon_clipper.hpp +++ b/include/mapnik/polygon_clipper.hpp @@ -28,6 +28,7 @@ // mapnik #include +#include #include // boost @@ -101,7 +102,7 @@ struct polygon_clipper } - polygon_clipper( box2d const& clip_box,Geometry & geom) + polygon_clipper(box2d const& clip_box, Geometry & geom) : clip_box_(clip_box), geom_(geom) { @@ -179,7 +180,13 @@ private: } polygon_list clipped_polygons; - +#ifdef MAPNIK_LOG + double area = boost::geometry::area(subject_poly); + if (area < 0) + { + MAPNIK_LOG_ERROR(polygon_clipper) << "negative area detected for polygon indicating incorrect winding order"; + } +#endif try { boost::geometry::intersection(clip_box_, subject_poly, clipped_polygons); From ec53cd9a02203b8e337a75cd286a22e60089f9d0 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 24 Sep 2013 23:22:06 -0700 Subject: [PATCH 122/122] automatically set c++11 flags --- SConstruct | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/SConstruct b/SConstruct index 08c403c10..f94286920 100644 --- a/SConstruct +++ b/SConstruct @@ -38,9 +38,13 @@ severities = ['debug', 'warn', 'error', 'none'] DEFAULT_CC = "gcc" DEFAULT_CXX = "g++" +DEFAULT_CXX11_CXXFLAGS = " -std=c++11" +DEFAULT_CXX11_LINKFLAGS = "" if sys.platform == 'darwin': DEFAULT_CC = "clang" DEFAULT_CXX = "clang++" + DEFAULT_CXX11_CXXFLAGS += ' -stdlib=libc++' + DEFAULT_CXX11_LINKFLAGS = ' -stdlib=libc++' py3 = None @@ -1126,8 +1130,10 @@ if not preconfigured: # set any custom cxxflags and ldflags to come first env.Append(CPPDEFINES = env['CUSTOM_DEFINES']) + env.Append(CUSTOM_CXXFLAGS = DEFAULT_CXX11_CXXFLAGS) env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS']) env.Append(CFLAGS = env['CUSTOM_CFLAGS']) + env.Append(CUSTOM_LDFLAGS = DEFAULT_CXX11_LINKFLAGS) env.Append(LINKFLAGS = env['CUSTOM_LDFLAGS']) ### platform specific bits @@ -1680,13 +1686,12 @@ if not preconfigured: # c++11 support / https://github.com/mapnik/mapnik/issues/1683 # - upgrade to PHOENIX_V3 since that is needed for c++11 compile - if 'c++11' in env['CUSTOM_CXXFLAGS']: - env.Append(CPPDEFINES = '-DBOOST_SPIRIT_USE_PHOENIX_V3=1') - # - workaround boost gil channel_algorithm.hpp narrowing error - # TODO - remove when building against >= 1.55 - # https://github.com/mapnik/mapnik/issues/1970 - if 'clang++' in env['CXX']: - env.Append(CXXFLAGS = '-Wno-c++11-narrowing') + env.Append(CPPDEFINES = '-DBOOST_SPIRIT_USE_PHOENIX_V3=1') + # - workaround boost gil channel_algorithm.hpp narrowing error + # TODO - remove when building against >= 1.55 + # https://github.com/mapnik/mapnik/issues/1970 + if 'clang++' in env['CXX']: + env.Append(CXXFLAGS = '-Wno-c++11-narrowing') # Enable logging in debug mode (always) and release mode (when specified) if env['DEFAULT_LOG_SEVERITY']: