Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove aspect_fix_mode as a map property #1759

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ For a complete change history, see the git log.

## Future

- Removed `Map.aspect_fix_mode` (#1758)

- Added `text-halo-rasterizer` property. Set to `fast` for lower quality but faster
halo rendering (#1298)

Expand Down
23 changes: 0 additions & 23 deletions bindings/python/mapnik_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,6 @@ void export_map()
{
using namespace boost::python;

// aspect ratio fix modes
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)
.value("SHRINK_CANVAS",mapnik::Map::SHRINK_CANVAS)
.value("ADJUST_BBOX_WIDTH",mapnik::Map::ADJUST_BBOX_WIDTH)
.value("ADJUST_BBOX_HEIGHT",mapnik::Map::ADJUST_BBOX_HEIGHT)
.value("ADJUST_CANVAS_WIDTH",mapnik::Map::ADJUST_CANVAS_WIDTH)
.value("ADJUST_CANVAS_HEIGHT", mapnik::Map::ADJUST_CANVAS_HEIGHT)
;

class_<std::vector<layer> >("Layers")
.def(vector_indexing_suite<std::vector<layer> >())
;
Expand Down Expand Up @@ -385,17 +373,6 @@ void export_map()
//.def("__deepcopy__",&map_deepcopy)
.add_property("parameters",make_function(params_nonconst,return_value_policy<reference_existing_object>()),"TODO")

.add_property("aspect_fix_mode",
&Map::get_aspect_fix_mode,
&Map::set_aspect_fix_mode,
// TODO - how to add arg info to properties?
//(arg("aspect_fix_mode")),
"Get/Set aspect fix mode.\n"
"Usage:\n"
"\n"
">>> m.aspect_fix_mode = aspect_fix_mode.GROW_BBOX\n"
)

.add_property("background",make_function
(&Map::background,return_value_policy<copy_const_reference>()),
&Map::set_background,
Expand Down
32 changes: 0 additions & 32 deletions include/mapnik/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,6 @@ class CoordTransform;

class MAPNIK_DECL Map
{
public:

enum aspect_fix_mode
{
// grow the width or height of the specified geo bbox to fill the map size. default behaviour.
GROW_BBOX,
// grow the width or height of the map to accomodate the specified geo bbox.
GROW_CANVAS,
// shrink the width or height of the specified geo bbox to fill the map size.
SHRINK_BBOX,
// shrink the width or height of the map to accomodate the specified geo bbox.
SHRINK_CANVAS,
// 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 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,
//
aspect_fix_mode_MAX
};

private:
static const unsigned MIN_MAPSIZE=16;
Expand All @@ -79,7 +56,6 @@ class MAPNIK_DECL Map
std::map<std::string,feature_type_style> styles_;
std::map<std::string,font_set> fontsets_;
std::vector<layer> layers_;
aspect_fix_mode aspectFixMode_;
box2d<double> current_extent_;
boost::optional<box2d<double> > maximum_extent_;
std::string base_path_;
Expand Down Expand Up @@ -324,7 +300,6 @@ class MAPNIK_DECL Map

/*! \brief Zoom the map to a bounding box.
*
* Aspect is handled automatic if not fitting to width/height.
* @param box The bounding box where to zoom.
*/
void zoom_to_box(box2d<double> const& box);
Expand Down Expand Up @@ -384,9 +359,6 @@ class MAPNIK_DECL Map

~Map();

inline void set_aspect_fix_mode(aspect_fix_mode afm) { aspectFixMode_ = afm; }
inline aspect_fix_mode get_aspect_fix_mode() const { return aspectFixMode_; }

/*!
* @brief Get extra, arbitrary Parameters attached to the Map
*/
Expand All @@ -401,12 +373,8 @@ class MAPNIK_DECL Map
* @brief Set extra, arbitary Parameters of the Map
*/
void set_extra_parameters(parameters& params);

private:
void fixAspectRatio();
};

DEFINE_ENUM(aspect_fix_mode_e,Map::aspect_fix_mode);
}

#endif // MAPNIK_MAP_HPP
1 change: 0 additions & 1 deletion src/deepcopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ namespace mapnik { namespace util {
// * styles_(rhs.styles_),
// fontsets_(rhs.fontsets_),
// * layers_(rhs.layers_),
// aspectFixMode_(rhs.aspectFixMode_),
// current_extent_(rhs.current_extent_),
// * maximum_extent_(rhs.maximum_extent_),
// * base_path_(rhs.base_path_),
Expand Down
99 changes: 8 additions & 91 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,18 @@
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( aspect_fix_mode_e, aspect_fix_mode_strings )

Map::Map()
: width_(400),
height_(400),
srs_(MAPNIK_LONGLAT_PROJ),
buffer_size_(0),
aspectFixMode_(GROW_BBOX),
base_path_("") {}

Map::Map(int width,int height, std::string const& srs)
: width_(width),
height_(height),
srs_(srs),
buffer_size_(0),
aspectFixMode_(GROW_BBOX),
base_path_("") {}

Map::Map(Map const& rhs)
Expand All @@ -85,7 +69,6 @@ Map::Map(Map const& rhs)
styles_(rhs.styles_),
fontsets_(rhs.fontsets_),
layers_(rhs.layers_),
aspectFixMode_(rhs.aspectFixMode_),
current_extent_(rhs.current_extent_),
maximum_extent_(rhs.maximum_extent_),
base_path_(rhs.base_path_),
Expand All @@ -105,7 +88,6 @@ Map& Map::operator=(Map const& rhs)
styles_=rhs.styles_;
fontsets_ = rhs.fontsets_;
layers_=rhs.layers_;
aspectFixMode_=rhs.aspectFixMode_;
maximum_extent_=rhs.maximum_extent_;
base_path_=rhs.base_path_;
extra_params_=rhs.extra_params_;
Expand Down Expand Up @@ -242,38 +224,31 @@ unsigned Map::height() const

void Map::set_width(unsigned width)
{
if (width != width_ &&
width >= MIN_MAPSIZE &&
if (width >= MIN_MAPSIZE &&
width <= MAX_MAPSIZE)
{
width_=width;
fixAspectRatio();
width_ = width;
}
}

void Map::set_height(unsigned height)
{
if (height != height_ &&
height >= MIN_MAPSIZE &&
if (height >= MIN_MAPSIZE &&
height <= MAX_MAPSIZE)
{
height_=height;
fixAspectRatio();
height_ = height;
}
}

void Map::resize(unsigned width,unsigned height)
{
if (width != width_ &&
height != height_ &&
width >= MIN_MAPSIZE &&
if (width >= MIN_MAPSIZE &&
width <= MAX_MAPSIZE &&
height >= MIN_MAPSIZE &&
height <= MAX_MAPSIZE)
{
width_=width;
height_=height;
fixAspectRatio();
width_ = width;
height_ = height;
}
}

Expand Down Expand Up @@ -351,7 +326,6 @@ void Map::zoom(double factor)
center.y - 0.5 * h,
center.x + 0.5 * w,
center.y + 0.5 * h);
fixAspectRatio();
}

void Map::zoom_all()
Expand Down Expand Up @@ -428,64 +402,7 @@ void Map::zoom_all()

void Map::zoom_to_box(box2d<double> const& box)
{
current_extent_=box;
fixAspectRatio();
}

void Map::fixAspectRatio()
{
if (current_extent_.width() > 0 && current_extent_.height() > 0)
{
double ratio1 = static_cast<double>(width_) / static_cast<double>(height_);
double ratio2 = current_extent_.width() / current_extent_.height();
if (ratio1 == ratio2) return;

switch(aspectFixMode_)
{
case ADJUST_BBOX_HEIGHT:
current_extent_.height(current_extent_.width() / ratio1);
break;
case ADJUST_BBOX_WIDTH:
current_extent_.width(current_extent_.height() * ratio1);
break;
case ADJUST_CANVAS_HEIGHT:
height_ = int (width_ / ratio2 + 0.5);
break;
case ADJUST_CANVAS_WIDTH:
width_ = int (height_ * ratio2 + 0.5);
break;
case GROW_BBOX:
if (ratio2 > ratio1)
current_extent_.height(current_extent_.width() / ratio1);
else
current_extent_.width(current_extent_.height() * ratio1);
break;
case SHRINK_BBOX:
if (ratio2 < ratio1)
current_extent_.height(current_extent_.width() / ratio1);
else
current_extent_.width(current_extent_.height() * ratio1);
break;
case GROW_CANVAS:
if (ratio2 > ratio1)
width_ = static_cast<int>(height_ * ratio2 + 0.5);
else
height_ = int (width_ / ratio2 + 0.5);
break;
case SHRINK_CANVAS:
if (ratio2 > ratio1)
height_ = int (width_ / ratio2 + 0.5);
else
width_ = static_cast<int>(height_ * ratio2 + 0.5);
break;
default:
if (ratio2 > ratio1)
current_extent_.height(current_extent_.width() / ratio1);
else
current_extent_.width(current_extent_.height() * ratio1);
break;
}
}
current_extent_ = box;
}

box2d<double> const& Map::get_current_extent() const
Expand Down
1 change: 0 additions & 1 deletion tests/python_tests/map_deepcopy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def setup():
# eq_(m2.base, m1.base)
# eq_(m2.background, m1.background)
# eq_(m2.buffer_size, m1.buffer_size)
# eq_(m2.aspect_fix_mode, m1.aspect_fix_mode)
# eq_(m2.envelope(),m1.envelope())
# eq_(m2.buffered_envelope(),m1.buffered_envelope())
# eq_(m2.scale(),m1.scale())
Expand Down