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