2012-08-16 14:53:38 +00:00
|
|
|
// mapnik
|
|
|
|
#include <mapnik/simplify.hpp>
|
|
|
|
|
2020-11-19 14:30:30 +00:00
|
|
|
#include <mapnik/warning.hpp>
|
|
|
|
MAPNIK_DISABLE_WARNING_PUSH
|
2015-11-08 01:53:09 +00:00
|
|
|
#include <mapnik/warning_ignore.hpp>
|
2012-08-16 14:53:38 +00:00
|
|
|
#include <boost/assign/list_of.hpp>
|
|
|
|
#include <boost/bimap.hpp>
|
2020-11-19 14:30:30 +00:00
|
|
|
MAPNIK_DISABLE_WARNING_POP
|
2012-08-16 14:53:38 +00:00
|
|
|
|
2022-01-26 09:43:31 +00:00
|
|
|
namespace mapnik {
|
2012-08-16 14:53:38 +00:00
|
|
|
|
2014-07-07 17:23:15 +00:00
|
|
|
using simplify_algorithm_lookup_type = boost::bimap<simplify_algorithm_e, std::string>;
|
2022-01-26 09:43:31 +00:00
|
|
|
static const simplify_algorithm_lookup_type simplify_lookup =
|
|
|
|
boost::assign::list_of<simplify_algorithm_lookup_type::relation>(radial_distance, "radial-distance")(
|
|
|
|
douglas_peucker,
|
|
|
|
"douglas-peucker")(visvalingam_whyatt, "visvalingam-whyatt")(zhao_saalfeld, "zhao-saalfeld");
|
2012-08-16 14:53:38 +00:00
|
|
|
|
|
|
|
boost::optional<simplify_algorithm_e> simplify_algorithm_from_string(std::string const& name)
|
|
|
|
{
|
|
|
|
boost::optional<simplify_algorithm_e> algo;
|
|
|
|
simplify_algorithm_lookup_type::right_const_iterator right_iter = simplify_lookup.right.find(name);
|
|
|
|
if (right_iter != simplify_lookup.right.end())
|
|
|
|
{
|
|
|
|
algo.reset(right_iter->second);
|
|
|
|
}
|
|
|
|
return algo;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::optional<std::string> simplify_algorithm_to_string(simplify_algorithm_e value)
|
|
|
|
{
|
|
|
|
boost::optional<std::string> algo;
|
|
|
|
simplify_algorithm_lookup_type::left_const_iterator left_iter = simplify_lookup.left.find(value);
|
|
|
|
if (left_iter != simplify_lookup.left.end())
|
|
|
|
{
|
|
|
|
algo.reset(left_iter->second);
|
|
|
|
}
|
|
|
|
return algo;
|
|
|
|
}
|
|
|
|
|
2022-01-26 09:43:31 +00:00
|
|
|
} // namespace mapnik
|