1.added default ctor in polygon_symbolizer (grey fill - RGB (128,128,128)
2.replaced tabs
This commit is contained in:
parent
f59a949464
commit
453b714580
5 changed files with 238 additions and 236 deletions
|
@ -20,7 +20,6 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
//$Id$
|
//$Id$
|
||||||
|
|
||||||
#ifndef FILL_HPP
|
#ifndef FILL_HPP
|
||||||
|
|
|
@ -34,57 +34,57 @@ namespace mapnik
|
||||||
|
|
||||||
class MAPNIK_DECL Map
|
class MAPNIK_DECL Map
|
||||||
{
|
{
|
||||||
friend class boost::serialization::access;
|
friend class boost::serialization::access;
|
||||||
template <typename Archive>
|
template <typename Archive>
|
||||||
void serialize(Archive & ar, const unsigned int /*version*/)
|
void serialize(Archive & ar, const unsigned int /*version*/)
|
||||||
{
|
{
|
||||||
ar & boost::serialization::make_nvp("width",width_)
|
ar & boost::serialization::make_nvp("width",width_)
|
||||||
& boost::serialization::make_nvp("height",height_)
|
& boost::serialization::make_nvp("height",height_)
|
||||||
& boost::serialization::make_nvp("srid",srid_)
|
& boost::serialization::make_nvp("srid",srid_)
|
||||||
& boost::serialization::make_nvp("layers",layers_);
|
& boost::serialization::make_nvp("layers",layers_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const unsigned MIN_MAPSIZE=16;
|
||||||
|
static const unsigned MAX_MAPSIZE=2048;
|
||||||
|
unsigned width_;
|
||||||
|
unsigned height_;
|
||||||
|
int srid_;
|
||||||
|
Color background_;
|
||||||
|
std::map<std::string,feature_type_style> styles_;
|
||||||
|
std::vector<Layer> layers_;
|
||||||
|
Envelope<double> currentExtent_;
|
||||||
|
|
||||||
static const unsigned MIN_MAPSIZE=16;
|
|
||||||
static const unsigned MAX_MAPSIZE=1024;
|
|
||||||
unsigned width_;
|
|
||||||
unsigned height_;
|
|
||||||
int srid_;
|
|
||||||
Color background_;
|
|
||||||
std::map<std::string,feature_type_style> styles_;
|
|
||||||
std::vector<Layer> layers_;
|
|
||||||
Envelope<double> currentExtent_;
|
|
||||||
public:
|
public:
|
||||||
Map();
|
Map();
|
||||||
Map(int width,int height,int srid=-1);
|
Map(int width,int height,int srid=-1);
|
||||||
Map(const Map& rhs);
|
Map(const Map& rhs);
|
||||||
Map& operator=(const Map& rhs);
|
Map& operator=(const Map& rhs);
|
||||||
|
bool insert_style(std::string const& name,feature_type_style const& style);
|
||||||
bool insert_style(std::string const& name,feature_type_style const& style);
|
void remove_style(const std::string& name);
|
||||||
void remove_style(const std::string& name);
|
feature_type_style const& find_style(std::string const& name) const;
|
||||||
feature_type_style const& find_style(std::string const& name) const;
|
size_t layerCount() const;
|
||||||
size_t layerCount() const;
|
void addLayer(const Layer& l);
|
||||||
void addLayer(const Layer& l);
|
const Layer& getLayer(size_t index) const;
|
||||||
const Layer& getLayer(size_t index) const;
|
Layer& getLayer(size_t index);
|
||||||
Layer& getLayer(size_t index);
|
void removeLayer(size_t index);
|
||||||
void removeLayer(size_t index);
|
std::vector<Layer> const& layers() const;
|
||||||
std::vector<Layer> const& layers() const;
|
unsigned getWidth() const;
|
||||||
unsigned getWidth() const;
|
unsigned getHeight() const;
|
||||||
unsigned getHeight() const;
|
void setWidth(unsigned width);
|
||||||
void setWidth(unsigned width);
|
void setHeight(unsigned height);
|
||||||
void setHeight(unsigned height);
|
void resize(unsigned width,unsigned height);
|
||||||
void resize(unsigned width,unsigned height);
|
int srid() const;
|
||||||
int srid() const;
|
void setBackground(const Color& c);
|
||||||
void setBackground(const Color& c);
|
const Color& getBackground() const;
|
||||||
const Color& getBackground() const;
|
void zoom(double zoom);
|
||||||
void zoom(double zoom);
|
void zoomToBox(const Envelope<double>& box);
|
||||||
void zoomToBox(const Envelope<double>& box);
|
void pan(int x,int y);
|
||||||
void pan(int x,int y);
|
void pan_and_zoom(int x,int y,double zoom);
|
||||||
void pan_and_zoom(int x,int y,double zoom);
|
const Envelope<double>& getCurrentExtent() const;
|
||||||
const Envelope<double>& getCurrentExtent() const;
|
double scale() const;
|
||||||
double scale() const;
|
virtual ~Map();
|
||||||
virtual ~Map();
|
|
||||||
private:
|
private:
|
||||||
void fixAspectRatio();
|
void fixAspectRatio();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,18 +31,21 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
struct MAPNIK_DECL polygon_symbolizer
|
struct MAPNIK_DECL polygon_symbolizer
|
||||||
{
|
{
|
||||||
polygon_symbolizer(Color const& fill)
|
explicit polygon_symbolizer()
|
||||||
: fill_(fill) {}
|
: fill_(Color(128,128,128) {}
|
||||||
Color const& get_fill() const
|
|
||||||
{
|
polygon_symbolizer(Color const& fill)
|
||||||
return fill_;
|
: fill_(fill) {}
|
||||||
}
|
Color const& get_fill() const
|
||||||
void set_fill(Color const& fill)
|
{
|
||||||
{
|
return fill_;
|
||||||
fill_ = fill;
|
}
|
||||||
}
|
void set_fill(Color const& fill)
|
||||||
|
{
|
||||||
|
fill_ = fill;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
Color fill_;
|
Color fill_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
330
include/rule.hpp
330
include/rule.hpp
|
@ -40,52 +40,52 @@
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
inline bool operator==(point_symbolizer const& lhs,
|
inline bool operator==(point_symbolizer const& lhs,
|
||||||
point_symbolizer const& rhs)
|
point_symbolizer const& rhs)
|
||||||
{
|
{
|
||||||
return (&lhs == &rhs);
|
return (&lhs == &rhs);
|
||||||
}
|
}
|
||||||
inline bool operator==(line_symbolizer const& lhs,
|
inline bool operator==(line_symbolizer const& lhs,
|
||||||
line_symbolizer const& rhs)
|
line_symbolizer const& rhs)
|
||||||
{
|
{
|
||||||
return (&lhs == &rhs);
|
return (&lhs == &rhs);
|
||||||
}
|
}
|
||||||
inline bool operator==(line_pattern_symbolizer const& lhs,
|
inline bool operator==(line_pattern_symbolizer const& lhs,
|
||||||
line_pattern_symbolizer const& rhs)
|
line_pattern_symbolizer const& rhs)
|
||||||
{
|
{
|
||||||
return (&lhs == &rhs);
|
return (&lhs == &rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator==(polygon_symbolizer const& lhs,
|
inline bool operator==(polygon_symbolizer const& lhs,
|
||||||
polygon_symbolizer const& rhs)
|
polygon_symbolizer const& rhs)
|
||||||
{
|
{
|
||||||
return (&lhs == &rhs);
|
return (&lhs == &rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator==(polygon_pattern_symbolizer const& lhs,
|
inline bool operator==(polygon_pattern_symbolizer const& lhs,
|
||||||
polygon_pattern_symbolizer const& rhs)
|
polygon_pattern_symbolizer const& rhs)
|
||||||
{
|
{
|
||||||
return (&lhs == &rhs);
|
return (&lhs == &rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator==(raster_symbolizer const& lhs,
|
inline bool operator==(raster_symbolizer const& lhs,
|
||||||
raster_symbolizer const& rhs)
|
raster_symbolizer const& rhs)
|
||||||
{
|
{
|
||||||
return (&lhs == &rhs);
|
return (&lhs == &rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator==(text_symbolizer const& lhs,
|
inline bool operator==(text_symbolizer const& lhs,
|
||||||
text_symbolizer const& rhs)
|
text_symbolizer const& rhs)
|
||||||
{
|
{
|
||||||
return (&lhs == &rhs);
|
return (&lhs == &rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef boost::variant<point_symbolizer,
|
typedef boost::variant<point_symbolizer,
|
||||||
line_symbolizer,
|
line_symbolizer,
|
||||||
line_pattern_symbolizer,
|
line_pattern_symbolizer,
|
||||||
polygon_symbolizer,
|
polygon_symbolizer,
|
||||||
polygon_pattern_symbolizer,
|
polygon_pattern_symbolizer,
|
||||||
raster_symbolizer,
|
raster_symbolizer,
|
||||||
text_symbolizer> symbolizer;
|
text_symbolizer> symbolizer;
|
||||||
|
|
||||||
|
|
||||||
typedef std::vector<symbolizer> symbolizers;
|
typedef std::vector<symbolizer> symbolizers;
|
||||||
|
@ -94,183 +94,183 @@ namespace mapnik
|
||||||
template <typename FeatureT,template <typename> class Filter>
|
template <typename FeatureT,template <typename> class Filter>
|
||||||
class rule
|
class rule
|
||||||
{
|
{
|
||||||
typedef Filter<FeatureT> filter_type;
|
typedef Filter<FeatureT> filter_type;
|
||||||
typedef boost::shared_ptr<filter_type> filter_ptr;
|
typedef boost::shared_ptr<filter_type> filter_ptr;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
std::string title_;
|
std::string title_;
|
||||||
std::string abstract_;
|
std::string abstract_;
|
||||||
double min_scale_;
|
double min_scale_;
|
||||||
double max_scale_;
|
double max_scale_;
|
||||||
symbolizers syms_;
|
symbolizers syms_;
|
||||||
filter_ptr filter_;
|
filter_ptr filter_;
|
||||||
bool else_filter_;
|
bool else_filter_;
|
||||||
public:
|
public:
|
||||||
rule()
|
rule()
|
||||||
: name_(),
|
: name_(),
|
||||||
title_(),
|
title_(),
|
||||||
abstract_(),
|
abstract_(),
|
||||||
min_scale_(0),
|
min_scale_(0),
|
||||||
max_scale_(std::numeric_limits<double>::infinity()),
|
max_scale_(std::numeric_limits<double>::infinity()),
|
||||||
syms_(),
|
syms_(),
|
||||||
filter_(new all_filter<FeatureT>),
|
filter_(new all_filter<FeatureT>),
|
||||||
else_filter_(false) {}
|
else_filter_(false) {}
|
||||||
|
|
||||||
rule(const std::string& name,
|
rule(const std::string& name,
|
||||||
const std::string& title="",
|
const std::string& title="",
|
||||||
double min_scale_denominator=0,
|
double min_scale_denominator=0,
|
||||||
double max_scale_denominator=std::numeric_limits<double>::infinity())
|
double max_scale_denominator=std::numeric_limits<double>::infinity())
|
||||||
: name_(name),
|
: name_(name),
|
||||||
title_(title),
|
title_(title),
|
||||||
min_scale_(min_scale_denominator),
|
min_scale_(min_scale_denominator),
|
||||||
max_scale_(max_scale_denominator),
|
max_scale_(max_scale_denominator),
|
||||||
syms_(),
|
syms_(),
|
||||||
filter_(new all_filter<FeatureT>),
|
filter_(new all_filter<FeatureT>),
|
||||||
else_filter_(false) {}
|
else_filter_(false) {}
|
||||||
|
|
||||||
rule(const rule& rhs)
|
rule(const rule& rhs)
|
||||||
: name_(rhs.name_),
|
: name_(rhs.name_),
|
||||||
title_(rhs.title_),
|
title_(rhs.title_),
|
||||||
abstract_(rhs.abstract_),
|
abstract_(rhs.abstract_),
|
||||||
min_scale_(rhs.min_scale_),
|
min_scale_(rhs.min_scale_),
|
||||||
max_scale_(rhs.max_scale_),
|
max_scale_(rhs.max_scale_),
|
||||||
syms_(rhs.syms_),
|
syms_(rhs.syms_),
|
||||||
filter_(rhs.filter_),
|
filter_(rhs.filter_),
|
||||||
else_filter_(rhs.else_filter_) {}
|
else_filter_(rhs.else_filter_) {}
|
||||||
|
|
||||||
rule& operator=(rule const& rhs)
|
rule& operator=(rule const& rhs)
|
||||||
{
|
{
|
||||||
rule tmp(rhs);
|
rule tmp(rhs);
|
||||||
swap(tmp);
|
swap(tmp);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
bool operator==(rule const& other)
|
bool operator==(rule const& other)
|
||||||
{
|
{
|
||||||
return (this == &other);
|
return (this == &other);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_max_scale(double scale)
|
void set_max_scale(double scale)
|
||||||
{
|
{
|
||||||
max_scale_=scale;
|
max_scale_=scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
double get_min_scale() const
|
double get_min_scale() const
|
||||||
{
|
{
|
||||||
return min_scale_;
|
return min_scale_;
|
||||||
}
|
}
|
||||||
|
|
||||||
double get_max_scale() const
|
double get_max_scale() const
|
||||||
{
|
{
|
||||||
return max_scale_;
|
return max_scale_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_min_scale(double scale)
|
void set_min_scale(double scale)
|
||||||
{
|
{
|
||||||
min_scale_=scale;
|
min_scale_=scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_name(std::string const& name)
|
void set_name(std::string const& name)
|
||||||
{
|
{
|
||||||
name_=name;
|
name_=name;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const& get_name() const
|
std::string const& get_name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const& get_title() const
|
std::string const& get_title() const
|
||||||
{
|
{
|
||||||
return title_;
|
return title_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_title(std::string const& title)
|
void set_title(std::string const& title)
|
||||||
{
|
{
|
||||||
title_=title;
|
title_=title;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_abstract(std::string const& abstract)
|
void set_abstract(std::string const& abstract)
|
||||||
{
|
{
|
||||||
abstract_=abstract;
|
abstract_=abstract;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const& get_abstract() const
|
std::string const& get_abstract() const
|
||||||
{
|
{
|
||||||
return abstract_;
|
return abstract_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void append(const symbolizer& sym)
|
void append(const symbolizer& sym)
|
||||||
{
|
{
|
||||||
syms_.push_back(sym);
|
syms_.push_back(sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_at(size_t index)
|
void remove_at(size_t index)
|
||||||
{
|
{
|
||||||
if (index < syms_.size())
|
if (index < syms_.size())
|
||||||
{
|
{
|
||||||
syms_.erase(syms_.begin()+index);
|
syms_.erase(syms_.begin()+index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const symbolizers& get_symbolizers() const
|
const symbolizers& get_symbolizers() const
|
||||||
{
|
{
|
||||||
return syms_;
|
return syms_;
|
||||||
}
|
}
|
||||||
|
|
||||||
symbolizers::const_iterator begin()
|
symbolizers::const_iterator begin()
|
||||||
{
|
{
|
||||||
return syms_.begin();
|
return syms_.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
symbolizers::const_iterator end()
|
symbolizers::const_iterator end()
|
||||||
{
|
{
|
||||||
return syms_.end();
|
return syms_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_filter(const filter_ptr& filter)
|
void set_filter(const filter_ptr& filter)
|
||||||
{
|
{
|
||||||
filter_=filter;
|
filter_=filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
filter_ptr const& get_filter() const
|
filter_ptr const& get_filter() const
|
||||||
{
|
{
|
||||||
return filter_;
|
return filter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_else(bool else_filter)
|
void set_else(bool else_filter)
|
||||||
{
|
{
|
||||||
else_filter_=else_filter;
|
else_filter_=else_filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_else_filter() const
|
bool has_else_filter() const
|
||||||
{
|
{
|
||||||
return else_filter_;
|
return else_filter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool active(double scale) const
|
bool active(double scale) const
|
||||||
{
|
{
|
||||||
return ( scale > min_scale_ && scale < max_scale_ );
|
return ( scale > min_scale_ && scale < max_scale_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
void accept(filter_visitor<FeatureT>& v) const
|
void accept(filter_visitor<FeatureT>& v) const
|
||||||
{
|
{
|
||||||
v.visit(*this);
|
v.visit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void swap(rule& rhs) throw()
|
void swap(rule& rhs) throw()
|
||||||
{
|
{
|
||||||
name_=rhs.name_;
|
name_=rhs.name_;
|
||||||
title_=rhs.title_;
|
title_=rhs.title_;
|
||||||
abstract_=rhs.abstract_;
|
abstract_=rhs.abstract_;
|
||||||
min_scale_=rhs.min_scale_;
|
min_scale_=rhs.min_scale_;
|
||||||
max_scale_=rhs.max_scale_;
|
max_scale_=rhs.max_scale_;
|
||||||
syms_=rhs.syms_;
|
syms_=rhs.syms_;
|
||||||
filter_=rhs.filter_;
|
filter_=rhs.filter_;
|
||||||
else_filter_=rhs.else_filter_;
|
else_filter_=rhs.else_filter_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef rule<Feature,filter> rule_type;
|
typedef rule<Feature,filter> rule_type;
|
||||||
|
|
|
@ -201,21 +201,21 @@ namespace mapnik
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline std::string toString(const T& x)
|
inline std::string toString(const T& x)
|
||||||
{
|
{
|
||||||
std::ostringstream o;
|
std::ostringstream o;
|
||||||
if (!(o << x))
|
if (!(o << x))
|
||||||
throw BadConversion(std::string("toString(")
|
throw BadConversion(std::string("toString(")
|
||||||
+ typeid(x).name() + ")");
|
+ typeid(x).name() + ")");
|
||||||
return o.str();
|
return o.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void fromString(const std::string& s, T& x,
|
inline void fromString(const std::string& s, T& x,
|
||||||
bool failIfLeftoverChars = true)
|
bool failIfLeftoverChars = true)
|
||||||
{
|
{
|
||||||
std::istringstream i(s);
|
std::istringstream i(s);
|
||||||
char c;
|
char c;
|
||||||
if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
|
if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
|
||||||
throw BadConversion("fromString("+s+")");
|
throw BadConversion("fromString("+s+")");
|
||||||
}
|
}
|
||||||
|
|
||||||
//inline bool space (char c)
|
//inline bool space (char c)
|
||||||
|
|
Loading…
Reference in a new issue