From 3fd7909ba0aa0f1ce843f8613556dc41bfb1710a Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 12 Dec 2012 15:09:07 -0800 Subject: [PATCH] fix compile on windows with msvc 2010 - closes #1646 --- include/mapnik/png_io.hpp | 8 ++- include/mapnik/util/conversions.hpp | 5 +- plugins/input/python/python_datasource.cpp | 60 +++++++++------------- src/palette.cpp | 2 +- 4 files changed, 36 insertions(+), 39 deletions(-) diff --git a/include/mapnik/png_io.hpp b/include/mapnik/png_io.hpp index d669e479a..25bd8d97b 100644 --- a/include/mapnik/png_io.hpp +++ b/include/mapnik/png_io.hpp @@ -30,9 +30,13 @@ #include #include #include + // zlib #include +// boost +#include + extern "C" { #include @@ -118,12 +122,12 @@ 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); - png_bytep row_pointers[image.height()]; + boost::scoped_array row_pointers(new png_bytep[image.height()]); for (unsigned int i = 0; i < image.height(); i++) { row_pointers[i] = (png_bytep)image.getRow(i); } - png_set_rows(png_ptr, info_ptr, (png_bytepp)&row_pointers); + png_set_rows(png_ptr, info_ptr, row_pointers.get()); png_write_png(png_ptr, info_ptr, (trans_mode == 0) ? PNG_TRANSFORM_STRIP_FILLER_AFTER : PNG_TRANSFORM_IDENTITY, NULL); png_destroy_write_struct(&png_ptr, &info_ptr); } diff --git a/include/mapnik/util/conversions.hpp b/include/mapnik/util/conversions.hpp index ad15627ae..48f2daa3d 100644 --- a/include/mapnik/util/conversions.hpp +++ b/include/mapnik/util/conversions.hpp @@ -28,12 +28,15 @@ // stl #include +#include // log10 + // boost #include #include // boost #include +#include // trunc to avoid needing C++11 #if BOOST_VERSION >= 104500 #include @@ -68,7 +71,7 @@ struct double_policy : boost::spirit::karma::real_policies { typedef boost::spirit::karma::real_policies base_type; static int floatfield(T n) { return base_type::fmtflags::fixed; } - static unsigned precision(T n) { return 15 - trunc(log10(n)); } + static unsigned precision(T n) { return static_cast(15 - boost::math::trunc(log10(n))); } template static bool dot(OutputIterator& sink, T n, unsigned precision) { return n ? *sink = '.', true : false; diff --git a/plugins/input/python/python_datasource.cpp b/plugins/input/python/python_datasource.cpp index 7ef0a3cfa..bceeb20bb 100644 --- a/plugins/input/python/python_datasource.cpp +++ b/plugins/input/python/python_datasource.cpp @@ -62,7 +62,6 @@ mapnik::layer_descriptor python_datasource::get_descriptor() const void python_datasource::bind() const { using namespace boost; - using namespace boost::python; if (is_bound_) return; @@ -81,34 +80,34 @@ void python_datasource::bind() const + factory_ + '"'); } // extract the module and the callable - str module_name("__main__"), callable_name; + boost::python::str module_name("__main__"), callable_name; if (factory_split.size() == 1) { - callable_name = str(factory_split[0]); + callable_name = boost::python::str(factory_split[0]); } else { - module_name = str(factory_split[0]); - callable_name = str(factory_split[1]); + module_name = boost::python::str(factory_split[0]); + callable_name = boost::python::str(factory_split[1]); } ensure_gil lock; // import the main module from Python (in case we're embedding the // interpreter directly) and also import the callable. - object main_module = import("__main__"); - object callable_module = import(module_name); - object callable = callable_module.attr(callable_name); + boost::python::object main_module = boost::python::import("__main__"); + boost::python::object callable_module = boost::python::import(module_name); + boost::python::object callable = callable_module.attr(callable_name); // prepare the arguments - dict kwargs; + boost::python::dict kwargs; typedef std::map::value_type kv_type; BOOST_FOREACH(const kv_type& kv, kwargs_) { - kwargs[str(kv.first)] = str(kv.second); + kwargs[boost::python::str(kv.first)] = boost::python::str(kv.second); } // get our wrapped data source datasource_ = callable(*boost::python::make_tuple(), **kwargs); } - catch ( error_already_set ) + catch ( boost::python::error_already_set ) { throw mapnik::datasource_exception(extractException()); } @@ -118,8 +117,6 @@ void python_datasource::bind() const mapnik::datasource::datasource_t python_datasource::type() const { - using namespace boost::python; - typedef boost::optional return_type; if (!is_bound_) bind(); @@ -127,11 +124,11 @@ mapnik::datasource::datasource_t python_datasource::type() const try { ensure_gil lock; - object data_type = datasource_.attr("data_type"); - long data_type_integer = extract(data_type); + boost::python::object data_type = datasource_.attr("data_type"); + long data_type_integer = boost::python::extract(data_type); return mapnik::datasource::datasource_t(data_type_integer); } - catch ( error_already_set ) + catch ( boost::python::error_already_set ) { throw mapnik::datasource_exception(extractException()); } @@ -140,16 +137,14 @@ mapnik::datasource::datasource_t python_datasource::type() const mapnik::box2d python_datasource::envelope() const { - using namespace boost::python; - if (!is_bound_) bind(); try { ensure_gil lock; - return extract >(datasource_.attr("envelope")); + return boost::python::extract >(datasource_.attr("envelope")); } - catch ( error_already_set ) + catch ( boost::python::error_already_set ) { throw mapnik::datasource_exception(extractException()); } @@ -157,8 +152,6 @@ mapnik::box2d python_datasource::envelope() const boost::optional python_datasource::get_geometry_type() const { - using namespace boost::python; - typedef boost::optional return_type; if (!is_bound_) bind(); @@ -171,16 +164,16 @@ boost::optional python_datasource::get_geometry_ { return return_type(); } - object py_geometry_type = datasource_.attr("geometry_type"); + boost::python::object py_geometry_type = datasource_.attr("geometry_type"); // if the attribute value is 'None', return a 'none' value - if (py_geometry_type.ptr() == object().ptr()) + if (py_geometry_type.ptr() == boost::python::object().ptr()) { return return_type(); } - long geom_type_integer = extract(py_geometry_type); + long geom_type_integer = boost::python::extract(py_geometry_type); return mapnik::datasource::geometry_t(geom_type_integer); } - catch ( error_already_set ) + catch ( boost::python::error_already_set ) { throw mapnik::datasource_exception(extractException()); } @@ -188,8 +181,6 @@ boost::optional python_datasource::get_geometry_ mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const { - using namespace boost::python; - if (!is_bound_) bind(); try @@ -198,9 +189,9 @@ mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const if (envelope().intersects(q.get_bbox())) { ensure_gil lock; - object features(datasource_.attr("features")(q)); + boost::python::object features(datasource_.attr("features")(q)); // if 'None' was returned, return an empty feature set - if(features.ptr() == object().ptr()) + if(features.ptr() == boost::python::object().ptr()) { return mapnik::featureset_ptr(); } @@ -209,7 +200,7 @@ mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const // otherwise return an empty featureset pointer return mapnik::featureset_ptr(); } - catch ( error_already_set ) + catch ( boost::python::error_already_set ) { throw mapnik::datasource_exception(extractException()); } @@ -217,23 +208,22 @@ mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const mapnik::featureset_ptr python_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const { - using namespace boost::python; if (!is_bound_) bind(); try { ensure_gil lock; - object features(datasource_.attr("features_at_point")(pt)); + boost::python::object features(datasource_.attr("features_at_point")(pt)); // if we returned none, return an empty set - if(features.ptr() == object().ptr()) + if(features.ptr() == boost::python::object().ptr()) { return mapnik::featureset_ptr(); } // otherwise, return a feature set which can iterate over the iterator return boost::make_shared(features); } - catch ( error_already_set ) + catch ( boost::python::error_already_set ) { throw mapnik::datasource_exception(extractException()); } diff --git a/src/palette.cpp b/src/palette.cpp index 669a44130..1829015a3 100644 --- a/src/palette.cpp +++ b/src/palette.cpp @@ -24,7 +24,7 @@ #include // stl -#include +#include #include namespace mapnik