start using c++11 features: auto/for/unique_ptr/variadic args - refs #1972

This commit is contained in:
Dane Springmeyer 2013-09-19 20:19:01 -07:00
parent 9bd3dd0e21
commit 5d12a345ae
86 changed files with 431 additions and 464 deletions

View file

@ -93,7 +93,7 @@ void benchmark(T & test_runner, std::string const& name)
bool compare_images(std::string const& src_fn,std::string const& dest_fn)
{
std::auto_ptr<mapnik::image_reader> reader1(mapnik::get_image_reader(dest_fn,"png"));
std::unique_ptr<mapnik::image_reader> reader1(mapnik::get_image_reader(dest_fn,"png"));
if (!reader1.get())
{
throw mapnik::image_reader_exception("Failed to load: " + dest_fn);
@ -101,7 +101,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn)
boost::shared_ptr<image_32> image_ptr1 = boost::make_shared<image_32>(reader1->width(),reader1->height());
reader1->read(0,0,image_ptr1->data());
std::auto_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(src_fn,"png"));
std::unique_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(src_fn,"png"));
if (!reader2.get())
{
throw mapnik::image_reader_exception("Failed to load: " + src_fn);
@ -163,7 +163,7 @@ struct test2
im_()
{
std::string filename("./benchmark/data/multicolor.png");
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(filename,"png"));
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(filename,"png"));
if (!reader.get())
{
throw mapnik::image_reader_exception("Failed to load: " + filename);
@ -450,7 +450,7 @@ struct test11
ps.close_polygon();
for (unsigned i=0;i<iter_;++i)
{
BOOST_FOREACH (geometry_type & geom , paths)
for (geometry_type & geom : paths)
{
poly_clipper clipped(geom,ps,
agg::clipper_and,
@ -500,7 +500,7 @@ struct test12
}
for (unsigned i=0;i<iter_;++i)
{
BOOST_FOREACH ( geometry_type & geom , paths)
for ( geometry_type & geom : paths)
{
poly_clipper clipped(extent_, geom);
unsigned cmd;
@ -535,7 +535,7 @@ struct test13
unsigned long count = 0;
for (unsigned i=0;i<iter_;++i)
{
BOOST_FOREACH( std::string const& name , mapnik::freetype_engine::face_names())
for ( std::string const& name : mapnik::freetype_engine::face_names())
{
mapnik::face_ptr f = engine.create_face(name);
if (f) ++count;

View file

@ -107,7 +107,7 @@ mapnik::box2d<double> envelope_impl(path_type & p)
{
mapnik::box2d<double> b;
bool first = true;
BOOST_FOREACH(mapnik::geometry_type const& geom, p)
for (mapnik::geometry_type const& geom : p)
{
if (first)
{
@ -232,6 +232,7 @@ std::string to_geojson( path_type const& geom)
std::string to_svg( geometry_type const& geom)
{
#if BOOST_VERSION >= 104700
std::string svg; // Use Python String directly ?
bool result = mapnik::util::to_svg(svg,geom);
@ -269,10 +270,10 @@ void export_geometry()
{
using namespace boost::python;
enum_<mapnik::eGeomType>("GeometryType")
.value("Point",mapnik::Point)
.value("LineString",mapnik::LineString)
.value("Polygon",mapnik::Polygon)
enum_<mapnik::geometry_type::types>("GeometryType")
.value("Point",mapnik::geometry_type::types::Point)
.value("LineString",mapnik::geometry_type::types::LineString)
.value("Polygon",mapnik::geometry_type::types::Polygon)
;
#if BOOST_VERSION >= 104700
@ -283,7 +284,7 @@ void export_geometry()
#endif
using mapnik::geometry_type;
class_<geometry_type, std::auto_ptr<geometry_type>, boost::noncopyable>("Geometry2d",no_init)
class_<geometry_type, std::shared_ptr<geometry_type>, boost::noncopyable>("Geometry2d",no_init)
.def("envelope",&geometry_type::envelope)
// .def("__str__",&geometry_type::to_string)
.def("type",&geometry_type::type)

View file

@ -151,7 +151,7 @@ boost::shared_ptr<image_32> open_from_file(std::string const& filename)
boost::optional<std::string> type = type_from_filename(filename);
if (type)
{
std::auto_ptr<image_reader> reader(get_image_reader(filename,*type));
std::unique_ptr<image_reader> reader(get_image_reader(filename,*type));
if (reader.get())
{
@ -166,7 +166,7 @@ boost::shared_ptr<image_32> open_from_file(std::string const& filename)
boost::shared_ptr<image_32> fromstring(std::string const& str)
{
std::auto_ptr<image_reader> reader(get_image_reader(str.c_str(),str.size()));
std::unique_ptr<image_reader> reader(get_image_reader(str.c_str(),str.size()));
if (reader.get())
{
boost::shared_ptr<image_32> image_ptr = boost::make_shared<image_32>(reader->width(),reader->height());
@ -182,7 +182,7 @@ boost::shared_ptr<image_32> frombuffer(PyObject * obj)
Py_ssize_t buffer_len;
if (PyObject_AsReadBuffer(obj, &buffer, &buffer_len) == 0)
{
std::auto_ptr<image_reader> reader(get_image_reader(reinterpret_cast<char const*>(buffer),buffer_len));
std::unique_ptr<image_reader> reader(get_image_reader(reinterpret_cast<char const*>(buffer),buffer_len));
if (reader.get())
{
boost::shared_ptr<image_32> image_ptr = boost::make_shared<image_32>(reader->width(),reader->height());

View file

@ -22,7 +22,7 @@
// boost
#include <boost/python.hpp>
#include <boost/foreach.hpp>
// mapnik
#include <mapnik/query.hpp>
@ -55,7 +55,7 @@ struct names_to_list
static PyObject* convert(std::set<std::string> const& names)
{
boost::python::list l;
BOOST_FOREACH( std::string const& name, names )
for ( std::string const& name : names )
{
l.append(name);
}
@ -86,6 +86,3 @@ void export_query()
return_value_policy<copy_const_reference>()) )
.def("add_property_name", &query::add_property_name);
}

View file

@ -45,13 +45,17 @@ std::string get_image_filters(feature_type_style & style)
void set_image_filters(feature_type_style & style, std::string const& filters)
{
std::vector<mapnik::filter::filter_type> new_filters;
bool result = parse_image_filters(filters, new_filters);
if (!result)
{
throw mapnik::value_error("failed to parse image-filters: '" + filters + "'");
}
style.image_filters().swap(new_filters);
#ifdef _WINDOWS
style.image_filters() = new_filters;
// FIXME : https://svn.boost.org/trac/boost/ticket/2839
#else
style.image_filters() = std::move(new_filters);
#endif
}
void export_style()

View file

@ -25,7 +25,7 @@
// boost
#include <boost/python.hpp>
#include <boost/scoped_array.hpp>
#include <boost/foreach.hpp>
// mapnik
#include <mapnik/map.hpp>
@ -245,7 +245,7 @@ void write_features(T const& grid_type,
std::set<std::string> const& attributes = grid_type.property_names();
typename T::feature_type::const_iterator feat_end = g_features.end();
BOOST_FOREACH ( std::string const& key_item, key_order )
for ( std::string const& key_item :key_order )
{
if (key_item.empty())
{
@ -261,7 +261,7 @@ void write_features(T const& grid_type,
bool found = false;
boost::python::dict feat;
mapnik::feature_ptr feature = feat_itr->second;
BOOST_FOREACH ( std::string const& attr, attributes )
for ( std::string const& attr : attributes )
{
if (attr == "__id__")
{
@ -305,7 +305,7 @@ void grid_encode_utf(T const& grid_type,
// convert key order to proper python list
boost::python::list keys_a;
BOOST_FOREACH ( typename T::lookup_type const& key_id, key_order )
for ( typename T::lookup_type const& key_id : key_order )
{
keys_a.append(key_id);
}

View file

@ -64,6 +64,7 @@ public:
box2d(coord<T,2> const& c0, coord<T,2> const& c1);
box2d(box2d_type const& rhs);
box2d(box2d_type const& rhs, agg::trans_affine const& tr);
box2d(box2d_type&& rhs);
box2d_type& operator=(box2d_type other);
T minx() const;
T miny() const;

View file

@ -210,7 +210,7 @@ public:
units_ = grad.get_units();
BOOST_FOREACH ( mapnik::stop_pair const& st, grad.get_stop_array() )
for ( mapnik::stop_pair const& st : grad.get_stop_array() )
{
mapnik::color const& stop_color = st.second;
double r= static_cast<double> (stop_color.red())/255.0;

View file

@ -31,42 +31,23 @@
#include <map>
namespace mapnik {
template <typename key_type,
typename product_type>
class default_factory_error
{
public:
struct factory_exception : public std::exception
{
const char* what() const throw()
{
return "unknown object type";
}
};
static product_type* on_unknown_type(const key_type&)
{
return 0;
}
};
template
<
typename product_type,
typename key_type,
typename product_creator=product_type* (*)(),
template <typename,typename> class factory_error_policy=default_factory_error
>
typename ...Args >
class factory : public singleton<factory <product_type,
key_type,
product_creator,factory_error_policy> >,
factory_error_policy <key_type,product_type>
Args...> >
{
private:
typedef product_type* (*product_creator)(Args...);
typedef std::map<key_type,product_creator> product_map;
product_map map_;
public:
bool register_product(const key_type& key,product_creator creator)
bool register_product(key_type const& key, product_creator creator)
{
return map_.insert(typename product_map::value_type(key,creator)).second;
}
@ -76,22 +57,12 @@ public:
return map_.erase(key)==1;
}
product_type* create_object(const key_type& key,std::string const& file)
product_type* create_object(key_type const& key, Args...args)
{
typename product_map::const_iterator pos=map_.find(key);
if (pos!=map_.end())
{
return (pos->second)(file);
}
return 0;
}
product_type* create_object(const key_type& key, char const* data, std::size_t size)
{
typename product_map::const_iterator pos=map_.find(key);
if (pos!=map_.end())
{
return (pos->second)(data, size);
return (pos->second)(args...);
}
return 0;
}

View file

@ -116,22 +116,22 @@ public:
template <typename T>
inline void put(context_type::key_type const& key, T const& val)
{
put(key,value(val));
put(key, std::move(value(val)));
}
template <typename T>
inline void put_new(context_type::key_type const& key, T const& val)
{
put_new(key,value(val));
put_new(key,std::move(value(val)));
}
inline void put(context_type::key_type const& key, value const& val)
inline void put(context_type::key_type const& key, value && val)
{
context_type::map_type::const_iterator itr = ctx_->mapping_.find(key);
if (itr != ctx_->mapping_.end()
&& itr->second < data_.size())
{
data_[itr->second] = val;
data_[itr->second] = std::move(val);
}
else
{
@ -139,19 +139,19 @@ public:
}
}
inline void put_new(context_type::key_type const& key, value const& val)
inline void put_new(context_type::key_type const& key, value && val)
{
context_type::map_type::const_iterator itr = ctx_->mapping_.find(key);
if (itr != ctx_->mapping_.end()
&& itr->second < data_.size())
{
data_[itr->second] = val;
data_[itr->second] = std::move(val);
}
else
{
cont_type::size_type index = ctx_->push(key);
if (index == data_.size())
data_.push_back(val);
data_.push_back(std::move(val));
}
}
@ -231,9 +231,8 @@ public:
// TODO - cache this
box2d<double> result;
bool first = true;
for (unsigned i=0;i<num_geometries();++i)
for (auto const& geom : geom_cont_)
{
geometry_type const& geom = get_geometry(i);
if (first)
{
box2d<double> box = geom.envelope();

View file

@ -48,7 +48,7 @@
// boost
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/foreach.hpp>
#include <boost/concept_check.hpp>
// stl
#include <vector>
@ -148,7 +148,7 @@ void feature_style_processor<Processor>::apply(double scale_denom)
scale_denom = mapnik::scale_denominator(m_.scale(),proj.is_geographic());
scale_denom *= p.scale_factor();
BOOST_FOREACH ( layer const& lyr, m_.layers() )
for (auto const& lyr : m_.layers() )
{
if (lyr.visible(scale_denom))
{
@ -292,7 +292,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
{
// check for styles needing compositing operations applied
// https://github.com/mapnik/mapnik/issues/1477
BOOST_FOREACH(std::string const& style_name, style_names)
for (std::string const& style_name : style_names)
{
boost::optional<feature_type_style const&> style=m_.find_style(style_name);
if (!style)
@ -346,10 +346,9 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
query q(layer_ext,res,scale_denom,extent);
std::vector<feature_type_style const*> active_styles;
attribute_collector collector(names);
boost::ptr_vector<rule_cache> rule_caches;
std::vector<rule_cache> rule_caches;
// iterate through all named styles collecting active styles and attribute names
BOOST_FOREACH(std::string const& style_name, style_names)
for (std::string const& style_name : style_names)
{
boost::optional<feature_type_style const&> style=m_.find_style(style_name);
if (!style)
@ -363,19 +362,19 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
std::vector<rule> const& rules = style->get_rules();
bool active_rules = false;
std::auto_ptr<rule_cache> rc(new rule_cache);
BOOST_FOREACH(rule const& r, rules)
rule_cache cache;
for (auto const& r : rules)
{
if (r.active(scale_denom))
{
rc->add_rule(r);
cache.add_rule(r);
active_rules = true;
collector(r);
}
}
if (active_rules)
{
rule_caches.push_back(rc);
rule_caches.push_back(std::move(cache));
active_styles.push_back(&(*style));
}
}
@ -386,14 +385,14 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
if (p.attribute_collection_policy() == COLLECT_ALL)
{
layer_descriptor lay_desc = ds->get_descriptor();
BOOST_FOREACH(attribute_descriptor const& desc, lay_desc.get_descriptors())
for (attribute_descriptor const& desc : lay_desc.get_descriptors())
{
q.add_property_name(desc.get_name());
}
}
else
{
BOOST_FOREACH(std::string const& name, names)
for (std::string const& name : names)
{
q.add_property_name(name);
}
@ -424,7 +423,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
// We're at a value boundary, so render what we have
// up to this point.
int i = 0;
BOOST_FOREACH (feature_type_style const* style, active_styles)
for (feature_type_style const* style : active_styles)
{
cache->prepare();
render_style(p, style, rule_caches[i], cache, prj_trans);
@ -437,7 +436,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
}
int i = 0;
BOOST_FOREACH (feature_type_style const* style, active_styles)
for (feature_type_style const* style : active_styles)
{
cache->prepare();
render_style(p, style, rule_caches[i], cache, prj_trans);
@ -458,11 +457,10 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
}
}
int i = 0;
BOOST_FOREACH (feature_type_style const* style, active_styles)
for (feature_type_style const* style : active_styles)
{
cache->prepare();
render_style(p, style, rule_caches[i], cache, prj_trans);
i++;
render_style(p, style, rule_caches[i++], cache, prj_trans);
}
cache->clear();
}
@ -470,10 +468,9 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
else
{
int i = 0;
BOOST_FOREACH (feature_type_style const* style, active_styles)
for (feature_type_style const* style : active_styles)
{
render_style(p, style, rule_caches[i], ds->features(q), prj_trans);
i++;
render_style(p, style, rule_caches[i++], ds->features(q), prj_trans);
}
}
}
@ -501,7 +498,7 @@ void feature_style_processor<Processor>::render_style(
{
bool do_else = true;
bool do_also = false;
BOOST_FOREACH(rule const* r, rc.get_if_rules() )
for (rule const* r : rc.get_if_rules() )
{
expression_ptr const& expr=r->get_filter();
value_type result = boost::apply_visitor(evaluate<feature_impl,value_type>(*feature),*expr);
@ -513,7 +510,7 @@ void feature_style_processor<Processor>::render_style(
rule::symbolizers const& symbols = r->get_symbolizers();
if(!p.process(symbols,*feature,prj_trans))
{
BOOST_FOREACH (symbolizer const& sym, symbols)
for (symbolizer const& sym : symbols)
{
boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym);
}
@ -528,13 +525,13 @@ void feature_style_processor<Processor>::render_style(
}
if (do_else)
{
BOOST_FOREACH( rule const* r, rc.get_else_rules() )
for (rule const* r : rc.get_else_rules() )
{
was_painted = true;
rule::symbolizers const& symbols = r->get_symbolizers();
if(!p.process(symbols,*feature,prj_trans))
{
BOOST_FOREACH (symbolizer const& sym, symbols)
for (symbolizer const& sym : symbols)
{
boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym);
}
@ -543,13 +540,13 @@ void feature_style_processor<Processor>::render_style(
}
if (do_also)
{
BOOST_FOREACH( rule const* r, rc.get_also_rules() )
for ( rule const* r : rc.get_also_rules() )
{
was_painted = true;
rule::symbolizers const& symbols = r->get_symbolizers();
if(!p.process(symbols,*feature,prj_trans))
{
BOOST_FOREACH (symbolizer const& sym, symbols)
for (symbolizer const& sym : symbols)
{
boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym);
}

View file

@ -42,7 +42,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/foreach.hpp>
#ifdef MAPNIK_THREADSAFE
#include <boost/thread/mutex.hpp>
#endif
@ -191,7 +191,7 @@ public:
{
std::vector<std::string> const& names = fset.get_face_names();
face_set_ptr face_set = boost::make_shared<font_face_set>();
BOOST_FOREACH( std::string const& name, names)
for ( std::string const& name : names)
{
face_ptr face = get_face(name);
if (face)

View file

@ -34,25 +34,29 @@
namespace mapnik {
enum eGeomType {
Unknown = 0,
Point = 1,
LineString = 2,
Polygon = 3
};
template <typename T, template <typename> class Container=vertex_vector>
class geometry : private mapnik::noncopyable
{
public:
static const std::uint8_t geometry_bits = 7;
enum types : std::uint8_t
{
Unknown = 0x00,
Point = 0x01,
LineString = 0x02,
Polygon = 0x03,
PolygonExterior = Polygon,
PolygonInterior = Polygon | ( 1 << geometry_bits)
};
typedef T coord_type;
typedef Container<coord_type> container_type;
typedef typename container_type::value_type value_type;
typedef typename container_type::size_type size_type;
private:
container_type cont_;
eGeomType type_;
mutable unsigned itr_;
types type_;
mutable size_type itr_;
public:
geometry()
@ -60,17 +64,22 @@ public:
itr_(0)
{}
explicit geometry(eGeomType type)
explicit geometry(types type)
: type_(type),
itr_(0)
{}
eGeomType type() const
types type() const
{
return type_;
return static_cast<types>(type_ & types::Polygon);
}
void set_type(eGeomType type)
bool interior() const
{
return static_cast<bool>(type_ >> geometry_bits);
}
void set_type(types type)
{
type_ = type;
}
@ -91,7 +100,7 @@ public:
double x = 0;
double y = 0;
rewind(0);
for (unsigned i=0; i < size(); ++i)
for (size_type i = 0; i < size(); ++i)
{
unsigned cmd = vertex(&x,&y);
if (cmd == SEG_CLOSE) continue;

View file

@ -79,11 +79,11 @@ struct raster_markers_rasterizer_dispatch_grid
marker_placement_e placement_method = sym_.get_marker_placement();
box2d<double> bbox_(0,0, src_.width(),src_.height());
if (placement_method != MARKER_LINE_PLACEMENT ||
path.type() == Point)
path.type() == geometry_type::types::Point)
{
double x = 0;
double y = 0;
if (path.type() == LineString)
if (path.type() == geometry_type::types::LineString)
{
if (!label::middle_point(path, x, y))
return;
@ -216,11 +216,11 @@ struct vector_markers_rasterizer_dispatch_grid
{
marker_placement_e placement_method = sym_.get_marker_placement();
if (placement_method != MARKER_LINE_PLACEMENT ||
path.type() == Point)
path.type() == geometry_type::types::Point)
{
double x = 0;
double y = 0;
if (path.type() == LineString)
if (path.type() == geometry_type::types::LineString)
{
if (!label::middle_point(path, x, y))
return;
@ -294,4 +294,3 @@ private:
}
#endif

View file

@ -27,7 +27,7 @@
#include <mapnik/feature.hpp>
#include <mapnik/geom_util.hpp>
// boost
#include <boost/foreach.hpp>
namespace mapnik {
class hit_test_filter
@ -40,7 +40,7 @@ public:
bool pass(feature_impl & feature)
{
BOOST_FOREACH(geometry_type & geom, feature.paths())
for (geometry_type & geom : feature.paths())
{
if (label::hit_test(geom, x_,y_,tol_))
return true;

View file

@ -32,7 +32,7 @@
#include <boost/variant/static_visitor.hpp>
#include <boost/gil/gil_all.hpp>
#include <boost/concept_check.hpp>
#include <boost/foreach.hpp>
// agg
#include "agg_basics.h"
@ -418,7 +418,7 @@ void apply_filter(Src & src, colorize_alpha const& op)
double step = 1.0/(size-1);
double offset = 0.0;
BOOST_FOREACH( mapnik::filter::color_stop const& stop, op)
for ( mapnik::filter::color_stop const& stop : op)
{
mapnik::color const& c = stop.color;
double stop_offset = stop.offset;

View file

@ -62,8 +62,11 @@ struct MAPNIK_DECL image_reader : private mapnik::noncopyable
virtual ~image_reader() {}
};
bool register_image_reader(std::string const& type,image_reader* (*)(std::string const&));
bool register_image_reader(std::string const& type,image_reader* (*)(char const*, std::size_t));
template <typename...Args>
bool register_image_reader(std::string const& type, image_reader* (* fun)(Args...))
{
return factory<image_reader,std::string, Args...>::instance().register_product(type, fun);
}
MAPNIK_DECL image_reader* get_image_reader(std::string const& file,std::string const& type);
MAPNIK_DECL image_reader* get_image_reader(std::string const& file);

View file

@ -207,17 +207,17 @@ struct geometry_generator_grammar :
coordinates = point | linestring | polygon
;
point = &uint_(mapnik::Point)[_1 = _type(_val)]
point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)]
<< point_coord [_1 = _first(_val)]
;
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)]
<< lit('[')
<< coords
<< lit(']')
;
polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)]
polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)]
<< lit('[')
<< coords2
<< lit("]]")
@ -284,12 +284,12 @@ struct multi_geometry_generator_grammar :
using boost::spirit::karma::_r1;
geometry_types.add
(mapnik::Point,"\"Point\"")
(mapnik::LineString,"\"LineString\"")
(mapnik::Polygon,"\"Polygon\"")
(mapnik::Point + 3,"\"MultiPoint\"")
(mapnik::LineString + 3,"\"MultiLineString\"")
(mapnik::Polygon + 3,"\"MultiPolygon\"")
(mapnik::geometry_type::types::Point,"\"Point\"")
(mapnik::geometry_type::types::LineString,"\"LineString\"")
(mapnik::geometry_type::types::Polygon,"\"Polygon\"")
(mapnik::geometry_type::types::Point + 3,"\"MultiPoint\"")
(mapnik::geometry_type::types::LineString + 3,"\"MultiLineString\"")
(mapnik::geometry_type::types::Polygon + 3,"\"MultiPolygon\"")
;
start %= ( eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)]

View file

@ -94,11 +94,11 @@ struct vector_markers_rasterizer_dispatch
marker_placement_e placement_method = sym_.get_marker_placement();
if (placement_method != MARKER_LINE_PLACEMENT ||
path.type() == Point)
path.type() == mapnik::geometry_type::types::Point)
{
double x = 0;
double y = 0;
if (path.type() == LineString)
if (path.type() == mapnik::geometry_type::types::LineString)
{
if (!label::middle_point(path, x, y))
return;
@ -206,11 +206,11 @@ struct raster_markers_rasterizer_dispatch
box2d<double> bbox_(0,0, src_.width(),src_.height());
if (placement_method != MARKER_LINE_PLACEMENT ||
path.type() == Point)
path.type() == mapnik::geometry_type::types::Point)
{
double x = 0;
double y = 0;
if (path.type() == LineString)
if (path.type() == mapnik::geometry_type::types::LineString)
{
if (!label::middle_point(path, x, y))
return;
@ -477,7 +477,7 @@ void apply_markers_multi(feature_impl & feature, Converter& converter, markers_s
double x, y;
if (label::centroid_geoms(feature.paths().begin(), feature.paths().end(), x, y))
{
geometry_type pt(Point);
geometry_type pt(geometry_type::types::Point);
pt.move_to(x, y);
// unset any clipping since we're now dealing with a point
converter.template unset<clip_poly_tag>();
@ -491,7 +491,7 @@ void apply_markers_multi(feature_impl & feature, Converter& converter, markers_s
// TODO: consider using true area for polygon types
double maxarea = 0;
geometry_type* largest = 0;
BOOST_FOREACH(geometry_type & geom, feature.paths())
for (geometry_type & geom : feature.paths())
{
const box2d<double>& env = geom.envelope();
double area = env.width() * env.height();
@ -512,7 +512,7 @@ void apply_markers_multi(feature_impl & feature, Converter& converter, markers_s
{
MAPNIK_LOG_WARN(marker_symbolizer) << "marker_multi_policy != 'each' has no effect with marker_placement != 'point'";
}
BOOST_FOREACH(geometry_type & path, feature.paths())
for (geometry_type & path : feature.paths())
{
converter.apply(path);
}

View file

@ -100,14 +100,14 @@ private:
// otherwise it will autodetect the orientation.
// 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.
std::auto_ptr<text_path> get_placement_offset(std::vector<vertex2d> const& path_positions,
std::unique_ptr<text_path> get_placement_offset(std::vector<vertex2d> const& path_positions,
std::vector<double> const& path_distances,
int & orientation, std::size_t index, double distance);
///Tests whether the given text_path be placed without a collision
// Returns true if it can
// NOTE: This edits p.envelopes so it can be used afterwards (you must clear it otherwise)
bool test_placement(std::auto_ptr<text_path> const& current_placement, int orientation);
bool test_placement(std::unique_ptr<text_path> const& current_placement, int orientation);
///Does a line-circle intersect calculation
// NOTE: Follow the strict pre conditions

View file

@ -31,7 +31,7 @@
#include <mapnik/geometry.hpp>
// boost
#include <boost/foreach.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
@ -189,10 +189,10 @@ private:
std::cerr << ex.what() << std::endl;
}
BOOST_FOREACH(polygon_2d const& poly, clipped_polygons)
for (polygon_2d const& poly : clipped_polygons)
{
bool move_to = true;
BOOST_FOREACH(point_2d const& c, boost::geometry::exterior_ring(poly))
for (point_2d const& c : boost::geometry::exterior_ring(poly))
{
if (move_to)
{
@ -206,10 +206,10 @@ private:
}
output_.close_path();
// interior rings
BOOST_FOREACH(polygon_2d::inner_container_type::value_type const& ring, boost::geometry::interior_rings(poly))
for (polygon_2d::inner_container_type::value_type const& ring : boost::geometry::interior_rings(poly))
{
move_to = true;
BOOST_FOREACH(point_2d const& c, ring)
for (point_2d const& c : ring)
{
if (move_to)
{

View file

@ -27,10 +27,6 @@
#include <mapnik/rule.hpp>
#include <mapnik/feature_type_style.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/foreach.hpp>
// stl
#include <vector>
@ -39,12 +35,30 @@ namespace mapnik
class rule_cache : private noncopyable
{
private:
//latest MS compiler (VC++ 2012 november CTP) doesn't support deleting functions
//rule_cache(rule_cache const& other) = delete; // no copy ctor
//rule_cache& operator=(rule_cache const& other) = delete; // no assignment op
public:
typedef std::vector<rule const*> rule_ptrs;
rule_cache()
: if_rules_(),
else_rules_(),
also_rules_() {}
: if_rules_(),
else_rules_(),
also_rules_() {}
rule_cache(rule_cache && rhs) // move ctor
: if_rules_(std::move(rhs.if_rules_)),
else_rules_(std::move(rhs.else_rules_)),
also_rules_(std::move(rhs.also_rules_))
{}
rule_cache& operator=(rule_cache && rhs) // move assign
{
std::swap(if_rules_, rhs.if_rules_);
std::swap(else_rules_,rhs.else_rules_);
std::swap(also_rules_, rhs.also_rules_);
return *this;
}
void add_rule(rule const& r)
{
@ -66,12 +80,12 @@ public:
{
return if_rules_;
}
rule_ptrs const& get_else_rules() const
{
return else_rules_;
}
rule_ptrs const& get_also_rules() const
{
return also_rules_;

View file

@ -35,7 +35,7 @@
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/foreach.hpp>
// agg
#include "agg_path_storage.h"
@ -142,7 +142,7 @@ public:
grad.get_control_points(x1,y1,x2,y2,radius);
m_gradient_lut.remove_all();
BOOST_FOREACH ( mapnik::stop_pair const& st, grad.get_stop_array() )
for ( mapnik::stop_pair const& st : grad.get_stop_array() )
{
mapnik::color const& stop_color = st.second;
unsigned r = stop_color.red();

View file

@ -41,7 +41,7 @@ struct symbolizer_hash
// specialisation for polygon_symbolizer
static std::size_t value(polygon_symbolizer const& sym)
{
std::size_t seed = Polygon;
std::size_t seed = geometry_type::types::Polygon;
boost::hash_combine(seed, sym.get_fill().rgba());
boost::hash_combine(seed, sym.get_opacity());
return seed;
@ -50,7 +50,7 @@ struct symbolizer_hash
// specialisation for line_symbolizer
static std::size_t value(line_symbolizer const& sym)
{
std::size_t seed = LineString;
std::size_t seed = geometry_type::types::LineString;
boost::hash_combine(seed, sym.get_stroke().get_color().rgba());
boost::hash_combine(seed, sym.get_stroke().get_width());
boost::hash_combine(seed, sym.get_stroke().get_opacity());

View file

@ -33,10 +33,10 @@
#include <mapnik/expression_evaluator.hpp>
// boost
#include <boost/foreach.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/range/adaptor/reversed.hpp>
// agg
#include <agg_trans_affine.h>
@ -190,7 +190,7 @@ struct transform_processor
{
attribute_collector<Container> collect(names);
BOOST_FOREACH (transform_node const& node, list)
for (transform_node const& node : list)
{
boost::apply_visitor(collect, *node);
}
@ -205,7 +205,7 @@ struct transform_processor
MAPNIK_LOG_DEBUG(transform) << "transform: begin with " << to_string(matrix_node(tr));
#endif
BOOST_REVERSE_FOREACH (transform_node const& node, list)
for (transform_node const& node : boost::adaptors::reverse(list))
{
boost::apply_visitor(eval, *node);
#ifdef MAPNIK_LOG

View file

@ -175,7 +175,7 @@ namespace mapnik { namespace util {
svg = point | linestring | polygon
;
point = &uint_(mapnik::Point)[_1 = _type(_val)]
point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)]
<< svg_point [_1 = _first(_val)]
;
@ -185,11 +185,11 @@ namespace mapnik { namespace util {
<< lit('\"')
;
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)]
<< lit("d=\"") << svg_path << lit("\"")
;
polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)]
polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)]
<< lit("d=\"") << svg_path << lit("\"")
;

View file

@ -27,14 +27,10 @@
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp>
// boost
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/foreach.hpp>
// stl
#include <vector>
#include <cstdio>
#include <memory>
namespace mapnik { namespace util {
@ -137,17 +133,17 @@ struct wkb_buffer
char * data_;
};
typedef boost::shared_ptr<wkb_buffer> wkb_buffer_ptr;
typedef std::unique_ptr<wkb_buffer> wkb_buffer_ptr;
template<typename GeometryType>
wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order)
{
assert(g.size() == 1);
std::size_t size = 1 + 4 + 8*2 ; // byteOrder + wkbType + Point
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
wkb_buffer_ptr wkb(new wkb_buffer(size));
wkb_stream ss(wkb->buffer(), wkb->size());
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::Point);
int type = static_cast<int>(mapnik::geometry_type::types::Point);
write(ss,type,4,byte_order);
double x = 0;
double y = 0;
@ -155,7 +151,7 @@ wkb_buffer_ptr to_point_wkb( GeometryType const& g, wkbByteOrder byte_order)
write(ss,x,8,byte_order);
write(ss,y,8,byte_order);
assert(ss.good());
return wkb;
return std::move(wkb);
}
template<typename GeometryType>
@ -164,10 +160,10 @@ wkb_buffer_ptr to_line_string_wkb( GeometryType const& g, wkbByteOrder byte_orde
unsigned num_points = g.size();
assert(num_points > 1);
std::size_t size = 1 + 4 + 4 + 8*2*num_points ; // byteOrder + wkbType + numPoints + Point*numPoints
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
wkb_buffer_ptr wkb(new wkb_buffer(size));
wkb_stream ss(wkb->buffer(), wkb->size());
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::LineString);
int type = static_cast<int>(mapnik::geometry_type::types::LineString);
write(ss,type,4,byte_order);
write(ss,num_points,4,byte_order);
double x = 0;
@ -179,7 +175,7 @@ wkb_buffer_ptr to_line_string_wkb( GeometryType const& g, wkbByteOrder byte_orde
write(ss,y,8,byte_order);
}
assert(ss.good());
return wkb;
return std::move(wkb);
}
template<typename GeometryType>
@ -212,18 +208,18 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
}
}
unsigned num_rings = rings.size();
wkb_buffer_ptr wkb = boost::make_shared<wkb_buffer>(size);
wkb_buffer_ptr wkb(new wkb_buffer(size));
wkb_stream ss(wkb->buffer(), wkb->size());
ss.write(reinterpret_cast<char*>(&byte_order),1);
int type = static_cast<int>(mapnik::Polygon);
int type = static_cast<int>(mapnik::geometry_type::types::Polygon);
write(ss,type,4,byte_order);
write(ss,num_rings,4,byte_order);
BOOST_FOREACH ( linear_ring const& ring, rings)
for ( linear_ring const& ring : rings)
{
unsigned num_ring_points = ring.size();
write(ss,num_ring_points,4,byte_order);
BOOST_FOREACH ( point_type const& pt, ring)
for ( point_type const& pt : ring)
{
write(ss,pt.first,8,byte_order);
write(ss,pt.second,8,byte_order);
@ -231,7 +227,7 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
}
assert(ss.good());
return wkb;
return std::move(wkb);
}
template<typename GeometryType>
@ -241,13 +237,13 @@ wkb_buffer_ptr to_wkb(GeometryType const& g, wkbByteOrder byte_order )
switch (g.type())
{
case mapnik::Point:
case mapnik::geometry_type::types::Point:
wkb = to_point_wkb(g, byte_order);
break;
case mapnik::LineString:
case mapnik::geometry_type::types::LineString:
wkb = to_line_string_wkb(g, byte_order);
break;
case mapnik::Polygon:
case mapnik::geometry_type::types::Polygon:
wkb = to_polygon_wkb(g, byte_order);
break;
default:
@ -281,21 +277,21 @@ wkb_buffer_ptr to_wkb(geometry_container const& paths, wkbByteOrder byte_order )
if (multi_type > 0 && multi_type != itr->type())
collection = true;
multi_type = type;
wkb_cont.push_back(wkb);
wkb_cont.push_back(std::move(wkb));
}
wkb_buffer_ptr multi_wkb = boost::make_shared<wkb_buffer>(multi_size);
wkb_buffer_ptr multi_wkb( new wkb_buffer(multi_size));
wkb_stream ss(multi_wkb->buffer(), multi_wkb->size());
ss.write(reinterpret_cast<char*>(&byte_order),1);
multi_type = collection ? 7 : multi_type + 3;
write(ss,multi_type, 4, byte_order);
write(ss,paths.size(),4,byte_order);
BOOST_FOREACH ( wkb_buffer_ptr const& wkb, wkb_cont)
for ( wkb_buffer_ptr const& wkb : wkb_cont)
{
ss.write(wkb->buffer(),wkb->size());
}
return multi_wkb;
return std::move(multi_wkb);
}
return wkb_buffer_ptr();

View file

@ -39,8 +39,6 @@
#include <boost/fusion/include/boost_tuple.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/math/special_functions/trunc.hpp> // trunc to avoid needing C++11
namespace boost { namespace spirit { namespace traits {
// make gcc and darwin toolsets happy.
@ -148,9 +146,8 @@ struct wkt_coordinate_policy : karma::real_policies<T>
static unsigned precision(T n)
{
if (n == 0.0) return 0;
return 6;
//using namespace boost::spirit; // for traits
//return std::max(6u, static_cast<unsigned>(15 - boost::math::trunc(log10(traits::get_absolute_value(n)))));
using namespace boost::spirit;
return static_cast<unsigned>(14 - std::trunc(std::log10(traits::get_absolute_value(n))));
}
template <typename OutputIterator>

View file

@ -47,6 +47,15 @@
#include <unicode/unistr.h>
#include <unicode/ustring.h>
namespace boost {
template <>
struct has_nothrow_copy<mapnik::value_unicode_string>
: mpl::true_
{
};
}
namespace mapnik {
@ -183,8 +192,9 @@ struct not_equals
// back compatibility shim to equate empty string with null for != test
// https://github.com/mapnik/mapnik/issues/1859
// TODO - consider removing entire specialization at Mapnik 3.x
bool operator() (value_null /*lhs*/, value_unicode_string const& rhs) const
bool operator() (value_null lhs, value_unicode_string const& rhs) const
{
boost::ignore_unused_variable_warning(lhs);
if (rhs.isEmpty()) return false;
return true;
}
@ -811,7 +821,7 @@ class value
friend const value operator%(value const&,value const&);
public:
value ()
value () noexcept //-- comment out for VC++11
: base_(value_null()) {}
value(value_integer val)
@ -840,6 +850,9 @@ public:
return *this;
}
value( value && other) noexcept
: base_(std::move(other.base_)) {}
bool operator==(value const& other) const
{
return boost::apply_visitor(impl::equals(),base_,other.base_);

View file

@ -51,6 +51,7 @@
#include <mapnik/offset_converter.hpp>
#include <mapnik/simplify_converter.hpp>
#include <mapnik/noncopyable.hpp>
#include <mapnik/polygon_clipper.hpp>
// agg
#include "agg_conv_clip_polygon.h"
@ -60,7 +61,6 @@
#include "agg_conv_stroke.h"
#include "agg_conv_dash.h"
#include "agg_conv_transform.h"
#include "agg_conv_clipper.h"
#include "agg_path_storage.h"
// stl
@ -71,7 +71,6 @@ namespace mapnik {
struct transform_tag {};
struct clip_line_tag {};
struct clip_poly_tag {};
struct clipper_tag {};
struct close_poly_tag {};
struct smooth_tag {};
struct simplify_tag {};
@ -88,7 +87,7 @@ struct converter_traits
typedef T0 geometry_type;
typedef geometry_type conv_type;
template <typename Args>
static void setup(geometry_type & /*geom*/, Args const& /*args*/)
static void setup(geometry_type & , Args const& )
{
throw std::runtime_error("invalid call to setup");
}
@ -183,32 +182,12 @@ template <typename T>
struct converter_traits<T,mapnik::clip_poly_tag>
{
typedef T geometry_type;
typedef typename agg::conv_clip_polygon<geometry_type> conv_type;
typedef mapnik::polygon_clipper<geometry_type> conv_type;
template <typename Args>
static void setup(geometry_type & geom, Args const& args)
{
typename boost::mpl::at<Args,boost::mpl::int_<0> >::type box = boost::fusion::at_c<0>(args);
geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy());
}
};
template <typename T>
struct converter_traits<T,mapnik::clipper_tag>
{
typedef T geometry_type;
typedef typename agg::conv_clipper<geometry_type,agg::path_storage> conv_type;
template <typename Args>
static void setup(geometry_type & geom, Args const& args)
{
typename boost::mpl::at<Args,boost::mpl::int_<0> >::type box = boost::fusion::at_c<0>(args);
agg::path_storage * ps = new agg::path_storage(); // FIXME: this will leak memory!
ps->move_to(box.minx(),box.miny());
ps->line_to(box.minx(),box.maxy());
ps->line_to(box.maxx(),box.maxy());
ps->line_to(box.maxx(),box.miny());
ps->close_polygon();
geom.attach2(*ps, agg::clipper_non_zero);
//geom.reverse(true);
geom.set_clip_box(box);
}
};
@ -218,7 +197,7 @@ struct converter_traits<T,mapnik::close_poly_tag>
typedef T geometry_type;
typedef typename agg::conv_close_polygon<geometry_type> conv_type;
template <typename Args>
static void setup(geometry_type & /*geom*/, Args const& /*args*/)
static void setup(geometry_type & , Args const&)
{
// no-op
}
@ -293,7 +272,7 @@ template <>
struct converter_fwd<true>
{
template <typename Base, typename T0,typename T1,typename T2, typename Iter,typename End>
static void forward(Base& base, T0 & geom,T1 const& /*args*/)
static void forward(Base& base, T0 & geom,T1 const& args)
{
base.template dispatch<Iter,End>(geom, typename boost::is_same<Iter,End>::type());
}

View file

@ -55,7 +55,7 @@ public:
// required for iterators support
typedef boost::tuple<unsigned,coord_type,coord_type> value_type;
typedef std::size_t size_type;
typedef unsigned char command_size;
typedef std::uint8_t command_size;
private:
unsigned num_blocks_;
unsigned max_blocks_;

View file

@ -113,7 +113,7 @@ namespace mapnik { namespace wkt {
;
// <point tagged text> ::= point <point text>
point_tagged_text = no_case[lit("POINT")] [ _a = new_<geometry_type>(Point) ]
point_tagged_text = no_case[lit("POINT")] [ _a = new_<geometry_type>(geometry_type::types::Point) ]
>> ( point_text(_a) [push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false])
;
@ -124,7 +124,7 @@ namespace mapnik { namespace wkt {
;
// <linestring tagged text> ::= linestring <linestring text>
linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_<geometry_type>(LineString) ]
linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_<geometry_type>(geometry_type::types::LineString) ]
>> (linestring_text(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false])
;
@ -134,7 +134,7 @@ namespace mapnik { namespace wkt {
;
// <polygon tagged text> ::= polygon <polygon text>
polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_<geometry_type>(Polygon) ]
polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_<geometry_type>(geometry_type::types::Polygon) ]
>> ( polygon_text(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false])
;
@ -150,7 +150,7 @@ namespace mapnik { namespace wkt {
// <multipoint text> ::= <empty set> | <left paren> <point text> {<comma> <point text>}* <right paren>
multipoint_text = (lit('(')
>> ((eps[_a = new_<geometry_type>(Point)]
>> ((eps[_a = new_<geometry_type>(geometry_type::types::Point)]
>> (point_text(_a) | empty_set) [push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false]) % lit(','))
>> lit(')')) | empty_set
@ -162,7 +162,7 @@ namespace mapnik { namespace wkt {
// <multilinestring text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren>
multilinestring_text = (lit('(')
>> ((eps[_a = new_<geometry_type>(LineString)]
>> ((eps[_a = new_<geometry_type>(geometry_type::types::LineString)]
>> ( points(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false]))
% lit(','))
@ -175,7 +175,7 @@ namespace mapnik { namespace wkt {
// <multipolygon text> ::= <empty set> | <left paren> <polygon text> {<comma> <polygon text>}* <right paren>
multipolygon_text = (lit('(')
>> ((eps[_a = new_<geometry_type>(Polygon)]
>> ((eps[_a = new_<geometry_type>(geometry_type::types::Polygon)]
>> ( polygon_text(_a)[push_back(_val,_a)]
| eps[cleanup_(_a)][_pass = false]))
% lit(','))

View file

@ -773,7 +773,7 @@ void csv_datasource::parse_csv(T & stream,
{
if (parsed_x && parsed_y)
{
mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point);
mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::geometry_type::types::Point);
pt->move_to(x,y);
feature->add_geometry(pt);
features_.push_back(feature);

View file

@ -523,7 +523,7 @@ feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt)
{
// construct feature
feature_ptr feature = feature_factory::create(ctx_,1);
geometry_type * point = new geometry_type(mapnik::Point);
geometry_type * point = new geometry_type(mapnik::geometry_type::types::Point);
point->move_to(pt.x, pt.y);
feature->add_geometry(point);
feature->put("value",value);

View file

@ -31,7 +31,7 @@
#include <boost/make_shared.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/spirit/include/support_multi_pass.hpp>
#include <boost/foreach.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry.hpp>
@ -140,7 +140,7 @@ geojson_datasource::geojson_datasource(parameters const& params)
bool first = true;
std::size_t count=0;
BOOST_FOREACH (mapnik::feature_ptr f, features_)
for (mapnik::feature_ptr f : features_)
{
mapnik::box2d<double> const& box = f->envelope();
if (first)

View file

@ -377,7 +377,7 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature)
}
void occi_featureset::convert_ordinates(mapnik::feature_ptr feature,
const mapnik::eGeomType& geom_type,
const mapnik::geometry::types& geom_type,
const std::vector<Number>& elem_info,
const std::vector<Number>& ordinates,
const int dimensions,
@ -404,7 +404,7 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature,
int next_interp = elem_info[i + 2];
bool is_linear_element = true;
bool is_unknown_etype = false;
mapnik::eGeomType gtype = mapnik::Point;
mapnik::geometry::types gtype = mapnik::Point;
switch (etype)
{

View file

@ -55,7 +55,7 @@ public:
private:
void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature);
void convert_ordinates (mapnik::feature_ptr feature,
const mapnik::eGeomType& geom_type,
const mapnik::geometry::types& geom_type,
const std::vector<oracle::occi::Number>& elem_info,
const std::vector<oracle::occi::Number>& ordinates,
const int dimensions,

View file

@ -79,21 +79,21 @@ void ogr_converter::convert_geometry(OGRGeometry* geom, feature_ptr feature)
void ogr_converter::convert_point(OGRPoint* geom, feature_ptr feature)
{
std::auto_ptr<geometry_type> point(new geometry_type(mapnik::Point));
std::unique_ptr<geometry_type> point(new geometry_type(mapnik::geometry_type::types::Point));
point->move_to(geom->getX(), geom->getY());
feature->paths().push_back(point);
feature->paths().push_back(point.release());
}
void ogr_converter::convert_linestring(OGRLineString* geom, feature_ptr feature)
{
int num_points = geom->getNumPoints();
std::auto_ptr<geometry_type> line(new geometry_type(mapnik::LineString));
std::unique_ptr<geometry_type> line(new geometry_type(mapnik::geometry_type::types::LineString));
line->move_to(geom->getX(0), geom->getY(0));
for (int i = 1; i < num_points; ++i)
{
line->line_to (geom->getX(i), geom->getY(i));
}
feature->paths().push_back(line);
feature->paths().push_back(line.release());
}
void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature)
@ -108,7 +108,7 @@ void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature)
capacity += interior->getNumPoints();
}
std::auto_ptr<geometry_type> poly(new geometry_type(mapnik::Polygon));
std::unique_ptr<geometry_type> poly(new geometry_type(mapnik::geometry_type::types::Polygon));
poly->move_to(exterior->getX(0), exterior->getY(0));
for (int i = 1; i < num_points; ++i)
@ -127,7 +127,7 @@ void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature)
}
poly->close_path();
}
feature->paths().push_back(poly);
feature->paths().push_back(poly.release());
}
void ogr_converter::convert_multipoint(OGRMultiPoint* geom, feature_ptr feature)

View file

@ -99,14 +99,13 @@ osm_datasource::osm_datasource(const parameters& params)
// Add the attributes to the datasource descriptor - assume they are
// all of type String
for (std::set<std::string>::iterator i = keys.begin(); i != keys.end(); i++)
for (auto const& key : keys)
{
desc_.add_descriptor(attribute_descriptor(*i, tagtypes.get_type(*i)));
desc_.add_descriptor(attribute_descriptor(key, tagtypes.get_type(key)));
}
// Get the bounds of the data and set extent_ accordingly
bounds b = osm_data_->get_bounds();
extent_ = box2d<double>(b.w, b.s, b.e, b.n);
extent_ = box2d<double>(b.w,b.s,b.e,b.n);
}
osm_datasource::~osm_datasource()

View file

@ -65,7 +65,7 @@ feature_ptr osm_featureset<filterT>::next()
feature = feature_factory::create(ctx_, cur_item->id);
double lat = static_cast<osm_node*>(cur_item)->lat;
double lon = static_cast<osm_node*>(cur_item)->lon;
geometry_type* point = new geometry_type(mapnik::Point);
geometry_type* point = new geometry_type(mapnik::geometry_type::types::Point);
point->move_to(lon, lat);
feature->add_geometry(point);
}
@ -86,11 +86,11 @@ feature_ptr osm_featureset<filterT>::next()
geometry_type* geom;
if (static_cast<osm_way*>(cur_item)->is_polygon())
{
geom = new geometry_type(mapnik::Polygon);
geom = new geometry_type(mapnik::geometry_type::types::Polygon);
}
else
{
geom = new geometry_type(mapnik::LineString);
geom = new geometry_type(mapnik::geometry_type::types::LineString);
}
geom->move_to(static_cast<osm_way*>(cur_item)->nodes[0]->lon,

View file

@ -1,4 +1,3 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)

View file

@ -7,7 +7,7 @@
#include <vector>
// boost
#include <boost/foreach.hpp>
#include <boost/make_shared.hpp>
#include <boost/python.hpp>
#include <boost/python/stl_iterator.hpp>
@ -26,7 +26,7 @@ python_datasource::python_datasource(parameters const& params)
factory_(*params.get<std::string>("factory", ""))
{
// extract any remaining parameters as keyword args for the factory
BOOST_FOREACH(const mapnik::parameters::value_type& kv, params)
for (const mapnik::parameters::value_type& kv : params)
{
if((kv.first != "type") && (kv.first != "factory"))
{
@ -73,7 +73,7 @@ python_datasource::python_datasource(parameters const& params)
// prepare the arguments
boost::python::dict kwargs;
typedef std::map<std::string, std::string>::value_type kv_type;
BOOST_FOREACH(const kv_type& kv, kwargs_)
for (kv_type const& kv : kwargs_)
{
kwargs[boost::python::str(kv.first)] = boost::python::str(kv.second);
}

View file

@ -118,7 +118,7 @@ raster_datasource::raster_datasource(parameters const& params)
try
{
std::auto_ptr<image_reader> reader(mapnik::get_image_reader(filename_, format_));
std::unique_ptr<image_reader> reader(mapnik::get_image_reader(filename_, format_));
if (reader.get())
{
width_ = reader->width();

View file

@ -71,7 +71,7 @@ feature_ptr raster_featureset<LookupPolicy>::next()
try
{
std::auto_ptr<image_reader> reader(mapnik::get_image_reader(curIter_->file(),curIter_->format()));
std::unique_ptr<image_reader> reader(mapnik::get_image_reader(curIter_->file(),curIter_->format()));
MAPNIK_LOG_DEBUG(raster) << "raster_featureset: Reader=" << curIter_->format() << "," << curIter_->file()
<< ",size(" << curIter_->width() << "," << curIter_->height() << ")";

View file

@ -89,9 +89,9 @@ feature_ptr shape_featureset<filterT>::next()
double y = record.read_double();
if (!filter_.pass(mapnik::box2d<double>(x,y,x,y)))
continue;
std::auto_ptr<geometry_type> point(new geometry_type(mapnik::Point));
std::unique_ptr<geometry_type> point(new geometry_type(mapnik::geometry_type::types::Point));
point->move_to(x, y);
feature->paths().push_back(point);
feature->paths().push_back(point.release());
break;
}
case shape_io::shape_multipoint:
@ -105,9 +105,9 @@ feature_ptr shape_featureset<filterT>::next()
{
double x = record.read_double();
double y = record.read_double();
std::auto_ptr<geometry_type> point(new geometry_type(mapnik::Point));
std::unique_ptr<geometry_type> point(new geometry_type(mapnik::geometry_type::types::Point));
point->move_to(x, y);
feature->paths().push_back(point);
feature->paths().push_back(point.release());
}
break;
}

View file

@ -101,9 +101,9 @@ feature_ptr shape_index_featureset<filterT>::next()
{
double x = record.read_double();
double y = record.read_double();
std::auto_ptr<geometry_type> point(new geometry_type(mapnik::Point));
std::unique_ptr<geometry_type> point(new geometry_type(mapnik::geometry_type::types::Point));
point->move_to(x, y);
feature->paths().push_back(point);
feature->paths().push_back(point.release());
break;
}
case shape_io::shape_multipoint:
@ -117,9 +117,9 @@ feature_ptr shape_index_featureset<filterT>::next()
{
double x = record.read_double();
double y = record.read_double();
std::auto_ptr<geometry_type> point(new geometry_type(mapnik::Point));
std::unique_ptr<geometry_type> point(new geometry_type(mapnik::geometry_type::types::Point));
point->move_to(x, y);
feature->paths().push_back(point);
feature->paths().push_back(point.release());
}
break;
}

View file

@ -96,7 +96,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry
int num_points = record.read_ndr_integer();
if (num_parts == 1)
{
std::auto_ptr<geometry_type> line(new geometry_type(mapnik::LineString));
std::unique_ptr<geometry_type> line(new geometry_type(mapnik::geometry_type::types::LineString));
record.skip(4);
double x = record.read_double();
double y = record.read_double();
@ -107,7 +107,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry
y = record.read_double();
line->line_to(x, y);
}
geom.push_back(line);
geom.push_back(line.release());
}
else
{
@ -120,7 +120,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry
int start, end;
for (int k = 0; k < num_parts; ++k)
{
std::auto_ptr<geometry_type> line(new geometry_type(mapnik::LineString));
std::unique_ptr<geometry_type> line(new geometry_type(mapnik::geometry_type::types::LineString));
start = parts[k];
if (k == num_parts - 1)
{
@ -141,7 +141,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry
y = record.read_double();
line->line_to(x, y);
}
geom.push_back(line);
geom.push_back(line.release());
}
}
}
@ -159,7 +159,7 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c
for (int k = 0; k < num_parts; ++k)
{
std::auto_ptr<geometry_type> poly(new geometry_type(mapnik::Polygon));
std::unique_ptr<geometry_type> poly(new geometry_type(mapnik::geometry_type::types::Polygon));
int start = parts[k];
int end;
if (k == num_parts - 1)
@ -181,6 +181,6 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c
poly->line_to(x, y);
}
poly->close_path();
geom.push_back(poly);
geom.push_back(poly.release());
}
}

View file

@ -264,7 +264,7 @@ void agg_renderer<T>::end_style_processing(feature_type_style const& st)
{
blend_from = true;
mapnik::filter::filter_visitor<image_32> visitor(*current_buffer_);
BOOST_FOREACH(mapnik::filter::filter_type const& filter_tag, st.image_filters())
for (mapnik::filter::filter_type const& filter_tag : st.image_filters())
{
boost::apply_visitor(visitor, filter_tag);
}
@ -281,7 +281,7 @@ void agg_renderer<T>::end_style_processing(feature_type_style const& st)
}
// apply any 'direct' image filters
mapnik::filter::filter_visitor<image_32> visitor(pixmap_);
BOOST_FOREACH(mapnik::filter::filter_type const& filter_tag, st.direct_image_filters())
for (mapnik::filter::filter_type const& filter_tag : st.direct_image_filters())
{
boost::apply_visitor(visitor, filter_tag);
}

View file

@ -91,8 +91,8 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
geometry_type const& geom = feature.get_geometry(i);
if (geom.size() > 2)
{
boost::scoped_ptr<geometry_type> frame(new geometry_type(LineString));
boost::scoped_ptr<geometry_type> roof(new geometry_type(Polygon));
boost::scoped_ptr<geometry_type> frame(new geometry_type(geometry_type::types::LineString));
boost::scoped_ptr<geometry_type> roof(new geometry_type(geometry_type::types::Polygon));
std::deque<segment_t> face_segments;
double x0 = 0;
double y0 = 0;
@ -124,7 +124,7 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
for (; itr!=end; ++itr)
{
boost::scoped_ptr<geometry_type> faces(new geometry_type(Polygon));
boost::scoped_ptr<geometry_type> faces(new geometry_type(geometry_type::types::Polygon));
faces->move_to(itr->get<0>(),itr->get<1>());
faces->line_to(itr->get<2>(),itr->get<3>());
faces->line_to(itr->get<2>(),itr->get<3>() + height);

View file

@ -50,7 +50,7 @@
#include "agg_conv_clip_polyline.h"
// boost
#include <boost/foreach.hpp>
namespace {
@ -153,7 +153,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
if (fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH(geometry_type & geom, feature.paths())
for (geometry_type & geom : feature.paths())
{
if (geom.size() > 1)
{

View file

@ -45,7 +45,7 @@
#include "agg_rasterizer_outline_aa.h"
// boost
#include <boost/foreach.hpp>
// stl
#include <string>
@ -129,7 +129,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature.paths())
for (geometry_type & geom : feature.paths())
{
if (geom.size() > 1)
{
@ -152,7 +152,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
if (stroke_.has_dash()) converter.set<dash_tag>();
converter.set<stroke_tag>(); //always stroke
BOOST_FOREACH( geometry_type & geom, feature.paths())
for (geometry_type & geom : feature.paths())
{
if (geom.size() > 1)
{

View file

@ -142,8 +142,8 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
{
eGeomType type = feature.paths()[0].type();
if (type == Polygon)
geometry_type::types type = feature.paths()[0].type();
if (type == geometry_type::types::Polygon)
converter.template set<clip_poly_tag>();
// line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426
//else if (type == LineString)
@ -182,8 +182,8 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
{
eGeomType type = feature.paths()[0].type();
if (type == Polygon)
geometry_type::types type = feature.paths()[0].type();
if (type == geometry_type::types::Polygon)
converter.template set<clip_poly_tag>();
// line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426
//else if (type == LineString)
@ -220,13 +220,13 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
{
eGeomType type = feature.paths()[0].type();
if (type == Polygon)
geometry_type::types type = feature.paths()[0].type();
if (type == geometry_type::types::Polygon)
converter.template set<clip_poly_tag>();
// line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426
//else if (type == LineString)
//else if (type == geometry_type::types::LineString)
// converter.template set<clip_line_tag>();
// don't clip if type==Point
// don't clip if type==geometry_type::types::Point
}
converter.template set<transform_tag>(); //always transform
if (sym.smooth() > 0.0) converter.template set<smooth_tag>(); // optional smooth converter

View file

@ -21,7 +21,7 @@
*****************************************************************************/
// boost
#include <boost/foreach.hpp>
// mapnik
#include <mapnik/feature.hpp>
@ -157,7 +157,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature.paths())
for ( geometry_type & geom : feature.paths())
{
if (geom.size() > 2)
{

View file

@ -21,7 +21,7 @@
*****************************************************************************/
// boost
#include <boost/foreach.hpp>
// mapnik
#include <mapnik/feature.hpp>
@ -70,7 +70,7 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature.paths())
for (geometry_type & geom : feature.paths())
{
if (geom.size() > 2)
{

View file

@ -70,6 +70,13 @@ box2d<T>::box2d(box2d_type const& rhs)
maxx_(rhs.maxx_),
maxy_(rhs.maxy_) {}
template <typename T>
box2d<T>::box2d(box2d_type && rhs)
: minx_(std::move(rhs.minx_)),
miny_(std::move(rhs.miny_)),
maxx_(std::move(rhs.maxx_)),
maxy_(std::move(rhs.maxy_)) {}
template <typename T>
box2d<T>& box2d<T>::operator=(box2d_type other)
{

View file

@ -327,7 +327,7 @@ void cairo_renderer_base::process(polygon_symbolizer const& sym,
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature.paths())
for ( geometry_type & geom : feature.paths())
{
if (geom.size() > 2)
{
@ -360,8 +360,8 @@ void cairo_renderer_base::process(building_symbolizer const& sym,
if (geom.size() > 2)
{
boost::scoped_ptr<geometry_type> frame(new geometry_type(LineString));
boost::scoped_ptr<geometry_type> roof(new geometry_type(Polygon));
boost::scoped_ptr<geometry_type> frame(new geometry_type(geometry_type::types::LineString));
boost::scoped_ptr<geometry_type> roof(new geometry_type(geometry_type::types::Polygon));
std::deque<segment_t> face_segments;
double x0 = 0;
double y0 = 0;
@ -392,7 +392,7 @@ void cairo_renderer_base::process(building_symbolizer const& sym,
std::deque<segment_t>::const_iterator end=face_segments.end();
for (; itr != end; ++itr)
{
boost::scoped_ptr<geometry_type> faces(new geometry_type(Polygon));
boost::scoped_ptr<geometry_type> faces(new geometry_type(geometry_type::types::Polygon));
faces->move_to(itr->get<0>(), itr->get<1>());
faces->line_to(itr->get<2>(), itr->get<3>());
faces->line_to(itr->get<2>(), itr->get<3>() + height);
@ -490,7 +490,7 @@ void cairo_renderer_base::process(line_symbolizer const& sym,
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature.paths())
for (geometry_type & geom : feature.paths())
{
if (geom.size() > 1)
{
@ -865,7 +865,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym,
if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature.paths())
for ( geometry_type & geom : feature.paths())
{
if (geom.size() > 2)
{
@ -987,11 +987,11 @@ struct markers_dispatch
marker_placement_e placement_method = sym_.get_marker_placement();
if (placement_method != MARKER_LINE_PLACEMENT ||
path.type() == Point)
path.type() == geometry_type::types::Point)
{
double x = 0;
double y = 0;
if (path.type() == LineString)
if (path.type() == geometry_type::types::LineString)
{
if (!label::middle_point(path, x, y))
return;
@ -1076,11 +1076,11 @@ struct markers_dispatch_2
marker_placement_e placement_method = sym_.get_marker_placement();
if (placement_method != MARKER_LINE_PLACEMENT ||
path.type() == Point)
path.type() == geometry_type::types::Point)
{
double x = 0;
double y = 0;
if (path.type() == LineString)
if (path.type() == geometry_type::types::LineString)
{
if (!label::middle_point(path, x, y))
return;
@ -1200,13 +1200,13 @@ void cairo_renderer_base::process(markers_symbolizer const& sym,
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
{
eGeomType type = feature.paths()[0].type();
if (type == Polygon)
geometry_type::types type = feature.paths()[0].type();
if (type == geometry_type::types::Polygon)
converter.set<clip_poly_tag>();
// line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426
//else if (type == LineString)
//else if (type == geometry_type::types::LineString)
// converter.template set<clip_line_tag>();
// don't clip if type==Point
// don't clip if type==geometry_type::types::Point
}
converter.set<transform_tag>(); //always transform
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
@ -1225,13 +1225,13 @@ void cairo_renderer_base::process(markers_symbolizer const& sym,
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
{
eGeomType type = feature.paths()[0].type();
if (type == Polygon)
geometry_type::types type = feature.paths()[0].type();
if (type == geometry_type::types::Polygon)
converter.set<clip_poly_tag>();
// line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426
//else if (type == LineString)
//else if (type == geometry_type::types::LineString)
// converter.template set<clip_line_tag>();
// don't clip if type==Point
// don't clip if type==geometry_type::types::Point
}
converter.set<transform_tag>(); //always transform
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
@ -1255,13 +1255,13 @@ void cairo_renderer_base::process(markers_symbolizer const& sym,
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
{
eGeomType type = feature.paths()[0].type();
if (type == Polygon)
geometry_type::types type = feature.paths()[0].type();
if (type == geometry_type::types::Polygon)
converter.set<clip_poly_tag>();
// line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426
//else if (type == LineString)
//else if (type == geometry_type::types::LineString)
// converter.template set<clip_line_tag>();
// don't clip if type==Point
// don't clip if type==geometry_type::types::Point
}
converter.set<transform_tag>(); //always transform
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter

View file

@ -44,7 +44,7 @@
// boost
#include <boost/optional.hpp>
#include <boost/foreach.hpp>
namespace mapnik { namespace util {
@ -100,12 +100,12 @@ namespace mapnik { namespace util {
// fontsets
typedef std::map<std::string,font_set> fontsets;
BOOST_FOREACH ( fontsets::value_type const& kv,map_in.fontsets())
for (fontsets::value_type const& kv : map_in.fontsets())
{
map_out.insert_fontset(kv.first,kv.second);
}
BOOST_FOREACH ( layer const& lyr_in, map_in.layers())
for ( layer const& lyr_in : map_in.layers())
{
layer lyr_out(lyr_in);
datasource_ptr ds_in = lyr_in.datasource();
@ -126,7 +126,7 @@ namespace mapnik { namespace util {
typedef style_cont::value_type value_type;
style_cont const& styles = map_in.styles();
BOOST_FOREACH ( value_type const& kv, styles )
for ( value_type const& kv : styles )
{
feature_type_style const& style_in = kv.second;
feature_type_style style_out(style_in,true); // deep copy

View file

@ -25,7 +25,7 @@
#include <mapnik/enumeration.hpp>
// boost
#include <boost/foreach.hpp>
namespace mapnik
{
@ -92,7 +92,7 @@ rules& feature_type_style::get_rules_nonconst()
bool feature_type_style::active(double scale_denom) const
{
BOOST_FOREACH(rule const& r, rules_)
for (rule const& r : rules_)
{
if (r.active(scale_denom))
{

View file

@ -292,7 +292,7 @@ font_face_set::size_type font_face_set::size() const
glyph_ptr font_face_set::get_glyph(unsigned c) const
{
BOOST_FOREACH ( face_ptr const& face, faces_)
for ( face_ptr const& face : faces_)
{
FT_UInt g = face->get_char(c);
if (g) return boost::make_shared<font_glyph>(face, g);
@ -399,7 +399,7 @@ void font_face_set::get_string_info(string_info & info, mapnik::value_unicode_st
void font_face_set::set_pixel_sizes(unsigned size)
{
BOOST_FOREACH ( face_ptr const& face, faces_)
for ( face_ptr const& face : faces_)
{
face->set_pixel_sizes(size);
}
@ -407,7 +407,7 @@ void font_face_set::set_pixel_sizes(unsigned size)
void font_face_set::set_character_sizes(double size)
{
BOOST_FOREACH ( face_ptr const& face, faces_)
for ( face_ptr const& face : faces_)
{
face->set_character_sizes(size);
}

View file

@ -55,7 +55,7 @@ std::size_t font_set::size() const
void font_set::add_face_name(std::string const& face_name)
{
face_names_.push_back(face_name);
face_names_.push_back(std::move(face_name));
}
void font_set::set_name(std::string const& name)

View file

@ -25,7 +25,7 @@
#include <mapnik/feature.hpp>
// boost
#include <boost/foreach.hpp>
#include <boost/property_tree/ptree.hpp>
namespace mapnik {
@ -36,7 +36,7 @@ namespace formatting {
void list_node::to_xml(boost::property_tree::ptree & xml) const
{
BOOST_FOREACH(node_ptr const& node, children_)
for (node_ptr const& node : children_)
{
node->to_xml(xml);
}
@ -44,17 +44,17 @@ void list_node::to_xml(boost::property_tree::ptree & xml) const
void list_node::apply(char_properties const& p, feature_impl const& feature, processed_text &output) const
{
BOOST_FOREACH(node_ptr const& node, children_)
{
for (node_ptr const& node : children_)
{
node->apply(p, feature, output);
}
}
}
void list_node::add_expressions(expression_set &output) const
{
BOOST_FOREACH(node_ptr const& node, children_)
for (node_ptr const& node : children_)
{
node->add_expressions(output);
}
@ -81,4 +81,3 @@ std::vector<node_ptr> const& list_node::get_children() const
}
} // ns mapnik
} // ns formatting

View file

@ -78,8 +78,8 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
geometry_type & geom = feature.get_geometry(i);
if (geom.size() > 2)
{
boost::scoped_ptr<geometry_type> frame(new geometry_type(LineString));
boost::scoped_ptr<geometry_type> roof(new geometry_type(Polygon));
boost::scoped_ptr<geometry_type> frame(new geometry_type(geometry_type::types::LineString));
boost::scoped_ptr<geometry_type> roof(new geometry_type(geometry_type::types::Polygon));
std::deque<segment_t> face_segments;
double x0(0);
double y0(0);
@ -106,7 +106,7 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
std::deque<segment_t>::const_iterator itr=face_segments.begin();
for (;itr!=face_segments.end();++itr)
{
boost::scoped_ptr<geometry_type> faces(new geometry_type(Polygon));
boost::scoped_ptr<geometry_type> faces(new geometry_type(geometry_type::types::Polygon));
faces->move_to(itr->get<0>(),itr->get<1>());
faces->line_to(itr->get<2>(),itr->get<3>());
faces->line_to(itr->get<2>(),itr->get<3>() + height);

View file

@ -38,7 +38,7 @@
#include "agg_conv_dash.h"
// boost
#include <boost/foreach.hpp>
// stl
#include <string>
@ -96,7 +96,7 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
if (stroke_.has_dash()) converter.set<dash_tag>();
converter.set<stroke_tag>(); //always stroke
BOOST_FOREACH( geometry_type & geom, feature.paths())
for ( geometry_type & geom : feature.paths())
{
if (geom.size() > 1)
{
@ -119,4 +119,3 @@ template void grid_renderer<grid>::process(line_symbolizer const&,
proj_transform const&);
}

View file

@ -150,8 +150,8 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
{
eGeomType type = feature.paths()[0].type();
if (type == Polygon)
geometry_type::types type = feature.paths()[0].type();
if (type == geometry_type::types::Polygon)
converter.template set<clip_poly_tag>();
// line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426
//else if (type == LineString)
@ -192,8 +192,8 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
{
eGeomType type = feature.paths()[0].type();
if (type == Polygon)
geometry_type::types type = feature.paths()[0].type();
if (type == geometry_type::types::Polygon)
converter.template set<clip_poly_tag>();
// line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426
//else if (type == LineString)
@ -237,8 +237,8 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
{
eGeomType type = feature.paths()[0].type();
if (type == Polygon)
geometry_type::types type = feature.paths()[0].type();
if (type == geometry_type::types::Polygon)
converter.template set<clip_poly_tag>();
// line clipping disabled due to https://github.com/mapnik/mapnik/issues/1426
//else if (type == LineString)

View file

@ -21,7 +21,7 @@
*****************************************************************************/
// boost
#include <boost/foreach.hpp>
// mapnik
#include <mapnik/feature.hpp>
@ -64,7 +64,7 @@ void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym,
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature.paths())
for ( geometry_type & geom : feature.paths())
{
if (geom.size() > 2)
{
@ -96,4 +96,3 @@ template void grid_renderer<grid>::process(polygon_pattern_symbolizer const&,
proj_transform const&);
}

View file

@ -21,7 +21,7 @@
*****************************************************************************/
// boost
#include <boost/foreach.hpp>
// mapnik
#include <mapnik/feature.hpp>
@ -69,7 +69,7 @@ void grid_renderer<T>::process(polygon_symbolizer const& sym,
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature.paths())
for ( geometry_type & geom : feature.paths())
{
if (geom.size() > 2)
{
@ -98,4 +98,3 @@ template void grid_renderer<grid>::process(polygon_symbolizer const&,
proj_transform const&);
}

View file

@ -28,13 +28,6 @@
namespace mapnik
{
typedef factory<image_reader,std::string,
image_reader* (*)(std::string const&)> ImageReaderFactory;
typedef factory<image_reader,std::string,
image_reader* (*)(char const*, std::size_t)> MemImageReaderFactory;
inline boost::optional<std::string> type_from_bytes(char const* data, size_t size)
{
typedef boost::optional<std::string> result_type;
@ -70,27 +63,18 @@ inline boost::optional<std::string> type_from_bytes(char const* data, size_t siz
return result_type();
}
bool register_image_reader(std::string const& type,image_reader* (* fun)(std::string const&))
{
return ImageReaderFactory::instance().register_product(type,fun);
}
bool register_image_reader(std::string const& type,image_reader* (* fun)(char const*, std::size_t))
{
return MemImageReaderFactory::instance().register_product(type,fun);
}
image_reader* get_image_reader(char const* data, size_t size)
{
boost::optional<std::string> type = type_from_bytes(data,size);
if (type)
return MemImageReaderFactory::instance().create_object(*type, data,size);
return 0;
return factory<image_reader,std::string,char const*,size_t>::instance().create_object(*type, data,size);
else
throw image_reader_exception("image_reader: can't determine type from input data");
}
image_reader* get_image_reader(std::string const& filename,std::string const& type)
{
return ImageReaderFactory::instance().create_object(type,filename);
return factory<image_reader,std::string,std::string const&>::instance().create_object(type,filename);
}
image_reader* get_image_reader(std::string const& filename)
@ -98,7 +82,7 @@ image_reader* get_image_reader(std::string const& filename)
boost::optional<std::string> type = type_from_filename(filename);
if (type)
{
return ImageReaderFactory::instance().create_object(*type,filename);
return factory<image_reader,std::string,std::string const&>::instance().create_object(*type,filename);
}
return 0;
}

View file

@ -68,7 +68,7 @@ extern "C"
#endif
// boost
#include <boost/foreach.hpp>
#include <boost/tokenizer.hpp>
// stl
@ -149,7 +149,7 @@ void handle_png_options(std::string const& type,
if (type.length() > 6){
boost::char_separator<char> sep(":");
boost::tokenizer< boost::char_separator<char> > tokens(type, sep);
BOOST_FOREACH(std::string t, tokens)
for (std::string const& t : tokens)
{
if (t == "png" || t == "png24" || t == "png32")
{
@ -258,7 +258,7 @@ void handle_webp_options(std::string const& type,
if (type.length() > 4){
boost::char_separator<char> sep(":");
boost::tokenizer< boost::char_separator<char> > tokens(type, sep);
BOOST_FOREACH(std::string t, tokens)
for (auto const& t : tokens)
{
if (boost::algorithm::starts_with(t, "quality="))
{

View file

@ -105,16 +105,16 @@ geometry_grammar<Iterator>::geometry_grammar()
| (eps(_r2 == 6) > multipolygon_coordinates(_r1))
;
point_coordinates = eps[ _a = new_<geometry_type>(Point) ]
point_coordinates = eps[ _a = new_<geometry_type>(geometry_type::types::Point) ]
> ( point(SEG_MOVETO,_a) [push_back(_r1,_a)] | eps[cleanup_(_a)][_pass = false] )
;
linestring_coordinates = eps[ _a = new_<geometry_type>(LineString)]
linestring_coordinates = eps[ _a = new_<geometry_type>(geometry_type::types::LineString)]
> -(points(_a) [push_back(_r1,_a)]
| eps[cleanup_(_a)][_pass = false])
;
polygon_coordinates = eps[ _a = new_<geometry_type>(Polygon) ]
polygon_coordinates = eps[ _a = new_<geometry_type>(geometry_type::types::Polygon) ]
> ((lit('[')
> -(points(_a)[close_path_(_a)] % lit(','))
> lit(']')) [push_back(_r1,_a)]

View file

@ -191,7 +191,7 @@ boost::optional<marker_ptr> marker_cache::find(std::string const& uri,
else
{
// TODO - support reading images from string
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(uri));
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(uri));
if (reader.get())
{
unsigned width = reader->width();

View file

@ -30,7 +30,7 @@
// boost
#include <boost/variant.hpp>
#include <boost/foreach.hpp>
#include <boost/make_shared.hpp>
// stl
@ -48,8 +48,8 @@ path_expression_ptr parse_path(std::string const& str)
path_expression_ptr parse_path(std::string const& str,
path_expression_grammar<std::string::const_iterator> const& g)
{
path_expression path;
path_expression path;
std::string::const_iterator itr = str.begin();
std::string::const_iterator end = str.end();
bool r = qi::phrase_parse(itr, end, g, boost::spirit::standard_wide::space, path);
@ -129,7 +129,7 @@ std::string path_processor::evaluate(path_expression const& path,feature_impl co
{
std::string out;
path_processor_detail::path_visitor_ eval(out,f);
BOOST_FOREACH( mapnik::path_component const& token, path)
for ( mapnik::path_component const& token : path)
boost::apply_visitor(eval,token);
return out;
}
@ -138,7 +138,7 @@ std::string path_processor::to_string(path_expression const& path)
{
std::string str;
path_processor_detail::to_string_ visitor(str);
BOOST_FOREACH( mapnik::path_component const& token, path)
for ( mapnik::path_component const& token : path)
boost::apply_visitor(visitor,token);
return str;
}
@ -146,7 +146,7 @@ std::string path_processor::to_string(path_expression const& path)
void path_processor::collect_attributes(path_expression const& path, std::set<std::string>& names)
{
path_processor_detail::collect_ visitor(names);
BOOST_FOREACH( mapnik::path_component const& token, path)
for ( mapnik::path_component const& token : path)
boost::apply_visitor(visitor,token);
}

View file

@ -36,7 +36,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/foreach.hpp>
//stl
#include <string>
@ -285,7 +285,7 @@ void placement_finder<DetectorT>::find_line_breaks()
//No linebreaks
line_sizes_.push_back(std::make_pair(string_width_, string_height_));
}
line_breaks_.push_back(info_.num_characters());
line_breaks_.push_back(static_cast<unsigned>(info_.num_characters()));
}
template <typename DetectorT>
@ -386,7 +386,7 @@ void placement_finder<DetectorT>::find_point_placement(double label_x,
double sina = std::sin(rad);
double x, y;
std::auto_ptr<text_path> current_placement(new text_path(label_x, label_y));
std::unique_ptr<text_path> current_placement(new text_path(label_x, label_y));
adjust_position(current_placement.get());
@ -500,7 +500,7 @@ void placement_finder<DetectorT>::find_point_placement(double label_x,
// check the placement of any additional envelopes
if (!p.allow_overlap && !additional_boxes_.empty())
{
BOOST_FOREACH(box2d<double> const& box, additional_boxes_)
for (box2d<double> const& box : additional_boxes_)
{
box2d<double> pt(box.minx() + current_placement->center.x,
box.miny() + current_placement->center.y,
@ -639,10 +639,10 @@ void placement_finder<DetectorT>::find_line_placements(PathT & shape_path)
{
//Record details for the start of the string placement
int orientation = 0;
std::auto_ptr<text_path> current_placement = get_placement_offset(path_positions, path_distances, orientation, index, segment_length - (distance - target_distance) + (diff*dir));
std::unique_ptr<text_path> current_placement = get_placement_offset(path_positions, path_distances, orientation, index, segment_length - (distance - target_distance) + (diff*dir));
//We were unable to place here
if (current_placement.get() == NULL)
if (current_placement.get() == nullptr)
continue;
//Apply displacement
@ -709,7 +709,7 @@ void placement_finder<DetectorT>::find_line_placements(PathT & shape_path)
}
template <typename DetectorT>
std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::vector<vertex2d> const& path_positions,
std::unique_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::vector<vertex2d> const& path_positions,
std::vector<double> const& path_distances,
int & orientation,
std::size_t index,
@ -722,7 +722,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
distance += path_distances[index];
}
if (index <= 1 && distance < 0) //We've gone off the start, fail out
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
//Same thing, checking if we go off the end
while (index < path_distances.size() && distance > path_distances[index])
@ -731,7 +731,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
index++;
}
if (index >= path_distances.size())
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
//Keep track of the initial index,distance incase we need to re-call get_placement_offset
const std::size_t initial_index = index;
@ -749,10 +749,10 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
double segment_length = path_distances[index];
if (segment_length == 0) {
// Not allowed to place across on 0 length segments or discontinuities
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
}
std::auto_ptr<text_path> current_placement(
std::unique_ptr<text_path> current_placement(
new text_path((old_x + dx*distance/segment_length),
(old_y + dy*distance/segment_length)
)
@ -777,7 +777,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
//Coordinates this character will start at
if (segment_length == 0) {
// Not allowed to place across on 0 length segments or discontinuities
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
}
double start_x = old_x + dx*distance/segment_length;
double start_y = old_y + dy*distance/segment_length;
@ -805,7 +805,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
if (index >= path_positions.size()) //Bail out if we run off the end of the shape
{
//MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Out of space";
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
}
new_x = path_positions[index].x;
new_y = path_positions[index].y;
@ -842,7 +842,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
std::fabs(angle_delta) > p.max_char_angle_delta)
{
//MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Too Bendy!";
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
}
double render_angle = angle;
@ -896,15 +896,15 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
{
//Otherwise we have failed to find a placement
//MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Double upside-down!";
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
}
}
return current_placement;
return std::move(current_placement);
}
template <typename DetectorT>
bool placement_finder<DetectorT>::test_placement(std::auto_ptr<text_path> const& current_placement,
bool placement_finder<DetectorT>::test_placement(std::unique_ptr<text_path> const& current_placement,
int orientation)
{
//Create and test envelopes

View file

@ -59,7 +59,7 @@ bool svg_renderer<OutputIterator>::process(rule::symbolizers const& syms,
// process each symbolizer to collect its (path) information.
// path information (attributes from line_ and polygon_ symbolizers)
// is collected with the path_attributes_ data member.
BOOST_FOREACH(symbolizer const& sym, syms)
for (symbolizer const& sym : syms)
{
if (is_path_based(sym))
{

View file

@ -35,8 +35,6 @@
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/fusion/include/std_pair.hpp>
#include <boost/foreach.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <string>
@ -434,7 +432,7 @@ void parse_attr(svg_parser & parser, xmlTextReaderPtr reader)
typedef cont_type::value_type value_type;
cont_type vec;
parse_style((const char*)value, vec);
BOOST_FOREACH(value_type kv , vec )
for (value_type kv : vec )
{
parse_attr(parser,BAD_CAST kv.first.c_str(),BAD_CAST kv.second.c_str());
}
@ -796,7 +794,7 @@ void parse_gradient_stop(svg_parser & parser, xmlTextReaderPtr reader)
cont_type vec;
parse_style((const char*)value, vec);
BOOST_FOREACH(value_type kv , vec )
for (value_type kv : vec )
{
if (kv.first == "stop-color")
{

View file

@ -219,8 +219,8 @@ void text_symbolizer_helper<FaceManagerT, DetectorT>::initialize_geometries()
// don't bother with empty geometries
if (geom.size() == 0) continue;
eGeomType type = geom.type();
if (type == Polygon)
geometry_type::types type = geom.type();
if (type == geometry_type::types::Polygon)
{
largest_box_only = sym_.largest_bbox_only();
if (sym_.get_minimum_path_length() > 0)
@ -284,7 +284,7 @@ void text_symbolizer_helper<FaceManagerT, DetectorT>::initialize_points()
// https://github.com/mapnik/mapnik/issues/1423
bool success = false;
// https://github.com/mapnik/mapnik/issues/1350
if (geom.type() == LineString)
if (geom.type() == geometry_type::types::LineString)
{
success = label::middle_point(geom, label_x,label_y);
}

View file

@ -25,7 +25,7 @@
#include <mapnik/transform_expression.hpp>
// boost
#include <boost/foreach.hpp>
// stl
#include <sstream>
@ -132,7 +132,7 @@ std::string to_expression_string(transform_list const& list)
std::streamsize first = 1;
transform_node_to_expression_string to_string(os);
BOOST_FOREACH (transform_node const& node, list)
for (transform_node const& node : list)
{
os.write(" ", first ? (first = 0) : 1);
boost::apply_visitor(to_string, *node);

View file

@ -102,7 +102,8 @@ private:
}
WebPDecoderConfig & config_;
};
std::auto_ptr<buffer_policy_type> buffer_;
std::unique_ptr<buffer_policy_type> buffer_;
size_t size_;
unsigned width_;
unsigned height_;
@ -148,7 +149,7 @@ webp_reader<T>::webp_reader(char const* data, std::size_t size)
template <typename T>
webp_reader<T>::webp_reader(std::string const& filename)
: buffer_(),
: buffer_(nullptr),
size_(0),
width_(0),
height_(0)
@ -163,12 +164,15 @@ webp_reader<T>::webp_reader(std::string const& filename)
std::streampos end = file.tellg();
std::size_t file_size = end - beg;
file.seekg (0, std::ios::beg);
buffer_ = std::auto_ptr<buffer_policy_type>(new buffer_policy_type(file_size));
file.read(reinterpret_cast<char*>(buffer_->data()), buffer_->size());
std::unique_ptr<buffer_policy_type> buffer(new buffer_policy_type(file_size));
file.read(reinterpret_cast<char*>(buffer->data()), buffer->size());
if (!file)
{
throw image_reader_exception("WEBP: Failed to read:" + filename);
}
buffer_ = std::move(buffer);
init();
}

View file

@ -250,9 +250,9 @@ private:
{
double x = read_double();
double y = read_double();
std::auto_ptr<geometry_type> pt(new geometry_type(Point));
std::unique_ptr<geometry_type> pt(new geometry_type(geometry_type::types::Point));
pt->move_to(x, y);
paths.push_back(pt);
paths.push_back(pt.release());
}
void read_multipoint(boost::ptr_vector<geometry_type> & paths)
@ -269,10 +269,10 @@ private:
{
double x = read_double();
double y = read_double();
std::auto_ptr<geometry_type> pt(new geometry_type(Point));
std::unique_ptr<geometry_type> pt(new geometry_type(geometry_type::types::Point));
pos_ += 8; // double z = read_double();
pt->move_to(x, y);
paths.push_back(pt);
paths.push_back(pt.release());
}
void read_multipoint_xyz(boost::ptr_vector<geometry_type> & paths)
@ -292,13 +292,13 @@ private:
{
CoordinateArray ar(num_points);
read_coords(ar);
std::auto_ptr<geometry_type> line(new geometry_type(LineString));
std::unique_ptr<geometry_type> line(new geometry_type(geometry_type::types::LineString));
line->move_to(ar[0].x, ar[0].y);
for (int i = 1; i < num_points; ++i)
{
line->line_to(ar[i].x, ar[i].y);
}
paths.push_back(line);
paths.push_back(line.release());
}
}
@ -319,13 +319,13 @@ private:
{
CoordinateArray ar(num_points);
read_coords_xyz(ar);
std::auto_ptr<geometry_type> line(new geometry_type(LineString));
std::unique_ptr<geometry_type> line(new geometry_type(geometry_type::types::LineString));
line->move_to(ar[0].x, ar[0].y);
for (int i = 1; i < num_points; ++i)
{
line->line_to(ar[i].x, ar[i].y);
}
paths.push_back(line);
paths.push_back(line.release());
}
}
@ -345,7 +345,7 @@ private:
int num_rings = read_integer();
if (num_rings > 0)
{
std::auto_ptr<geometry_type> poly(new geometry_type(Polygon));
std::unique_ptr<geometry_type> poly(new geometry_type(geometry_type::types::Polygon));
for (int i = 0; i < num_rings; ++i)
{
int num_points = read_integer();
@ -362,7 +362,7 @@ private:
}
}
if (poly->size() > 3) // ignore if polygon has less than (3 + close_path) vertices
paths.push_back(poly);
paths.push_back(poly.release());
}
}
@ -381,7 +381,7 @@ private:
int num_rings = read_integer();
if (num_rings > 0)
{
std::auto_ptr<geometry_type> poly(new geometry_type(Polygon));
std::unique_ptr<geometry_type> poly(new geometry_type(geometry_type::types::Polygon));
for (int i = 0; i < num_rings; ++i)
{
int num_points = read_integer();
@ -398,7 +398,7 @@ private:
}
}
if (poly->size() > 2) // ignore if polygon has less than 3 vertices
paths.push_back(poly);
paths.push_back(poly.release());
}
}

View file

@ -72,20 +72,20 @@ wkt_generator<OutputIterator, Geometry>::wkt_generator(bool single)
wkt = point | linestring | polygon
;
point = &uint_(mapnik::Point)[_1 = _type(_val)]
point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)]
<< string[ phoenix::if_ (single) [_1 = "Point("]
.else_[_1 = "("]]
<< point_coord [_1 = _first(_val)] << lit(')')
;
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)]
<< string[ phoenix::if_ (single) [_1 = "LineString("]
.else_[_1 = "("]]
<< coords
<< lit(')')
;
polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)]
polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)]
<< string[ phoenix::if_ (single) [_1 = "Polygon("]
.else_[_1 = "("]]
<< coords2
@ -126,9 +126,9 @@ wkt_multi_generator<OutputIterator, GeometryContainer>::wkt_multi_generator()
using boost::spirit::karma::_a;
geometry_types.add
(mapnik::Point,"Point")
(mapnik::LineString,"LineString")
(mapnik::Polygon,"Polygon")
(mapnik::geometry_type::types::Point,"Point")
(mapnik::geometry_type::types::LineString,"LineString")
(mapnik::geometry_type::types::Polygon,"Polygon")
;
wkt = eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)]

View file

@ -6,7 +6,7 @@
// boost
#include <boost/detail/lightweight_test.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
// stl
#include <stdexcept>
@ -54,7 +54,7 @@ void parse_geom(mapnik::geometry_type & geom,
std::string const& geom_string) {
std::vector<std::string> vertices;
boost::split(vertices, geom_string, boost::is_any_of(","));
BOOST_FOREACH(std::string const& vert, vertices)
for (std::string const& vert : vertices)
{
std::vector<std::string> commands;
boost::split(commands, vert, boost::is_any_of(" "));

View file

@ -43,7 +43,7 @@ int main(int argc, char** argv)
mapnik::transcoder tr("utf-8");
mapnik::value_unicode_string ustr = tr.transcode("hello world!");
feature->put("name",ustr);
mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point);
mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::geometry_type::types::Point);
pt->move_to(128,128);
feature->add_geometry(pt);
boost::shared_ptr<mapnik::memory_datasource> ds = boost::make_shared<mapnik::memory_datasource>();

View file

@ -23,7 +23,7 @@
struct output_geometry_backend
{
output_geometry_backend(boost::ptr_vector<mapnik::geometry_type> & paths, mapnik::eGeomType type)
output_geometry_backend(boost::ptr_vector<mapnik::geometry_type> & paths, mapnik::geometry_type::types type)
: paths_(paths),
type_(type) {}
@ -32,17 +32,17 @@ struct output_geometry_backend
{
mapnik::vertex2d vtx(mapnik::vertex2d::no_init);
path.rewind(0);
std::auto_ptr<mapnik::geometry_type> geom_ptr(new mapnik::geometry_type(type_));
std::unique_ptr<mapnik::geometry_type> geom_ptr(new mapnik::geometry_type(type_));
while ((vtx.cmd = path.vertex(&vtx.x, &vtx.y)) != mapnik::SEG_END)
{
//std::cerr << vtx.x << "," << vtx.y << " cmd=" << vtx.cmd << std::endl;
geom_ptr->push_vertex(vtx.x, vtx.y, (mapnik::CommandType)vtx.cmd);
}
paths_.push_back(geom_ptr);
paths_.push_back(geom_ptr.release());
}
boost::ptr_vector<mapnik::geometry_type> & paths_;
mapnik::eGeomType type_;
mapnik::geometry_type::types type_;
};
boost::optional<std::string> linestring_bbox_clipping(mapnik::box2d<double> bbox,
@ -56,7 +56,7 @@ boost::optional<std::string> linestring_bbox_clipping(mapnik::box2d<double> bbox
line_symbolizer sym;
CoordTransform t(bbox.width(),bbox.height(), bbox);
boost::ptr_vector<mapnik::geometry_type> output_paths;
output_geometry_backend backend(output_paths, mapnik::LineString);
output_geometry_backend backend(output_paths, mapnik::geometry_type::types::LineString);
typedef boost::mpl::vector<clip_line_tag> conv_types;
vertex_converter<box2d<double>, output_geometry_backend, line_symbolizer,
@ -71,7 +71,7 @@ boost::optional<std::string> linestring_bbox_clipping(mapnik::box2d<double> bbox
throw std::runtime_error("Failed to parse WKT");
}
BOOST_FOREACH( geometry_type & geom, p)
for (geometry_type & geom : p)
{
converter.apply(geom);
}
@ -96,7 +96,7 @@ boost::optional<std::string> polygon_bbox_clipping(mapnik::box2d<double> bbox,
polygon_symbolizer sym;
CoordTransform t(bbox.width(),bbox.height(), bbox);
boost::ptr_vector<mapnik::geometry_type> output_paths;
output_geometry_backend backend(output_paths, mapnik::Polygon);
output_geometry_backend backend(output_paths, mapnik::geometry_type::types::Polygon);
typedef boost::mpl::vector<clip_poly_tag> conv_types;
vertex_converter<box2d<double>, output_geometry_backend, polygon_symbolizer,
@ -111,7 +111,7 @@ boost::optional<std::string> polygon_bbox_clipping(mapnik::box2d<double> bbox,
throw std::runtime_error("Failed to parse WKT");
}
BOOST_FOREACH( geometry_type & geom, p)
for (geometry_type & geom : p)
{
converter.apply(geom);
}

View file

@ -25,7 +25,6 @@ int main(int argc, char** argv)
{
BOOST_TEST(set_working_dir(args));
#if defined(HAVE_JPEG)
should_throw = "./tests/cpp_tests/data/blank.jpg";
BOOST_TEST( mapnik::util::exists( should_throw ) );
@ -33,8 +32,8 @@ int main(int argc, char** argv)
BOOST_TEST( type );
try
{
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
if (reader.get()) BOOST_TEST( false );
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
BOOST_TEST( false );
}
catch (std::exception const&)
{
@ -49,21 +48,22 @@ int main(int argc, char** argv)
BOOST_TEST( type );
try
{
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
if (reader.get()) BOOST_TEST( false );
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
BOOST_TEST( false );
}
catch (std::exception const&)
{
BOOST_TEST( true );
}
should_throw = "./tests/data/images/xcode-CgBI.png";
BOOST_TEST( mapnik::util::exists( should_throw ) );
type = mapnik::type_from_filename(should_throw);
BOOST_TEST( type );
try
{
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
if (reader.get()) BOOST_TEST( false );
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
BOOST_TEST( false );
}
catch (std::exception const&)
{
@ -78,8 +78,8 @@ int main(int argc, char** argv)
BOOST_TEST( type );
try
{
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
if (reader.get()) BOOST_TEST( false );
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
BOOST_TEST( false );
}
catch (std::exception const&)
{
@ -94,7 +94,7 @@ int main(int argc, char** argv)
BOOST_TEST( type );
try
{
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
BOOST_TEST( false );
}
catch (std::exception const&)

View file

@ -19,7 +19,7 @@ int main(int argc, char** argv)
double x,y;
// single point
mapnik::geometry_type pt(mapnik::Point);
mapnik::geometry_type pt(mapnik::geometry_type::types::Point);
pt.move_to(10,10);
BOOST_TEST( mapnik::label::centroid(pt, x, y) );
BOOST_TEST( x == 10 );
@ -32,7 +32,7 @@ int main(int argc, char** argv)
BOOST_TEST_EQ( y, 15 );
// line with two verticies
mapnik::geometry_type line(mapnik::LineString);
mapnik::geometry_type line(mapnik::geometry_type::types::LineString);
line.move_to(0,0);
line.move_to(50,50);
BOOST_TEST( mapnik::label::centroid(line, x, y) );

View file

@ -17,16 +17,16 @@
#include <mapnik/image_reader.hpp>
#include <mapnik/scale_denominator.hpp>
#include <mapnik/feature_style_processor.hpp>
#include <boost/foreach.hpp>
#include <vector>
#include <algorithm>
#include "utils.hpp"
bool compare_images(std::string const& src_fn,std::string const& dest_fn)
{
using namespace mapnik;
std::auto_ptr<mapnik::image_reader> reader1(mapnik::get_image_reader(dest_fn,"png"));
std::unique_ptr<mapnik::image_reader> reader1(mapnik::get_image_reader(dest_fn,"png"));
if (!reader1.get())
{
throw mapnik::image_reader_exception("Failed to load: " + dest_fn);
@ -34,7 +34,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn)
boost::shared_ptr<image_32> image_ptr1 = boost::make_shared<image_32>(reader1->width(),reader1->height());
reader1->read(0,0,image_ptr1->data());
std::auto_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(src_fn,"png"));
std::unique_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(src_fn,"png"));
if (!reader2.get())
{
throw mapnik::image_reader_exception("Failed to load: " + src_fn);
@ -116,7 +116,7 @@ int main(int argc, char** argv)
mapnik::projection map_proj(m.srs(),true);
double scale_denom = mapnik::scale_denominator(req.scale(),map_proj.is_geographic());
scale_denom *= scale_factor;
BOOST_FOREACH ( mapnik::layer const& lyr, m.layers() )
for (mapnik::layer const& lyr : m.layers() )
{
if (lyr.visible(scale_denom))
{

View file

@ -29,7 +29,7 @@
#include <mapnik/datasource_cache.hpp>
#include <mapnik/util/geometry_to_wkb.hpp>
#include <boost/foreach.hpp>
int main (int argc, char ** argv )
@ -70,7 +70,7 @@ int main (int argc, char ** argv )
mapnik::query q(ds->envelope());
mapnik::layer_descriptor layer_desc = ds->get_descriptor();
BOOST_FOREACH ( mapnik::attribute_descriptor const& attr_desc, layer_desc.get_descriptors())
for (mapnik::attribute_descriptor const& attr_desc : layer_desc.get_descriptors())
{
q.add_property_name(attr_desc.get_name());
}
@ -82,7 +82,7 @@ int main (int argc, char ** argv )
{
std::cerr << *f << std::endl;
boost::ptr_vector<mapnik::geometry_type> & paths = f->paths();
BOOST_FOREACH ( mapnik::geometry_type const& geom, paths)
for (mapnik::geometry_type const& geom : paths)
{
// NDR
{