Update metawriter_factory.hpp

This commit is contained in:
Hermann Kraus 2012-03-07 15:26:13 +01:00
parent 9a05dc1828
commit daf30ca0d1
3 changed files with 16 additions and 14 deletions

View file

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

@ -35,7 +35,6 @@
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/font_set.hpp>
#include <mapnik/ptree_helpers.hpp>
#ifdef HAVE_LIBXML2
#include <mapnik/libxml2_loader.hpp>
#endif
@ -501,7 +500,7 @@ void map_parser::parse_metawriter(Map & map, xml_node const& pt)
try
{
name = pt.get_attr<std::string>("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<std::string>(); //TODO: get_text
std::string style_name = child->get_text();
if (style_name.empty())
{
std::ostringstream ss;

View file

@ -22,14 +22,13 @@
//$Id$
#include <mapnik/metawriter_factory.hpp>
#include <mapnik/ptree_helpers.hpp>
#include <mapnik/metawriter_json.hpp>
#include <mapnik/metawriter_inmem.hpp>
#include <mapnik/xml_tree.hpp>
#include <mapnik/ptree_helpers.hpp>
#include <boost/optional.hpp>
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<string>(pt, "type");
string type = pt.get_attr<string>("type");
optional<string> properties = get_opt_attr<string>(pt, "default-output");
optional<string> properties = pt.get_opt_attr<string>("default-output");
if (type == "json") {
string file = get_attr<string>(pt, "file");
string file = pt.get_attr<string>("file");
metawriter_json_ptr json = metawriter_json_ptr(new metawriter_json(properties, parse_path(file)));
optional<boolean> output_empty = get_opt_attr<boolean>(pt, "output-empty");
optional<boolean> output_empty = pt.get_opt_attr<boolean>("output-empty");
if (output_empty) {
json->set_output_empty(*output_empty);
}
optional<boolean> pixel_coordinates = get_opt_attr<boolean>(pt, "pixel-coordinates");
optional<boolean> pixel_coordinates = pt.get_opt_attr<boolean>("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_json *>(metawriter.get());
if (json) {