Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merge with master

  • Loading branch information...
commit 982a2b940ed7613c3555e3860c53c511a3a667a5 2 parents 965181b + f0bc106
@springmeyer springmeyer authored
Showing with 2,198 additions and 1,873 deletions.
  1. +1 −1  bindings/python/mapnik_image.cpp
  2. +5 −1 bindings/python/mapnik_polygon_symbolizer.cpp
  3. +51 −51 bindings/python/mapnik_text_placement.cpp
  4. +7 −7 bindings/python/mapnik_threads.hpp
  5. +4 −4 bindings/python/python_optional.hpp
  6. +3 −1 demo/python/rundemo.py
  7. +2 −1  demo/viewer/mapwidget.cpp
  8. +91 −0 include/mapnik/agg_helpers.hpp
  9. +1 −1  include/mapnik/agg_renderer.hpp
  10. +90 −0 include/mapnik/boolean.hpp
  11. +8 −0 include/mapnik/color.hpp
  12. +6 −114 include/mapnik/color_factory.hpp
  13. +0 −2  include/mapnik/config.hpp
  14. +13 −16 include/mapnik/config_error.hpp
  15. +1 −1  include/mapnik/expression.hpp
  16. +2 −2 include/mapnik/expression_grammar.hpp
  17. +12 −12 include/mapnik/feature.hpp
  18. +1 −1  include/mapnik/font_engine_freetype.hpp
  19. +2 −1  include/mapnik/formatting/base.hpp
  20. +2 −2 include/mapnik/formatting/expression.hpp
  21. +1 −1  include/mapnik/formatting/format.hpp
  22. +3 −3 include/mapnik/formatting/registry.hpp
  23. +1 −1  include/mapnik/formatting/text.hpp
  24. +1 −1  include/mapnik/geometry.hpp
  25. +2 −2 include/mapnik/hextree.hpp
  26. +18 −10 include/mapnik/internal/dump_xml.hpp
  27. +2 −1  include/mapnik/metawriter_factory.hpp
  28. +0 −1  include/mapnik/palette.hpp
  29. +6 −6 include/mapnik/placement_finder.hpp
  30. +4 −2 include/mapnik/polygon_symbolizer.hpp
  31. +0 −433 include/mapnik/ptree_helpers.hpp
  32. +0 −1  include/mapnik/raster_colorizer.hpp
  33. +1 −1  include/mapnik/symbolizer_helpers.hpp
  34. +1 −1  include/mapnik/text_placements/list.hpp
  35. +3 −3 include/mapnik/text_placements/registry.hpp
  36. +1 −1  include/mapnik/text_placements/simple.hpp
  37. +2 −2 include/mapnik/text_properties.hpp
  38. +9 −9 include/mapnik/util/conversions.hpp
  39. +0 −1  include/mapnik/value.hpp
  40. +4 −4 include/mapnik/vertex_vector.hpp
  41. +3 −5 include/mapnik/{libxml2_loader.hpp → xml_loader.hpp}
  42. +137 −0 include/mapnik/xml_node.hpp
  43. +62 −0 include/mapnik/xml_tree.hpp
  44. +2 −1  plugins/input/csv/csv_datasource.cpp
  45. +1 −1  plugins/input/gdal/gdal_datasource.cpp
  46. +1 −1  plugins/input/geos/geos_datasource.cpp
  47. +1 −1  plugins/input/kismet/kismet_datasource.cpp
  48. +1 −1  plugins/input/occi/occi_datasource.cpp
  49. +1 −1  plugins/input/occi/occi_featureset.cpp
  50. +1 −1  plugins/input/ogr/ogr_datasource.cpp
  51. +17 −17 plugins/input/postgis/postgis_datasource.cpp
  52. +1 −1  plugins/input/rasterlite/rasterlite_datasource.cpp
  53. +1 −1  plugins/input/shape/dbfile.cpp
  54. +2 −2 plugins/input/shape/shape_index_featureset.cpp
  55. +5 −5 plugins/input/shape/shape_io.cpp
  56. +1 −1  plugins/input/sqlite/sqlite_datasource.cpp
  57. +0 −1  src/agg/agg_renderer.cpp
  58. +16 −65 src/agg/process_line_symbolizer.cpp
  59. +1 −1  src/agg/process_markers_symbolizer.cpp
  60. +4 −22 src/agg/process_polygon_pattern_symbolizer.cpp
  61. +27 −27 src/agg/process_polygon_symbolizer.cpp
  62. +9 −1 src/build.py
  63. +36 −22 src/cairo_renderer.cpp
  64. +97 −0 src/color.cpp
  65. +55 −0 src/config_error.cpp
  66. +9 −9 src/conversions.cpp
  67. +3 −2 src/expression.cpp
  68. +1 −2  src/feature_style_processor.cpp
  69. +6 −5 src/formatting/base.cpp
  70. +13 −12 src/formatting/expression.cpp
  71. +13 −12 src/formatting/format.cpp
  72. +6 −3 src/formatting/registry.cpp
  73. +3 −7 src/formatting/text.cpp
  74. +0 −1  src/grid/grid_renderer.cpp
  75. +18 −18 src/json/feature_collection_parser.cpp
  76. +35 −35 src/json/geojson_generator.cpp
  77. +1 −0  src/layer.cpp
  78. +46 −69 src/libxml2_loader.cpp
  79. +400 −722 src/load_map.cpp
  80. +2 −2 src/map.cpp
  81. +14 −11 src/metawriter_factory.cpp
  82. +1 −0  src/palette.cpp
  83. +15 −15 src/placement_finder.cpp
  84. +14 −2 src/polygon_symbolizer.cpp
  85. +25 −1 src/processed_text.cpp
  86. +171 −0 src/rapidxml_loader.cpp
  87. +4 −0 src/save_map.cpp
  88. +1 −0  src/svg_parser.cpp
  89. +1 −1  src/symbolizer_helpers.cpp
  90. +1 −2  src/text_placements/dummy.cpp
  91. +11 −8 src/text_placements/list.cpp
  92. +3 −2 src/text_placements/registry.cpp
  93. +9 −7 src/text_placements/simple.cpp
  94. +37 −35 src/text_properties.cpp
  95. +483 −0 src/xml_tree.cpp
  96. +2 −7 tests/python_tests/object_test.py
  97. +5 −1 tests/visual_tests/compare.py
  98. +1 −1  tests/visual_tests/shieldsymbolizer-1.xml
  99. +1 −1  tests/visual_tests/test.py
View
2  bindings/python/mapnik_image.cpp
@@ -125,7 +125,7 @@ bool painted(mapnik::image_32 const& im)
void set_pixel(mapnik::image_32 & im, unsigned x, unsigned y, mapnik::color const& c)
{
im.setPixel(x, y, c.rgba());
-}
+}
boost::shared_ptr<image_32> open_from_file(std::string const& filename)
{
View
6 bindings/python/mapnik_polygon_symbolizer.cpp
@@ -84,7 +84,11 @@ void export_polygon_symbolizer()
.add_property("gamma_method",
&polygon_symbolizer::get_gamma_method,
&polygon_symbolizer::set_gamma_method,
- "Set/get the gamma correction method of the polygon")
+ "gamma correction method")
+ .add_property("smooth",
+ &polygon_symbolizer::smooth,
+ &polygon_symbolizer::set_smooth,
+ "smooth value (0..1.0)")
;
}
View
102 bindings/python/mapnik_text_placement.cpp
@@ -40,15 +40,15 @@
using namespace mapnik;
/* Notes:
-Overriding functions in inherited classes:
-boost.python documentation doesn't really tell you how to do it.
-But this helps:
-http://www.gamedev.net/topic/446225-inheritance-in-boostpython/
+ Overriding functions in inherited classes:
+ boost.python documentation doesn't really tell you how to do it.
+ But this helps:
+ http://www.gamedev.net/topic/446225-inheritance-in-boostpython/
-register_ptr_to_python is required for wrapped classes, but not for unwrapped.
+ register_ptr_to_python is required for wrapped classes, but not for unwrapped.
-Functions don't have to be members of the class, but can also be
-normal functions taking a ref to the class as first parameter.
+ Functions don't have to be members of the class, but can also be
+ normal functions taking a ref to the class as first parameter.
*/
namespace {
@@ -261,7 +261,7 @@ struct TextPlacementsWrap: text_placements, wrapper<text_placements>
struct TextPlacementInfoWrap: text_placement_info, wrapper<text_placement_info>
{
TextPlacementInfoWrap(text_placements const* parent,
- double scale_factor_)
+ double scale_factor_)
: text_placement_info(parent, scale_factor_)
{
@@ -339,7 +339,7 @@ void export_text_placement()
;
class_<text_symbolizer>("TextSymbolizer",
- init<>())
+ init<>())
.def(init<expression_ptr, std::string const&, unsigned, color const&>())
.add_property("placements",
&text_symbolizer::get_placement_options,
@@ -357,7 +357,7 @@ void export_text_placement()
class_with_converter<text_symbolizer_properties>
- ("TextSymbolizerProperties")
+ ("TextSymbolizerProperties")
.def_readwrite_convert("label_placement", &text_symbolizer_properties::label_placement)
.def_readwrite_convert("horizontal_alignment", &text_symbolizer_properties::halign)
.def_readwrite_convert("justify_alignment", &text_symbolizer_properties::jalign)
@@ -381,15 +381,15 @@ void export_text_placement()
.add_property ("format_tree",
&text_symbolizer_properties::format_tree,
&text_symbolizer_properties::set_format_tree);
- /* from_xml, to_xml operate on mapnik's internal XML tree and don't make sense in python.
- add_expressions isn't useful in python either. The result is only needed by
- attribute_collector (which isn't exposed in python) and
- it just calls add_expressions of the associated formatting tree.
- set_old_style expression is just a compatibility wrapper and doesn't need to be exposed in python. */
- ;
+ /* from_xml, to_xml operate on mapnik's internal XML tree and don't make sense in python.
+ add_expressions isn't useful in python either. The result is only needed by
+ attribute_collector (which isn't exposed in python) and
+ it just calls add_expressions of the associated formatting tree.
+ set_old_style expression is just a compatibility wrapper and doesn't need to be exposed in python. */
+ ;
class_<char_properties>
- ("CharProperties")
+ ("CharProperties")
.def(init<char_properties const&>()) //Copy constructor
.def_readwrite("face_name", &char_properties::face_name)
.def_readwrite("fontset", &char_properties::fontset)
@@ -407,9 +407,9 @@ void export_text_placement()
;
class_<TextPlacementsWrap,
- boost::shared_ptr<TextPlacementsWrap>,
- boost::noncopyable>
- ("TextPlacements")
+ boost::shared_ptr<TextPlacementsWrap>,
+ boost::noncopyable>
+ ("TextPlacements")
.def_readwrite("defaults", &text_placements::defaults)
.def("get_placement_info", pure_virtual(&text_placements::get_placement_info))
/* TODO: add_expressions() */
@@ -417,10 +417,10 @@ void export_text_placement()
register_ptr_to_python<boost::shared_ptr<text_placements> >();
class_<TextPlacementInfoWrap,
- boost::shared_ptr<TextPlacementInfoWrap>,
- boost::noncopyable>
- ("TextPlacementInfo",
- init<text_placements const*, double>())
+ boost::shared_ptr<TextPlacementInfoWrap>,
+ boost::noncopyable>
+ ("TextPlacementInfo",
+ init<text_placements const*, double>())
.def("next", pure_virtual(&text_placement_info::next))
.def("get_actual_label_spacing", &text_placement_info::get_actual_label_spacing)
.def("get_actual_minimum_distance", &text_placement_info::get_actual_minimum_distance)
@@ -432,27 +432,27 @@ void export_text_placement()
class_<processed_text,
- boost::shared_ptr<processed_text>,
- boost::noncopyable>
- ("ProcessedText", no_init)
+ boost::shared_ptr<processed_text>,
+ boost::noncopyable>
+ ("ProcessedText", no_init)
.def("push_back", &processed_text::push_back)
.def("clear", &processed_text::clear)
;
class_<expression_set,
- boost::shared_ptr<expression_set>,
- boost::noncopyable>
- ("ExpressionSet")
+ boost::shared_ptr<expression_set>,
+ boost::noncopyable>
+ ("ExpressionSet")
.def("insert", &insert_expression);
- ;
+ ;
//TODO: Python namespace
class_<NodeWrap,
- boost::shared_ptr<NodeWrap>,
- boost::noncopyable>
- ("FormattingNode")
+ boost::shared_ptr<NodeWrap>,
+ boost::noncopyable>
+ ("FormattingNode")
.def("apply", pure_virtual(&formatting::node::apply))
.def("add_expressions",
&formatting::node::add_expressions,
@@ -462,10 +462,10 @@ void export_text_placement()
class_<TextNodeWrap,
- boost::shared_ptr<TextNodeWrap>,
- bases<formatting::node>,
- boost::noncopyable>
- ("FormattingText", init<expression_ptr>())
+ boost::shared_ptr<TextNodeWrap>,
+ bases<formatting::node>,
+ boost::noncopyable>
+ ("FormattingText", init<expression_ptr>())
.def(init<std::string>())
.def("apply", &formatting::text_node::apply, &TextNodeWrap::default_apply)
.add_property("text",
@@ -476,10 +476,10 @@ void export_text_placement()
class_with_converter<FormatNodeWrap,
- boost::shared_ptr<FormatNodeWrap>,
- bases<formatting::node>,
- boost::noncopyable>
- ("FormattingFormat")
+ boost::shared_ptr<FormatNodeWrap>,
+ bases<formatting::node>,
+ boost::noncopyable>
+ ("FormattingFormat")
.def_readwrite_convert("text_size", &formatting::format_node::text_size)
.def_readwrite_convert("face_name", &formatting::format_node::face_name)
.def_readwrite_convert("character_spacing", &formatting::format_node::character_spacing)
@@ -499,10 +499,10 @@ void export_text_placement()
register_ptr_to_python<boost::shared_ptr<formatting::format_node> >();
class_<ListNodeWrap,
- boost::shared_ptr<ListNodeWrap>,
- bases<formatting::node>,
- boost::noncopyable>
- ("FormattingList", init<>())
+ boost::shared_ptr<ListNodeWrap>,
+ bases<formatting::node>,
+ boost::noncopyable>
+ ("FormattingList", init<>())
.def(init<list>())
.def("append", &formatting::list_node::push_back)
.def("apply", &formatting::list_node::apply, &ListNodeWrap::default_apply)
@@ -510,15 +510,15 @@ void export_text_placement()
.def("__getitem__", &ListNodeWrap::get_item)
.def("__setitem__", &ListNodeWrap::set_item)
.def("append", &ListNodeWrap::append)
- ;
+ ;
register_ptr_to_python<boost::shared_ptr<formatting::list_node> >();
class_<ExprFormatWrap,
- boost::shared_ptr<ExprFormatWrap>,
- bases<formatting::node>,
- boost::noncopyable>
- ("FormattingExpressionFormat")
+ boost::shared_ptr<ExprFormatWrap>,
+ bases<formatting::node>,
+ boost::noncopyable>
+ ("FormattingExpressionFormat")
.def_readwrite("text_size", &formatting::expression_format::text_size)
.def_readwrite("face_name", &formatting::expression_format::face_name)
.def_readwrite("character_spacing", &formatting::expression_format::character_spacing)
View
14 bindings/python/mapnik_threads.hpp
@@ -29,8 +29,8 @@ namespace mapnik {
class python_thread
{
/* Docs:
- http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock
- */
+ http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock
+ */
public:
static void unblock()
{
@@ -38,8 +38,8 @@ class python_thread
if (state.get())
{
std::cerr << "ERROR: Python threads are already unblocked. "
- "Unblocking again will loose the current state and "
- "might crash later. Aborting!\n";
+ "Unblocking again will loose the current state and "
+ "might crash later. Aborting!\n";
abort(); //This is a serious error and can't be handled in any other sane way
}
#endif
@@ -59,9 +59,9 @@ class python_thread
if (thread_support && !state.get())
{
std::cerr << "ERROR: Trying to restore python thread state, "
- "but no state is saved. Can't continue and also "
- "can't raise an exception because the python "
- "interpreter might be non-function. Aborting!\n";
+ "but no state is saved. Can't continue and also "
+ "can't raise an exception because the python "
+ "interpreter might be non-function. Aborting!\n";
abort();
}
#endif
View
8 bindings/python/python_optional.hpp
@@ -102,8 +102,8 @@ struct python_optional : public boost::noncopyable
/** This class works around a bug in boost python.
- See http://osdir.com/ml/python.c++/2003-11/msg00158.html
- */
+ See http://osdir.com/ml/python.c++/2003-11/msg00158.html
+*/
template <typename T, typename X1 = boost::python::detail::not_specified, typename X2 = boost::python::detail::not_specified, typename X3 = boost::python::detail::not_specified>
class class_with_converter : public boost::python::class_<T, X1, X2, X3>
{
@@ -131,8 +131,8 @@ class class_with_converter : public boost::python::class_<T, X1, X2, X3>
self& def_readwrite_convert(char const* name, D const& d, char const* doc=0)
{
this->add_property(name,
- boost::python::make_getter(d, boost::python::return_value_policy<boost::python::return_by_value>()),
- boost::python::make_setter(d, boost::python::default_call_policies()));
+ boost::python::make_getter(d, boost::python::return_value_policy<boost::python::return_by_value>()),
+ boost::python::make_setter(d, boost::python::default_call_policies()));
return *this;
}
};
View
4 demo/python/rundemo.py
@@ -138,7 +138,9 @@
qcdrain_style = mapnik.Style()
qcdrain_rule = mapnik.Rule()
qcdrain_rule.filter = mapnik.Expression('[HYC] = 8')
-qcdrain_rule.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color(153, 204, 255)))
+sym = mapnik.PolygonSymbolizer(mapnik.Color(153, 204, 255))
+sym.smooth = 1.0 # very smooth
+qcdrain_rule.symbols.append(sym)
qcdrain_style.rules.append(qcdrain_rule)
m.append_style('drainage', qcdrain_style)
View
3  demo/viewer/mapwidget.cpp
@@ -30,6 +30,7 @@
#include <mapnik/ctrans.hpp>
#include <mapnik/memory_datasource.hpp>
#include <mapnik/feature_kv_iterator.hpp>
+#include <mapnik/config_error.hpp>
#include "mapwidget.hpp"
#include "info_dialog.hpp"
@@ -487,7 +488,7 @@ void MapWidget::updateMap()
}
catch (mapnik::config_error & ex)
{
- std::cerr << ex.what() << std::endl;
+ std::cerr << ex.what() << std::endl;
}
catch (...)
{
View
91 include/mapnik/agg_helpers.hpp
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ *
+ * This file is part of Mapnik (c++ mapping toolkit)
+ *
+ * Copyright (C) 2012 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
+ *
+ *****************************************************************************/
+
+#ifndef MAPNIK_AGG_HELPERS_HPP
+#define MAPNIK_AGG_HELPERS_HPP
+
+#include "agg_gamma_functions.h"
+#include "agg_math_stroke.h"
+
+namespace mapnik {
+
+template <typename T0, typename T1>
+void set_gamma_method(T0 const& obj, T1 & ras_ptr)
+{
+ switch (obj.get_gamma_method())
+ {
+ case GAMMA_POWER:
+ ras_ptr->gamma(agg::gamma_power(obj.get_gamma()));
+ break;
+ case GAMMA_LINEAR:
+ ras_ptr->gamma(agg::gamma_linear(0.0, obj.get_gamma()));
+ break;
+ case GAMMA_NONE:
+ ras_ptr->gamma(agg::gamma_none());
+ break;
+ case GAMMA_THRESHOLD:
+ ras_ptr->gamma(agg::gamma_threshold(obj.get_gamma()));
+ break;
+ case GAMMA_MULTIPLY:
+ ras_ptr->gamma(agg::gamma_multiply(obj.get_gamma()));
+ break;
+ default:
+ ras_ptr->gamma(agg::gamma_power(obj.get_gamma()));
+ }
+}
+
+template <typename Stroke,typename PathType>
+void set_join_caps(Stroke const& stroke_, PathType & stroke)
+{
+ line_join_e join=stroke_.get_line_join();
+ switch (join)
+ {
+ case MITER_JOIN:
+ stroke.generator().line_join(agg::miter_join);
+ break;
+ case MITER_REVERT_JOIN:
+ stroke.generator().line_join(agg::miter_join);
+ break;
+ case ROUND_JOIN:
+ stroke.generator().line_join(agg::round_join);
+ break;
+ default:
+ stroke.generator().line_join(agg::bevel_join);
+ }
+
+ line_cap_e cap=stroke_.get_line_cap();
+ switch (cap)
+ {
+ case BUTT_CAP:
+ stroke.generator().line_cap(agg::butt_cap);
+ break;
+ case SQUARE_CAP:
+ stroke.generator().line_cap(agg::square_cap);
+ break;
+ default:
+ stroke.generator().line_cap(agg::round_cap);
+ }
+}
+
+}
+
+#endif //MAPNIK_AGG_HELPERS_HPP
View
2  include/mapnik/agg_renderer.hpp
@@ -66,7 +66,7 @@ class MAPNIK_DECL agg_renderer : public feature_style_processor<agg_renderer<T>
void start_layer_processing(layer const& lay, box2d<double> const& query_extent);
void end_layer_processing(layer const& lay);
void render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, double opacity);
-
+
void process(point_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans);
View
90 include/mapnik/boolean.hpp
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ *
+ * This file is part of Mapnik (c++ mapping toolkit)
+ *
+ * Copyright (C) 2011 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
+ *
+ *****************************************************************************/
+#ifndef MAPNIK_BOOLEAN_HPP
+#define MAPNIK_BOOLEAN_HPP
+#include <istream>
+
+namespace mapnik
+{
+/** Helper for class bool */
+class boolean {
+public:
+ boolean(): b_(false) {}
+ boolean(bool b) : b_(b) {}
+ boolean(boolean const& b) : b_(b.b_) {}
+
+ operator bool() const
+ {
+ return b_;
+ }
+ boolean & operator = (boolean const& other)
+ {
+ b_ = other.b_;
+ return * this;
+ }
+ boolean & operator = (bool other)
+ {
+ b_ = other;
+ return * this;
+ }
+private:
+ bool b_;
+};
+
+/** Special stream input operator for boolean values */
+template <typename charT, typename traits>
+std::basic_istream<charT, traits> &
+operator >> ( std::basic_istream<charT, traits> & s, boolean & b )
+{
+ std::string word;
+ s >> word;
+ if ( s )
+ {
+ if ( word == "true" || word == "yes" || word == "on" ||
+ word == "1")
+ {
+ b = true;
+ }
+ else if ( word == "false" || word == "no" || word == "off" ||
+ word == "0")
+ {
+ b = false;
+ }
+ else
+ {
+ s.setstate( std::ios::failbit );
+ }
+ }
+ return s;
+}
+
+template <typename charT, typename traits>
+std::basic_ostream<charT, traits> &
+operator << ( std::basic_ostream<charT, traits> & s, boolean const& b )
+{
+ s << ( b ? "true" : "false" );
+ return s;
+}
+
+}
+
+#endif // MAPNIK_BOOLEAN_HPP
View
8 include/mapnik/color.hpp
@@ -137,6 +137,14 @@ class MAPNIK_DECL color
std::string to_hex_string() const;
};
+template <typename charT, typename traits>
+std::basic_ostream<charT, traits> &
+operator << ( std::basic_ostream<charT, traits> & s, mapnik::color const& c )
+{
+ std::string hex_string( c.to_string() );
+ s << hex_string;
+ return s;
+}
}
View
120 include/mapnik/color_factory.hpp
@@ -25,134 +25,26 @@
// mapnik
#include <mapnik/config.hpp>
-#include <mapnik/color.hpp>
-#include <mapnik/config_error.hpp>
// boost
#include <boost/utility.hpp>
-#include <boost/version.hpp>
-
-// boost 1.41 -> 1.44 compatibility, to be removed in mapnik 2.1 (dane)
-#if BOOST_VERSION >= 104500
-#include <mapnik/css_color_grammar.hpp>
namespace mapnik {
-class MAPNIK_DECL color_factory : boost::noncopyable
-{
-public:
-
- static void init_from_string(color & c, std::string const& css_color)
- {
- typedef std::string::const_iterator iterator_type;
- typedef mapnik::css_color_grammar<iterator_type> css_color_grammar;
-
- css_color_grammar g;
- iterator_type first = css_color.begin();
- iterator_type last = css_color.end();
- bool result =
- boost::spirit::qi::phrase_parse(first,
- last,
- g,
- boost::spirit::ascii::space,
- c);
- if (!result)
- {
- throw config_error(std::string("Failed to parse color value: ") +
- "Expected a CSS color, but got '" + css_color + "'");
- }
- }
-
- static bool parse_from_string(color & c, std::string const& css_color,
- mapnik::css_color_grammar<std::string::const_iterator> const& g)
- {
- std::string::const_iterator first = css_color.begin();
- std::string::const_iterator last = css_color.end();
- bool result =
- boost::spirit::qi::phrase_parse(first,
- last,
- g,
- boost::spirit::ascii::space,
- c);
- return result && (first == last);
- }
-
- static color from_string(std::string const& css_color)
- {
- color c;
- init_from_string(c,css_color);
- return c;
- }
-};
-}
-
-#else
-#include <mapnik/css_color_grammar_deprecated.hpp>
-
-namespace mapnik {
+class color;
+template <typename Iterator> struct css_color_grammar;
class MAPNIK_DECL color_factory : boost::noncopyable
{
public:
- static bool parse_from_string(color & c, std::string const& css_color,
- mapnik::css_color_grammar<std::string::const_iterator> const& g)
- {
- std::string::const_iterator first = css_color.begin();
- std::string::const_iterator last = css_color.end();
- mapnik::css css_;
- bool result =
- boost::spirit::qi::phrase_parse(first,
- last,
- g,
- boost::spirit::ascii::space,
- css_);
- if (result && (first == last))
- {
- c.set_red(css_.r);
- c.set_green(css_.g);
- c.set_blue(css_.b);
- c.set_alpha(css_.a);
- return true;
- }
- return false;
- }
-
- static void init_from_string(color & c, std::string const& css_color)
- {
- typedef std::string::const_iterator iterator_type;
- typedef mapnik::css_color_grammar<iterator_type> css_color_grammar;
+ static void init_from_string(color & c, std::string const& css_color);
- css_color_grammar g;
- iterator_type first = css_color.begin();
- iterator_type last = css_color.end();
- mapnik::css css_;
- bool result =
- boost::spirit::qi::phrase_parse(first,
- last,
- g,
- boost::spirit::ascii::space,
- css_);
- if (!result)
- {
- throw config_error(std::string("Failed to parse color value: ") +
- "Expected a CSS color, but got '" + css_color + "'");
- }
- c.set_red(css_.r);
- c.set_green(css_.g);
- c.set_blue(css_.b);
- c.set_alpha(css_.a);
- }
+ static bool parse_from_string(color & c, std::string const& css_color,
+ mapnik::css_color_grammar<std::string::const_iterator> const& g);
- static color from_string(std::string const& css_color)
- {
- color c;
- init_from_string(c,css_color);
- return c;
- }
+ static color from_string(std::string const& css_color);
};
}
-#endif
-
#endif // MAPNIK_COLOR_FACTORY_HPP
View
2  include/mapnik/config.hpp
@@ -25,8 +25,6 @@
// Windows DLL support
-#define MAPNIK_SUPPORTS_GRID_RENDERER
-
#ifdef _WINDOWS
# define MAPNIK_EXP __declspec (dllexport)
# define MAPNIK_IMP __declspec (dllimport)
View
29 include/mapnik/config_error.hpp
@@ -28,31 +28,28 @@
namespace mapnik {
+class xml_node;
class config_error : public std::exception
{
public:
- config_error():
- what_() {}
-
- config_error( std::string const& what ) :
- what_( what )
- {
- }
+ config_error(std::string const& what);
+ config_error(std::string const& what, xml_node const& node);
+ config_error(std::string const& what, unsigned line_number, std::string const& filename);
virtual ~config_error() throw() {}
- virtual const char * what() const throw()
- {
- return what_.c_str();
- }
-
- void append_context(std::string const& ctx) const
- {
- what_ += " " + ctx;
- }
+ virtual const char * what() const throw();
+ void append_context(const std::string & ctx) const;
+ void append_context(const std::string & ctx, xml_node const& node) const;
+ void append_context(xml_node const& node) const;
protected:
mutable std::string what_;
+ mutable unsigned line_number_;
+ mutable std::string file_;
+ mutable std::string node_name_;
+ mutable std::string msg_;
};
+
}
#endif // MAPNIK_CONFIG_ERROR_HPP
View
2  include/mapnik/expression.hpp
@@ -26,7 +26,6 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/expression_node.hpp>
-#include <mapnik/expression_grammar.hpp>
// stl
#include <string>
@@ -35,6 +34,7 @@ namespace mapnik
{
typedef boost::shared_ptr<expr_node> expression_ptr;
+template <typename Iterator> struct expression_grammar;
class expression_factory
{
View
4 include/mapnik/expression_grammar.hpp
@@ -229,7 +229,7 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
("\\r", '\r')("\\t", '\t')("\\v", '\v')("\\\\", '\\')
("\\\'", '\'')("\\\"", '\"')
;
-
+
#if BOOST_VERSION > 104500
quote_char %= char_('\'') | char_('"');
ustring %= omit[quote_char[_a = _1]]
@@ -237,7 +237,7 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
>> lit(_a);
attr %= '[' >> no_skip[+~char_(']')] >> ']';
#else
- ustring %= lit('\'')
+ ustring %= lit('\'')
>> *(unesc_char | "\\x" >> hex | (char_ - lit('\'')))
>> lit('\'');
attr %= '[' >> lexeme[+(char_ - ']')] >> ']';
View
24 include/mapnik/feature.hpp
@@ -99,11 +99,11 @@ class MAPNIK_DECL feature_impl : private boost::noncopyable
feature_impl(context_ptr const& ctx, int id)
: id_(id),
- ctx_(ctx),
- data_(ctx_->mapping_.size()),
- geom_cont_(),
- raster_()
- {}
+ ctx_(ctx),
+ data_(ctx_->mapping_.size()),
+ geom_cont_(),
+ raster_()
+ {}
inline int id() const { return id_;}
@@ -163,25 +163,25 @@ class MAPNIK_DECL feature_impl : private boost::noncopyable
{
context_type::map_type::const_iterator itr = ctx_->mapping_.find(key);
if (itr != ctx_->mapping_.end())
- return get(itr->second);
- else
- throw std::out_of_range(std::string("Key does not exist: '") + key + "'");
+ return get(itr->second);
+ else
+ throw std::out_of_range(std::string("Key does not exist: '") + key + "'");
}
-
+
value_type const& get(std::size_t index) const
{
if (index < data_.size())
return data_[index];
throw std::out_of_range("Index out of range");
}
-
+
boost::optional<value_type const&> get_optional(std::size_t index) const
{
if (index < data_.size())
return boost::optional<value_type const&>(data_[index]);
return boost::optional<value_type const&>();
}
-
+
std::size_t size() const
{
return data_.size();
@@ -273,7 +273,7 @@ class MAPNIK_DECL feature_impl : private boost::noncopyable
if (index < data_.size())
{
ss << " " << itr->first << ":" << data_[itr->second] << std::endl;
- }
+ }
}
ss << ")" << std::endl;
return ss.str();
View
2  include/mapnik/font_engine_freetype.hpp
@@ -153,7 +153,7 @@ class MAPNIK_DECL font_face_set : private boost::noncopyable
public:
font_face_set(void)
: faces_(),
- dimension_cache_() {}
+ dimension_cache_() {}
void add(face_ptr face)
{
View
3  include/mapnik/formatting/base.hpp
@@ -36,6 +36,7 @@ namespace mapnik {
typedef std::set<expression_ptr> expression_set;
class processed_text;
+class xml_node;
struct char_properties;
namespace formatting {
@@ -48,7 +49,7 @@ class node
public:
virtual ~node() {}
virtual void to_xml(boost::property_tree::ptree &xml) const;
- static node_ptr from_xml(boost::property_tree::ptree const& xml);
+ static node_ptr from_xml(xml_node const& xml);
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const = 0;
virtual void add_expressions(expression_set &output) const;
};
View
4 include/mapnik/formatting/expression.hpp
@@ -31,7 +31,7 @@ namespace formatting {
class expression_format: public node {
public:
void to_xml(boost::property_tree::ptree &xml) const;
- static node_ptr from_xml(boost::property_tree::ptree const& xml);
+ static node_ptr from_xml(xml_node const& xml);
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const;
virtual void add_expressions(expression_set &output) const;
@@ -51,7 +51,7 @@ class expression_format: public node {
private:
node_ptr child_;
- static expression_ptr get_expression(boost::property_tree::ptree const& xml, std::string name);
+ static expression_ptr get_expression(xml_node const& xml, std::string name);
};
} //ns formatting
} //ns mapnik
View
2  include/mapnik/formatting/format.hpp
@@ -31,7 +31,7 @@ namespace formatting {
class format_node: public node {
public:
void to_xml(boost::property_tree::ptree &xml) const;
- static node_ptr from_xml(boost::property_tree::ptree const& xml);
+ static node_ptr from_xml(xml_node const& xml);
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const;
virtual void add_expressions(expression_set &output) const;
View
6 include/mapnik/formatting/registry.hpp
@@ -38,16 +38,16 @@ namespace mapnik
namespace formatting
{
-typedef node_ptr (*from_xml_function_ptr)(boost::property_tree::ptree const& xml);
+typedef node_ptr (*from_xml_function_ptr)(xml_node const& xml);
class registry : public singleton<registry, CreateStatic>,
- private boost::noncopyable
+ private boost::noncopyable
{
public:
registry();
~registry() {}
void register_name(std::string name, from_xml_function_ptr ptr, bool overwrite=false);
- node_ptr from_xml(std::string name, boost::property_tree::ptree const& xml);
+ node_ptr from_xml(xml_node const& xml);
private:
std::map<std::string, from_xml_function_ptr> map_;
};
View
2  include/mapnik/formatting/text.hpp
@@ -31,7 +31,7 @@ class text_node: public node {
text_node(expression_ptr text): node(), text_(text) {}
text_node(std::string text): node(), text_(parse_expression(text)) {}
void to_xml(boost::property_tree::ptree &xml) const;
- static node_ptr from_xml(boost::property_tree::ptree const& xml);
+ static node_ptr from_xml(xml_node const& xml);
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const;
virtual void add_expressions(expression_set &output) const;
View
2  include/mapnik/geometry.hpp
@@ -390,7 +390,7 @@ class geometry : private::boost::noncopyable
}
return false;
}
-
+
};
typedef geometry<double,vertex_vector> geometry_type;
View
4 include/mapnik/hextree.hpp
@@ -160,7 +160,7 @@ class hextree : private boost::noncopyable
~hextree()
{}
-
+
void setMaxColors(unsigned max_colors)
{
max_colors_ = max_colors;
@@ -335,7 +335,7 @@ class hextree : private boost::noncopyable
sorted_pal_.reserve(colors_);
create_palette_rek(sorted_pal_, root_.get());
-
+
// sort palette for binary searching in quantization
#if BOOST_VERSION >= 104600
boost::sort(sorted_pal_, rgba::mean_sort_cmp());
View
28 include/mapnik/internal/dump_xml.hpp
@@ -1,26 +1,34 @@
#ifndef DUMP_XML_HPP
#define DUMP_XML_HPP
-#include <boost/property_tree/ptree.hpp>
+#include <mapnik/xml_node.hpp>
/* Debug dump ptree XML representation.
-*/
-void dump_xml(boost::property_tree::ptree const& xml, unsigned level=0)
+ */
+void dump_xml(xml_node const& xml, unsigned level=0)
{
std::string indent;
- int i;
+ unsigned i;
for (i=0; i<level; i++)
{
indent += " ";
}
- if (xml.data().length()) std::cout << indent << "data: '" << xml.data() << "'\n";
- boost::property_tree::ptree::const_iterator itr = xml.begin();
- boost::property_tree::ptree::const_iterator end = xml.end();
+ xml_node::attribute_map const& attr = xml.get_attributes();
+ std::cerr << indent <<"[" << xml.name();
+ xml_node::attribute_map::const_iterator aitr = attr.begin();
+ xml_node::attribute_map::const_iterator aend = attr.end();
+ for (;aitr!=aend; aitr++)
+ {
+ std::cerr << " (" << aitr->first << ", " << aitr->second.value << ", " << aitr->second.processed << ")";
+ }
+ std::cerr << "]" << "\n";
+ if (xml.is_text()) std::cerr << indent << "text: '" << xml.text() << "'\n";
+ xml_node::const_iterator itr = xml.begin();
+ xml_node::const_iterator end = xml.end();
for (; itr!=end; itr++)
{
- std::cout << indent <<"[" << itr->first << "]" << "\n";
- dump_xml(itr->second, level+1);
- std::cout << indent << "[/" << itr->first << "]" << "\n";
+ dump_xml(*itr, level+1);
}
+ std::cerr << indent << "[/" << xml.name() << "]" << "\n";
}
View
3  include/mapnik/metawriter_factory.hpp
@@ -30,6 +30,7 @@
#include <boost/property_tree/ptree.hpp>
namespace mapnik {
+class xml_node;
/**
* Creates a metawriter with the properties specified in the property
@@ -37,7 +38,7 @@ namespace mapnik {
* metawriters, but should provide an easy point to make them a
* proper factory method if this is wanted in the future.
*/
-metawriter_ptr metawriter_create(const boost::property_tree::ptree &pt);
+metawriter_ptr metawriter_create(xml_node const& pt);
/**
* Writes properties into the given property tree representing the
View
1  include/mapnik/palette.hpp
@@ -26,7 +26,6 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/global.hpp>
-#include <mapnik/config_error.hpp>
// boost
#include <boost/utility.hpp>
View
12 include/mapnik/placement_finder.hpp
@@ -124,16 +124,16 @@ class placement_finder : boost::noncopyable
text_symbolizer_properties const& p;
text_placement_info const& pi;
/** Length of the longest line after linebreaks.
- * Before find_line_breaks() this is the total length of the string.
- */
+ * Before find_line_breaks() this is the total length of the string.
+ */
double string_width_;
/** Height of the string after linebreaks.
- * Before find_line_breaks() this is the total length of the string.
- */
+ * Before find_line_breaks() this is the total length of the string.
+ */
double string_height_;
/** Height of the tallest font in the first line not including line spacing.
- * Used to determine the correct offset for the first line.
- */
+ * Used to determine the correct offset for the first line.
+ */
double first_line_space_;
vertical_alignment_e valign_;
horizontal_alignment_e halign_;
View
6 include/mapnik/polygon_symbolizer.hpp
@@ -35,7 +35,7 @@ namespace mapnik
struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base
{
polygon_symbolizer();
- polygon_symbolizer(color const& fill);
+ explicit polygon_symbolizer(color const& fill);
color const& get_fill() const;
void set_fill(color const& fill);
void set_opacity(double opacity);
@@ -44,12 +44,14 @@ struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base
double get_gamma() const;
void set_gamma_method(gamma_method_e gamma_method);
gamma_method_e get_gamma_method() const;
-
+ void set_smooth(double smooth);
+ double smooth() const;
private:
color fill_;
double opacity_;
double gamma_;
gamma_method_e gamma_method_;
+ double smooth_;
};
}
View
433 include/mapnik/ptree_helpers.hpp
@@ -23,450 +23,17 @@
#ifndef MAPNIK_PTREE_HELPERS_HPP
#define MAPNIK_PTREE_HELPERS_HPP
-// mapnik
-#include <mapnik/enumeration.hpp>
-#include <mapnik/config_error.hpp>
-#include <mapnik/color_factory.hpp>
-#include <mapnik/util/conversions.hpp>
// boost
#include <boost/property_tree/ptree.hpp>
-#include <boost/optional.hpp>
-#include <boost/lexical_cast.hpp>
-
-// stl
-#include <iostream>
-#include <sstream>
namespace mapnik {
template <typename T>
-inline boost::optional<T> fast_cast(std::string const& value);
-
-template <typename T>
-T get(boost::property_tree::ptree const& node, std::string const& name, bool is_attribute,
- T const& default_value);
-template <typename T>
-T get(boost::property_tree::ptree const& node, std::string const& name, bool is_attribute);
-template <typename T>
-T get_value(boost::property_tree::ptree const& node, std::string const& name);
-template <typename T>
-boost::optional<T> get_optional(boost::property_tree::ptree const& node, std::string const& name,
- bool is_attribute);
-
-template <typename T>
-boost::optional<T> get_opt_attr( boost::property_tree::ptree const& node,
- std::string const& name)
-{
- return get_optional<T>( node, name, true);
-}
-
-template <typename T>
-boost::optional<T> get_opt_child( boost::property_tree::ptree const& node,
- std::string const& name)
-{
- return get_optional<T>( node, name, false);
-}
-
-template <typename T>
-T get_attr( boost::property_tree::ptree const& node, std::string const& name,
- T const& default_value )
-{
- return get<T>( node, name, true, default_value);
-}
-
-template <typename T>
-T get_attr( boost::property_tree::ptree const& node, std::string const& name )
-{
- return get<T>( node, name, true );
-}
-
-
-template <typename charT, typename traits>
-std::basic_ostream<charT, traits> &
-operator << ( std::basic_ostream<charT, traits> & s, mapnik::color const& c )
-{
- std::string hex_string( c.to_string() );
- s << hex_string;
- return s;
-}
-
-/** Helper for class bool */
-class boolean {
-public:
- boolean() : b_(false) {}
- boolean(bool b) : b_(b) {}
- boolean(boolean const& b) : b_(b.b_) {}
-
- operator bool() const
- {
- return b_;
- }
- boolean & operator = (boolean const& other)
- {
- b_ = other.b_;
- return * this;
- }
- boolean & operator = (bool other)
- {
- b_ = other;
- return * this;
- }
-private:
- bool b_;
-};
-
-/** Special stream input operator for boolean values */
-template <typename charT, typename traits>
-std::basic_istream<charT, traits> &
-operator >> ( std::basic_istream<charT, traits> & s, boolean & b )
-{
- std::string word;
- s >> word;
- if ( s )
- {
- if ( word == "true" || word == "yes" || word == "on" ||
- word == "1")
- {
- b = true;
- }
- else if ( word == "false" || word == "no" || word == "off" ||
- word == "0")
- {
- b = false;
- }
- else
- {
- s.setstate( std::ios::failbit );
- }
- }
- return s;
-}
-
-template <typename charT, typename traits>
-std::basic_ostream<charT, traits> &
-operator << ( std::basic_ostream<charT, traits> & s, boolean const& b )
-{
- s << ( b ? "true" : "false" );
- return s;
-}
-
-template <typename T>
void set_attr(boost::property_tree::ptree & pt, std::string const& name, T const& v)
{
pt.put("<xmlattr>." + name, v);
}
-
-class boolean;
-
-template <typename T>
-struct name_trait
-{
- static std::string name()
- {
- return "<unknown>";
- }
- // missing name_trait for type ...
- // if you get here you are probably using a new type
- // in the XML file. Just add a name trait for the new
- // type below.
- BOOST_STATIC_ASSERT( sizeof(T) == 0 );
-};
-
-#define DEFINE_NAME_TRAIT( type, type_name ) \
- template <> \
- struct name_trait<type> \
- { \
- static std::string name() { return std::string("type ") + type_name; } \
- };
-
-
-DEFINE_NAME_TRAIT( double, "double")
-DEFINE_NAME_TRAIT( float, "float")
-DEFINE_NAME_TRAIT( unsigned, "unsigned")
-DEFINE_NAME_TRAIT( boolean, "boolean")
-DEFINE_NAME_TRAIT( int, "integer" )
-DEFINE_NAME_TRAIT( std::string, "string" )
-DEFINE_NAME_TRAIT( color, "color" )
-
-template <typename ENUM, int MAX>
-struct name_trait< mapnik::enumeration<ENUM, MAX> >
-{
- typedef enumeration<ENUM, MAX> Enum;
-
- static std::string name()
- {
- std::string value_list("one of [");
- for (unsigned i = 0; i < Enum::MAX; ++i)
- {
- value_list += Enum::get_string( i );
- if ( i + 1 < Enum::MAX ) value_list += ", ";
- }
- value_list += "]";
-
- return value_list;
- }
-};
-
-template <typename T>
-inline boost::optional<T> fast_cast(std::string const& value)
-{
- try
- {
- return boost::lexical_cast<T>( value );
- }
- catch (boost::bad_lexical_cast const& ex)
- {
- return boost::optional<T>();
- }
-
-}
-
-template <>
-inline boost::optional<int> fast_cast(std::string const& value)
-{
- int result;
- if (mapnik::conversions::string2int(value,result))
- return boost::optional<int>(result);
- return boost::optional<int>();
-}
-
-template <>
-inline boost::optional<double> fast_cast(std::string const& value)
-{
- double result;
- if (mapnik::conversions::string2double(value,result))
- return boost::optional<double>(result);
- return boost::optional<double>();
-}
-
-template <>
-inline boost::optional<float> fast_cast(std::string const& value)
-{
- float result;
- if (mapnik::conversions::string2float(value,result))
- return boost::optional<float>(result);
- return boost::optional<float>();
-}
-
-template <typename T>
-T get(boost::property_tree::ptree const& node,
- std::string const& name,
- bool is_attribute,
- T const& default_value)
-{
- boost::optional<std::string> str;
- if (is_attribute)
- {
- str = node.get_optional<std::string>( std::string("<xmlattr>.") + name );
- }
- else
- {
- str = node.get_optional<std::string>(name + ".<xmltext>");
- }
-
- if ( str )
- {
- boost::optional<T> result = fast_cast<T>(*str);
- if (result)
- {
- return *result;
- }
- else
- {
- throw config_error(std::string("Failed to parse ") +
- (is_attribute ? "attribute" : "child node") + " '" +
- name + "'. Expected " + name_trait<T>::name() +
- " but got '" + *str + "'");
- }
- }
- else
- {
- return default_value;
- }
-}
-
-template <>
-inline color get(boost::property_tree::ptree const& node,
- std::string const& name,
- bool is_attribute,
- color const& default_value)
-{
- boost::optional<std::string> str;
- if (is_attribute)
- {
- str = node.get_optional<std::string>( std::string("<xmlattr>.") + name );
- }
- else
- {
- str = node.get_optional<std::string>(name + ".<xmltext>");
- }
-
- if ( str )
- {
- try
- {
- return mapnik::color_factory::from_string((*str).c_str());
- }
- catch (...)
- {
- throw config_error(std::string("Failed to parse ") +
- (is_attribute ? "attribute" : "child node") + " '" +
- name + "'. Expected " + name_trait<color>::name() +
- " but got '" + *str + "'");
- }
- }
- else
- {
- return default_value;
- }
-}
-
-template <typename T>
-T get(boost::property_tree::ptree const& node, std::string const& name, bool is_attribute)
-{
- boost::optional<std::string> str;
- if (is_attribute)
- {
- str = node.get_optional<std::string>( std::string("<xmlattr>.") + name);
- }
- else
- {
- str = node.get_optional<std::string>(name + ".<xmltext>");
- }
-
- if ( ! str )
- {
- throw config_error(std::string("Required ") +
- (is_attribute ? "attribute " : "child node ") +
- "'" + name + "' is missing");
- }
- boost::optional<T> result = fast_cast<T>(*str);
- if (result)
- {
- return *result;
- }
- else
- {
- throw config_error(std::string("Failed to parse ") +
- (is_attribute ? "attribute" : "child node") + " '" +
- name + "'. Expected " + name_trait<T>::name() +
- " but got '" + *str + "'");
- }
-}
-
-template <typename T>
-T get_value(boost::property_tree::ptree const& node, std::string const& name)
-{
- try
- {
- /* NOTE: get_child works as long as there is only one child with that name.
- If this function is used this used this condition must always be satisfied.
- */
- return node.get_child("<xmltext>").get_value<T>();
- }
- catch (boost::property_tree::ptree_bad_path)
- {
- /* If the XML parser did not find any non-empty data element the is no
- <xmltext> node. But we don't want to fail here but simply return a
- default constructed value of the requested type.
- */
- return T();
- }
- catch (...)
- {
- throw config_error(std::string("Failed to parse ") +
- name + ". Expected " + name_trait<T>::name() +
- " but got '" + node.data() + "'");
- }
-}
-
-template <typename T>
-boost::optional<T> get_optional(boost::property_tree::ptree const& node,
- std::string const& name,
- bool is_attribute)
-{
- boost::optional<std::string> str;
- if (is_attribute)
- {
- str = node.get_optional<std::string>( std::string("<xmlattr>.") + name);
- }
- else
- {
- str = node.get_optional<std::string>(name + ".<xmltext>");
- }
-
- boost::optional<T> result;
- if ( str )
- {
- result = fast_cast<T>(*str);
- if (!result)
- {
- throw config_error(std::string("Failed to parse ") +
- (is_attribute ? "attribute" : "child node") + " '" +
- name + "'. Expected " + name_trait<T>::name() +
- " but got '" + *str + "'");
- }
- }
-
- return result;
-}
-
-template <>
-inline boost::optional<std::string> get_optional(boost::property_tree::ptree const& node,
- std::string const& name,
- bool is_attribute)
-{
- if (is_attribute)
- {
- return node.get_optional<std::string>( std::string("<xmlattr>.") + name);
- }
- else
- {
- return node.get_optional<std::string>(name + ".<xmltext>");
- }
-}
-
-template <>
-inline boost::optional<color> get_optional(boost::property_tree::ptree const& node,
- std::string const& name,
- bool is_attribute)
-{
- boost::optional<std::string> str;
- if (is_attribute)
- {
- str = node.get_optional<std::string>( std::string("<xmlattr>.") + name);
- }
- else
- {
- str = node.get_optional<std::string>(name + ".<xmltext>");
- }
-
- boost::optional<color> result;
- if ( str )
- {
- try
- {
- result = mapnik::color_factory::from_string((*str).c_str());
- }
- catch (...)
- {
- throw config_error(std::string("Failed to parse ") +
- (is_attribute ? "attribute" : "child node") + " '" +
- name + "'. Expected " + name_trait<color>::name() +
- " but got '" + *str + "'");
- }
- }
-
- return result;
-}
-
-static inline bool has_child(boost::property_tree::ptree const& node, std::string const& name)
-{
- boost::optional<std::string> str = node.get_optional<std::string>(name);
- return str;
-}
-
} // end of namespace mapnik
#endif // MAPNIK_PTREE_HELPERS_HPP
View
1  include/mapnik/raster_colorizer.hpp
@@ -39,7 +39,6 @@
// mapnik
#include <mapnik/config.hpp>
-#include <mapnik/config_error.hpp>
#include <mapnik/color.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/enumeration.hpp>
View
2  include/mapnik/symbolizer_helpers.hpp
@@ -65,11 +65,11 @@ class text_symbolizer_helper
detector_(detector),
writer_(sym.get_metawriter()),
dims_(0, 0, width, height),
+ query_extent_(query_extent),
text_(font_manager, scale_factor),
angle_(0.0),
placement_valid_(false),
points_on_line_(false),
- query_extent_(query_extent),
finder_()
{
initialize_geometries();
View
2  include/mapnik/text_placements/list.hpp
@@ -38,7 +38,7 @@ class text_placements_list: public text_placements
text_symbolizer_properties & add();
text_symbolizer_properties & get(unsigned i);
unsigned size() const;
- static text_placements_ptr from_xml(boost::property_tree::ptree const &xml, fontset_map const & fontsets);
+ static text_placements_ptr from_xml(xml_node const &xml, fontset_map const & fontsets);
private:
std::vector<text_symbolizer_properties> list_;
friend class text_placement_info_list;
View
6 include/mapnik/text_placements/registry.hpp
@@ -39,17 +39,17 @@ namespace placements
{
typedef text_placements_ptr (*from_xml_function_ptr)(
- boost::property_tree::ptree const& xml, fontset_map const & fontsets);
+ xml_node const& xml, fontset_map const & fontsets);
class registry : public singleton<registry, CreateStatic>,
- private boost::noncopyable
+ private boost::noncopyable
{
public:
registry();
~registry() {}
void register_name(std::string name, from_xml_function_ptr ptr, bool overwrite=false);
text_placements_ptr from_xml(std::string name,
- boost::property_tree::ptree const& xml,
+ xml_node const& xml,
fontset_map const & fontsets);
private:
std::map<std::string, from_xml_function_ptr> map_;
View
2  include/mapnik/text_placements/simple.hpp
@@ -52,7 +52,7 @@ class text_placements_simple: public text_placements
text_placement_info_ptr get_placement_info(double scale_factor) const;
void set_positions(std::string positions);
std::string get_positions();
- static text_placements_ptr from_xml(boost::property_tree::ptree const &xml, fontset_map const & fontsets);
+ static text_placements_ptr from_xml(xml_node const &xml, fontset_map const & fontsets);
private:
std::string positions_;
std::vector<directions_t> direction_;
View
4 include/mapnik/text_properties.hpp
@@ -54,7 +54,7 @@ struct char_properties
{
char_properties();
/** Construct object from XML. */
- void from_xml(boost::property_tree::ptree const &sym, fontset_map const & fontsets);
+ void from_xml(xml_node const &sym, fontset_map const & fontsets);
/** Write object to XML ptree. */
void to_xml(boost::property_tree::ptree &node, bool explicit_defaults, char_properties const& dfl=char_properties()) const;
std::string face_name;
@@ -124,7 +124,7 @@ struct text_symbolizer_properties
{
text_symbolizer_properties();
/** Load all values from XML ptree. */
- void from_xml(boost::property_tree::ptree const &sym, fontset_map const & fontsets);
+ void from_xml(xml_node const &sym, fontset_map const & fontsets);
/** Save all values to XML ptree (but does not create a new parent node!). */
void to_xml(boost::property_tree::ptree &node, bool explicit_defaults, text_symbolizer_properties const &dfl=text_symbolizer_properties()) const;
View
18 include/mapnik/util/conversions.hpp
@@ -30,16 +30,16 @@
namespace mapnik { namespace conversions {
-bool string2int(const char * value, int & result);
-bool string2int(std::string const& value, int & result);
-
-bool string2double(std::string const& value, double & result);
-bool string2double(const char * value, double & result);
-
-bool string2float(std::string const& value, float & result);
-bool string2float(const char * value, float & result);
+ bool string2int(const char * value, int & result);
+ bool string2int(std::string const& value, int & result);
-}
+ bool string2double(std::string const& value, double & result);
+ bool string2double(const char * value, double & result);
+
+ bool string2float(std::string const& value, float & result);
+ bool string2float(const char * value, float & result);
+
+ }
}
#endif // MAPNIK_CONVERSIONS_UTIL_HPP
View
1  include/mapnik/value.hpp
@@ -26,7 +26,6 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/unicode.hpp>
-#include <mapnik/config_error.hpp>
// boost
#include <boost/variant.hpp>
View
8 include/mapnik/vertex_vector.hpp
@@ -55,16 +55,16 @@ class vertex_vector : private boost::noncopyable
// required for iterators support
typedef boost::tuple<unsigned,coord_type,coord_type> value_type;
typedef std::size_t size_type;
-
+
private:
unsigned num_blocks_;
unsigned max_blocks_;
coord_type** vertices_;
unsigned char** commands_;
size_type pos_;
-
+
public:
-
+
vertex_vector()
: num_blocks_(0),
max_blocks_(0),
@@ -114,7 +114,7 @@ class vertex_vector : private boost::noncopyable
*y = (*vertex);
return commands_[block] [pos & block_mask];
}
-
+
private:
void allocate_block(unsigned block)
{
View
8 include/mapnik/libxml2_loader.hpp → include/mapnik/xml_loader.hpp
@@ -23,16 +23,14 @@
#ifndef MAPNIK_LIBXML2_LOADER_HPP
#define MAPNIK_LIBXML2_LOADER_HPP
-// boost
-#include <boost/property_tree/ptree.hpp>
-
// stl
#include <string>
namespace mapnik
{
-void read_xml2( std::string const & filename, boost::property_tree::ptree & pt);
-void read_xml2_string( std::string const & str, boost::property_tree::ptree & pt, std::string const & base_path="");
+class xml_node;
+void read_xml(std::string const & filename, xml_node &node);
+void read_xml_string(std::string const & str, xml_node &node, std::string const & base_path="");
}
#endif // MAPNIK_LIBXML2_LOADER_HPP
View
137 include/mapnik/xml_node.hpp
@@ -0,0 +1,137 @@
+/*****************************************************************************
+ *
+ * This file is part of Mapnik (c++ mapping toolkit)
+ *
+ * Copyright (C) 2012 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
+ *
+ *****************************************************************************/
+
+#ifndef MAPNIK_XML_NODE_H
+#define MAPNIK_XML_NODE_H
+
+//mapnik
+#include <mapnik/boolean.hpp>
+
+
+//boost
+#include <boost/optional.hpp>
+
+//stl
+#include <list>
+#include <string>
+#include <map>
+#include <exception>
+
+namespace mapnik
+{
+class xml_tree;
+
+class xml_attribute
+{
+public:
+ xml_attribute(std::string const& value);
+ std::string value;
+ mutable bool processed;
+};
+
+class node_not_found: public std::exception
+{
+public:
+ node_not_found(std::string node_name);
+ virtual const char* what() const throw();
+ ~node_not_found() throw ();
+private:
+ std::string node_name_;
+};
+
+class attribute_not_found: public std::exception
+{
+public:
+ attribute_not_found(std::string const& node_name, std::string const& attribute_name);
+ virtual const char* what() const throw();
+ ~attribute_not_found() throw ();
+private:
+ std::string node_name_;
+ std::string attribute_name_;
+};
+
+class more_than_one_child: public std::exception
+{
+public:
+ more_than_one_child(std::string const& node_name);
+ virtual const char* what() const throw();
+ ~more_than_one_child() throw ();
+private:
+ std::string node_name_;
+};
+
+class xml_node
+{
+public:
+ typedef std::list<xml_node>::const_iterator const_iterator;
+ typedef std::map<std::string, xml_attribute> attribute_map;
+ xml_node(xml_tree &tree, std::string name, unsigned line=0, bool text_node = false);
+
+ std::string const& name() const;
+ std::string const& text() const;
+ std::string const& filename() const;
+ bool is_text() const;
+ bool is(std::string const& name) const;
+
+ xml_node &add_child(std::string const& name, unsigned line=0, bool text_node = false);
+ void add_attribute(std::string const& name, std::string const& value);
+ attribute_map const& get_attributes() const;
+
+ bool processed() const;
+ void set_processed(bool processed) const;
+
+ unsigned line() const;
+
+ const_iterator begin() const;
+ const_iterator end() const;
+
+ xml_node & get_child(std::string const& name);
+ xml_node const& get_child(std::string const& name) const;
+ xml_node const* get_opt_child(std::string const& name) const;
+ bool has_child(std::string const& name) const;
+
+ template <typename T>
+ boost::optional<T> get_opt_attr(std::string const& name) const;
+
+ template <typename T>
+ T get_attr(std::string const& name, T const& default_value) const;
+ template <typename T>
+ T get_attr(std::string const& name) const;
+
+ std::string get_text() const;
+
+ template <typename T>
+ T get_value() const;
+private:
+ xml_tree &tree_;
+ std::string name_;
+ std::list<xml_node> children_;
+ attribute_map attributes_;
+ bool text_node_;
+ unsigned line_;
+ mutable bool processed_;
+ static std::string xml_text;
+};
+
+} //ns mapnik
+
+#endif // MAPNIK_XML_NODE_H
View
62 include/mapnik/xml_tree.hpp
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ *
+ * This file is part of Mapnik (c++ mapping toolkit)
+ *
+ * Copyright (C) 2012 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
+ *
+ *****************************************************************************/
+
+#ifndef MAPNIK_XML_TREE_H
+#define MAPNIK_XML_TREE_H
+//mapnik
+#include <mapnik/xml_node.hpp>
+#include <mapnik/expression_grammar.hpp>
+
+// boost
+#include <boost/format.hpp>
+
+#if BOOST_VERSION >= 104500
+#include <mapnik/css_color_grammar.hpp>
+#else
+#include <mapnik/css_color_grammar_deprecated.hpp>
+#endif
+
+//stl
+#include <string>
+
+
+namespace mapnik
+{
+class xml_tree
+{
+public:
+ xml_tree(std::string const& encoding="utf8");
+ void set_filename(std::string fn);
+ std::string const& filename() const;
+ xml_node &root();
+private:
+ xml_node node_;
+ std::string file_;
+ transcoder tr_;
+public:
+ mapnik::css_color_grammar<std::string::const_iterator> color_grammar;
+ mapnik::expression_grammar<std::string::const_iterator> expr_grammar;
+};
+
+} //ns mapnik
+
+#endif // MAPNIK_XML_TREE_H
View
3  plugins/input/csv/csv_datasource.cpp
@@ -6,6 +6,7 @@
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/spirit/include/qi.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
// mapnik
#include <mapnik/feature_layer_desc.hpp>
@@ -14,7 +15,7 @@
#include <mapnik/memory_featureset.hpp>
#include <mapnik/wkt/wkt_factory.hpp>
#include <mapnik/util/geometry_to_ds_type.hpp>
-#include <mapnik/ptree_helpers.hpp> // mapnik::boolean
+#include <mapnik/boolean.hpp>
// stl
#include <sstream>
View
2  plugins/input/gdal/gdal_datasource.cpp
@@ -25,7 +25,7 @@
#include "gdal_featureset.hpp"
// mapnik
-#include <mapnik/ptree_helpers.hpp>
+#include <mapnik/boolean.hpp>
#include <mapnik/geom_util.hpp>
#include <gdal_version.h>
View
2  plugins/input/geos/geos_datasource.cpp
@@ -30,7 +30,7 @@
#include <cstdarg>
// mapnik
-#include <mapnik/ptree_helpers.hpp>
+#include <mapnik/boolean.hpp>
#include <mapnik/geom_util.hpp>
// boost
View
2  plugins/input/kismet/kismet_datasource.cpp
@@ -33,7 +33,7 @@
#include <cstdio>
// mapnik
-#include <mapnik/ptree_helpers.hpp>
+#include <mapnik/boolean.hpp>
// boost
#include <boost/algorithm/string.hpp>
View
2  plugins/input/occi/occi_datasource.cpp
@@ -25,7 +25,7 @@
#include "occi_featureset.hpp"
// mapnik
-#include <mapnik/ptree_helpers.hpp>
+#include <mapnik/boolean.hpp>
#include <mapnik/sql_utils.hpp>
// boost
View
2  plugins/input/occi/occi_featureset.cpp
@@ -373,7 +373,7 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature,
if (! is_single_geom && elem_size > SDO_ELEM_INFO_SIZE)
{
geometry_type* geom = new geometry_type(geom_type);
-
+
for (int i = SDO_ELEM_INFO_SIZE; i < elem_size; i+=3)
{
int next_offset = elem_info[i];
View