Avoid recentering viewport if the bounding box is max size 0, as noticed by @jreinam

This commit is contained in:
Joseph Lenox 2016-11-27 11:34:38 -06:00
parent d47f6d30af
commit d398c27e1f

View File

@ -370,6 +370,8 @@ sub zoom_to_bounding_box {
# bounding box # bounding box
my $max_size = max(@{$bb->size}) * 2; my $max_size = max(@{$bb->size}) * 2;
my $min_viewport_size = min($self->GetSizeWH); my $min_viewport_size = min($self->GetSizeWH);
if ($max_size != 0) {
# only re-zoom if we have a valid bounding box, avoid a divide by 0 error.
$self->_zoom($min_viewport_size / $max_size); $self->_zoom($min_viewport_size / $max_size);
# center view around bounding box center # center view around bounding box center
@ -377,6 +379,7 @@ sub zoom_to_bounding_box {
$self->on_viewport_changed->() if $self->on_viewport_changed; $self->on_viewport_changed->() if $self->on_viewport_changed;
} }
}
sub zoom_to_bed { sub zoom_to_bed {
my ($self) = @_; my ($self) = @_;