fix other potential division by zero conditions - closes #1110
This commit is contained in:
parent
9fb45ebf75
commit
5f4734ebe0
2 changed files with 51 additions and 46 deletions
|
@ -264,8 +264,10 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
|
|||
box2d<double> query_ext = m_.get_current_extent();
|
||||
box2d<double> unbuffered_extent = m_.get_current_extent();
|
||||
prj_trans.forward(query_ext, PROJ_ENVELOPE_POINTS);
|
||||
query::resolution_type res(m_.width()/query_ext.width(),
|
||||
m_.height()/query_ext.height());
|
||||
double qw = query_ext.width()>0 ? query_ext.width() : 1;
|
||||
double qh = query_ext.height()>0 ? query_ext.height() : 1;
|
||||
query::resolution_type res(m_.width()/qw,
|
||||
m_.height()/qh);
|
||||
|
||||
query q(layer_ext,res,scale_denom,unbuffered_extent);
|
||||
|
||||
|
|
91
src/map.cpp
91
src/map.cpp
|
@ -451,54 +451,57 @@ void Map::zoom_to_box(const box2d<double> &box)
|
|||
|
||||
void Map::fixAspectRatio()
|
||||
{
|
||||
double ratio1 = (double) width_ / (double) height_;
|
||||
double ratio2 = current_extent_.width() / current_extent_.height();
|
||||
if (ratio1 == ratio2) return;
|
||||
|
||||
switch(aspectFixMode_)
|
||||
if (current_extent_.width() > 0 && current_extent_.height() > 0)
|
||||
{
|
||||
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)
|
||||
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);
|
||||
else
|
||||
break;
|
||||
case ADJUST_BBOX_WIDTH:
|
||||
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_ = (int) (height_ * ratio2 + 0.5);
|
||||
else
|
||||
break;
|
||||
case ADJUST_CANVAS_HEIGHT:
|
||||
height_ = int (width_ / ratio2 + 0.5);
|
||||
break;
|
||||
case SHRINK_CANVAS:
|
||||
if (ratio2 > ratio1)
|
||||
height_ = int (width_ / ratio2 + 0.5);
|
||||
else
|
||||
width_ = (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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue