Fix deprecation warnings. Part 2

Closes #1340.
This commit is contained in:
Hermann Kraus 2012-07-25 01:15:44 +02:00
parent 3054145103
commit 08cbf1c71c
2 changed files with 12 additions and 44 deletions

View file

@ -21,6 +21,13 @@
*
*****************************************************************************/
/* The functions in this file produce deprecation warnings.
* But as shield symbolizer doesn't fully support more than one
* placement from python yet these functions are actually the
* correct ones.
*/
#define NO_DEPRECATION_WARNINGS
// boost
#include <boost/python.hpp>
@ -53,12 +60,13 @@ tuple get_shield_displacement(const shield_symbolizer& s)
void set_shield_displacement(shield_symbolizer & s, boost::python::tuple arg)
{
s.set_shield_displacement(extract<double>(arg[0]),extract<double>(arg[1]));
s.get_placement_options()->defaults.displacement.first = extract<double>(arg[0]);
s.get_placement_options()->defaults.displacement.second = extract<double>(arg[1]);
}
tuple get_text_displacement(const shield_symbolizer& t)
{
position const& pos = t.get_displacement();
position const& pos = t.get_placement_options()->defaults.displacement;
return boost::python::make_tuple(pos.first, pos.second);
}
@ -79,46 +87,6 @@ void set_filename(shield_symbolizer & t, std::string const& file_expr)
}
struct shield_symbolizer_pickle_suite : boost::python::pickle_suite
{
static boost::python::tuple
getinitargs(const shield_symbolizer& s)
{
std::string filename = path_processor_type::to_string(*s.get_filename());
//(name, font name, font size, font color, image file, image type, width, height)
return boost::python::make_tuple( "TODO",//s.get_name(),
s.get_face_name(),s.get_text_size(),s.get_fill(),filename,guess_type(filename));
}
static boost::python::tuple
getstate(const shield_symbolizer& s)
{
return boost::python::make_tuple(s.get_halo_fill(),s.get_halo_radius());
}
// TODO add lots more...
static void
setstate (shield_symbolizer& s, boost::python::tuple state)
{
using namespace boost::python;
/*if (len(state) != 1)
{
PyErr_SetObject(PyExc_ValueError,
("expected 1-item tuple in call to __setstate__; got %s"
% state).ptr()
);
throw_error_already_set();
}*/
s.set_halo_fill(extract<color>(state[0]));
s.set_halo_radius(extract<float>(state[1]));
}
};
void export_shield_symbolizer()
{
using namespace boost::python;
@ -126,7 +94,7 @@ void export_shield_symbolizer()
init<expression_ptr,
std::string const&,
unsigned, mapnik::color const&,
path_expression_ptr>("TODO")
path_expression_ptr>()
)
//.def_pickle(shield_symbolizer_pickle_suite())
.add_property("allow_overlap",

View file

@ -37,7 +37,7 @@
// stl
#include <string>
#if (1 && __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#if (!defined(NO_DEPRECATION_WARNINGS) && __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#define func_deprecated __attribute__ ((deprecated))
#else
#define func_deprecated