From a4675f2d530d6634c2350caf36fb3d166acb6728 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 13 Mar 2013 15:45:16 -0700 Subject: [PATCH] remove aspect_fix_mode as a map property --- CHANGELOG.md | 2 + bindings/python/mapnik_map.cpp | 23 ------ include/mapnik/map.hpp | 32 -------- src/deepcopy.cpp | 1 - src/map.cpp | 99 ++----------------------- tests/python_tests/map_deepcopy_test.py | 1 - 6 files changed, 10 insertions(+), 148 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7978afcf..8b3b49cd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/bindings/python/mapnik_map.cpp b/bindings/python/mapnik_map.cpp index dcd5ee575..f1d3cf96e 100644 --- a/bindings/python/mapnik_map.cpp +++ b/bindings/python/mapnik_map.cpp @@ -137,18 +137,6 @@ void export_map() { using namespace boost::python; - // aspect ratio fix modes - mapnik::enumeration_("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_ >("Layers") .def(vector_indexing_suite >()) ; @@ -385,17 +373,6 @@ void export_map() //.def("__deepcopy__",&map_deepcopy) .add_property("parameters",make_function(params_nonconst,return_value_policy()),"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()), &Map::set_background, diff --git a/include/mapnik/map.hpp b/include/mapnik/map.hpp index fcf121832..c32636331 100644 --- a/include/mapnik/map.hpp +++ b/include/mapnik/map.hpp @@ -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; @@ -79,7 +56,6 @@ private: std::map styles_; std::map fontsets_; std::vector layers_; - aspect_fix_mode aspectFixMode_; box2d current_extent_; boost::optional > maximum_extent_; std::string base_path_; @@ -324,7 +300,6 @@ public: /*! \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 const& box); @@ -384,9 +359,6 @@ public: ~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 */ @@ -401,12 +373,8 @@ public: * @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 diff --git a/src/deepcopy.cpp b/src/deepcopy.cpp index 3460da544..7961de39d 100644 --- a/src/deepcopy.cpp +++ b/src/deepcopy.cpp @@ -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_), diff --git a/src/map.cpp b/src/map.cpp index ca29e3a15..3eca6c187 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -45,26 +45,11 @@ 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) @@ -72,7 +57,6 @@ Map::Map(int width,int height, std::string const& srs) height_(height), srs_(srs), buffer_size_(0), - aspectFixMode_(GROW_BBOX), base_path_("") {} Map::Map(Map const& rhs) @@ -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_), @@ -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_; @@ -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; } } @@ -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() @@ -428,64 +402,7 @@ void Map::zoom_all() void Map::zoom_to_box(box2d const& box) { - current_extent_=box; - fixAspectRatio(); -} - -void Map::fixAspectRatio() -{ - if (current_extent_.width() > 0 && current_extent_.height() > 0) - { - double ratio1 = static_cast(width_) / static_cast(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(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(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 const& Map::get_current_extent() const diff --git a/tests/python_tests/map_deepcopy_test.py b/tests/python_tests/map_deepcopy_test.py index 2caf846c0..82616cd07 100644 --- a/tests/python_tests/map_deepcopy_test.py +++ b/tests/python_tests/map_deepcopy_test.py @@ -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())