python bindings: reduce compile times by consolidating code in fewer cpp files
This commit is contained in:
parent
b08908b5f4
commit
fe5b3713ba
23 changed files with 775 additions and 1195 deletions
|
@ -1,52 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2012 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/attribute.hpp>
|
||||
#include <mapnik/building_symbolizer.hpp>
|
||||
|
||||
using namespace mapnik;
|
||||
using mapnik::building_symbolizer;
|
||||
using mapnik::color;
|
||||
|
||||
void export_building_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
class_<building_symbolizer>("BuildingSymbolizer",
|
||||
init<>("Default BuildingSymbolizer"))
|
||||
.add_property("fill",make_function
|
||||
(&building_symbolizer::get_fill,
|
||||
return_value_policy<copy_const_reference>()),
|
||||
&building_symbolizer::set_fill)
|
||||
.add_property("fill_opacity",
|
||||
&building_symbolizer::get_opacity,
|
||||
&building_symbolizer::set_opacity)
|
||||
.add_property("height",
|
||||
make_function(&building_symbolizer::height,
|
||||
return_value_policy<copy_const_reference>()),
|
||||
&building_symbolizer::set_height,
|
||||
"Set/get the building height")
|
||||
;
|
||||
|
||||
}
|
|
@ -22,17 +22,13 @@
|
|||
|
||||
// boost
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/detail/api_placeholder.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
// stl
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/box2d.hpp>
|
||||
#include <mapnik/coord.hpp>
|
||||
#include <mapnik/query.hpp>
|
||||
#include <mapnik/datasource.hpp>
|
||||
#include <mapnik/datasource_cache.hpp>
|
||||
#include <mapnik/feature_layer_desc.hpp>
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2013 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include "mapnik_enumeration.hpp"
|
||||
#include <mapnik/debug_symbolizer.hpp>
|
||||
|
||||
void export_debug_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
mapnik::enumeration_<mapnik::debug_symbolizer_mode_e>("debug_symbolizer_mode")
|
||||
.value("COLLISION",mapnik::DEBUG_SYM_MODE_COLLISION)
|
||||
.value("VERTEX",mapnik::DEBUG_SYM_MODE_VERTEX)
|
||||
;
|
||||
|
||||
class_<mapnik::debug_symbolizer>("DebugSymbolizer",
|
||||
init<>("Default debug Symbolizer"))
|
||||
.add_property("mode",
|
||||
&mapnik::debug_symbolizer::get_mode,
|
||||
&mapnik::debug_symbolizer::set_mode)
|
||||
;
|
||||
}
|
|
@ -22,6 +22,11 @@
|
|||
#ifndef MAPNIK_PYTHON_BINDING_ENUMERATION_INCLUDED
|
||||
#define MAPNIK_PYTHON_BINDING_ENUMERATION_INCLUDED
|
||||
|
||||
#include <boost/python/converter/registered.hpp> // for registered
|
||||
#include <boost/python/enum.hpp> // for enum_
|
||||
#include <boost/python/implicit.hpp> // for implicitly_convertible
|
||||
#include <boost/python/to_python_converter.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename EnumWrapper>
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
// boost
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/detail/api_placeholder.hpp>
|
||||
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
|
||||
|
||||
// mapnik
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/python.hpp>
|
||||
|
||||
#include <mapnik/line_pattern_symbolizer.hpp>
|
||||
#include <mapnik/parse_path.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include "mapnik_svg.hpp"
|
||||
|
||||
using mapnik::line_pattern_symbolizer;
|
||||
using mapnik::path_processor_type;
|
||||
using mapnik::path_expression_ptr;
|
||||
using mapnik::guess_type;
|
||||
using mapnik::parse_path;
|
||||
|
||||
|
||||
namespace {
|
||||
using namespace boost::python;
|
||||
|
||||
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 export_line_pattern_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
class_<line_pattern_symbolizer>("LinePatternSymbolizer",
|
||||
init<path_expression_ptr>
|
||||
("<image file expression>"))
|
||||
.add_property("transform",
|
||||
mapnik::get_svg_transform<line_pattern_symbolizer>,
|
||||
mapnik::set_svg_transform<line_pattern_symbolizer>)
|
||||
.add_property("filename",
|
||||
&get_filename,
|
||||
&set_filename)
|
||||
.add_property("offset",
|
||||
&line_pattern_symbolizer::offset,
|
||||
&line_pattern_symbolizer::set_offset,
|
||||
"Set/get the offset")
|
||||
.add_property("comp_op",
|
||||
&line_pattern_symbolizer::comp_op,
|
||||
&line_pattern_symbolizer::set_comp_op,
|
||||
"Set/get the comp-op")
|
||||
.add_property("clip",
|
||||
&line_pattern_symbolizer::clip,
|
||||
&line_pattern_symbolizer::set_clip,
|
||||
"Set/get the line pattern geometry's clipping status")
|
||||
.add_property("smooth",
|
||||
&line_pattern_symbolizer::smooth,
|
||||
&line_pattern_symbolizer::set_smooth,
|
||||
"smooth value (0..1.0)")
|
||||
;
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include "mapnik_enumeration.hpp"
|
||||
#include <mapnik/line_symbolizer.hpp>
|
||||
#include <mapnik/symbolizer_hash.hpp>
|
||||
|
||||
using namespace mapnik;
|
||||
using mapnik::line_symbolizer;
|
||||
using mapnik::stroke;
|
||||
using mapnik::color;
|
||||
|
||||
std::size_t line_symbolizer_hash(line_symbolizer const& sym)
|
||||
{
|
||||
return symbolizer_hash::value(sym);
|
||||
}
|
||||
|
||||
|
||||
void export_line_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
enumeration_<line_rasterizer_e>("line_rasterizer")
|
||||
.value("FULL",RASTERIZER_FULL)
|
||||
.value("FAST",RASTERIZER_FAST)
|
||||
;
|
||||
class_<line_symbolizer>("LineSymbolizer",
|
||||
init<>("Default LineSymbolizer - 1px solid black"))
|
||||
.def(init<stroke const&>("TODO"))
|
||||
.def(init<color const& ,float>())
|
||||
.add_property("rasterizer",
|
||||
&line_symbolizer::get_rasterizer,
|
||||
&line_symbolizer::set_rasterizer,
|
||||
"Set/get the rasterization method of the line of the point")
|
||||
.add_property("stroke",make_function
|
||||
(&line_symbolizer::get_stroke,
|
||||
return_value_policy<reference_existing_object>()),
|
||||
&line_symbolizer::set_stroke)
|
||||
.add_property("simplify_tolerance",
|
||||
&line_symbolizer::simplify_tolerance,
|
||||
&line_symbolizer::set_simplify_tolerance,
|
||||
"simplification tolerance measure")
|
||||
.add_property("offset",
|
||||
&line_symbolizer::offset,
|
||||
&line_symbolizer::set_offset,
|
||||
"offset value")
|
||||
.add_property("comp_op",
|
||||
&line_symbolizer::comp_op,
|
||||
&line_symbolizer::set_comp_op,
|
||||
"Set/get the comp-op")
|
||||
.add_property("clip",
|
||||
&line_symbolizer::clip,
|
||||
&line_symbolizer::set_clip,
|
||||
"Set/get the line geometry's clipping status")
|
||||
.add_property("smooth",
|
||||
&line_symbolizer::smooth,
|
||||
&line_symbolizer::set_smooth,
|
||||
"smooth value (0..1.0)")
|
||||
.def("__hash__", line_symbolizer_hash)
|
||||
;
|
||||
}
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
// boost
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/detail/api_placeholder.hpp>
|
||||
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
|
||||
#include <boost/python/iterator.hpp>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
|
|
|
@ -1,162 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2010 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/python.hpp>
|
||||
|
||||
#include <mapnik/graphics.hpp>
|
||||
#include <mapnik/expression_node.hpp>
|
||||
#include <mapnik/value_error.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/markers_symbolizer.hpp>
|
||||
#include <mapnik/parse_path.hpp>
|
||||
#include "mapnik_svg.hpp"
|
||||
#include "mapnik_enumeration.hpp"
|
||||
#include "python_optional.hpp"
|
||||
|
||||
#include <mapnik/marker_cache.hpp> // for known_svg_prefix_
|
||||
|
||||
using mapnik::markers_symbolizer;
|
||||
using mapnik::symbolizer_with_image;
|
||||
using mapnik::path_processor_type;
|
||||
using mapnik::parse_path;
|
||||
|
||||
namespace {
|
||||
using namespace boost::python;
|
||||
|
||||
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_marker_type(mapnik::markers_symbolizer & symbolizer, std::string const& marker_type)
|
||||
{
|
||||
std::string filename;
|
||||
if (marker_type == "ellipse")
|
||||
{
|
||||
filename = mapnik::marker_cache::instance().known_svg_prefix_ + "ellipse";
|
||||
}
|
||||
else if (marker_type == "arrow")
|
||||
{
|
||||
filename = mapnik::marker_cache::instance().known_svg_prefix_ + "arrow";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw mapnik::value_error("Unknown marker-type: '" + marker_type + "'");
|
||||
}
|
||||
symbolizer.set_filename(parse_path(filename));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void export_markers_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
mapnik::enumeration_<mapnik::marker_placement_e>("marker_placement")
|
||||
.value("POINT_PLACEMENT",mapnik::MARKER_POINT_PLACEMENT)
|
||||
.value("INTERIOR_PLACEMENT",mapnik::MARKER_INTERIOR_PLACEMENT)
|
||||
.value("LINE_PLACEMENT",mapnik::MARKER_LINE_PLACEMENT)
|
||||
;
|
||||
|
||||
mapnik::enumeration_<mapnik::marker_multi_policy_e>("marker_multi_policy")
|
||||
.value("EACH",mapnik::MARKER_EACH_MULTI)
|
||||
.value("WHOLE",mapnik::MARKER_WHOLE_MULTI)
|
||||
.value("LARGEST",mapnik::MARKER_LARGEST_MULTI)
|
||||
;
|
||||
|
||||
class_<markers_symbolizer>("MarkersSymbolizer",
|
||||
init<>("Default Markers Symbolizer - circle"))
|
||||
.def (init<mapnik::path_expression_ptr>("<path expression ptr>"))
|
||||
.add_property("filename",
|
||||
&get_filename,
|
||||
&set_filename)
|
||||
.add_property("marker_type",
|
||||
&get_filename,
|
||||
&set_marker_type)
|
||||
.add_property("allow_overlap",
|
||||
&markers_symbolizer::get_allow_overlap,
|
||||
&markers_symbolizer::set_allow_overlap)
|
||||
.add_property("spacing",
|
||||
&markers_symbolizer::get_spacing,
|
||||
&markers_symbolizer::set_spacing)
|
||||
.add_property("max_error",
|
||||
&markers_symbolizer::get_max_error,
|
||||
&markers_symbolizer::set_max_error)
|
||||
.add_property("opacity",
|
||||
&markers_symbolizer::get_opacity,
|
||||
&markers_symbolizer::set_opacity,
|
||||
"Set/get the overall opacity")
|
||||
.add_property("fill_opacity",
|
||||
&markers_symbolizer::get_fill_opacity,
|
||||
&markers_symbolizer::set_fill_opacity,
|
||||
"Set/get the fill opacity")
|
||||
.add_property("ignore_placement",
|
||||
&markers_symbolizer::get_ignore_placement,
|
||||
&markers_symbolizer::set_ignore_placement)
|
||||
.add_property("transform",
|
||||
&mapnik::get_svg_transform<markers_symbolizer>,
|
||||
&mapnik::set_svg_transform<markers_symbolizer>)
|
||||
.add_property("width",
|
||||
make_function(&markers_symbolizer::get_width,
|
||||
return_value_policy<copy_const_reference>()),
|
||||
&markers_symbolizer::set_width,
|
||||
"Set/get the marker width")
|
||||
.add_property("height",
|
||||
make_function(&markers_symbolizer::get_height,
|
||||
return_value_policy<copy_const_reference>()),
|
||||
&markers_symbolizer::set_height,
|
||||
"Set/get the marker height")
|
||||
.add_property("fill",
|
||||
&markers_symbolizer::get_fill,
|
||||
&markers_symbolizer::set_fill,
|
||||
"Set/get the marker fill color")
|
||||
.add_property("stroke",
|
||||
&markers_symbolizer::get_stroke,
|
||||
&markers_symbolizer::set_stroke,
|
||||
"Set/get the marker stroke (outline)")
|
||||
.add_property("placement",
|
||||
&markers_symbolizer::get_marker_placement,
|
||||
&markers_symbolizer::set_marker_placement,
|
||||
"Set/get the marker placement")
|
||||
.add_property("multi_policy",
|
||||
&markers_symbolizer::get_marker_multi_policy,
|
||||
&markers_symbolizer::set_marker_multi_policy,
|
||||
"Set/get the marker multi geometry rendering policy")
|
||||
.add_property("comp_op",
|
||||
&markers_symbolizer::comp_op,
|
||||
&markers_symbolizer::set_comp_op,
|
||||
"Set/get the marker comp-op")
|
||||
.add_property("clip",
|
||||
&markers_symbolizer::clip,
|
||||
&markers_symbolizer::set_clip,
|
||||
"Set/get the marker geometry's clipping status")
|
||||
.add_property("smooth",
|
||||
&markers_symbolizer::smooth,
|
||||
&markers_symbolizer::set_smooth,
|
||||
"Set/get the marker geometry's smooth value")
|
||||
;
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include "mapnik_enumeration.hpp"
|
||||
#include <mapnik/graphics.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/point_symbolizer.hpp>
|
||||
#include <mapnik/parse_path.hpp>
|
||||
#include "mapnik_svg.hpp"
|
||||
|
||||
using namespace mapnik;
|
||||
using mapnik::point_symbolizer;
|
||||
using mapnik::symbolizer_with_image;
|
||||
using mapnik::path_processor_type;
|
||||
using mapnik::parse_path;
|
||||
|
||||
|
||||
namespace {
|
||||
using namespace boost::python;
|
||||
|
||||
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 export_point_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
enumeration_<point_placement_e>("point_placement")
|
||||
.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>"))
|
||||
.add_property("filename",
|
||||
&get_filename,
|
||||
&set_filename)
|
||||
.add_property("allow_overlap",
|
||||
&point_symbolizer::get_allow_overlap,
|
||||
&point_symbolizer::set_allow_overlap)
|
||||
.add_property("opacity",
|
||||
&point_symbolizer::get_opacity,
|
||||
&point_symbolizer::set_opacity)
|
||||
.add_property("ignore_placement",
|
||||
&point_symbolizer::get_ignore_placement,
|
||||
&point_symbolizer::set_ignore_placement)
|
||||
.add_property("placement",
|
||||
&point_symbolizer::get_point_placement,
|
||||
&point_symbolizer::set_point_placement,
|
||||
"Set/get the placement of the point")
|
||||
.add_property("transform",
|
||||
mapnik::get_svg_transform<point_symbolizer>,
|
||||
mapnik::set_svg_transform<point_symbolizer>)
|
||||
.add_property("comp_op",
|
||||
&point_symbolizer::comp_op,
|
||||
&point_symbolizer::set_comp_op,
|
||||
"Set/get the comp-op")
|
||||
;
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/polygon_pattern_symbolizer.hpp>
|
||||
#include "mapnik_enumeration.hpp"
|
||||
#include <mapnik/parse_path.hpp>
|
||||
#include "mapnik_svg.hpp"
|
||||
|
||||
using namespace mapnik;
|
||||
using mapnik::polygon_pattern_symbolizer;
|
||||
using mapnik::path_expression_ptr;
|
||||
using mapnik::path_processor_type;
|
||||
using mapnik::parse_path;
|
||||
using mapnik::guess_type;
|
||||
|
||||
namespace {
|
||||
using namespace boost::python;
|
||||
|
||||
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 export_polygon_pattern_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
enumeration_<pattern_alignment_e>("pattern_alignment")
|
||||
.value("LOCAL",LOCAL_ALIGNMENT)
|
||||
.value("GLOBAL",GLOBAL_ALIGNMENT)
|
||||
;
|
||||
|
||||
class_<polygon_pattern_symbolizer>("PolygonPatternSymbolizer",
|
||||
init<path_expression_ptr>("<path_expression_ptr>"))
|
||||
.add_property("alignment",
|
||||
&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>)
|
||||
.add_property("filename",
|
||||
&get_filename,
|
||||
&set_filename)
|
||||
.add_property("opacity",
|
||||
&polygon_pattern_symbolizer::get_opacity,
|
||||
&polygon_pattern_symbolizer::set_opacity)
|
||||
.add_property("gamma",
|
||||
&polygon_pattern_symbolizer::get_gamma,
|
||||
&polygon_pattern_symbolizer::set_gamma)
|
||||
.add_property("gamma_method",
|
||||
&polygon_pattern_symbolizer::get_gamma_method,
|
||||
&polygon_pattern_symbolizer::set_gamma_method,
|
||||
"Set/get the gamma correction method of the polygon")
|
||||
.add_property("comp_op",
|
||||
&polygon_pattern_symbolizer::comp_op,
|
||||
&polygon_pattern_symbolizer::set_comp_op,
|
||||
"Set/get the pattern comp-op")
|
||||
.add_property("clip",
|
||||
&polygon_pattern_symbolizer::clip,
|
||||
&polygon_pattern_symbolizer::set_clip,
|
||||
"Set/get the pattern geometry's clipping status")
|
||||
.add_property("smooth",
|
||||
&polygon_pattern_symbolizer::smooth,
|
||||
&polygon_pattern_symbolizer::set_smooth,
|
||||
"Set/get the pattern geometry's smooth value")
|
||||
;
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <mapnik/polygon_symbolizer.hpp>
|
||||
#include <mapnik/symbolizer_hash.hpp>
|
||||
|
||||
using namespace mapnik;
|
||||
using mapnik::polygon_symbolizer;
|
||||
using mapnik::color;
|
||||
|
||||
std::size_t polygon_symbolizer_hash(polygon_symbolizer const& sym)
|
||||
{
|
||||
return symbolizer_hash::value(sym);
|
||||
}
|
||||
|
||||
void export_polygon_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
class_<polygon_symbolizer>("PolygonSymbolizer",
|
||||
init<>("Default PolygonSymbolizer - solid fill grey"))
|
||||
.def(init<color const&>("TODO"))
|
||||
.add_property("fill",make_function
|
||||
(&polygon_symbolizer::get_fill,
|
||||
return_value_policy<copy_const_reference>()),
|
||||
&polygon_symbolizer::set_fill)
|
||||
.add_property("fill_opacity",
|
||||
&polygon_symbolizer::get_opacity,
|
||||
&polygon_symbolizer::set_opacity)
|
||||
.add_property("gamma",
|
||||
&polygon_symbolizer::get_gamma,
|
||||
&polygon_symbolizer::set_gamma)
|
||||
.add_property("gamma_method",
|
||||
&polygon_symbolizer::get_gamma_method,
|
||||
&polygon_symbolizer::set_gamma_method,
|
||||
"gamma correction method")
|
||||
.add_property("comp_op",
|
||||
&polygon_symbolizer::comp_op,
|
||||
&polygon_symbolizer::set_comp_op,
|
||||
"Set/get the polygon comp-op")
|
||||
.add_property("clip",
|
||||
&polygon_symbolizer::clip,
|
||||
&polygon_symbolizer::set_clip,
|
||||
"Set/get the polygon geometry's clipping status")
|
||||
.add_property("smooth",
|
||||
&polygon_symbolizer::smooth,
|
||||
&polygon_symbolizer::set_smooth,
|
||||
"Set/get the polygon geometry's smooth value")
|
||||
.add_property("simplify_tolerance",
|
||||
&polygon_symbolizer::simplify_tolerance,
|
||||
&polygon_symbolizer::set_simplify_tolerance,
|
||||
"simplfication tolerance measure")
|
||||
.def("__hash__", polygon_symbolizer_hash)
|
||||
;
|
||||
|
||||
}
|
|
@ -20,15 +20,22 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/get_pointer.hpp>
|
||||
#include <boost/python/detail/api_placeholder.hpp>
|
||||
#include <boost/python/args.hpp> // for keywords, arg, etc
|
||||
#include <boost/python/converter/from_python.hpp>
|
||||
#include <boost/python/def.hpp> // for def
|
||||
#include <boost/python/detail/defaults_gen.hpp>
|
||||
#include <boost/python/detail/none.hpp> // for none
|
||||
#include <boost/python/dict.hpp> // for dict
|
||||
#include <boost/python/exception_translator.hpp>
|
||||
#include <boost/python/list.hpp> // for list
|
||||
#include <boost/python/module.hpp> // for BOOST_PYTHON_MODULE
|
||||
#include <boost/python/object_core.hpp> // for get_managed_object
|
||||
#include <boost/python/register_ptr_to_python.hpp>
|
||||
#include <boost/python/to_python_converter.hpp>
|
||||
|
||||
// stl
|
||||
#include <stdexcept>
|
||||
|
||||
void register_cairo();
|
||||
void export_color();
|
||||
void export_coord();
|
||||
void export_layer();
|
||||
|
@ -78,20 +85,12 @@ void export_logger();
|
|||
void export_wkt_reader();
|
||||
|
||||
#include <mapnik/version.hpp>
|
||||
#include <mapnik/value_error.hpp>
|
||||
#include <mapnik/layer.hpp>
|
||||
#include <mapnik/map.hpp>
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
#ifdef HAVE_CAIRO
|
||||
#include <mapnik/cairo_renderer.hpp>
|
||||
#endif
|
||||
#include <mapnik/graphics.hpp>
|
||||
#include <mapnik/stroke.hpp>
|
||||
#include <mapnik/font_set.hpp>
|
||||
#include <mapnik/rule.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/load_map.hpp>
|
||||
#include <mapnik/scale_denominator.hpp>
|
||||
#include <mapnik/value_error.hpp>
|
||||
#include <mapnik/save_map.hpp>
|
||||
#include <mapnik/scale_denominator.hpp>
|
||||
|
@ -106,6 +105,13 @@ void export_wkt_reader();
|
|||
#include <mapnik/mapped_memory_cache.hpp>
|
||||
#endif
|
||||
|
||||
namespace mapnik {
|
||||
class font_set;
|
||||
class stroke;
|
||||
class layer;
|
||||
class color;
|
||||
class label_collision_detector4;
|
||||
}
|
||||
void clear_cache()
|
||||
{
|
||||
mapnik::marker_cache::instance().clear();
|
||||
|
@ -115,9 +121,48 @@ void clear_cache()
|
|||
}
|
||||
|
||||
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
||||
#include <mapnik/cairo_renderer.hpp>
|
||||
#include <boost/python/type_id.hpp>
|
||||
#include <boost/python/converter/registry.hpp>
|
||||
#include <pycairo.h>
|
||||
#include <cairo.h>
|
||||
static Pycairo_CAPI_t *Pycairo_CAPI;
|
||||
static void *extract_surface(PyObject* op)
|
||||
{
|
||||
if (PyObject_TypeCheck(op, const_cast<PyTypeObject*>(Pycairo_CAPI->Surface_Type)))
|
||||
{
|
||||
return op;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void *extract_context(PyObject* op)
|
||||
{
|
||||
if (PyObject_TypeCheck(op, const_cast<PyTypeObject*>(Pycairo_CAPI->Context_Type)))
|
||||
{
|
||||
return op;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void register_cairo()
|
||||
{
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
Pycairo_CAPI = (Pycairo_CAPI_t*) PyCapsule_Import(const_cast<char *>("cairo.CAPI"), 0);
|
||||
#else
|
||||
Pycairo_CAPI = (Pycairo_CAPI_t*) PyCObject_Import(const_cast<char *>("cairo"), const_cast<char *>("CAPI"));
|
||||
#endif
|
||||
if (Pycairo_CAPI == NULL) return;
|
||||
|
||||
boost::python::converter::registry::insert(&extract_surface, boost::python::type_id<PycairoSurface>());
|
||||
boost::python::converter::registry::insert(&extract_context, boost::python::type_id<PycairoContext>());
|
||||
}
|
||||
#endif
|
||||
|
||||
using mapnik::python_thread;
|
||||
|
@ -127,7 +172,7 @@ bool python_thread::thread_support = true;
|
|||
#endif
|
||||
boost::thread_specific_ptr<PyThreadState> python_thread::state;
|
||||
|
||||
void render(const mapnik::Map& map,
|
||||
void render(mapnik::Map const& map,
|
||||
mapnik::image_32& image,
|
||||
double scale_factor = 1.0,
|
||||
unsigned offset_x = 0u,
|
||||
|
@ -140,7 +185,7 @@ void render(const mapnik::Map& map,
|
|||
}
|
||||
|
||||
void render_with_detector(
|
||||
const mapnik::Map &map,
|
||||
mapnik::Map const& map,
|
||||
mapnik::image_32 &image,
|
||||
boost::shared_ptr<mapnik::label_collision_detector4> detector,
|
||||
double scale_factor = 1.0,
|
||||
|
@ -152,7 +197,7 @@ void render_with_detector(
|
|||
ren.apply();
|
||||
}
|
||||
|
||||
void render_layer2(const mapnik::Map& map,
|
||||
void render_layer2(mapnik::Map const& map,
|
||||
mapnik::image_32& image,
|
||||
unsigned layer_idx)
|
||||
{
|
||||
|
@ -174,7 +219,7 @@ void render_layer2(const mapnik::Map& map,
|
|||
|
||||
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
||||
|
||||
void render3(const mapnik::Map& map,
|
||||
void render3(mapnik::Map const& map,
|
||||
PycairoSurface* py_surface,
|
||||
double scale_factor = 1.0,
|
||||
unsigned offset_x = 0,
|
||||
|
@ -186,7 +231,7 @@ void render3(const mapnik::Map& map,
|
|||
ren.apply();
|
||||
}
|
||||
|
||||
void render4(const mapnik::Map& map, PycairoSurface* py_surface)
|
||||
void render4(mapnik::Map const& map, PycairoSurface* py_surface)
|
||||
{
|
||||
python_unblock_auto_block b;
|
||||
mapnik::cairo_surface_ptr surface(cairo_surface_reference(py_surface->surface), mapnik::cairo_surface_closer());
|
||||
|
@ -194,7 +239,7 @@ void render4(const mapnik::Map& map, PycairoSurface* py_surface)
|
|||
ren.apply();
|
||||
}
|
||||
|
||||
void render5(const mapnik::Map& map,
|
||||
void render5(mapnik::Map const& map,
|
||||
PycairoContext* py_context,
|
||||
double scale_factor = 1.0,
|
||||
unsigned offset_x = 0,
|
||||
|
@ -206,7 +251,7 @@ void render5(const mapnik::Map& map,
|
|||
ren.apply();
|
||||
}
|
||||
|
||||
void render6(const mapnik::Map& map, PycairoContext* py_context)
|
||||
void render6(mapnik::Map const& map, PycairoContext* py_context)
|
||||
{
|
||||
python_unblock_auto_block b;
|
||||
mapnik::cairo_ptr context(cairo_reference(py_context->ctx), mapnik::cairo_closer());
|
||||
|
@ -215,7 +260,7 @@ void render6(const mapnik::Map& map, PycairoContext* py_context)
|
|||
}
|
||||
|
||||
void render_with_detector2(
|
||||
const mapnik::Map& map,
|
||||
mapnik::Map const& map,
|
||||
PycairoContext* py_context,
|
||||
boost::shared_ptr<mapnik::label_collision_detector4> detector)
|
||||
{
|
||||
|
@ -226,7 +271,7 @@ void render_with_detector2(
|
|||
}
|
||||
|
||||
void render_with_detector3(
|
||||
const mapnik::Map& map,
|
||||
mapnik::Map const& map,
|
||||
PycairoContext* py_context,
|
||||
boost::shared_ptr<mapnik::label_collision_detector4> detector,
|
||||
double scale_factor = 1.0,
|
||||
|
@ -240,7 +285,7 @@ void render_with_detector3(
|
|||
}
|
||||
|
||||
void render_with_detector4(
|
||||
const mapnik::Map& map,
|
||||
mapnik::Map const& map,
|
||||
PycairoSurface* py_surface,
|
||||
boost::shared_ptr<mapnik::label_collision_detector4> detector)
|
||||
{
|
||||
|
@ -251,7 +296,7 @@ void render_with_detector4(
|
|||
}
|
||||
|
||||
void render_with_detector5(
|
||||
const mapnik::Map& map,
|
||||
mapnik::Map const& map,
|
||||
PycairoSurface* py_surface,
|
||||
boost::shared_ptr<mapnik::label_collision_detector4> detector,
|
||||
double scale_factor = 1.0,
|
||||
|
@ -267,7 +312,7 @@ void render_with_detector5(
|
|||
#endif
|
||||
|
||||
|
||||
void render_tile_to_file(const mapnik::Map& map,
|
||||
void render_tile_to_file(mapnik::Map const& map,
|
||||
unsigned offset_x, unsigned offset_y,
|
||||
unsigned width, unsigned height,
|
||||
std::string const& file,
|
||||
|
@ -278,7 +323,7 @@ void render_tile_to_file(const mapnik::Map& map,
|
|||
mapnik::save_to_file(image.data(),file,format);
|
||||
}
|
||||
|
||||
void render_to_file1(const mapnik::Map& map,
|
||||
void render_to_file1(mapnik::Map const& map,
|
||||
std::string const& filename,
|
||||
std::string const& format)
|
||||
{
|
||||
|
@ -298,7 +343,7 @@ void render_to_file1(const mapnik::Map& map,
|
|||
}
|
||||
}
|
||||
|
||||
void render_to_file2(const mapnik::Map& map,std::string const& filename)
|
||||
void render_to_file2(mapnik::Map const& map,std::string const& filename)
|
||||
{
|
||||
std::string format = mapnik::guess_type(filename);
|
||||
if (format == "pdf" || format == "svg" || format =="ps")
|
||||
|
@ -317,7 +362,7 @@ void render_to_file2(const mapnik::Map& map,std::string const& filename)
|
|||
}
|
||||
}
|
||||
|
||||
void render_to_file3(const mapnik::Map& map,
|
||||
void render_to_file3(mapnik::Map const& map,
|
||||
std::string const& filename,
|
||||
std::string const& format,
|
||||
double scale_factor = 1.0
|
||||
|
@ -339,7 +384,7 @@ void render_to_file3(const mapnik::Map& map,
|
|||
}
|
||||
}
|
||||
|
||||
double scale_denominator(mapnik::Map const &map, bool geographic)
|
||||
double scale_denominator(mapnik::Map const& map, bool geographic)
|
||||
{
|
||||
return mapnik::scale_denominator(map.scale(), geographic);
|
||||
}
|
||||
|
@ -494,7 +539,9 @@ BOOST_PYTHON_MODULE(_mapnik)
|
|||
register_exception_translator<std::out_of_range>(&out_of_range_error_translator);
|
||||
register_exception_translator<mapnik::value_error>(&value_error_translator);
|
||||
register_exception_translator<std::runtime_error>(&runtime_error_translator);
|
||||
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
||||
register_cairo();
|
||||
#endif
|
||||
export_query();
|
||||
export_geometry();
|
||||
export_feature();
|
||||
|
|
|
@ -1,136 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
// boost
|
||||
#include <boost/python.hpp>
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/raster_symbolizer.hpp>
|
||||
#include <mapnik/raster_colorizer.hpp>
|
||||
#include <mapnik/image_scaling.hpp>
|
||||
|
||||
|
||||
using mapnik::raster_symbolizer;
|
||||
|
||||
void export_raster_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
class_<raster_symbolizer>("RasterSymbolizer",
|
||||
init<>("Default ctor"))
|
||||
|
||||
.add_property("mode",
|
||||
make_function(&raster_symbolizer::get_mode,return_value_policy<copy_const_reference>()),
|
||||
&raster_symbolizer::set_mode,
|
||||
"Get/Set merging mode. (deprecated, use comp_op instead)\n"
|
||||
)
|
||||
.add_property("comp_op",
|
||||
&raster_symbolizer::comp_op,
|
||||
&raster_symbolizer::set_comp_op,
|
||||
"Set/get the raster comp-op"
|
||||
)
|
||||
.add_property("scaling",
|
||||
&raster_symbolizer::get_scaling_method,
|
||||
&raster_symbolizer::set_scaling_method,
|
||||
"Get/Set scaling algorithm.\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
">>> from mapnik import RasterSymbolizer\n"
|
||||
">>> r = RasterSymbolizer()\n"
|
||||
">>> r.scaling = 'mapnik.scaling_method.GAUSSIAN'\n"
|
||||
)
|
||||
|
||||
.add_property("opacity",
|
||||
&raster_symbolizer::get_opacity,
|
||||
&raster_symbolizer::set_opacity,
|
||||
"Get/Set opacity.\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
">>> from mapnik import RasterSymbolizer\n"
|
||||
">>> r = RasterSymbolizer()\n"
|
||||
">>> r.opacity = .5\n"
|
||||
)
|
||||
.add_property("colorizer",
|
||||
&raster_symbolizer::get_colorizer,
|
||||
&raster_symbolizer::set_colorizer,
|
||||
"Get/Set the RasterColorizer used to color data rasters.\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
">>> from mapnik import RasterSymbolizer, RasterColorizer\n"
|
||||
">>> r = RasterSymbolizer()\n"
|
||||
">>> r.colorizer = RasterColorizer()\n"
|
||||
">>> for value, color in [\n"
|
||||
"... (0, \"#000000\"),\n"
|
||||
"... (10, \"#ff0000\"),\n"
|
||||
"... (40, \"#00ff00\"),\n"
|
||||
"... ]:\n"
|
||||
"... r.colorizer.append_band(value, color)\n"
|
||||
)
|
||||
.add_property("filter_factor",
|
||||
&raster_symbolizer::get_filter_factor,
|
||||
&raster_symbolizer::set_filter_factor,
|
||||
"Get/Set the filter factor used by the datasource.\n"
|
||||
"\n"
|
||||
"This is used by the Raster or Gdal datasources to pre-downscale\n"
|
||||
"images using overviews.\n"
|
||||
"Higher numbers can sometimes cause much better scaled image\n"
|
||||
"output, at the cost of speed.\n"
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
" -1.0 : (Default) A suitable value will be determined from the\n"
|
||||
" chosen scaling method during rendering.\n"
|
||||
" 1.0 : The datasource will take care of all the scaling\n"
|
||||
" (using nearest neighbor interpolation)\n"
|
||||
" 2.0 : The datasource will scale the datasource to\n"
|
||||
" 2.0x the desired size, and mapnik will scale the rest\n"
|
||||
" of the way using the interpolation defined in self.scaling.\n"
|
||||
)
|
||||
.add_property("mesh_size",
|
||||
&raster_symbolizer::get_mesh_size,
|
||||
&raster_symbolizer::set_mesh_size,
|
||||
"Get/Set warping mesh size.\n"
|
||||
"Larger values result in faster warping times but might "
|
||||
"result in distorted maps.\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
">>> from mapnik import RasterSymbolizer\n"
|
||||
">>> r = RasterSymbolizer()\n"
|
||||
">>> r.mesh_size = 32\n"
|
||||
)
|
||||
.add_property("premultiplied",
|
||||
&raster_symbolizer::premultiplied,
|
||||
&raster_symbolizer::set_premultiplied,
|
||||
"Get/Set premultiplied status of the source image.\n"
|
||||
"Can be used to override what the source data reports (when in error)\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
">>> from mapnik import RasterSymbolizer\n"
|
||||
">>> r = RasterSymbolizer()\n"
|
||||
">>> r.premultiplied = False\n"
|
||||
)
|
||||
;
|
||||
}
|
|
@ -23,7 +23,6 @@
|
|||
// boost
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/python/implicit.hpp>
|
||||
#include <boost/python/detail/api_placeholder.hpp>
|
||||
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
|
||||
|
||||
// mapnik
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include <boost/python.hpp>
|
||||
#include <mapnik/image_scaling.hpp>
|
||||
#include "mapnik_enumeration.hpp"
|
||||
|
||||
void export_scaling_method()
|
||||
{
|
||||
|
|
|
@ -1,218 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2006 10East Corp.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* The functions in this file produce deprecation warnings.
|
||||
* But as shield symbolizer doesn't fully support more than one
|
||||
* placement from python yet these functions are actually the
|
||||
* correct ones.
|
||||
*/
|
||||
#define NO_DEPRECATION_WARNINGS
|
||||
|
||||
// boost
|
||||
#include <boost/python.hpp>
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/shield_symbolizer.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/parse_path.hpp>
|
||||
#include <mapnik/path_expression.hpp>
|
||||
#include "mapnik_svg.hpp"
|
||||
|
||||
using mapnik::color;
|
||||
using mapnik::shield_symbolizer;
|
||||
using mapnik::text_symbolizer;
|
||||
using mapnik::symbolizer_with_image;
|
||||
using mapnik::path_processor_type;
|
||||
using mapnik::path_expression_ptr;
|
||||
using mapnik::guess_type;
|
||||
using mapnik::expression_ptr;
|
||||
using mapnik::parse_path;
|
||||
using mapnik::position;
|
||||
|
||||
|
||||
namespace {
|
||||
using namespace boost::python;
|
||||
|
||||
tuple get_shield_displacement(const shield_symbolizer& s)
|
||||
{
|
||||
position const& pos = s.get_shield_displacement();
|
||||
return boost::python::make_tuple(pos.first, pos.second);
|
||||
}
|
||||
|
||||
void set_shield_displacement(shield_symbolizer & s, boost::python::tuple arg)
|
||||
{
|
||||
s.get_placement_options()->defaults.displacement.first = extract<double>(arg[0]);
|
||||
s.get_placement_options()->defaults.displacement.second = extract<double>(arg[1]);
|
||||
}
|
||||
|
||||
tuple get_text_displacement(const shield_symbolizer& t)
|
||||
{
|
||||
position const& pos = t.get_placement_options()->defaults.displacement;
|
||||
return boost::python::make_tuple(pos.first, pos.second);
|
||||
}
|
||||
|
||||
void set_text_displacement(shield_symbolizer & t, boost::python::tuple arg)
|
||||
{
|
||||
t.set_displacement(extract<double>(arg[0]),extract<double>(arg[1]));
|
||||
}
|
||||
|
||||
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 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>()
|
||||
)
|
||||
.add_property("allow_overlap",
|
||||
&shield_symbolizer::get_allow_overlap,
|
||||
&shield_symbolizer::set_allow_overlap,
|
||||
"Set/get the allow_overlap property of the label")
|
||||
.add_property("avoid_edges",
|
||||
&shield_symbolizer::get_avoid_edges,
|
||||
&shield_symbolizer::set_avoid_edges,
|
||||
"Set/get the avoid_edge property of the label")
|
||||
.add_property("character_spacing",
|
||||
&shield_symbolizer::get_character_spacing,
|
||||
&shield_symbolizer::set_character_spacing,
|
||||
"Set/get the character_spacing property of the label")
|
||||
.add_property("displacement",
|
||||
&get_text_displacement,
|
||||
&set_text_displacement)
|
||||
.add_property("face_name",
|
||||
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",
|
||||
make_function(&shield_symbolizer::get_fill,return_value_policy<copy_const_reference>()),
|
||||
&shield_symbolizer::set_fill)
|
||||
.add_property("fontset",
|
||||
make_function(&shield_symbolizer::get_fontset,return_value_policy<copy_const_reference>()),
|
||||
&shield_symbolizer::set_fontset)
|
||||
.add_property("force_odd_labels",
|
||||
&shield_symbolizer::get_force_odd_labels,
|
||||
&shield_symbolizer::set_force_odd_labels)
|
||||
.add_property("halo_fill",
|
||||
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::set_halo_radius)
|
||||
.add_property("horizontal_alignment",
|
||||
&shield_symbolizer::get_horizontal_alignment,
|
||||
&shield_symbolizer::set_horizontal_alignment,
|
||||
"Set/get the horizontal alignment of the label")
|
||||
.add_property("justify_alignment",
|
||||
&shield_symbolizer::get_justify_alignment,
|
||||
&shield_symbolizer::set_justify_alignment,
|
||||
"Set/get the text justification")
|
||||
.add_property("label_placement",
|
||||
&shield_symbolizer::get_label_placement,
|
||||
&shield_symbolizer::set_label_placement,
|
||||
"Set/get the placement of the label")
|
||||
.add_property("label_position_tolerance",
|
||||
&shield_symbolizer::get_label_position_tolerance,
|
||||
&shield_symbolizer::set_label_position_tolerance)
|
||||
.add_property("label_spacing",
|
||||
&shield_symbolizer::get_label_spacing,
|
||||
&shield_symbolizer::set_label_spacing)
|
||||
.add_property("line_spacing",
|
||||
&shield_symbolizer::get_line_spacing,
|
||||
&shield_symbolizer::set_line_spacing)
|
||||
.add_property("max_char_angle_delta",
|
||||
&shield_symbolizer::get_max_char_angle_delta,
|
||||
&shield_symbolizer::set_max_char_angle_delta)
|
||||
.add_property("minimum_distance",
|
||||
&shield_symbolizer::get_minimum_distance,
|
||||
&shield_symbolizer::set_minimum_distance)
|
||||
.add_property("minimum_padding",
|
||||
&shield_symbolizer::get_minimum_padding,
|
||||
&shield_symbolizer::set_minimum_padding)
|
||||
.add_property("name",&shield_symbolizer::get_name,
|
||||
&shield_symbolizer::set_name)
|
||||
.add_property("opacity",
|
||||
&shield_symbolizer::get_opacity,
|
||||
&shield_symbolizer::set_opacity,
|
||||
"Set/get the shield opacity")
|
||||
.add_property("shield_displacement",
|
||||
get_shield_displacement,
|
||||
set_shield_displacement)
|
||||
.add_property("text_opacity",
|
||||
&shield_symbolizer::get_text_opacity,
|
||||
&shield_symbolizer::set_text_opacity,
|
||||
"Set/get the text opacity")
|
||||
.add_property("text_transform",
|
||||
&shield_symbolizer::get_text_transform,
|
||||
&shield_symbolizer::set_text_transform,
|
||||
"Set/get the text conversion method")
|
||||
.add_property("text_ratio",
|
||||
&shield_symbolizer::get_text_ratio,
|
||||
&shield_symbolizer::set_text_ratio)
|
||||
.add_property("text_size",
|
||||
&shield_symbolizer::get_text_size,
|
||||
&shield_symbolizer::set_text_size)
|
||||
.add_property("vertical_alignment",
|
||||
&shield_symbolizer::get_vertical_alignment,
|
||||
&shield_symbolizer::set_vertical_alignment,
|
||||
"Set/get the vertical alignment of the label")
|
||||
.add_property("wrap_width",
|
||||
&shield_symbolizer::get_wrap_width,
|
||||
&shield_symbolizer::set_wrap_width)
|
||||
.add_property("wrap_character",
|
||||
&shield_symbolizer::get_wrap_char_string,
|
||||
&shield_symbolizer::set_wrap_char_from_string)
|
||||
.add_property("wrap_before",
|
||||
&shield_symbolizer::get_wrap_before,
|
||||
&shield_symbolizer::set_wrap_before)
|
||||
.add_property("unlock_image",
|
||||
&shield_symbolizer::get_unlock_image,
|
||||
&shield_symbolizer::set_unlock_image)
|
||||
.add_property("filename",
|
||||
&get_filename,
|
||||
&set_filename)
|
||||
.add_property("transform",
|
||||
mapnik::get_svg_transform<shield_symbolizer>,
|
||||
mapnik::set_svg_transform<shield_symbolizer>)
|
||||
.add_property("comp_op",
|
||||
&shield_symbolizer::comp_op,
|
||||
&shield_symbolizer::set_comp_op,
|
||||
"Set/get the comp-op")
|
||||
.add_property("clip",
|
||||
&shield_symbolizer::clip,
|
||||
&shield_symbolizer::set_clip,
|
||||
"Set/get the shield geometry's clipping status")
|
||||
;
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
||||
* Copyright (C) 2013 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -20,6 +20,14 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/* The functions in this file produce deprecation warnings.
|
||||
* But as shield symbolizer doesn't fully support more than one
|
||||
* placement from python yet these functions are actually the
|
||||
* correct ones.
|
||||
*/
|
||||
|
||||
#define NO_DEPRECATION_WARNINGS
|
||||
|
||||
// boost
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
|
@ -28,9 +36,18 @@
|
|||
//symbolizer typdef here rather than mapnik/symbolizer.hpp
|
||||
#include <mapnik/rule.hpp>
|
||||
#include <mapnik/symbolizer_hash.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/parse_path.hpp>
|
||||
#include <mapnik/path_expression.hpp>
|
||||
#include "mapnik_enumeration.hpp"
|
||||
#include "mapnik_svg.hpp"
|
||||
#include <mapnik/graphics.hpp>
|
||||
#include <mapnik/expression_node.hpp>
|
||||
#include <mapnik/value_error.hpp>
|
||||
#include <mapnik/marker_cache.hpp> // for known_svg_prefix_
|
||||
|
||||
|
||||
using mapnik::symbolizer;
|
||||
|
||||
using mapnik::rule;
|
||||
using mapnik::point_symbolizer;
|
||||
using mapnik::line_symbolizer;
|
||||
|
@ -42,6 +59,59 @@ using mapnik::shield_symbolizer;
|
|||
using mapnik::text_symbolizer;
|
||||
using mapnik::building_symbolizer;
|
||||
using mapnik::markers_symbolizer;
|
||||
using mapnik::color;
|
||||
using mapnik::path_processor_type;
|
||||
using mapnik::path_expression_ptr;
|
||||
using mapnik::guess_type;
|
||||
using mapnik::expression_ptr;
|
||||
using mapnik::parse_path;
|
||||
using mapnik::position;
|
||||
|
||||
|
||||
namespace {
|
||||
using namespace boost::python;
|
||||
|
||||
tuple get_shield_displacement(const shield_symbolizer& s)
|
||||
{
|
||||
position const& pos = s.get_shield_displacement();
|
||||
return boost::python::make_tuple(pos.first, pos.second);
|
||||
}
|
||||
|
||||
void set_shield_displacement(shield_symbolizer & s, boost::python::tuple arg)
|
||||
{
|
||||
s.get_placement_options()->defaults.displacement.first = extract<double>(arg[0]);
|
||||
s.get_placement_options()->defaults.displacement.second = extract<double>(arg[1]);
|
||||
}
|
||||
|
||||
tuple get_text_displacement(const shield_symbolizer& t)
|
||||
{
|
||||
position const& pos = t.get_placement_options()->defaults.displacement;
|
||||
return boost::python::make_tuple(pos.first, pos.second);
|
||||
}
|
||||
|
||||
void set_text_displacement(shield_symbolizer & t, boost::python::tuple arg)
|
||||
{
|
||||
t.set_displacement(extract<double>(arg[0]),extract<double>(arg[1]));
|
||||
}
|
||||
|
||||
void set_marker_type(mapnik::markers_symbolizer & symbolizer, std::string const& marker_type)
|
||||
{
|
||||
std::string filename;
|
||||
if (marker_type == "ellipse")
|
||||
{
|
||||
filename = mapnik::marker_cache::instance().known_svg_prefix_ + "ellipse";
|
||||
}
|
||||
else if (marker_type == "arrow")
|
||||
{
|
||||
filename = mapnik::marker_cache::instance().known_svg_prefix_ + "arrow";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw mapnik::value_error("Unknown marker-type: '" + marker_type + "'");
|
||||
}
|
||||
symbolizer.set_filename(parse_path(filename));
|
||||
}
|
||||
|
||||
|
||||
struct get_symbolizer_type : public boost::static_visitor<std::string>
|
||||
{
|
||||
|
@ -184,6 +254,20 @@ std::size_t hash_impl(symbolizer const& sym)
|
|||
return boost::apply_visitor(symbolizer_hash_visitor(), sym);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string get_file_impl(T const& sym)
|
||||
{
|
||||
return path_processor_type::to_string(*sym.get_filename());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void set_file_impl(T & sym, std::string const& file_expr)
|
||||
{
|
||||
sym.set_filename(parse_path(file_expr));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void export_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
@ -225,3 +309,569 @@ void export_symbolizer()
|
|||
return_value_policy<copy_const_reference>())
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
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>()
|
||||
)
|
||||
.add_property("allow_overlap",
|
||||
&shield_symbolizer::get_allow_overlap,
|
||||
&shield_symbolizer::set_allow_overlap,
|
||||
"Set/get the allow_overlap property of the label")
|
||||
.add_property("avoid_edges",
|
||||
&shield_symbolizer::get_avoid_edges,
|
||||
&shield_symbolizer::set_avoid_edges,
|
||||
"Set/get the avoid_edge property of the label")
|
||||
.add_property("character_spacing",
|
||||
&shield_symbolizer::get_character_spacing,
|
||||
&shield_symbolizer::set_character_spacing,
|
||||
"Set/get the character_spacing property of the label")
|
||||
.add_property("displacement",
|
||||
&get_text_displacement,
|
||||
&set_text_displacement)
|
||||
.add_property("face_name",
|
||||
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",
|
||||
make_function(&shield_symbolizer::get_fill,return_value_policy<copy_const_reference>()),
|
||||
&shield_symbolizer::set_fill)
|
||||
.add_property("fontset",
|
||||
make_function(&shield_symbolizer::get_fontset,return_value_policy<copy_const_reference>()),
|
||||
&shield_symbolizer::set_fontset)
|
||||
.add_property("force_odd_labels",
|
||||
&shield_symbolizer::get_force_odd_labels,
|
||||
&shield_symbolizer::set_force_odd_labels)
|
||||
.add_property("halo_fill",
|
||||
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::set_halo_radius)
|
||||
.add_property("horizontal_alignment",
|
||||
&shield_symbolizer::get_horizontal_alignment,
|
||||
&shield_symbolizer::set_horizontal_alignment,
|
||||
"Set/get the horizontal alignment of the label")
|
||||
.add_property("justify_alignment",
|
||||
&shield_symbolizer::get_justify_alignment,
|
||||
&shield_symbolizer::set_justify_alignment,
|
||||
"Set/get the text justification")
|
||||
.add_property("label_placement",
|
||||
&shield_symbolizer::get_label_placement,
|
||||
&shield_symbolizer::set_label_placement,
|
||||
"Set/get the placement of the label")
|
||||
.add_property("label_position_tolerance",
|
||||
&shield_symbolizer::get_label_position_tolerance,
|
||||
&shield_symbolizer::set_label_position_tolerance)
|
||||
.add_property("label_spacing",
|
||||
&shield_symbolizer::get_label_spacing,
|
||||
&shield_symbolizer::set_label_spacing)
|
||||
.add_property("line_spacing",
|
||||
&shield_symbolizer::get_line_spacing,
|
||||
&shield_symbolizer::set_line_spacing)
|
||||
.add_property("max_char_angle_delta",
|
||||
&shield_symbolizer::get_max_char_angle_delta,
|
||||
&shield_symbolizer::set_max_char_angle_delta)
|
||||
.add_property("minimum_distance",
|
||||
&shield_symbolizer::get_minimum_distance,
|
||||
&shield_symbolizer::set_minimum_distance)
|
||||
.add_property("minimum_padding",
|
||||
&shield_symbolizer::get_minimum_padding,
|
||||
&shield_symbolizer::set_minimum_padding)
|
||||
.add_property("name",&shield_symbolizer::get_name,
|
||||
&shield_symbolizer::set_name)
|
||||
.add_property("opacity",
|
||||
&shield_symbolizer::get_opacity,
|
||||
&shield_symbolizer::set_opacity,
|
||||
"Set/get the shield opacity")
|
||||
.add_property("shield_displacement",
|
||||
get_shield_displacement,
|
||||
set_shield_displacement)
|
||||
.add_property("text_opacity",
|
||||
&shield_symbolizer::get_text_opacity,
|
||||
&shield_symbolizer::set_text_opacity,
|
||||
"Set/get the text opacity")
|
||||
.add_property("text_transform",
|
||||
&shield_symbolizer::get_text_transform,
|
||||
&shield_symbolizer::set_text_transform,
|
||||
"Set/get the text conversion method")
|
||||
.add_property("text_ratio",
|
||||
&shield_symbolizer::get_text_ratio,
|
||||
&shield_symbolizer::set_text_ratio)
|
||||
.add_property("text_size",
|
||||
&shield_symbolizer::get_text_size,
|
||||
&shield_symbolizer::set_text_size)
|
||||
.add_property("vertical_alignment",
|
||||
&shield_symbolizer::get_vertical_alignment,
|
||||
&shield_symbolizer::set_vertical_alignment,
|
||||
"Set/get the vertical alignment of the label")
|
||||
.add_property("wrap_width",
|
||||
&shield_symbolizer::get_wrap_width,
|
||||
&shield_symbolizer::set_wrap_width)
|
||||
.add_property("wrap_character",
|
||||
&shield_symbolizer::get_wrap_char_string,
|
||||
&shield_symbolizer::set_wrap_char_from_string)
|
||||
.add_property("wrap_before",
|
||||
&shield_symbolizer::get_wrap_before,
|
||||
&shield_symbolizer::set_wrap_before)
|
||||
.add_property("unlock_image",
|
||||
&shield_symbolizer::get_unlock_image,
|
||||
&shield_symbolizer::set_unlock_image)
|
||||
.add_property("filename",
|
||||
get_file_impl<shield_symbolizer>,
|
||||
set_file_impl<shield_symbolizer>)
|
||||
.add_property("transform",
|
||||
mapnik::get_svg_transform<shield_symbolizer>,
|
||||
mapnik::set_svg_transform<shield_symbolizer>)
|
||||
.add_property("comp_op",
|
||||
&shield_symbolizer::comp_op,
|
||||
&shield_symbolizer::set_comp_op,
|
||||
"Set/get the comp-op")
|
||||
.add_property("clip",
|
||||
&shield_symbolizer::clip,
|
||||
&shield_symbolizer::set_clip,
|
||||
"Set/get the shield geometry's clipping status")
|
||||
;
|
||||
}
|
||||
|
||||
void export_polygon_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
class_<polygon_symbolizer>("PolygonSymbolizer",
|
||||
init<>("Default PolygonSymbolizer - solid fill grey"))
|
||||
.def(init<color const&>("TODO"))
|
||||
.add_property("fill",make_function
|
||||
(&polygon_symbolizer::get_fill,
|
||||
return_value_policy<copy_const_reference>()),
|
||||
&polygon_symbolizer::set_fill)
|
||||
.add_property("fill_opacity",
|
||||
&polygon_symbolizer::get_opacity,
|
||||
&polygon_symbolizer::set_opacity)
|
||||
.add_property("gamma",
|
||||
&polygon_symbolizer::get_gamma,
|
||||
&polygon_symbolizer::set_gamma)
|
||||
.add_property("gamma_method",
|
||||
&polygon_symbolizer::get_gamma_method,
|
||||
&polygon_symbolizer::set_gamma_method,
|
||||
"gamma correction method")
|
||||
.add_property("comp_op",
|
||||
&polygon_symbolizer::comp_op,
|
||||
&polygon_symbolizer::set_comp_op,
|
||||
"Set/get the polygon comp-op")
|
||||
.add_property("clip",
|
||||
&polygon_symbolizer::clip,
|
||||
&polygon_symbolizer::set_clip,
|
||||
"Set/get the polygon geometry's clipping status")
|
||||
.add_property("smooth",
|
||||
&polygon_symbolizer::smooth,
|
||||
&polygon_symbolizer::set_smooth,
|
||||
"Set/get the polygon geometry's smooth value")
|
||||
.add_property("simplify_tolerance",
|
||||
&polygon_symbolizer::simplify_tolerance,
|
||||
&polygon_symbolizer::set_simplify_tolerance,
|
||||
"simplfication tolerance measure")
|
||||
.def("__hash__", hash_impl)
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
void export_polygon_pattern_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
mapnik::enumeration_<mapnik::pattern_alignment_e>("pattern_alignment")
|
||||
.value("LOCAL",mapnik::LOCAL_ALIGNMENT)
|
||||
.value("GLOBAL",mapnik::GLOBAL_ALIGNMENT)
|
||||
;
|
||||
|
||||
class_<polygon_pattern_symbolizer>("PolygonPatternSymbolizer",
|
||||
init<path_expression_ptr>("<path_expression_ptr>"))
|
||||
.add_property("alignment",
|
||||
&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>)
|
||||
.add_property("filename",
|
||||
&get_file_impl<polygon_pattern_symbolizer>,
|
||||
&set_file_impl<polygon_pattern_symbolizer>)
|
||||
.add_property("opacity",
|
||||
&polygon_pattern_symbolizer::get_opacity,
|
||||
&polygon_pattern_symbolizer::set_opacity)
|
||||
.add_property("gamma",
|
||||
&polygon_pattern_symbolizer::get_gamma,
|
||||
&polygon_pattern_symbolizer::set_gamma)
|
||||
.add_property("gamma_method",
|
||||
&polygon_pattern_symbolizer::get_gamma_method,
|
||||
&polygon_pattern_symbolizer::set_gamma_method,
|
||||
"Set/get the gamma correction method of the polygon")
|
||||
.add_property("comp_op",
|
||||
&polygon_pattern_symbolizer::comp_op,
|
||||
&polygon_pattern_symbolizer::set_comp_op,
|
||||
"Set/get the pattern comp-op")
|
||||
.add_property("clip",
|
||||
&polygon_pattern_symbolizer::clip,
|
||||
&polygon_pattern_symbolizer::set_clip,
|
||||
"Set/get the pattern geometry's clipping status")
|
||||
.add_property("smooth",
|
||||
&polygon_pattern_symbolizer::smooth,
|
||||
&polygon_pattern_symbolizer::set_smooth,
|
||||
"Set/get the pattern geometry's smooth value")
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
void export_raster_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
class_<raster_symbolizer>("RasterSymbolizer",
|
||||
init<>("Default ctor"))
|
||||
|
||||
.add_property("mode",
|
||||
make_function(&raster_symbolizer::get_mode,return_value_policy<copy_const_reference>()),
|
||||
&raster_symbolizer::set_mode,
|
||||
"Get/Set merging mode. (deprecated, use comp_op instead)\n"
|
||||
)
|
||||
.add_property("comp_op",
|
||||
&raster_symbolizer::comp_op,
|
||||
&raster_symbolizer::set_comp_op,
|
||||
"Set/get the raster comp-op"
|
||||
)
|
||||
.add_property("scaling",
|
||||
&raster_symbolizer::get_scaling_method,
|
||||
&raster_symbolizer::set_scaling_method,
|
||||
"Get/Set scaling algorithm.\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
">>> from mapnik import RasterSymbolizer\n"
|
||||
">>> r = RasterSymbolizer()\n"
|
||||
">>> r.scaling = 'mapnik.scaling_method.GAUSSIAN'\n"
|
||||
)
|
||||
|
||||
.add_property("opacity",
|
||||
&raster_symbolizer::get_opacity,
|
||||
&raster_symbolizer::set_opacity,
|
||||
"Get/Set opacity.\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
">>> from mapnik import RasterSymbolizer\n"
|
||||
">>> r = RasterSymbolizer()\n"
|
||||
">>> r.opacity = .5\n"
|
||||
)
|
||||
.add_property("colorizer",
|
||||
&raster_symbolizer::get_colorizer,
|
||||
&raster_symbolizer::set_colorizer,
|
||||
"Get/Set the RasterColorizer used to color data rasters.\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
">>> from mapnik import RasterSymbolizer, RasterColorizer\n"
|
||||
">>> r = RasterSymbolizer()\n"
|
||||
">>> r.colorizer = RasterColorizer()\n"
|
||||
">>> for value, color in [\n"
|
||||
"... (0, \"#000000\"),\n"
|
||||
"... (10, \"#ff0000\"),\n"
|
||||
"... (40, \"#00ff00\"),\n"
|
||||
"... ]:\n"
|
||||
"... r.colorizer.append_band(value, color)\n"
|
||||
)
|
||||
.add_property("filter_factor",
|
||||
&raster_symbolizer::get_filter_factor,
|
||||
&raster_symbolizer::set_filter_factor,
|
||||
"Get/Set the filter factor used by the datasource.\n"
|
||||
"\n"
|
||||
"This is used by the Raster or Gdal datasources to pre-downscale\n"
|
||||
"images using overviews.\n"
|
||||
"Higher numbers can sometimes cause much better scaled image\n"
|
||||
"output, at the cost of speed.\n"
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
" -1.0 : (Default) A suitable value will be determined from the\n"
|
||||
" chosen scaling method during rendering.\n"
|
||||
" 1.0 : The datasource will take care of all the scaling\n"
|
||||
" (using nearest neighbor interpolation)\n"
|
||||
" 2.0 : The datasource will scale the datasource to\n"
|
||||
" 2.0x the desired size, and mapnik will scale the rest\n"
|
||||
" of the way using the interpolation defined in self.scaling.\n"
|
||||
)
|
||||
.add_property("mesh_size",
|
||||
&raster_symbolizer::get_mesh_size,
|
||||
&raster_symbolizer::set_mesh_size,
|
||||
"Get/Set warping mesh size.\n"
|
||||
"Larger values result in faster warping times but might "
|
||||
"result in distorted maps.\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
">>> from mapnik import RasterSymbolizer\n"
|
||||
">>> r = RasterSymbolizer()\n"
|
||||
">>> r.mesh_size = 32\n"
|
||||
)
|
||||
.add_property("premultiplied",
|
||||
&raster_symbolizer::premultiplied,
|
||||
&raster_symbolizer::set_premultiplied,
|
||||
"Get/Set premultiplied status of the source image.\n"
|
||||
"Can be used to override what the source data reports (when in error)\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
">>> from mapnik import RasterSymbolizer\n"
|
||||
">>> r = RasterSymbolizer()\n"
|
||||
">>> r.premultiplied = False\n"
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
void export_point_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
mapnik::enumeration_<mapnik::point_placement_e>("point_placement")
|
||||
.value("CENTROID",mapnik::CENTROID_POINT_PLACEMENT)
|
||||
.value("INTERIOR",mapnik::INTERIOR_POINT_PLACEMENT)
|
||||
;
|
||||
|
||||
class_<point_symbolizer>("PointSymbolizer",
|
||||
init<>("Default Point Symbolizer - 4x4 black square"))
|
||||
.def (init<mapnik::path_expression_ptr>("<path expression ptr>"))
|
||||
.add_property("filename",
|
||||
&get_file_impl<point_symbolizer>,
|
||||
&set_file_impl<point_symbolizer>)
|
||||
.add_property("allow_overlap",
|
||||
&point_symbolizer::get_allow_overlap,
|
||||
&point_symbolizer::set_allow_overlap)
|
||||
.add_property("opacity",
|
||||
&point_symbolizer::get_opacity,
|
||||
&point_symbolizer::set_opacity)
|
||||
.add_property("ignore_placement",
|
||||
&point_symbolizer::get_ignore_placement,
|
||||
&point_symbolizer::set_ignore_placement)
|
||||
.add_property("placement",
|
||||
&point_symbolizer::get_point_placement,
|
||||
&point_symbolizer::set_point_placement,
|
||||
"Set/get the placement of the point")
|
||||
.add_property("transform",
|
||||
mapnik::get_svg_transform<point_symbolizer>,
|
||||
mapnik::set_svg_transform<point_symbolizer>)
|
||||
.add_property("comp_op",
|
||||
&point_symbolizer::comp_op,
|
||||
&point_symbolizer::set_comp_op,
|
||||
"Set/get the comp-op")
|
||||
;
|
||||
}
|
||||
|
||||
void export_markers_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
mapnik::enumeration_<mapnik::marker_placement_e>("marker_placement")
|
||||
.value("POINT_PLACEMENT",mapnik::MARKER_POINT_PLACEMENT)
|
||||
.value("INTERIOR_PLACEMENT",mapnik::MARKER_INTERIOR_PLACEMENT)
|
||||
.value("LINE_PLACEMENT",mapnik::MARKER_LINE_PLACEMENT)
|
||||
;
|
||||
|
||||
mapnik::enumeration_<mapnik::marker_multi_policy_e>("marker_multi_policy")
|
||||
.value("EACH",mapnik::MARKER_EACH_MULTI)
|
||||
.value("WHOLE",mapnik::MARKER_WHOLE_MULTI)
|
||||
.value("LARGEST",mapnik::MARKER_LARGEST_MULTI)
|
||||
;
|
||||
|
||||
class_<markers_symbolizer>("MarkersSymbolizer",
|
||||
init<>("Default Markers Symbolizer - circle"))
|
||||
.def (init<mapnik::path_expression_ptr>("<path expression ptr>"))
|
||||
.add_property("filename",
|
||||
&get_file_impl<markers_symbolizer>,
|
||||
&set_file_impl<markers_symbolizer>)
|
||||
.add_property("marker_type",
|
||||
&get_file_impl<markers_symbolizer>,
|
||||
&set_marker_type)
|
||||
.add_property("allow_overlap",
|
||||
&markers_symbolizer::get_allow_overlap,
|
||||
&markers_symbolizer::set_allow_overlap)
|
||||
.add_property("spacing",
|
||||
&markers_symbolizer::get_spacing,
|
||||
&markers_symbolizer::set_spacing)
|
||||
.add_property("max_error",
|
||||
&markers_symbolizer::get_max_error,
|
||||
&markers_symbolizer::set_max_error)
|
||||
.add_property("opacity",
|
||||
&markers_symbolizer::get_opacity,
|
||||
&markers_symbolizer::set_opacity,
|
||||
"Set/get the overall opacity")
|
||||
.add_property("fill_opacity",
|
||||
&markers_symbolizer::get_fill_opacity,
|
||||
&markers_symbolizer::set_fill_opacity,
|
||||
"Set/get the fill opacity")
|
||||
.add_property("ignore_placement",
|
||||
&markers_symbolizer::get_ignore_placement,
|
||||
&markers_symbolizer::set_ignore_placement)
|
||||
.add_property("transform",
|
||||
&mapnik::get_svg_transform<markers_symbolizer>,
|
||||
&mapnik::set_svg_transform<markers_symbolizer>)
|
||||
.add_property("width",
|
||||
make_function(&markers_symbolizer::get_width,
|
||||
return_value_policy<copy_const_reference>()),
|
||||
&markers_symbolizer::set_width,
|
||||
"Set/get the marker width")
|
||||
.add_property("height",
|
||||
make_function(&markers_symbolizer::get_height,
|
||||
return_value_policy<copy_const_reference>()),
|
||||
&markers_symbolizer::set_height,
|
||||
"Set/get the marker height")
|
||||
.add_property("fill",
|
||||
&markers_symbolizer::get_fill,
|
||||
&markers_symbolizer::set_fill,
|
||||
"Set/get the marker fill color")
|
||||
.add_property("stroke",
|
||||
&markers_symbolizer::get_stroke,
|
||||
&markers_symbolizer::set_stroke,
|
||||
"Set/get the marker stroke (outline)")
|
||||
.add_property("placement",
|
||||
&markers_symbolizer::get_marker_placement,
|
||||
&markers_symbolizer::set_marker_placement,
|
||||
"Set/get the marker placement")
|
||||
.add_property("multi_policy",
|
||||
&markers_symbolizer::get_marker_multi_policy,
|
||||
&markers_symbolizer::set_marker_multi_policy,
|
||||
"Set/get the marker multi geometry rendering policy")
|
||||
.add_property("comp_op",
|
||||
&markers_symbolizer::comp_op,
|
||||
&markers_symbolizer::set_comp_op,
|
||||
"Set/get the marker comp-op")
|
||||
.add_property("clip",
|
||||
&markers_symbolizer::clip,
|
||||
&markers_symbolizer::set_clip,
|
||||
"Set/get the marker geometry's clipping status")
|
||||
.add_property("smooth",
|
||||
&markers_symbolizer::smooth,
|
||||
&markers_symbolizer::set_smooth,
|
||||
"Set/get the marker geometry's smooth value")
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
void export_line_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
mapnik::enumeration_<mapnik::line_rasterizer_e>("line_rasterizer")
|
||||
.value("FULL",mapnik::RASTERIZER_FULL)
|
||||
.value("FAST",mapnik::RASTERIZER_FAST)
|
||||
;
|
||||
class_<line_symbolizer>("LineSymbolizer",
|
||||
init<>("Default LineSymbolizer - 1px solid black"))
|
||||
.def(init<mapnik::stroke const&>("TODO"))
|
||||
.def(init<mapnik::color const& ,float>())
|
||||
.add_property("rasterizer",
|
||||
&line_symbolizer::get_rasterizer,
|
||||
&line_symbolizer::set_rasterizer,
|
||||
"Set/get the rasterization method of the line of the point")
|
||||
.add_property("stroke",make_function
|
||||
(&line_symbolizer::get_stroke,
|
||||
return_value_policy<reference_existing_object>()),
|
||||
&line_symbolizer::set_stroke)
|
||||
.add_property("simplify_tolerance",
|
||||
&line_symbolizer::simplify_tolerance,
|
||||
&line_symbolizer::set_simplify_tolerance,
|
||||
"simplification tolerance measure")
|
||||
.add_property("offset",
|
||||
&line_symbolizer::offset,
|
||||
&line_symbolizer::set_offset,
|
||||
"offset value")
|
||||
.add_property("comp_op",
|
||||
&line_symbolizer::comp_op,
|
||||
&line_symbolizer::set_comp_op,
|
||||
"Set/get the comp-op")
|
||||
.add_property("clip",
|
||||
&line_symbolizer::clip,
|
||||
&line_symbolizer::set_clip,
|
||||
"Set/get the line geometry's clipping status")
|
||||
.add_property("smooth",
|
||||
&line_symbolizer::smooth,
|
||||
&line_symbolizer::set_smooth,
|
||||
"smooth value (0..1.0)")
|
||||
.def("__hash__", hash_impl)
|
||||
;
|
||||
}
|
||||
|
||||
void export_line_pattern_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
class_<line_pattern_symbolizer>("LinePatternSymbolizer",
|
||||
init<path_expression_ptr>
|
||||
("<image file expression>"))
|
||||
.add_property("transform",
|
||||
mapnik::get_svg_transform<line_pattern_symbolizer>,
|
||||
mapnik::set_svg_transform<line_pattern_symbolizer>)
|
||||
.add_property("filename",
|
||||
&get_file_impl<line_pattern_symbolizer>,
|
||||
&set_file_impl<line_pattern_symbolizer>)
|
||||
.add_property("offset",
|
||||
&line_pattern_symbolizer::offset,
|
||||
&line_pattern_symbolizer::set_offset,
|
||||
"Set/get the offset")
|
||||
.add_property("comp_op",
|
||||
&line_pattern_symbolizer::comp_op,
|
||||
&line_pattern_symbolizer::set_comp_op,
|
||||
"Set/get the comp-op")
|
||||
.add_property("clip",
|
||||
&line_pattern_symbolizer::clip,
|
||||
&line_pattern_symbolizer::set_clip,
|
||||
"Set/get the line pattern geometry's clipping status")
|
||||
.add_property("smooth",
|
||||
&line_pattern_symbolizer::smooth,
|
||||
&line_pattern_symbolizer::set_smooth,
|
||||
"smooth value (0..1.0)")
|
||||
;
|
||||
}
|
||||
|
||||
void export_debug_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
mapnik::enumeration_<mapnik::debug_symbolizer_mode_e>("debug_symbolizer_mode")
|
||||
.value("COLLISION",mapnik::DEBUG_SYM_MODE_COLLISION)
|
||||
.value("VERTEX",mapnik::DEBUG_SYM_MODE_VERTEX)
|
||||
;
|
||||
|
||||
class_<mapnik::debug_symbolizer>("DebugSymbolizer",
|
||||
init<>("Default debug Symbolizer"))
|
||||
.add_property("mode",
|
||||
&mapnik::debug_symbolizer::get_mode,
|
||||
&mapnik::debug_symbolizer::set_mode)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
void export_building_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
class_<building_symbolizer>("BuildingSymbolizer",
|
||||
init<>("Default BuildingSymbolizer"))
|
||||
.add_property("fill",make_function
|
||||
(&building_symbolizer::get_fill,
|
||||
return_value_policy<copy_const_reference>()),
|
||||
&building_symbolizer::set_fill)
|
||||
.add_property("fill_opacity",
|
||||
&building_symbolizer::get_opacity,
|
||||
&building_symbolizer::set_opacity)
|
||||
.add_property("height",
|
||||
make_function(&building_symbolizer::height,
|
||||
return_value_policy<copy_const_reference>()),
|
||||
&building_symbolizer::set_height,
|
||||
"Set/get the building height")
|
||||
;
|
||||
|
||||
}
|
||||
|
|
|
@ -24,19 +24,15 @@
|
|||
#include <boost/noncopyable.hpp>
|
||||
|
||||
#include <mapnik/text_properties.hpp>
|
||||
#include <mapnik/text_placements/simple.hpp>
|
||||
#include <mapnik/text_placements/list.hpp>
|
||||
#include <mapnik/formatting/text.hpp>
|
||||
#include <mapnik/formatting/list.hpp>
|
||||
#include <mapnik/formatting/format.hpp>
|
||||
#include <mapnik/formatting/expression_format.hpp>
|
||||
#include <mapnik/processed_text.hpp>
|
||||
#include <mapnik/expression_string.hpp>
|
||||
#include <mapnik/text_symbolizer.hpp>
|
||||
|
||||
#include "mapnik_enumeration.hpp"
|
||||
#include "mapnik_threads.hpp"
|
||||
#include "python_optional.hpp"
|
||||
|
||||
using namespace mapnik;
|
||||
|
||||
|
@ -53,8 +49,48 @@ using namespace mapnik;
|
|||
*/
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
// This class works around a feature in boost python.
|
||||
// See http://osdir.com/ml/python.c++/2003-11/msg00158.html
|
||||
|
||||
template <typename T,
|
||||
typename X1 = boost::python::detail::not_specified,
|
||||
typename X2 = boost::python::detail::not_specified,
|
||||
typename X3 = boost::python::detail::not_specified>
|
||||
class class_with_converter : public boost::python::class_<T, X1, X2, X3>
|
||||
{
|
||||
public:
|
||||
typedef class_with_converter<T,X1,X2,X3> self;
|
||||
// Construct with the class name, with or without docstring, and default __init__() function
|
||||
class_with_converter(char const* name, char const* doc = 0) : boost::python::class_<T, X1, X2, X3>(name, doc) { }
|
||||
|
||||
// Construct with class name, no docstring, and an uncallable __init__ function
|
||||
class_with_converter(char const* name, boost::python::no_init_t y) : boost::python::class_<T, X1, X2, X3>(name, y) { }
|
||||
|
||||
// Construct with class name, docstring, and an uncallable __init__ function
|
||||
class_with_converter(char const* name, char const* doc, boost::python::no_init_t y) : boost::python::class_<T, X1, X2, X3>(name, doc, y) { }
|
||||
|
||||
// Construct with class name and init<> function
|
||||
template <class DerivedT> class_with_converter(char const* name, boost::python::init_base<DerivedT> const& i)
|
||||
: boost::python::class_<T, X1, X2, X3>(name, i) { }
|
||||
|
||||
// Construct with class name, docstring and init<> function
|
||||
template <class DerivedT>
|
||||
inline class_with_converter(char const* name, char const* doc, boost::python::init_base<DerivedT> const& i)
|
||||
: boost::python::class_<T, X1, X2, X3>(name, doc, i) { }
|
||||
|
||||
template <class D>
|
||||
self& def_readwrite_convert(char const* name, D const& d, char const* /*doc*/=0)
|
||||
{
|
||||
this->add_property(name,
|
||||
boost::python::make_getter(d, boost::python::return_value_policy<boost::python::return_by_value>()),
|
||||
boost::python::make_setter(d, boost::python::default_call_policies()));
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
boost::python::tuple get_displacement(text_symbolizer_properties const& t)
|
||||
{
|
||||
return boost::python::make_tuple(t.displacement.first, t.displacement.second);
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
#ifndef MAPNIK_THREADS_HPP
|
||||
#define MAPNIK_THREADS_HPP
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/python.hpp>
|
||||
|
||||
#include <boost/thread/tss.hpp> // for thread_specific_ptr
|
||||
#include <Python.h>
|
||||
|
||||
namespace mapnik {
|
||||
class python_thread
|
||||
{
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2008 Tom Hughes
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
||||
|
||||
#include <boost/python/type_id.hpp>
|
||||
#include <boost/python/converter/registry.hpp>
|
||||
|
||||
#include <pycairo.h>
|
||||
|
||||
static Pycairo_CAPI_t *Pycairo_CAPI;
|
||||
|
||||
static void *extract_surface(PyObject* op)
|
||||
{
|
||||
|
||||
if (PyObject_TypeCheck(op, const_cast<PyTypeObject*>(Pycairo_CAPI->Surface_Type)))
|
||||
{
|
||||
return op;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void *extract_context(PyObject* op)
|
||||
{
|
||||
if (PyObject_TypeCheck(op, const_cast<PyTypeObject*>(Pycairo_CAPI->Context_Type)))
|
||||
{
|
||||
return op;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void register_cairo()
|
||||
{
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
Pycairo_CAPI = (Pycairo_CAPI_t*) PyCapsule_Import(const_cast<char *>("cairo.CAPI"), 0);
|
||||
#else
|
||||
Pycairo_CAPI = (Pycairo_CAPI_t*) PyCObject_Import(const_cast<char *>("cairo"), const_cast<char *>("CAPI"));
|
||||
#endif
|
||||
if (Pycairo_CAPI == NULL) return;
|
||||
|
||||
boost::python::converter::registry::insert(&extract_surface, boost::python::type_id<PycairoSurface>());
|
||||
boost::python::converter::registry::insert(&extract_context, boost::python::type_id<PycairoContext>());
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void register_cairo()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
|
@ -38,7 +38,6 @@
|
|||
#include <mapnik/value_error.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/feature_kv_iterator.hpp>
|
||||
#include "mapnik_value_converter.hpp"
|
||||
#include "python_grid_utils.hpp"
|
||||
|
||||
// stl
|
||||
|
|
|
@ -196,43 +196,3 @@ struct python_optional<bool> : public mapnik::noncopyable
|
|||
optional_to_python, optional_from_python>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// This class works around a feature in boost python.
|
||||
// See http://osdir.com/ml/python.c++/2003-11/msg00158.html
|
||||
|
||||
template <typename T,
|
||||
typename X1 = boost::python::detail::not_specified,
|
||||
typename X2 = boost::python::detail::not_specified,
|
||||
typename X3 = boost::python::detail::not_specified>
|
||||
class class_with_converter : public boost::python::class_<T, X1, X2, X3>
|
||||
{
|
||||
public:
|
||||
typedef class_with_converter<T,X1,X2,X3> self;
|
||||
// Construct with the class name, with or without docstring, and default __init__() function
|
||||
class_with_converter(char const* name, char const* doc = 0) : boost::python::class_<T, X1, X2, X3>(name, doc) { }
|
||||
|
||||
// Construct with class name, no docstring, and an uncallable __init__ function
|
||||
class_with_converter(char const* name, boost::python::no_init_t y) : boost::python::class_<T, X1, X2, X3>(name, y) { }
|
||||
|
||||
// Construct with class name, docstring, and an uncallable __init__ function
|
||||
class_with_converter(char const* name, char const* doc, boost::python::no_init_t y) : boost::python::class_<T, X1, X2, X3>(name, doc, y) { }
|
||||
|
||||
// Construct with class name and init<> function
|
||||
template <class DerivedT> class_with_converter(char const* name, boost::python::init_base<DerivedT> const& i)
|
||||
: boost::python::class_<T, X1, X2, X3>(name, i) { }
|
||||
|
||||
// Construct with class name, docstring and init<> function
|
||||
template <class DerivedT>
|
||||
inline class_with_converter(char const* name, char const* doc, boost::python::init_base<DerivedT> const& i)
|
||||
: boost::python::class_<T, X1, X2, X3>(name, doc, i) { }
|
||||
|
||||
template <class D>
|
||||
self& def_readwrite_convert(char const* name, D const& d, char const* /*doc*/=0)
|
||||
{
|
||||
this->add_property(name,
|
||||
boost::python::make_getter(d, boost::python::return_value_policy<boost::python::return_by_value>()),
|
||||
boost::python::make_setter(d, boost::python::default_call_policies()));
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue