add RESPECT mode to make 'fixing' of bbox aspect a no-op on map

This commit is contained in:
Dane Springmeyer 2014-08-14 20:25:53 -07:00
parent fe8e9a0094
commit 751e039347
3 changed files with 6 additions and 2 deletions

View file

@ -147,6 +147,7 @@ void export_map()
.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)
.value("RESPECT", mapnik::Map::RESPECT)
;
class_<std::vector<layer> >("Layers")

View file

@ -71,9 +71,10 @@ public:
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 the height of the map, leave width and geo bbox unchanged
ADJUST_CANVAS_HEIGHT,
//
// do nothing
RESPECT,
aspect_fix_mode_MAX
};

View file

@ -56,6 +56,7 @@ static const char * aspect_fix_mode_strings[] = {
"ADJUST_BBOX_HEIGHT",
"ADJUST_CANVAS_WIDTH",
"ADJUST_CANVAS_HEIGHT",
"RESPECT",
""
};
@ -511,6 +512,7 @@ void Map::zoom_to_box(box2d<double> const& box)
void Map::fixAspectRatio()
{
if (aspectFixMode_ == RESPECT) return;
if (current_extent_.width() > 0 && current_extent_.height() > 0)
{
double ratio1 = static_cast<double>(width_) / static_cast<double>(height_);