Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Main Repositories
otb
Commits
d2fea898
Commit
d2fea898
authored
Apr 13, 2016
by
Stéphane Albert
Browse files
BUG: MANTIS-1179: Fixed otb::GlImageActor::UpdateResolution() algorithm.
parent
c55d177a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Modules/Visualization/Ice/src/otbGlImageActor.cxx
View file @
d2fea898
...
...
@@ -972,44 +972,61 @@ void GlImageActor::UpdateResolution()
double
distAC
=
vcl_sqrt
((
pointA
[
0
]
-
pointC
[
0
])
*
(
pointA
[
0
]
-
pointC
[
0
])
+
(
pointA
[
1
]
-
pointC
[
1
])
*
(
pointA
[
1
]
-
pointC
[
1
]));
double
resolution
=
std
::
min
(
100
/
distAB
,
100
/
distAC
);
// std::cout << std::endl;
// std::cout << "resolution: " << resolution << std::endl;
// Arbitrary higher than any distance we will compute here
double
minDist
=
50000.
;
m_CurrentResolution
=
0
;
bool
isFound
=
false
;
// OTB always include full resolution level in available resolutions.
assert
(
!
m_AvailableResolutions
.
empty
()
);
//
Compute the diff and keep the index that minimize the distance
for
(
R
esolution
VectorType
::
iterator
it
=
m_AvailableResolutions
.
begin
();
it
!=
m_AvailableResolutions
.
end
();
++
it
)
//
MANTIS-1179: resolution>1 <=> zooming in past 1:1 scale. So, cap
// r
esolution
to index 0.
if
(
resolution
<
1.0
)
{
bool
isFound
=
false
;
// Compute the diff and keep the index that minimize the distance
for
(
ResolutionVectorType
::
iterator
it
=
m_AvailableResolutions
.
begin
();
it
!=
m_AvailableResolutions
.
end
();
++
it
)
{
double
diff
=
1
/
((
double
)(
1
<<
(
*
it
)))
-
resolution
;
// std::cout << "diff: " << diff << std::endl;
if
(
(
(
m_ResolutionAlgorithm
==
ResolutionAlgorithm
::
Nearest_Lower
&&
diff
<=
0
)
||
(
m_ResolutionAlgorithm
==
ResolutionAlgorithm
::
Nearest_Upper
&&
diff
>=
0
)
||
(
m_ResolutionAlgorithm
==
ResolutionAlgorithm
::
Nearest
)
)
&&
vcl_abs
(
diff
)
<
minDist
)
{
isFound
=
true
;
minDist
=
vcl_abs
(
diff
);
m_CurrentResolution
=
std
::
distance
(
m_AvailableResolutions
.
begin
(),
it
);
// std::cout << "found: " << m_CurrentResolution << std::endl;
}
}
double
diff
=
1
/
((
double
)(
1
<<
(
*
it
)))
-
resolution
;
if
(
(
(
m_ResolutionAlgorithm
==
ResolutionAlgorithm
::
Nearest_Lower
&&
diff
<
0
)
||
(
m_ResolutionAlgorithm
==
ResolutionAlgorithm
::
Nearest_Upper
&&
diff
>
0
)
||
(
m_ResolutionAlgorithm
==
ResolutionAlgorithm
::
Nearest
)
)
&&
vcl_abs
(
diff
)
<
minDist
)
// MANTIS-1147: Cap current-resolution.
if
(
!
isFound
)
{
isFound
=
true
;
assert
(
m_AvailableResolutions
.
size
()
>
0
);
m_CurrentResolution
=
m_AvailableResolutions
.
size
()
-
1
;
minDist
=
vcl_abs
(
diff
);
m_CurrentResolution
=
std
::
distance
(
m_AvailableResolutions
.
begin
(),
it
);
// std::cout << "not found: " << m_CurrentResolution << std::endl;
}
}
// MANTIS-1147: Cap current-resolution.
if
(
!
isFound
)
m_CurrentResolution
=
m_AvailableResolutions
.
size
()
-
1
;
std
::
ostringstream
extFilename
;
extFilename
<<
m_FileName
<<
"?&resol="
<<
m_CurrentResolution
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment