2006-03-31 12:32:02 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
2005-06-14 17:06:59 +02:00
|
|
|
*
|
2011-10-23 15:04:25 +02:00
|
|
|
* Copyright (C) 2011 Artem Pavlenko
|
2005-06-14 17:06:59 +02:00
|
|
|
*
|
2006-03-31 12:32:02 +02:00
|
|
|
* 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,
|
2005-06-14 17:06:59 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2006-03-31 12:32:02 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2005-06-14 17:06:59 +02:00
|
|
|
*
|
2006-03-31 12:32:02 +02:00
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2005-06-14 17:06:59 +02:00
|
|
|
|
2009-12-16 21:02:06 +01:00
|
|
|
#ifndef MAPNIK_SYMBOLIZER_HPP
|
|
|
|
#define MAPNIK_SYMBOLIZER_HPP
|
2005-06-14 17:06:59 +02:00
|
|
|
|
2009-12-16 21:02:06 +01:00
|
|
|
// mapnik
|
|
|
|
#include <mapnik/config.hpp>
|
2010-06-18 17:39:32 +02:00
|
|
|
#include <mapnik/parse_path.hpp>
|
2010-07-06 02:37:05 +02:00
|
|
|
#include <mapnik/metawriter.hpp>
|
2009-12-16 21:02:06 +01:00
|
|
|
|
2010-06-03 14:35:02 +02:00
|
|
|
// boost
|
|
|
|
#include <boost/array.hpp>
|
2007-09-25 20:47:12 +02:00
|
|
|
|
2005-06-14 17:06:59 +02:00
|
|
|
namespace mapnik
|
|
|
|
{
|
2007-09-25 20:47:12 +02:00
|
|
|
|
2010-07-06 02:37:05 +02:00
|
|
|
class Map;
|
|
|
|
|
|
|
|
class MAPNIK_DECL symbolizer_base {
|
|
|
|
public:
|
2011-01-11 00:04:34 +01:00
|
|
|
symbolizer_base():
|
|
|
|
properties_(),
|
|
|
|
properties_complete_(),
|
|
|
|
writer_name_(),
|
|
|
|
writer_ptr_() {}
|
|
|
|
|
2011-07-29 00:59:05 +02:00
|
|
|
/** Add a metawriter to this symbolizer using a name. */
|
2010-07-19 13:09:44 +02:00
|
|
|
void add_metawriter(std::string const& name, metawriter_properties const& properties);
|
2011-07-29 00:59:05 +02:00
|
|
|
/** 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 = "");
|
2010-07-06 02:37:05 +02:00
|
|
|
/** Cache metawriter objects to avoid repeated lookups while processing.
|
|
|
|
*
|
2011-07-29 00:59:05 +02:00
|
|
|
* 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.
|
2010-07-06 02:37:05 +02:00
|
|
|
*/
|
|
|
|
void cache_metawriters(Map const &m);
|
|
|
|
/** Get the metawriter associated with this symbolizer or a NULL pointer if none exists.
|
|
|
|
*
|
|
|
|
* This functions requires that cache_metawriters() was called first.
|
|
|
|
*/
|
2010-07-12 17:27:33 +02:00
|
|
|
metawriter_with_properties get_metawriter() const;
|
2010-08-12 02:11:01 +02:00
|
|
|
/** Get metawriter properties.
|
|
|
|
* This functions returns the default attributes of the
|
|
|
|
* metawriter + symbolizer specific attributes.
|
2010-07-12 17:27:33 +02:00
|
|
|
* \note This function is a helperfunction for class attribute_collector.
|
|
|
|
*/
|
2011-07-29 00:59:05 +02:00
|
|
|
metawriter_properties const& get_metawriter_properties() const { return properties_complete_; }
|
2010-08-12 02:11:01 +02:00
|
|
|
/** Get metawriter properties which only apply to this symbolizer.
|
|
|
|
*/
|
2011-07-29 00:59:05 +02:00
|
|
|
metawriter_properties const& get_metawriter_properties_overrides() const { return properties_; }
|
2010-08-12 02:11:01 +02:00
|
|
|
/** Get metawriter name. */
|
2011-07-29 00:59:05 +02:00
|
|
|
std::string const& get_metawriter_name() const { return writer_name_; }
|
2010-07-06 02:37:05 +02:00
|
|
|
private:
|
2010-07-12 17:27:33 +02:00
|
|
|
metawriter_properties properties_;
|
2010-07-31 12:20:56 +02:00
|
|
|
metawriter_properties properties_complete_;
|
2010-07-06 02:37:05 +02:00
|
|
|
std::string writer_name_;
|
|
|
|
metawriter_ptr writer_ptr_;
|
|
|
|
};
|
|
|
|
|
2010-06-03 14:35:02 +02:00
|
|
|
typedef boost::array<double,6> transform_type;
|
|
|
|
|
2009-12-16 21:02:06 +01:00
|
|
|
class MAPNIK_DECL symbolizer_with_image {
|
|
|
|
public:
|
|
|
|
path_expression_ptr get_filename() const;
|
|
|
|
void set_filename(path_expression_ptr filename);
|
2010-06-03 14:35:02 +02:00
|
|
|
void set_transform(transform_type const& );
|
|
|
|
transform_type const& get_transform() const;
|
2011-01-11 00:04:34 +01:00
|
|
|
std::string const get_transform_string() const;
|
2010-06-15 14:27:42 +02:00
|
|
|
void set_opacity(float opacity);
|
|
|
|
float get_opacity() const;
|
2009-12-16 21:02:06 +01:00
|
|
|
protected:
|
|
|
|
symbolizer_with_image(path_expression_ptr filename);
|
|
|
|
symbolizer_with_image(symbolizer_with_image const& rhs);
|
2010-06-03 14:35:02 +02:00
|
|
|
path_expression_ptr image_filename_;
|
2010-06-15 14:27:42 +02:00
|
|
|
float opacity_;
|
2010-06-15 15:36:41 +02:00
|
|
|
transform_type matrix_;
|
2009-12-16 21:02:06 +01:00
|
|
|
};
|
2005-06-14 17:06:59 +02:00
|
|
|
}
|
|
|
|
|
2011-10-23 16:09:47 +02:00
|
|
|
#endif // MAPNIK_SYMBOLIZER_HPP
|