+ qualify 'value' to avoid names clashing
+ use _enumeration helper wrapper
This commit is contained in:
parent
afaf2df3ec
commit
570fe611f4
4 changed files with 45 additions and 11 deletions
|
@ -67,7 +67,7 @@ class enumeration_ :
|
|||
for (unsigned i = 0; i < EnumWrapper::MAX; ++i)
|
||||
{
|
||||
// Register the strings allready defined for this enum.
|
||||
value( EnumWrapper::get_string( i ), native_type( i ) );
|
||||
base_type::value( EnumWrapper::get_string( i ), native_type( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ void export_map()
|
|||
using namespace boost::python;
|
||||
|
||||
// aspect ratio fix modes
|
||||
enum_<mapnik::Map::aspect_fix_mode>("aspect_fix_mode")
|
||||
mapnik::enumeration_<mapnik::aspect_fix_mode_e>("aspect_fix_mode")
|
||||
.value("GROW_BBOX", mapnik::Map::GROW_BBOX)
|
||||
.value("GROW_CANVAS",mapnik::Map::GROW_CANVAS)
|
||||
.value("SHRINK_BBOX",mapnik::Map::SHRINK_BBOX)
|
||||
|
@ -294,11 +294,13 @@ void export_map()
|
|||
">>> m.scale()\n"
|
||||
)
|
||||
|
||||
.def("set_aspect_fix_mode",&Map::setAspectFixMode,
|
||||
"Set aspect fix mode.\n"
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
">>> m.set_aspect_fix_mode(...)\n"
|
||||
.add_property("aspect_fix_mode",
|
||||
&Map::getAspectFixMode,
|
||||
&Map::setAspectFixMode,
|
||||
"Get/Set aspect fix mode.\n"
|
||||
"Usage:\n"
|
||||
"\n"
|
||||
">>> m.aspect_fix_mode = aspect_fix_mode.GROW_BBOX\n"
|
||||
)
|
||||
|
||||
.def("get_aspect_fix_mode",&Map::getAspectFixMode,
|
||||
|
|
|
@ -28,9 +28,13 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/enumeration.hpp>
|
||||
#include <mapnik/feature_type_style.hpp>
|
||||
#include <mapnik/datasource.hpp>
|
||||
#include <mapnik/layer.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/optional/optional.hpp>
|
||||
|
||||
namespace mapnik
|
||||
|
@ -52,12 +56,15 @@ namespace mapnik
|
|||
// adjust the width of the specified geo bbox, leave height and map size unchanged
|
||||
ADJUST_BBOX_WIDTH,
|
||||
// adjust the height of the specified geo bbox, leave width and map size unchanged
|
||||
ADJUST_BBOX_HEIGHT,
|
||||
ADJUST_BBOX_HEIGHT,
|
||||
// adjust the width of the map, leave height and geo bbox unchanged
|
||||
ADJUST_CANVAS_WIDTH,
|
||||
//adjust the height of the map, leave width and geo bbox unchanged
|
||||
ADJUST_CANVAS_HEIGHT
|
||||
ADJUST_CANVAS_HEIGHT,
|
||||
//
|
||||
aspect_fix_mode_MAX
|
||||
};
|
||||
|
||||
private:
|
||||
static const unsigned MIN_MAPSIZE=16;
|
||||
static const unsigned MAX_MAPSIZE=MIN_MAPSIZE<<10;
|
||||
|
@ -341,11 +348,13 @@ namespace mapnik
|
|||
~Map();
|
||||
|
||||
inline void setAspectFixMode(aspect_fix_mode afm) { aspectFixMode_ = afm; }
|
||||
inline int getAspectFixMode() { return aspectFixMode_; }
|
||||
inline aspect_fix_mode getAspectFixMode() { return aspectFixMode_; }
|
||||
|
||||
private:
|
||||
void fixAspectRatio();
|
||||
};
|
||||
|
||||
DEFINE_ENUM(aspect_fix_mode_e,Map::aspect_fix_mode);
|
||||
}
|
||||
|
||||
#endif //MAP_HPP
|
||||
|
|
25
src/map.cpp
25
src/map.cpp
|
@ -32,6 +32,21 @@
|
|||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
static const char * aspect_fix_mode_strings[] = {
|
||||
"GROW_BBOX",
|
||||
"GROW_CANVAS",
|
||||
"SHRINK_BBOX",
|
||||
"SHRINK_CANVAS",
|
||||
"ADJUST_BBOX_WIDTH",
|
||||
"ADJUST_BBOX_HEIGHT",
|
||||
"ADJUST_CANVAS_WIDTH",
|
||||
"ADJUST_CANVAS_HEIGHT",
|
||||
""
|
||||
};
|
||||
|
||||
IMPLEMENT_ENUM( mapnik::aspect_fix_mode_e, aspect_fix_mode_strings );
|
||||
|
||||
Map::Map()
|
||||
: width_(400),
|
||||
height_(400),
|
||||
|
@ -364,9 +379,15 @@ namespace mapnik
|
|||
else
|
||||
width_ = (int) (height_ * ratio2 + 0.5);
|
||||
break;
|
||||
default:
|
||||
if (ratio2 > ratio1)
|
||||
currentExtent_.height(currentExtent_.width() / ratio1);
|
||||
else
|
||||
currentExtent_.width(currentExtent_.height() * ratio1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const Envelope<double>& Map::getCurrentExtent() const
|
||||
{
|
||||
return currentExtent_;
|
||||
|
@ -505,4 +526,6 @@ namespace mapnik
|
|||
}
|
||||
|
||||
Map::~Map() {}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue