From daf30ca0d17d01c5ebc59415eb752ddb61ed3024 Mon Sep 17 00:00:00 2001 From: Hermann Kraus Date: Wed, 7 Mar 2012 15:26:13 +0100 Subject: [PATCH] Update metawriter_factory.hpp --- include/mapnik/metawriter_factory.hpp | 3 ++- src/load_map.cpp | 5 ++--- src/metawriter_factory.cpp | 22 ++++++++++++---------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/mapnik/metawriter_factory.hpp b/include/mapnik/metawriter_factory.hpp index d5b8911fd..1af7ff5d7 100644 --- a/include/mapnik/metawriter_factory.hpp +++ b/include/mapnik/metawriter_factory.hpp @@ -30,6 +30,7 @@ #include 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 diff --git a/src/load_map.cpp b/src/load_map.cpp index 1d03075d4..6120d22c7 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -35,7 +35,6 @@ #include #include -#include #ifdef HAVE_LIBXML2 #include #endif @@ -501,7 +500,7 @@ void map_parser::parse_metawriter(Map & map, xml_node const& pt) try { name = pt.get_attr("name"); - //TODO: writer = metawriter_create(pt); + writer = metawriter_create(pt); map.insert_metawriter(name, writer); } catch (const config_error & ex) { ex.append_context(std::string("in meta writer '") + name + "'"); @@ -620,7 +619,7 @@ void map_parser::parse_layer(Map & map, xml_node const& lay) if (child->is("StyleName")) { - std::string style_name = child->get_value(); //TODO: get_text + std::string style_name = child->get_text(); if (style_name.empty()) { std::ostringstream ss; diff --git a/src/metawriter_factory.cpp b/src/metawriter_factory.cpp index d79201838..2d05a70aa 100644 --- a/src/metawriter_factory.cpp +++ b/src/metawriter_factory.cpp @@ -22,14 +22,13 @@ //$Id$ #include -#include - #include #include +#include +#include #include -using boost::property_tree::ptree; using boost::optional; using std::string; @@ -37,20 +36,21 @@ namespace mapnik { metawriter_ptr -metawriter_create(const boost::property_tree::ptree &pt) { +metawriter_create(xml_node const& pt) +{ metawriter_ptr writer; - string type = get_attr(pt, "type"); + string type = pt.get_attr("type"); - optional properties = get_opt_attr(pt, "default-output"); + optional properties = pt.get_opt_attr("default-output"); if (type == "json") { - string file = get_attr(pt, "file"); + string file = pt.get_attr("file"); metawriter_json_ptr json = metawriter_json_ptr(new metawriter_json(properties, parse_path(file))); - optional output_empty = get_opt_attr(pt, "output-empty"); + optional output_empty = pt.get_opt_attr("output-empty"); if (output_empty) { json->set_output_empty(*output_empty); } - optional pixel_coordinates = get_opt_attr(pt, "pixel-coordinates"); + optional pixel_coordinates = pt.get_opt_attr("pixel-coordinates"); if (pixel_coordinates) { json->set_pixel_coordinates(*pixel_coordinates); } @@ -67,7 +67,9 @@ metawriter_create(const boost::property_tree::ptree &pt) { } void -metawriter_save(const metawriter_ptr &metawriter, ptree &metawriter_node, bool explicit_defaults) { +metawriter_save(const metawriter_ptr &metawriter, + boost::property_tree::ptree &metawriter_node, bool explicit_defaults) +{ metawriter_json *json = dynamic_cast(metawriter.get()); if (json) {