Skip to content

Commit

Permalink
Merge branch 'master' into geometry-clipping
Browse files Browse the repository at this point in the history
Conflicts:
	SConstruct
	include/mapnik/symbolizer_helpers.hpp
	src/placement_finder.cpp
  • Loading branch information
artemp committed Mar 9, 2012
2 parents 5ce1871 + c5c0f92 commit 254b3c9
Show file tree
Hide file tree
Showing 44 changed files with 255 additions and 160 deletions.
2 changes: 2 additions & 0 deletions SConstruct
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1411,7 +1411,9 @@ if not preconfigured:
pthread = '-pthread' pthread = '-pthread'


# Common debugging flags. # Common debugging flags.
# http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html
debug_flags = '-g -fno-omit-frame-pointer -DDEBUG -DMAPNIK_DEBUG' debug_flags = '-g -fno-omit-frame-pointer -DDEBUG -DMAPNIK_DEBUG'

ndebug_flags = '-DNDEBUG' ndebug_flags = '-DNDEBUG'




Expand Down
1 change: 1 addition & 0 deletions bindings/python/mapnik/__init__.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ def register_fonts(path=fontscollectionpath,valid_extensions=['.ttf','.otf','.tt
'SQLite', 'SQLite',
'Osm', 'Osm',
'Kismet', 'Kismet',
'Geos',
# version and environment # version and environment
'mapnik_version_string', 'mapnik_version_string',
'mapnik_version', 'mapnik_version',
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/mapnik_map.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct map_pickle_suite : boost::python::pickle_suite
Map::const_style_iterator end = m.styles().end(); Map::const_style_iterator end = m.styles().end();
for (; it != end; ++it) for (; it != end; ++it)
{ {
const std::string & name = it->first; std::string const& name = it->first;
const mapnik::feature_type_style & style = it->second; const mapnik::feature_type_style & style = it->second;
boost::python::tuple style_pair = boost::python::make_tuple(name,style); boost::python::tuple style_pair = boost::python::make_tuple(name,style);
s.append(style_pair); s.append(style_pair);
Expand Down Expand Up @@ -153,7 +153,7 @@ bool has_metawriter(mapnik::Map const& m)


// returns empty shared_ptr when the metawriter isn't found, or is // returns empty shared_ptr when the metawriter isn't found, or is
// of the wrong type. empty pointers make it back to Python as a None. // of the wrong type. empty pointers make it back to Python as a None.
mapnik::metawriter_inmem_ptr find_inmem_metawriter(const mapnik::Map &m, const std::string &name) { mapnik::metawriter_inmem_ptr find_inmem_metawriter(const mapnik::Map &m, std::string const&name) {
mapnik::metawriter_ptr metawriter = m.find_metawriter(name); mapnik::metawriter_ptr metawriter = m.find_metawriter(name);
mapnik::metawriter_inmem_ptr inmem; mapnik::metawriter_inmem_ptr inmem;


Expand Down
12 changes: 12 additions & 0 deletions docs/contributing.markdown
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ If you see bits of code around that do not follow these please don't hesitate to


(int)value; // no (int)value; // no


#### Use const keyword after the type

std::string const& variable_name // preferred, for consistency

const std::string & variable_name // no

#### Pass built-in types by value, all others by const&

void my_function(int double val); // if int, char, double, etc pass by value

void my_function(std::string const& val); // if std::string or user type, pass by const&

#### Shared pointers should be created with [boost::make_shared](http://www.boost.org/doc/libs/1_47_0/libs/smart_ptr/make_shared.html) where possible #### Shared pointers should be created with [boost::make_shared](http://www.boost.org/doc/libs/1_47_0/libs/smart_ptr/make_shared.html) where possible


#### Function definitions should not be separated from their arguments: #### Function definitions should not be separated from their arguments:
Expand Down
4 changes: 0 additions & 4 deletions include/mapnik/agg_renderer.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
#include <mapnik/font_engine_freetype.hpp> #include <mapnik/font_engine_freetype.hpp>
#include <mapnik/label_collision_detector.hpp> #include <mapnik/label_collision_detector.hpp>
#include <mapnik/map.hpp> #include <mapnik/map.hpp>
//#include <mapnik/marker.hpp>

// agg
//#include "agg_trans_affine.h"


// boost // boost
#include <boost/utility.hpp> #include <boost/utility.hpp>
Expand Down
17 changes: 15 additions & 2 deletions include/mapnik/char_info.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,11 +31,24 @@ struct char_properties;
class char_info { class char_info {
public: public:
char_info(unsigned c_, double width_, double ymax_, double ymin_, double line_height_) char_info(unsigned c_, double width_, double ymax_, double ymin_, double line_height_)
: c(c_), width(width_), line_height(line_height_), ymin(ymin_), ymax(ymax_) : c(c_),
width(width_),
line_height(line_height_),
ymin(ymin_),
ymax(ymax_),
avg_height(ymax_-ymin_),
format()
{ {
} }

char_info() char_info()
: c(0), width(0), line_height(0), ymin(0), ymax(0) : c(0),
width(0),
line_height(0),
ymin(0),
ymax(0),
avg_height(0),
format()
{ {
} }


Expand Down
7 changes: 4 additions & 3 deletions include/mapnik/config_error.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ namespace mapnik {
class config_error : public std::exception class config_error : public std::exception
{ {
public: public:
config_error() {} config_error():
what_() {}


config_error( const std::string & what ) : config_error( std::string const& what ) :
what_( what ) what_( what )
{ {
} }
Expand All @@ -44,7 +45,7 @@ class config_error : public std::exception
return what_.c_str(); return what_.c_str();
} }


void append_context(const std::string & ctx) const void append_context(std::string const& ctx) const
{ {
what_ += " " + ctx; what_ += " " + ctx;
} }
Expand Down
19 changes: 13 additions & 6 deletions include/mapnik/ctrans.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -380,20 +380,27 @@ class CoordTransform
private: private:
int width_; int width_;
int height_; int height_;
double sx_;
double sy_;
box2d<double> extent_; box2d<double> extent_;
double offset_x_; double offset_x_;
double offset_y_; double offset_y_;
double sx_;
double sy_;


public: public:
CoordTransform(int width, int height, const box2d<double>& extent, CoordTransform(int width, int height, const box2d<double>& extent,
double offset_x = 0, double offset_y = 0) double offset_x = 0, double offset_y = 0)
: width_(width), height_(height), extent_(extent), : width_(width),
offset_x_(offset_x), offset_y_(offset_y) height_(height),
extent_(extent),
offset_x_(offset_x),
offset_y_(offset_y),
sx_(1.0),
sy_(1.0)
{ {
sx_ = static_cast<double>(width_) / extent_.width(); if (extent_.width())
sy_ = static_cast<double>(height_) / extent_.height(); sx_ = static_cast<double>(width_) / extent_.width();
if (extent_.height())
sy_ = static_cast<double>(height_) / extent_.height();
} }


inline int width() const inline int width() const
Expand Down
12 changes: 7 additions & 5 deletions include/mapnik/enumeration.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ namespace mapnik {
class illegal_enum_value : public std::exception class illegal_enum_value : public std::exception
{ {
public: public:
illegal_enum_value() {} illegal_enum_value():
what_() {}


illegal_enum_value( const std::string & what ) : illegal_enum_value( std::string const& what ) :
what_( what ) what_( what )
{ {
} }
Expand Down Expand Up @@ -138,7 +139,8 @@ template <class ENUM, int THE_MAX>
class MAPNIK_DECL enumeration { class MAPNIK_DECL enumeration {
public: public:
typedef ENUM native_type; typedef ENUM native_type;
enumeration() {}; enumeration():
value_() {};
enumeration( ENUM v ) : value_(v) {} enumeration( ENUM v ) : value_(v) {}
enumeration( const enumeration & other ) : value_(other.value_) {} enumeration( const enumeration & other ) : value_(other.value_) {}


Expand Down Expand Up @@ -171,7 +173,7 @@ class MAPNIK_DECL enumeration {
/** Converts @p str to an enum. /** Converts @p str to an enum.
* @throw illegal_enum_value @p str is not a legal identifier. * @throw illegal_enum_value @p str is not a legal identifier.
* */ * */
void from_string(const std::string & str) void from_string(std::string const& str)
{ {
for (unsigned i = 0; i < THE_MAX; ++i) for (unsigned i = 0; i < THE_MAX; ++i)
{ {
Expand Down Expand Up @@ -267,7 +269,7 @@ class MAPNIK_DECL enumeration {
} }
return true; return true;
} }
static const std::string & get_full_qualified_name() static std::string const& get_full_qualified_name()
{ {
return our_name_; return our_name_;
} }
Expand Down
6 changes: 4 additions & 2 deletions include/mapnik/feature.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ class MAPNIK_DECL feature_impl : private boost::noncopyable
feature_impl(context_ptr const& ctx, int id) feature_impl(context_ptr const& ctx, int id)
: id_(id), : id_(id),
ctx_(ctx), ctx_(ctx),
data_(ctx_->mapping_.size()) data_(ctx_->mapping_.size()),
geom_cont_(),
raster_()
{} {}


inline int id() const { return id_;} inline int id() const { return id_;}
Expand Down Expand Up @@ -280,9 +282,9 @@ class MAPNIK_DECL feature_impl : private boost::noncopyable
private: private:
int id_; int id_;
context_ptr ctx_; context_ptr ctx_;
cont_type data_;
boost::ptr_vector<geometry_type> geom_cont_; boost::ptr_vector<geometry_type> geom_cont_;
raster_ptr raster_; raster_ptr raster_;
cont_type data_;
}; };




Expand Down
3 changes: 2 additions & 1 deletion include/mapnik/font_engine_freetype.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ class MAPNIK_DECL font_face_set : private boost::noncopyable
{ {
public: public:
font_face_set(void) font_face_set(void)
: faces_() {} : faces_(),
dimension_cache_() {}


void add(face_ptr face) void add(face_ptr face)
{ {
Expand Down
2 changes: 1 addition & 1 deletion include/mapnik/image_util.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ inline boost::optional<std::string> type_from_filename(std::string const& filena
return result_type(); return result_type();
} }


inline std::string guess_type( const std::string & filename ) inline std::string guess_type( std::string const& filename )
{ {
std::string::size_type idx = filename.find_last_of("."); std::string::size_type idx = filename.find_last_of(".");
if ( idx != std::string::npos ) { if ( idx != std::string::npos ) {
Expand Down
2 changes: 1 addition & 1 deletion include/mapnik/load_map.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
namespace mapnik namespace mapnik
{ {
MAPNIK_DECL void load_map(Map & map, std::string const& filename, bool strict = false); MAPNIK_DECL void load_map(Map & map, std::string const& filename, bool strict = false);
MAPNIK_DECL void load_map_string(Map & map, std::string const& str, bool strict = false, std::string const& base_path=""); MAPNIK_DECL void load_map_string(Map & map, std::string const& str, bool strict = false, std::string base_path="");
} }


#endif // MAPNIK_LOAD_MAP_HPP #endif // MAPNIK_LOAD_MAP_HPP
9 changes: 1 addition & 8 deletions include/mapnik/marker_cache.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@


// mapnik // mapnik
#include <mapnik/utils.hpp> #include <mapnik/utils.hpp>
#include <mapnik/marker.hpp>
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/svg/svg_path_attributes.hpp>
#include <mapnik/svg/svg_storage.hpp>
#include <mapnik/svg/svg_path_adapter.hpp>

// agg
#include "agg_path_storage.h"


// boost // boost
#include <boost/utility.hpp> #include <boost/utility.hpp>
Expand All @@ -43,7 +36,7 @@
namespace mapnik namespace mapnik
{ {


using namespace mapnik::svg; class marker;


typedef boost::shared_ptr<marker> marker_ptr; typedef boost::shared_ptr<marker> marker_ptr;


Expand Down
16 changes: 8 additions & 8 deletions include/mapnik/placement_finder.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -92,29 +92,29 @@ class placement_finder : boost::noncopyable
// otherwise it will autodetect the orientation. // otherwise it will autodetect the orientation.
// If >= 50% of the characters end up upside down, it will be retried the other way. // If >= 50% of the characters end up upside down, it will be retried the other way.
// RETURN: 1/-1 depending which way up the string ends up being. // RETURN: 1/-1 depending which way up the string ends up being.
std::auto_ptr<text_path> get_placement_offset(const std::vector<vertex2d> & path_positions, std::auto_ptr<text_path> get_placement_offset(std::vector<vertex2d> const& path_positions,
const std::vector<double> & path_distances, std::vector<double> const& path_distances,
int & orientation, unsigned index, double distance); int & orientation, unsigned index, double distance);


///Tests wether the given text_path be placed without a collision ///Tests whether the given text_path be placed without a collision
// Returns true if it can // Returns true if it can
// NOTE: This edits p.envelopes so it can be used afterwards (you must clear it otherwise) // NOTE: This edits p.envelopes so it can be used afterwards (you must clear it otherwise)
bool test_placement(const std::auto_ptr<text_path> & current_placement, const int & orientation); bool test_placement(std::auto_ptr<text_path> const& current_placement, int orientation);


///Does a line-circle intersect calculation ///Does a line-circle intersect calculation
// NOTE: Follow the strict pre conditions // NOTE: Follow the strict pre conditions
// Pre Conditions: x1,y1 is within radius distance of cx,cy. x2,y2 is outside radius distance of cx,cy // Pre Conditions: x1,y1 is within radius distance of cx,cy. x2,y2 is outside radius distance of cx,cy
// This means there is exactly one intersect point // This means there is exactly one intersect point
// Result is returned in ix, iy // Result is returned in ix, iy
void find_line_circle_intersection( void find_line_circle_intersection(
const double &cx, const double &cy, const double &radius, double cx, double cy, double radius,
const double &x1, const double &y1, const double &x2, const double &y2, double x1, double y1, double x2, double y2,
double &ix, double &iy); double & ix, double & iy);


void find_line_breaks(); void find_line_breaks();
void init_string_size(); void init_string_size();
void init_alignment(); void init_alignment();
void adjust_position(text_path *current_placement, double label_x, double label_y); void adjust_position(text_path *current_placement);
void add_line(double width, double height, bool first_line); void add_line(double width, double height, bool first_line);


///General Internals ///General Internals
Expand Down
12 changes: 10 additions & 2 deletions include/mapnik/ptree_helpers.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ operator << ( std::basic_ostream<charT, traits> & s, mapnik::color const& c )
/** Helper for class bool */ /** Helper for class bool */
class boolean { class boolean {
public: public:
boolean() {} boolean() : b_(false) {}
boolean(bool b) : b_(b) {} boolean(bool b) : b_(b) {}
boolean(boolean const& b) : b_(b.b_) {} boolean(boolean const& b) : b_(b.b_) {}


Expand Down Expand Up @@ -211,7 +211,15 @@ struct name_trait< mapnik::enumeration<ENUM, MAX> >
template <typename T> template <typename T>
inline boost::optional<T> fast_cast(std::string const& value) inline boost::optional<T> fast_cast(std::string const& value)
{ {
return boost::lexical_cast<T>( value ); try
{
return boost::lexical_cast<T>( value );
}
catch (boost::bad_lexical_cast const& ex)
{
return boost::optional<T>();
}

} }


template <> template <>
Expand Down
2 changes: 1 addition & 1 deletion include/mapnik/shield_symbolizer.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct MAPNIK_DECL shield_symbolizer : public text_symbolizer,


bool get_unlock_image() const; // image is not locked to the text placement bool get_unlock_image() const; // image is not locked to the text placement
void set_unlock_image(bool unlock_image); void set_unlock_image(bool unlock_image);
void set_shield_displacement(double shield_dx,double shield_dy); void set_shield_displacement(double shield_dx, double shield_dy);
position const& get_shield_displacement() const; position const& get_shield_displacement() const;


private: private:
Expand Down
10 changes: 5 additions & 5 deletions include/mapnik/symbolizer_helpers.hpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class text_symbolizer_helper
unsigned width, unsigned width,
unsigned height, unsigned height,
double scale_factor, double scale_factor,
CoordTransform const &t, CoordTransform const& t,
FaceManagerT &font_manager, FaceManagerT &font_manager,
DetectorT &detector, DetectorT &detector,
box2d<double> const& query_extent) box2d<double> const& query_extent)
Expand Down Expand Up @@ -85,7 +85,7 @@ class text_symbolizer_helper
bool next(); bool next();


/** Get current placement. next() has to be called before! */ /** Get current placement. next() has to be called before! */
placements_type &placements() const; placements_type & placements() const;
protected: protected:
bool next_point_placement(); bool next_point_placement();
bool next_line_placement(); bool next_line_placement();
Expand All @@ -98,8 +98,8 @@ class text_symbolizer_helper
Feature const& feature_; Feature const& feature_;
proj_transform const& prj_trans_; proj_transform const& prj_trans_;
CoordTransform const& t_; CoordTransform const& t_;
FaceManagerT &font_manager_; FaceManagerT & font_manager_;
DetectorT &detector_; DetectorT & detector_;
metawriter_with_properties writer_; metawriter_with_properties writer_;
box2d<double> dims_; box2d<double> dims_;
box2d<double> const& query_extent_; box2d<double> const& query_extent_;
Expand Down Expand Up @@ -152,7 +152,7 @@ class shield_symbolizer_helper: public text_symbolizer_helper<FaceManagerT, Dete


bool next(); bool next();
pixel_position get_marker_position(text_path const& p); pixel_position get_marker_position(text_path const& p);
marker &get_marker() const; marker & get_marker() const;
agg::trans_affine const& get_transform() const; agg::trans_affine const& get_transform() const;
protected: protected:
bool next_point_placement(); bool next_point_placement();
Expand Down
Loading

0 comments on commit 254b3c9

Please sign in to comment.