Created a class for metawriter_properties.
This commit is contained in:
parent
635a487463
commit
7e10a32503
3 changed files with 15 additions and 16 deletions
|
@ -41,7 +41,14 @@
|
|||
namespace mapnik {
|
||||
|
||||
/** All properties to be output by a metawriter. */
|
||||
typedef std::set<std::string> metawriter_properties;
|
||||
class metawriter_properties : public std::set<std::string>
|
||||
{
|
||||
public:
|
||||
metawriter_properties(boost::optional<std::string> str);
|
||||
metawriter_properties() {};
|
||||
template <class InputIterator> metawriter_properties(
|
||||
InputIterator first, InputIterator last) : std::set<std::string>(first, last) {};
|
||||
};
|
||||
|
||||
/** Abstract baseclass for all metawriter classes. */
|
||||
class metawriter
|
||||
|
@ -62,7 +69,6 @@ class metawriter
|
|||
metawriter_properties const& properties = metawriter_properties())=0;
|
||||
virtual void start() {};
|
||||
virtual void stop() {};
|
||||
static metawriter_properties parse_properties(boost::optional<std::string> str);
|
||||
protected:
|
||||
metawriter_properties dflt_properties_;
|
||||
};
|
||||
|
|
|
@ -354,7 +354,7 @@ void map_parser::parse_metawriter(Map & map, ptree const & pt)
|
|||
if (type == "json") {
|
||||
string file = get_attr<string>(pt, "file");
|
||||
optional<string> properties = get_attr<string>(pt, "default-output");
|
||||
writer = metawriter_ptr(new metawriter_json(metawriter_properties(metawriter::parse_properties(properties)), file));
|
||||
writer = metawriter_ptr(new metawriter_json(properties, file));
|
||||
} else {
|
||||
throw config_error(string("Unknown type '") + type + "'");
|
||||
}
|
||||
|
@ -705,7 +705,7 @@ void map_parser::parse_metawriter_in_symbolizer(symbolizer_base &sym, ptree cons
|
|||
optional<std::string> writer = get_opt_attr<string>(pt, "meta-writer");
|
||||
if (!writer) return;
|
||||
optional<std::string> output = get_opt_attr<string>(pt, "meta-output");
|
||||
sym.add_metawriter(*writer, metawriter::parse_properties(output));
|
||||
sym.add_metawriter(*writer, output);
|
||||
}
|
||||
|
||||
void map_parser::parse_point_symbolizer( rule_type & rule, ptree const & sym )
|
||||
|
|
|
@ -70,19 +70,15 @@ void metawriter_json::add_box(box2d<double> box, Feature const &feature,
|
|||
proj_transform const& prj_trans, CoordTransform const &t,
|
||||
const metawriter_properties& properties)
|
||||
{
|
||||
metawriter_properties props;
|
||||
if (properties.empty())
|
||||
metawriter_properties props(properties);
|
||||
if (props.empty())
|
||||
{
|
||||
props = dflt_properties_;
|
||||
}
|
||||
else
|
||||
{
|
||||
props = properties;
|
||||
}
|
||||
|
||||
if (props.empty())
|
||||
{
|
||||
std::cerr << "WARNING: No expression available for GeoJSON metawriter.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
/* Coordinate transform in renderer:
|
||||
|
@ -134,13 +130,10 @@ void metawriter_json::add_box(box2d<double> box, Feature const &feature,
|
|||
f << "\n} }";
|
||||
}
|
||||
|
||||
metawriter_properties metawriter::parse_properties(boost::optional<std::string> str)
|
||||
metawriter_properties::metawriter_properties(boost::optional<std::string> str)
|
||||
{
|
||||
metawriter_properties properties;
|
||||
if (str) {
|
||||
std::string str_ = boost::algorithm::erase_all_copy(*str, " ");
|
||||
boost::split(properties, str_, boost::is_any_of(","), boost::token_compress_on);
|
||||
boost::split(*this, *str, boost::is_any_of(", "), boost::token_compress_on);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue