Merge branch '2.3.x' of github.com:mapnik/mapnik

Conflicts:
	bindings/python/mapnik_building_symbolizer.cpp
	bindings/python/mapnik_debug_symbolizer.cpp
	bindings/python/mapnik_line_pattern_symbolizer.cpp
	bindings/python/mapnik_line_symbolizer.cpp
	bindings/python/mapnik_markers_symbolizer.cpp
	bindings/python/mapnik_point_symbolizer.cpp
	bindings/python/mapnik_polygon_symbolizer.cpp
	bindings/python/mapnik_python.cpp
	bindings/python/mapnik_raster_symbolizer.cpp
	bindings/python/mapnik_shield_symbolizer.cpp
	bindings/python/mapnik_symbolizer.cpp
This commit is contained in:
Dane Springmeyer 2013-11-07 09:21:05 -08:00
commit 08fa9fd8ec
60 changed files with 4306 additions and 3388 deletions

View file

@ -14,6 +14,8 @@ Released ...
Summary: TODO
- Added missing support for `geometry-transform` in `line-pattern` and `polygon-pattern` symbolizers (#2065)
- Dropped support for Sun compiler
- Upgraded unifont to `unifont-6.3.20131020`

View file

@ -1,6 +1,6 @@
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2009 Artem Pavlenko, Jean-Francois Doyon, Dane Springmeyer
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public

View file

@ -1,53 +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_std_shared_shim.hpp"
#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")
;
}

View file

@ -23,18 +23,14 @@
// boost
#include "boost_std_shared_shim.hpp"
#include <boost/python.hpp>
#include <boost/python/detail/api_placeholder.hpp>
#include <boost/noncopyable.hpp>
#include <boost/version.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>

View file

@ -1,44 +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_std_shared_shim.hpp"
#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)
;
}

View file

@ -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>

View file

@ -24,7 +24,6 @@
// boost
#include <boost/python.hpp>
#include <boost/python/detail/api_placeholder.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
// mapnik

View file

@ -1,84 +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_std_shared_shim.hpp"
#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)")
;
}

View file

@ -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_std_shared_shim.hpp"
#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)
;
}

View file

@ -24,7 +24,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>

View file

@ -1,164 +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_std_shared_shim.hpp"
#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")
;
}

View file

@ -1,91 +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_std_shared_shim.hpp"
#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")
;
}

View file

@ -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")
;
}

View file

@ -1,78 +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_std_shared_shim.hpp"
#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)
;
}

View file

@ -21,15 +21,22 @@
*****************************************************************************/
#include "boost_std_shared_shim.hpp"
#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();
@ -79,20 +86,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>
@ -107,6 +106,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();
@ -116,9 +122,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;
@ -128,7 +173,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,
@ -141,7 +186,7 @@ void render(const mapnik::Map& map,
}
void render_with_detector(
const mapnik::Map &map,
mapnik::Map const& map,
mapnik::image_32 &image,
std::shared_ptr<mapnik::label_collision_detector4> detector,
double scale_factor = 1.0,
@ -153,7 +198,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)
{
@ -175,7 +220,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,
@ -187,7 +232,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());
@ -195,7 +240,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,
@ -207,7 +252,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());
@ -216,7 +261,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,
std::shared_ptr<mapnik::label_collision_detector4> detector)
{
@ -227,7 +272,7 @@ void render_with_detector2(
}
void render_with_detector3(
const mapnik::Map& map,
mapnik::Map const& map,
PycairoContext* py_context,
std::shared_ptr<mapnik::label_collision_detector4> detector,
double scale_factor = 1.0,
@ -241,7 +286,7 @@ void render_with_detector3(
}
void render_with_detector4(
const mapnik::Map& map,
mapnik::Map const& map,
PycairoSurface* py_surface,
std::shared_ptr<mapnik::label_collision_detector4> detector)
{
@ -252,7 +297,7 @@ void render_with_detector4(
}
void render_with_detector5(
const mapnik::Map& map,
mapnik::Map const& map,
PycairoSurface* py_surface,
std::shared_ptr<mapnik::label_collision_detector4> detector,
double scale_factor = 1.0,
@ -268,7 +313,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,
@ -279,7 +324,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)
{
@ -299,7 +344,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")
@ -318,7 +363,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
@ -340,7 +385,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);
}
@ -495,7 +540,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();

View file

@ -1,138 +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_std_shared_shim.hpp"
// 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"
)
;
}

View file

@ -25,7 +25,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

View file

@ -23,7 +23,6 @@
#include <boost/python.hpp>
#include <mapnik/image_scaling.hpp>
#include "mapnik_enumeration.hpp"
void export_scaling_method()
{

View file

@ -1,220 +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
*
*****************************************************************************/
#include "boost_std_shared_shim.hpp"
/* 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")
;
}

View file

@ -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
@ -21,6 +21,13 @@
*****************************************************************************/
#include "boost_std_shared_shim.hpp"
/* 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>
@ -30,9 +37,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;
@ -44,6 +60,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>
{
@ -186,6 +255,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;
@ -227,3 +310,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")
;
}

View file

@ -27,19 +27,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;
@ -56,8 +52,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);

View file

@ -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
{

View file

@ -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

View file

@ -36,7 +36,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

View file

@ -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;
}
};

View file

@ -1,7 +1,7 @@
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2010 Artem Pavlenko, Jean-Francois Doyon
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public

28
deps/agg/build.py vendored
View file

@ -1,19 +1,21 @@
# This file is part of Mapnik (c++ mapping toolkit)
# Copyright (C) 2005 Artem Pavlenko, Jean-Francois Doyon
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or any later version.
# This file is part of Mapnik (c++ mapping toolkit)
#
# This program 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 General Public License for more details.
# Copyright (C) 2013 Artem Pavlenko
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Mapnik 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
#
#

View file

@ -1,295 +1,295 @@
/*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 1.1 *
* Date : 4 April 2011 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2011 *
* *
* License: *
* Use, modification & distribution is subject to Boost Software License Ver 1. *
* http://www.boost.org/LICENSE_1_0.txt *
* *
*******************************************************************************/
#ifndef AGG_CONV_CLIPPER_INCLUDED
#define AGG_CONV_CLIPPER_INCLUDED
#include <cmath>
#include "agg_basics.h"
#include "agg_array.h"
#include "clipper.hpp"
namespace agg
{
enum clipper_op_e { clipper_or,
clipper_and, clipper_xor, clipper_a_minus_b, clipper_b_minus_a };
enum clipper_PolyFillType {clipper_even_odd, clipper_non_zero, clipper_positive, clipper_negative};
template<class VSA, class VSB> class conv_clipper
{
enum status { status_move_to, status_line_to, status_stop };
typedef VSA source_a_type;
typedef VSB source_b_type;
typedef conv_clipper<source_a_type, source_b_type> self_type;
private:
source_a_type* m_src_a;
source_b_type* m_src_b;
status m_status;
int m_vertex;
int m_contour;
int m_scaling_factor;
clipper_op_e m_operation;
pod_bvector<ClipperLib::IntPoint, 8> m_vertex_accumulator;
ClipperLib::Polygons m_poly_a;
ClipperLib::Polygons m_poly_b;
ClipperLib::Polygons m_result;
ClipperLib::Clipper m_clipper;
clipper_PolyFillType m_subjFillType;
clipper_PolyFillType m_clipFillType;
int Round(double val)
{
if ((val < 0)) return (int)(val - 0.5); else return (int)(val + 0.5);
}
public:
conv_clipper(source_a_type &a, source_b_type &b,
clipper_op_e op = clipper_or,
clipper_PolyFillType subjFillType = clipper_even_odd,
clipper_PolyFillType clipFillType = clipper_even_odd,
int scaling_factor = 2) :
m_src_a(&a),
m_src_b(&b),
m_status(status_move_to),
m_vertex(-1),
m_contour(-1),
m_operation(op),
m_subjFillType(subjFillType),
m_clipFillType(clipFillType)
{
m_scaling_factor = std::max(std::min(scaling_factor, 6),0);
m_scaling_factor = Round(std::pow((double)10, m_scaling_factor));
}
~conv_clipper()
{
}
void attach1(VSA &source, clipper_PolyFillType subjFillType = clipper_even_odd)
{ m_src_a = &source; m_subjFillType = subjFillType; }
void attach2(VSB &source, clipper_PolyFillType clipFillType = clipper_even_odd)
{ m_src_b = &source; m_clipFillType = clipFillType; }
void operation(clipper_op_e v) { m_operation = v; }
void rewind(unsigned path_id);
unsigned vertex(double* x, double* y);
bool next_contour();
bool next_vertex(double* x, double* y);
void start_extracting();
void add_vertex_(double &x, double &y);
void end_contour(ClipperLib::Polygons &p);
template<class VS> void add(VS &src, ClipperLib::Polygons &p){
unsigned cmd;
double x; double y; double start_x; double start_y;
bool starting_first_line;
start_x = 0.0;
start_y = 0.0;
starting_first_line = true;
p.resize(0);
cmd = src->vertex( &x , &y );
while(!is_stop(cmd))
{
if(is_vertex(cmd))
{
if(is_move_to(cmd))
{
if(!starting_first_line ) end_contour(p);
start_x = x;
start_y = y;
}
add_vertex_( x, y );
starting_first_line = false;
}
else if(is_end_poly(cmd))
{
if(!starting_first_line && is_closed(cmd))
add_vertex_( start_x, start_y );
}
cmd = src->vertex( &x, &y );
}
end_contour(p);
}
};
//------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::start_extracting()
{
m_status = status_move_to;
m_contour = -1;
m_vertex = -1;
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::rewind(unsigned path_id)
{
m_src_a->rewind( path_id );
m_src_b->rewind( path_id );
add( m_src_a , m_poly_a );
add( m_src_b , m_poly_b );
m_result.resize(0);
ClipperLib::PolyFillType pftSubj, pftClip;
switch (m_subjFillType)
{
case clipper_even_odd: pftSubj = ClipperLib::pftEvenOdd; break;
case clipper_non_zero: pftSubj = ClipperLib::pftNonZero; break;
case clipper_positive: pftSubj = ClipperLib::pftPositive; break;
default: pftSubj = ClipperLib::pftNegative;
}
switch (m_clipFillType)
{
case clipper_even_odd: pftClip = ClipperLib::pftEvenOdd; break;
case clipper_non_zero: pftClip = ClipperLib::pftNonZero; break;
case clipper_positive: pftClip = ClipperLib::pftPositive; break;
default: pftClip = ClipperLib::pftNegative;
}
m_clipper.Clear();
switch( m_operation ) {
case clipper_or:
{
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctUnion , m_result , pftSubj, pftClip);
break;
}
case clipper_and:
{
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctIntersection , m_result, pftSubj, pftClip );
break;
}
case clipper_xor:
{
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctXor , m_result, pftSubj, pftClip );
break;
}
case clipper_a_minus_b:
{
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctDifference , m_result, pftSubj, pftClip );
break;
}
case clipper_b_minus_a:
{
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctDifference , m_result, pftSubj, pftClip );
break;
}
}
start_extracting();
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::end_contour( ClipperLib::Polygons &p)
{
unsigned i, len;
if( m_vertex_accumulator.size() < 3 ) return;
len = p.size();
p.resize(len+1);
p[len].resize(m_vertex_accumulator.size());
for( i = 0 ; i < m_vertex_accumulator.size() ; i++ )
p[len][i] = m_vertex_accumulator[i];
m_vertex_accumulator.remove_all();
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::add_vertex_(double &x, double &y)
{
ClipperLib::IntPoint v;
v.X = Round(x * m_scaling_factor);
v.Y = Round(y * m_scaling_factor);
m_vertex_accumulator.add( v );
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
bool conv_clipper<VSA, VSB>::next_contour()
{
m_contour++;
if(m_contour >= (int)m_result.size()) return false;
m_vertex =-1;
return true;
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
bool conv_clipper<VSA, VSB>::next_vertex(double *x, double *y)
{
m_vertex++;
if(m_vertex >= (int)m_result[m_contour].size()) return false;
*x = (double)m_result[ m_contour ][ m_vertex ].X / m_scaling_factor;
*y = (double)m_result[ m_contour ][ m_vertex ].Y / m_scaling_factor;
return true;
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
unsigned conv_clipper<VSA, VSB>::vertex(double *x, double *y)
{
if( m_status == status_move_to )
{
if( next_contour() )
{
if( next_vertex( x, y ) )
{
m_status =status_line_to;
return path_cmd_move_to;
}
else
{
m_status = status_stop;
return path_cmd_end_poly | path_flags_close;
}
}
else
return path_cmd_stop;
}
else
{
if( next_vertex( x, y ) )
{
return path_cmd_line_to;
}
else
{
m_status = status_move_to;
return path_cmd_end_poly | path_flags_close;
}
}
}
//------------------------------------------------------------------------------
} //namespace agg
#endif //AGG_CONV_CLIPPER_INCLUDED
/*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 1.1 *
* Date : 4 April 2011 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2011 *
* *
* License: *
* Use, modification & distribution is subject to Boost Software License Ver 1. *
* http://www.boost.org/LICENSE_1_0.txt *
* *
*******************************************************************************/
#ifndef AGG_CONV_CLIPPER_INCLUDED
#define AGG_CONV_CLIPPER_INCLUDED
#include <cmath>
#include "agg_basics.h"
#include "agg_array.h"
#include "clipper.hpp"
namespace agg
{
enum clipper_op_e { clipper_or,
clipper_and, clipper_xor, clipper_a_minus_b, clipper_b_minus_a };
enum clipper_PolyFillType {clipper_even_odd, clipper_non_zero, clipper_positive, clipper_negative};
template<class VSA, class VSB> class conv_clipper
{
enum status { status_move_to, status_line_to, status_stop };
typedef VSA source_a_type;
typedef VSB source_b_type;
typedef conv_clipper<source_a_type, source_b_type> self_type;
private:
source_a_type* m_src_a;
source_b_type* m_src_b;
status m_status;
int m_vertex;
int m_contour;
int m_scaling_factor;
clipper_op_e m_operation;
pod_bvector<ClipperLib::IntPoint, 8> m_vertex_accumulator;
ClipperLib::Paths m_poly_a;
ClipperLib::Paths m_poly_b;
ClipperLib::Paths m_result;
ClipperLib::Clipper m_clipper;
clipper_PolyFillType m_subjFillType;
clipper_PolyFillType m_clipFillType;
int Round(double val)
{
if ((val < 0)) return (int)(val - 0.5); else return (int)(val + 0.5);
}
public:
conv_clipper(source_a_type &a, source_b_type &b,
clipper_op_e op = clipper_or,
clipper_PolyFillType subjFillType = clipper_even_odd,
clipper_PolyFillType clipFillType = clipper_even_odd,
int scaling_factor = 2) :
m_src_a(&a),
m_src_b(&b),
m_status(status_move_to),
m_vertex(-1),
m_contour(-1),
m_operation(op),
m_subjFillType(subjFillType),
m_clipFillType(clipFillType)
{
m_scaling_factor = std::max(std::min(scaling_factor, 6),0);
m_scaling_factor = Round(std::pow((double)10, m_scaling_factor));
}
~conv_clipper()
{
}
void attach1(VSA &source, clipper_PolyFillType subjFillType = clipper_even_odd)
{ m_src_a = &source; m_subjFillType = subjFillType; }
void attach2(VSB &source, clipper_PolyFillType clipFillType = clipper_even_odd)
{ m_src_b = &source; m_clipFillType = clipFillType; }
void operation(clipper_op_e v) { m_operation = v; }
void rewind(unsigned path_id);
unsigned vertex(double* x, double* y);
bool next_contour();
bool next_vertex(double* x, double* y);
void start_extracting();
void add_vertex_(double &x, double &y);
void end_contour(ClipperLib::Paths &p);
template<class VS> void add(VS &src, ClipperLib::Paths &p){
unsigned cmd;
double x; double y; double start_x; double start_y;
bool starting_first_line;
start_x = 0.0;
start_y = 0.0;
starting_first_line = true;
p.resize(0);
cmd = src->vertex( &x , &y );
while(!is_stop(cmd))
{
if(is_vertex(cmd))
{
if(is_move_to(cmd))
{
if(!starting_first_line ) end_contour(p);
start_x = x;
start_y = y;
}
add_vertex_( x, y );
starting_first_line = false;
}
else if(is_end_poly(cmd))
{
if(!starting_first_line && is_closed(cmd))
add_vertex_( start_x, start_y );
}
cmd = src->vertex( &x, &y );
}
end_contour(p);
}
};
//------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::start_extracting()
{
m_status = status_move_to;
m_contour = -1;
m_vertex = -1;
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::rewind(unsigned path_id)
{
m_src_a->rewind( path_id );
m_src_b->rewind( path_id );
add( m_src_a , m_poly_a );
add( m_src_b , m_poly_b );
m_result.resize(0);
ClipperLib::PolyFillType pftSubj, pftClip;
switch (m_subjFillType)
{
case clipper_even_odd: pftSubj = ClipperLib::pftEvenOdd; break;
case clipper_non_zero: pftSubj = ClipperLib::pftNonZero; break;
case clipper_positive: pftSubj = ClipperLib::pftPositive; break;
default: pftSubj = ClipperLib::pftNegative;
}
switch (m_clipFillType)
{
case clipper_even_odd: pftClip = ClipperLib::pftEvenOdd; break;
case clipper_non_zero: pftClip = ClipperLib::pftNonZero; break;
case clipper_positive: pftClip = ClipperLib::pftPositive; break;
default: pftClip = ClipperLib::pftNegative;
}
m_clipper.Clear();
switch( m_operation ) {
case clipper_or:
{
m_clipper.AddPaths( m_poly_a , ClipperLib::ptSubject, true );
m_clipper.AddPaths( m_poly_b , ClipperLib::ptClip, true );
m_clipper.Execute( ClipperLib::ctUnion , m_result , pftSubj, pftClip);
break;
}
case clipper_and:
{
m_clipper.AddPaths( m_poly_a , ClipperLib::ptSubject, true );
m_clipper.AddPaths( m_poly_b , ClipperLib::ptClip, true );
m_clipper.Execute( ClipperLib::ctIntersection , m_result, pftSubj, pftClip );
break;
}
case clipper_xor:
{
m_clipper.AddPaths( m_poly_a , ClipperLib::ptSubject, true );
m_clipper.AddPaths( m_poly_b , ClipperLib::ptClip, true );
m_clipper.Execute( ClipperLib::ctXor , m_result, pftSubj, pftClip );
break;
}
case clipper_a_minus_b:
{
m_clipper.AddPaths( m_poly_a , ClipperLib::ptSubject, true );
m_clipper.AddPaths( m_poly_b , ClipperLib::ptClip, true );
m_clipper.Execute( ClipperLib::ctDifference , m_result, pftSubj, pftClip );
break;
}
case clipper_b_minus_a:
{
m_clipper.AddPaths( m_poly_b , ClipperLib::ptSubject, true );
m_clipper.AddPaths( m_poly_a , ClipperLib::ptClip, true );
m_clipper.Execute( ClipperLib::ctDifference , m_result, pftSubj, pftClip );
break;
}
}
start_extracting();
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::end_contour( ClipperLib::Paths &p)
{
unsigned i, len;
if( m_vertex_accumulator.size() < 3 ) return;
len = p.size();
p.resize(len+1);
p[len].resize(m_vertex_accumulator.size());
for( i = 0 ; i < m_vertex_accumulator.size() ; i++ )
p[len][i] = m_vertex_accumulator[i];
m_vertex_accumulator.remove_all();
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::add_vertex_(double &x, double &y)
{
ClipperLib::IntPoint v;
v.X = Round(x * m_scaling_factor);
v.Y = Round(y * m_scaling_factor);
m_vertex_accumulator.add( v );
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
bool conv_clipper<VSA, VSB>::next_contour()
{
m_contour++;
if(m_contour >= (int)m_result.size()) return false;
m_vertex =-1;
return true;
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
bool conv_clipper<VSA, VSB>::next_vertex(double *x, double *y)
{
m_vertex++;
if(m_vertex >= (int)m_result[m_contour].size()) return false;
*x = (double)m_result[ m_contour ][ m_vertex ].X / m_scaling_factor;
*y = (double)m_result[ m_contour ][ m_vertex ].Y / m_scaling_factor;
return true;
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
unsigned conv_clipper<VSA, VSB>::vertex(double *x, double *y)
{
if( m_status == status_move_to )
{
if( next_contour() )
{
if( next_vertex( x, y ) )
{
m_status =status_line_to;
return path_cmd_move_to;
}
else
{
m_status = status_stop;
return path_cmd_end_poly | path_flags_close;
}
}
else
return path_cmd_stop;
}
else
{
if( next_vertex( x, y ) )
{
return path_cmd_line_to;
}
else
{
m_status = status_move_to;
return path_cmd_end_poly | path_flags_close;
}
}
}
//------------------------------------------------------------------------------
} //namespace agg
#endif //AGG_CONV_CLIPPER_INCLUDED

View file

@ -1,8 +1,8 @@
/*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 5.1.5 *
* Date : 4 May 2013 *
* Version : 6.0.0 *
* Date : 30 October 2013 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2013 *
* *
@ -35,12 +35,30 @@
#define clipper_hpp
#include <mapnik/config.hpp>
#define CLIPPER_VERSION "6.0.0"
//use_int32: When enabled 32bit ints are used instead of 64bit ints. This
//improve performance but coordinate values are limited to the range +/- 46340
//#define use_int32
//use_xyz: adds a Z member to IntPoint. Adds a minor cost to perfomance.
//#define use_xyz
//use_lines: Enables line clipping. Adds a very minor cost to performance.
//#define use_lines
//When enabled, code developed with earlier versions of Clipper
//(ie prior to ver 6) should compile without changes.
//In a future update, this compatability code will be removed.
//#define use_deprecated
#include <vector>
#include <set>
#include <stdexcept>
#include <cstring>
#include <cstdlib>
#include <ostream>
#include <functional>
namespace ClipperLib {
@ -52,23 +70,63 @@ enum PolyType { ptSubject, ptClip };
//see http://glprogramming.com/red/chapter11.html
enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
typedef signed long long long64;
typedef unsigned long long ulong64;
#ifdef use_int32
typedef int cInt;
typedef unsigned int cUInt;
#else
typedef signed long long cInt;
typedef unsigned long long cUInt;
#endif
struct IntPoint {
public:
long64 X;
long64 Y;
IntPoint(long64 x = 0, long64 y = 0): X(x), Y(y) {};
friend std::ostream& operator <<(std::ostream &s, IntPoint &p);
cInt X;
cInt Y;
#ifdef use_xyz
cInt Z;
IntPoint(cInt x = 0, cInt y = 0, cInt z = 0): X(x), Y(y), Z(z) {};
#else
IntPoint(cInt x = 0, cInt y = 0): X(x), Y(y) {};
#endif
friend inline bool operator== (const IntPoint& a, const IntPoint& b)
{
return a.X == b.X && a.Y == b.Y;
}
friend inline bool operator!= (const IntPoint& a, const IntPoint& b)
{
return a.X != b.X || a.Y != b.Y;
}
};
//------------------------------------------------------------------------------
typedef std::vector< IntPoint > Polygon;
typedef std::vector< Polygon > Polygons;
typedef std::vector< IntPoint > Path;
typedef std::vector< Path > Paths;
inline Path& operator <<(Path& poly, const IntPoint& p) {poly.push_back(p); return poly;}
inline Paths& operator <<(Paths& polys, const Path& p) {polys.push_back(p); return polys;}
std::ostream& operator <<(std::ostream &s, Polygon &p);
std::ostream& operator <<(std::ostream &s, Polygons &p);
std::ostream& operator <<(std::ostream &s, const IntPoint &p);
std::ostream& operator <<(std::ostream &s, const Path &p);
std::ostream& operator <<(std::ostream &s, const Paths &p);
#ifdef use_deprecated
typedef signed long long long64; //backward compatibility only
typedef Path Polygon;
typedef Paths Polygons;
#endif
struct DoublePoint
{
double X;
double Y;
DoublePoint(double x = 0, double y = 0) : X(x), Y(y) {}
DoublePoint(IntPoint ip) : X((double)ip.X), Y((double)ip.Y) {}
};
//------------------------------------------------------------------------------
#ifdef use_xyz
typedef void (*TZFillCallback)(IntPoint& z1, IntPoint& z2, IntPoint& pt);
#endif
class PolyNode;
typedef std::vector< PolyNode* > PolyNodes;
@ -77,13 +135,15 @@ class PolyNode
{
public:
PolyNode();
Polygon Contour;
Path Contour;
PolyNodes Childs;
PolyNode* Parent;
PolyNode* GetNext() const;
bool IsHole() const;
bool IsOpen() const;
int ChildCount() const;
private:
bool m_IsOpen;
PolyNode* GetNextSiblingUp() const;
unsigned Index; //node index in Parent.Childs
void AddChild(PolyNode& child);
@ -101,113 +161,63 @@ private:
PolyNodes AllNodes;
friend class Clipper; //to access AllNodes
};
enum JoinType { jtSquare, jtRound, jtMiter };
bool Orientation(const Polygon &poly);
MAPNIK_DECL double Area(const Polygon &poly);
enum InitOptions {ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4};
enum JoinType {jtSquare, jtRound, jtMiter};
enum EndType {etClosed, etButt, etSquare, etRound};
void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys,
double delta, JoinType jointype = jtSquare, double limit = 0, bool autoFix = true);
bool Orientation(const Path &poly);
double Area(const Path &poly);
void SimplifyPolygon(const Polygon &in_poly, Polygons &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(const Polygons &in_polys, Polygons &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(Polygons &polys, PolyFillType fillType = pftEvenOdd);
#ifdef use_deprecated
void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys,
double delta, JoinType jointype = jtSquare, double limit = 0, bool autoFix = true);
void PolyTreeToPolygons(const PolyTree& polytree, Paths& paths);
void ReversePolygon(Path& p);
void ReversePolygons(Paths& p);
#endif
void CleanPolygon(Polygon& in_poly, Polygon& out_poly, double distance = 1.415);
void CleanPolygons(Polygons& in_polys, Polygons& out_polys, double distance = 1.415);
void OffsetPaths(const Paths &in_polys, Paths &out_polys,
double delta, JoinType jointype, EndType endtype, double limit = 0);
void PolyTreeToPolygons(PolyTree& polytree, Polygons& polygons);
void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd);
void ReversePolygon(Polygon& p);
void ReversePolygons(Polygons& p);
void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415);
void CleanPolygon(Path& poly, double distance = 1.415);
void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415);
void CleanPolygons(Paths& polys, double distance = 1.415);
//used internally ...
void MinkowkiSum(const Path& poly, const Path& path, Paths& solution, bool isClosed);
void MinkowkiDiff(const Path& poly, const Path& path, Paths& solution, bool isClosed);
void PolyTreeToPaths(const PolyTree& polytree, Paths& paths);
void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths);
void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths);
void ReversePath(Path& p);
void ReversePaths(Paths& p);
struct IntRect { cInt left; cInt top; cInt right; cInt bottom; };
//enums that are used internally ...
enum EdgeSide { esLeft = 1, esRight = 2};
enum IntersectProtects { ipNone = 0, ipLeft = 1, ipRight = 2, ipBoth = 3 };
struct TEdge {
long64 xbot;
long64 ybot;
long64 xcurr;
long64 ycurr;
long64 xtop;
long64 ytop;
double dx;
long64 deltaX;
long64 deltaY;
PolyType polyType;
EdgeSide side;
int windDelta; //1 or -1 depending on winding direction
int windCnt;
int windCnt2; //winding count of the opposite polytype
int outIdx;
TEdge *next;
TEdge *prev;
TEdge *nextInLML;
TEdge *nextInAEL;
TEdge *prevInAEL;
TEdge *nextInSEL;
TEdge *prevInSEL;
};
struct IntersectNode {
TEdge *edge1;
TEdge *edge2;
IntPoint pt;
IntersectNode *next;
};
struct LocalMinima {
long64 Y;
TEdge *leftBound;
TEdge *rightBound;
LocalMinima *next;
};
struct Scanbeam {
long64 Y;
Scanbeam *next;
};
struct OutPt; //forward declaration
struct OutRec {
int idx;
bool isHole;
OutRec *FirstLeft; //see comments in clipper.pas
PolyNode *polyNode;
OutPt *pts;
OutPt *bottomPt;
};
struct OutPt {
int idx;
IntPoint pt;
OutPt *next;
OutPt *prev;
};
struct JoinRec {
IntPoint pt1a;
IntPoint pt1b;
int poly1Idx;
IntPoint pt2a;
IntPoint pt2b;
int poly2Idx;
};
struct HorzJoinRec {
TEdge *edge;
int savedIdx;
};
struct IntRect { long64 left; long64 top; long64 right; long64 bottom; };
//forward declarations (for stuff used internally) ...
struct TEdge;
struct IntersectNode;
struct LocalMinima;
struct Scanbeam;
struct OutPt;
struct OutRec;
struct Join;
typedef std::vector < OutRec* > PolyOutList;
typedef std::vector < TEdge* > EdgeList;
typedef std::vector < JoinRec* > JoinList;
typedef std::vector < HorzJoinRec* > HorzJoinList;
typedef std::vector < Join* > JoinList;
//------------------------------------------------------------------------------
//ClipperBase is the ancestor to the Clipper class. It should not be
//instantiated directly. This class simply abstracts the conversion of sets of
@ -217,29 +227,43 @@ class MAPNIK_DECL ClipperBase
public:
ClipperBase();
virtual ~ClipperBase();
bool AddPolygon(const Polygon &pg, PolyType polyType);
bool AddPolygons( const Polygons &ppg, PolyType polyType);
bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed);
bool AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed);
#ifdef use_deprecated
bool AddPolygon(const Path &pg, PolyType PolyTyp);
bool AddPolygons(const Paths &ppg, PolyType PolyTyp);
#endif
virtual void Clear();
IntRect GetBounds();
bool PreserveCollinear() {return m_PreserveCollinear;};
void PreserveCollinear(bool value) {m_PreserveCollinear = value;};
protected:
void DisposeLocalMinimaList();
TEdge* AddBoundsToLML(TEdge *e);
TEdge* AddBoundsToLML(TEdge *e, bool IsClosed);
void PopLocalMinima();
virtual void Reset();
void InsertLocalMinima(LocalMinima *newLm);
void DoMinimaLML(TEdge* E1, TEdge* E2, bool IsClosed);
TEdge* DescendToMin(TEdge *&E);
void AscendToMax(TEdge *&E, bool Appending, bool IsClosed);
LocalMinima *m_CurrentLM;
LocalMinima *m_MinimaList;
bool m_UseFullRange;
EdgeList m_edges;
bool m_PreserveCollinear;
bool m_HasOpenPaths;
};
//------------------------------------------------------------------------------
class MAPNIK_DECL Clipper : public virtual ClipperBase
{
public:
Clipper();
Clipper(int initOptions = 0);
~Clipper();
bool Execute(ClipType clipType,
Polygons &solution,
Paths &solution,
PolyFillType subjFillType = pftEvenOdd,
PolyFillType clipFillType = pftEvenOdd);
bool Execute(ClipType clipType,
@ -249,17 +273,21 @@ public:
void Clear();
bool ReverseSolution() {return m_ReverseOutput;};
void ReverseSolution(bool value) {m_ReverseOutput = value;};
bool ForceSimple() {return m_ForceSimple;};
void ForceSimple(bool value) {m_ForceSimple = value;};
bool StrictlySimple() {return m_StrictSimple;};
void StrictlySimple(bool value) {m_StrictSimple = value;};
//set the callback function for z value filling on intersections (otherwise Z is 0)
#ifdef use_xyz
void ZFillFunction(TZFillCallback zFillFunc);
#endif
protected:
void Reset();
virtual bool ExecuteInternal();
private:
PolyOutList m_PolyOuts;
JoinList m_Joins;
HorzJoinList m_HorizJoins;
JoinList m_GhostJoins;
ClipType m_ClipType;
Scanbeam *m_Scanbeam;
std::set< cInt, std::greater<cInt> > m_Scanbeam;
TEdge *m_ActiveEdges;
TEdge *m_SortedEdges;
IntersectNode *m_IntersectNodes;
@ -268,15 +296,17 @@ private:
PolyFillType m_SubjFillType;
bool m_ReverseOutput;
bool m_UsingPolyTree;
bool m_ForceSimple;
void DisposeScanbeamList();
bool m_StrictSimple;
#ifdef use_xyz
TZFillCallback m_ZFill; //custom callback
#endif
void SetWindingCount(TEdge& edge);
bool IsEvenOddFillType(const TEdge& edge) const;
bool IsEvenOddAltFillType(const TEdge& edge) const;
void InsertScanbeam(const long64 Y);
long64 PopScanbeam();
void InsertLocalMinimaIntoAEL(const long64 botY);
void InsertEdgeIntoAEL(TEdge *edge);
void InsertScanbeam(const cInt Y);
cInt PopScanbeam();
void InsertLocalMinimaIntoAEL(const cInt botY);
void InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge);
void AddEdgeToSEL(TEdge *edge);
void CopyAELToSEL();
void DeleteFromSEL(TEdge *e);
@ -284,27 +314,28 @@ private:
void UpdateEdgeIntoAEL(TEdge *&e);
void SwapPositionsInSEL(TEdge *edge1, TEdge *edge2);
bool IsContributing(const TEdge& edge) const;
bool IsTopHorz(const long64 XPos);
bool IsTopHorz(const cInt XPos);
void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2);
void DoMaxima(TEdge *e, long64 topY);
void ProcessHorizontals();
void ProcessHorizontal(TEdge *horzEdge);
void DoMaxima(TEdge *e);
void PrepareHorzJoins(TEdge* horzEdge, bool isTopOfScanbeam);
void ProcessHorizontals(bool IsTopOfScanbeam);
void ProcessHorizontal(TEdge *horzEdge, bool isTopOfScanbeam);
void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
void AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
OutPt* AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
OutRec* GetOutRec(int idx);
void AppendPolygon(TEdge *e1, TEdge *e2);
void IntersectEdges(TEdge *e1, TEdge *e2,
const IntPoint &pt, const IntersectProtects protects);
const IntPoint &pt, bool protect = false);
OutRec* CreateOutRec();
void AddOutPt(TEdge *e, const IntPoint &pt);
void DisposeAllPolyPts();
OutPt* AddOutPt(TEdge *e, const IntPoint &pt);
void DisposeAllOutRecs();
void DisposeOutRec(PolyOutList::size_type index);
bool ProcessIntersections(const long64 botY, const long64 topY);
void AddIntersectNode(TEdge *e1, TEdge *e2, const IntPoint &pt);
void BuildIntersectList(const long64 botY, const long64 topY);
bool ProcessIntersections(const cInt botY, const cInt topY);
void InsertIntersectNode(TEdge *e1, TEdge *e2, const IntPoint &pt);
void BuildIntersectList(const cInt botY, const cInt topY);
void ProcessIntersectList();
void ProcessEdgesAtTopOfScanbeam(const long64 topY);
void BuildResult(Polygons& polys);
void ProcessEdgesAtTopOfScanbeam(const cInt topY);
void BuildResult(Paths& polys);
void BuildResult2(PolyTree& polytree);
void SetHoleState(TEdge *e, OutRec *outrec);
void DisposeIntersectNodes();
@ -312,19 +343,19 @@ private:
void FixupOutPolygon(OutRec &outrec);
bool IsHole(TEdge *e);
void FixHoleLinkage(OutRec &outrec);
void AddJoin(TEdge *e1, TEdge *e2, int e1OutIdx = -1, int e2OutIdx = -1);
void AddJoin(OutPt *op1, OutPt *op2, const IntPoint offPt);
void ClearJoins();
void AddHorzJoin(TEdge *e, int idx);
void ClearHorzJoins();
bool JoinPoints(const JoinRec *j, OutPt *&p1, OutPt *&p2);
void FixupJoinRecs(JoinRec *j, OutPt *pt, unsigned startIdx);
void ClearGhostJoins();
void AddGhostJoin(OutPt *op, const IntPoint offPt);
bool JoinPoints(const Join *j, OutPt *&p1, OutPt *&p2);
void JoinCommonEdges();
void DoSimplePolygons();
void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec);
void FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec);
#ifdef use_xyz
void SetZ(IntPoint& pt, TEdge& e);
#endif
};
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
class clipperException : public std::exception

File diff suppressed because it is too large Load diff

View file

@ -1,20 +1,22 @@
# This file is part of Mapnik (c++ mapping toolkit)
# Copyright (C) 2005 Artem Pavlenko, Jean-Francois Doyon
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik 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
#
#
import os

View file

@ -1,3 +1,24 @@
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik 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
#
#
import os
from glob import glob

View file

@ -125,8 +125,13 @@ struct integer_parser
typedef qi::int_parser<T,10,1,-1> type;
};
#ifdef __GNUC__
template <typename Iterator>
struct MAPNIK_DECL expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
#else
template <typename Iterator>
struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
#endif
{
typedef qi::rule<Iterator, expr_node(), space_type> rule_type;

View file

@ -2,7 +2,7 @@
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Hermann Kraus
* 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

View file

@ -140,7 +140,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
clip_box.pad(padding);
}
typedef boost::mpl::vector<clip_line_tag,transform_tag,offset_transform_tag,simplify_tag,smooth_tag> conv_types;
typedef boost::mpl::vector<clip_line_tag,transform_tag,offset_transform_tag,affine_transform_tag,simplify_tag,smooth_tag> conv_types;
vertex_converter<box2d<double>, rasterizer_type, line_pattern_symbolizer,
CoordTransform, proj_transform, agg::trans_affine, conv_types>
converter(clip_box,ras,sym,t_,prj_trans,tr,scale_factor_);
@ -149,6 +149,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
converter.set<transform_tag>(); //always transform
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (std::fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
converter.set<affine_transform_tag>(); // optional affine transform
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
for (geometry_type & geom : feature.paths())

View file

@ -148,13 +148,14 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
agg::trans_affine tr;
evaluate_transform(tr, feature, sym.get_transform());
typedef boost::mpl::vector<clip_poly_tag,transform_tag,simplify_tag,smooth_tag> conv_types;
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag> conv_types;
vertex_converter<box2d<double>, rasterizer, polygon_pattern_symbolizer,
CoordTransform, proj_transform, agg::trans_affine, conv_types>
converter(clip_box,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_);
if (prj_trans.equal() && sym.clip()) converter.set<clip_poly_tag>(); //optional clip (default: true)
converter.set<transform_tag>(); //always transform
converter.set<affine_transform_tag>(); // optional affine transform
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter

View file

@ -1,7 +1,7 @@
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public

View file

@ -76,6 +76,7 @@
// stl
#include <deque>
#include <cmath>
namespace mapnik
{
@ -784,8 +785,8 @@ void cairo_renderer_base::process(line_pattern_symbolizer const& sym,
{
double dx = x - x0;
double dy = y - y0;
double angle = atan2(dy, dx);
double offset = fmod(length, width);
double angle = std::atan2(dy, dx);
double offset = std::fmod(length, width);
cairo_matrix_t matrix;
cairo_matrix_init_identity(&matrix);

View file

@ -27,6 +27,10 @@
#include <mapnik/grid/grid_renderer_base.hpp>
#include <mapnik/grid/grid.hpp>
#include <mapnik/line_pattern_symbolizer.hpp>
#include <mapnik/marker.hpp>
#include <mapnik/marker_cache.hpp>
#include <mapnik/vertex_converters.hpp>
#include <mapnik/parse_path.hpp>
// agg
#include "agg_rasterizer_scanline_aa.h"
@ -45,10 +49,27 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<marker_ptr> mark = marker_cache::instance().find(filename,true);
if (!mark) return;
if (!(*mark)->is_bitmap())
{
MAPNIK_LOG_DEBUG(agg_renderer) << "agg_renderer: Only images (not '" << filename << "') are supported in the line_pattern_symbolizer";
return;
}
boost::optional<image_ptr> pat = (*mark)->get_bitmap_data();
if (!pat) return;
typedef coord_transform<CoordTransform,geometry_type> path_type;
typedef typename grid_renderer_base_type::pixfmt_type pixfmt_type;
typedef typename grid_renderer_base_type::pixfmt_type::color_type color_type;
typedef agg::renderer_scanline_bin_solid<grid_renderer_base_type> renderer_type;
typedef boost::mpl::vector<clip_line_tag, transform_tag,
offset_transform_tag, affine_transform_tag,
simplify_tag, smooth_tag, stroke_tag> conv_types;
agg::scanline_bin sl;
grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_);
@ -59,19 +80,45 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
ras_ptr->reset();
// TODO - actually handle image dimensions
int stroke_width = 2;
int stroke_width = (*pat)->width();
for (std::size_t i=0;i<feature.num_geometries();++i)
agg::trans_affine tr;
evaluate_transform(tr, feature, sym.get_transform());
box2d<double> clipping_extent = query_extent_;
if (sym.clip())
{
double padding = (double)(query_extent_.width()/pixmap_.width());
double half_stroke = stroke_width/2.0;
if (half_stroke > 1)
padding *= half_stroke;
if (std::fabs(sym.offset()) > 0)
padding *= std::fabs(sym.offset()) * 1.2;
padding *= scale_factor_;
clipping_extent.pad(padding);
}
// to avoid the complexity of using an agg pattern filter instead
// we create a line_symbolizer in order to fake the pattern
stroke str;
str.set_width(stroke_width);
line_symbolizer line(str);
vertex_converter<box2d<double>, grid_rasterizer, line_symbolizer,
CoordTransform, proj_transform, agg::trans_affine, conv_types>
converter(clipping_extent,*ras_ptr,line,t_,prj_trans,tr,scale_factor_);
if (sym.clip()) converter.set<clip_line_tag>(); // optional clip (default: true)
converter.set<transform_tag>(); // always transform
if (std::fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
converter.set<affine_transform_tag>(); // optional affine transform
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
converter.set<stroke_tag>(); //always stroke
for (geometry_type & geom : feature.paths())
{
geometry_type & geom = feature.get_geometry(i);
if (geom.size() > 1)
{
path_type path(t_,geom,prj_trans);
agg::conv_stroke<path_type> stroke(path);
stroke.generator().miter_limit(4.0);
stroke.generator().width(stroke_width * scale_factor_);
ras_ptr->add_path(stroke);
converter.apply(geom);
}
}

View file

@ -31,6 +31,9 @@
#include <mapnik/grid/grid.hpp>
#include <mapnik/polygon_pattern_symbolizer.hpp>
#include <mapnik/vertex_converters.hpp>
#include <mapnik/marker.hpp>
#include <mapnik/marker_cache.hpp>
#include <mapnik/parse_path.hpp>
// agg
#include "agg_rasterizer_scanline_aa.h"
@ -48,6 +51,20 @@ void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<marker_ptr> mark = marker_cache::instance().find(filename,true);
if (!mark) return;
if (!(*mark)->is_bitmap())
{
MAPNIK_LOG_DEBUG(agg_renderer) << "agg_renderer: Only images (not '" << filename << "') are supported in the line_pattern_symbolizer";
return;
}
boost::optional<image_ptr> pat = (*mark)->get_bitmap_data();
if (!pat) return;
ras_ptr->reset();
agg::trans_affine tr;

View file

@ -24,6 +24,7 @@
#include <stdexcept>
#ifdef _WINDOWS
#define NOMINMAX
#include <windows.h>
#define handle HMODULE
#define dlsym GetProcAddress

View file

@ -130,8 +130,8 @@ png_reader<T>::png_reader(std::string const& file_name)
bit_depth_(0),
color_type_(0)
{
if (!stream_) throw image_reader_exception("PNG reader: cannot open file "+ file_name);
if (!source_.is_open()) throw image_reader_exception("PNG reader: cannot open file '"+ file_name + "'");
if (!stream_) throw image_reader_exception("PNG reader: cannot open file '"+ file_name + "'");
init();
}
@ -145,7 +145,7 @@ png_reader<T>::png_reader(char const* data, std::size_t size)
color_type_(0)
{
if (!stream_) throw image_reader_exception("cannot open image stream");
if (!stream_) throw image_reader_exception("PNG reader: cannot open image stream");
init();
}
@ -162,7 +162,7 @@ void png_reader<T>::init()
stream_.read(reinterpret_cast<char*>(header),8);
if ( stream_.gcount() != 8)
{
throw image_reader_exception("Could not read image");
throw image_reader_exception("PNG reader: Could not read image");
}
int is_png=!png_sig_cmp(header,0,8);
if (!is_png)

View file

@ -25,7 +25,7 @@
#include <mapnik/utils.hpp>
#include <string>
#include <vector>
#define NOMINMAX
#include <windows.h>
namespace mapnik {

View file

@ -0,0 +1,59 @@
{
"keys": [
"",
"1"
],
"data": {},
"grid": [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!! !!!!!!!!!!! ",
" !!!!!!!!!!! !!!!!!!!!!! ",
" !!!!!!!!!!! !!!!!!!!!!! ",
" !!!!!!!!!!! !!!!!!!!!!! ",
" !!!!!!!!!!! !!!!!!!!!!! ",
" !!!!!!!!!!! !!!!!!!!!!! ",
" !!!!!!!!!!! !!!!!!!!!!! ",
" !!!!!!!!!!! !!!!!!!!!!! ",
" !!!!!!!!!!! !!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
}

View file

@ -32,33 +32,33 @@
" ",
" ",
" ",
" ",
" !!!!! ########### $$$$$$$$$$ %%%%%%% ",
" !!! !!! ### ### $$$ $$$ %%%% %%% ",
" !! !! ## ## $$ $$ %% %%% ",
" !! !! ## ## $ $$ %% % ",
" !! ! # # $$ $ % %% ",
" ! !! # # $$ $ %% % ",
" ! !! # # $ $ %% % ",
" !! ! # # $ $ % % ",
" ! ! # # $ $ % % ",
" ! ! # # $ $ % % ",
" ! ! # # $ $ % % ",
" ! ! &&&&& # $ $ % % ",
" ! '''''''''''''''''''''''''''''' # # $ $ % (((((((((((( ",
" ! ! # # $ $ % % ",
" ! ! # $ $ % ",
" ! # # $ % ",
" ! ! ## # $ $ % % ",
" ! ! # # $ $ % % ",
" !! ! # # $ $ % % ",
" !! ! ## ## $$ $ % % ",
" ! !! # # $ $$ %% %% ",
" !! !! ## ### $$ $$ %% %% ",
" !! !! ### ### $$$ $$$ %%% %%% ",
" !!!!! !!!!!! ######### $$$$$$$$$$ %%%%%%%%%%%% ",
" ",
" ",
" !!!!!!!!! ############# $$$$$$$$$$$$ %%%%%%%%%%% ",
" !!!!!!!!!!!!!!!!! ##################### $$$$$$$$$$$$$$$$$$$$ %%%%%%%%%%%%%%%%%%% ",
" !!!!!!!!!!!!!!!!!!!!!!! ######################### $$$$$$$$$$$$$$$$$$$$$$$$ %%%%%%%%%%%%%%%%%%%%%%% ",
" !!!!!!!!!!! !!!!!!!!!!!! ######## ######### $$$$$$$$$ $$$$$$$$$$ %%%%%%%%%% %%%%%%%%%% ",
" !!!!!!! !!!!!!! ####### ####### $$$$$$ $$$$$$$ %%%%%%% %%%%%%%% ",
" !!!!!! !!!!!! ###### ###### $$$$$ $$$$$$ %%%%% %%%%%% ",
" !!!!!! !!!!! ##### ##### $$$$$ $$$$$ %%%%% %%%%% ",
" !!!! !!!!! ##### ##### $$$$ $$$$$ %%%% %%%%% ",
" !!!! !!!! #### #### $$$$ $$$$ %%%% %%%% ",
" !!!! !!!! #### #### $$$ $$$$ %%%% %%%% ",
" !!!! !!!! #### #### $$$$ $$$ %%%% %%%% ",
" !!! !!!! ### ### $$$$ $$$ %%%% %%% ",
" !!! !!! #&&&&& ### $$$ $$$ %%% %%% ",
" !!! ''''''''''''''''''''''''''''''! ### ### $$$ $$$ %%% ((((((((((((% ",
" !!! !!! ### ### $$$$ $$$ %%% %%% ",
" !!! !!!! #### #### $$$$ $$$ %%%% %%% ",
" !!!! !!! ### #### $$$ $$$$ %%% %%%% ",
" !!!! !!!! #### #### $$$$ $$$$ %%%% %%%% ",
" !!!! !!!!! #### #### $$$$ $$$$$ %%%% %%%%% ",
" !!!!! !!!!! ##### ##### $$$$ $$$$$ %%%%% %%%%% ",
" !!!!! !!!!! ###### ###### $$$$$$ $$$$$$ %%%%%% %%%%% ",
" !!!!!! !!!!!! ####### ####### $$$$$$ $$$$$$$ %%%%%%% %%%%%% ",
" !!!!!!!! !!!!!!!! ########## ########## $$$$$$$$$ $$$$$$$$$ %%%%%%%% %%%%%%%%% ",
" !!!!!!!!!!!!!!!!!!!!!!!!! ####################### $$$$$$$$$$$$$$$$$$$$$$$$ %%%%%%%%%%%%%%%%%%%%%%%%% ",
" !!!!!!!!!!!!!!!!!!!!! ################### $$$$$$$$$$$$$$$$$$$$ %%%%%%%%%%%%%%%%%%%%% ",
" !!!!!!!!!!!!!!! ########### $$$$$$$$$$$$$ %%%%%%%%%%%%%% ",
" !!! ",
" ",
" ",
" ",

View file

@ -1,12 +1,12 @@
{
"keys": [
"",
"4",
"3",
"4",
"2",
"1",
"8",
"7",
"8",
"6",
"5"
],
@ -67,24 +67,24 @@
" ",
" ",
" ",
" ",
" !!!!!!!! ##### ##### $$$$$$$$$$ %%%%%%%%% ",
" !! !! ### ## $$ $$ %% %% ",
" !! ! # # $$ $$ %% %% ",
" !! !! # # $$ $ % % ",
" ! !! # # $ $ % % ",
" ! ! # # $ $ % %",
"! ! # $ $ % ",
"! ! # $ $ % ",
"&&&&&&&&&&&&&&&&&&&&&&&&&& ''''''''''''''''''''''# (((((((((((((((((((((((((( )))))))))))))))))))))))))",
"! ! $ $ % ",
"! ! # # $ $ % %",
" ! ! ## # $ $ %% %",
" !! ! # # $ $ % % ",
" !! !! ## ## $ $ %% % ",
" ! ! ## # $$ $$ %% %% ",
" !!! !!! ### ### $$$ $$ %%% %% ",
" !!!!!!!!!! ##### $$$$$$$$ %%%%%%%% ",
" !! ",
" ########## !!!!!!!!!!!!! $$$$$$$$$$$$ %%%%%%%%%%% ",
" #### #### !!! !!! $$$ $$$ %%%% %%%% ",
" ### ### !!! !!! $$$ $$ %% %%% ",
" ## ## !! !! $$ $$ %% %% ",
" ## ## !! !! $$ $$ %% %%",
" # ## ! ! $$ $$ %% %",
"## # !! !! $ $ % %",
"# # !&&&& ! $ $ %% ",
"'''''''''''''''''''''''''' !&&&&&&&&&&&&&&&&&&&&&&&&&! (((((((((((((((((((((((((( %)))))))))))))))))))))))))",
"# # !! !! $ $ %% ",
"# # ! ! $$ $ % %",
"## ## !! !! $ $ %% %",
" ## ## !! !! $$ $$ %% %%",
" ## ## !! !! $$$ $$ %% %%% ",
" ### ### !!! !!! $$ $$$ %%% %% ",
" #### #### !!!!! !!!!! $$$$$ $$$$$ %%%% %%%%% ",
" ############ !!!!!!!!! $$$$$$$$$$ %%%%%%%%%%% ",
" ",
" ",
" ",

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View file

@ -0,0 +1,99 @@
<Map background-color="#eee" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<Style name="polygon">
<Rule>
<PolygonPatternSymbolizer
file="../../data/images/stripes_pattern.png"
geometry-transform="translate(2,2)"
/>
<PolygonPatternSymbolizer
file="../data/pattern.png"
/>
</Rule>
</Style>
<Style name="line">
<Rule>
<LinePatternSymbolizer
file="../../data/images/stripes_pattern.png"
geometry-transform="translate(-3,-3)"
/>
<LinePatternSymbolizer
file="../../data/images/stripes_pattern.png"
geometry-transform="translate(3,3)"
/>
</Rule>
</Style>
<Style name="point">
<Rule>
<MarkersSymbolizer
fill="#437"
width="10"
stroke-width="0"
transform="translate(2,2)"
allow-overlap="true"
/>
<MarkersSymbolizer
fill="#ec3"
width="10"
stroke-width="0"
allow-overlap="true"
/>
</Rule>
</Style>
<Layer name="polygon" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<StyleName>polygon</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
wkt
"POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1), (2 2, 2 3, 3 3, 3 2, 2 2))"
</Parameter>
</Datasource>
</Layer>
<Layer name="line" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<StyleName>line</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
wkt
"LINESTRING (0.5 0.5, 4.5 4.5)"
</Parameter>
</Datasource>
</Layer>
<Layer name="point" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<StyleName>point</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
wkt
"POINT (1 4)"
</Parameter>
</Datasource>
</Layer>
<!-- points to frame data view -->
<Style name="frame">
<Rule>
<PointSymbolizer />
</Rule>
</Style>
<Layer name="frame" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<StyleName>frame</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
x,y
0,0
5,0
0,5
5,5
</Parameter>
</Datasource>
</Layer>
</Map>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map background-color="white" srs="+proj=latlong +datum=WGS84" font-directory="/usr/share/fonts/truetype/tlwg/">
<Map background-color="white" srs="+proj=latlong +datum=WGS84">
<Layer name="layer" srs="+proj=latlong +datum=WGS84">
<StyleName>My Style</StyleName>
<Datasource>

View file

@ -100,6 +100,7 @@ files = {
'shield-on-polygon': {'sizes':[(600,400)]},
'shield-on-line-spacing-eq-width': {'sizes':[(600,400)]},
'geometry-transform-translate': {'sizes':[(200,200)]},
'geometry-transform-translate-patterns': {'sizes':[(200,200)]},
'marker-svg-opacity':{},
'marker-svg-opacity2':{},
'marker-svg-empty-g-element':{},

View file

@ -1,3 +1,23 @@
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik 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
#
#
import re
import os

View file

@ -1,7 +1,7 @@
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public

View file

@ -1,7 +1,7 @@
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2010 Artem Pavlenko
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@ -19,6 +19,7 @@
#
#
import os
Import ('env')

View file

@ -1,7 +1,7 @@
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2009 Artem Pavlenko, Dane Springmeyer
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@ -19,6 +19,7 @@
#
#
import os
from copy import copy

View file

@ -1,7 +1,7 @@
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public

View file

@ -1,7 +1,7 @@
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public

View file

@ -1,7 +1,7 @@
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public