code formatting

This commit is contained in:
Dane Springmeyer 2011-11-13 19:54:32 -08:00
parent 01bd36623c
commit 4654312d00
55 changed files with 1072 additions and 1072 deletions

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -40,7 +40,7 @@ struct color_pickle_suite : boost::python::pickle_suite
}
};
void export_color ()
void export_color ()
{
using namespace boost::python;
class_<color>("Color", init<int,int,int,int>(

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -42,7 +42,7 @@ struct coord_pickle_suite : boost::python::pickle_suite
void export_coord()
{
using namespace boost::python;
class_<coord<double,2> >("Coord",init<double, double>(
class_<coord<double,2> >("Coord",init<double, double>(
// class docstring is in mapnik/__init__.py, class _Coord
(arg("x"), arg("y")),
"Constructs a new point with the given coordinates.\n")
@ -59,7 +59,7 @@ void export_coord()
.def(self - self) // __sub__
.def(self - float())
.def(self * float()) //__mult__
.def(float() * self)
.def(float() * self)
.def(self / float()) // __div__
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -41,7 +41,7 @@ using mapnik::memory_datasource;
using mapnik::layer_descriptor;
using mapnik::attribute_descriptor;
namespace
namespace
{
//user-friendly wrapper that uses Python dictionary
using namespace boost::python;
@ -54,17 +54,17 @@ boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
{
std::string key = extract<std::string>(keys[i]);
object obj = d[key];
if (key == "bind")
{
bind = extract<bool>(obj)();
continue;
}
extract<std::string> ex0(obj);
extract<int> ex1(obj);
extract<double> ex2(obj);
if (ex0.check())
{
params[key] = ex0();
@ -78,10 +78,10 @@ boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
params[key] = ex2();
}
}
return mapnik::datasource_cache::create(params, bind);
}
std::string describe(boost::shared_ptr<mapnik::datasource> const& ds)
{
std::stringstream ss;
@ -95,7 +95,7 @@ std::string describe(boost::shared_ptr<mapnik::datasource> const& ds)
}
return ss.str();
}
std::string encoding(boost::shared_ptr<mapnik::datasource> const& ds)
{
layer_descriptor ld = ds->get_descriptor();
@ -134,7 +134,7 @@ boost::python::list field_types(boost::shared_ptr<mapnik::datasource> const& ds)
std::vector<attribute_descriptor>::const_iterator it = desc_ar.begin();
std::vector<attribute_descriptor>::const_iterator end = desc_ar.end();
for (; it != end; ++it)
{
{
unsigned type = it->get_type();
if (type == mapnik::Integer)
// this crashes, so send back strings instead
@ -162,7 +162,7 @@ boost::python::list field_types(boost::shared_ptr<mapnik::datasource> const& ds)
void export_datasource()
{
using namespace boost::python;
class_<datasource,boost::shared_ptr<datasource>,
boost::noncopyable>("Datasource",no_init)
.def("envelope",&datasource::envelope)
@ -174,11 +174,11 @@ void export_datasource()
.def("encoding",&encoding) //todo expose as property
.def("name",&name)
.def("features_at_point",&datasource::features_at_point)
.def("params",&datasource::params,return_value_policy<copy_const_reference>(),
"The configuration parameters of the data source. "
.def("params",&datasource::params,return_value_policy<copy_const_reference>(),
"The configuration parameters of the data source. "
"These vary depending on the type of data source.")
;
def("Describe",&describe);
def("CreateDatasource",&create_datasource);

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -36,7 +36,7 @@ void export_datasource_cache()
return_value_policy<reference_existing_object>())
.staticmethod("instance")
;
class_<datasource_cache,bases<singleton<datasource_cache,CreateStatic> >,
boost::noncopyable>("DatasourceCache",no_init)
.def("create",&datasource_cache::create)
@ -44,6 +44,6 @@ void export_datasource_cache()
.def("register_datasources",&datasource_cache::register_datasources)
.staticmethod("register_datasources")
.def("plugin_names",&datasource_cache::plugin_names)
.staticmethod("plugin_names")
.staticmethod("plugin_names")
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -26,7 +26,7 @@ namespace mapnik {
template <typename EnumWrapper>
class enumeration_ :
public boost::python::enum_<typename EnumWrapper::native_type>
public boost::python::enum_<typename EnumWrapper::native_type>
{
// some short cuts
typedef boost::python::enum_<typename EnumWrapper::native_type> base_type;
@ -46,7 +46,7 @@ public:
enumeration_(const char * python_alias, const char * doc) :
base_type( python_alias, doc )
#else
enumeration_(const char * python_alias, const char * /*doc*/) :
enumeration_(const char * python_alias, const char * /*doc*/) :
// Boost.Python < 1.35.0 doesn't support
// docstrings for enums so we ignore it.
base_type( python_alias )

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -102,13 +102,13 @@ void export_envelope()
"Equivalent to Box2d(ll.x, ll.y, ur.x, ur.y).\n"))
.def("from_string",from_string)
.staticmethod("from_string")
.add_property("minx", &box2d<double>::minx,
.add_property("minx", &box2d<double>::minx,
"X coordinate for the lower left corner")
.add_property("miny", &box2d<double>::miny,
.add_property("miny", &box2d<double>::miny,
"Y coordinate for the lower left corner")
.add_property("maxx", &box2d<double>::maxx,
"X coordinate for the upper right corner")
.add_property("maxy", &box2d<double>::maxy,
.add_property("maxy", &box2d<double>::maxy,
"Y coordinate for the upper right corner")
.def("center", &box2d<double>::center,
"Returns the coordinates of the center of the bounding box.\n"
@ -259,13 +259,13 @@ void export_envelope()
">>> e1 = Box2d(0, 0, 100, 100)\n"
">>> e2 = Box2d(50, 50, 150, 150)\n"
">>> e1.intersect(e2)\n"
"Box2d(50.0, 50.0, 100.0, 100.0)\n"
"Box2d(50.0, 50.0, 100.0, 100.0)\n"
)
.def(self == self) // __eq__
.def(self != self) // __neq__
.def(self + self) // __add__
.def(self * float()) // __mult__
.def(float() * self)
.def(float() * self)
.def(self / float()) // __div__
.def("__getitem__",&box2d<double>::operator[])
.def("valid",&box2d<double>::valid)

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -76,7 +76,7 @@ void export_expression()
.def("evaluate", &expression_evaluate_)
.def("__str__",&to_expression_string);
;
def("Expression",&parse_expression_,(arg("expr")),"Expression string");
class_<mapnik::path_expression ,boost::noncopyable>("PathExpression",
@ -85,6 +85,6 @@ void export_expression()
.def("evaluate", &path_evaluate_) // note: "pass" is a reserved word in Python
.def("__str__",&path_to_string_);
;
def("PathExpression",&parse_path_,(arg("expr")),"PathExpression string");
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -70,7 +70,7 @@ namespace boost { namespace python {
: public map_indexing_suite2<Container,
NoProxy, final_map_derived_policies<Container, NoProxy> > {};
}
template <class Container,bool NoProxy = false,
class DerivedPolicies = detail::final_map_derived_policies<Container, NoProxy> >
class map_indexing_suite2
@ -97,7 +97,7 @@ namespace boost { namespace python {
static void
extension_def(Class& /*cl*/)
{
}
static data_type&
@ -111,37 +111,37 @@ namespace boost { namespace python {
}
return i->second;
}
static void
set_item(Container& container, index_type i, data_type const& v)
{
container[i] = v;
}
static void
delete_item(Container& container, index_type i)
{
container.props().erase(i);
}
static size_t
size(Container& container)
{
return container.props().size();
}
static bool
contains(Container& container, key_type const& key)
{
return container.props().find(key) != container.end();
}
static bool
compare_index(Container& container, index_type a, index_type b)
{
return container.props().key_comp()(a, b);
}
static index_type
convert_index(Container& /*container*/, PyObject* i_)
{
@ -156,13 +156,13 @@ namespace boost { namespace python {
if (i.check())
return i();
}
PyErr_SetString(PyExc_TypeError, "Invalid index type");
throw_error_already_set();
return index_type();
}
};
template <typename T1, typename T2>
struct std_pair_to_tuple
@ -173,7 +173,7 @@ namespace boost { namespace python {
boost::python::make_tuple(p.first, p.second).ptr());
}
};
template <typename T1, typename T2>
struct std_pair_to_python_converter
{
@ -201,9 +201,9 @@ struct UnicodeString_from_python_str
{
if (!(
#if PY_VERSION_HEX >= 0x03000000
PyBytes_Check(obj_ptr)
PyBytes_Check(obj_ptr)
#else
PyString_Check(obj_ptr)
PyString_Check(obj_ptr)
#endif
|| PyUnicode_Check(obj_ptr)))
return 0;
@ -245,7 +245,7 @@ void export_feature()
{
using namespace boost::python;
using mapnik::Feature;
implicitly_convertible<int,mapnik::value>();
implicitly_convertible<double,mapnik::value>();
implicitly_convertible<UnicodeString,mapnik::value>();
@ -253,7 +253,7 @@ void export_feature()
std_pair_to_python_converter<std::string const,mapnik::value>();
UnicodeString_from_python_str();
class_<Feature,boost::shared_ptr<Feature>,
boost::noncopyable>("Feature",init<int>("Default ctor."))
.def("id",&Feature::id)

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -65,21 +65,21 @@ void export_featureset()
using namespace boost::python;
using mapnik::Feature;
using mapnik::Featureset;
class_<Featureset,boost::shared_ptr<Featureset>,
boost::noncopyable>("Featureset",no_init)
.def("__iter__",pass_through)
.def("next",next)
.add_property("features",features,
"The list of features.\n"
"\n"
"Usage:\n"
">>> m.query_map_point(0, 10, 10)\n"
"<mapnik2._mapnik2.Featureset object at 0x1004d2938>\n"
">>> fs = m.query_map_point(0, 10, 10)\n"
">>> for f in fs.features:\n"
">>> print f\n"
"<mapnik2.Feature object at 0x105e64140>\n"
"The list of features.\n"
"\n"
"Usage:\n"
">>> m.query_map_point(0, 10, 10)\n"
"<mapnik2._mapnik2.Featureset object at 0x1004d2938>\n"
">>> fs = m.query_map_point(0, 10, 10)\n"
">>> for f in fs.features:\n"
">>> print f\n"
"<mapnik2.Feature object at 0x105e64140>\n"
)
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* This library is free software; you can redistribute it and/or
@ -63,7 +63,7 @@ void from_wkb_impl(path_type& p, std::string const& wkb)
void export_geometry()
{
using namespace boost::python;
enum_<mapnik::eGeomType>("GeometryType")
.value("Point",mapnik::Point)
.value("LineString",mapnik::LineString)
@ -72,7 +72,7 @@ void export_geometry()
.value("MultiLineString",mapnik::MultiLineString)
.value("MultiPolygon",mapnik::MultiPolygon)
;
using mapnik::geometry_type;
class_<geometry_type, std::auto_ptr<geometry_type>,boost::noncopyable>("Geometry2d",no_init)
.def("envelope",&geometry_type::envelope)
@ -80,12 +80,12 @@ void export_geometry()
.def("type",&geometry_type::type)
// TODO add other geometry_type methods
;
class_<path_type,boost::noncopyable>("Path")
.def("__getitem__", getitem_impl,return_value_policy<reference_existing_object>())
.def("__len__", &path_type::size)
.def("from_wkt",from_wkt_impl)
.def("from_wkb",from_wkb_impl)
;
}

View file

@ -73,7 +73,7 @@ void export_glyph_symbolizer()
&glyph_symbolizer::set_halo_fill)
.add_property("halo_radius",
&glyph_symbolizer::get_halo_radius,
&glyph_symbolizer::get_halo_radius,
&glyph_symbolizer::set_halo_radius)
.add_property("size",
@ -117,5 +117,5 @@ void export_glyph_symbolizer()
"defined).\n"
"Only needed if no explicit color is provided"
)
;
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -43,10 +43,10 @@ bool painted(mapnik::grid const& grid)
void export_grid()
{
class_<mapnik::grid,boost::shared_ptr<mapnik::grid> >(
"Grid",
"This class represents a feature hitgrid.",
init<int,int,std::string,unsigned>(
( boost::python::arg("width"), boost::python::arg("height"),boost::python::arg("key")="__id__", boost::python::arg("resolution")=1 ),
"Grid",
"This class represents a feature hitgrid.",
init<int,int,std::string,unsigned>(
( boost::python::arg("width"), boost::python::arg("height"),boost::python::arg("key")="__id__", boost::python::arg("resolution")=1 ),
"Create a mapnik.Grid object\n"
))
.def("painted",&painted)
@ -54,16 +54,16 @@ void export_grid()
.def("height",&mapnik::grid::height)
.def("view",&mapnik::grid::get_view)
.def("encode",encode,
( boost::python::arg("encoding")="utf", boost::python::arg("features")=true,boost::python::arg("resolution")=4 ),
"Encode the grid as as optimized json\n"
( boost::python::arg("encoding")="utf", boost::python::arg("features")=true,boost::python::arg("resolution")=4 ),
"Encode the grid as as optimized json\n"
)
.add_property("key",
make_function(&mapnik::grid::get_key,return_value_policy<copy_const_reference>()),
&mapnik::grid::set_key,
"Get/Set key to be used as unique indentifier for features\n"
"The value should either be __id__ to refer to the feature.id()\n"
"or some globally unique integer or string attribute field\n"
)
make_function(&mapnik::grid::get_key,return_value_policy<copy_const_reference>()),
&mapnik::grid::set_key,
"Get/Set key to be used as unique indentifier for features\n"
"The value should either be __id__ to refer to the feature.id()\n"
"or some globally unique integer or string attribute field\n"
)
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -40,13 +40,13 @@ static dict (*encode)( mapnik::grid_view const&, std::string, bool, unsigned int
void export_grid_view()
{
class_<mapnik::grid_view,
boost::shared_ptr<mapnik::grid_view> >("GridView",
"This class represents a feature hitgrid subset.",no_init)
boost::shared_ptr<mapnik::grid_view> >("GridView",
"This class represents a feature hitgrid subset.",no_init)
.def("width",&mapnik::grid_view::width)
.def("height",&mapnik::grid_view::height)
.def("encode",encode,
( boost::python::arg("encoding")="utf",boost::python::arg("add_features")=true,boost::python::arg("resolution")=4 ),
"Encode the grid as as optimized json\n"
( boost::python::arg("encoding")="utf",boost::python::arg("add_features")=true,boost::python::arg("resolution")=4 ),
"Encode the grid as as optimized json\n"
)
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -68,7 +68,7 @@ PyObject* tostring1( image_32 const& im)
{
int size = im.width() * im.height() * 4;
return
#if PY_VERSION_HEX >= 0x03000000
#if PY_VERSION_HEX >= 0x03000000
::PyBytes_FromStringAndSize
#else
::PyString_FromStringAndSize
@ -81,24 +81,24 @@ PyObject* tostring2(image_32 const & im, std::string const& format)
{
std::string s = save_to_string(im, format);
return
#if PY_VERSION_HEX >= 0x03000000
#if PY_VERSION_HEX >= 0x03000000
::PyBytes_FromStringAndSize
#else
::PyString_FromStringAndSize
#endif
(s.data(),s.size());
(s.data(),s.size());
}
PyObject* tostring3(image_32 const & im, std::string const& format, mapnik::rgba_palette const& pal)
{
std::string s = save_to_string(im, format, pal);
return
#if PY_VERSION_HEX >= 0x03000000
#if PY_VERSION_HEX >= 0x03000000
::PyBytes_FromStringAndSize
#else
::PyString_FromStringAndSize
#endif
(s.data(),s.size());
(s.data(),s.size());
}
@ -131,16 +131,16 @@ boost::shared_ptr<image_32> open_from_file(std::string const& filename)
std::auto_ptr<image_reader> reader(get_image_reader(filename,*type));
if (reader.get())
{
boost::shared_ptr<image_32> image_ptr = boost::make_shared<image_32>(reader->width(),reader->height());
reader->read(0,0,image_ptr->data());
return image_ptr;
}
throw mapnik::image_reader_exception("Failed to load: " + filename);
throw mapnik::image_reader_exception("Failed to load: " + filename);
}
throw mapnik::image_reader_exception("Unsupported image format:" + filename);
}
void blend (image_32 & im, unsigned x, unsigned y, image_32 const& im2, float opacity)
{
im.set_rectangle_alpha2(im2.data(),x,y,opacity);
@ -169,7 +169,7 @@ void export_image()
.value("src", mapnik::src)
.value("dst", mapnik::dst)
.value("src_over", mapnik::src_over)
.value("dst_over", mapnik::dst_over)
.value("dst_over", mapnik::dst_over)
.value("src_in", mapnik::src_in)
.value("dst_in", mapnik::dst_in)
.value("src_out", mapnik::src_out)
@ -194,7 +194,7 @@ void export_image()
.value("invert", mapnik::invert)
.value("invert_rgb", mapnik::invert_rgb)
;
class_<image_32,boost::shared_ptr<image_32> >("Image","This class represents a 32 bit RGBA image.",init<int,int>())
.def("width",&image_32::width)
.def("height",&image_32::height)
@ -209,7 +209,7 @@ void export_image()
.def("blend",&blend)
.def("composite",&composite)
//TODO(haoyu) The method name 'tostring' might be confusing since they actually return bytes in Python 3
.def("tostring",&tostring1)
.def("tostring",&tostring2)
.def("tostring",&tostring3)
@ -222,6 +222,6 @@ void export_image()
.def("from_cairo",&from_cairo)
.staticmethod("from_cairo")
#endif
;
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -48,10 +48,10 @@ PyObject* view_tostring1(image_view<image_data_32> const& view)
std::ostringstream ss(std::ios::out|std::ios::binary);
for (unsigned i=0;i<view.height();i++)
{
ss.write(reinterpret_cast<const char*>(view.getRow(i)),
ss.write(reinterpret_cast<const char*>(view.getRow(i)),
view.width() * sizeof(image_view<image_data_32>::pixel_type));
}
return
return
#if PY_VERSION_HEX >= 0x03000000
::PyBytes_FromStringAndSize
#else
@ -64,7 +64,7 @@ PyObject* view_tostring1(image_view<image_data_32> const& view)
PyObject* view_tostring2(image_view<image_data_32> const & view, std::string const& format)
{
std::string s = save_to_string(view, format);
return
return
#if PY_VERSION_HEX >= 0x03000000
::PyBytes_FromStringAndSize
#else
@ -76,7 +76,7 @@ PyObject* view_tostring2(image_view<image_data_32> const & view, std::string con
PyObject* view_tostring3(image_view<image_data_32> const & view, std::string const& format, mapnik::rgba_palette const& pal)
{
std::string s = save_to_string(view, format, pal);
return
return
#if PY_VERSION_HEX >= 0x03000000
::PyBytes_FromStringAndSize
#else
@ -85,22 +85,22 @@ PyObject* view_tostring3(image_view<image_data_32> const & view, std::string con
(s.data(),s.size());
}
void save_view1(image_view<image_data_32> const& view,
void save_view1(image_view<image_data_32> const& view,
std::string const& filename)
{
save_to_file(view,filename);
}
void save_view2(image_view<image_data_32> const& view,
std::string const& filename,
void save_view2(image_view<image_data_32> const& view,
std::string const& filename,
std::string const& type)
{
save_to_file(view,filename,type);
}
void save_view3(image_view<image_data_32> const& view,
std::string const& filename,
std::string const& type,
void save_view3(image_view<image_data_32> const& view,
std::string const& filename,
std::string const& type,
mapnik::rgba_palette const& pal)
{
save_to_file(view,filename,type,pal);

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -33,36 +33,36 @@ using mapnik::metawriter_inmem;
using mapnik::metawriter_inmem_ptr;
namespace {
std::map<std::string, mapnik::value>::const_iterator
std::map<std::string, mapnik::value>::const_iterator
mapnik_value_map_begin(const std::map<std::string, mapnik::value> &m) {
return m.begin();
}
std::map<std::string, mapnik::value>::const_iterator
std::map<std::string, mapnik::value>::const_iterator
mapnik_value_map_end(const std::map<std::string, mapnik::value> &m) {
return m.end();
return m.end();
}
}
void export_inmem_metawriter() {
using namespace boost::python;
using namespace boost::python;
class_<std::map<std::string, mapnik::value> >
("MapnikProperties", "Retarded.", init<>())
.def("__iter__", range(&mapnik_value_map_begin, &mapnik_value_map_end))
;
class_<std::map<std::string, mapnik::value> >
("MapnikProperties", "Retarded.", init<>())
.def("__iter__", range(&mapnik_value_map_begin, &mapnik_value_map_end))
;
class_<metawriter_inmem::meta_instance>
("MetaInstance", "Single rendered instance of meta-information.", no_init)
.def_readonly("box", &metawriter_inmem::meta_instance::box)
.def_readonly("properties", &metawriter_inmem::meta_instance::properties)
;
class_<metawriter_inmem::meta_instance>
("MetaInstance", "Single rendered instance of meta-information.", no_init)
.def_readonly("box", &metawriter_inmem::meta_instance::box)
.def_readonly("properties", &metawriter_inmem::meta_instance::properties)
;
class_<metawriter_inmem, metawriter_inmem_ptr, boost::noncopyable>
("MetaWriterInMem",
"Collects meta-information about elements rendered.",
no_init)
.def("__iter__", range(&metawriter_inmem::inst_begin,
&metawriter_inmem::inst_end))
;
class_<metawriter_inmem, metawriter_inmem_ptr, boost::noncopyable>
("MetaWriterInMem",
"Collects meta-information about elements rendered.",
no_init)
.def("__iter__", range(&metawriter_inmem::inst_begin,
&metawriter_inmem::inst_end))
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -38,86 +38,86 @@ using boost::make_shared;
namespace
{
boost::shared_ptr<label_collision_detector4>
boost::shared_ptr<label_collision_detector4>
create_label_collision_detector_from_extent(box2d<double> const &extent)
{
return make_shared<label_collision_detector4>(extent);
return make_shared<label_collision_detector4>(extent);
}
boost::shared_ptr<label_collision_detector4>
boost::shared_ptr<label_collision_detector4>
create_label_collision_detector_from_map(Map const &m)
{
double buffer = m.buffer_size();
box2d<double> extent(-buffer, -buffer, m.width() + buffer, m.height() + buffer);
return make_shared<label_collision_detector4>(extent);
double buffer = m.buffer_size();
box2d<double> extent(-buffer, -buffer, m.width() + buffer, m.height() + buffer);
return make_shared<label_collision_detector4>(extent);
}
boost::python::list
make_label_boxes(boost::shared_ptr<label_collision_detector4> det)
make_label_boxes(boost::shared_ptr<label_collision_detector4> det)
{
boost::python::list boxes;
boost::python::list boxes;
for (label_collision_detector4::query_iterator jtr = det->begin();
jtr != det->end(); ++jtr)
{
boxes.append<box2d<double> >(jtr->box);
}
for (label_collision_detector4::query_iterator jtr = det->begin();
jtr != det->end(); ++jtr)
{
boxes.append<box2d<double> >(jtr->box);
}
return boxes;
return boxes;
}
}
void export_label_collision_detector()
void export_label_collision_detector()
{
using namespace boost::python;
// for overload resolution
void (label_collision_detector4::*insert_box)(box2d<double> const &) = &label_collision_detector4::insert;
using namespace boost::python;
class_<label_collision_detector4, boost::shared_ptr<label_collision_detector4>, boost::noncopyable>
("LabelCollisionDetector",
"Object to detect collisions between labels, used in the rendering process.",
no_init)
// for overload resolution
void (label_collision_detector4::*insert_box)(box2d<double> const &) = &label_collision_detector4::insert;
.def("__init__", make_constructor(create_label_collision_detector_from_extent),
"Creates an empty collision detection object with a given extent. Note "
"that the constructor from Map objects is a sensible default and usually "
"what you want to do.\n"
"\n"
"Example:\n"
">>> m = Map(size_x, size_y)\n"
">>> buf_sz = m.buffer_size\n"
">>> extent = mapnik.Box2d(-buf_sz, -buf_sz, m.width + buf_sz, m.height + buf_sz)\n"
">>> detector = mapnik.LabelCollisionDetector(extent)")
class_<label_collision_detector4, boost::shared_ptr<label_collision_detector4>, boost::noncopyable>
("LabelCollisionDetector",
"Object to detect collisions between labels, used in the rendering process.",
no_init)
.def("__init__", make_constructor(create_label_collision_detector_from_map),
"Creates an empty collision detection object matching the given Map object. "
"The created detector will have the same size, including the buffer, as the "
"map object. This is usually what you want to do.\n"
"\n"
"Example:\n"
">>> m = Map(size_x, size_y)\n"
">>> detector = mapnik.LabelCollisionDetector(m)")
.def("__init__", make_constructor(create_label_collision_detector_from_extent),
"Creates an empty collision detection object with a given extent. Note "
"that the constructor from Map objects is a sensible default and usually "
"what you want to do.\n"
"\n"
"Example:\n"
">>> m = Map(size_x, size_y)\n"
">>> buf_sz = m.buffer_size\n"
">>> extent = mapnik.Box2d(-buf_sz, -buf_sz, m.width + buf_sz, m.height + buf_sz)\n"
">>> detector = mapnik.LabelCollisionDetector(extent)")
.def("extent", &label_collision_detector4::extent, return_value_policy<copy_const_reference>(),
"Returns the total extent (bounding box) of all labels inside the detector.\n"
"\n"
"Example:\n"
">>> detector.extent()\n"
"Box2d(573.252589209,494.789179821,584.261023823,496.83610261)")
.def("__init__", make_constructor(create_label_collision_detector_from_map),
"Creates an empty collision detection object matching the given Map object. "
"The created detector will have the same size, including the buffer, as the "
"map object. This is usually what you want to do.\n"
"\n"
"Example:\n"
">>> m = Map(size_x, size_y)\n"
">>> detector = mapnik.LabelCollisionDetector(m)")
.def("boxes", &make_label_boxes,
"Returns a list of all the label boxes inside the detector.")
.def("extent", &label_collision_detector4::extent, return_value_policy<copy_const_reference>(),
"Returns the total extent (bounding box) of all labels inside the detector.\n"
"\n"
"Example:\n"
">>> detector.extent()\n"
"Box2d(573.252589209,494.789179821,584.261023823,496.83610261)")
.def("insert", insert_box,
"Insert a 2d box into the collision detector. This can be used to ensure that "
"some space is left clear on the map for later overdrawing, for example by "
"non-Mapnik processes.\n"
"\n"
"Example:\n"
">>> m = Map(size_x, size_y)\n"
">>> detector = mapnik.LabelCollisionDetector(m)"
">>> detector.insert(mapnik.Box2d(196, 254, 291, 389))")
;
.def("boxes", &make_label_boxes,
"Returns a list of all the label boxes inside the detector.")
.def("insert", insert_box,
"Insert a 2d box into the collision detector. This can be used to ensure that "
"some space is left clear on the map for later overdrawing, for example by "
"non-Mapnik processes.\n"
"\n"
"Example:\n"
">>> m = Map(size_x, size_y)\n"
">>> detector = mapnik.LabelCollisionDetector(m)"
">>> detector.insert(mapnik.Box2d(196, 254, 291, 389))")
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -53,7 +53,7 @@ struct layer_pickle_suite : boost::python::pickle_suite
for (unsigned i = 0; i < style_names.size(); ++i)
{
s.append(style_names[i]);
}
}
return boost::python::make_tuple(l.abstract(),l.title(),l.clear_label_cache(),l.getMinZoom(),l.getMaxZoom(),l.isQueryable(),l.datasource()->params(),l.cache_features(),s);
}
@ -84,7 +84,7 @@ struct layer_pickle_suite : boost::python::pickle_suite
mapnik::parameters params = extract<parameters>(state[6]);
l.set_datasource(datasource_cache::instance()->create(params));
boost::python::list s = extract<boost::python::list>(state[7]);
for (int i=0;i<len(s);++i)
{
@ -103,7 +103,7 @@ void export_layer()
class_<std::vector<std::string> >("Names")
.def(vector_indexing_suite<std::vector<std::string>,true >())
;
class_<layer>("Layer", "A Mapnik map layer.", init<std::string const&,optional<std::string const&> >(
"Create a Layer with a named string and, optionally, an srs string.\n"
"\n"
@ -119,8 +119,8 @@ void export_layer()
))
.def_pickle(layer_pickle_suite())
.def("envelope",&layer::envelope,
.def("envelope",&layer::envelope,
"Return the geographic envelope/bounding box."
"\n"
"Determined based on the layer datasource.\n"
@ -131,7 +131,7 @@ void export_layer()
">>> lyr.envelope()\n"
"box2d(-1.0,-1.0,0.0,0.0) # default until a datasource is loaded\n"
)
.def("visible", &layer::isVisible,
"Return True if this layer's data is active and visible at a given scale.\n"
"\n"
@ -151,8 +151,8 @@ void export_layer()
">>> lyr.visible(1.0/1000000)\n"
"False\n"
)
.add_property("abstract",
.add_property("abstract",
make_function(&layer::abstract,return_value_policy<copy_const_reference>()),
&layer::set_abstract,
"Get/Set the abstract of the layer.\n"
@ -181,7 +181,7 @@ void export_layer()
">>> lyr.active\n"
"False\n"
)
.add_property("clear_label_cache",
&layer::clear_label_cache,
&layer::set_clear_label_cache,
@ -190,7 +190,7 @@ void export_layer()
"Usage:\n"
">>> lyr.clear_label_cache\n"
"False # False by default, meaning label positions from other layers will impact placement \n"
">>> lyr.clear_label_cache = True # set to True to clear the label collision detector cache\n"
">>> lyr.clear_label_cache = True # set to True to clear the label collision detector cache\n"
)
.add_property("cache_features",
@ -201,9 +201,9 @@ void export_layer()
"Usage:\n"
">>> lyr.cache_features\n"
"False # False by default\n"
">>> lyr.cache_features = True # set to True to enable feature caching\n"
">>> lyr.cache_features = True # set to True to enable feature caching\n"
)
.add_property("datasource",
&layer::datasource,
&layer::set_datasource,
@ -231,7 +231,7 @@ void export_layer()
">>> lyr.maxzoom\n"
"9.9999999999999995e-07\n"
)
.add_property("minzoom",
&layer::getMinZoom,
&layer::setMinZoom,
@ -245,9 +245,9 @@ void export_layer()
">>> lyr.minzoom = 1.0/1000000\n"
">>> lyr.minzoom\n"
"9.9999999999999995e-07\n"
)
)
.add_property("name",
.add_property("name",
make_function(&layer::name, return_value_policy<copy_const_reference>()),
&layer::set_name,
"Get/Set the name of the layer.\n"
@ -277,7 +277,7 @@ void export_layer()
"True\n"
)
.add_property("srs",
.add_property("srs",
make_function(&layer::srs,return_value_policy<copy_const_reference>()),
&layer::set_srs,
"Get/Set the SRS of the layer.\n"
@ -309,7 +309,7 @@ void export_layer()
">>> lyr.styles[0]\n"
"'My Style'\n"
)
.add_property("title",
make_function(&layer::title, return_value_policy<copy_const_reference>()),
&layer::set_title,
@ -324,6 +324,6 @@ void export_layer()
">>> lyr.title\n"
"'My first layer'\n"
)
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -38,14 +38,14 @@ using mapnik::parse_path;
namespace {
using namespace boost::python;
const std::string get_filename(line_pattern_symbolizer const& t)
{
return path_processor_type::to_string(*t.get_filename());
const std::string get_filename(line_pattern_symbolizer const& t)
{
return path_processor_type::to_string(*t.get_filename());
}
void set_filename(line_pattern_symbolizer & t, std::string const& file_expr)
{
t.set_filename(parse_path(file_expr));
void set_filename(line_pattern_symbolizer & t, std::string const& file_expr)
{
t.set_filename(parse_path(file_expr));
}
}
@ -56,7 +56,7 @@ struct line_pattern_symbolizer_pickle_suite : boost::python::pickle_suite
getinitargs(const line_pattern_symbolizer& l)
{
std::string filename = path_processor_type::to_string(*l.get_filename());
// FIXME : Do we need "type" parameter at all ?
// FIXME : Do we need "type" parameter at all ?
return boost::python::make_tuple(filename, guess_type(filename));
}
};
@ -64,16 +64,16 @@ struct line_pattern_symbolizer_pickle_suite : boost::python::pickle_suite
void export_line_pattern_symbolizer()
{
using namespace boost::python;
class_<line_pattern_symbolizer>("LinePatternSymbolizer",
init<path_expression_ptr>
("<image file expression>"))
//.def_pickle(line_pattern_symbolizer_pickle_suite())
.add_property("transform",
mapnik::get_svg_transform<line_pattern_symbolizer>,
mapnik::set_svg_transform<line_pattern_symbolizer>)
mapnik::get_svg_transform<line_pattern_symbolizer>,
mapnik::set_svg_transform<line_pattern_symbolizer>)
.add_property("filename",
&get_filename,
&set_filename)
;
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -43,7 +43,7 @@ struct line_symbolizer_pickle_suite : boost::python::pickle_suite
void export_line_symbolizer()
{
using namespace boost::python;
enumeration_<line_rasterizer_e>("line_rasterizer")
.value("FULL",RASTERIZER_FULL)
.value("FAST",RASTERIZER_FAST)
@ -62,5 +62,5 @@ void export_line_symbolizer()
(&line_symbolizer::get_stroke,
return_value_policy<copy_const_reference>()),
&line_symbolizer::set_stroke)
;
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -57,7 +57,7 @@ struct map_pickle_suite : boost::python::pickle_suite
{
l.append(m.getLayer(i));
}
boost::python::list s;
Map::const_style_iterator it = m.styles().begin();
Map::const_style_iterator end = m.styles().end();
@ -91,14 +91,14 @@ struct map_pickle_suite : boost::python::pickle_suite
{
color bg = extract<color>(state[1]);
m.set_background(bg);
}
}
boost::python::list l=extract<boost::python::list>(state[2]);
for (int i=0;i<len(l);++i)
{
m.addLayer(extract<layer>(l[i]));
}
boost::python::list s=extract<boost::python::list>(state[3]);
for (int i=0;i<len(s);++i)
{
@ -112,7 +112,7 @@ struct map_pickle_suite : boost::python::pickle_suite
{
std::string base_path = extract<std::string>(state[4]);
m.set_base_path(base_path);
}
}
}
};
@ -138,17 +138,17 @@ bool has_metawriter(mapnik::Map const& m)
return false;
}
// returns empty shared_ptr when the metawriter isn't found, or is
// returns empty shared_ptr when the metawriter isn't found, or is
// of the wrong type. empty pointers make it back to Python as a None.
mapnik::metawriter_inmem_ptr find_inmem_metawriter(const mapnik::Map &m, const std::string &name) {
mapnik::metawriter_ptr metawriter = m.find_metawriter(name);
mapnik::metawriter_inmem_ptr inmem;
mapnik::metawriter_ptr metawriter = m.find_metawriter(name);
mapnik::metawriter_inmem_ptr inmem;
if (metawriter) {
inmem = boost::dynamic_pointer_cast<mapnik::metawriter_inmem>(metawriter);
}
return inmem;
if (metawriter) {
inmem = boost::dynamic_pointer_cast<mapnik::metawriter_inmem>(metawriter);
}
return inmem;
}
// TODO - we likely should allow indexing by negative number from python
@ -157,7 +157,7 @@ mapnik::featureset_ptr query_point(mapnik::Map const& m, int index, double x, do
{
if (index < 0){
PyErr_SetString(PyExc_IndexError, "Please provide a layer index >= 0");
boost::python::throw_error_already_set();
boost::python::throw_error_already_set();
}
unsigned idx = index;
return m.query_point(idx, x, y);
@ -167,16 +167,16 @@ mapnik::featureset_ptr query_map_point(mapnik::Map const& m, int index, double x
{
if (index < 0){
PyErr_SetString(PyExc_IndexError, "Please provide a layer index >= 0");
boost::python::throw_error_already_set();
boost::python::throw_error_already_set();
}
unsigned idx = index;
return m.query_map_point(idx, x, y);
}
void export_map()
void export_map()
{
using namespace boost::python;
// aspect ratio fix modes
mapnik::enumeration_<mapnik::aspect_fix_mode_e>("aspect_fix_mode")
.value("GROW_BBOX", mapnik::Map::GROW_BBOX)
@ -188,12 +188,12 @@ void export_map()
.value("ADJUST_CANVAS_WIDTH",mapnik::Map::ADJUST_CANVAS_WIDTH)
.value("ADJUST_CANVAS_HEIGHT", mapnik::Map::ADJUST_CANVAS_HEIGHT)
;
python_optional<mapnik::color> ();
class_<std::vector<layer> >("Layers")
.def(vector_indexing_suite<std::vector<layer> >())
;
class_<Map>("Map","The map object.",init<int,int,optional<std::string const&> >(
( arg("width"),arg("height"),arg("srs") ),
"Create a Map with a width and height as integers and, optionally,\n"
@ -209,10 +209,10 @@ void export_map()
">>> m.srs\n"
"'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'\n"
))
.def_pickle(map_pickle_suite()
)
.def("append_style",&Map::insert_style,
(arg("style_name"),arg("style_object")),
"Insert a Mapnik Style onto the map by appending it.\n"
@ -278,7 +278,7 @@ void export_map()
">>> m.has_metawriter()\n"
"False\n"
)
.def("pan",&Map::pan,
(arg("x"),arg("y")),
"Set the Map center at a given x,y location\n"
@ -292,7 +292,7 @@ void export_map()
">>> m.envelope().center()\n"
"Coord(0.00166666666667,-0.835)\n"
)
.def("pan_and_zoom",&Map::pan_and_zoom,
(arg("x"),arg("y"),arg("factor")),
"Set the Map center at a given x,y location\n"
@ -308,7 +308,7 @@ void export_map()
">>> m.scale()\n"
"0.00062500000000000001\n"
)
.def("query_map_point",query_map_point,
(arg("layer_idx"),arg("pixel_x"),arg("pixel_y")),
"Query a Map Layer (by layer index) for features \n"
@ -325,7 +325,7 @@ void export_map()
">>> featureset.features\n"
">>> [<mapnik.Feature object at 0x3995630>]\n"
)
.def("query_point",query_point,
(arg("layer idx"),arg("x"),arg("y")),
"Query a Map Layer (by layer index) for features \n"
@ -349,7 +349,7 @@ void export_map()
"Usage:\n"
">>> m.remove_all()\n"
)
.def("remove_style",&Map::remove_style,
(arg("style_name")),
"Remove a Mapnik Style from the map.\n"
@ -365,7 +365,7 @@ void export_map()
"Usage:\n"
">>> m.resize(64,64)\n"
)
.def("scale", &Map::scale,
"Return the Map Scale.\n"
"Usage:\n"
@ -379,16 +379,16 @@ void export_map()
"\n"
">>> m.scale_denominator()\n"
)
.def("view_transform",&Map::view_transform,
"Return the map ViewTransform object\n"
"which is used internally to convert between\n"
"geographic coordinates and screen coordinates.\n"
"\n"
"Usage:\n"
">>> m.view_transform()\n"
">>> m.view_transform()\n"
)
.def("zoom",&Map::zoom,
(arg("factor")),
"Zoom in or out by a given factor.\n"
@ -399,7 +399,7 @@ void export_map()
"\n"
">>> m.zoom(0.25)\n"
)
.def("zoom_all",&Map::zoom_all,
"Set the geographical extent of the map\n"
"to the combined extents of all active layers.\n"
@ -407,7 +407,7 @@ void export_map()
"Usage:\n"
">>> m.zoom_all()\n"
)
.def("zoom_to_box",&Map::zoom_to_box,
(arg("Boxd2")),
"Set the geographical extent of the map\n"
@ -418,37 +418,37 @@ void export_map()
">>> m.zoom_to_box(extent)\n"
)
.def("get_metawriter_property", &Map::get_metawriter_property,
(arg("name")),
"Reads a metawriter property.\n"
"These properties are completely user-defined and can be used to"
"create filenames, etc.\n"
"\n"
"Usage:\n"
">>> map.set_metawriter_property(\"x\", \"10\")\n"
">>> map.get_metawriter_property(\"x\")\n"
"10\n"
)
(arg("name")),
"Reads a metawriter property.\n"
"These properties are completely user-defined and can be used to"
"create filenames, etc.\n"
"\n"
"Usage:\n"
">>> map.set_metawriter_property(\"x\", \"10\")\n"
">>> map.get_metawriter_property(\"x\")\n"
"10\n"
)
.def("set_metawriter_property", &Map::set_metawriter_property,
(arg("name"),arg("value")),
"Sets a metawriter property.\n"
"These properties are completely user-defined and can be used to"
"create filenames, etc.\n"
"\n"
"Usage:\n"
">>> map.set_metawriter_property(\"x\", str(x))\n"
">>> map.set_metawriter_property(\"y\", str(y))\n"
">>> map.set_metawriter_property(\"z\", str(z))\n"
"\n"
"Use a path like \"[z]/[x]/[y].json\" to create filenames.\n"
)
(arg("name"),arg("value")),
"Sets a metawriter property.\n"
"These properties are completely user-defined and can be used to"
"create filenames, etc.\n"
"\n"
"Usage:\n"
">>> map.set_metawriter_property(\"x\", str(x))\n"
">>> map.set_metawriter_property(\"y\", str(y))\n"
">>> map.set_metawriter_property(\"z\", str(z))\n"
"\n"
"Use a path like \"[z]/[x]/[y].json\" to create filenames.\n"
)
.def("find_inmem_metawriter", find_inmem_metawriter,
(arg("name")),
"Gets an inmem metawriter, or None if no such metawriter "
"exists.\n"
"Use this after the map has been rendered to retrieve information "
"about the hit areas rendered on the map.\n"
)
(arg("name")),
"Gets an inmem metawriter, or None if no such metawriter "
"exists.\n"
"Use this after the map has been rendered to retrieve information "
"about the hit areas rendered on the map.\n"
)
.def("extra_attributes",&Map::get_extra_attributes,return_value_policy<copy_const_reference>(),"TODO")
.add_property("aspect_fix_mode",
@ -460,8 +460,8 @@ void export_map()
"Usage:\n"
"\n"
">>> m.aspect_fix_mode = aspect_fix_mode.GROW_BBOX\n"
)
)
.add_property("background",make_function
(&Map::background,return_value_policy<copy_const_reference>()),
&Map::set_background,
@ -480,7 +480,7 @@ void export_map()
"Usage:\n"
">>> m.base_path = '.'\n"
)
.add_property("buffer_size",
&Map::buffer_size,
&Map::set_buffer_size,
@ -493,7 +493,7 @@ void export_map()
">>> m.buffer_size\n"
"2\n"
)
.add_property("height",
&Map::height,
&Map::set_height,
@ -507,9 +507,9 @@ void export_map()
">>> m.height\n"
"600\n"
)
.add_property("layers",make_function
(layers_nonconst,return_value_policy<reference_existing_object>()),
(layers_nonconst,return_value_policy<reference_existing_object>()),
"The list of map layers.\n"
"\n"
"Usage:\n"
@ -548,7 +548,7 @@ void export_map()
"... \n"
">>> m.srs = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over'\n"
)
.add_property("width",
&Map::width,
&Map::set_width,

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2010 Artem Pavlenko
@ -33,18 +33,18 @@ using mapnik::symbolizer_with_image;
using mapnik::path_processor_type;
using mapnik::parse_path;
namespace {
namespace {
using namespace boost::python;
std::string get_filename(mapnik::markers_symbolizer const& symbolizer)
{
return path_processor_type::to_string(*symbolizer.get_filename());
}
std::string get_filename(mapnik::markers_symbolizer const& symbolizer)
{
return path_processor_type::to_string(*symbolizer.get_filename());
}
void set_filename(mapnik::markers_symbolizer & symbolizer, std::string const& file_expr)
{
symbolizer.set_filename(parse_path(file_expr));
}
void set_filename(mapnik::markers_symbolizer & symbolizer, std::string const& file_expr)
{
symbolizer.set_filename(parse_path(file_expr));
}
}
@ -75,10 +75,10 @@ struct markers_symbolizer_pickle_suite : boost::python::pickle_suite
);
throw_error_already_set();
}
p.set_allow_overlap(extract<bool>(state[0]));
//p.set_opacity(extract<float>(state[1]));
}
};
@ -87,14 +87,14 @@ struct markers_symbolizer_pickle_suite : boost::python::pickle_suite
void export_markers_symbolizer()
{
using namespace boost::python;
class_<markers_symbolizer>("MarkersSymbolizer",
init<>("Default Markers Symbolizer - blue arrow"))
init<>("Default Markers Symbolizer - blue arrow"))
.def (init<mapnik::path_expression_ptr>("<path expression ptr>"))
//.def_pickle(markers_symbolizer_pickle_suite())
.add_property("filename",
&get_filename,
&set_filename)
&set_filename)
.add_property("allow_overlap",
&markers_symbolizer::get_allow_overlap,
&markers_symbolizer::set_allow_overlap)

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -40,14 +40,14 @@ static boost::shared_ptr<mapnik::rgba_palette> make_palette( const std::string&
return boost::make_shared<mapnik::rgba_palette>(palette, type);
}
void export_palette ()
void export_palette ()
{
using namespace boost::python;
class_<boost::shared_ptr<mapnik::rgba_palette> >("Palette",no_init)
/*, init<std::string,std::string>(
( arg("palette"), arg("type")),
"Creates a new color palette from a file\n"
)*/
.def( "__init__", boost::python::make_constructor( &make_palette))
;
/*, init<std::string,std::string>(
( arg("palette"), arg("type")),
"Creates a new color palette from a file\n"
)*/
.def( "__init__", boost::python::make_constructor( &make_palette))
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -33,14 +33,14 @@ using mapnik::parameters;
struct pickle_value : public boost::static_visitor<>
{
public:
pickle_value( boost::python::list vals):
pickle_value( boost::python::list vals):
vals_(vals) {}
void operator () ( int val )
{
vals_.append(val);
}
void operator () ( double val )
{
vals_.append(val);
@ -50,7 +50,7 @@ public:
{
vals_.append(val);
}
private:
boost::python::list vals_;
@ -97,7 +97,7 @@ struct parameters_pickle_suite : boost::python::pickle_suite
);
throw_error_already_set();
}
dict d = extract<dict>(state[0]);
boost::python::list keys = d.keys();
for (int i=0; i<len(keys); ++i)
@ -107,7 +107,7 @@ struct parameters_pickle_suite : boost::python::pickle_suite
extract<std::string> ex0(obj);
extract<int> ex1(obj);
extract<double> ex2(obj);
if (ex0.check())
{
p[key] = ex0();
@ -119,14 +119,14 @@ struct parameters_pickle_suite : boost::python::pickle_suite
else if (ex2.check())
{
p[key] = ex2();
}
}
/*
extract_value serializer( p, key );
mapnik::value_holder val = extract<mapnik::value_holder>(d[key]);
boost::apply_visitor( serializer, val );
*/
}
}
}
};

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -39,14 +39,14 @@ using mapnik::parse_path;
namespace {
using namespace boost::python;
const std::string get_filename(point_symbolizer const& t)
{
return path_processor_type::to_string(*t.get_filename());
const std::string get_filename(point_symbolizer const& t)
{
return path_processor_type::to_string(*t.get_filename());
}
void set_filename(point_symbolizer & t, std::string const& file_expr)
{
t.set_filename(parse_path(file_expr));
void set_filename(point_symbolizer & t, std::string const& file_expr)
{
t.set_filename(parse_path(file_expr));
}
}
@ -81,12 +81,12 @@ struct point_symbolizer_pickle_suite : boost::python::pickle_suite
);
throw_error_already_set();
}
p.set_allow_overlap(extract<bool>(state[0]));
p.set_opacity(extract<float>(state[1]));
p.set_ignore_placement(extract<bool>(state[2]));
p.set_point_placement(extract<point_placement_e>(state[3]));
}
};
@ -100,7 +100,7 @@ void export_point_symbolizer()
.value("CENTROID",CENTROID_POINT_PLACEMENT)
.value("INTERIOR",INTERIOR_POINT_PLACEMENT)
;
class_<point_symbolizer>("PointSymbolizer",
init<>("Default Point Symbolizer - 4x4 black square"))
.def (init<mapnik::path_expression_ptr>("<path expression ptr>"))

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -38,14 +38,14 @@ using mapnik::guess_type;
namespace {
using namespace boost::python;
const std::string get_filename(polygon_pattern_symbolizer const& t)
{
return path_processor_type::to_string(*t.get_filename());
const std::string get_filename(polygon_pattern_symbolizer const& t)
{
return path_processor_type::to_string(*t.get_filename());
}
void set_filename(polygon_pattern_symbolizer & t, std::string const& file_expr)
{
t.set_filename(parse_path(file_expr));
void set_filename(polygon_pattern_symbolizer & t, std::string const& file_expr)
{
t.set_filename(parse_path(file_expr));
}
}
@ -77,7 +77,7 @@ struct polygon_pattern_symbolizer_pickle_suite : boost::python::pickle_suite
);
throw_error_already_set();
}
p.set_alignment(extract<pattern_alignment_e>(state[0]));
p.set_gamma(extract<float>(state[1]));
}
@ -92,22 +92,22 @@ void export_polygon_pattern_symbolizer()
.value("LOCAL",LOCAL_ALIGNMENT)
.value("GLOBAL",GLOBAL_ALIGNMENT)
;
class_<polygon_pattern_symbolizer>("PolygonPatternSymbolizer",
init<path_expression_ptr>("<path_expression_ptr>"))
.def_pickle(polygon_pattern_symbolizer_pickle_suite())
.add_property("alignment",
&polygon_pattern_symbolizer::get_alignment,
&polygon_pattern_symbolizer::set_alignment,
"Set/get the alignment of the pattern")
&polygon_pattern_symbolizer::get_alignment,
&polygon_pattern_symbolizer::set_alignment,
"Set/get the alignment of the pattern")
.add_property("transform",
mapnik::get_svg_transform<polygon_pattern_symbolizer>,
mapnik::set_svg_transform<polygon_pattern_symbolizer>)
mapnik::get_svg_transform<polygon_pattern_symbolizer>,
mapnik::set_svg_transform<polygon_pattern_symbolizer>)
.add_property("filename",
&get_filename,
&set_filename)
.add_property("gamma",
&polygon_pattern_symbolizer::get_gamma,
&polygon_pattern_symbolizer::set_gamma)
;
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -32,7 +32,7 @@ struct polygon_symbolizer_pickle_suite : boost::python::pickle_suite
static boost::python::tuple
getinitargs(const polygon_symbolizer& p)
{
return boost::python::make_tuple(p.get_fill());
return boost::python::make_tuple(p.get_fill());
}
static boost::python::tuple
@ -53,7 +53,7 @@ struct polygon_symbolizer_pickle_suite : boost::python::pickle_suite
);
throw_error_already_set();
}
p.set_opacity(extract<float>(state[0]));
p.set_gamma(extract<float>(state[1]));
}
@ -63,7 +63,7 @@ struct polygon_symbolizer_pickle_suite : boost::python::pickle_suite
void export_polygon_symbolizer()
{
using namespace boost::python;
class_<polygon_symbolizer>("PolygonSymbolizer",
init<>("Default PolygonSymbolizer - solid fill grey"))
.def(init<color const&>("TODO"))
@ -78,6 +78,6 @@ void export_polygon_symbolizer()
.add_property("gamma",
&polygon_symbolizer::get_gamma,
&polygon_symbolizer::set_gamma)
;
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2009 Artem Pavlenko
@ -25,7 +25,7 @@
#include <mapnik/proj_transform.hpp>
// boost
#include <boost/python.hpp>
using mapnik::proj_transform;
using mapnik::projection;
@ -54,7 +54,7 @@ mapnik::coord2d forward_transform_c(mapnik::proj_transform& t, mapnik::coord2d c
}
return mapnik::coord2d(x,y);
}
mapnik::coord2d backward_transform_c(mapnik::proj_transform& t, mapnik::coord2d const& c)
{
double x = c.x;
@ -122,7 +122,7 @@ mapnik::box2d<double> backward_transform_env_p(mapnik::proj_transform& t, mapnik
void export_proj_transform ()
{
using namespace boost::python;
class_<proj_transform, boost::noncopyable>("ProjTransform", init< projection const&, projection const& >())
.def_pickle(proj_transform_pickle_suite())
.def("forward", forward_transform_c)
@ -132,5 +132,5 @@ void export_proj_transform ()
.def("forward", forward_transform_env_p)
.def("backward",backward_transform_env_p)
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -41,7 +41,7 @@ struct projection_pickle_suite : boost::python::pickle_suite
};
namespace {
mapnik::coord2d forward_pt(mapnik::coord2d const& pt,
mapnik::coord2d forward_pt(mapnik::coord2d const& pt,
mapnik::projection const& prj)
{
double x = pt.x;
@ -49,8 +49,8 @@ mapnik::coord2d forward_pt(mapnik::coord2d const& pt,
prj.forward(x,y);
return mapnik::coord2d(x,y);
}
mapnik::coord2d inverse_pt(mapnik::coord2d const& pt,
mapnik::coord2d inverse_pt(mapnik::coord2d const& pt,
mapnik::projection const& prj)
{
double x = pt.x;
@ -58,7 +58,7 @@ mapnik::coord2d inverse_pt(mapnik::coord2d const& pt,
prj.inverse(x,y);
return mapnik::coord2d(x,y);
}
mapnik::box2d<double> forward_env(mapnik::box2d<double> const & box,
mapnik::projection const& prj)
{
@ -70,7 +70,7 @@ mapnik::box2d<double> forward_env(mapnik::box2d<double> const & box,
prj.forward(maxx,maxy);
return mapnik::box2d<double>(minx,miny,maxx,maxy);
}
mapnik::box2d<double> inverse_env(mapnik::box2d<double> const & box,
mapnik::projection const& prj)
{
@ -82,18 +82,18 @@ mapnik::box2d<double> inverse_env(mapnik::box2d<double> const & box,
prj.inverse(maxx,maxy);
return mapnik::box2d<double>(minx,miny,maxx,maxy);
}
}
void export_projection ()
{
using namespace boost::python;
using namespace boost::python;
class_<projection>("Projection", "Represents a map projection.",init<optional<std::string const&> >(
(arg("proj4_string")),
"Constructs a new projection from its PROJ.4 string representation.\n"
"\n"
"The parameterless version of this constructor is equivalent to\n"
"The parameterless version of this constructor is equivalent to\n"
" Projection('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
"\n"
"The constructor will throw a RuntimeError in case the projection\n"
@ -110,10 +110,10 @@ void export_projection ()
"This property is True if the projection is a geographic projection\n"
"(i.e. it uses lon/lat coordinates)\n")
;
def("forward_",&forward_pt);
def("inverse_",&inverse_pt);
def("forward_",&forward_env);
def("inverse_",&inverse_env);
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -99,53 +99,53 @@ namespace boost { namespace python {
return boost::apply_visitor(value_converter(),v.base());
}
};
}}
}}
void render(const mapnik::Map& map,
mapnik::image_32& image,
mapnik::image_32& image,
double scale_factor = 1.0,
unsigned offset_x = 0u,
unsigned offset_y = 0u)
{
Py_BEGIN_ALLOW_THREADS
try
{
mapnik::agg_renderer<mapnik::image_32> ren(map,image,scale_factor,offset_x, offset_y);
ren.apply();
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
Py_END_ALLOW_THREADS
}
void render_with_detector(
const mapnik::Map &map,
mapnik::image_32 &image,
boost::shared_ptr<mapnik::label_collision_detector4> detector,
double scale_factor = 1.0,
unsigned offset_x = 0u,
unsigned offset_y = 0u)
{
Py_BEGIN_ALLOW_THREADS
try
{
mapnik::agg_renderer<mapnik::image_32> ren(map,image,scale_factor,offset_x, offset_y);
ren.apply();
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
try
{
mapnik::agg_renderer<mapnik::image_32> ren(map,image,detector);
ren.apply();
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
Py_END_ALLOW_THREADS
}
void render_with_detector(
const mapnik::Map &map,
mapnik::image_32 &image,
boost::shared_ptr<mapnik::label_collision_detector4> detector,
double scale_factor = 1.0,
unsigned offset_x = 0u,
unsigned offset_y = 0u)
{
Py_BEGIN_ALLOW_THREADS
try
{
mapnik::agg_renderer<mapnik::image_32> ren(map,image,detector);
ren.apply();
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
Py_END_ALLOW_THREADS
}
}
void render_layer2(const mapnik::Map& map,
mapnik::image_32& image,
unsigned layer_idx)
mapnik::image_32& image,
unsigned layer_idx)
{
std::vector<mapnik::layer> const& layers = map.layers();
std::size_t layer_num = layers.size();
@ -157,101 +157,101 @@ void render_layer2(const mapnik::Map& map,
}
Py_BEGIN_ALLOW_THREADS
try
{
mapnik::layer const& layer = layers[layer_idx];
mapnik::agg_renderer<mapnik::image_32> ren(map,image,1.0,0,0);
std::set<std::string> names;
ren.apply(layer,names);
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
try
{
mapnik::layer const& layer = layers[layer_idx];
mapnik::agg_renderer<mapnik::image_32> ren(map,image,1.0,0,0);
std::set<std::string> names;
ren.apply(layer,names);
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
Py_END_ALLOW_THREADS
}
}
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
void render3(const mapnik::Map& map,
PycairoSurface* surface,
unsigned offset_x = 0,
unsigned offset_y = 0)
PycairoSurface* surface,
unsigned offset_x = 0,
unsigned offset_y = 0)
{
Py_BEGIN_ALLOW_THREADS
try
{
Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
mapnik::cairo_renderer<Cairo::Surface> ren(map,s,offset_x, offset_y);
ren.apply();
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
try
{
Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
mapnik::cairo_renderer<Cairo::Surface> ren(map,s,offset_x, offset_y);
ren.apply();
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
Py_END_ALLOW_THREADS
}
}
void render4(const mapnik::Map& map, PycairoSurface* surface)
{
Py_BEGIN_ALLOW_THREADS
try
{
Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
mapnik::cairo_renderer<Cairo::Surface> ren(map,s);
ren.apply();
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
try
{
Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
mapnik::cairo_renderer<Cairo::Surface> ren(map,s);
ren.apply();
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
Py_END_ALLOW_THREADS
}
}
void render5(const mapnik::Map& map,
PycairoContext* context,
unsigned offset_x = 0,
unsigned offset_y = 0)
PycairoContext* context,
unsigned offset_x = 0,
unsigned offset_y = 0)
{
Py_BEGIN_ALLOW_THREADS
try
{
Cairo::RefPtr<Cairo::Context> c(new Cairo::Context(context->ctx));
mapnik::cairo_renderer<Cairo::Context> ren(map,c,offset_x, offset_y);
ren.apply();
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
try
{
Cairo::RefPtr<Cairo::Context> c(new Cairo::Context(context->ctx));
mapnik::cairo_renderer<Cairo::Context> ren(map,c,offset_x, offset_y);
ren.apply();
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
Py_END_ALLOW_THREADS
}
}
void render6(const mapnik::Map& map, PycairoContext* context)
{
Py_BEGIN_ALLOW_THREADS
try
{
Cairo::RefPtr<Cairo::Context> c(new Cairo::Context(context->ctx));
mapnik::cairo_renderer<Cairo::Context> ren(map,c);
ren.apply();
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
try
{
Cairo::RefPtr<Cairo::Context> c(new Cairo::Context(context->ctx));
mapnik::cairo_renderer<Cairo::Context> ren(map,c);
ren.apply();
}
catch (...)
{
Py_BLOCK_THREADS
throw;
}
Py_END_ALLOW_THREADS
}
}
#endif
void render_tile_to_file(const mapnik::Map& map,
void render_tile_to_file(const mapnik::Map& map,
unsigned offset_x, unsigned offset_y,
unsigned width, unsigned height,
const std::string& file,
@ -274,11 +274,11 @@ void render_to_file1(const mapnik::Map& map,
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
#endif
}
else
else
{
mapnik::image_32 image(map.width(),map.height());
render(map,image,1.0,0,0);
mapnik::save_to_file(image,filename,format);
mapnik::save_to_file(image,filename,format);
}
}
@ -293,11 +293,11 @@ void render_to_file2(const mapnik::Map& map,const std::string& filename)
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
#endif
}
else
else
{
mapnik::image_32 image(map.width(),map.height());
render(map,image,1.0,0,0);
mapnik::save_to_file(image,filename);
mapnik::save_to_file(image,filename);
}
}
@ -305,7 +305,7 @@ void render_to_file3(const mapnik::Map& map,
const std::string& filename,
const std::string& format,
double scale_factor = 1.0
)
)
{
if (format == "pdf" || format == "svg" || format =="ps" || format == "ARGB32" || format == "RGB24")
{
@ -315,11 +315,11 @@ void render_to_file3(const mapnik::Map& map,
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
#endif
}
else
else
{
mapnik::image_32 image(map.width(),map.height());
render(map,image,scale_factor,0,0);
mapnik::save_to_file(image,filename,format);
mapnik::save_to_file(image,filename,format);
}
}
@ -355,9 +355,9 @@ unsigned mapnik_svn_revision()
bool has_jpeg()
{
#if defined(HAVE_JPEG)
return true;
return true;
#else
return false;
return false;
#endif
}
@ -379,10 +379,10 @@ bool has_pycairo()
if (Pycairo_CAPI == NULL){
/*
Case where pycairo support has been compiled into
mapnik but at runtime the cairo python module
is unable to be imported and therefore Pycairo surfaces
and contexts cannot be passed to mapnik.render()
*/
mapnik but at runtime the cairo python module
is unable to be imported and therefore Pycairo surfaces
and contexts cannot be passed to mapnik.render()
*/
return false;
}
return true;
@ -401,7 +401,7 @@ BOOST_PYTHON_FUNCTION_OVERLOADS(render_with_detector_overloads, render_with_dete
BOOST_PYTHON_MODULE(_mapnik2)
{
using namespace boost::python;
using mapnik::load_map;
@ -409,7 +409,7 @@ BOOST_PYTHON_MODULE(_mapnik2)
using mapnik::save_map;
using mapnik::save_map_to_string;
using mapnik::render_grid;
register_exception_translator<mapnik::config_error>(&config_error_translator);
register_exception_translator<mapnik::value_error>(&value_error_translator);
register_cairo();
@ -419,8 +419,8 @@ BOOST_PYTHON_MODULE(_mapnik2)
export_featureset();
export_datasource();
export_parameters();
export_color();
export_envelope();
export_color();
export_envelope();
export_palette();
export_image();
export_image_view();
@ -428,7 +428,7 @@ BOOST_PYTHON_MODULE(_mapnik2)
export_grid_view();
export_expression();
export_rule();
export_style();
export_style();
export_layer();
export_stroke();
export_datasource_cache();
@ -454,14 +454,14 @@ BOOST_PYTHON_MODULE(_mapnik2)
export_label_collision_detector();
def("render_grid",&render_grid,
( arg("map"),
arg("layer"),
args("key")="__id__",
arg("resolution")=4,
arg("fields")=boost::python::list()
)
);
( arg("map"),
arg("layer"),
args("key")="__id__",
arg("resolution")=4,
arg("fields")=boost::python::list()
)
);
def("render_to_file",&render_to_file1,
"\n"
"Render Map to file using explicit image type.\n"
@ -503,16 +503,16 @@ BOOST_PYTHON_MODULE(_mapnik2)
">>> render_to_file(m,'image.jpeg',scale_factor)\n"
"\n"
);
def("render_tile_to_file",&render_tile_to_file,
"\n"
"TODO\n"
"\n"
);
);
def("render", &render, render_overloads(
"\n"
"\n"
"Render Map to an AGG image_32 using offsets\n"
"\n"
"Usage:\n"
@ -526,29 +526,29 @@ BOOST_PYTHON_MODULE(_mapnik2)
">>> render(m,im,scale_factor)\n"
">>> render(m,im,scale_factor,offset[0],offset[1])\n"
"\n"
));
));
def("render_with_detector", &render_with_detector, render_with_detector_overloads(
"\n"
"Render Map to an AGG image_32 using a pre-constructed detector.\n"
"\n"
"Usage:\n"
">>> from mapnik import Map, Image, LabelCollisionDetector, render_with_detector, load_map\n"
">>> m = Map(256,256)\n"
">>> load_map(m,'mapfile.xml')\n"
">>> im = Image(m.width,m.height)\n"
">>> detector = LabelCollisionDetector(m)\n"
">>> render_with_detector(m, im, detector)\n"
));
"\n"
"Render Map to an AGG image_32 using a pre-constructed detector.\n"
"\n"
"Usage:\n"
">>> from mapnik import Map, Image, LabelCollisionDetector, render_with_detector, load_map\n"
">>> m = Map(256,256)\n"
">>> load_map(m,'mapfile.xml')\n"
">>> im = Image(m.width,m.height)\n"
">>> detector = LabelCollisionDetector(m)\n"
">>> render_with_detector(m, im, detector)\n"
));
def("render_layer", &render_layer2,
(arg("map"),arg("image"),args("layer"))
);
(arg("map"),arg("image"),args("layer"))
);
def("render_layer", &mapnik::render_layer_for_grid,
(arg("map"),arg("grid"),args("layer"),arg("fields")=boost::python::list())
);
(arg("map"),arg("grid"),args("layer"),arg("fields")=boost::python::list())
);
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
def("render",&render3,
"\n"
@ -587,7 +587,7 @@ BOOST_PYTHON_MODULE(_mapnik2)
">>> from cairo import SVGSurface, Context\n"
">>> surface = SVGSurface('image.svg', m.width, m.height)\n"
">>> ctx = Context(surface)\n"
">>> load_map(m,'mapfile.xml')\n"
">>> load_map(m,'mapfile.xml')\n"
">>> render(m,context,1,1)\n"
"\n"
);
@ -620,7 +620,7 @@ BOOST_PYTHON_MODULE(_mapnik2)
">>> scale_denominator(m,Projection(m.srs).geographic)\n"
"\n"
);
def("load_map", &load_map, load_map_overloads());
def("load_map_from_string", &load_map_string, load_map_string_overloads());
@ -641,7 +641,7 @@ BOOST_PYTHON_MODULE(_mapnik2)
"\n"
);
*/
def("save_map_to_string", &save_map_to_string, save_map_to_string_overloads());
def("mapnik_version", &mapnik_version,"Get the Mapnik version number");
def("mapnik_svn_revision", &mapnik_svn_revision,"Get the Mapnik svn revision");

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -32,7 +32,7 @@ struct query_pickle_suite : boost::python::pickle_suite
static boost::python::tuple
getinitargs(query const& q)
{
return boost::python::make_tuple(q.get_bbox(),q.resolution());
return boost::python::make_tuple(q.get_bbox(),q.resolution());
}
};
@ -40,7 +40,7 @@ void export_query()
{
using namespace boost::python;
class_<query>("Query", "a spatial query data object",
class_<query>("Query", "a spatial query data object",
init<box2d<double>,query::resolution_type const&,double>() )
.def(init<box2d<double> >())
.def_pickle(query_pickle_suite())

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2010 Artem Pavlenko
@ -69,98 +69,98 @@ void export_raster_colorizer()
using namespace boost::python;
class_<raster_colorizer,raster_colorizer_ptr>("RasterColorizer",
"A Raster Colorizer object.",
init<colorizer_mode_enum, color>(args("default_mode","default_color"))
)
"A Raster Colorizer object.",
init<colorizer_mode_enum, color>(args("default_mode","default_color"))
)
.def(init<>())
.add_property("default_color",
make_function(&raster_colorizer::get_default_color, return_value_policy<reference_existing_object>()),
&raster_colorizer::set_default_color,
"The default color for stops added without a color (mapnik.Color).\n")
.add_property("default_mode",
&raster_colorizer::get_default_mode_enum,
&raster_colorizer::set_default_mode_enum,
"The default mode (mapnik.ColorizerMode).\n"
"\n"
"If a stop is added without a mode, then it will inherit this default mode\n")
.add_property("default_color",
make_function(&raster_colorizer::get_default_color, return_value_policy<reference_existing_object>()),
&raster_colorizer::set_default_color,
"The default color for stops added without a color (mapnik.Color).\n")
.add_property("default_mode",
&raster_colorizer::get_default_mode_enum,
&raster_colorizer::set_default_mode_enum,
"The default mode (mapnik.ColorizerMode).\n"
"\n"
"If a stop is added without a mode, then it will inherit this default mode\n")
.add_property("stops",
make_function(get_stops,return_value_policy<reference_existing_object>()),
"The list of stops this RasterColorizer contains\n")
make_function(get_stops,return_value_policy<reference_existing_object>()),
"The list of stops this RasterColorizer contains\n")
.add_property("epsilon",
&raster_colorizer::get_epsilon,
&raster_colorizer::set_epsilon,
"Comparison epsilon value for exact mode\n"
"\n"
"When comparing values in exact mode, values need only be within epsilon to match.\n")
&raster_colorizer::get_epsilon,
&raster_colorizer::set_epsilon,
"Comparison epsilon value for exact mode\n"
"\n"
"When comparing values in exact mode, values need only be within epsilon to match.\n")
.def("add_stop", add_stop,
(arg("ColorizerStop")),
"Add a colorizer stop to the raster colorizer.\n"
"\n"
"Usage:\n"
">>> colorizer = mapnik.RasterColorizer()\n"
">>> color = mapnik.Color(\"#0044cc\")\n"
">>> stop = mapnik.ColorizerStop(3, mapnik.COLORIZER_INHERIT, color)\n"
">>> colorizer.add_stop(stop)\n"
(arg("ColorizerStop")),
"Add a colorizer stop to the raster colorizer.\n"
"\n"
"Usage:\n"
">>> colorizer = mapnik.RasterColorizer()\n"
">>> color = mapnik.Color(\"#0044cc\")\n"
">>> stop = mapnik.ColorizerStop(3, mapnik.COLORIZER_INHERIT, color)\n"
">>> colorizer.add_stop(stop)\n"
)
.def("add_stop", add_stop2,
(arg("value")),
"Add a colorizer stop to the raster colorizer, using the default mode and color.\n"
"\n"
"Usage:\n"
">>> default_color = mapnik.Color(\"#0044cc\")\n"
">>> colorizer = mapnik.RasterColorizer(mapnik2.COLORIZER_LINEAR, default_color)\n"
">>> colorizer.add_stop(100)\n"
(arg("value")),
"Add a colorizer stop to the raster colorizer, using the default mode and color.\n"
"\n"
"Usage:\n"
">>> default_color = mapnik.Color(\"#0044cc\")\n"
">>> colorizer = mapnik.RasterColorizer(mapnik2.COLORIZER_LINEAR, default_color)\n"
">>> colorizer.add_stop(100)\n"
)
.def("add_stop", add_stop3,
(arg("value")),
"Add a colorizer stop to the raster colorizer, using the default mode.\n"
"\n"
"Usage:\n"
">>> default_color = mapnik.Color(\"#0044cc\")\n"
">>> colorizer = mapnik.RasterColorizer(mapnik2.COLORIZER_LINEAR, default_color)\n"
">>> colorizer.add_stop(100, mapnik.Color(\"#123456\"))\n"
(arg("value")),
"Add a colorizer stop to the raster colorizer, using the default mode.\n"
"\n"
"Usage:\n"
">>> default_color = mapnik.Color(\"#0044cc\")\n"
">>> colorizer = mapnik.RasterColorizer(mapnik2.COLORIZER_LINEAR, default_color)\n"
">>> colorizer.add_stop(100, mapnik.Color(\"#123456\"))\n"
)
.def("add_stop", add_stop4,
(arg("value")),
"Add a colorizer stop to the raster colorizer, using the default color.\n"
"\n"
"Usage:\n"
">>> default_color = mapnik.Color(\"#0044cc\")\n"
">>> colorizer = mapnik.RasterColorizer(mapnik2.COLORIZER_LINEAR, default_color)\n"
">>> colorizer.add_stop(100, mapnik2.COLORIZER_EXACT)\n"
(arg("value")),
"Add a colorizer stop to the raster colorizer, using the default color.\n"
"\n"
"Usage:\n"
">>> default_color = mapnik.Color(\"#0044cc\")\n"
">>> colorizer = mapnik.RasterColorizer(mapnik2.COLORIZER_LINEAR, default_color)\n"
">>> colorizer.add_stop(100, mapnik2.COLORIZER_EXACT)\n"
)
.def("add_stop", add_stop5,
(arg("value")),
"Add a colorizer stop to the raster colorizer.\n"
"\n"
"Usage:\n"
">>> default_color = mapnik.Color(\"#0044cc\")\n"
">>> colorizer = mapnik.RasterColorizer(mapnik2.COLORIZER_LINEAR, default_color)\n"
">>> colorizer.add_stop(100, mapnik.COLORIZER_DISCRETE, mapnik.Color(\"#112233\"))\n"
(arg("value")),
"Add a colorizer stop to the raster colorizer.\n"
"\n"
"Usage:\n"
">>> default_color = mapnik.Color(\"#0044cc\")\n"
">>> colorizer = mapnik.RasterColorizer(mapnik2.COLORIZER_LINEAR, default_color)\n"
">>> colorizer.add_stop(100, mapnik.COLORIZER_DISCRETE, mapnik.Color(\"#112233\"))\n"
)
.def("get_color", &raster_colorizer::get_color,
"Get the color assigned to a certain value in raster data.\n"
"\n"
"Usage:\n"
">>> colorizer = mapnik.RasterColorizer()\n"
">>> color = mapnik.Color(\"#0044cc\")\n"
">>> colorizer.add_stop(0, mapnik2.COLORIZER_DISCRETE, mapnik.Color(\"#000000\"))\n"
">>> colorizer.add_stop(100, mapnik2.COLORIZER_DISCRETE, mapnik.Color(\"#0E0A06\"))\n"
">>> colorizer.get_color(50)\n"
"Color('#070503')\n"
.def("get_color", &raster_colorizer::get_color,
"Get the color assigned to a certain value in raster data.\n"
"\n"
"Usage:\n"
">>> colorizer = mapnik.RasterColorizer()\n"
">>> color = mapnik.Color(\"#0044cc\")\n"
">>> colorizer.add_stop(0, mapnik2.COLORIZER_DISCRETE, mapnik.Color(\"#000000\"))\n"
">>> colorizer.add_stop(100, mapnik2.COLORIZER_DISCRETE, mapnik.Color(\"#0E0A06\"))\n"
">>> colorizer.get_color(50)\n"
"Color('#070503')\n"
)
;
;
class_<colorizer_stops>("ColorizerStops",
"A RasterColorizer's collection of ordered color stops.\n"
"This class is not meant to be instantiated from python. However, "
"it can be accessed at a RasterColorizer's \"stops\" attribute for "
"introspection purposes",
no_init)
"A RasterColorizer's collection of ordered color stops.\n"
"This class is not meant to be instantiated from python. However, "
"it can be accessed at a RasterColorizer's \"stops\" attribute for "
"introspection purposes",
no_init)
.def(vector_indexing_suite<colorizer_stops>())
;
@ -174,32 +174,32 @@ void export_raster_colorizer()
class_<colorizer_stop>("ColorizerStop",init<float, colorizer_mode_enum, color const&>(
"A Colorizer Stop object.\n"
"Create with a value, ColorizerMode, and Color\n"
"\n"
"Usage:"
">>> color = mapnik.Color(\"#fff000\")\n"
">>> stop= mapnik.ColorizerStop(42.42, mapnik.COLORIZER_LINEAR, color)\n"
))
.add_property("color",
make_function(&colorizer_stop::get_color, return_value_policy<reference_existing_object>()),
&colorizer_stop::set_color,
"The stop color (mapnik.Color).\n")
.add_property("value",
&colorizer_stop::get_value,
&colorizer_stop::set_value,
"The stop value.\n")
.add_property("label",
make_function(&colorizer_stop::get_label, return_value_policy<copy_const_reference>()),
&colorizer_stop::set_label,
"The stop label.\n")
.add_property("mode",
&colorizer_stop::get_mode_enum,
&colorizer_stop::set_mode_enum,
"The stop mode (mapnik.ColorizerMode).\n"
"\n"
"If this is COLORIZER_INHERIT then it will inherit the default mode\n"
" from the RasterColorizer it is added to.\n")
"A Colorizer Stop object.\n"
"Create with a value, ColorizerMode, and Color\n"
"\n"
"Usage:"
">>> color = mapnik.Color(\"#fff000\")\n"
">>> stop= mapnik.ColorizerStop(42.42, mapnik.COLORIZER_LINEAR, color)\n"
))
.add_property("color",
make_function(&colorizer_stop::get_color, return_value_policy<reference_existing_object>()),
&colorizer_stop::set_color,
"The stop color (mapnik.Color).\n")
.add_property("value",
&colorizer_stop::get_value,
&colorizer_stop::set_value,
"The stop value.\n")
.add_property("label",
make_function(&colorizer_stop::get_label, return_value_policy<copy_const_reference>()),
&colorizer_stop::set_label,
"The stop label.\n")
.add_property("mode",
&colorizer_stop::get_mode_enum,
&colorizer_stop::set_mode_enum,
"The stop mode (mapnik.ColorizerMode).\n"
"\n"
"If this is COLORIZER_INHERIT then it will inherit the default mode\n"
" from the RasterColorizer it is added to.\n")
.def(self == self)
.def("__str__",&colorizer_stop::to_string)
;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -32,7 +32,7 @@ struct raster_symbolizer_pickle_suite : boost::python::pickle_suite
static boost::python::tuple
getinitargs(const raster_symbolizer& r)
{
return boost::python::make_tuple();
return boost::python::make_tuple();
}
*/
@ -54,7 +54,7 @@ struct raster_symbolizer_pickle_suite : boost::python::pickle_suite
);
throw_error_already_set();
}
r.set_mode(extract<std::string>(state[0]));
r.set_scaling(extract<std::string>(state[1]));
r.set_opacity(extract<float>(state[2]));
@ -70,9 +70,9 @@ void export_raster_symbolizer()
class_<raster_symbolizer>("RasterSymbolizer",
init<>("Default ctor"))
.def_pickle(raster_symbolizer_pickle_suite())
.add_property("mode",
make_function(&raster_symbolizer::get_mode,return_value_policy<copy_const_reference>()),
&raster_symbolizer::set_mode,
@ -87,7 +87,7 @@ void export_raster_symbolizer()
">>> r = RasterSymbolizer()\n"
">>> r.mode = 'grain_merge2'\n"
)
.add_property("scaling",
make_function(&raster_symbolizer::get_scaling,return_value_policy<copy_const_reference>()),
&raster_symbolizer::set_scaling,
@ -101,7 +101,7 @@ void export_raster_symbolizer()
">>> r = RasterSymbolizer()\n"
">>> r.scaling = 'bilinear8'\n"
)
.add_property("opacity",
&raster_symbolizer::get_opacity,
&raster_symbolizer::set_opacity,
@ -162,5 +162,5 @@ void export_raster_symbolizer()
">>> r = RasterSymbolizer()\n"
">>> r.mesh_size = 32\n"
)
;
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -51,7 +51,7 @@ using mapnik::to_expression_string;
struct pickle_symbolizer : public boost::static_visitor<>
{
public:
pickle_symbolizer( boost::python::list syms):
pickle_symbolizer( boost::python::list syms):
syms_(syms) {}
template <typename T>
@ -59,7 +59,7 @@ public:
{
syms_.append(sym);
}
private:
boost::python::list syms_;
};
@ -68,9 +68,9 @@ private:
struct extract_symbolizer : public boost::static_visitor<>
{
public:
extract_symbolizer( rule& r):
extract_symbolizer( rule& r):
r_(r) {}
template <typename T>
void operator () ( T const& sym )
{
@ -78,7 +78,7 @@ public:
}
private:
rule& r_;
};
struct rule_pickle_suite : boost::python::pickle_suite
@ -93,15 +93,15 @@ struct rule_pickle_suite : boost::python::pickle_suite
getstate(const rule& r)
{
boost::python::list syms;
rule::symbolizers::const_iterator begin = r.get_symbolizers().begin();
rule::symbolizers::const_iterator end = r.get_symbolizers().end();
rule::symbolizers::const_iterator end = r.get_symbolizers().end();
pickle_symbolizer serializer( syms );
std::for_each( begin, end , boost::apply_visitor( serializer ));
// We serialize filter expressions AST as strings
std::string filter_expr = to_expression_string(*r.get_filter());
return boost::python::make_tuple(r.get_abstract(),filter_expr,r.has_else_filter(),r.has_also_filter(),syms);
}
@ -117,11 +117,11 @@ struct rule_pickle_suite : boost::python::pickle_suite
);
throw_error_already_set();
}
if (state[0])
{
r.set_title(extract<std::string>(state[0]));
}
}
if (state[1])
{
@ -132,25 +132,25 @@ struct rule_pickle_suite : boost::python::pickle_suite
{
r.set_filter(mapnik::parse_expression(filter,"utf8"));
}
}
}
if (state[2])
{
r.set_else(true);
}
}
if (state[3])
{
r.set_also(true);
}
boost::python::list syms=extract<boost::python::list>(state[4]);
extract_symbolizer serializer( r );
for (int i=0;i<len(syms);++i)
{
//symbolizer symbol = extract<symbolizer>(syms[i]);
//boost::apply_visitor( serializer, symbol );
}
}
}
};
@ -169,11 +169,11 @@ void export_rule()
implicitly_convertible<text_symbolizer,symbolizer>();
implicitly_convertible<glyph_symbolizer,symbolizer>();
implicitly_convertible<markers_symbolizer,symbolizer>();
class_<rule::symbolizers>("Symbolizers",init<>("TODO"))
.def(vector_indexing_suite<rule::symbolizers>())
;
class_<rule>("Rule",init<>("default constructor"))
.def(init<std::string const&,
boost::python::optional<std::string const&,double,double> >())

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -63,7 +63,7 @@ void set_text_displacement(shield_symbolizer & t, boost::python::tuple arg)
{
t.set_displacement(extract<double>(arg[0]),extract<double>(arg[1]));
}
tuple get_anchor(const shield_symbolizer& t)
{
boost::tuple<double,double> pos = t.get_anchor();
@ -75,15 +75,15 @@ void set_anchor(shield_symbolizer & t, boost::python::tuple arg)
t.set_anchor(extract<double>(arg[0]),extract<double>(arg[1]));
}
const std::string get_filename(shield_symbolizer const& t)
{
return path_processor_type::to_string(*t.get_filename());
const std::string get_filename(shield_symbolizer const& t)
{
return path_processor_type::to_string(*t.get_filename());
}
void set_filename(shield_symbolizer & t, std::string const& file_expr)
{
t.set_filename(parse_path(file_expr));
}
void set_filename(shield_symbolizer & t, std::string const& file_expr)
{
t.set_filename(parse_path(file_expr));
}
}
@ -96,7 +96,7 @@ struct shield_symbolizer_pickle_suite : boost::python::pickle_suite
//(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
@ -118,10 +118,10 @@ struct shield_symbolizer_pickle_suite : boost::python::pickle_suite
);
throw_error_already_set();
}*/
s.set_halo_fill(extract<color>(state[0]));
s.set_halo_radius(extract<float>(state[1]));
}
};
@ -131,10 +131,10 @@ void export_shield_symbolizer()
{
using namespace boost::python;
class_< shield_symbolizer, bases<text_symbolizer> >("ShieldSymbolizer",
init<expression_ptr,
std::string const&,
unsigned, mapnik::color const&,
path_expression_ptr>("TODO")
init<expression_ptr,
std::string const&,
unsigned, mapnik::color const&,
path_expression_ptr>("TODO")
)
//.def_pickle(shield_symbolizer_pickle_suite())
.add_property("anchor",
@ -159,7 +159,7 @@ void export_shield_symbolizer()
make_function(&shield_symbolizer::get_face_name,return_value_policy<copy_const_reference>()),
&shield_symbolizer::set_face_name,
"Set/get the face_name property of the label")
.add_property("fill",
.add_property("fill",
make_function(&shield_symbolizer::get_fill,return_value_policy<copy_const_reference>()),
&shield_symbolizer::set_fill)
.add_property("fontset",
@ -172,7 +172,7 @@ void export_shield_symbolizer()
make_function(&shield_symbolizer::get_halo_fill,return_value_policy<copy_const_reference>()),
&shield_symbolizer::set_halo_fill)
.add_property("halo_radius",
&shield_symbolizer::get_halo_radius,
&shield_symbolizer::get_halo_radius,
&shield_symbolizer::set_halo_radius)
.add_property("horizontal_alignment",
&shield_symbolizer::get_horizontal_alignment,

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c+mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -57,7 +57,7 @@ struct stroke_pickle_suite : boost::python::pickle_suite
{
return boost::python::make_tuple(s.get_color(),s.get_width());
}
static boost::python::tuple
@ -140,15 +140,15 @@ void export_stroke ()
.add_property("width",
&stroke::get_width,
&stroke::set_width,
"Gets or sets the stroke width in pixels.\n")
"Gets or sets the stroke width in pixels.\n")
.add_property("opacity",
&stroke::get_opacity,
&stroke::set_opacity,
&stroke::set_opacity,
"Gets or sets the opacity of this stroke.\n"
"The value is a float between 0 and 1.\n")
.add_property("gamma",
&stroke::get_gamma,
&stroke::set_gamma,
&stroke::set_gamma,
"Gets or sets the gamma of this stroke.\n"
"The value is a float between 0 and 1.\n")
.add_property("line_cap",

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -42,7 +42,7 @@ struct style_pickle_suite : boost::python::pickle_suite
rules::const_iterator end = s.get_rules().end();
for (; it != end; ++it)
{
rule_list.append( *it );
rule_list.append( *it );
}
return boost::python::make_tuple(rule_list);
@ -60,14 +60,14 @@ struct style_pickle_suite : boost::python::pickle_suite
);
throw_error_already_set();
}
boost::python::list rules = extract<boost::python::list>(state[0]);
for (int i=0; i<len(rules); ++i)
{
s.add_rule(extract<rule>(rules[i]));
}
}
};
void export_style()
@ -97,12 +97,12 @@ void export_style()
">>> print r\n"
"<mapnik2._mapnik2.Rule object at 0x100549910>\n"
"<mapnik2._mapnik2.Rule object at 0x100549980>\n"
)
)
.add_property("filter_mode",
&feature_type_style::get_filter_mode,
&feature_type_style::set_filter_mode,
"Set/get the placement of the label")
;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2010 Robert Coup
@ -47,7 +47,7 @@ void set_svg_transform(T& symbolizer, std::string const& transform_wkt)
{
std::stringstream ss;
ss << "Could not parse transform from '" << transform_wkt << "', expected string like: 'matrix(1, 0, 0, 1, 0, 0)'";
throw mapnik::value_error(ss.str());
throw mapnik::value_error(ss.str());
}
mapnik::transform_type matrix;
tr.store_to(&matrix[0]);

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -45,52 +45,52 @@ struct get_symbolizer_type : public boost::static_visitor<std::string>
{
public:
get_symbolizer_type() {}
std::string operator () ( const point_symbolizer & /*sym*/ )
{
return "point";
}
std::string operator () ( const line_symbolizer & /*sym*/ )
{
return "line";
}
std::string operator () ( const line_pattern_symbolizer & /*sym*/ )
{
return "line_pattern";
}
std::string operator () ( const polygon_symbolizer & /*sym*/ )
{
return "polygon";
}
std::string operator () ( const polygon_pattern_symbolizer & /*sym*/ )
{
return "polygon_pattern";
}
std::string operator () ( const raster_symbolizer & /*sym*/ )
{
return "raster";
}
std::string operator () ( const shield_symbolizer & /*sym*/ )
{
return "shield";
}
std::string operator () ( const text_symbolizer & /*sym*/ )
{
return "text";
}
std::string operator () ( const building_symbolizer & /*sym*/ )
{
return "building";
}
std::string operator () ( const markers_symbolizer & /*sym*/ )
{
return "markers";

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
@ -69,7 +69,7 @@ struct text_symbolizer_pickle_suite : boost::python::pickle_suite
return boost::python::make_tuple("TODO",//t.get_name(),
t.get_face_name(),t.get_text_size(),t.get_fill());
}
static boost::python::tuple
@ -77,7 +77,7 @@ struct text_symbolizer_pickle_suite : boost::python::pickle_suite
{
boost::python::tuple disp = get_text_displacement(t);
boost::python::tuple anchor = get_anchor(t);
// so we do not exceed max args accepted by make_tuple,
// lets put the increasing list of parameters in a list
boost::python::list extras;
@ -91,11 +91,11 @@ struct text_symbolizer_pickle_suite : boost::python::pickle_suite
extras.append(t.get_text_opacity());
extras.append(t.get_minimum_padding());
extras.append(t.get_minimum_path_length());
return boost::python::make_tuple(disp,t.get_label_placement(),
t.get_vertical_alignment(),t.get_halo_radius(),t.get_halo_fill(),t.get_text_ratio(),
t.get_wrap_width(),t.get_label_spacing(),t.get_minimum_distance(),t.get_allow_overlap(),
anchor,t.get_force_odd_labels(),t.get_max_char_angle_delta(),extras
t.get_vertical_alignment(),t.get_halo_radius(),t.get_halo_fill(),t.get_text_ratio(),
t.get_wrap_width(),t.get_label_spacing(),t.get_minimum_distance(),t.get_allow_overlap(),
anchor,t.get_force_odd_labels(),t.get_max_char_angle_delta(),extras
);
}
@ -103,7 +103,7 @@ struct text_symbolizer_pickle_suite : boost::python::pickle_suite
setstate (text_symbolizer& t, boost::python::tuple state)
{
using namespace boost::python;
if (len(state) != 14)
{
PyErr_SetObject(PyExc_ValueError,
@ -112,16 +112,16 @@ struct text_symbolizer_pickle_suite : boost::python::pickle_suite
);
throw_error_already_set();
}
tuple disp = extract<tuple>(state[0]);
double dx = extract<double>(disp[0]);
double dy = extract<double>(disp[1]);
t.set_displacement(dx,dy);
t.set_label_placement(extract<label_placement_e>(state[1]));
t.set_vertical_alignment(extract<vertical_alignment_e>(state[2]));
t.set_halo_radius(extract<unsigned>(state[3]));
t.set_halo_fill(extract<color>(state[4]));
@ -135,14 +135,14 @@ struct text_symbolizer_pickle_suite : boost::python::pickle_suite
t.set_minimum_distance(extract<double>(state[8]));
t.set_allow_overlap(extract<bool>(state[9]));
tuple anch = extract<tuple>(state[10]);
double x = extract<double>(anch[0]);
double y = extract<double>(anch[1]);
t.set_anchor(x,y);
t.set_force_odd_labels(extract<bool>(state[11]));
t.set_max_char_angle_delta(extract<double>(state[12]));
list extras = extract<list>(state[13]);
t.set_wrap_char_from_string(extract<std::string>(extras[0]));
@ -187,7 +187,7 @@ void export_text_symbolizer()
.value("MIDDLE",J_MIDDLE)
.value("RIGHT",J_RIGHT)
;
enumeration_<text_transform_e>("text_transform")
.value("NONE",NONE)
.value("UPPERCASE",UPPERCASE)
@ -196,19 +196,19 @@ void export_text_symbolizer()
;
class_<text_symbolizer>("TextSymbolizer",init<expression_ptr,std::string const&, unsigned,color const&>())
/*
// todo - all python classes can have kwargs and default constructors
class_<text_symbolizer>("TextSymbolizer",
/*
// todo - all python classes can have kwargs and default constructors
class_<text_symbolizer>("TextSymbolizer",
init<expression_ptr,std::string const&, unsigned,color const&>(
(
arg("name"),
arg("font_face")="DejaVu Sans Book",
arg("size")=10,
arg("color")=color("black")
),
(
arg("name"),
arg("font_face")="DejaVu Sans Book",
arg("size")=10,
arg("color")=color("black")
),
"Create a TextSymbolizer\n"
))
*/
*/
//.def_pickle(text_symbolizer_pickle_suite())
.add_property("anchor",
@ -233,7 +233,7 @@ void export_text_symbolizer()
make_function(&text_symbolizer::get_face_name,return_value_policy<copy_const_reference>()),
&text_symbolizer::set_face_name,
"Set/get the face_name property of the label")
.add_property("fill",
.add_property("fill",
make_function(&text_symbolizer::get_fill,return_value_policy<copy_const_reference>()),
&text_symbolizer::set_fill)
.add_property("fontset",
@ -246,7 +246,7 @@ void export_text_symbolizer()
make_function(&text_symbolizer::get_halo_fill,return_value_policy<copy_const_reference>()),
&text_symbolizer::set_halo_fill)
.add_property("halo_radius",
&text_symbolizer::get_halo_radius,
&text_symbolizer::get_halo_radius,
&text_symbolizer::set_halo_radius)
.add_property("horizontal_alignment",
&text_symbolizer::get_horizontal_alignment,

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -47,23 +47,23 @@ namespace boost { namespace python {
{
return ::PyBool_FromLong(val);
}
PyObject * operator() (UnicodeString const& s) const
{
std::string buffer;
mapnik::to_utf8(s,buffer);
PyObject *obj = Py_None;
obj = ::PyUnicode_DecodeUTF8(buffer.c_str(),implicit_cast<ssize_t>(buffer.length()),0);
obj = ::PyUnicode_DecodeUTF8(buffer.c_str(),implicit_cast<ssize_t>(buffer.length()),0);
return obj;
}
PyObject * operator() (mapnik::value_null const& /*s*/) const
{
return Py_None;
}
};
}
}
}
#endif // MAPNIK_PYTHON_BINDING_VALUE_CONVERTER_INCLUDED

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2009 Artem Pavlenko, Jean-Francois Doyon
@ -47,31 +47,31 @@ mapnik::coord2d forward_point(mapnik::CoordTransform const& t, mapnik::coord2d c
t.forward(out);
return out;
}
mapnik::coord2d backward_point(mapnik::CoordTransform const& t, mapnik::coord2d const& in)
{
mapnik::coord2d out(in);
t.backward(out);
return out;
}
mapnik::box2d<double> forward_envelope(mapnik::CoordTransform const& t, mapnik::box2d<double> const& in)
{
return t.forward(in);
}
mapnik::box2d<double> backward_envelope(mapnik::CoordTransform const& t, mapnik::box2d<double> const& in)
{
return t.backward(in);
}
}
void export_view_transform()
void export_view_transform()
{
using namespace boost::python;
using mapnik::box2d;
using mapnik::coord2d;
class_<CoordTransform>("ViewTransform",init<int,int,box2d<double> const& > (
"Create a ViewTransform with a width and height as integers and extent"))
.def_pickle(view_transform_pickle_suite())

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -40,9 +40,9 @@ namespace mapnik {
template <typename T>
static void grid2utf(T const& grid_type,
boost::python::list& l,
std::vector<grid::lookup_type>& key_order)
static void grid2utf(T const& grid_type,
boost::python::list& l,
std::vector<grid::lookup_type>& key_order)
{
typename T::data_type const& data = grid_type.data();
typename T::feature_key_type const& feature_keys = grid_type.get_feature_keys();
@ -51,11 +51,11 @@ static void grid2utf(T const& grid_type,
typename T::feature_key_type::const_iterator feature_pos;
// start counting at utf8 codepoint 32, aka space character
boost::uint16_t codepoint = 32;
unsigned array_size = data.width();
for (unsigned y = 0; y < data.height(); ++y)
{
boost::uint16_t idx = 0;
boost::uint16_t idx = 0;
boost::scoped_array<Py_UNICODE> line(new Py_UNICODE[array_size]);
typename T::value_type const* row = data.getRow(y);
for (unsigned x = 0; x < data.width(); ++x)
@ -71,7 +71,7 @@ static void grid2utf(T const& grid_type,
// can't be encoded directly in JSON.
if (codepoint == 34) ++codepoint; // Skip "
else if (codepoint == 92) ++codepoint; // Skip backslash
keys[val] = codepoint;
key_order.push_back(val);
line[idx++] = static_cast<Py_UNICODE>(codepoint);
@ -85,17 +85,17 @@ static void grid2utf(T const& grid_type,
// else, shouldn't get here...
}
l.append(boost::python::object(
boost::python::handle<>(
PyUnicode_FromUnicode(line.get(), array_size))));
boost::python::handle<>(
PyUnicode_FromUnicode(line.get(), array_size))));
}
}
template <typename T>
static void grid2utf(T const& grid_type,
boost::python::list& l,
std::vector<typename T::lookup_type>& key_order,
unsigned int resolution)
static void grid2utf(T const& grid_type,
boost::python::list& l,
std::vector<typename T::lookup_type>& key_order,
unsigned int resolution)
{
//typename T::data_type const& data = grid_type.data();
typename T::feature_key_type const& feature_keys = grid_type.get_feature_keys();
@ -109,7 +109,7 @@ static void grid2utf(T const& grid_type,
unsigned array_size = static_cast<unsigned int>(grid_type.width()/resolution);
for (unsigned y = 0; y < grid_type.height(); y=y+resolution)
{
boost::uint16_t idx = 0;
boost::uint16_t idx = 0;
boost::scoped_array<Py_UNICODE> line(new Py_UNICODE[array_size]);
mapnik::grid::value_type const* row = grid_type.getRow(y);
for (unsigned x = 0; x < grid_type.width(); x=x+resolution)
@ -138,17 +138,17 @@ static void grid2utf(T const& grid_type,
// else, shouldn't get here...
}
l.append(boost::python::object(
boost::python::handle<>(
PyUnicode_FromUnicode(line.get(), array_size))));
boost::python::handle<>(
PyUnicode_FromUnicode(line.get(), array_size))));
}
}
template <typename T>
static void grid2utf2(T const& grid_type,
boost::python::list& l,
std::vector<typename T::lookup_type>& key_order,
unsigned int resolution)
static void grid2utf2(T const& grid_type,
boost::python::list& l,
std::vector<typename T::lookup_type>& key_order,
unsigned int resolution)
{
typename T::data_type const& data = grid_type.data();
typename T::feature_key_type const& feature_keys = grid_type.get_feature_keys();
@ -194,16 +194,16 @@ static void grid2utf2(T const& grid_type,
// else, shouldn't get here...
}
l.append(boost::python::object(
boost::python::handle<>(
PyUnicode_FromUnicode(line.get(), array_size))));
boost::python::handle<>(
PyUnicode_FromUnicode(line.get(), array_size))));
}
}
template <typename T>
static void write_features(T const& grid_type,
boost::python::dict& feature_data,
std::vector<typename T::lookup_type> const& key_order)
boost::python::dict& feature_data,
std::vector<typename T::lookup_type> const& key_order)
{
std::string const& key = grid_type.get_key();
std::set<std::string> const& attributes = grid_type.property_names();
@ -218,7 +218,7 @@ static void write_features(T const& grid_type,
if (itr != props.end())
{
typename T::lookup_type const& join_value = itr->second.to_string();
// only serialize features visible in the grid
if(std::find(key_order.begin(), key_order.end(), join_value) != key_order.end()) {
boost::python::dict feat;
@ -236,7 +236,7 @@ static void write_features(T const& grid_type,
boost::python::handle<>(
boost::apply_visitor(
boost::python::value_converter(),
it->second.base())));
it->second.base())));
}
}
else if ( (attributes.find(key_name) != attributes.end()) )
@ -246,7 +246,7 @@ static void write_features(T const& grid_type,
boost::python::handle<>(
boost::apply_visitor(
boost::python::value_converter(),
it->second.base())));
it->second.base())));
}
}
if (found)
@ -264,14 +264,14 @@ static void write_features(T const& grid_type,
template <typename T>
static void grid_encode_utf(T const& grid_type,
boost::python::dict & json,
bool add_features,
unsigned int resolution)
boost::python::dict & json,
bool add_features,
unsigned int resolution)
{
// convert buffer to utf and gather key order
boost::python::list l;
std::vector<typename T::lookup_type> key_order;
if (resolution != 1) {
// resample on the fly - faster, less accurate
mapnik::grid2utf<T>(grid_type,l,key_order,resolution);
@ -281,7 +281,7 @@ static void grid_encode_utf(T const& grid_type,
}
else
{
mapnik::grid2utf<T>(grid_type,l,key_order);
mapnik::grid2utf<T>(grid_type,l,key_order);
}
// convert key order to proper python list
@ -325,9 +325,9 @@ static boost::python::dict grid_encode( T const& grid, std::string format, bool
* whether features are dumped is determined by argument not 'fields'
*/
static void render_layer_for_grid(const mapnik::Map& map,
mapnik::grid& grid,
unsigned layer_idx, // TODO - layer by name or index
boost::python::list const& fields)
mapnik::grid& grid,
unsigned layer_idx, // TODO - layer by name or index
boost::python::list const& fields)
{
std::vector<mapnik::layer> const& layers = map.layers();
std::size_t layer_num = layers.size();
@ -347,9 +347,9 @@ static void render_layer_for_grid(const mapnik::Map& map,
}
else
{
std::stringstream s;
s << "list of field names must be strings";
throw mapnik::value_error(s.str());
std::stringstream s;
s << "list of field names must be strings";
throw mapnik::value_error(s.str());
}
}
@ -358,10 +358,10 @@ static void render_layer_for_grid(const mapnik::Map& map,
std::string const& key = grid.get_key();
// if key is special __id__ keyword
if (key == grid.id_name_)
if (key == grid.id_name_)
{
// TODO - should feature.id() be a first class attribute?
// if __id__ is requested to be dumped out
// remove it so that datasource queries will not break
if (attributes.find(key) != attributes.end())
@ -375,7 +375,7 @@ static void render_layer_for_grid(const mapnik::Map& map,
// them make sure the datasource query includes this field
attributes.insert(key);
}
mapnik::grid_renderer<mapnik::grid> ren(map,grid,1.0,0,0);
mapnik::layer const& layer = layers[layer_idx];
ren.apply(layer,attributes);
@ -385,10 +385,10 @@ static void render_layer_for_grid(const mapnik::Map& map,
* grid object is created on the fly at potentially reduced size
*/
static boost::python::dict render_grid(const mapnik::Map& map,
unsigned layer_idx, // layer
std::string const& key, // key_name
unsigned int step, // resolution
boost::python::list const& fields)
unsigned layer_idx, // layer
std::string const& key, // key_name
unsigned int step, // resolution
boost::python::list const& fields)
{
std::vector<mapnik::layer> const& layers = map.layers();
@ -405,7 +405,7 @@ static boost::python::dict render_grid(const mapnik::Map& map,
// TODO - no need to pass step here
mapnik::grid grid(grid_width,grid_height,key,step);
// convert python list to std::vector
boost::python::ssize_t num_fields = boost::python::len(fields);
for(boost::python::ssize_t i=0; i<num_fields; i++) {
@ -415,20 +415,20 @@ static boost::python::dict render_grid(const mapnik::Map& map,
}
else
{
std::stringstream s;
s << "list of field names must be strings";
throw mapnik::value_error(s.str());
std::stringstream s;
s << "list of field names must be strings";
throw mapnik::value_error(s.str());
}
}
// copy property names
std::set<std::string> attributes = grid.property_names();
// if key is special __id__ keyword
if (key == grid.id_name_)
if (key == grid.id_name_)
{
// TODO - should feature.id() be a first class attribute?
// if __id__ is requested to be dumped out
// remove it so that datasource queries will not break
if (attributes.find(key) != attributes.end())
@ -442,7 +442,7 @@ static boost::python::dict render_grid(const mapnik::Map& map,
// them make sure the datasource query includes this field
attributes.insert(key);
}
try
{
mapnik::grid_renderer<mapnik::grid> ren(map,grid,1.0,0,0);
@ -453,7 +453,7 @@ static boost::python::dict render_grid(const mapnik::Map& map,
{
throw;
}
bool add_features = false;
if (num_fields > 0)
add_features = true;

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2007 Artem Pavlenko
@ -68,7 +68,7 @@ struct python_optional : public boost::noncopyable
const registration& converters(registered<T>::converters);
if (implicit_rvalue_convertible_from_python(source,
if (implicit_rvalue_convertible_from_python(source,
converters)) {
rvalue_from_python_stage1_data data =
rvalue_from_python_stage1(source, converters);
@ -82,7 +82,7 @@ struct python_optional : public boost::noncopyable
{
using namespace boost::python::converter;
void * const storage = ((rvalue_from_python_storage<T> *)
void * const storage = ((rvalue_from_python_storage<T> *)
data)->storage.bytes;
if (data->convertible == source) // == None

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
@ -40,69 +40,69 @@
int main ( int argc , char** argv)
{
{
if (argc != 2)
{
std::cout << "usage: ./rundemo <mapnik_install_dir>\nUsually /usr/local/lib/mapnik2\n";
std::cout << "Warning: ./rundemo looks for data in ../data/,\nTherefore must be run from within the demo/c++ folder.\n";
return EXIT_SUCCESS;
}
using namespace mapnik;
try {
std::cout << " running demo ... \n";
std::string mapnik_dir(argv[1]);
std::cout << " looking for 'shape.input' plugin in... " << mapnik_dir << "/input/" << "\n";
datasource_cache::instance()->register_datasources(mapnik_dir + "/input/");
datasource_cache::instance()->register_datasources(mapnik_dir + "/input/");
std::cout << " looking for DejaVuSans font in... " << mapnik_dir << "/fonts/DejaVuSans.ttf" << "\n";
freetype_engine::register_font(mapnik_dir + "/fonts/DejaVuSans.ttf");
Map m(800,600);
m.set_background(color_factory::from_string("white"));
// create styles
// Provinces (polygon)
feature_type_style provpoly_style;
rule provpoly_rule_on;
provpoly_rule_on.set_filter(parse_expression("[NAME_EN] = 'Ontario'"));
provpoly_rule_on.append(polygon_symbolizer(color(250, 190, 183)));
provpoly_style.add_rule(provpoly_rule_on);
rule provpoly_rule_qc;
provpoly_rule_qc.set_filter(parse_expression("[NOM_FR] = 'Québec'"));
provpoly_rule_qc.append(polygon_symbolizer(color(217, 235, 203)));
provpoly_style.add_rule(provpoly_rule_qc);
m.insert_style("provinces",provpoly_style);
// Provinces (polyline)
feature_type_style provlines_style;
stroke provlines_stk (color(0,0,0),1.0);
provlines_stk.add_dash(8, 4);
provlines_stk.add_dash(2, 2);
provlines_stk.add_dash(2, 2);
rule provlines_rule;
provlines_rule.append(line_symbolizer(provlines_stk));
provlines_style.add_rule(provlines_rule);
m.insert_style("provlines",provlines_style);
// Drainage
// Drainage
feature_type_style qcdrain_style;
rule qcdrain_rule;
qcdrain_rule.set_filter(parse_expression("[HYC] = 8"));
qcdrain_rule.append(polygon_symbolizer(color(153, 204, 255)));
qcdrain_style.add_rule(qcdrain_rule);
m.insert_style("drainage",qcdrain_style);
// Roads 3 and 4 (The "grey" roads)
feature_type_style roads34_style;
feature_type_style roads34_style;
rule roads34_rule;
roads34_rule.set_filter(parse_expression("[CLASS] = 3 or [CLASS] = 4"));
stroke roads34_rule_stk(color(171,158,137),2.0);
@ -110,9 +110,9 @@ int main ( int argc , char** argv)
roads34_rule_stk.set_line_join(ROUND_JOIN);
roads34_rule.append(line_symbolizer(roads34_rule_stk));
roads34_style.add_rule(roads34_rule);
m.insert_style("smallroads",roads34_style);
// Roads 2 (The thin yellow ones)
feature_type_style roads2_style_1;
@ -123,9 +123,9 @@ int main ( int argc , char** argv)
roads2_rule_stk_1.set_line_join(ROUND_JOIN);
roads2_rule_1.append(line_symbolizer(roads2_rule_stk_1));
roads2_style_1.add_rule(roads2_rule_1);
m.insert_style("road-border", roads2_style_1);
feature_type_style roads2_style_2;
rule roads2_rule_2;
roads2_rule_2.set_filter(parse_expression("[CLASS] = 2"));
@ -134,9 +134,9 @@ int main ( int argc , char** argv)
roads2_rule_stk_2.set_line_join(ROUND_JOIN);
roads2_rule_2.append(line_symbolizer(roads2_rule_stk_2));
roads2_style_2.add_rule(roads2_rule_2);
m.insert_style("road-fill", roads2_style_2);
// Roads 1 (The big orange ones, the highways)
feature_type_style roads1_style_1;
rule roads1_rule_1;
@ -147,7 +147,7 @@ int main ( int argc , char** argv)
roads1_rule_1.append(line_symbolizer(roads1_rule_stk_1));
roads1_style_1.add_rule(roads1_rule_1);
m.insert_style("highway-border", roads1_style_1);
feature_type_style roads1_style_2;
rule roads1_rule_2;
roads1_rule_2.set_filter(parse_expression("[CLASS] = 1"));
@ -157,9 +157,9 @@ int main ( int argc , char** argv)
roads1_rule_2.append(line_symbolizer(roads1_rule_stk_2));
roads1_style_2.add_rule(roads1_rule_2);
m.insert_style("highway-fill", roads1_style_2);
// Populated Places
feature_type_style popplaces_style;
rule popplaces_rule;
text_symbolizer popplaces_text_symbolizer(parse_expression("[GEONAME]"),"DejaVu Sans Book",10,color(0,0,0));
@ -167,22 +167,22 @@ int main ( int argc , char** argv)
popplaces_text_symbolizer.set_halo_radius(1);
popplaces_rule.append(popplaces_text_symbolizer);
popplaces_style.add_rule(popplaces_rule);
m.insert_style("popplaces",popplaces_style );
// layers
// Provincial polygons
{
parameters p;
p["type"]="shape";
p["file"]="../data/boundaries";
layer lyr("Provinces");
layer lyr("Provinces");
lyr.set_datasource(datasource_cache::instance()->create(p));
lyr.add_style("provinces");
lyr.add_style("provinces");
m.addLayer(lyr);
}
// Drainage
{
parameters p;
@ -190,38 +190,38 @@ int main ( int argc , char** argv)
p["file"]="../data/qcdrainage";
layer lyr("Quebec Hydrography");
lyr.set_datasource(datasource_cache::instance()->create(p));
lyr.add_style("drainage");
lyr.add_style("drainage");
m.addLayer(lyr);
}
{
parameters p;
p["type"]="shape";
p["file"]="../data/ontdrainage";
layer lyr("Ontario Hydrography");
layer lyr("Ontario Hydrography");
lyr.set_datasource(datasource_cache::instance()->create(p));
lyr.add_style("drainage");
lyr.add_style("drainage");
m.addLayer(lyr);
}
// Provincial boundaries
{
parameters p;
p["type"]="shape";
p["file"]="../data/boundaries_l";
layer lyr("Provincial borders");
layer lyr("Provincial borders");
lyr.set_datasource(datasource_cache::instance()->create(p));
lyr.add_style("provlines");
lyr.add_style("provlines");
m.addLayer(lyr);
}
// Roads
{
parameters p;
p["type"]="shape";
p["file"]="../data/roads";
layer lyr("Roads");
p["file"]="../data/roads";
layer lyr("Roads");
lyr.set_datasource(datasource_cache::instance()->create(p));
lyr.add_style("smallroads");
lyr.add_style("road-border");
@ -229,7 +229,7 @@ int main ( int argc , char** argv)
lyr.add_style("highway-border");
lyr.add_style("highway-fill");
m.addLayer(lyr);
m.addLayer(lyr);
}
// popplaces
{
@ -239,27 +239,27 @@ int main ( int argc , char** argv)
p["encoding"] = "latin1";
layer lyr("Populated Places");
lyr.set_datasource(datasource_cache::instance()->create(p));
lyr.add_style("popplaces");
lyr.add_style("popplaces");
m.addLayer(lyr);
}
m.zoom_to_box(box2d<double>(1405120.04127408,-247003.813399447,
1706357.31328276,-25098.593149577));
1706357.31328276,-25098.593149577));
image_32 buf(m.width(),m.height());
agg_renderer<image_32> ren(m,buf);
ren.apply();
save_to_file<image_data_32>(buf.data(),"demo.jpg","jpeg");
save_to_file<image_data_32>(buf.data(),"demo.png","png");
save_to_file<image_data_32>(buf.data(),"demo256.png","png256");
std::cout << "Three maps have been rendered using AGG in the current directory:\n"
"- demo.jpg\n"
"- demo.png\n"
"- demo256.png\n"
"Have a look!\n";
"- demo.jpg\n"
"- demo.png\n"
"- demo256.png\n"
"Have a look!\n";
#if defined(HAVE_CAIRO)
#if defined(HAVE_CAIRO)
Cairo::RefPtr<Cairo::ImageSurface> image_surface;
image_surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, m.width(),m.height());
@ -280,12 +280,12 @@ int main ( int argc , char** argv)
svg_render.apply();
std::cout << "Three maps have been rendered using Cairo in the current directory:\n"
"- cairo-demo.png\n"
"- cairo-demo256.png\n"
"- cairo-demo.pdf\n"
"- cairo-demo.svg\n"
"Have a look!\n";
#endif
"- cairo-demo.png\n"
"- cairo-demo256.png\n"
"- cairo-demo.pdf\n"
"- cairo-demo.svg\n"
"Have a look!\n";
#endif
}
catch ( const mapnik::config_error & ex )

View file

@ -114,11 +114,11 @@ feature_ptr occi_featureset::next()
int type_oid = columnObj.getInt(MetaData::ATTR_DATA_TYPE);
/*
int type_code = columnObj.getInt(MetaData::ATTR_TYPECODE);
if (type_code == OCCI_TYPECODE_OBJECT)
{
continue;
}
int type_code = columnObj.getInt(MetaData::ATTR_TYPECODE);
if (type_code == OCCI_TYPECODE_OBJECT)
{
continue;
}
*/
switch (type_oid)

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko
@ -51,18 +51,18 @@ const double MINRATIO=0.5;
const double MAXRATIO=0.8;
const double DEFAULT_RATIO=0.55;
int main (int argc,char** argv)
int main (int argc,char** argv)
{
using namespace mapnik;
namespace po = boost::program_options;
using std::string;
using std::vector;
bool verbose=false;
unsigned int depth=DEFAULT_DEPTH;
double ratio=DEFAULT_RATIO;
vector<string> ogr_files;
try
{
po::options_description desc("ogrindex utility");
@ -70,23 +70,23 @@ int main (int argc,char** argv)
("help,h", "produce usage message")
("version,V", "print version string")
("verbose,v", "verbose output")
("depth,d", po::value<unsigned int>(), "max tree depth\n(default 8)")
("depth,d", po::value<unsigned int>(), "max tree depth\n(default 8)")
("ratio,r", po::value<double>(), "split ratio (default 0.55)")
("ogr_files", po::value<vector<string> >(), "ogr supported files to index: file1 file2 ...fileN")
;
po::positional_options_description p;
p.add("ogr_files",-1);
po::variables_map vm;
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
po::notify(vm);
if (vm.count("version"))
{
std::clog<<"version 0.1.0" <<std::endl;
return 1;
}
if (vm.count("help"))
if (vm.count("help"))
{
std::clog << desc << std::endl;
return 1;
@ -109,10 +109,10 @@ int main (int argc,char** argv)
std::clog << "Exception of unknown type!" << std::endl;
return -1;
}
std::clog << "max tree depth:" << depth << std::endl;
std::clog << "split ratio:" << ratio << std::endl;
vector<string>::const_iterator itr = ogr_files.begin();
if (itr == ogr_files.end())
{
@ -124,7 +124,7 @@ int main (int argc,char** argv)
std::clog << "processing " << *itr << std::endl;
std::string ogrname (*itr++);
if (! boost::filesystem::exists (ogrname))
{
std::clog << "error : file " << ogrname << " doesn't exists" << std::endl;
@ -148,7 +148,7 @@ int main (int argc,char** argv)
params["file"] = ogrname;
//unsigned first = 0;
params["layer_by_index"] = 0;//ogrlayername;
try
{
ogr_datasource ogr (params);
@ -157,14 +157,14 @@ int main (int argc,char** argv)
box2d<double> extent = ogr.envelope();
quadtree<int> tree (extent, depth, ratio);
int count=0;
std::clog << "file:" << ogrname << std::endl;
std::clog << "layer:" << ogrlayername << std::endl;
std::clog << "extent:" << extent << std::endl;
mapnik::query q (extent, 1.0);
mapnik::featureset_ptr itr = ogr.features (q);
while (true)
{
mapnik::feature_ptr fp = itr->next();
@ -172,23 +172,23 @@ int main (int argc,char** argv)
{
break;
}
box2d<double> item_ext = fp->envelope();
tree.insert (count, item_ext);
if (verbose) {
std::clog << "record number " << (count + 1) << " box=" << item_ext << std::endl;
}
++count;
}
std::clog << " number shapes=" << count << std::endl;
std::clog << " number shapes=" << count << std::endl;
std::fstream file((ogrlayername+".ogrindex").c_str(),
std::ios::in | std::ios::out | std::ios::trunc | std::ios::binary);
if (!file) {
std::clog << "cannot open ogrindex file for writing file \""
std::clog << "cannot open ogrindex file for writing file \""
<< (ogrlayername+".ogrindex") << "\"" << std::endl;
} else {
tree.trim();
@ -213,7 +213,7 @@ int main (int argc,char** argv)
}
}
std::clog << "done!" << std::endl;
return 0;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2009 Artem Pavlenko
@ -39,13 +39,13 @@
int main ( int argc, char** argv)
{
namespace po = boost::program_options;
po::options_description desc("Postgresql/PostGIS to SQLite3 converter\n Options");
std::string usage = "usage: pgsql2sqlite --dbname db --table planet_osm_line --file osm.sqlite --query \"select * from planet_osm_line\"";
try
{
try
{
desc.add_options()
("help,?","Display this help screen.")
("host,h",po::value<std::string>(),"Allows you to specify connection to a database on a machine other than the default.")
@ -56,17 +56,17 @@ int main ( int argc, char** argv)
("query,q",po::value<std::string>(),"Name of the table/or query to pass to postmaster")
("table,t",po::value<std::string>(),"Name of the output table to create (default: table in query)")
("file,f",po::value<std::string>(),"Use this option to specify the name of the file to create.")
;
//po::positional_options_description p;
//p.add("table",1);
po::variables_map vm;
//positional(p)
po::store(po::command_line_parser(argc,argv).options(desc).run(),vm);
po::notify(vm);
if (vm.count("help"))
{
std::cout << desc << "\n";
@ -80,31 +80,31 @@ int main ( int argc, char** argv)
std::cout << "Both --dbname, --file and, --query are required\n";
return EXIT_FAILURE;
}
boost::optional<std::string> host;
boost::optional<std::string> port ;
boost::optional<std::string> dbname;
boost::optional<std::string> user;
boost::optional<std::string> password;
boost::optional<std::string> connect_timeout("4");
if (vm.count("host")) host = vm["host"].as<std::string>();
if (vm.count("port")) port = vm["port"].as<std::string>();
if (vm.count("dbname")) dbname = vm["dbname"].as<std::string>();
if (vm.count("user")) user = vm["user"].as<std::string>();
if (vm.count("password")) password = vm["password"].as<std::string>();
ConnectionCreator<Connection> creator(host,port,dbname,user,password,connect_timeout);
try
try
{
boost::shared_ptr<Connection> conn(creator());
std::string query = vm["query"].as<std::string>();
std::string query = vm["query"].as<std::string>();
std::string output_table_name = vm.count("table") ? vm["table"].as<std::string>() : mapnik::sql_utils::table_from_sql(query);
std::string output_file = vm["file"].as<std::string>();
std::cout << "output_table : " << output_table_name << "\n";
mapnik::pgsql2sqlite(conn,query,output_table_name,output_file);
}
catch (mapnik::datasource_exception & ex)
@ -119,6 +119,6 @@ int main ( int argc, char** argv)
std::cerr << e.what() << "\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2009 Artem Pavlenko
@ -59,7 +59,7 @@ struct blob_to_hex
char hex[3];
std::memset(hex,0,3);
for ( unsigned pos=0; pos < size; ++pos)
{
{
std::sprintf (hex, "%02X", int(blob[pos]) & 0xff);
s << hex;
}
@ -67,33 +67,33 @@ struct blob_to_hex
}
};
*/
template <typename Connection>
void pgsql2sqlite(Connection conn,
std::string const& query,
std::string const& output_table_name,
void pgsql2sqlite(Connection conn,
std::string const& query,
std::string const& output_table_name,
std::string const& output_filename)
{
{
namespace sqlite = mapnik::sqlite;
sqlite::database db(output_filename);
boost::shared_ptr<ResultSet> rs = conn->executeQuery("select * from (" + query + ") as query limit 0;");
int count = rs->getNumFields();
std::ostringstream select_sql;
select_sql << "select ";
for (int i=0; i<count; ++i)
{
if (i!=0) select_sql << ",";
select_sql << "\"" << rs->getFieldName(i) << "\"";
}
select_sql << " from (" << query << ") as query";
std::string table_name = mapnik::sql_utils::table_from_sql(query);
std::string schema_name="";
std::string::size_type idx=table_name.find_last_of('.');
if (idx!=std::string::npos)
@ -105,7 +105,7 @@ void pgsql2sqlite(Connection conn,
{
table_name=table_name.substr(0);
}
std::ostringstream geom_col_sql;
geom_col_sql << "select f_geometry_column,srid,type from geometry_columns ";
geom_col_sql << "where f_table_name='" << table_name << "'";
@ -113,16 +113,16 @@ void pgsql2sqlite(Connection conn,
{
geom_col_sql <<" and f_table_schema='"<< schema_name <<"'";
}
rs = conn->executeQuery(geom_col_sql.str());
int srid = -1;
std::string geom_col = "UNKNOWN";
std::string geom_type = "UNKNOWN";
if ( rs->next())
{
try
try
{
srid = boost::lexical_cast<int>(rs->getValue("srid"));
}
@ -133,7 +133,7 @@ void pgsql2sqlite(Connection conn,
geom_col = rs->getValue("f_geometry_column");
geom_type = rs->getValue("type");
}
// add AsBinary(<geometry_column>) modifier
std::string select_sql_str = select_sql.str();
boost::algorithm::replace_all(select_sql_str, "\"" + geom_col + "\"","AsBinary(" + geom_col+") as " + geom_col);
@ -141,31 +141,31 @@ void pgsql2sqlite(Connection conn,
#ifdef MAPNIK_DEBUG
std::cout << select_sql_str << "\n";
#endif
std::ostringstream cursor_sql;
std::string cursor_name("my_cursor");
cursor_sql << "DECLARE " << cursor_name << " BINARY INSENSITIVE NO SCROLL CURSOR WITH HOLD FOR " << select_sql_str << " FOR READ ONLY";
conn->execute(cursor_sql.str());
boost::shared_ptr<CursorResultSet> cursor(new CursorResultSet(conn,cursor_name,10000));
unsigned num_fields = cursor->getNumFields();
if (num_fields == 0) return;
std::string feature_id = "fid";
std::ostringstream create_sql;
create_sql << "create table if not exists " << output_table_name << " (" << feature_id << " INTEGER PRIMARY KEY AUTOINCREMENT,";
int geometry_oid = -1;
std::string output_table_insert_sql = "insert into " + output_table_name + " values (?";
for ( unsigned pos = 0; pos < num_fields ; ++pos)
{
if (pos > 0)
if (pos > 0)
{
create_sql << ",";
}
@ -193,47 +193,47 @@ void pgsql2sqlite(Connection conn,
default:
create_sql << "' TEXT";
break;
}
}
}
}
create_sql << ");";
output_table_insert_sql +=")";
std::cout << "client_encoding=" << conn->client_encoding() << "\n";
std::cout << "geometry_column=" << geom_col << "(" << geom_type
std::cout << "geometry_column=" << geom_col << "(" << geom_type
<< ") srid=" << srid << " oid=" << geometry_oid << "\n";
db.execute("begin;");
// output table sql
db.execute(create_sql.str());
// spatial index sql
std::string spatial_index_sql = "create virtual table idx_" + output_table_name
std::string spatial_index_sql = "create virtual table idx_" + output_table_name
+ "_" + geom_col + " using rtree(pkid, xmin, xmax, ymin, ymax)";
db.execute(spatial_index_sql);
//blob_to_hex hex;
int pkid = 0;
std::string spatial_index_insert_sql = "insert into idx_" + output_table_name + "_"
std::string spatial_index_insert_sql = "insert into idx_" + output_table_name + "_"
+ geom_col + " values (?,?,?,?,?)" ;
sqlite::prepared_statement spatial_index(db,spatial_index_insert_sql);
#ifdef MAPNIK_DEBUG
std::cout << output_table_insert_sql << "\n";
#endif
sqlite::prepared_statement output_table(db,output_table_insert_sql);
while (cursor->next())
{
++pkid;
sqlite::record_type output_rec;
output_rec.push_back(sqlite::value_type(pkid));
bool empty_geom = true;
@ -245,7 +245,7 @@ void pgsql2sqlite(Connection conn,
int size=cursor->getFieldLength(pos);
int oid = cursor->getTypeOID(pos);
buf=cursor->getValue(pos);
switch (oid)
{
case 25:
@ -280,19 +280,19 @@ void pgsql2sqlite(Connection conn,
case 1700:
{
std::string str = mapnik::sql_utils::numeric2string(buf);
try
try
{
double val = boost::lexical_cast<double>(str);
output_rec.push_back(sqlite::value_type(val));
}
catch (boost::bad_lexical_cast & ex)
{
std::clog << ex.what() << "\n";
std::clog << ex.what() << "\n";
}
break;
}
default:
default:
{
if (oid == geometry_oid)
{
@ -305,46 +305,46 @@ void pgsql2sqlite(Connection conn,
if (bbox.valid())
{
sqlite::record_type rec;
rec.push_back(sqlite::value_type(pkid));
rec.push_back(sqlite::value_type(bbox.minx()));
rec.push_back(sqlite::value_type(bbox.maxx()));
rec.push_back(sqlite::value_type(bbox.miny()));
rec.push_back(sqlite::value_type(bbox.maxy()));
spatial_index.insert_record(rec);
empty_geom = false;
}
}
//output_rec.push_back(sqlite::value_type("X'" + hex(buf,size) + "'"));
output_rec.push_back(sqlite::blob(buf,size));
}
else
else
{
output_rec.push_back(sqlite::null_type());
}
break;
}
}
}
}
else
else
{
output_rec.push_back(sqlite::null_type());
}
}
}
if (!empty_geom) output_table.insert_record(output_rec);
if (pkid % 1000 == 0)
{
std::cout << "\r processing " << pkid << " features";
std::cout.flush();
}
if (pkid % 100000 == 0)
{
db.execute("commit;begin;");
db.execute("commit;begin;");
}
}
// commit

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2009 Artem Pavlenko
@ -33,17 +33,17 @@ namespace mapnik { namespace sqlite {
{
sqlite3_close(db);
throw;
}
}
db_ = sqlite_db(db,database_closer());
#ifdef MAPNIK_DEBUG
std::cerr << "Open database " << name << "\n";
#endif
}
database::~database() {}
bool database::execute(std::string const& sql)
bool database::execute(std::string const& sql)
{
char * err_msg;
int res = sqlite3_exec(db_.get(),sql.c_str(),0,0,&err_msg);

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2009 Artem Pavlenko
@ -30,7 +30,7 @@
//stl
//#ifdef MAPNIK_DEBUG
#include <iostream>
#include <iostream>
//#endif
#include <string>
#include <vector>
@ -40,7 +40,7 @@ namespace mapnik { namespace sqlite {
class database : private boost::noncopyable
{
friend class prepared_statement;
struct database_closer
{
void operator () (sqlite3 * db)
@ -51,10 +51,10 @@ namespace mapnik { namespace sqlite {
sqlite3_close(db);
}
};
typedef boost::shared_ptr<sqlite3> sqlite_db;
typedef boost::shared_ptr<sqlite3> sqlite_db;
sqlite_db db_;
public:
database(std::string const& name);
~database();
@ -62,25 +62,25 @@ namespace mapnik { namespace sqlite {
};
struct null_type {};
struct blob
struct blob
{
blob(const char* buf, unsigned size)
: buf_(buf), size_(size) {}
const char * buf_;
unsigned size_;
};
typedef boost::variant<int,double,std::string, blob,null_type> value_type;
typedef std::vector<value_type> record_type;
class prepared_statement : boost::noncopyable
class prepared_statement : boost::noncopyable
{
struct binder : public boost::static_visitor<bool>
{
binder(sqlite3_stmt * stmt, unsigned index)
: stmt_(stmt), index_(index) {}
bool operator() (null_type )
{
if (sqlite3_bind_null(stmt_, index_) != SQLITE_OK)
@ -90,7 +90,7 @@ namespace mapnik { namespace sqlite {
}
return true;
}
bool operator() (int val)
{
if (sqlite3_bind_int(stmt_, index_ , val ) != SQLITE_OK)
@ -100,7 +100,7 @@ namespace mapnik { namespace sqlite {
}
return true;
}
bool operator() (double val)
{
if (sqlite3_bind_double(stmt_, index_ , val ) != SQLITE_OK)
@ -110,7 +110,7 @@ namespace mapnik { namespace sqlite {
}
return true;
}
bool operator() (std::string const& val)
{
if (sqlite3_bind_text(stmt_, index_, val.c_str(), val.length(), SQLITE_STATIC) != SQLITE_OK)
@ -120,7 +120,7 @@ namespace mapnik { namespace sqlite {
}
return true;
}
bool operator() (blob const& val)
{
if (sqlite3_bind_blob(stmt_, index_, val.buf_, val.size_, SQLITE_STATIC) != SQLITE_OK)
@ -130,7 +130,7 @@ namespace mapnik { namespace sqlite {
}
return true;
}
sqlite3_stmt * stmt_;
unsigned index_;
};
@ -143,22 +143,22 @@ namespace mapnik { namespace sqlite {
int res = sqlite3_prepare_v2(db_, sql.c_str(),-1, &stmt_,&tail);
if (res != SQLITE_OK)
{
std::cerr << "ERR:"<< res << "\n";
std::cerr << "ERR:"<< res << "\n";
throw;
}
}
~prepared_statement()
{
int res = sqlite3_finalize(stmt_);
if (res != SQLITE_OK)
{
std::cerr << "ERR:" << res << "\n";
std::cerr << "ERR:" << res << "\n";
}
}
bool insert_record(record_type const& rec) const
{
{
#ifdef MAPNIK_DEBUG
assert( unsigned(sqlite3_bind_parameter_count(stmt_)) == rec.size());
#endif
@ -173,7 +173,7 @@ namespace mapnik { namespace sqlite {
return false;
}
}
sqlite3_step(stmt_);
sqlite3_reset(stmt_);

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko
@ -24,7 +24,7 @@
#ifndef QUADTREE_HPP
#define QUADTREE_HPP
// stl
#include <cstring>
#include <cstring>
#include <vector>
#include <fstream>
#include <iostream>
@ -46,29 +46,29 @@ struct quadtree_node
memset(children_,0,sizeof(quadtree_node<T>*)*4);
}
~quadtree_node()
~quadtree_node()
{
for (int i=0;i<4;++i)
for (int i=0;i<4;++i)
{
if (children_[i])
if (children_[i])
{
delete children_[i],children_[i]=0;
}
}
}
int num_subnodes() const
int num_subnodes() const
{
int count=0;
for (int i=0;i<4;++i)
for (int i=0;i<4;++i)
{
if (children_[i])
if (children_[i])
{
++count;
}
}
return count;
}
}
};
template <typename T>
@ -88,34 +88,34 @@ public:
{
if (root_) delete root_;
}
void insert(const T& data,const box2d<double>& item_ext)
{
insert(data,item_ext,root_,maxdepth_);
}
int count() const
{
return count_nodes(root_);
}
int count_items() const
int count_items() const
{
int count=0;
count_items(root_,count);
return count;
}
void print() const
{
print(root_);
}
void trim()
void trim()
{
trim_tree(root_);
}
}
void write(std::ostream& out)
{
char header[16];
@ -133,25 +133,25 @@ public:
private:
void trim_tree(quadtree_node<T>*& node)
{
if (node)
{
if (node)
{
for (int i=0;i<4;++i)
{
trim_tree(node->children_[i]);
{
trim_tree(node->children_[i]);
}
if (node->num_subnodes()==1 && node->data_.size()==0)
{
for (int i=0;i<4;++i)
for (int i=0;i<4;++i)
{
if (node->children_[i])
{
{
node=node->children_[i];
break;
break;
}
}
}
}
}
}
@ -176,11 +176,11 @@ private:
{
if (node)
{
count += node->data_.size();
count += node->data_.size();
for (int i=0;i<4;++i)
{
count_items(node->children_[i],count);
}
}
}
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko
@ -40,7 +40,7 @@ const double MINRATIO=0.5;
const double MAXRATIO=0.8;
const double DEFAULT_RATIO=0.55;
int main (int argc,char** argv)
int main (int argc,char** argv)
{
using namespace mapnik;
namespace po = boost::program_options;
@ -48,12 +48,12 @@ int main (int argc,char** argv)
using std::vector;
using std::clog;
using std::endl;
bool verbose=false;
unsigned int depth=DEFAULT_DEPTH;
double ratio=DEFAULT_RATIO;
vector<string> shape_files;
try
{
po::options_description desc("shapeindex utility");
@ -61,29 +61,29 @@ int main (int argc,char** argv)
("help,h", "produce usage message")
("version,V","print version string")
("verbose,v","verbose output")
("depth,d", po::value<unsigned int>(), "max tree depth\n(default 8)")
("depth,d", po::value<unsigned int>(), "max tree depth\n(default 8)")
("ratio,r",po::value<double>(),"split ratio (default 0.55)")
("shape_files",po::value<vector<string> >(),"shape files to index: file1 file2 ...fileN")
;
po::positional_options_description p;
p.add("shape_files",-1);
po::variables_map vm;
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
po::notify(vm);
if (vm.count("version"))
{
clog<<"version 0.3.0" <<std::endl;
return 1;
}
if (vm.count("help"))
if (vm.count("help"))
{
clog << desc << endl;
return 1;
}
if (vm.count("verbose"))
if (vm.count("verbose"))
{
verbose = true;
}
@ -95,7 +95,7 @@ int main (int argc,char** argv)
{
ratio = vm["ratio"].as<double>();
}
if (vm.count("shape_files"))
{
shape_files=vm["shape_files"].as< vector<string> >();
@ -106,10 +106,10 @@ int main (int argc,char** argv)
clog << "Exception of unknown type!" << endl;
return -1;
}
clog << "max tree depth:" << depth << endl;
clog << "split ratio:" << ratio << endl;
vector<string>::const_iterator itr = shape_files.begin();
if (itr == shape_files.end())
{
@ -135,33 +135,33 @@ int main (int argc,char** argv)
clog << "error : cannot open " << shapename_full << endl;
continue;
}
int code = shp.read_xdr_integer(); //file_code == 9994
clog << code << endl;
shp.skip(5*4);
shp.skip(5*4);
int file_length=shp.read_xdr_integer();
int version=shp.read_ndr_integer();
int shape_type=shp.read_ndr_integer();
box2d<double> extent;
shp.read_envelope(extent);
clog << "length=" << file_length << endl;
clog << "version=" << version << endl;
clog << "type=" << shape_type << endl;
clog << "extent:" << extent << endl;
int pos=50;
shp.seek(pos*2);
shp.seek(pos*2);
quadtree<int> tree(extent,depth,ratio);
int count=0;
while (true) {
long offset=shp.pos();
int record_number=shp.read_xdr_integer();
int content_length=shp.read_xdr_integer();
shape_type = shp.read_ndr_integer();
shape_type = shp.read_ndr_integer();
box2d<double> item_ext;
if (shape_type==shape_io::shape_null)
{
@ -172,7 +172,7 @@ int main (int argc,char** argv)
double x=shp.read_double();
double y=shp.read_double();
item_ext=box2d<double>(x,y,x,y);
}
else if (shape_type==shape_io::shape_pointm)
{
@ -181,7 +181,7 @@ int main (int argc,char** argv)
// skip m
shp.read_double();
item_ext=box2d<double>(x,y,x,y);
}
else if (shape_type==shape_io::shape_pointz)
{
@ -190,19 +190,19 @@ int main (int argc,char** argv)
// skip z
shp.read_double();
//skip m if exists
if ( content_length == 8 + 36)
if ( content_length == 8 + 36)
{
shp.read_double();
}
item_ext=box2d<double>(x,y,x,y);
}
else
{
else
{
shp.read_envelope(item_ext);
shp.skip(2*content_length-4*8-4);
}
tree.insert(offset,item_ext);
if (verbose) {
clog << "record number " << record_number << " box=" << item_ext << endl;
@ -213,15 +213,15 @@ int main (int argc,char** argv)
if (pos>=file_length) {
break;
}
}
clog << " number shapes=" << count << endl;
}
}
clog << " number shapes=" << count << endl;
std::fstream file((shapename+".index").c_str(),
std::ios::in | std::ios::out | std::ios::trunc | std::ios::binary);
if (!file) {
clog << "cannot open index file for writing file \""
clog << "cannot open index file for writing file \""
<< (shapename+".index") << "\"" << endl;
} else {
tree.trim();
@ -232,7 +232,7 @@ int main (int argc,char** argv)
file.close();
}
}
clog << "done!" << endl;
return 0;
}

View file

@ -1,5 +1,5 @@
/*****************************************************************************
*
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2010 Artem Pavlenko
@ -45,13 +45,13 @@
#include "agg_scanline_u.h"
int main (int argc,char** argv)
int main (int argc,char** argv)
{
namespace po = boost::program_options;
bool verbose=false;
std::vector<std::string> svg_files;
try
{
po::options_description desc("svg2png utility");
@ -61,10 +61,10 @@ int main (int argc,char** argv)
("verbose,v","verbose output")
("svg",po::value<std::vector<std::string> >(),"svg file to read")
;
po::positional_options_description p;
p.add("svg",-1);
po::variables_map vm;
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
po::notify(vm);
@ -74,12 +74,12 @@ int main (int argc,char** argv)
return 1;
}
if (vm.count("help"))
if (vm.count("help"))
{
std::clog << desc << std::endl;
return 1;
}
if (vm.count("verbose"))
if (vm.count("verbose"))
{
verbose = true;
}
@ -107,10 +107,10 @@ int main (int argc,char** argv)
boost::optional<mapnik::marker_ptr> marker_ptr = mapnik::marker_cache::instance()->find(svg_name, false);
if (marker_ptr) {
mapnik::marker marker = **marker_ptr;
if (marker.is_vector()) {
typedef agg::pixfmt_rgba32_plain pixfmt;
typedef agg::renderer_base<pixfmt> renderer_base;
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
@ -138,10 +138,10 @@ int main (int argc,char** argv)
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage((*marker.get_vector_data())->source());
mapnik::svg::svg_path_adapter svg_path(stl_storage);
mapnik::svg::svg_renderer<mapnik::svg::svg_path_adapter,
agg::pod_bvector<mapnik::svg::path_attributes>,
renderer_solid,
agg::pixfmt_rgba32_plain > svg_renderer_this(svg_path,
(*marker.get_vector_data())->attributes());
agg::pod_bvector<mapnik::svg::path_attributes>,
renderer_solid,
agg::pixfmt_rgba32_plain > svg_renderer_this(svg_path,
(*marker.get_vector_data())->attributes());
svg_renderer_this.render(ras_ptr, sl, renb, mtx, opacity, bbox);