Merge branch 'master' into spirit-x3
This commit is contained in:
commit
f2c4ec86ea
5 changed files with 52 additions and 31 deletions
|
@ -246,6 +246,16 @@ private:
|
|||
static bool our_verified_flag_;
|
||||
};
|
||||
|
||||
/** ostream operator for enumeration
|
||||
* @relates mapnik::enumeration
|
||||
*/
|
||||
template <class ENUM, int THE_MAX>
|
||||
std::ostream &
|
||||
operator<<(std::ostream & os, const mapnik::enumeration<ENUM, THE_MAX> & e)
|
||||
{
|
||||
return os << e.as_string();
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
|
||||
/** Helper macro.
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/color.hpp>
|
||||
#include <mapnik/enumeration.hpp>
|
||||
|
||||
// stl
|
||||
#include <vector>
|
||||
|
@ -39,26 +38,20 @@ namespace mapnik
|
|||
using stop_pair = std::pair<double, mapnik::color>;
|
||||
using stop_array = std::vector<stop_pair >;
|
||||
|
||||
enum gradient_enum
|
||||
enum gradient_e
|
||||
{
|
||||
NO_GRADIENT,
|
||||
LINEAR,
|
||||
RADIAL,
|
||||
gradient_enum_MAX
|
||||
RADIAL
|
||||
};
|
||||
|
||||
DEFINE_ENUM( gradient_e, gradient_enum );
|
||||
|
||||
enum gradient_unit_enum
|
||||
enum gradient_unit_e
|
||||
{
|
||||
USER_SPACE_ON_USE,
|
||||
USER_SPACE_ON_USE_BOUNDING_BOX, // used to indicate % age values were specified. This are % of the svg image extent.
|
||||
OBJECT_BOUNDING_BOX, // (i.e., the abstract coordinate system where (0,0) is at the top/left of the object bounding box and (1,1) is at the bottom/right of the object bounding box)
|
||||
gradient_unit_enum_MAX
|
||||
OBJECT_BOUNDING_BOX // (i.e., the abstract coordinate system where (0,0) is at the top/left of the object bounding box and (1,1) is at the bottom/right of the object bounding box)
|
||||
};
|
||||
|
||||
DEFINE_ENUM( gradient_unit_e, gradient_unit_enum );
|
||||
|
||||
class MAPNIK_DECL gradient
|
||||
{
|
||||
// transform
|
||||
|
|
|
@ -26,24 +26,6 @@
|
|||
namespace mapnik
|
||||
{
|
||||
|
||||
static const char * gradient_strings[] = {
|
||||
"no-gradient",
|
||||
"linear",
|
||||
"radial",
|
||||
""
|
||||
};
|
||||
|
||||
IMPLEMENT_ENUM( gradient_e, gradient_strings )
|
||||
|
||||
static const char * gradient_unit_strings[] = {
|
||||
"user-space-on-use",
|
||||
"user-space-on-use-bounding-box",
|
||||
"object-bounding-box",
|
||||
""
|
||||
};
|
||||
|
||||
IMPLEMENT_ENUM( gradient_unit_e, gradient_unit_strings )
|
||||
|
||||
gradient::gradient()
|
||||
: transform_(),
|
||||
x1_(0),
|
||||
|
|
|
@ -104,7 +104,7 @@ void serialize_raster_colorizer(ptree & sym_node,
|
|||
raster_colorizer dfl;
|
||||
if (colorizer->get_default_mode() != dfl.get_default_mode() || explicit_defaults)
|
||||
{
|
||||
set_attr(col_node, "default-mode", colorizer->get_default_mode());
|
||||
set_attr(col_node, "default-mode", colorizer->get_default_mode().as_string());
|
||||
}
|
||||
if (colorizer->get_default_color() != dfl.get_default_color() || explicit_defaults)
|
||||
{
|
||||
|
@ -403,7 +403,7 @@ void serialize_style( ptree & map_node, std::string const& name, feature_type_st
|
|||
filter_mode_e filter_mode = style.get_filter_mode();
|
||||
if (filter_mode != dfl.get_filter_mode() || explicit_defaults)
|
||||
{
|
||||
set_attr(style_node, "filter-mode", filter_mode);
|
||||
set_attr(style_node, "filter-mode", filter_mode.as_string());
|
||||
}
|
||||
|
||||
double opacity = style.get_opacity();
|
||||
|
|
36
test/unit/numerics/enumeration.cpp
Normal file
36
test/unit/numerics/enumeration.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "catch.hpp"
|
||||
#include <mapnik/enumeration.hpp>
|
||||
#include <sstream>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
enum _test_enumeration_enum : std::uint8_t
|
||||
{
|
||||
TEST_ONE,
|
||||
TEST_TWO,
|
||||
_test_enumeration_enum_MAX
|
||||
};
|
||||
|
||||
DEFINE_ENUM( _test_enumeration_e, _test_enumeration_enum );
|
||||
|
||||
static const char * _test_enumeration_strings[] = {
|
||||
"test_one",
|
||||
"test_two",
|
||||
""
|
||||
};
|
||||
|
||||
IMPLEMENT_ENUM( _test_enumeration_e, _test_enumeration_strings )
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("enumeration") {
|
||||
|
||||
mapnik::_test_enumeration_e e(mapnik::TEST_ONE);
|
||||
CHECK( e.as_string() == "test_one" );
|
||||
// test the << operator, which calls `as_string` internally
|
||||
// this is not used in mapnik, but kept for back compat
|
||||
std::stringstream s;
|
||||
s << e;
|
||||
CHECK( s.str() == "test_one" );
|
||||
|
||||
}
|
Loading…
Reference in a new issue