Added metawriter helper function.
This commit is contained in:
parent
da337036d4
commit
53e0b22c2b
3 changed files with 30 additions and 12 deletions
|
@ -45,18 +45,23 @@ class MAPNIK_DECL symbolizer_base {
|
|||
writer_name_(),
|
||||
writer_ptr_() {}
|
||||
|
||||
/** Add a metawriter to this symbolizer.
|
||||
*
|
||||
* expression can be empty the default expression of
|
||||
* the writer is used in this case. */
|
||||
/** Add a metawriter to this symbolizer using a name. */
|
||||
void add_metawriter(std::string const& name, metawriter_properties const& properties);
|
||||
/** Add a metawriter to this symbolizer using a pointer.
|
||||
* The name is only needed if you intend to call save_map() some time.
|
||||
* You don't need to call cache_metawriters() when using this function.
|
||||
* Call this function with an NULL writer_ptr to remove a metawriter.
|
||||
*/
|
||||
void add_metawriter(metawriter_ptr writer_ptr,
|
||||
metawriter_properties const& properties = metawriter_properties(),
|
||||
std::string const& name = "");
|
||||
/** Cache metawriter objects to avoid repeated lookups while processing.
|
||||
*
|
||||
* This function has to be called before the symbolizer is used, because
|
||||
* the map object is not available in renderer::apply().
|
||||
* If the metawriter was added using a symbolic name (instead of a pointer)
|
||||
* this function has to be called before the symbolizer is used, because
|
||||
* the map object is not available in renderer::apply() to resolve the reference.
|
||||
*/
|
||||
void cache_metawriters(Map const &m);
|
||||
//TODO: Allow more than one meta writer per symbolizer?
|
||||
/** Get the metawriter associated with this symbolizer or a NULL pointer if none exists.
|
||||
*
|
||||
* This functions requires that cache_metawriters() was called first.
|
||||
|
@ -67,18 +72,17 @@ class MAPNIK_DECL symbolizer_base {
|
|||
* metawriter + symbolizer specific attributes.
|
||||
* \note This function is a helperfunction for class attribute_collector.
|
||||
*/
|
||||
metawriter_properties const& get_metawriter_properties() const {return properties_complete_;}
|
||||
metawriter_properties const& get_metawriter_properties() const { return properties_complete_; }
|
||||
/** Get metawriter properties which only apply to this symbolizer.
|
||||
*/
|
||||
metawriter_properties const& get_metawriter_properties_overrides() const {return properties_;}
|
||||
metawriter_properties const& get_metawriter_properties_overrides() const { return properties_; }
|
||||
/** Get metawriter name. */
|
||||
std::string const& get_metawriter_name() const {return writer_name_;}
|
||||
std::string const& get_metawriter_name() const { return writer_name_; }
|
||||
private:
|
||||
metawriter_properties properties_;
|
||||
metawriter_properties properties_complete_;
|
||||
std::string writer_name_;
|
||||
metawriter_ptr writer_ptr_;
|
||||
|
||||
};
|
||||
|
||||
typedef boost::array<double,6> transform_type;
|
||||
|
|
|
@ -96,7 +96,7 @@ metawriter_json_stream::~metawriter_json_stream()
|
|||
|
||||
metawriter_json_stream::metawriter_json_stream(metawriter_properties dflt_properties)
|
||||
: metawriter(dflt_properties), count_(-1), output_empty_(true),
|
||||
trans_(0), output_srs_("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"), pixel_coordinates_(false), f_(0)
|
||||
pixel_coordinates_(false), trans_(0), output_srs_("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"), f_(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,20 @@ void symbolizer_base::add_metawriter(std::string const& name, metawriter_propert
|
|||
properties_ = properties;
|
||||
}
|
||||
|
||||
void symbolizer_base::add_metawriter(metawriter_ptr writer_ptr, metawriter_properties const& properties,
|
||||
std::string const& name)
|
||||
{
|
||||
writer_ptr_ = writer_ptr;
|
||||
properties_ = properties;
|
||||
writer_name_ = name;
|
||||
if (writer_ptr) {
|
||||
properties_complete_ = writer_ptr->get_default_properties();
|
||||
properties_complete_.insert(properties_.begin(), properties_.end());
|
||||
} else {
|
||||
properties_complete_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void symbolizer_base::cache_metawriters(Map const &m)
|
||||
{
|
||||
if (writer_name_.empty()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue