fix compile on windows with msvc 2010 - closes #1646

This commit is contained in:
Dane Springmeyer 2012-12-12 15:09:07 -08:00
parent e60a3f7703
commit 3fd7909ba0
4 changed files with 36 additions and 39 deletions

View file

@ -30,9 +30,13 @@
#include <mapnik/hextree.hpp>
#include <mapnik/miniz_png.hpp>
#include <mapnik/image_data.hpp>
// zlib
#include <zlib.h>
// boost
#include <boost/scoped_array.hpp>
extern "C"
{
#include <png.h>
@ -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<png_byte*> 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);
}

View file

@ -28,12 +28,15 @@
// stl
#include <string>
#include <cmath> // log10
// boost
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/karma.hpp>
// boost
#include <boost/version.hpp>
#include <boost/math/special_functions/trunc.hpp> // trunc to avoid needing C++11
#if BOOST_VERSION >= 104500
#include <boost/config/warning_disable.hpp>
@ -68,7 +71,7 @@ struct double_policy : boost::spirit::karma::real_policies<T>
{
typedef boost::spirit::karma::real_policies<T> 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<unsigned>(15 - boost::math::trunc(log10(n))); }
template <typename OutputIterator>
static bool dot(OutputIterator& sink, T n, unsigned precision) {
return n ? *sink = '.', true : false;

View file

@ -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<std::string, std::string>::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<mapnik::datasource::geometry_t> 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<long>(data_type);
boost::python::object data_type = datasource_.attr("data_type");
long data_type_integer = boost::python::extract<long>(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<double> python_datasource::envelope() const
{
using namespace boost::python;
if (!is_bound_) bind();
try
{
ensure_gil lock;
return extract<mapnik::box2d<double> >(datasource_.attr("envelope"));
return boost::python::extract<mapnik::box2d<double> >(datasource_.attr("envelope"));
}
catch ( error_already_set )
catch ( boost::python::error_already_set )
{
throw mapnik::datasource_exception(extractException());
}
@ -157,8 +152,6 @@ mapnik::box2d<double> python_datasource::envelope() const
boost::optional<mapnik::datasource::geometry_t> python_datasource::get_geometry_type() const
{
using namespace boost::python;
typedef boost::optional<mapnik::datasource::geometry_t> return_type;
if (!is_bound_) bind();
@ -171,16 +164,16 @@ boost::optional<mapnik::datasource::geometry_t> 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<long>(py_geometry_type);
long geom_type_integer = boost::python::extract<long>(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<mapnik::datasource::geometry_t> 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<python_featureset>(features);
}
catch ( error_already_set )
catch ( boost::python::error_already_set )
{
throw mapnik::datasource_exception(extractException());
}

View file

@ -24,7 +24,7 @@
#include <mapnik/config_error.hpp>
// stl
#include <iostream>
#include <sstream>
#include <iomanip>
namespace mapnik