apply mapnik_format.el formatting
This commit is contained in:
parent
76e108ff9d
commit
b36739fd88
7 changed files with 85 additions and 85 deletions
|
@ -125,7 +125,7 @@ bool painted(mapnik::image_32 const& im)
|
|||
void set_pixel(mapnik::image_32 & im, unsigned x, unsigned y, mapnik::color const& c)
|
||||
{
|
||||
im.setPixel(x, y, c.rgba());
|
||||
}
|
||||
}
|
||||
|
||||
boost::shared_ptr<image_32> open_from_file(std::string const& filename)
|
||||
{
|
||||
|
|
|
@ -40,15 +40,15 @@
|
|||
using namespace mapnik;
|
||||
|
||||
/* Notes:
|
||||
Overriding functions in inherited classes:
|
||||
boost.python documentation doesn't really tell you how to do it.
|
||||
But this helps:
|
||||
http://www.gamedev.net/topic/446225-inheritance-in-boostpython/
|
||||
Overriding functions in inherited classes:
|
||||
boost.python documentation doesn't really tell you how to do it.
|
||||
But this helps:
|
||||
http://www.gamedev.net/topic/446225-inheritance-in-boostpython/
|
||||
|
||||
register_ptr_to_python is required for wrapped classes, but not for unwrapped.
|
||||
register_ptr_to_python is required for wrapped classes, but not for unwrapped.
|
||||
|
||||
Functions don't have to be members of the class, but can also be
|
||||
normal functions taking a ref to the class as first parameter.
|
||||
Functions don't have to be members of the class, but can also be
|
||||
normal functions taking a ref to the class as first parameter.
|
||||
*/
|
||||
|
||||
namespace {
|
||||
|
@ -261,7 +261,7 @@ struct TextPlacementsWrap: text_placements, wrapper<text_placements>
|
|||
struct TextPlacementInfoWrap: text_placement_info, wrapper<text_placement_info>
|
||||
{
|
||||
TextPlacementInfoWrap(text_placements const* parent,
|
||||
double scale_factor_)
|
||||
double scale_factor_)
|
||||
: text_placement_info(parent, scale_factor_)
|
||||
{
|
||||
|
||||
|
@ -339,7 +339,7 @@ void export_text_placement()
|
|||
;
|
||||
|
||||
class_<text_symbolizer>("TextSymbolizer",
|
||||
init<>())
|
||||
init<>())
|
||||
.def(init<expression_ptr, std::string const&, unsigned, color const&>())
|
||||
.add_property("placements",
|
||||
&text_symbolizer::get_placement_options,
|
||||
|
@ -357,7 +357,7 @@ void export_text_placement()
|
|||
|
||||
|
||||
class_with_converter<text_symbolizer_properties>
|
||||
("TextSymbolizerProperties")
|
||||
("TextSymbolizerProperties")
|
||||
.def_readwrite_convert("label_placement", &text_symbolizer_properties::label_placement)
|
||||
.def_readwrite_convert("horizontal_alignment", &text_symbolizer_properties::halign)
|
||||
.def_readwrite_convert("justify_alignment", &text_symbolizer_properties::jalign)
|
||||
|
@ -381,15 +381,15 @@ void export_text_placement()
|
|||
.add_property ("format_tree",
|
||||
&text_symbolizer_properties::format_tree,
|
||||
&text_symbolizer_properties::set_format_tree);
|
||||
/* from_xml, to_xml operate on mapnik's internal XML tree and don't make sense in python.
|
||||
add_expressions isn't useful in python either. The result is only needed by
|
||||
attribute_collector (which isn't exposed in python) and
|
||||
it just calls add_expressions of the associated formatting tree.
|
||||
set_old_style expression is just a compatibility wrapper and doesn't need to be exposed in python. */
|
||||
;
|
||||
/* from_xml, to_xml operate on mapnik's internal XML tree and don't make sense in python.
|
||||
add_expressions isn't useful in python either. The result is only needed by
|
||||
attribute_collector (which isn't exposed in python) and
|
||||
it just calls add_expressions of the associated formatting tree.
|
||||
set_old_style expression is just a compatibility wrapper and doesn't need to be exposed in python. */
|
||||
;
|
||||
|
||||
class_<char_properties>
|
||||
("CharProperties")
|
||||
("CharProperties")
|
||||
.def(init<char_properties const&>()) //Copy constructor
|
||||
.def_readwrite("face_name", &char_properties::face_name)
|
||||
.def_readwrite("fontset", &char_properties::fontset)
|
||||
|
@ -407,9 +407,9 @@ void export_text_placement()
|
|||
;
|
||||
|
||||
class_<TextPlacementsWrap,
|
||||
boost::shared_ptr<TextPlacementsWrap>,
|
||||
boost::noncopyable>
|
||||
("TextPlacements")
|
||||
boost::shared_ptr<TextPlacementsWrap>,
|
||||
boost::noncopyable>
|
||||
("TextPlacements")
|
||||
.def_readwrite("defaults", &text_placements::defaults)
|
||||
.def("get_placement_info", pure_virtual(&text_placements::get_placement_info))
|
||||
/* TODO: add_expressions() */
|
||||
|
@ -417,10 +417,10 @@ void export_text_placement()
|
|||
register_ptr_to_python<boost::shared_ptr<text_placements> >();
|
||||
|
||||
class_<TextPlacementInfoWrap,
|
||||
boost::shared_ptr<TextPlacementInfoWrap>,
|
||||
boost::noncopyable>
|
||||
("TextPlacementInfo",
|
||||
init<text_placements const*, double>())
|
||||
boost::shared_ptr<TextPlacementInfoWrap>,
|
||||
boost::noncopyable>
|
||||
("TextPlacementInfo",
|
||||
init<text_placements const*, double>())
|
||||
.def("next", pure_virtual(&text_placement_info::next))
|
||||
.def("get_actual_label_spacing", &text_placement_info::get_actual_label_spacing)
|
||||
.def("get_actual_minimum_distance", &text_placement_info::get_actual_minimum_distance)
|
||||
|
@ -432,27 +432,27 @@ void export_text_placement()
|
|||
|
||||
|
||||
class_<processed_text,
|
||||
boost::shared_ptr<processed_text>,
|
||||
boost::noncopyable>
|
||||
("ProcessedText", no_init)
|
||||
boost::shared_ptr<processed_text>,
|
||||
boost::noncopyable>
|
||||
("ProcessedText", no_init)
|
||||
.def("push_back", &processed_text::push_back)
|
||||
.def("clear", &processed_text::clear)
|
||||
;
|
||||
|
||||
|
||||
class_<expression_set,
|
||||
boost::shared_ptr<expression_set>,
|
||||
boost::noncopyable>
|
||||
("ExpressionSet")
|
||||
boost::shared_ptr<expression_set>,
|
||||
boost::noncopyable>
|
||||
("ExpressionSet")
|
||||
.def("insert", &insert_expression);
|
||||
;
|
||||
;
|
||||
|
||||
|
||||
//TODO: Python namespace
|
||||
class_<NodeWrap,
|
||||
boost::shared_ptr<NodeWrap>,
|
||||
boost::noncopyable>
|
||||
("FormattingNode")
|
||||
boost::shared_ptr<NodeWrap>,
|
||||
boost::noncopyable>
|
||||
("FormattingNode")
|
||||
.def("apply", pure_virtual(&formatting::node::apply))
|
||||
.def("add_expressions",
|
||||
&formatting::node::add_expressions,
|
||||
|
@ -462,10 +462,10 @@ void export_text_placement()
|
|||
|
||||
|
||||
class_<TextNodeWrap,
|
||||
boost::shared_ptr<TextNodeWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingText", init<expression_ptr>())
|
||||
boost::shared_ptr<TextNodeWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingText", init<expression_ptr>())
|
||||
.def(init<std::string>())
|
||||
.def("apply", &formatting::text_node::apply, &TextNodeWrap::default_apply)
|
||||
.add_property("text",
|
||||
|
@ -476,10 +476,10 @@ void export_text_placement()
|
|||
|
||||
|
||||
class_with_converter<FormatNodeWrap,
|
||||
boost::shared_ptr<FormatNodeWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingFormat")
|
||||
boost::shared_ptr<FormatNodeWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingFormat")
|
||||
.def_readwrite_convert("text_size", &formatting::format_node::text_size)
|
||||
.def_readwrite_convert("face_name", &formatting::format_node::face_name)
|
||||
.def_readwrite_convert("character_spacing", &formatting::format_node::character_spacing)
|
||||
|
@ -499,10 +499,10 @@ void export_text_placement()
|
|||
register_ptr_to_python<boost::shared_ptr<formatting::format_node> >();
|
||||
|
||||
class_<ListNodeWrap,
|
||||
boost::shared_ptr<ListNodeWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingList", init<>())
|
||||
boost::shared_ptr<ListNodeWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingList", init<>())
|
||||
.def(init<list>())
|
||||
.def("append", &formatting::list_node::push_back)
|
||||
.def("apply", &formatting::list_node::apply, &ListNodeWrap::default_apply)
|
||||
|
@ -510,15 +510,15 @@ void export_text_placement()
|
|||
.def("__getitem__", &ListNodeWrap::get_item)
|
||||
.def("__setitem__", &ListNodeWrap::set_item)
|
||||
.def("append", &ListNodeWrap::append)
|
||||
;
|
||||
;
|
||||
|
||||
register_ptr_to_python<boost::shared_ptr<formatting::list_node> >();
|
||||
|
||||
class_<ExprFormatWrap,
|
||||
boost::shared_ptr<ExprFormatWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingExpressionFormat")
|
||||
boost::shared_ptr<ExprFormatWrap>,
|
||||
bases<formatting::node>,
|
||||
boost::noncopyable>
|
||||
("FormattingExpressionFormat")
|
||||
.def_readwrite("text_size", &formatting::expression_format::text_size)
|
||||
.def_readwrite("face_name", &formatting::expression_format::face_name)
|
||||
.def_readwrite("character_spacing", &formatting::expression_format::character_spacing)
|
||||
|
|
|
@ -29,8 +29,8 @@ namespace mapnik {
|
|||
class python_thread
|
||||
{
|
||||
/* Docs:
|
||||
http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock
|
||||
*/
|
||||
http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock
|
||||
*/
|
||||
public:
|
||||
static void unblock()
|
||||
{
|
||||
|
@ -38,8 +38,8 @@ public:
|
|||
if (state.get())
|
||||
{
|
||||
std::cerr << "ERROR: Python threads are already unblocked. "
|
||||
"Unblocking again will loose the current state and "
|
||||
"might crash later. Aborting!\n";
|
||||
"Unblocking again will loose the current state and "
|
||||
"might crash later. Aborting!\n";
|
||||
abort(); //This is a serious error and can't be handled in any other sane way
|
||||
}
|
||||
#endif
|
||||
|
@ -59,9 +59,9 @@ public:
|
|||
if (thread_support && !state.get())
|
||||
{
|
||||
std::cerr << "ERROR: Trying to restore python thread state, "
|
||||
"but no state is saved. Can't continue and also "
|
||||
"can't raise an exception because the python "
|
||||
"interpreter might be non-function. Aborting!\n";
|
||||
"but no state is saved. Can't continue and also "
|
||||
"can't raise an exception because the python "
|
||||
"interpreter might be non-function. Aborting!\n";
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -102,8 +102,8 @@ struct python_optional : public boost::noncopyable
|
|||
|
||||
/** This class works around a bug 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 <typename T, typename X1 = boost::python::detail::not_specified, typename X2 = boost::python::detail::not_specified, typename X3 = boost::python::detail::not_specified>
|
||||
class class_with_converter : public boost::python::class_<T, X1, X2, X3>
|
||||
{
|
||||
|
@ -131,8 +131,8 @@ public:
|
|||
self& def_readwrite_convert(char const* name, D const& d, char const* doc=0)
|
||||
{
|
||||
this->add_property(name,
|
||||
boost::python::make_getter(d, boost::python::return_value_policy<boost::python::return_by_value>()),
|
||||
boost::python::make_setter(d, boost::python::default_call_policies()));
|
||||
boost::python::make_getter(d, boost::python::return_value_policy<boost::python::return_by_value>()),
|
||||
boost::python::make_setter(d, boost::python::default_call_policies()));
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -373,7 +373,7 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature,
|
|||
if (! is_single_geom && elem_size > SDO_ELEM_INFO_SIZE)
|
||||
{
|
||||
geometry_type* geom = new geometry_type(geom_type);
|
||||
|
||||
|
||||
for (int i = SDO_ELEM_INFO_SIZE; i < elem_size; i+=3)
|
||||
{
|
||||
int next_offset = elem_info[i];
|
||||
|
|
|
@ -681,22 +681,22 @@ box2d<double> postgis_datasource::envelope() const
|
|||
shared_ptr<ResultSet> rs = conn->executeQuery(s.str());
|
||||
if (rs->next() && !rs->isNull(0))
|
||||
{
|
||||
double lox;
|
||||
double loy;
|
||||
double hix;
|
||||
double hiy;
|
||||
if (mapnik::conversions::string2double(rs->getValue(0),lox) &&
|
||||
mapnik::conversions::string2double(rs->getValue(1),loy) &&
|
||||
mapnik::conversions::string2double(rs->getValue(2),hix) &&
|
||||
mapnik::conversions::string2double(rs->getValue(3),hiy))
|
||||
{
|
||||
extent_.init(lox,loy,hix,hiy);
|
||||
extent_initialized_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::clog << boost::format("Postgis Plugin: warning: could not determine extent from query: %s\n") % s.str() << std::endl;
|
||||
}
|
||||
double lox;
|
||||
double loy;
|
||||
double hix;
|
||||
double hiy;
|
||||
if (mapnik::conversions::string2double(rs->getValue(0),lox) &&
|
||||
mapnik::conversions::string2double(rs->getValue(1),loy) &&
|
||||
mapnik::conversions::string2double(rs->getValue(2),hix) &&
|
||||
mapnik::conversions::string2double(rs->getValue(3),hiy))
|
||||
{
|
||||
extent_.init(lox,loy,hix,hiy);
|
||||
extent_initialized_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::clog << boost::format("Postgis Plugin: warning: could not determine extent from query: %s\n") % s.str() << std::endl;
|
||||
}
|
||||
}
|
||||
rs->close();
|
||||
}
|
||||
|
|
|
@ -103,12 +103,12 @@ void shape_io::read_polyline(mapnik::geometry_container & geom)
|
|||
{
|
||||
shape_file::record_type record(reclength_ * 2 - 36);
|
||||
shp_.read_record(record);
|
||||
|
||||
|
||||
int num_parts = record.read_ndr_integer();
|
||||
int num_points = record.read_ndr_integer();
|
||||
if (num_parts == 1)
|
||||
{
|
||||
geometry_type* line = new geometry_type(mapnik::LineString);
|
||||
geometry_type* line = new geometry_type(mapnik::LineString);
|
||||
record.skip(4);
|
||||
double x = record.read_double();
|
||||
double y = record.read_double();
|
||||
|
@ -132,7 +132,7 @@ void shape_io::read_polyline(mapnik::geometry_container & geom)
|
|||
int start, end;
|
||||
for (int k = 0; k < num_parts; ++k)
|
||||
{
|
||||
geometry_type* line = new geometry_type(mapnik::LineString);
|
||||
geometry_type* line = new geometry_type(mapnik::LineString);
|
||||
start = parts[k];
|
||||
if (k == num_parts - 1)
|
||||
{
|
||||
|
@ -179,11 +179,11 @@ void shape_io::read_polygon(mapnik::geometry_container & geom)
|
|||
{
|
||||
shape_file::record_type record(reclength_ * 2 - 36);
|
||||
shp_.read_record(record);
|
||||
|
||||
|
||||
int num_parts = record.read_ndr_integer();
|
||||
int num_points = record.read_ndr_integer();
|
||||
std::vector<int> parts(num_parts);
|
||||
|
||||
|
||||
for (int i = 0; i < num_parts; ++i)
|
||||
{
|
||||
parts[i] = record.read_ndr_integer();
|
||||
|
|
Loading…
Reference in a new issue