use std::optional instead of boost::optional

This commit is contained in:
Mathis Logemann 2024-04-19 20:45:24 +02:00
parent e1feef5a79
commit 7ef431ece2
123 changed files with 774 additions and 978 deletions

View file

@ -15,8 +15,6 @@
#include <cstdio> // snprintf
#include <iomanip>
#include <iostream>
#include <set>
#include <sstream>
#include <thread>
#include <mutex>
#include <vector>

View file

@ -9,7 +9,7 @@ class test : public benchmark::test_case
: test_case(params)
, line_data_("this is one line\nand this is a second line\nand a third line")
{
boost::optional<std::string> line_data = params.get<std::string>("line");
auto line_data = params.get<std::string>("line");
if (line_data)
{
line_data_ = *line_data;
@ -57,7 +57,7 @@ class test2 : public benchmark::test_case
: test_case(params)
, line_data_("this is one line\nand this is a second line\nand a third line")
{
boost::optional<std::string> line_data = params.get<std::string>("line");
auto line_data = params.get<std::string>("line");
if (line_data)
{
line_data_ = *line_data;

View file

@ -26,14 +26,14 @@ class test : public benchmark::test_case
, scale_factor_(*params.get<mapnik::value_double>("scale_factor", 1.0))
, preview_(*params.get<std::string>("preview", ""))
{
boost::optional<std::string> map = params.get<std::string>("map");
const auto map = params.get<std::string>("map");
if (!map)
{
throw std::runtime_error("please provide a --map <path to xml> arg");
}
xml_ = *map;
boost::optional<std::string> ext = params.get<std::string>("extent");
const auto ext = params.get<std::string>("extent");
if (ext && !ext->empty())
{
if (!extent_.from_string(*ext))
@ -101,7 +101,7 @@ int main(int argc, char** argv)
{
mapnik::parameters params;
benchmark::handle_args(argc, argv, params);
boost::optional<std::string> name = params.get<std::string>("name");
const auto name = params.get<std::string>("name");
if (!name)
{
std::clog << "please provide a name for this test\n";

View file

@ -64,14 +64,14 @@ class test : public benchmark::test_case
, preview_(*params.get<std::string>("preview", ""))
, im_(m_->width(), m_->height())
{
boost::optional<std::string> map = params.get<std::string>("map");
const auto map = params.get<std::string>("map");
if (!map)
{
throw std::runtime_error("please provide a --map=<path to xml> arg");
}
xml_ = *map;
boost::optional<std::string> ext = params.get<std::string>("extent");
auto ext = params.get<std::string>("extent");
mapnik::load_map(*m_, xml_, true);
if (ext && !ext->empty())
{
@ -156,7 +156,7 @@ int main(int argc, char** argv)
{
mapnik::parameters params;
benchmark::handle_args(argc, argv, params);
boost::optional<std::string> name = params.get<std::string>("name");
const auto name = params.get<std::string>("name");
if (!name)
{
std::clog << "please provide a name for this test\n";

View file

@ -175,14 +175,14 @@ struct symbolizer_attributes
void operator()(raster_symbolizer const& sym)
{
boost::optional<double> filter_factor = get_optional<double>(sym, keys::filter_factor);
const auto filter_factor = get_optional<double>(sym, keys::filter_factor);
if (filter_factor)
{
filter_factor_ = *filter_factor;
}
else
{
boost::optional<scaling_method_e> scaling_method = get_optional<scaling_method_e>(sym, keys::scaling);
const auto scaling_method = get_optional<scaling_method_e>(sym, keys::scaling);
if (scaling_method && *scaling_method != SCALING_NEAR)
{
filter_factor_ = 2;

View file

@ -38,6 +38,7 @@
#include <map>
#include <string>
#include <memory>
#include <optional>
namespace mapnik {
@ -91,7 +92,7 @@ class MAPNIK_DECL datasource : private util::noncopyable
// default implementation without context use features method
return features(q);
}
virtual boost::optional<datasource_geometry_t> get_geometry_type() const = 0;
virtual std::optional<datasource_geometry_t> get_geometry_type() const = 0;
virtual featureset_ptr features(query const& q) const = 0;
virtual featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const = 0;
virtual box2d<double> envelope() const = 0;

View file

@ -131,11 +131,11 @@ struct evaluate_expression
};
template<typename T>
struct evaluate_expression<T, boost::none_t>
struct evaluate_expression<T, std::nullopt_t>
{
using value_type = T;
evaluate_expression(boost::none_t) {}
evaluate_expression(std::nullopt_t) {}
value_type operator()(attribute const&) const
{
@ -265,7 +265,7 @@ std::tuple<T, bool> pre_evaluate_expression(expression_ptr const& expr)
{
try
{
return std::make_tuple(util::apply_visitor(mapnik::evaluate_expression<T, boost::none_t>(boost::none), *expr),
return std::make_tuple(util::apply_visitor(mapnik::evaluate_expression<T, std::nullopt_t>(std::nullopt), *expr),
true);
}
catch (...)

View file

@ -29,7 +29,6 @@
MAPNIK_DISABLE_WARNING_PUSH
MAPNIK_DISABLE_UNUSED_VARIABLE
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
#include <boost/msm/back/state_machine.hpp>
#include <boost/msm/front/state_machine_def.hpp>
#include <boost/msm/front/functor_row.hpp>
@ -37,6 +36,7 @@ MAPNIK_DISABLE_WARNING_POP
// stl
#include <cmath>
#include <optional>
namespace mapnik {
@ -91,7 +91,7 @@ struct store
{
m.v2 = m.v1;
m.v1 = e.vertex;
m.output = boost::none;
m.output = std::nullopt;
}
};
@ -177,7 +177,7 @@ struct extender_def : public msm::front::state_machine_def<extender_def>
: extend_length(extend_length)
{}
boost::optional<vertex2d> output;
std::optional<vertex2d> output;
vertex2d v1, v2;
double extend_length;
};

View file

@ -248,7 +248,7 @@ void feature_style_processor<Processor>::prepare_layer(layer_rendering_material&
box2d<double> buffered_query_ext(query_ext); // buffered
double buffer_padding = 2.0 * scale * p.scale_factor();
boost::optional<int> layer_buffer_size = lay.buffer_size();
const auto layer_buffer_size = lay.buffer_size();
if (layer_buffer_size) // if layer overrides buffer size, use this value to compute buffered extent
{
buffer_padding *= *layer_buffer_size;
@ -261,7 +261,7 @@ void feature_style_processor<Processor>::prepare_layer(layer_rendering_material&
buffered_query_ext.height(query_ext.height() + buffer_padding);
// clip buffered extent by maximum extent, if supplied
boost::optional<box2d<double>> const& maximum_extent = m_.maximum_extent();
auto&& maximum_extent = m_.maximum_extent();
if (maximum_extent)
{
buffered_query_ext.clip(*maximum_extent);

View file

@ -29,15 +29,11 @@
#include <mapnik/image_filter_types.hpp>
#include <mapnik/image_compositing.hpp>
#include <mapnik/rule.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
// stl
#include <vector>
#include <cstddef>
#include <optional>
namespace mapnik {
@ -56,7 +52,7 @@ class MAPNIK_DECL feature_type_style
std::vector<filter::filter_type> filters_;
std::vector<filter::filter_type> direct_filters_;
// comp-op
boost::optional<composite_mode_e> comp_op_;
std::optional<composite_mode_e> comp_op_;
float opacity_;
bool image_filters_inflate_;
friend void swap(feature_type_style& lhs, feature_type_style& rhs);
@ -87,7 +83,7 @@ class MAPNIK_DECL feature_type_style
std::vector<filter::filter_type>& direct_image_filters();
// compositing
void set_comp_op(composite_mode_e comp_op);
boost::optional<composite_mode_e> comp_op() const;
std::optional<composite_mode_e> comp_op() const;
void set_opacity(float opacity);
float get_opacity() const;
void set_image_filters_inflate(bool inflate);

View file

@ -35,11 +35,7 @@
#include <map>
#include <utility> // pair
#include <vector>
namespace boost {
template<class T>
class optional;
}
#include <optional>
namespace mapnik {
@ -117,7 +113,7 @@ class MAPNIK_DECL face_manager
face_ptr get_face(std::string const& name);
face_set_ptr get_face_set(std::string const& name);
face_set_ptr get_face_set(font_set const& fset);
face_set_ptr get_face_set(std::string const& name, boost::optional<font_set> fset);
face_set_ptr get_face_set(std::string const& name, std::optional<font_set> fset);
stroker_ptr get_stroker() const { return stroker_; }
private:

View file

@ -26,14 +26,9 @@
#include <mapnik/config.hpp>
#include <mapnik/image.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
// stl
#include <string>
#include <optional>
namespace mapnik {
@ -80,8 +75,8 @@ enum composite_mode_e {
divide
};
MAPNIK_DECL boost::optional<composite_mode_e> comp_op_from_string(std::string const& name);
MAPNIK_DECL boost::optional<std::string> comp_op_to_string(composite_mode_e comp_op);
MAPNIK_DECL std::optional<composite_mode_e> comp_op_from_string(std::string const& name);
MAPNIK_DECL std::optional<std::string> comp_op_to_string(composite_mode_e comp_op);
template<typename T>
MAPNIK_DECL void composite(T& dst, T const& src, composite_mode_e mode, float opacity = 1, int dx = 0, int dy = 0);

View file

@ -25,17 +25,12 @@
#include <map>
#include <string>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
#include <optional>
namespace mapnik {
using image_options_map = std::map<std::string, boost::optional<std::string>>;
inline std::string to_string(boost::optional<std::string> const& val)
using image_options_map = std::map<std::string, std::optional<std::string>>;
inline std::string to_string(std::optional<std::string> const& val)
{
return val ? *val : "<unitialised>";
}

View file

@ -30,15 +30,9 @@
#include <mapnik/factory.hpp>
#include <mapnik/geometry/box2d.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
// stl
#include <stdexcept>
#include <string>
#include <optional>
namespace mapnik {
@ -62,7 +56,7 @@ struct MAPNIK_DECL image_reader : private util::noncopyable
virtual unsigned width() const = 0;
virtual unsigned height() const = 0;
virtual bool has_alpha() const = 0;
virtual boost::optional<box2d<double>> bounding_box() const = 0;
virtual std::optional<box2d<double>> bounding_box() const = 0;
virtual void read(unsigned x, unsigned y, image_rgba8& image) = 0;
virtual image_any read(unsigned x, unsigned y, unsigned width, unsigned height) = 0;
virtual ~image_reader() {}

View file

@ -28,13 +28,8 @@
#include <mapnik/image.hpp>
// stl
#include <iosfwd>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
#include <string>
#include <optional>
namespace mapnik {
@ -58,8 +53,8 @@ enum scaling_method_e {
SCALING_BLACKMAN
};
MAPNIK_DECL boost::optional<scaling_method_e> scaling_method_from_string(std::string const& name);
MAPNIK_DECL boost::optional<std::string> scaling_method_to_string(scaling_method_e scaling_method);
MAPNIK_DECL std::optional<scaling_method_e> scaling_method_from_string(std::string const& name);
MAPNIK_DECL std::optional<std::string> scaling_method_to_string(scaling_method_e scaling_method);
template<typename T>
MAPNIK_DECL void scale_image_agg(T& target,
@ -70,7 +65,7 @@ MAPNIK_DECL void scale_image_agg(T& target,
double x_off_f,
double y_off_f,
double filter_factor,
boost::optional<double> const& nodata_value);
std::optional<double> const& nodata_value);
template<typename T>
inline void scale_image_agg(T& target,
T const& source,
@ -89,7 +84,7 @@ inline void scale_image_agg(T& target,
x_off_f,
y_off_f,
filter_factor,
boost::optional<double>());
std::optional<double>());
}
} // namespace mapnik

View file

@ -32,12 +32,12 @@
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
// stl
#include <string>
#include <exception>
#include <optional>
namespace mapnik {
@ -361,25 +361,23 @@ inline bool is_webp(std::string const& filename)
return boost::algorithm::iends_with(filename, std::string(".webp"));
}
inline boost::optional<std::string> type_from_filename(std::string const& filename)
inline std::optional<std::string> type_from_filename(std::string const& filename)
{
using result_type = boost::optional<std::string>;
if (is_png(filename))
return result_type("png");
return "png";
if (is_jpeg(filename))
return result_type("jpeg");
return "jpeg";
if (is_tiff(filename))
return result_type("tiff");
return "tiff";
if (is_pdf(filename))
return result_type("pdf");
return "pdf";
if (is_svg(filename))
return result_type("svg");
return "svg";
if (is_ps(filename))
return result_type("ps");
return "ps";
if (is_webp(filename))
return result_type("webp");
return result_type();
return "webp";
return std::nullopt;
}
inline std::string guess_type(std::string const& filename)

View file

@ -26,12 +26,7 @@
#include <mapnik/json/json_value.hpp>
#include <mapnik/util/variant.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
#include <optional>
#include <tuple>
#include <vector>
#include <list>
@ -53,37 +48,37 @@ using properties = std::vector<property>;
struct point
{
coordinate coord;
boost::optional<properties> props;
std::optional<properties> props;
};
struct multi_point
{
std::vector<coordinate> points;
boost::optional<properties> props;
std::optional<properties> props;
};
struct linestring
{
std::vector<index_type> rings;
boost::optional<properties> props;
std::optional<properties> props;
};
struct multi_linestring
{
std::vector<std::vector<index_type>> lines;
boost::optional<properties> props;
std::optional<properties> props;
};
struct polygon
{
std::vector<std::vector<index_type>> rings;
boost::optional<properties> props;
std::optional<properties> props;
};
struct multi_polygon
{
std::vector<std::vector<std::vector<index_type>>> polygons;
boost::optional<properties> props;
std::optional<properties> props;
};
struct empty
@ -118,8 +113,8 @@ struct topology
{
std::vector<geometry> geometries;
std::vector<arc> arcs;
boost::optional<transform> tr;
boost::optional<bounding_box> bbox;
std::optional<transform> tr;
std::optional<bounding_box> bbox;
};
} // namespace topojson

View file

@ -210,15 +210,15 @@ class MAPNIK_DECL layer
// compositing
void set_comp_op(composite_mode_e comp_op);
boost::optional<composite_mode_e> comp_op() const;
std::optional<composite_mode_e> comp_op() const;
void set_opacity(double opacity);
double get_opacity() const;
void set_maximum_extent(box2d<double> const& box);
boost::optional<box2d<double>> const& maximum_extent() const;
std::optional<box2d<double>> const& maximum_extent() const;
void reset_maximum_extent();
void set_buffer_size(int size);
boost::optional<int> const& buffer_size() const;
std::optional<int> const& buffer_size() const;
void reset_buffer_size();
~layer();
@ -235,9 +235,9 @@ class MAPNIK_DECL layer
std::vector<std::string> styles_;
std::vector<layer> layers_;
datasource_ptr ds_;
boost::optional<int> buffer_size_;
boost::optional<box2d<double>> maximum_extent_;
boost::optional<composite_mode_e> comp_op_;
std::optional<int> buffer_size_;
std::optional<box2d<double>> maximum_extent_;
std::optional<composite_mode_e> comp_op_;
double opacity_;
};
} // namespace mapnik

View file

@ -33,11 +33,8 @@
#include <mapnik/well_known_srs.hpp>
#include <mapnik/image_compositing.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
#include <boost/optional/optional_fwd.hpp>
// stl
#include <memory>
@ -84,8 +81,8 @@ class MAPNIK_DECL Map : boost::equality_comparable<Map>
unsigned height_;
std::string srs_;
int buffer_size_;
boost::optional<color> background_;
boost::optional<std::string> background_image_;
std::optional<color> background_;
std::optional<std::string> background_image_;
composite_mode_e background_image_comp_op_;
float background_image_opacity_;
std::map<std::string, feature_type_style> styles_;
@ -93,10 +90,10 @@ class MAPNIK_DECL Map : boost::equality_comparable<Map>
std::vector<layer> layers_;
aspect_fix_mode aspectFixMode_;
box2d<double> current_extent_;
boost::optional<box2d<double>> maximum_extent_;
std::optional<box2d<double>> maximum_extent_;
std::string base_path_;
parameters extra_params_;
boost::optional<std::string> font_directory_;
std::optional<std::string> font_directory_;
freetype_engine::font_file_mapping_type font_file_mapping_;
freetype_engine::font_memory_cache_type font_memory_cache_;
@ -318,7 +315,7 @@ class MAPNIK_DECL Map : boost::equality_comparable<Map>
* @return Background color as boost::optional
* object
*/
boost::optional<color> const& background() const;
std::optional<color> const& background() const;
/*! \brief Set the map background image filename.
* @param image_filename Background image filename.
@ -329,7 +326,7 @@ class MAPNIK_DECL Map : boost::equality_comparable<Map>
* @return Background image path as std::string
* object
*/
boost::optional<std::string> const& background_image() const;
std::optional<std::string> const& background_image() const;
/*! \brief Set the compositing operation uses to blend the background image into the background color.
* @param comp_op compositing operation.
@ -369,7 +366,7 @@ class MAPNIK_DECL Map : boost::equality_comparable<Map>
/*! \brief Get the map maximum extent as box2d<double>
*/
boost::optional<box2d<double>> const& maximum_extent() const;
std::optional<box2d<double>> const& maximum_extent() const;
void reset_maximum_extent();
@ -467,7 +464,7 @@ class MAPNIK_DECL Map : boost::equality_comparable<Map>
*/
void set_extra_parameters(parameters& params);
boost::optional<std::string> const& font_directory() const { return font_directory_; }
std::optional<std::string> const& font_directory() const { return font_directory_; }
void set_font_directory(std::string const& dir) { font_directory_ = dir; }

View file

@ -31,12 +31,7 @@
#include <memory>
#include <string>
#include <unordered_map>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
#include <optional>
namespace boost {
namespace interprocess {
@ -64,7 +59,7 @@ class MAPNIK_DECL mapped_memory_cache : public singleton<mapped_memory_cache, Cr
* @return false if the resource was not removed or wasn't in the cache
*/
bool remove(std::string const& key);
boost::optional<mapped_region_ptr> find(std::string const& key, bool update_cache = false);
std::optional<mapped_region_ptr> find(std::string const& key, bool update_cache = false);
void clear();
};

View file

@ -46,7 +46,7 @@ class MAPNIK_DECL memory_datasource : public datasource
virtual featureset_ptr features(query const& q) const;
virtual featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const;
virtual box2d<double> envelope() const;
virtual boost::optional<datasource_geometry_t> get_geometry_type() const;
virtual std::optional<datasource_geometry_t> get_geometry_type() const;
virtual layer_descriptor get_descriptor() const;
//
void push(feature_ptr feature);

View file

@ -28,15 +28,10 @@
#include <mapnik/value/types.hpp>
#include <mapnik/util/variant.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
// stl
#include <string>
#include <map>
#include <optional>
namespace mapnik {
@ -72,33 +67,33 @@ class MAPNIK_DECL parameters : public param_map
public:
parameters() {}
template<typename T>
boost::optional<T> get(std::string const& key) const;
std::optional<T> get(std::string const& key) const;
template<typename T>
boost::optional<T> get(std::string const& key, T const& default_opt_value) const;
std::optional<T> get(std::string const& key, T const& default_opt_value) const;
};
#ifdef _MSC_VER
template MAPNIK_DECL boost::optional<std::string> parameters::get(std::string const& key) const;
template MAPNIK_DECL boost::optional<std::string> parameters::get(std::string const& key,
template MAPNIK_DECL std::optional<std::string> parameters::get(std::string const& key) const;
template MAPNIK_DECL std::optional<std::string> parameters::get(std::string const& key,
std::string const& default_opt_value) const;
template MAPNIK_DECL boost::optional<value_double> parameters::get(std::string const& key) const;
template MAPNIK_DECL boost::optional<value_double> parameters::get(std::string const& key,
template MAPNIK_DECL std::optional<value_double> parameters::get(std::string const& key) const;
template MAPNIK_DECL std::optional<value_double> parameters::get(std::string const& key,
value_double const& default_opt_value) const;
template MAPNIK_DECL boost::optional<value_integer> parameters::get(std::string const& key) const;
template MAPNIK_DECL boost::optional<value_integer> parameters::get(std::string const& key,
template MAPNIK_DECL std::optional<value_integer> parameters::get(std::string const& key) const;
template MAPNIK_DECL std::optional<value_integer> parameters::get(std::string const& key,
value_integer const& default_opt_value) const;
template MAPNIK_DECL boost::optional<value_bool> parameters::get(std::string const& key) const;
template MAPNIK_DECL boost::optional<value_bool> parameters::get(std::string const& key,
template MAPNIK_DECL std::optional<value_bool> parameters::get(std::string const& key) const;
template MAPNIK_DECL std::optional<value_bool> parameters::get(std::string const& key,
value_bool const& default_opt_value) const;
template MAPNIK_DECL boost::optional<mapnik::boolean_type> parameters::get(std::string const& key) const;
template MAPNIK_DECL boost::optional<mapnik::boolean_type>
template MAPNIK_DECL std::optional<mapnik::boolean_type> parameters::get(std::string const& key) const;
template MAPNIK_DECL std::optional<mapnik::boolean_type>
parameters::get(std::string const& key, mapnik::boolean_type const& default_opt_value) const;
template MAPNIK_DECL boost::optional<mapnik::value_null> parameters::get(std::string const& key) const;
template MAPNIK_DECL boost::optional<mapnik::value_null>
template MAPNIK_DECL std::optional<mapnik::value_null> parameters::get(std::string const& key) const;
template MAPNIK_DECL std::optional<mapnik::value_null>
parameters::get(std::string const& key, mapnik::value_null const& default_opt_value) const;
#endif

View file

@ -32,7 +32,6 @@
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
#include <boost/lexical_cast.hpp>
MAPNIK_DISABLE_WARNING_POP
@ -40,6 +39,7 @@ MAPNIK_DISABLE_WARNING_POP
#include <string>
#include <sstream>
#include <stdexcept>
#include <optional>
namespace mapnik {
namespace detail {
@ -47,13 +47,13 @@ namespace detail {
template<typename T>
struct extract_value
{
static inline boost::optional<T> do_extract_from_string(std::string const& /*source*/)
static inline std::optional<T> do_extract_from_string(std::string const& /*source*/)
{
std::ostringstream s;
s << "No conversion from std::string to " << typeid(T).name();
throw std::runtime_error(s.str());
}
static inline boost::optional<T> do_extract_from_bool(value_bool const& /*source*/)
static inline std::optional<T> do_extract_from_bool(value_bool const& /*source*/)
{
std::ostringstream s;
s << "No conversion from boolean to " << typeid(T).name();
@ -64,110 +64,106 @@ struct extract_value
template<>
struct extract_value<value_bool>
{
static inline boost::optional<value_bool> do_extract_from_string(std::string const& source)
static inline std::optional<value_bool> do_extract_from_string(std::string const& source)
{
bool result;
if (mapnik::util::string2bool(source, result))
return boost::optional<value_bool>(result);
return boost::optional<value_bool>();
return std::optional<value_bool>(result);
return std::nullopt;
}
static inline boost::optional<value_bool> do_extract_from_bool(value_bool const& source)
static inline std::optional<value_bool> do_extract_from_bool(value_bool const& source)
{
return boost::optional<value_bool>(source);
return source;
}
};
template<>
struct extract_value<mapnik::boolean_type>
{
static inline boost::optional<mapnik::boolean_type> do_extract_from_string(std::string const& source)
static inline std::optional<mapnik::boolean_type> do_extract_from_string(std::string const& source)
{
bool result;
if (mapnik::util::string2bool(source, result))
return boost::optional<mapnik::boolean_type>(result);
return boost::optional<mapnik::boolean_type>();
return std::optional<mapnik::boolean_type>(result);
return std::nullopt;
}
static inline boost::optional<mapnik::boolean_type> do_extract_from_bool(value_bool const& source)
static inline std::optional<mapnik::boolean_type> do_extract_from_bool(value_bool const& source)
{
return boost::optional<mapnik::boolean_type>(source);
return std::optional<mapnik::boolean_type>(source);
}
};
template<>
struct extract_value<mapnik::value_integer>
{
static inline boost::optional<mapnik::value_integer> do_extract_from_string(std::string const& source)
static inline std::optional<mapnik::value_integer> do_extract_from_string(std::string const& source)
{
mapnik::value_integer result;
if (mapnik::util::string2int(source, result))
return boost::optional<mapnik::value_integer>(result);
return boost::optional<mapnik::value_integer>();
return std::optional<mapnik::value_integer>(result);
return std::nullopt;
}
static inline boost::optional<mapnik::value_integer> do_extract_from_bool(value_bool const& source)
static inline std::optional<mapnik::value_integer> do_extract_from_bool(value_bool const& source)
{
return boost::optional<mapnik::value_integer>(boost::lexical_cast<mapnik::value_integer>(source));
return std::optional<mapnik::value_integer>(boost::lexical_cast<mapnik::value_integer>(source));
}
};
template<>
struct extract_value<mapnik::value_double>
{
static inline boost::optional<mapnik::value_double> do_extract_from_string(std::string const& source)
static inline std::optional<mapnik::value_double> do_extract_from_string(std::string const& source)
{
mapnik::value_double result;
if (mapnik::util::string2double(source, result))
return boost::optional<double>(result);
return boost::optional<double>();
return std::optional<double>(result);
return std::nullopt;
}
static inline boost::optional<mapnik::value_double> do_extract_from_bool(value_bool const& source)
static inline std::optional<mapnik::value_double> do_extract_from_bool(value_bool const& source)
{
return boost::optional<double>(boost::lexical_cast<double>(source));
return std::optional<double>(boost::lexical_cast<double>(source));
}
};
template<>
struct extract_value<mapnik::value_null>
{
static inline boost::optional<mapnik::value_null> do_extract_from_string(std::string const&)
static inline std::optional<mapnik::value_null> do_extract_from_string(std::string const&)
{
return boost::optional<mapnik::value_null>(); // FIXME
return std::nullopt; // FIXME
}
static inline boost::optional<mapnik::value_null> do_extract_from_bool(value_bool const&)
static inline std::optional<mapnik::value_null> do_extract_from_bool(value_bool const&)
{
return boost::optional<mapnik::value_null>(); // FIXME
return std::nullopt; // FIXME
}
};
template<>
struct extract_value<std::string>
{
static inline boost::optional<std::string> do_extract_from_string(std::string const& source)
static inline std::optional<std::string> do_extract_from_string(std::string const& source)
{
return boost::optional<std::string>(source);
return std::optional<std::string>(source);
}
static inline boost::optional<std::string> do_extract_from_bool(value_bool const& source)
static inline std::optional<std::string> do_extract_from_bool(value_bool const& source)
{
if (source)
{
return boost::optional<std::string>("true");
}
return boost::optional<std::string>("false");
return source ? "true" : "false";
}
};
template<typename T>
boost::optional<T> param_cast(std::string const& source)
std::optional<T> param_cast(std::string const& source)
{
return extract_value<T>::do_extract_from_string(source);
}
template<typename T>
boost::optional<T> param_cast(value_bool const& source)
std::optional<T> param_cast(value_bool const& source)
{
return extract_value<T>::do_extract_from_bool(source);
}
@ -177,7 +173,7 @@ boost::optional<T> param_cast(value_bool const& source)
template<typename T>
struct value_extractor_visitor
{
value_extractor_visitor(boost::optional<T>& var)
value_extractor_visitor(std::optional<T>& var)
: var_(var)
{}
@ -200,7 +196,7 @@ struct value_extractor_visitor
}
}
boost::optional<T>& var_;
std::optional<T>& var_;
};
namespace params_detail {
@ -209,11 +205,11 @@ template<typename T>
struct converter
{
using value_type = T;
using return_type = boost::optional<value_type>;
using return_type = std::optional<value_type>;
static return_type
extract(parameters const& params, std::string const& name, boost::optional<T> const& default_opt_value)
extract(parameters const& params, std::string const& name, std::optional<T> const& default_opt_value)
{
boost::optional<T> result(default_opt_value);
std::optional<T> result(default_opt_value);
parameters::const_iterator itr = params.find(name);
if (itr != params.end())
{
@ -226,15 +222,15 @@ struct converter
} // end namespace params_detail
template<typename T>
boost::optional<T> parameters::get(std::string const& key) const
std::optional<T> parameters::get(std::string const& key) const
{
return params_detail::converter<T>::extract(*this, key, boost::none);
return params_detail::converter<T>::extract(*this, key, std::nullopt);
}
template<typename T>
boost::optional<T> parameters::get(std::string const& key, T const& default_opt_value) const
std::optional<T> parameters::get(std::string const& key, T const& default_opt_value) const
{
return params_detail::converter<T>::extract(*this, key, boost::optional<T>(default_opt_value));
return params_detail::converter<T>::extract(*this, key, std::optional<T>(default_opt_value));
}
} // namespace mapnik

View file

@ -73,7 +73,7 @@ class MAPNIK_DECL projection
bool operator!=(const projection& other) const;
bool is_initialized() const;
bool is_geographic() const;
boost::optional<well_known_srs_e> well_known() const;
std::optional<well_known_srs_e> well_known() const;
std::string const& params() const;
void forward(double& x, double& y) const;
void inverse(double& x, double& y) const;

View file

@ -29,11 +29,7 @@
#include <mapnik/util/noncopyable.hpp>
#include <mapnik/util/variant.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
#include <optional>
namespace mapnik {
@ -44,7 +40,7 @@ class raster : private util::noncopyable
box2d<double> query_ext_;
image_any data_;
double filter_factor_;
boost::optional<double> nodata_;
std::optional<double> nodata_;
template<typename ImageData>
raster(box2d<double> const& ext, box2d<double> const& query_ext, ImageData&& data, double filter_factor)
@ -64,7 +60,7 @@ class raster : private util::noncopyable
void set_nodata(double _nodata) { nodata_ = _nodata; }
boost::optional<double> const& nodata() const { return nodata_; }
std::optional<double> const& nodata() const { return nodata_; }
double get_filter_factor() const { return filter_factor_; }

View file

@ -42,14 +42,9 @@
#include <mapnik/enumeration.hpp>
#include <mapnik/image.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
#include <memory>
#include <vector>
#include <optional>
namespace mapnik {
@ -193,7 +188,7 @@ class MAPNIK_DECL raster_colorizer
colorizer_stops const& get_stops() const { return stops_; }
template<typename T>
void colorize(image_rgba8& out, T const& in, boost::optional<double> const& nodata, feature_impl const& f) const;
void colorize(image_rgba8& out, T const& in, std::optional<double> const& nodata, feature_impl const& f) const;
//! \brief Perform the translation of input to output
//!

View file

@ -31,6 +31,7 @@
#include <mapnik/raster_colorizer.hpp>
#include <mapnik/proj_transform.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/renderer_common.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
@ -66,7 +67,7 @@ struct image_dispatcher
raster_symbolizer const& sym,
feature_impl const& feature,
F& composite,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
bool need_scaling)
: start_x_(start_x)
, start_y_(start_y)
@ -156,7 +157,7 @@ struct image_dispatcher
raster_symbolizer const& sym_;
feature_impl const& feature_;
composite_function& composite_;
boost::optional<double> const& nodata_;
std::optional<double> const& nodata_;
bool need_scaling_;
};
@ -181,7 +182,7 @@ struct image_warp_dispatcher
raster_symbolizer const& sym,
feature_impl const& feature,
F& composite,
boost::optional<double> const& nodata)
std::optional<double> const& nodata)
: prj_trans_(prj_trans)
, start_x_(start_x)
, start_y_(start_y)
@ -265,7 +266,7 @@ struct image_warp_dispatcher
raster_symbolizer const& sym_;
feature_impl const& feature_;
composite_function& composite_;
boost::optional<double> const& nodata_;
std::optional<double> const& nodata_;
};
} // namespace detail

View file

@ -6,19 +6,14 @@
// stl
#include <string>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
#include <optional>
namespace mapnik {
enum simplify_algorithm_e { radial_distance = 0, douglas_peucker, visvalingam_whyatt, zhao_saalfeld };
MAPNIK_DECL boost::optional<simplify_algorithm_e> simplify_algorithm_from_string(std::string const& name);
MAPNIK_DECL boost::optional<std::string> simplify_algorithm_to_string(simplify_algorithm_e algorithm);
MAPNIK_DECL std::optional<simplify_algorithm_e> simplify_algorithm_from_string(std::string const& name);
MAPNIK_DECL std::optional<std::string> simplify_algorithm_to_string(simplify_algorithm_e algorithm);
} // namespace mapnik

View file

@ -24,13 +24,6 @@
#define MAPNIK_SPAN_IMAGE_FILTER_INCLUDED
#include <mapnik/safe_cast.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore_agg.hpp>
@ -38,7 +31,7 @@ MAPNIK_DISABLE_WARNING_PUSH
#include "agg_span_image_filter_rgba.h"
MAPNIK_DISABLE_WARNING_POP
#include <limits>
#include <optional>
namespace mapnik {
@ -58,7 +51,7 @@ class span_image_resample_gray_affine : public agg::span_image_resample_affine<S
span_image_resample_gray_affine(source_type& src,
interpolator_type& inter,
agg::image_filter_lut const& filter,
boost::optional<value_type> const& nodata_value)
std::optional<value_type> const& nodata_value)
: base_type(src, inter, filter)
, nodata_value_(nodata_value)
{}
@ -152,7 +145,7 @@ class span_image_resample_gray_affine : public agg::span_image_resample_affine<S
}
private:
boost::optional<value_type> nodata_value_;
std::optional<value_type> nodata_value_;
};
template<class Source>
@ -170,7 +163,7 @@ class span_image_resample_rgba_affine : public agg::span_image_resample_rgba_aff
span_image_resample_rgba_affine(source_type& src,
interpolator_type& inter,
agg::image_filter_lut const& _filter,
boost::optional<value_type> const& nodata_value)
std::optional<value_type> const& nodata_value)
: agg::span_image_resample_rgba_affine<Source>(src, inter, _filter)
{}
};

View file

@ -35,8 +35,7 @@
#include <map>
#include <algorithm>
#include <deque>
// boost
#include <boost/optional.hpp>
#include <optional>
namespace boost {
namespace property_tree {
@ -109,7 +108,7 @@ class MAPNIK_DECL svg_parser : private util::noncopyable
std::map<std::string, gradient> gradient_map_;
std::map<std::string, boost::property_tree::detail::rapidxml::xml_node<char> const*> node_cache_;
mapnik::css_data css_data_;
boost::optional<viewbox> vbox_{};
std::optional<viewbox> vbox_{};
double normalized_diagonal_ = 0.0;
agg::trans_affine viewbox_tr_{};
std::deque<double> font_sizes_{};

View file

@ -50,12 +50,7 @@
#include <functional>
#include <map>
#include <tuple>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
#include <optional>
namespace mapnik {
@ -129,21 +124,21 @@ struct enum_traits
template<>
struct enum_traits<composite_mode_e>
{
using result_type = boost::optional<composite_mode_e>;
using result_type = std::optional<composite_mode_e>;
static result_type from_string(std::string const& str) { return comp_op_from_string(str); }
};
template<>
struct enum_traits<scaling_method_e>
{
using result_type = boost::optional<scaling_method_e>;
using result_type = std::optional<scaling_method_e>;
static result_type from_string(std::string const& str) { return scaling_method_from_string(str); }
};
template<>
struct enum_traits<simplify_algorithm_e>
{
using result_type = boost::optional<simplify_algorithm_e>;
using result_type = std::optional<simplify_algorithm_e>;
static result_type from_string(std::string const& str) { return simplify_algorithm_from_string(str); }
};
@ -151,7 +146,7 @@ struct enum_traits<simplify_algorithm_e>
template<> \
struct enum_traits<e> \
{ \
using result_type = boost::optional<e>; \
using result_type = std::optional<e>; \
static result_type from_string(std::string const& str) \
{ \
enumeration<e, alias##_to_string, alias##_from_string, alias##_lookup> enum_; \
@ -433,7 +428,7 @@ T get(symbolizer_base const& sym,
}
template<typename T>
boost::optional<T>
std::optional<T>
get_optional(symbolizer_base const& sym, keys key, mapnik::feature_impl const& feature, attributes const& vars)
{
using const_iterator = symbolizer_base::cont_type::const_iterator;
@ -442,7 +437,7 @@ boost::optional<T>
{
return util::apply_visitor(extract_value<T>(feature, vars), itr->second);
}
return boost::optional<T>();
return std::nullopt;
}
template<typename T>
@ -470,7 +465,7 @@ T get(symbolizer_base const& sym, keys key, T const& default_value)
}
template<typename T>
boost::optional<T> get_optional(symbolizer_base const& sym, keys key)
std::optional<T> get_optional(symbolizer_base const& sym, keys key)
{
using const_iterator = symbolizer_base::cont_type::const_iterator;
const_iterator itr = sym.properties.find(key);
@ -478,7 +473,7 @@ boost::optional<T> get_optional(symbolizer_base const& sym, keys key)
{
return util::apply_visitor(extract_raw_value<T>(), itr->second);
}
return boost::optional<T>{};
return std::nullopt;
}
} // namespace mapnik

View file

@ -360,14 +360,14 @@ struct set_symbolizer_property_impl
using value_type = T;
try
{
boost::optional<value_type> val = node.get_opt_attr<value_type>(name);
const auto val = node.get_opt_attr<value_type>(name);
if (val)
put(sym, key, *val);
}
catch (config_error const& ex)
{
// try parsing as an expression
boost::optional<expression_ptr> val = node.get_opt_attr<expression_ptr>(name);
const auto val = node.get_opt_attr<expression_ptr>(name);
if (val)
{
// first try pre-evaluate expressions which don't have dynamic properties
@ -395,7 +395,7 @@ struct set_symbolizer_property_impl<Symbolizer, transform_type, false>
{
static void apply(Symbolizer& sym, keys key, std::string const& name, xml_node const& node)
{
boost::optional<std::string> transform = node.get_opt_attr<std::string>(name);
const auto transform = node.get_opt_attr<std::string>(name);
if (transform)
put(sym, key, mapnik::parse_transform(*transform));
}
@ -406,7 +406,7 @@ struct set_symbolizer_property_impl<Symbolizer, dash_array, false>
{
static void apply(Symbolizer& sym, keys key, std::string const& name, xml_node const& node)
{
boost::optional<std::string> str = node.get_opt_attr<std::string>(name);
const auto str = node.get_opt_attr<std::string>(name);
if (str)
{
dash_array dash;
@ -416,14 +416,14 @@ struct set_symbolizer_property_impl<Symbolizer, dash_array, false>
}
else
{
boost::optional<expression_ptr> val = node.get_opt_attr<expression_ptr>(name);
const auto val = node.get_opt_attr<expression_ptr>(name);
if (val)
{
// first try pre-evaluate expressions which don't have dynamic properties
auto result = pre_evaluate_expression<mapnik::value>(*val);
if (std::get<1>(result))
const auto [value, is_evaluated] = pre_evaluate_expression<mapnik::value>(*val);
if (is_evaluated)
{
set_property_from_value(sym, key, std::get<0>(result));
set_property_from_value(sym, key, value);
}
else
{
@ -447,25 +447,25 @@ struct set_symbolizer_property_impl<Symbolizer, T, true>
static void apply(Symbolizer& sym, keys key, std::string const& name, xml_node const& node)
{
using value_type = T;
boost::optional<std::string> enum_str = node.get_opt_attr<std::string>(name);
const auto enum_str = node.get_opt_attr<std::string>(name);
if (enum_str)
{
boost::optional<value_type> enum_val = detail::enum_traits<value_type>::from_string(*enum_str);
const auto enum_val = detail::enum_traits<value_type>::from_string(*enum_str);
if (enum_val)
{
put(sym, key, *enum_val);
}
else
{
boost::optional<expression_ptr> val = node.get_opt_attr<expression_ptr>(name);
const auto val = node.get_opt_attr<expression_ptr>(name);
if (val)
{
// first try pre-evaluating expression
auto result = pre_evaluate_expression<value>(*val);
if (std::get<1>(result))
const auto [result_value, is_evaluated] = pre_evaluate_expression<value>(*val);
if (is_evaluated)
{
boost::optional<value_type> enum_val2 =
detail::enum_traits<value_type>::from_string(std::get<0>(result).to_string());
const auto enum_val2 =
detail::enum_traits<value_type>::from_string(result_value.to_string());
if (enum_val2)
{
put(sym, key, *enum_val);

View file

@ -50,19 +50,19 @@ class MAPNIK_DECL format_node : public node
void set_child(node_ptr child);
node_ptr get_child() const;
boost::optional<std::string> face_name;
boost::optional<font_set> fontset;
boost::optional<symbolizer_base::value_type> text_size;
boost::optional<symbolizer_base::value_type> character_spacing;
boost::optional<symbolizer_base::value_type> line_spacing;
boost::optional<symbolizer_base::value_type> text_opacity;
boost::optional<symbolizer_base::value_type> wrap_before;
boost::optional<symbolizer_base::value_type> repeat_wrap_char;
boost::optional<symbolizer_base::value_type> text_transform;
boost::optional<symbolizer_base::value_type> fill;
boost::optional<symbolizer_base::value_type> halo_fill;
boost::optional<symbolizer_base::value_type> halo_radius;
boost::optional<symbolizer_base::value_type> ff_settings;
std::optional<std::string> face_name;
std::optional<font_set> fontset;
std::optional<symbolizer_base::value_type> text_size;
std::optional<symbolizer_base::value_type> character_spacing;
std::optional<symbolizer_base::value_type> line_spacing;
std::optional<symbolizer_base::value_type> text_opacity;
std::optional<symbolizer_base::value_type> wrap_before;
std::optional<symbolizer_base::value_type> repeat_wrap_char;
std::optional<symbolizer_base::value_type> text_transform;
std::optional<symbolizer_base::value_type> fill;
std::optional<symbolizer_base::value_type> halo_fill;
std::optional<symbolizer_base::value_type> halo_radius;
std::optional<symbolizer_base::value_type> ff_settings;
private:
node_ptr child_;

View file

@ -25,12 +25,7 @@
#include <mapnik/text/formatting/base.hpp>
#include <mapnik/text/text_properties.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
#include <optional>
namespace mapnik {
namespace formatting {
@ -48,18 +43,18 @@ class MAPNIK_DECL layout_node : public node
void set_child(node_ptr child);
node_ptr get_child() const;
//
boost::optional<symbolizer_base::value_type> dx;
boost::optional<symbolizer_base::value_type> dy;
boost::optional<symbolizer_base::value_type> halign;
boost::optional<symbolizer_base::value_type> valign;
boost::optional<symbolizer_base::value_type> jalign;
boost::optional<symbolizer_base::value_type> text_ratio;
boost::optional<symbolizer_base::value_type> wrap_width;
boost::optional<symbolizer_base::value_type> wrap_char;
boost::optional<symbolizer_base::value_type> wrap_before;
boost::optional<symbolizer_base::value_type> repeat_wrap_char;
boost::optional<symbolizer_base::value_type> rotate_displacement;
boost::optional<symbolizer_base::value_type> orientation;
std::optional<symbolizer_base::value_type> dx;
std::optional<symbolizer_base::value_type> dy;
std::optional<symbolizer_base::value_type> halign;
std::optional<symbolizer_base::value_type> valign;
std::optional<symbolizer_base::value_type> jalign;
std::optional<symbolizer_base::value_type> text_ratio;
std::optional<symbolizer_base::value_type> wrap_width;
std::optional<symbolizer_base::value_type> wrap_char;
std::optional<symbolizer_base::value_type> wrap_before;
std::optional<symbolizer_base::value_type> repeat_wrap_char;
std::optional<symbolizer_base::value_type> rotate_displacement;
std::optional<symbolizer_base::value_type> orientation;
private:
node_ptr child_;

View file

@ -60,13 +60,13 @@ struct set_property_from_xml_impl
{
try
{
boost::optional<target_type> val_ = node.get_opt_attr<target_type>(name);
const auto val_ = node.get_opt_attr<target_type>(name);
if (val_)
val = *val_;
}
catch (config_error const& ex)
{
boost::optional<expression_ptr> val_ = node.get_opt_attr<expression_ptr>(name);
const auto val_ = node.get_opt_attr<expression_ptr>(name);
if (val_)
val = *val_;
else
@ -86,13 +86,13 @@ struct set_property_from_xml_impl<std::string, false>
{
try
{
boost::optional<expression_ptr> val_ = node.get_opt_attr<expression_ptr>(name);
const auto val_ = node.get_opt_attr<expression_ptr>(name);
if (val_)
val = *val_;
}
catch (config_error const& ex)
{
boost::optional<target_type> val_ = node.get_opt_attr<target_type>(name);
const auto val_ = node.get_opt_attr<target_type>(name);
if (val_)
val = *val_;
else
@ -112,7 +112,7 @@ struct set_property_from_xml_impl<T0, true>
{
try
{
boost::optional<std::string> enum_str = node.get_opt_attr<std::string>(name);
const auto enum_str = node.get_opt_attr<std::string>(name);
if (enum_str)
{
target_enum_type e;
@ -122,7 +122,7 @@ struct set_property_from_xml_impl<T0, true>
}
catch (...)
{
boost::optional<expression_ptr> expr = node.get_opt_attr<expression_ptr>(name);
const auto expr = node.get_opt_attr<expression_ptr>(name);
if (expr)
val = *expr;
else

View file

@ -35,11 +35,11 @@
// stl
#include <map>
#include <optional>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
#include <boost/property_tree/ptree_fwd.hpp>
MAPNIK_DISABLE_WARNING_POP
@ -53,7 +53,7 @@ namespace detail {
struct evaluated_format_properties
{
std::string face_name;
boost::optional<font_set> fontset;
std::optional<font_set> fontset;
double text_size;
double character_spacing;
double line_spacing;
@ -113,7 +113,7 @@ struct MAPNIK_DECL format_properties
void add_expressions(expression_set& output) const;
std::string face_name;
boost::optional<font_set> fontset;
std::optional<font_set> fontset;
// expressions
symbolizer_base::value_type text_size;
symbolizer_base::value_type character_spacing;

View file

@ -32,7 +32,6 @@
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/vector.hpp>
MAPNIK_DISABLE_WARNING_POP

View file

@ -40,7 +40,7 @@ MAPNIK_DECL void reproject_and_scale_raster(raster& target,
double offset_y,
unsigned mesh_size,
scaling_method_e scaling_method,
boost::optional<double> const& nodata_value);
std::optional<double> const& nodata_value);
MAPNIK_DECL void reproject_and_scale_raster(raster& target,
raster const& source,
@ -61,7 +61,7 @@ MAPNIK_DECL void warp_image(T& target,
unsigned mesh_size,
scaling_method_e scaling_method,
double filter_factor,
boost::optional<double> const& nodata_value);
std::optional<double> const& nodata_value);
} // namespace mapnik
#endif // MAPNIK_WARP_HPP

View file

@ -28,13 +28,8 @@
#include <mapnik/geometry/point.hpp>
#include <mapnik/util/math.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
// stl
#include <optional>
#include <vector>
namespace mapnik {
@ -51,8 +46,8 @@ constexpr double MERC_MAX_LATITUDE = 85.0511287798065923778;
extern MAPNIK_DECL std::string const MAPNIK_GEOGRAPHIC_PROJ;
extern MAPNIK_DECL std::string const MAPNIK_WEBMERCATOR_PROJ;
MAPNIK_DECL boost::optional<bool> is_known_geographic(std::string const& srs);
MAPNIK_DECL boost::optional<well_known_srs_e> is_well_known_srs(std::string const& srs);
MAPNIK_DECL std::optional<bool> is_known_geographic(std::string const& srs);
MAPNIK_DECL std::optional<well_known_srs_e> is_well_known_srs(std::string const& srs);
MAPNIK_DECL bool lonlat2merc(double& x, double& y);
MAPNIK_DECL bool lonlat2merc(double* x, double* y, std::size_t point_count, std::size_t stride = 1);

View file

@ -36,17 +36,12 @@
#include <mapnik/attribute.hpp>
#include <mapnik/text/font_feature_settings.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
// stl
#include <string>
#include <map>
#include <typeinfo>
#include <utility>
#include <optional>
#include <stdexcept>
namespace mapnik {
@ -55,7 +50,7 @@ namespace detail {
template<typename T>
struct do_xml_attribute_cast
{
static inline boost::optional<T> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& /*source*/)
static inline std::optional<T> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& /*source*/)
{
std::string err_msg("No conversion from std::string to ");
err_msg += std::string(typeid(T).name());
@ -67,13 +62,13 @@ struct do_xml_attribute_cast
template<>
struct do_xml_attribute_cast<mapnik::boolean_type>
{
static inline boost::optional<mapnik::boolean_type> xml_attribute_cast_impl(xml_tree const& /*tree*/,
std::string const& source)
static inline std::optional<mapnik::boolean_type> xml_attribute_cast_impl(xml_tree const& /*tree*/,
std::string const& source)
{
bool result;
if (mapnik::util::string2bool(source, result))
return boost::optional<mapnik::boolean_type>(result);
return boost::optional<mapnik::boolean_type>();
return result;
return std::nullopt;
}
};
@ -81,13 +76,13 @@ struct do_xml_attribute_cast<mapnik::boolean_type>
template<>
struct do_xml_attribute_cast<mapnik::value_bool>
{
static inline boost::optional<mapnik::value_bool> xml_attribute_cast_impl(xml_tree const& /*tree*/,
std::string const& source)
static inline std::optional<mapnik::value_bool> xml_attribute_cast_impl(xml_tree const& /*tree*/,
std::string const& source)
{
bool result;
if (mapnik::util::string2bool(source, result))
return boost::optional<mapnik::value_bool>(result);
return boost::optional<mapnik::value_bool>();
return result;
return std::nullopt;
}
};
@ -95,12 +90,12 @@ struct do_xml_attribute_cast<mapnik::value_bool>
template<>
struct do_xml_attribute_cast<int>
{
static inline boost::optional<int> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
static inline std::optional<int> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
{
int result;
if (mapnik::util::string2int(source, result))
return boost::optional<int>(result);
return boost::optional<int>();
return result;
return std::nullopt;
}
};
@ -109,13 +104,13 @@ struct do_xml_attribute_cast<int>
template<>
struct do_xml_attribute_cast<mapnik::value_integer>
{
static inline boost::optional<mapnik::value_integer> xml_attribute_cast_impl(xml_tree const& /*tree*/,
std::string const& source)
static inline std::optional<mapnik::value_integer> xml_attribute_cast_impl(xml_tree const& /*tree*/,
std::string const& source)
{
int result;
if (mapnik::util::string2int(source, result))
return boost::optional<mapnik::value_integer>(result);
return boost::optional<mapnik::value_integer>();
return result;
return std::nullopt;
}
};
@ -126,12 +121,12 @@ struct do_xml_attribute_cast<mapnik::value_integer>
template<>
struct do_xml_attribute_cast<unsigned>
{
static inline boost::optional<unsigned> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
static inline std::optional<unsigned> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
{
int result;
if (mapnik::util::string2int(source, result) && result >= 0)
return boost::optional<unsigned>(static_cast<unsigned>(result));
return boost::optional<unsigned>();
return static_cast<unsigned>(result);
return std::nullopt;
}
};
@ -139,12 +134,12 @@ struct do_xml_attribute_cast<unsigned>
template<>
struct do_xml_attribute_cast<float>
{
static inline boost::optional<float> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
static inline std::optional<float> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
{
float result;
if (mapnik::util::string2float(source, result))
return boost::optional<float>(result);
return boost::optional<float>();
return result;
return std::nullopt;
}
};
@ -152,12 +147,12 @@ struct do_xml_attribute_cast<float>
template<>
struct do_xml_attribute_cast<double>
{
static inline boost::optional<double> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
static inline std::optional<double> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
{
double result;
if (mapnik::util::string2double(source, result))
return boost::optional<double>(result);
return boost::optional<double>();
return result;
return std::nullopt;
}
};
@ -169,19 +164,19 @@ template<typename ENUM,
struct do_xml_attribute_cast<mapnik::enumeration<ENUM, F_TO_STRING, F_FROM_STRING, F_LOOKUP>>
{
using Enum = mapnik::enumeration<ENUM, F_TO_STRING, F_FROM_STRING, F_LOOKUP>;
static inline boost::optional<Enum> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
static inline std::optional<Enum> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
{
using result_type = typename boost::optional<Enum>;
try
{
Enum e;
e.from_string(source);
return result_type(e);
return e;
}
catch (illegal_enum_value const& ex)
{
MAPNIK_LOG_ERROR(do_xml_attribute_cast) << ex.what();
return result_type();
return std::nullopt;
;
}
}
};
@ -190,7 +185,7 @@ struct do_xml_attribute_cast<mapnik::enumeration<ENUM, F_TO_STRING, F_FROM_STRIN
template<>
struct do_xml_attribute_cast<mapnik::color>
{
static inline boost::optional<mapnik::color> xml_attribute_cast_impl(xml_tree const&, std::string const& source)
static inline std::optional<mapnik::color> xml_attribute_cast_impl(xml_tree const&, std::string const& source)
{
return parse_color(source);
}
@ -200,9 +195,9 @@ struct do_xml_attribute_cast<mapnik::color>
template<>
struct do_xml_attribute_cast<std::string>
{
static inline boost::optional<std::string> xml_attribute_cast_impl(xml_tree const&, std::string const& source)
static inline std::optional<std::string> xml_attribute_cast_impl(xml_tree const&, std::string const& source)
{
return boost::optional<std::string>(source);
return source;
}
};
@ -210,8 +205,8 @@ struct do_xml_attribute_cast<std::string>
template<>
struct do_xml_attribute_cast<mapnik::expression_ptr>
{
static inline boost::optional<mapnik::expression_ptr> xml_attribute_cast_impl(xml_tree const& tree,
std::string const& source)
static inline std::optional<mapnik::expression_ptr> xml_attribute_cast_impl(xml_tree const& tree,
std::string const& source)
{
std::map<std::string, mapnik::expression_ptr>::const_iterator itr = tree.expr_cache_.find(source);
if (itr != tree.expr_cache_.end())
@ -231,8 +226,8 @@ struct do_xml_attribute_cast<mapnik::expression_ptr>
template<>
struct do_xml_attribute_cast<mapnik::font_feature_settings>
{
static inline boost::optional<mapnik::font_feature_settings> xml_attribute_cast_impl(xml_tree const&,
std::string const& source)
static inline std::optional<mapnik::font_feature_settings> xml_attribute_cast_impl(xml_tree const&,
std::string const& source)
{
return mapnik::font_feature_settings(source);
}
@ -241,7 +236,7 @@ struct do_xml_attribute_cast<mapnik::font_feature_settings>
} // end namespace detail
template<typename T>
boost::optional<T> xml_attribute_cast(xml_tree const& tree, std::string const& source)
std::optional<T> xml_attribute_cast(xml_tree const& tree, std::string const& source)
{
return detail::do_xml_attribute_cast<T>::xml_attribute_cast_impl(tree, source);
}

View file

@ -26,17 +26,12 @@
// mapnik
#include <mapnik/config.hpp> // for MAPNIK_DECL
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
// stl
#include <list>
#include <string>
#include <map>
#include <exception>
#include <optional>
namespace mapnik {
class MAPNIK_DECL xml_tree;
@ -129,7 +124,7 @@ class MAPNIK_DECL xml_node
bool has_attribute(std::string const& name) const;
template<typename T>
boost::optional<T> get_opt_attr(std::string const& name) const;
std::optional<T> get_opt_attr(std::string const& name) const;
template<typename T>
T get_attr(std::string const& name, T const& default_opt_value) const;

View file

@ -96,23 +96,23 @@ csv_datasource::csv_datasource(parameters const& params)
separator_ = val.front();
}
boost::optional<std::string> ext = params.get<std::string>("extent");
const auto ext = params.get<std::string>("extent");
if (ext && !ext->empty())
{
extent_initialized_ = extent_.from_string(*ext);
}
boost::optional<std::string> inline_string = params.get<std::string>("inline");
const auto inline_string = params.get<std::string>("inline");
if (inline_string)
{
inline_string_ = *inline_string;
}
else
{
boost::optional<std::string> file = params.get<std::string>("file");
const auto file = params.get<std::string>("file");
if (!file)
throw mapnik::datasource_exception("CSV Plugin: missing <file> parameter");
boost::optional<std::string> base = params.get<std::string>("base");
const auto base = params.get<std::string>("base");
if (base)
filename_ = *base + "/" + *file;
else
@ -254,9 +254,9 @@ mapnik::layer_descriptor csv_datasource::get_descriptor() const
return desc_;
}
boost::optional<mapnik::datasource_geometry_t> csv_datasource::get_geometry_type_impl(std::istream& stream) const
std::optional<mapnik::datasource_geometry_t> csv_datasource::get_geometry_type_impl(std::istream& stream) const
{
boost::optional<mapnik::datasource_geometry_t> result;
std::optional<mapnik::datasource_geometry_t> result;
if (tree_)
{
int multi_type = 0;
@ -282,7 +282,7 @@ boost::optional<mapnik::datasource_geometry_t> csv_datasource::get_geometry_type
int type = static_cast<int>(*result);
if (multi_type > 0 && multi_type != type)
{
result.reset(mapnik::datasource_geometry_t::Collection);
result = mapnik::datasource_geometry_t::Collection;
return result;
}
multi_type = type;
@ -329,7 +329,7 @@ boost::optional<mapnik::datasource_geometry_t> csv_datasource::get_geometry_type
int type = static_cast<int>(*result);
if (multi_type > 0 && multi_type != type)
{
result.reset(mapnik::datasource_geometry_t::Collection);
result = mapnik::datasource_geometry_t::Collection;
return result;
}
multi_type = type;
@ -347,7 +347,7 @@ boost::optional<mapnik::datasource_geometry_t> csv_datasource::get_geometry_type
return result;
}
boost::optional<mapnik::datasource_geometry_t> csv_datasource::get_geometry_type() const
std::optional<mapnik::datasource_geometry_t> csv_datasource::get_geometry_type() const
{
if (inline_string_.empty())
{

View file

@ -32,12 +32,12 @@
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/datasource_plugin.hpp>
#include "csv_utils.hpp"
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
#include <boost/version.hpp>
#include <boost/geometry/strategies/cartesian/disjoint_box_box.hpp>
#include <boost/geometry/index/rtree.hpp>
@ -45,10 +45,8 @@ MAPNIK_DISABLE_WARNING_POP
// stl
#include <iosfwd>
#include <vector>
#include <string>
#include <mapnik/datasource_plugin.hpp>
template<std::size_t Max, std::size_t Min>
struct csv_linear : boost::geometry::index::linear<Max, Min>
@ -93,18 +91,18 @@ class csv_datasource : public mapnik::datasource,
csv_datasource(mapnik::parameters const& params);
virtual ~csv_datasource();
mapnik::datasource::datasource_t type() const;
mapnik::datasource::datasource_t type() const override;
static const char* name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
mapnik::layer_descriptor get_descriptor() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
mapnik::featureset_ptr features(mapnik::query const& q) const override;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override;
mapnik::box2d<double> envelope() const override;
mapnik::layer_descriptor get_descriptor() const override;
std::optional<mapnik::datasource_geometry_t> get_geometry_type() const override;
private:
void parse_csv(std::istream&);
virtual void add_feature(mapnik::value_integer index, mapnik::csv_line const& values);
boost::optional<mapnik::datasource_geometry_t> get_geometry_type_impl(std::istream&) const;
virtual void add_feature(mapnik::value_integer index, mapnik::csv_line const& values) override;
std::optional<mapnik::datasource_geometry_t> get_geometry_type_impl(std::istream&) const;
mapnik::layer_descriptor desc_;
std::string filename_;

View file

@ -59,8 +59,8 @@ csv_featureset::csv_featureset(std::string const& filename,
, tr_("utf8")
{
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
boost::optional<mapnik::mapped_region_ptr> memory = mapnik::mapped_memory_cache::instance().find(filename, true);
if (memory)
const auto memory = mapnik::mapped_memory_cache::instance().find(filename, true);
if (memory.has_value())
{
mapped_region_ = *memory;
}

View file

@ -57,8 +57,8 @@ csv_index_featureset::csv_index_featureset(std::string const& filename,
{
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
boost::optional<mapnik::mapped_region_ptr> memory = mapnik::mapped_memory_cache::instance().find(filename, true);
if (memory)
const auto memory = mapnik::mapped_memory_cache::instance().find(filename, true);
if (memory.has_value())
{
mapped_region_ = *memory;
}

View file

@ -32,8 +32,6 @@
#include <gdal_version.h>
#include <mutex>
using mapnik::datasource;
using mapnik::parameters;
@ -69,12 +67,12 @@ gdal_datasource::gdal_datasource(parameters const& params)
mapnik::progress_timer __stats__(std::clog, "gdal_datasource::init");
#endif
boost::optional<std::string> file = params.get<std::string>("file");
if (!file)
auto file = params.get<std::string>("file");
if (!file.has_value())
throw datasource_exception("missing <file> parameter");
boost::optional<std::string> base = params.get<std::string>("base");
if (base)
auto base = params.get<std::string>("base");
if (base.has_value())
{
dataset_name_ = *base + "/" + *file;
}
@ -120,8 +118,8 @@ gdal_datasource::gdal_datasource(parameters const& params)
double tr[6];
bool bbox_override = false;
boost::optional<std::string> bbox_s = params.get<std::string>("extent");
if (bbox_s)
const auto bbox_s = params.get<std::string>("extent");
if (bbox_s.has_value())
{
MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: BBox Parameter=" << *bbox_s;
@ -212,9 +210,9 @@ box2d<double> gdal_datasource::envelope() const
return extent_;
}
boost::optional<mapnik::datasource_geometry_t> gdal_datasource::get_geometry_type() const
std::optional<mapnik::datasource_geometry_t> gdal_datasource::get_geometry_type() const
{
return boost::optional<mapnik::datasource_geometry_t>();
return std::nullopt;
}
layer_descriptor gdal_datasource::get_descriptor() const

View file

@ -49,13 +49,13 @@ class gdal_datasource : public mapnik::datasource
public:
gdal_datasource(mapnik::parameters const& params);
virtual ~gdal_datasource();
mapnik::datasource::datasource_t type() const;
mapnik::datasource::datasource_t type() const override;
static const char* name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;
mapnik::featureset_ptr features(mapnik::query const& q) const override;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override;
mapnik::box2d<double> envelope() const override;
std::optional<mapnik::datasource_geometry_t> get_geometry_type() const override;
mapnik::layer_descriptor get_descriptor() const override;
private:
std::unique_ptr<GDALDataset, decltype(&GDALClose)> dataset_;
@ -69,7 +69,7 @@ class gdal_datasource : public mapnik::datasource
double dy_;
int nbands_;
bool shared_dataset_;
boost::optional<double> nodata_value_;
std::optional<double> nodata_value_;
double nodata_tolerance_;
int64_t max_image_area_;
};

View file

@ -86,7 +86,7 @@ gdal_featureset::gdal_featureset(GDALDataset& dataset,
int nbands,
double dx,
double dy,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
double nodata_tolerance,
int64_t max_image_area)
: dataset_(dataset)

View file

@ -24,11 +24,11 @@
#define GDAL_FEATURESET_HPP
// mapnik
#include <mapnik/feature.hpp>
#include <mapnik/featureset.hpp>
#include <mapnik/query.hpp>
#include <mapnik/util/variant.hpp>
// boost
#include <boost/optional.hpp>
#include <optional>
class GDALDataset;
class GDALRasterBand;
@ -60,7 +60,7 @@ class gdal_featureset : public mapnik::Featureset
int nbands,
double dx,
double dy,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
double nodata_tolerance,
int64_t max_image_area);
virtual ~gdal_featureset();
@ -85,7 +85,7 @@ class gdal_featureset : public mapnik::Featureset
double dx_;
double dy_;
int nbands_;
boost::optional<double> nodata_value_;
std::optional<double> nodata_value_;
double nodata_tolerance_;
int64_t max_image_area_;
bool first_;

View file

@ -32,8 +32,8 @@
#include <cmath>
#include <cassert>
#include <vector>
#include <optional>
#include <boost/optional.hpp>
#include <protozero/pbf_reader.hpp>
namespace mapnik {
@ -293,7 +293,7 @@ struct geobuf : util::noncopyable
template<typename T>
geometry::geometry<double>
read_coords(T& reader, geometry_type_e type, boost::optional<std::vector<std::uint32_t>> const& lengths)
read_coords(T& reader, geometry_type_e type, std::optional<std::vector<std::uint32_t>> const& lengths)
{
geometry::geometry<double> geom = geometry::geometry_empty();
switch (type)
@ -405,7 +405,7 @@ struct geobuf : util::noncopyable
template<typename T>
geometry::multi_line_string<double>
read_multi_linestring(T& reader, boost::optional<std::vector<std::uint32_t>> const& lengths)
read_multi_linestring(T& reader, std::optional<std::vector<std::uint32_t>> const& lengths)
{
geometry::multi_line_string<double> multi_line;
multi_line.reserve(!lengths ? 1 : lengths->size());
@ -432,7 +432,7 @@ struct geobuf : util::noncopyable
}
template<typename T>
geometry::polygon<double> read_polygon(T& reader, boost::optional<std::vector<std::uint32_t>> const& lengths)
geometry::polygon<double> read_polygon(T& reader, std::optional<std::vector<std::uint32_t>> const& lengths)
{
geometry::polygon<double> poly;
poly.reserve(!lengths ? 1 : lengths->size());
@ -460,7 +460,7 @@ struct geobuf : util::noncopyable
template<typename T>
geometry::multi_polygon<double> read_multi_polygon(T& reader,
boost::optional<std::vector<std::uint32_t>> const& lengths)
std::optional<std::vector<std::uint32_t>> const& lengths)
{
geometry::multi_polygon<double> multi_poly;
if (!lengths)
@ -496,7 +496,7 @@ struct geobuf : util::noncopyable
{
geometry::geometry<double> geom = geometry::geometry_empty();
geometry_type_e type = Unknown;
boost::optional<std::vector<std::uint32_t>> lengths;
std::optional<std::vector<std::uint32_t>> lengths;
while (reader.next())
{
switch (reader.tag())

View file

@ -79,12 +79,12 @@ geobuf_datasource::geobuf_datasource(parameters const& params)
, features_()
, tree_(nullptr)
{
boost::optional<std::string> file = params.get<std::string>("file");
if (!file)
const auto file = params.get<std::string>("file");
if (!file.has_value())
throw mapnik::datasource_exception("Geobuf Plugin: missing <file> parameter");
boost::optional<std::string> base = params.get<std::string>("base");
if (base)
const auto base = params.get<std::string>("base");
if (base.has_value())
filename_ = *base + "/" + *file;
else
filename_ = *file;
@ -159,9 +159,9 @@ const char* geobuf_datasource::name()
return "geobuf";
}
boost::optional<mapnik::datasource_geometry_t> geobuf_datasource::get_geometry_type() const
std::optional<mapnik::datasource_geometry_t> geobuf_datasource::get_geometry_type() const
{
boost::optional<mapnik::datasource_geometry_t> result;
std::optional<mapnik::datasource_geometry_t> result;
int multi_type = 0;
unsigned num_features = features_.size();
for (unsigned i = 0; i < num_features && i < 5; ++i)
@ -172,7 +172,7 @@ boost::optional<mapnik::datasource_geometry_t> geobuf_datasource::get_geometry_t
int type = static_cast<int>(*result);
if (multi_type > 0 && multi_type != type)
{
result.reset(mapnik::datasource_geometry_t::Collection);
result = mapnik::datasource_geometry_t::Collection;
return result;
}
multi_type = type;

View file

@ -34,11 +34,9 @@
#include <mapnik/unicode.hpp>
#include <mapnik/datasource_plugin.hpp>
// boost
#include <boost/optional.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
#include <boost/version.hpp>
#include <boost/geometry/strategies/cartesian/disjoint_box_box.hpp>
#include <boost/geometry/index/rtree.hpp>
@ -96,13 +94,13 @@ class geobuf_datasource : public mapnik::datasource
// constructor
geobuf_datasource(mapnik::parameters const& params);
virtual ~geobuf_datasource();
mapnik::datasource::datasource_t type() const;
mapnik::datasource::datasource_t type() const override;
static const char* name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
mapnik::layer_descriptor get_descriptor() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
mapnik::featureset_ptr features(mapnik::query const& q) const override;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override;
mapnik::box2d<double> envelope() const override;
mapnik::layer_descriptor get_descriptor() const override;
std::optional<mapnik::datasource_geometry_t> get_geometry_type() const override;
void parse_geobuf(char const* buffer, std::size_t size);
private:

View file

@ -101,14 +101,14 @@ geojson_datasource::geojson_datasource(parameters const& params)
, num_features_to_query_(
std::max(mapnik::value_integer(1), *params.get<mapnik::value_integer>("num_features_to_query", 5)))
{
boost::optional<std::string> inline_string = params.get<std::string>("inline");
const auto inline_string = params.get<std::string>("inline");
if (!inline_string)
{
boost::optional<std::string> file = params.get<std::string>("file");
const auto file = params.get<std::string>("file");
if (!file)
throw mapnik::datasource_exception("GeoJSON Plugin: missing <file> parameter");
boost::optional<std::string> base = params.get<std::string>("base");
const auto base = params.get<std::string>("base");
if (base)
filename_ = *base + "/" + *file;
else
@ -143,9 +143,8 @@ geojson_datasource::geojson_datasource(parameters const& params)
char const* start = file_buffer.c_str();
char const* end = (count == 1) ? start + file_buffer.length() : start;
#else
boost::optional<mapnik::mapped_region_ptr> mapped_region =
mapnik::mapped_memory_cache::instance().find(filename_, false);
if (!mapped_region)
const auto mapped_region = mapnik::mapped_memory_cache::instance().find(filename_, false);
if (!mapped_region.has_value())
{
throw std::runtime_error("could not get file mapping for " + filename_);
}
@ -440,9 +439,9 @@ mapnik::layer_descriptor geojson_datasource::get_descriptor() const
return desc_;
}
boost::optional<mapnik::datasource_geometry_t> geojson_datasource::get_geometry_type() const
std::optional<mapnik::datasource_geometry_t> geojson_datasource::get_geometry_type() const
{
boost::optional<mapnik::datasource_geometry_t> result;
std::optional<mapnik::datasource_geometry_t> result;
int multi_type = 0;
if (has_disk_index_)
{
@ -489,7 +488,7 @@ boost::optional<mapnik::datasource_geometry_t> geojson_datasource::get_geometry_
int type = static_cast<int>(*result);
if (multi_type > 0 && multi_type != type)
{
result.reset(mapnik::datasource_geometry_t::Collection);
result = mapnik::datasource_geometry_t::Collection;
return result;
}
multi_type = type;
@ -507,7 +506,7 @@ boost::optional<mapnik::datasource_geometry_t> geojson_datasource::get_geometry_
int type = static_cast<int>(*result);
if (multi_type > 0 && multi_type != type)
{
result.reset(mapnik::datasource_geometry_t::Collection);
result = mapnik::datasource_geometry_t::Collection;
return result;
}
multi_type = type;
@ -554,7 +553,7 @@ boost::optional<mapnik::datasource_geometry_t> geojson_datasource::get_geometry_
int type = static_cast<int>(*result);
if (multi_type > 0 && multi_type != type)
{
result.reset(mapnik::datasource_geometry_t::Collection);
result = mapnik::datasource_geometry_t::Collection;
return result;
}
multi_type = type;

View file

@ -37,7 +37,6 @@
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
#include <boost/version.hpp>
#include <boost/geometry/strategies/cartesian/disjoint_box_box.hpp>
#include <boost/geometry/index/rtree.hpp>
@ -50,6 +49,7 @@ MAPNIK_DISABLE_WARNING_POP
#include <map>
#include <deque>
#include <functional>
#include <optional>
template<std::size_t Max, std::size_t Min>
struct geojson_linear : boost::geometry::index::linear<Max, Min>
@ -94,13 +94,13 @@ class geojson_datasource : public mapnik::datasource
// constructor
geojson_datasource(mapnik::parameters const& params);
virtual ~geojson_datasource();
mapnik::datasource::datasource_t type() const;
mapnik::datasource::datasource_t type() const override;
static const char* name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
mapnik::layer_descriptor get_descriptor() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
mapnik::featureset_ptr features(mapnik::query const& q) const override;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override;
mapnik::box2d<double> envelope() const override;
mapnik::layer_descriptor get_descriptor() const override;
std::optional<mapnik::datasource_geometry_t> get_geometry_type() const override;
template<typename Iterator>
void parse_geojson(Iterator start, Iterator end);
template<typename Iterator>

View file

@ -50,8 +50,8 @@ geojson_index_featureset::geojson_index_featureset(std::string const& filename,
ctx_(std::make_shared<mapnik::context_type>())
{
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
boost::optional<mapnik::mapped_region_ptr> memory = mapnik::mapped_memory_cache::instance().find(filename, true);
if (memory)
const auto memory = mapnik::mapped_memory_cache::instance().find(filename, true);
if (memory.has_value())
{
mapped_region_ = *memory;
}

View file

@ -45,6 +45,8 @@ MAPNIK_DISABLE_WARNING_POP
#include <sstream>
#include <stdexcept>
#include "ogr_utils.hpp"
using mapnik::datasource;
using mapnik::parameters;
@ -100,8 +102,8 @@ void ogr_datasource::init(mapnik::parameters const& params)
mapnik::progress_timer __stats__(std::clog, "ogr_datasource::init");
#endif
boost::optional<std::string> file = params.get<std::string>("file");
boost::optional<std::string> string = params.get<std::string>("string");
const auto file = params.get<std::string>("file");
auto string = params.get<std::string>("string");
if (!string)
string = params.get<std::string>("inline");
if (!file && !string)
@ -115,7 +117,7 @@ void ogr_datasource::init(mapnik::parameters const& params)
}
else
{
boost::optional<std::string> base = params.get<std::string>("base");
const auto base = params.get<std::string>("base");
if (base)
{
dataset_name_ = *base + "/" + *file;
@ -164,14 +166,14 @@ void ogr_datasource::init(mapnik::parameters const& params)
}
// initialize layer
boost::optional<std::string> layer_by_name = params.get<std::string>("layer");
boost::optional<mapnik::value_integer> layer_by_index = params.get<mapnik::value_integer>("layer_by_index");
boost::optional<std::string> layer_by_sql = params.get<std::string>("layer_by_sql");
const auto layer_by_name = params.get<std::string>("layer");
const auto layer_by_index = params.get<mapnik::value_integer>("layer_by_index");
const auto layer_by_sql = params.get<std::string>("layer_by_sql");
int passed_parameters = 0;
passed_parameters += layer_by_name ? 1 : 0;
passed_parameters += layer_by_index ? 1 : 0;
passed_parameters += layer_by_sql ? 1 : 0;
passed_parameters += layer_by_name.has_value() ? 1 : 0;
passed_parameters += layer_by_index.has_value() ? 1 : 0;
passed_parameters += layer_by_sql.has_value() ? 1 : 0;
if (passed_parameters > 1)
{
@ -267,8 +269,8 @@ void ogr_datasource::init(mapnik::parameters const& params)
OGRLayer* layer = layer_.layer();
// initialize envelope
boost::optional<std::string> ext = params.get<std::string>("extent");
if (ext && !ext->empty())
const auto ext = params.get<std::string>("extent");
if (ext.has_value() && !ext->empty())
{
extent_.from_string(*ext);
}
@ -402,9 +404,9 @@ box2d<double> ogr_datasource::envelope() const
return extent_;
}
boost::optional<mapnik::datasource_geometry_t> ogr_datasource::get_geometry_type() const
std::optional<mapnik::datasource_geometry_t> ogr_datasource::get_geometry_type() const
{
boost::optional<mapnik::datasource_geometry_t> result;
std::optional<mapnik::datasource_geometry_t> result;
if (dataset_ && layer_.is_valid())
{
OGRLayer* layer = layer_.layer();
@ -417,19 +419,19 @@ boost::optional<mapnik::datasource_geometry_t> ogr_datasource::get_geometry_type
{
case wkbPoint:
case wkbMultiPoint:
result.reset(mapnik::datasource_geometry_t::Point);
result = mapnik::datasource_geometry_t::Point;
break;
case wkbLinearRing:
case wkbLineString:
case wkbMultiLineString:
result.reset(mapnik::datasource_geometry_t::LineString);
result = mapnik::datasource_geometry_t::LineString;
break;
case wkbPolygon:
case wkbMultiPolygon:
result.reset(mapnik::datasource_geometry_t::Polygon);
result = mapnik::datasource_geometry_t::Polygon;
break;
case wkbGeometryCollection:
result.reset(mapnik::datasource_geometry_t::Collection);
result = mapnik::datasource_geometry_t::Collection;
break;
case wkbNone:
case wkbUnknown: {
@ -451,19 +453,19 @@ boost::optional<mapnik::datasource_geometry_t> ogr_datasource::get_geometry_type
{
case wkbPoint:
case wkbMultiPoint:
result.reset(mapnik::datasource_geometry_t::Point);
result = mapnik::datasource_geometry_t::Point;
break;
case wkbLinearRing:
case wkbLineString:
case wkbMultiLineString:
result.reset(mapnik::datasource_geometry_t::LineString);
result = mapnik::datasource_geometry_t::LineString;
break;
case wkbPolygon:
case wkbMultiPolygon:
result.reset(mapnik::datasource_geometry_t::Polygon);
result = mapnik::datasource_geometry_t::Polygon;
break;
case wkbGeometryCollection:
result.reset(mapnik::datasource_geometry_t::Collection);
result = mapnik::datasource_geometry_t::Collection;
break;
default:
break;

View file

@ -33,12 +33,7 @@
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/datasource_plugin.hpp>
// boost
#include <boost/optional.hpp>
#include <memory>
// stl
#include <vector>
#include <string>
#include <mapnik/warning.hpp>
@ -47,7 +42,6 @@ MAPNIK_DISABLE_WARNING_PUSH
#include <ogrsf_frmts.h>
MAPNIK_DISABLE_WARNING_POP
#include "ogr_layer_ptr.hpp"
#include "ogr_utils.hpp"
DATASOURCE_PLUGIN_DEF(ogr_datasource_plugin, ogr);
@ -56,13 +50,13 @@ class ogr_datasource : public mapnik::datasource
public:
ogr_datasource(mapnik::parameters const& params);
virtual ~ogr_datasource();
mapnik::datasource::datasource_t type() const;
mapnik::datasource::datasource_t type() const override;
static const char* name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;
mapnik::featureset_ptr features(mapnik::query const& q) const override;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override;
mapnik::box2d<double> envelope() const override;
std::optional<mapnik::datasource_geometry_t> get_geometry_type() const override;
mapnik::layer_descriptor get_descriptor() const override;
private:
void init(mapnik::parameters const& params);

View file

@ -70,8 +70,8 @@ ogr_index_featureset<filterT>::ogr_index_featureset(mapnik::context_ptr const& c
, feature_envelope_()
{
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
boost::optional<mapnik::mapped_region_ptr> memory = mapnik::mapped_memory_cache::instance().find(index_file, true);
if (memory)
const auto memory = mapnik::mapped_memory_cache::instance().find(index_file, true);
if (memory.has_value())
{
boost::interprocess::ibufferstream file(static_cast<char*>((*memory)->get_address()), (*memory)->get_size());
ogr_index<filterT, boost::interprocess::ibufferstream>::query(filter, file, ids_);

View file

@ -104,8 +104,8 @@ pgraster_datasource::pgraster_datasource(parameters const& params)
throw mapnik::datasource_exception("Pgraster Plugin: missing <table> parameter");
}
boost::optional<std::string> ext = params.get<std::string>("extent");
if (ext && !ext->empty())
const auto ext = params.get<std::string>("extent");
if (ext.has_value() && !ext->empty())
{
extent_initialized_ = extent_.from_string(*ext);
}
@ -124,9 +124,8 @@ pgraster_datasource::pgraster_datasource(parameters const& params)
asynchronous_request_ = true;
}
boost::optional<value_integer> initial_size = params.get<value_integer>("initial_size", 1);
boost::optional<mapnik::boolean_type> autodetect_key_field =
params.get<mapnik::boolean_type>("autodetect_key_field", false);
const auto initial_size = params.get<value_integer>("initial_size", 1);
const auto autodetect_key_field = params.get<mapnik::boolean_type>("autodetect_key_field", false);
ConnectionManager::instance().registerPool(creator_, *initial_size, pool_max_size_);
CnxPool_ptr pool = ConnectionManager::instance().getPool(creator_.id());
@ -298,14 +297,12 @@ pgraster_datasource::pgraster_datasource(parameters const& params)
std::ostringstream err;
if (parsed_schema_.empty())
{
err << "Pgraster Plugin: unable to lookup available table"
<< " overviews due to unknown schema";
err << "Pgraster Plugin: unable to lookup available table" << " overviews due to unknown schema";
throw mapnik::datasource_exception(err.str());
}
if (geometryColumn_.empty())
{
err << "Pgraster Plugin: unable to lookup available table"
<< " overviews due to unknown column name";
err << "Pgraster Plugin: unable to lookup available table" << " overviews due to unknown column name";
throw mapnik::datasource_exception(err.str());
}
@ -415,8 +412,7 @@ pgraster_datasource::pgraster_datasource(parameters const& params)
else if (result_rows > 1)
{
std::ostringstream err;
err << "PostGIS Plugin: Error: '"
<< "multi column primary key detected but is not supported";
err << "PostGIS Plugin: Error: '" << "multi column primary key detected but is not supported";
throw mapnik::datasource_exception(err.str());
}
}
@ -489,8 +485,7 @@ pgraster_datasource::pgraster_datasource(parameters const& params)
}
rs_oid->close();
error_s << " for key_field '" << fld_name << "' - "
<< "must be an integer primary key";
error_s << " for key_field '" << fld_name << "' - " << "must be an integer primary key";
rs->close();
throw mapnik::datasource_exception(error_s.str());
@ -1120,8 +1115,8 @@ box2d<double> pgraster_datasource::envelope() const
}
else
{
s << "SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext)"
<< " FROM (SELECT ST_Extent(" << identifier(col) << "::geometry) as ext from ";
s << "SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext)" << " FROM (SELECT ST_Extent("
<< identifier(col) << "::geometry) as ext from ";
if (extent_from_subquery_)
{
@ -1167,7 +1162,7 @@ box2d<double> pgraster_datasource::envelope() const
return extent_;
}
boost::optional<mapnik::datasource_geometry_t> pgraster_datasource::get_geometry_type() const
std::optional<mapnik::datasource_geometry_t> pgraster_datasource::get_geometry_type() const
{
return boost::optional<mapnik::datasource_geometry_t>();
return std::nullopt;
}

View file

@ -80,15 +80,15 @@ class pgraster_datasource : public datasource
public:
pgraster_datasource(const parameters& params);
~pgraster_datasource();
mapnik::datasource::datasource_t type() const;
mapnik::datasource::datasource_t type() const override;
static const char* name();
processor_context_ptr get_context(feature_style_context_map&) const;
featureset_ptr features_with_context(query const& q, processor_context_ptr ctx) const;
featureset_ptr features(query const& q) const;
featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const;
processor_context_ptr get_context(feature_style_context_map&) const override;
featureset_ptr features_with_context(query const& q, processor_context_ptr ctx) const override;
featureset_ptr features(query const& q) const override;
featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const override;
mapnik::box2d<double> envelope() const override;
std::optional<mapnik::datasource_geometry_t> get_geometry_type() const override;
layer_descriptor get_descriptor() const override;
private:
std::string sql_bbox(box2d<double> const& env) const;

View file

@ -42,7 +42,7 @@ extern "C" {
class Connection
{
public:
Connection(std::string const& connection_str, boost::optional<std::string> const& password)
Connection(std::string const& connection_str, std::optional<std::string> const& password)
: cursorId(0)
, closed_(false)
, pending_(false)

View file

@ -30,12 +30,10 @@
#include <mapnik/pool.hpp>
#include <mapnik/util/singleton.hpp>
// boost
#include <boost/optional.hpp>
// stl
#include <string>
#include <memory>
#include <optional>
using mapnik::CreateStatic;
using mapnik::Pool;
@ -78,7 +76,7 @@ class ConnectionCreator
{
// only set fallback_application_name, so that application_name
// can still be overriden with PGAPPNAME environment variable
append_param(connect_str, "fallback_application_name=", "mapnik");
append_param(connect_str, "fallback_application_name=", std::string{"mapnik"});
}
return connect_str;
}
@ -96,18 +94,18 @@ class ConnectionCreator
return true;
}
static bool append_param(std::string& dest, char const* key, boost::optional<std::string> const& opt)
static bool append_param(std::string& dest, char const* key, std::optional<std::string> const& opt)
{
return opt && append_param(dest, key, *opt);
}
boost::optional<std::string> host_;
boost::optional<std::string> port_;
boost::optional<std::string> dbname_;
boost::optional<std::string> user_;
boost::optional<std::string> password_;
boost::optional<std::string> connect_timeout_;
boost::optional<std::string> application_name_;
std::optional<std::string> host_;
std::optional<std::string> port_;
std::optional<std::string> dbname_;
std::optional<std::string> user_;
std::optional<std::string> password_;
std::optional<std::string> connect_timeout_;
std::optional<std::string> application_name_;
};
class ConnectionManager : public singleton<ConnectionManager, CreateStatic>

View file

@ -107,8 +107,8 @@ postgis_datasource::postgis_datasource(parameters const& params)
throw mapnik::datasource_exception("Postgis Plugin: missing <table> parameter");
}
boost::optional<std::string> ext = params.get<std::string>("extent");
if (ext && !ext->empty())
const auto ext = params.get<std::string>("extent");
if (ext.has_value() && !ext->empty())
{
extent_initialized_ = extent_.from_string(*ext);
}
@ -127,19 +127,17 @@ postgis_datasource::postgis_datasource(parameters const& params)
asynchronous_request_ = true;
}
boost::optional<mapnik::value_integer> initial_size = params.get<mapnik::value_integer>("initial_size", 1);
boost::optional<mapnik::boolean_type> autodetect_key_field =
params.get<mapnik::boolean_type>("autodetect_key_field", false);
boost::optional<mapnik::boolean_type> estimate_extent = params.get<mapnik::boolean_type>("estimate_extent", false);
const auto initial_size = params.get<mapnik::value_integer>("initial_size", 1);
const auto autodetect_key_field = params.get<mapnik::boolean_type>("autodetect_key_field", false);
const auto estimate_extent = params.get<mapnik::boolean_type>("estimate_extent", false);
estimate_extent_ = estimate_extent && *estimate_extent;
boost::optional<mapnik::boolean_type> simplify_opt = params.get<mapnik::boolean_type>("simplify_geometries", false);
const auto simplify_opt = params.get<mapnik::boolean_type>("simplify_geometries", false);
simplify_geometries_ = simplify_opt && *simplify_opt;
boost::optional<mapnik::boolean_type> twkb_opt = params.get<mapnik::boolean_type>("twkb_encoding", false);
const auto twkb_opt = params.get<mapnik::boolean_type>("twkb_encoding", false);
twkb_encoding_ = twkb_opt && *twkb_opt;
boost::optional<mapnik::boolean_type> simplify_preserve_opt =
params.get<mapnik::boolean_type>("simplify_dp_preserve", false);
const auto simplify_preserve_opt = params.get<mapnik::boolean_type>("simplify_dp_preserve", false);
simplify_dp_preserve_ = simplify_preserve_opt && *simplify_preserve_opt;
ConnectionManager::instance().registerPool(creator_, *initial_size, pool_max_size_);
@ -310,8 +308,7 @@ postgis_datasource::postgis_datasource(parameters const& params)
else if (result_rows > 1)
{
std::ostringstream err;
err << "PostGIS Plugin: Error: '"
<< "multi column primary key detected but is not supported";
err << "PostGIS Plugin: Error: '" << "multi column primary key detected but is not supported";
throw mapnik::datasource_exception(err.str());
}
}
@ -387,8 +384,7 @@ postgis_datasource::postgis_datasource(parameters const& params)
}
rs_oid->close();
error_s << " for key_field '" << fld_name << "' - "
<< "must be an integer primary key";
error_s << " for key_field '" << fld_name << "' - " << "must be an integer primary key";
rs->close();
throw mapnik::datasource_exception(error_s.str());
@ -1024,8 +1020,8 @@ box2d<double> postgis_datasource::envelope() const
}
else
{
s << "SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext)"
<< " FROM (SELECT ST_Extent(" << identifier(geometryColumn_) << ") as ext from ";
s << "SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext)" << " FROM (SELECT ST_Extent("
<< identifier(geometryColumn_) << ") as ext from ";
if (extent_from_subquery_)
{
@ -1067,9 +1063,9 @@ box2d<double> postgis_datasource::envelope() const
return extent_;
}
boost::optional<mapnik::datasource_geometry_t> postgis_datasource::get_geometry_type() const
std::optional<mapnik::datasource_geometry_t> postgis_datasource::get_geometry_type() const
{
boost::optional<mapnik::datasource_geometry_t> result;
std::optional<mapnik::datasource_geometry_t> result;
CnxPool_ptr pool = ConnectionManager::instance().getPool(creator_.id());
if (pool)
@ -1099,17 +1095,17 @@ boost::optional<mapnik::datasource_geometry_t> postgis_datasource::get_geometry_
g_type = rs->getValue("type");
if (boost::algorithm::contains(g_type, "line"))
{
result.reset(mapnik::datasource_geometry_t::LineString);
result = mapnik::datasource_geometry_t::LineString;
return result;
}
else if (boost::algorithm::contains(g_type, "point"))
{
result.reset(mapnik::datasource_geometry_t::Point);
result = mapnik::datasource_geometry_t::Point;
return result;
}
else if (boost::algorithm::contains(g_type, "polygon"))
{
result.reset(mapnik::datasource_geometry_t::Polygon);
result = mapnik::datasource_geometry_t::Polygon;
return result;
}
else // geometry
@ -1131,8 +1127,8 @@ boost::optional<mapnik::datasource_geometry_t> postgis_datasource::get_geometry_
std::string prev_type("");
s << "SELECT ST_GeometryType(" << identifier(geometryColumn_) << ") AS geom"
<< " FROM " << populate_tokens(table_);
s << "SELECT ST_GeometryType(" << identifier(geometryColumn_) << ") AS geom" << " FROM "
<< populate_tokens(table_);
if (row_limit_ > 0 && row_limit_ < 5)
{
@ -1150,26 +1146,26 @@ boost::optional<mapnik::datasource_geometry_t> postgis_datasource::get_geometry_
if (boost::algorithm::icontains(data, "line"))
{
g_type = "linestring";
result.reset(mapnik::datasource_geometry_t::LineString);
result = mapnik::datasource_geometry_t::LineString;
}
else if (boost::algorithm::icontains(data, "point"))
{
g_type = "point";
result.reset(mapnik::datasource_geometry_t::Point);
result = mapnik::datasource_geometry_t::Point;
}
else if (boost::algorithm::icontains(data, "polygon"))
{
g_type = "polygon";
result.reset(mapnik::datasource_geometry_t::Polygon);
result = mapnik::datasource_geometry_t::Polygon;
}
else // geometry
{
result.reset(mapnik::datasource_geometry_t::Collection);
result = mapnik::datasource_geometry_t::Collection;
return result;
}
if (!prev_type.empty() && g_type != prev_type)
{
result.reset(mapnik::datasource_geometry_t::Collection);
result = mapnik::datasource_geometry_t::Collection;
return result;
}
prev_type = g_type;

View file

@ -69,15 +69,15 @@ class postgis_datasource : public datasource
public:
postgis_datasource(const parameters& params);
~postgis_datasource();
mapnik::datasource::datasource_t type() const;
mapnik::datasource::datasource_t type() const override;
static const char* name();
processor_context_ptr get_context(feature_style_context_map&) const;
featureset_ptr features_with_context(query const& q, processor_context_ptr ctx) const;
featureset_ptr features(query const& q) const;
featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const;
processor_context_ptr get_context(feature_style_context_map&) const override;
featureset_ptr features_with_context(query const& q, processor_context_ptr ctx) const override;
featureset_ptr features(query const& q) const override;
featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const override;
mapnik::box2d<double> envelope() const override;
std::optional<mapnik::datasource_geometry_t> get_geometry_type() const override;
layer_descriptor get_descriptor() const override;
private:
std::string sql_bbox(box2d<double> const& env) const;

View file

@ -55,11 +55,11 @@ raster_datasource::raster_datasource(parameters const& params)
{
MAPNIK_LOG_DEBUG(raster) << "raster_datasource: Initializing...";
boost::optional<std::string> file = params.get<std::string>("file");
const auto file = params.get<std::string>("file");
if (!file)
throw datasource_exception("Raster Plugin: missing <file> parameter ");
boost::optional<std::string> base = params.get<std::string>("base");
const auto base = params.get<std::string>("base");
if (base)
filename_ = *base + "/" + *file;
else
@ -69,15 +69,15 @@ raster_datasource::raster_datasource(parameters const& params)
tile_size_ = *params.get<mapnik::value_integer>("tile_size", 1024);
tile_stride_ = *params.get<mapnik::value_integer>("tile_stride", 1);
boost::optional<std::string> format_from_filename = mapnik::type_from_filename(*file);
const auto format_from_filename = mapnik::type_from_filename(*file);
format_ = *params.get<std::string>("format", format_from_filename ? (*format_from_filename) : "tiff");
boost::optional<mapnik::value_double> lox = params.get<mapnik::value_double>("lox");
boost::optional<mapnik::value_double> loy = params.get<mapnik::value_double>("loy");
boost::optional<mapnik::value_double> hix = params.get<mapnik::value_double>("hix");
boost::optional<mapnik::value_double> hiy = params.get<mapnik::value_double>("hiy");
const auto lox = params.get<mapnik::value_double>("lox");
const auto loy = params.get<mapnik::value_double>("loy");
const auto hix = params.get<mapnik::value_double>("hix");
const auto hiy = params.get<mapnik::value_double>("hiy");
boost::optional<std::string> ext = params.get<std::string>("extent");
const auto ext = params.get<std::string>("extent");
if (lox && loy && hix && hiy)
{
@ -108,8 +108,8 @@ raster_datasource::raster_datasource(parameters const& params)
if (multi_tiles_)
{
boost::optional<mapnik::value_integer> x_width = params.get<mapnik::value_integer>("x_width");
boost::optional<mapnik::value_integer> y_width = params.get<mapnik::value_integer>("y_width");
const auto x_width = params.get<mapnik::value_integer>("x_width");
const auto y_width = params.get<mapnik::value_integer>("y_width");
if (!x_width)
{
@ -121,8 +121,8 @@ raster_datasource::raster_datasource(parameters const& params)
throw datasource_exception("Raster Plugin: y-width parameter not supplied for multi-tiled data source.");
}
width_ = x_width.get() * tile_size_;
height_ = y_width.get() * tile_size_;
width_ = x_width.value() * tile_size_;
height_ = y_width.value() * tile_size_;
}
else
{
@ -174,9 +174,9 @@ mapnik::box2d<double> raster_datasource::envelope() const
return extent_;
}
boost::optional<mapnik::datasource_geometry_t> raster_datasource::get_geometry_type() const
std::optional<mapnik::datasource_geometry_t> raster_datasource::get_geometry_type() const
{
return boost::optional<mapnik::datasource_geometry_t>();
return std::nullopt;
}
layer_descriptor raster_datasource::get_descriptor() const

View file

@ -33,14 +33,6 @@
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/datasource_plugin.hpp>
// boost
#include <boost/optional.hpp>
#include <memory>
// stl
#include <vector>
#include <string>
DATASOURCE_PLUGIN_DEF(raster_datasource_plugin, raster);
class raster_datasource : public mapnik::datasource
@ -48,13 +40,13 @@ class raster_datasource : public mapnik::datasource
public:
raster_datasource(const mapnik::parameters& params);
virtual ~raster_datasource();
datasource::datasource_t type() const;
datasource::datasource_t type() const override;
static const char* name();
mapnik::featureset_ptr features(const mapnik::query& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;
mapnik::featureset_ptr features(const mapnik::query& q) const override;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override;
mapnik::box2d<double> envelope() const override;
std::optional<mapnik::datasource_geometry_t> get_geometry_type() const override;
mapnik::layer_descriptor get_descriptor() const override;
bool log_enabled() const;
private:

View file

@ -72,12 +72,12 @@ shape_datasource::shape_datasource(parameters const& params)
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::init");
#endif
boost::optional<std::string> file = params.get<std::string>("file");
if (!file)
const auto file = params.get<std::string>("file");
if (!file.has_value())
throw datasource_exception("Shape Plugin: missing <file> parameter");
boost::optional<std::string> base = params.get<std::string>("base");
if (base)
const auto base = params.get<std::string>("base");
if (base.has_value())
shape_name_ = *base + "/" + *file;
else
shape_name_ = *file;
@ -307,13 +307,13 @@ box2d<double> shape_datasource::envelope() const
return extent_;
}
boost::optional<mapnik::datasource_geometry_t> shape_datasource::get_geometry_type() const
std::optional<mapnik::datasource_geometry_t> shape_datasource::get_geometry_type() const
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::get_geometry_type");
#endif
boost::optional<mapnik::datasource_geometry_t> result;
std::optional<mapnik::datasource_geometry_t> result;
switch (shape_type_)
{
case shape_io::shape_point:
@ -322,19 +322,19 @@ boost::optional<mapnik::datasource_geometry_t> shape_datasource::get_geometry_ty
case shape_io::shape_multipoint:
case shape_io::shape_multipointm:
case shape_io::shape_multipointz: {
result.reset(mapnik::datasource_geometry_t::Point);
result = mapnik::datasource_geometry_t::Point;
break;
}
case shape_io::shape_polyline:
case shape_io::shape_polylinem:
case shape_io::shape_polylinez: {
result.reset(mapnik::datasource_geometry_t::LineString);
result = mapnik::datasource_geometry_t::LineString;
break;
}
case shape_io::shape_polygon:
case shape_io::shape_polygonm:
case shape_io::shape_polygonz: {
result.reset(mapnik::datasource_geometry_t::Polygon);
result = mapnik::datasource_geometry_t::Polygon;
break;
}
default:

View file

@ -34,12 +34,7 @@
#include <mapnik/value/types.hpp>
#include <mapnik/datasource_plugin.hpp>
// boost
#include <boost/optional.hpp>
#include <memory>
// stl
#include <vector>
#include <string>
#include "shape_io.hpp"
@ -58,13 +53,13 @@ class shape_datasource : public datasource
public:
shape_datasource(parameters const& params);
virtual ~shape_datasource();
datasource::datasource_t type() const;
datasource::datasource_t type() const override;
static const char* name();
featureset_ptr features(query const& q) const;
featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const;
box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const;
featureset_ptr features(query const& q) const override;
featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const override;
box2d<double> envelope() const override;
std::optional<mapnik::datasource_geometry_t> get_geometry_type() const override;
layer_descriptor get_descriptor() const override;
private:
void init(shape_io& shape);

View file

@ -86,11 +86,11 @@ sqlite_datasource::sqlite_datasource(parameters const& params)
mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::init");
#endif
boost::optional<std::string> file = params.get<std::string>("file");
const auto file = params.get<std::string>("file");
if (!file)
throw datasource_exception("Sqlite Plugin: missing <file> parameter");
boost::optional<std::string> base = params.get<std::string>("base");
const auto base = params.get<std::string>("base");
if (base)
dataset_name_ = *base + "/" + *file;
else
@ -106,12 +106,12 @@ sqlite_datasource::sqlite_datasource(parameters const& params)
// TODO - remove this option once all datasources have an indexing api
bool auto_index = *params.get<mapnik::boolean_type>("auto_index", true);
boost::optional<std::string> ext = params.get<std::string>("extent");
if (ext)
const auto ext = params.get<std::string>("extent");
if (ext.has_value())
extent_initialized_ = extent_.from_string(*ext);
boost::optional<std::string> wkb = params.get<std::string>("wkb_format");
if (wkb)
const auto wkb = params.get<std::string>("wkb_format");
if (wkb.has_value())
{
if (*wkb == "spatialite")
{
@ -139,14 +139,14 @@ sqlite_datasource::sqlite_datasource(parameters const& params)
// databases are relative to directory containing dataset_name_. Sqlite
// will default to attaching from cwd. Typicaly usage means that the
// map loader will produce full paths here.
boost::optional<std::string> attachdb = params.get<std::string>("attachdb");
if (attachdb)
const auto attachdb = params.get<std::string>("attachdb");
if (attachdb.has_value())
{
parse_attachdb(*attachdb);
}
boost::optional<std::string> initdb = params.get<std::string>("initdb");
if (initdb)
const auto initdb = params.get<std::string>("initdb");
if (initdb.has_value())
{
init_statements_.push_back(*initdb);
}
@ -154,11 +154,11 @@ sqlite_datasource::sqlite_datasource(parameters const& params)
// now actually create the connection and start executing setup sql
dataset_ = std::make_shared<sqlite_connection>(dataset_name_);
boost::optional<mapnik::value_integer> table_by_index = params.get<mapnik::value_integer>("table_by_index");
const auto table_by_index = params.get<mapnik::value_integer>("table_by_index");
int passed_parameters = 0;
passed_parameters += params.get<std::string>("table") ? 1 : 0;
passed_parameters += table_by_index ? 1 : 0;
passed_parameters += table_by_index.has_value() ? 1 : 0;
if (passed_parameters > 1)
{
@ -426,13 +426,13 @@ box2d<double> sqlite_datasource::envelope() const
return extent_;
}
boost::optional<mapnik::datasource_geometry_t> sqlite_datasource::get_geometry_type() const
std::optional<mapnik::datasource_geometry_t> sqlite_datasource::get_geometry_type() const
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::get_geometry_type");
#endif
boost::optional<mapnik::datasource_geometry_t> result;
std::optional<mapnik::datasource_geometry_t> result;
if (dataset_)
{
// get geometry type by querying first features
@ -470,7 +470,7 @@ boost::optional<mapnik::datasource_geometry_t> sqlite_datasource::get_geometry_t
int type = static_cast<int>(*result);
if (multi_type > 0 && multi_type != type)
{
result.reset(mapnik::datasource_geometry_t::Collection);
result = mapnik::datasource_geometry_t::Collection;
return result;
}
multi_type = type;

View file

@ -35,13 +35,10 @@
#include <mapnik/value/types.hpp>
#include <mapnik/datasource_plugin.hpp>
// boost
#include <boost/optional.hpp>
#include <memory>
// stl
#include <vector>
#include <string>
#include <memory>
// sqlite
#include "sqlite_connection.hpp"
@ -53,13 +50,13 @@ class sqlite_datasource : public mapnik::datasource
public:
sqlite_datasource(mapnik::parameters const& params);
virtual ~sqlite_datasource();
datasource::datasource_t type() const;
datasource::datasource_t type() const override;
static const char* name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;
mapnik::featureset_ptr features(mapnik::query const& q) const override;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override;
mapnik::box2d<double> envelope() const override;
std::optional<mapnik::datasource_geometry_t> get_geometry_type() const override;
mapnik::layer_descriptor get_descriptor() const override;
private:
// Fill init_statements with any statements

View file

@ -23,9 +23,6 @@
#include "topojson_datasource.hpp"
#include "topojson_featureset.hpp"
#include <fstream>
#include <algorithm>
// boost
#include <boost/algorithm/string.hpp>
@ -132,18 +129,18 @@ topojson_datasource::topojson_datasource(parameters const& params)
, tr_(new mapnik::transcoder(*params.get<std::string>("encoding", "utf-8")))
, tree_(nullptr)
{
boost::optional<std::string> inline_string = params.get<std::string>("inline");
const auto inline_string = params.get<std::string>("inline");
if (inline_string)
{
inline_string_ = *inline_string;
}
else
{
boost::optional<std::string> file = params.get<std::string>("file");
const auto file = params.get<std::string>("file");
if (!file)
throw mapnik::datasource_exception("TopoJSON Plugin: missing <file> parameter");
boost::optional<std::string> base = params.get<std::string>("base");
const auto base = params.get<std::string>("base");
if (base)
filename_ = *base + "/" + *file;
else
@ -225,9 +222,9 @@ const char* topojson_datasource::name()
return "topojson";
}
boost::optional<mapnik::datasource_geometry_t> topojson_datasource::get_geometry_type() const
std::optional<mapnik::datasource_geometry_t> topojson_datasource::get_geometry_type() const
{
boost::optional<mapnik::datasource_geometry_t> result;
std::optional<mapnik::datasource_geometry_t> result;
int multi_type = 0;
std::size_t num_features = topo_.geometries.size();
for (std::size_t i = 0; i < num_features && i < 5; ++i)
@ -238,12 +235,12 @@ boost::optional<mapnik::datasource_geometry_t> topojson_datasource::get_geometry
{
if (multi_type > 0 && multi_type != type)
{
result.reset(mapnik::datasource_geometry_t::Collection);
result = mapnik::datasource_geometry_t::Collection;
return result;
}
else
{
result.reset(static_cast<mapnik::datasource_geometry_t>(type));
result = static_cast<mapnik::datasource_geometry_t>(type);
}
multi_type = type;
}

View file

@ -38,7 +38,6 @@
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry.hpp>
#include <boost/version.hpp>
@ -47,11 +46,10 @@ MAPNIK_DISABLE_WARNING_PUSH
MAPNIK_DISABLE_WARNING_POP
// stl
#include <vector>
#include <string>
#include <map>
#include <deque>
#include <memory>
#include <optional>
DATASOURCE_PLUGIN_DEF(topojson_datasource_plugin, topojson);
@ -66,13 +64,13 @@ class topojson_datasource : public mapnik::datasource
// constructor
topojson_datasource(mapnik::parameters const& params);
virtual ~topojson_datasource();
mapnik::datasource::datasource_t type() const;
mapnik::datasource::datasource_t type() const override;
static const char* name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
mapnik::layer_descriptor get_descriptor() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
mapnik::featureset_ptr features(mapnik::query const& q) const override;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const override;
mapnik::box2d<double> envelope() const override;
mapnik::layer_descriptor get_descriptor() const override;
std::optional<mapnik::datasource_geometry_t> get_geometry_type() const override;
template<typename T>
void parse_topojson(T const& buffer);

View file

@ -56,12 +56,6 @@ MAPNIK_DISABLE_WARNING_PUSH
#include "agg_span_image_filter_rgba.h"
MAPNIK_DISABLE_WARNING_POP
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
// stl
#include <cmath>
@ -167,7 +161,7 @@ void agg_renderer<T0, T1>::setup(Map const& m, buffer_type& pixmap)
buffers_.emplace(pixmap);
mapnik::set_premultiplied_alpha(pixmap, true);
boost::optional<color> const& bg = m.background();
auto&& bg = m.background();
if (bg)
{
if (bg->alpha() < 255)
@ -184,7 +178,7 @@ void agg_renderer<T0, T1>::setup(Map const& m, buffer_type& pixmap)
}
}
boost::optional<std::string> const& image_filename = m.background_image();
auto&& image_filename = m.background_image();
if (image_filename)
{
// NOTE: marker_cache returns premultiplied image, if needed
@ -229,7 +223,7 @@ void agg_renderer<T0, T1>::start_layer_processing(layer const& lay, box2d<double
}
common_.query_extent_ = query_extent;
boost::optional<box2d<double>> const& maximum_extent = lay.maximum_extent();
auto&& maximum_extent = lay.maximum_extent();
if (maximum_extent)
{
common_.query_extent_.clip(*maximum_extent);

View file

@ -118,13 +118,13 @@ struct setup_marker_visitor
void operator()(marker_rgba8 const& marker) const
{
mapnik::image_rgba8 const& bg_image = marker.get_data();
std::size_t w = bg_image.width();
std::size_t h = bg_image.height();
const std::size_t w = bg_image.width();
const std::size_t h = bg_image.height();
if (w > 0 && h > 0)
{
// repeat background-image both vertically and horizontally
std::size_t x_steps = std::size_t(std::ceil(common_.width_ / double(w)));
std::size_t y_steps = std::size_t(std::ceil(common_.height_ / double(h)));
const std::size_t x_steps = std::size_t(std::ceil(common_.width_ / double(w)));
const std::size_t y_steps = std::size_t(std::ceil(common_.height_ / double(h)));
for (std::size_t x = 0; x < x_steps; ++x)
{
for (std::size_t y = 0; y < y_steps; ++y)
@ -144,16 +144,16 @@ struct setup_marker_visitor
template<typename T>
void cairo_renderer<T>::setup(Map const& map)
{
boost::optional<color> bg = m_.background();
if (bg)
const auto bg = m_.background();
if (bg.has_value())
{
cairo_save_restore guard(context_);
context_.set_color(*bg);
context_.set_operator(composite_mode_e::src);
context_.paint();
}
boost::optional<std::string> const& image_filename = map.background_image();
if (image_filename)
auto&& image_filename = map.background_image();
if (image_filename.has_value())
{
// NOTE: marker_cache returns premultiplied image, if needed
std::shared_ptr<mapnik::marker const> bg_marker = mapnik::marker_cache::instance().find(*image_filename, true);
@ -166,7 +166,7 @@ template<typename T>
void cairo_renderer<T>::start_map_processing(Map const& map)
{
MAPNIK_LOG_DEBUG(cairo_renderer) << "cairo_renderer: Start map processing bbox=" << map.get_current_extent();
box2d<double> bounds = common_.t_.forward(common_.t_.extent());
const box2d<double> bounds = common_.t_.forward(common_.t_.extent());
context_.rectangle(bounds.minx(), bounds.miny(), bounds.maxx(), bounds.maxy());
context_.clip();
}

View file

@ -53,8 +53,8 @@ void save_to_cairo_file(mapnik::Map const& map,
double scale_factor,
double scale_denominator)
{
boost::optional<std::string> type = type_from_filename(filename);
if (type)
const auto type = type_from_filename(filename);
if (type.has_value())
{
save_to_cairo_file(map, filename, *type, scale_factor, scale_denominator);
}

View file

@ -59,8 +59,8 @@ datasource_cache::~datasource_cache() {}
datasource_ptr datasource_cache::create(parameters const& params)
{
boost::optional<std::string> type = params.get<std::string>("type");
if (!type)
const auto type = params.get<std::string>("type");
if (!type.has_value())
{
throw config_error(std::string("Could not create datasource. Required ") + "parameter 'type' is missing");
}

View file

@ -154,7 +154,7 @@ void init_datasource_cache_static()
datasource_ptr create_static_datasource(parameters const& params)
{
boost::optional<std::string> type = params.get<std::string>("type");
const auto type = params.get<std::string>("type");
datasource_map::iterator it = ds_map.find(*type);
if (it != ds_map.end())
{

View file

@ -23,12 +23,6 @@
#include <mapnik/feature_kv_iterator.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
namespace mapnik {
feature_kv_iterator::feature_kv_iterator(feature_impl const& f, bool begin)

View file

@ -21,8 +21,6 @@
*****************************************************************************/
#include <algorithm>
#include <string>
#include <unordered_map>
#include <mapnik/feature_type_style.hpp>
#include <mapnik/rule.hpp>
#include <mapnik/enumeration.hpp>
@ -150,7 +148,7 @@ void feature_type_style::set_comp_op(composite_mode_e _comp_op)
comp_op_ = _comp_op;
}
boost::optional<composite_mode_e> feature_type_style::comp_op() const
std::optional<composite_mode_e> feature_type_style::comp_op() const
{
return comp_op_;
}

View file

@ -32,7 +32,6 @@
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/optional.hpp>
// freetype2
extern "C" {
@ -45,7 +44,6 @@ MAPNIK_DISABLE_WARNING_POP
// stl
#include <algorithm>
#include <stdexcept>
namespace mapnik {
template class MAPNIK_DECL singleton<freetype_engine, CreateUsingNew>;
@ -481,7 +479,7 @@ face_set_ptr face_manager::get_face_set(font_set const& fset)
return face_set;
}
face_set_ptr face_manager::get_face_set(std::string const& name, boost::optional<font_set> fset)
face_set_ptr face_manager::get_face_set(std::string const& name, std::optional<font_set> fset)
{
if (fset && fset->size() > 0)
{

View file

@ -28,15 +28,8 @@
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
MAPNIK_DISABLE_WARNING_POP
namespace mapnik {
namespace geometry {

View file

@ -123,8 +123,8 @@ void grid_renderer<T>::start_layer_processing(layer const& lay, box2d<double> co
common_.detector_->clear();
}
common_.query_extent_ = query_extent;
boost::optional<box2d<double>> const& maximum_extent = lay.maximum_extent();
if (maximum_extent)
auto&& maximum_extent = lay.maximum_extent();
if (maximum_extent.has_value())
{
common_.query_extent_.clip(*maximum_extent);
}
@ -207,7 +207,6 @@ struct grid_render_marker_visitor
else
{
image_rgba8 target(data.width(), data.height());
boost::optional<double> nodata;
mapnik::scale_image_agg(target,
data,
SCALING_NEAR,
@ -216,7 +215,7 @@ struct grid_render_marker_visitor
0.0,
0.0,
1.0,
nodata); // TODO: is 1.0 a valid default here, and do we even care in grid_renderer
std::nullopt); // TODO: is 1.0 a valid default here, and do we even care in grid_renderer
// what the image looks like?
pixmap_.set_rectangle(feature_.id(),
target,

View file

@ -64,24 +64,24 @@ static const comp_op_lookup_type comp_lookup =
_color,
"color")(_value, "value")(linear_dodge, "linear-dodge")(linear_burn, "linear-burn")(divide, "divide");
boost::optional<composite_mode_e> comp_op_from_string(std::string const& name)
std::optional<composite_mode_e> comp_op_from_string(std::string const& name)
{
boost::optional<composite_mode_e> mode;
std::optional<composite_mode_e> mode;
comp_op_lookup_type::right_const_iterator right_iter = comp_lookup.right.find(name);
if (right_iter != comp_lookup.right.end())
{
mode.reset(right_iter->second);
mode = right_iter->second;
}
return mode;
}
boost::optional<std::string> comp_op_to_string(composite_mode_e comp_op)
std::optional<std::string> comp_op_to_string(composite_mode_e comp_op)
{
boost::optional<std::string> mode;
std::optional<std::string> mode;
comp_op_lookup_type::left_const_iterator left_iter = comp_lookup.left.find(comp_op);
if (left_iter != comp_lookup.left.end())
{
mode.reset(left_iter->second);
mode = left_iter->second;
}
return mode;
}

View file

@ -42,7 +42,7 @@ namespace x3 = boost::spirit::x3;
using x3::lit;
using x3::ascii::char_;
using pair_type = std::pair<std::string, boost::optional<std::string>>;
using pair_type = std::pair<std::string, std::optional<std::string>>;
x3::rule<class image_options, image_options_map> const image_options("image options");
x3::rule<class key_value, pair_type> const key_value("key_value");

View file

@ -27,20 +27,19 @@
namespace mapnik {
inline boost::optional<std::string> type_from_bytes(char const* data, size_t size)
inline std::optional<std::string> type_from_bytes(char const* data, size_t size)
{
using result_type = boost::optional<std::string>;
unsigned char const* header = reinterpret_cast<unsigned char const*>(data);
if (size >= 4)
{
unsigned int magic = (header[0] << 24) | (header[1] << 16) | (header[2] << 8) | header[3];
if (magic == 0x89504E47U)
{
return result_type("png");
return "png";
}
else if (magic == 0x49492A00U || magic == 0x4D4D002AU)
{
return result_type("tiff");
return "tiff";
}
}
if (size >= 2)
@ -48,7 +47,7 @@ inline boost::optional<std::string> type_from_bytes(char const* data, size_t siz
unsigned int magic = ((header[0] << 8) | header[1]) & 0xffff;
if (magic == 0xffd8)
{
return result_type("jpeg");
return "jpeg";
}
}
@ -57,16 +56,16 @@ inline boost::optional<std::string> type_from_bytes(char const* data, size_t siz
if (header[0] == 'R' && header[1] == 'I' && header[2] == 'F' && header[3] == 'F' && header[8] == 'W' &&
header[9] == 'E' && header[10] == 'B' && header[11] == 'P')
{
return result_type("webp");
return "webp";
}
}
return result_type();
return std::nullopt;
}
image_reader* get_image_reader(char const* data, size_t size)
{
boost::optional<std::string> type = type_from_bytes(data, size);
if (type)
const auto type = type_from_bytes(data, size);
if (type.has_value())
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");
@ -79,8 +78,8 @@ image_reader* get_image_reader(std::string const& filename, std::string const& t
image_reader* get_image_reader(std::string const& filename)
{
boost::optional<std::string> type = type_from_filename(filename);
if (type)
const auto type = type_from_filename(filename);
if (type.has_value())
{
return factory<image_reader, std::string, std::string const&>::instance().create_object(*type, filename);
}

View file

@ -66,26 +66,24 @@ static const scaling_method_lookup_type scaling_lookup =
SCALING_SINC,
"sinc")(SCALING_LANCZOS, "lanczos")(SCALING_BLACKMAN, "blackman");
boost::optional<scaling_method_e> scaling_method_from_string(std::string const& name)
std::optional<scaling_method_e> scaling_method_from_string(std::string const& name)
{
boost::optional<scaling_method_e> mode;
scaling_method_lookup_type::right_const_iterator right_iter = scaling_lookup.right.find(name);
if (right_iter != scaling_lookup.right.end())
{
mode.reset(right_iter->second);
return right_iter->second;
}
return mode;
return std::nullopt;
}
boost::optional<std::string> scaling_method_to_string(scaling_method_e scaling_method)
std::optional<std::string> scaling_method_to_string(scaling_method_e scaling_method)
{
boost::optional<std::string> mode;
scaling_method_lookup_type::left_const_iterator left_iter = scaling_lookup.left.find(scaling_method);
if (left_iter != scaling_lookup.left.end())
{
mode.reset(left_iter->second);
return left_iter->second;
}
return mode;
return std::nullopt;
}
template<typename T>
@ -97,7 +95,7 @@ void scale_image_agg(T& target,
double x_off_f,
double y_off_f,
double filter_factor,
boost::optional<double> const& nodata_value)
std::optional<double> const& nodata_value)
{
// "the image filters should work namely in the premultiplied color space"
// http://old.nabble.com/Re:--AGG--Basic-image-transformations-p1110665.html
@ -157,8 +155,8 @@ void scale_image_agg(T& target,
using span_gen_type = typename detail::agg_scaling_traits<image_type>::span_image_resample_affine;
agg::image_filter_lut filter;
detail::set_scaling_method(filter, scaling_method, filter_factor);
boost::optional<typename span_gen_type::value_type> nodata;
if (nodata_value)
std::optional<typename span_gen_type::value_type> nodata;
if (nodata_value.has_value())
{
nodata.emplace(safe_cast<typename span_gen_type::value_type>(*nodata_value));
}
@ -175,7 +173,7 @@ template MAPNIK_DECL void scale_image_agg(image_rgba8&,
double,
double,
double,
boost::optional<double> const&);
std::optional<double> const&);
template MAPNIK_DECL void scale_image_agg(image_gray8&,
image_gray8 const&,
@ -185,7 +183,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray8&,
double,
double,
double,
boost::optional<double> const&);
std::optional<double> const&);
template MAPNIK_DECL void scale_image_agg(image_gray8s&,
image_gray8s const&,
@ -195,7 +193,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray8s&,
double,
double,
double,
boost::optional<double> const&);
std::optional<double> const&);
template MAPNIK_DECL void scale_image_agg(image_gray16&,
image_gray16 const&,
@ -205,7 +203,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray16&,
double,
double,
double,
boost::optional<double> const&);
std::optional<double> const&);
template MAPNIK_DECL void scale_image_agg(image_gray16s&,
image_gray16s const&,
@ -215,7 +213,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray16s&,
double,
double,
double,
boost::optional<double> const&);
std::optional<double> const&);
template MAPNIK_DECL void scale_image_agg(image_gray32&,
image_gray32 const&,
@ -225,7 +223,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray32&,
double,
double,
double,
boost::optional<double> const&);
std::optional<double> const&);
template MAPNIK_DECL void scale_image_agg(image_gray32s&,
image_gray32s const&,
@ -235,7 +233,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray32s&,
double,
double,
double,
boost::optional<double> const&);
std::optional<double> const&);
template MAPNIK_DECL void scale_image_agg(image_gray32f&,
image_gray32f const&,
@ -245,7 +243,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray32f&,
double,
double,
double,
boost::optional<double> const&);
std::optional<double> const&);
template MAPNIK_DECL void scale_image_agg(image_gray64&,
image_gray64 const&,
@ -255,7 +253,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray64&,
double,
double,
double,
boost::optional<double> const&);
std::optional<double> const&);
template MAPNIK_DECL void scale_image_agg(image_gray64s&,
image_gray64s const&,
@ -265,7 +263,7 @@ template MAPNIK_DECL void scale_image_agg(image_gray64s&,
double,
double,
double,
boost::optional<double> const&);
std::optional<double> const&);
template MAPNIK_DECL void scale_image_agg(image_gray64f&,
image_gray64f const&,
@ -275,5 +273,5 @@ template MAPNIK_DECL void scale_image_agg(image_gray64f&,
double,
double,
double,
boost::optional<double> const&);
std::optional<double> const&);
} // namespace mapnik

View file

@ -313,8 +313,8 @@ MAPNIK_DECL void
template<typename T>
MAPNIK_DECL void save_to_file(T const& image, std::string const& filename)
{
boost::optional<std::string> type = type_from_filename(filename);
if (type)
const auto type = type_from_filename(filename);
if (type.has_value())
{
save_to_file<T>(image, filename, *type);
}
@ -325,8 +325,8 @@ MAPNIK_DECL void save_to_file(T const& image, std::string const& filename)
template<typename T>
MAPNIK_DECL void save_to_file(T const& image, std::string const& filename, rgba_palette const& palette)
{
boost::optional<std::string> type = type_from_filename(filename);
if (type)
const auto type = type_from_filename(filename);
if (type.has_value())
{
save_to_file<T>(image, filename, *type, palette);
}
@ -425,11 +425,11 @@ struct is_solid_visitor
if (image.size() > 0)
{
pixel_type const first_p = *image.begin();
auto itr = std::find_if(/*std::execution::par_unseq,*/ // still missing on ubuntu with
// clang++10/libc++ (!)
image.begin(),
image.end(),
[first_p](pixel_type const p) { return first_p != p; });
const auto itr = std::find_if(/*std::execution::par_unseq,*/ // still missing on ubuntu with
// clang++10/libc++ (!)
image.begin(),
image.end(),
[first_p](auto&& p) { return first_p != p; });
return (itr == image.end());
}
return true;

View file

@ -75,7 +75,7 @@ class jpeg_reader : public image_reader
~jpeg_reader();
unsigned width() const final;
unsigned height() const final;
boost::optional<box2d<double>> bounding_box() const final;
std::optional<box2d<double>> bounding_box() const override final;
inline bool has_alpha() const final { return false; }
void read(unsigned x, unsigned y, image_rgba8& image) final;
image_any read(unsigned x, unsigned y, unsigned width, unsigned height) final;
@ -260,9 +260,9 @@ unsigned jpeg_reader<T>::height() const
}
template<typename T>
boost::optional<box2d<double>> jpeg_reader<T>::bounding_box() const
std::optional<box2d<double>> jpeg_reader<T>::bounding_box() const
{
return boost::optional<box2d<double>>();
return std::nullopt;
}
template<typename T>
@ -289,8 +289,8 @@ void jpeg_reader<T>::read(unsigned x0, unsigned y0, image_rgba8& image)
row_stride = cinfo.output_width * cinfo.output_components;
buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo, JPOOL_IMAGE, row_stride, 1);
unsigned w = std::min(unsigned(image.width()), width_ - x0);
unsigned h = std::min(unsigned(image.height()), height_ - y0);
const unsigned w = std::min(unsigned(image.width()), width_ - x0);
const unsigned h = std::min(unsigned(image.height()), height_ - y0);
const std::unique_ptr<unsigned int[]> out_row(new unsigned int[w]);
unsigned row = 0;

View file

@ -227,10 +227,10 @@ void layer::set_datasource(datasource_ptr const& ds)
void layer::set_maximum_extent(box2d<double> const& box)
{
maximum_extent_.reset(box);
maximum_extent_ = box;
}
boost::optional<box2d<double>> const& layer::maximum_extent() const
std::optional<box2d<double>> const& layer::maximum_extent() const
{
return maximum_extent_;
}
@ -242,10 +242,10 @@ void layer::reset_maximum_extent()
void layer::set_buffer_size(int size)
{
buffer_size_.reset(size);
buffer_size_ = size;
}
boost::optional<int> const& layer::buffer_size() const
std::optional<int> const& layer::buffer_size() const
{
return buffer_size_;
}
@ -297,7 +297,7 @@ void layer::set_comp_op(composite_mode_e comp_op)
comp_op_ = comp_op;
}
boost::optional<composite_mode_e> layer::comp_op() const
std::optional<composite_mode_e> layer::comp_op() const
{
return comp_op_;
}

View file

@ -63,7 +63,6 @@
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore.hpp>
#include <boost/optional.hpp>
#include <boost/tokenizer.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
@ -82,7 +81,7 @@ MAPNIK_DISABLE_WARNING_POP
using boost::tokenizer;
namespace mapnik {
using boost::optional;
using std::optional;
using util::name_to_int;
using util::operator"" _case;
@ -135,10 +134,10 @@ class map_parser : util::noncopyable
void ensure_font_face(std::string const& face_name);
void find_unused_nodes(xml_node const& root);
void find_unused_nodes_recursive(xml_node const& node, std::string& error_text);
std::string ensure_relative_to_xml(boost::optional<std::string> const& opt_path);
std::string ensure_relative_to_xml(std::optional<std::string> const& opt_path);
void ensure_exists(std::string const& file_path);
void check_styles(Map const& map);
boost::optional<color> get_opt_color_attr(boost::property_tree::ptree const& node, std::string const& name);
std::optional<color> get_opt_color_attr(boost::property_tree::ptree const& node, std::string const& name);
bool strict_;
std::string filename_;
@ -849,15 +848,15 @@ void map_parser::parse_layer(Parent& parent, xml_node const& node)
}
}
boost::optional<std::string> base_param = params.get<std::string>("base");
boost::optional<std::string> file_param = params.get<std::string>("file");
const auto base_param = params.get<std::string>("base");
const auto file_param = params.get<std::string>("file");
if (base_param)
if (base_param.has_value())
{
params["base"] = ensure_relative_to_xml(base_param);
}
else if (file_param)
else if (file_param.has_value())
{
params["file"] = ensure_relative_to_xml(file_param);
}
@ -1461,8 +1460,8 @@ void map_parser::parse_raster_symbolizer(rule& rule, xml_node const& node)
}
else
{
boost::optional<scaling_method_e> method = scaling_method_from_string(scaling_method);
if (method)
const auto method = scaling_method_from_string(scaling_method);
if (method.has_value())
{
put(raster_sym, keys::scaling, *method);
}
@ -1753,7 +1752,7 @@ void map_parser::ensure_font_face(std::string const& face_name)
}
}
std::string map_parser::ensure_relative_to_xml(boost::optional<std::string> const& opt_path)
std::string map_parser::ensure_relative_to_xml(std::optional<std::string> const& opt_path)
{
if (marker_cache::instance().is_uri(*opt_path))
return *opt_path;

View file

@ -427,7 +427,7 @@ int Map::buffer_size() const
return buffer_size_;
}
boost::optional<color> const& Map::background() const
std::optional<color> const& Map::background() const
{
return background_;
}
@ -437,7 +437,7 @@ void Map::set_background(color const& c)
background_ = c;
}
boost::optional<std::string> const& Map::background_image() const
std::optional<std::string> const& Map::background_image() const
{
return background_image_;
}
@ -469,10 +469,10 @@ void Map::set_background_image_opacity(float opacity)
void Map::set_maximum_extent(box2d<double> const& box)
{
maximum_extent_.reset(box);
maximum_extent_ = box;
}
boost::optional<box2d<double>> const& Map::maximum_extent() const
std::optional<box2d<double>> const& Map::maximum_extent() const
{
return maximum_extent_;
}

View file

@ -63,19 +63,17 @@ bool mapped_memory_cache::remove(std::string const& key)
return cache_.erase(key) > 0;
}
boost::optional<mapped_region_ptr> mapped_memory_cache::find(std::string const& uri, bool update_cache)
std::optional<mapped_region_ptr> mapped_memory_cache::find(std::string const& uri, bool update_cache)
{
#ifdef MAPNIK_THREADSAFE
std::lock_guard<std::mutex> lock(mutex_);
#endif
using iterator_type = std::unordered_map<std::string, mapped_region_ptr>::const_iterator;
boost::optional<mapped_region_ptr> result;
iterator_type itr = cache_.find(uri);
if (itr != cache_.end())
{
result.reset(itr->second);
return result;
return itr->second;
}
if (mapnik::util::exists(uri))
@ -85,12 +83,11 @@ boost::optional<mapped_region_ptr> mapped_memory_cache::find(std::string const&
boost::interprocess::file_mapping mapping(uri.c_str(), boost::interprocess::read_only);
mapped_region_ptr region(
std::make_shared<boost::interprocess::mapped_region>(mapping, boost::interprocess::read_only));
result.reset(region);
if (update_cache)
{
cache_.emplace(uri, *result);
cache_.emplace(uri, region);
}
return result;
return region;
}
catch (std::exception const& ex)
{
@ -104,7 +101,7 @@ boost::optional<mapped_region_ptr> mapped_memory_cache::find(std::string const&
MAPNIK_LOG_WARN(mapped_memory_cache) << "Memory region does not exist file: " << uri;
}
*/
return result;
return std::nullopt;
}
} // namespace mapnik

View file

@ -83,11 +83,11 @@ namespace detail {
struct push_explicit_style
{
push_explicit_style(svg::group& dst,
boost::optional<color> const& fill_color,
boost::optional<double> const& fill_opacity,
boost::optional<color> const& stroke_color,
boost::optional<double> const& stroke_width,
boost::optional<double> const& stroke_opacity)
std::optional<color> const& fill_color,
std::optional<double> const& fill_opacity,
std::optional<color> const& stroke_color,
std::optional<double> const& stroke_width,
std::optional<double> const& stroke_opacity)
: current_group_(&dst)
, fill_color_(fill_color)
, fill_opacity_(fill_opacity)
@ -168,11 +168,11 @@ struct push_explicit_style
return true;
}
mutable svg::group* current_group_;
boost::optional<color> const& fill_color_;
boost::optional<double> const& fill_opacity_;
boost::optional<color> const& stroke_color_;
boost::optional<double> const& stroke_width_;
boost::optional<double> const& stroke_opacity_;
std::optional<color> const& fill_color_;
std::optional<double> const& fill_opacity_;
std::optional<color> const& stroke_color_;
std::optional<double> const& stroke_width_;
std::optional<double> const& stroke_opacity_;
};
} // namespace detail

View file

@ -159,7 +159,7 @@ box2d<double> memory_datasource::envelope() const
return extent_;
}
boost::optional<datasource_geometry_t> memory_datasource::get_geometry_type() const
std::optional<datasource_geometry_t> memory_datasource::get_geometry_type() const
{
// TODO - detect this?
return datasource_geometry_t::Collection;

View file

@ -28,26 +28,26 @@
namespace mapnik {
template boost::optional<std::string> parameters::get(std::string const& key) const;
template boost::optional<std::string> parameters::get(std::string const& key,
template std::optional<std::string> parameters::get(std::string const& key) const;
template std::optional<std::string> parameters::get(std::string const& key,
std::string const& default_opt_value) const;
template boost::optional<value_double> parameters::get(std::string const& key) const;
template boost::optional<value_double> parameters::get(std::string const& key,
template std::optional<value_double> parameters::get(std::string const& key) const;
template std::optional<value_double> parameters::get(std::string const& key,
value_double const& default_opt_value) const;
template boost::optional<value_bool> parameters::get(std::string const& key) const;
template boost::optional<value_bool> parameters::get(std::string const& key, value_bool const& default_opt_value) const;
template std::optional<value_bool> parameters::get(std::string const& key) const;
template std::optional<value_bool> parameters::get(std::string const& key, value_bool const& default_opt_value) const;
template boost::optional<boolean_type> parameters::get(std::string const& key) const;
template boost::optional<boolean_type> parameters::get(std::string const& key,
template std::optional<boolean_type> parameters::get(std::string const& key) const;
template std::optional<boolean_type> parameters::get(std::string const& key,
boolean_type const& default_opt_value) const;
template boost::optional<value_null> parameters::get(std::string const& key) const;
template boost::optional<value_null> parameters::get(std::string const& key, value_null const& default_opt_value) const;
template std::optional<value_null> parameters::get(std::string const& key) const;
template std::optional<value_null> parameters::get(std::string const& key, value_null const& default_opt_value) const;
template boost::optional<value_integer> parameters::get(std::string const& key) const;
template boost::optional<value_integer> parameters::get(std::string const& key,
template std::optional<value_integer> parameters::get(std::string const& key) const;
template std::optional<value_integer> parameters::get(std::string const& key,
value_integer const& default_opt_value) const;
} // namespace mapnik

View file

@ -70,7 +70,7 @@ class png_reader : public image_reader
~png_reader();
unsigned width() const final;
unsigned height() const final;
boost::optional<box2d<double>> bounding_box() const final;
std::optional<box2d<double>> bounding_box() const final;
inline bool has_alpha() const final { return has_alpha_; }
void read(unsigned x, unsigned y, image_rgba8& image) final;
image_any read(unsigned x, unsigned y, unsigned width, unsigned height) final;
@ -211,9 +211,9 @@ unsigned png_reader<T>::height() const
}
template<typename T>
boost::optional<box2d<double>> png_reader<T>::bounding_box() const
std::optional<box2d<double>> png_reader<T>::bounding_box() const
{
return boost::optional<box2d<double>>();
return std::nullopt;
}
template<typename T>

View file

@ -104,8 +104,8 @@ proj_transform::proj_transform(projection const& source, projection const& dest)
{
is_source_longlat_ = source.is_geographic();
is_dest_longlat_ = dest.is_geographic();
boost::optional<well_known_srs_e> src_k = source.well_known();
boost::optional<well_known_srs_e> dest_k = dest.well_known();
const auto src_k = source.well_known();
const auto dest_k = dest.well_known();
bool known_trans = false;
if (src_k && dest_k)
{
@ -492,14 +492,14 @@ std::string proj_transform::definition() const
}
else
#endif
if (wgs84_to_merc_)
{
return "wgs84 => merc";
}
else if (merc_to_wgs84_)
{
return "merc => wgs84";
}
if (wgs84_to_merc_)
{
return "wgs84 => merc";
}
else if (merc_to_wgs84_)
{
return "merc => wgs84";
}
return "unknown";
}

View file

@ -44,8 +44,8 @@ projection::projection(std::string const& params, bool defer_proj_init)
, proj_(nullptr)
, proj_ctx_(nullptr)
{
boost::optional<bool> is_known = is_known_geographic(params_);
if (is_known)
const auto is_known = is_known_geographic(params_);
if (is_known.has_value())
{
is_geographic_ = *is_known;
}
@ -131,7 +131,7 @@ bool projection::is_geographic() const
return is_geographic_;
}
boost::optional<well_known_srs_e> projection::well_known() const
std::optional<well_known_srs_e> projection::well_known() const
{
return is_well_known_srs(params_);
}

View file

@ -120,7 +120,7 @@ float get_nodata_color<std::uint8_t>()
template<typename T>
void raster_colorizer::colorize(image_rgba8& out,
T const& in,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
feature_impl const& f) const
{
using image_type = T;
@ -313,43 +313,43 @@ unsigned raster_colorizer::get_color(float val) const
template void raster_colorizer::colorize(image_rgba8& out,
image_gray8 const& in,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
feature_impl const& f) const;
template void raster_colorizer::colorize(image_rgba8& out,
image_gray8s const& in,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
feature_impl const& f) const;
template void raster_colorizer::colorize(image_rgba8& out,
image_gray16 const& in,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
feature_impl const& f) const;
template void raster_colorizer::colorize(image_rgba8& out,
image_gray16s const& in,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
feature_impl const& f) const;
template void raster_colorizer::colorize(image_rgba8& out,
image_gray32 const& in,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
feature_impl const& f) const;
template void raster_colorizer::colorize(image_rgba8& out,
image_gray32s const& in,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
feature_impl const& f) const;
template void raster_colorizer::colorize(image_rgba8& out,
image_gray32f const& in,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
feature_impl const& f) const;
template void raster_colorizer::colorize(image_rgba8& out,
image_gray64 const& in,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
feature_impl const& f) const;
template void raster_colorizer::colorize(image_rgba8& out,
image_gray64s const& in,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
feature_impl const& f) const;
template void raster_colorizer::colorize(image_rgba8& out,
image_gray64f const& in,
boost::optional<double> const& nodata,
std::optional<double> const& nodata,
feature_impl const& f) const;
} // namespace mapnik

View file

@ -53,15 +53,15 @@ MAPNIK_DISABLE_WARNING_PUSH
#include <boost/algorithm/string.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/optional.hpp>
#include <boost/version.hpp>
MAPNIK_DISABLE_WARNING_POP
// stl
#include <iostream>
#include <optional>
namespace mapnik {
using boost::optional;
using std::optional;
using boost::property_tree::ptree;
void serialize_text_placements(ptree& node, text_placements_ptr const& p, bool explicit_defaults)
@ -405,7 +405,7 @@ void serialize_style(ptree& map_node, std::string const& name, feature_type_styl
set_attr(style_node, "image-filters-inflate", image_filters_inflate);
}
boost::optional<composite_mode_e> comp_op = style.comp_op();
auto&& comp_op = style.comp_op();
if (comp_op)
{
set_attr(style_node, "comp-op", *comp_op_to_string(*comp_op));
@ -547,7 +547,7 @@ void serialize_layer(ptree& map_node, layer const& lyr, bool explicit_defaults)
set_attr(layer_node, "group-by", lyr.group_by());
}
boost::optional<int> const& buffer_size = lyr.buffer_size();
auto&& buffer_size = lyr.buffer_size();
if (buffer_size || explicit_defaults)
{
set_attr(layer_node, "buffer-size", *buffer_size);

Some files were not shown because too many files have changed in this diff Show more