Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
e0a5a1e9
Commit
e0a5a1e9
authored
Feb 26, 2019
by
Piotr Gawron
Browse files
computing distance between element and coordinates sometimes returned invalid (low) value
parent
656bd882
Changes
3
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
e0a5a1e9
minerva
(
12.2.0
~
beta
.2
)
unstable
;
urgency
=
medium
*
Bug
fix
:
clicking
outside
of
the
element
sometimes
resulted
with
the
invalid
element
highlighted
(#
324
)
*
Bug
fix
:
parent
compartment
/
pathway
use
proper
type
name
in
left
panel
(#
324
)
*
Bug
fix
:
editing
/
removing
project
requires
Map
Management
privilege
(#
681
)
...
...
frontend-js/src/main/js/map/CustomMap.js
View file @
e0a5a1e9
...
...
@@ -1235,7 +1235,7 @@ CustomMap.prototype.getDistance = function (params) {
var
elementWidth
=
element
.
getWidth
();
var
elementHeight
=
element
.
getHeight
();
return
Math
.
min
(
Functions
.
distance
(
p1
,
new
Point
(
elementX
,
y
)),
Functions
.
distance
(
p1
,
new
Point
(
elementX
,
elementY
)),
Functions
.
distance
(
p1
,
new
Point
(
elementX
+
elementWidth
,
elementY
)),
Functions
.
distance
(
p1
,
new
Point
(
elementX
,
elementY
+
elementHeight
)),
Functions
.
distance
(
p1
,
new
Point
(
elementX
+
elementWidth
,
elementY
+
elementHeight
))
...
...
frontend-js/src/test/js/map/CustomMap-test.js
View file @
e0a5a1e9
...
...
@@ -1017,4 +1017,84 @@ describe('CustomMap', function () {
return
map
.
getControl
(
ControlType
.
LOGO_IMG
).
onclick
()
});
});
describe
(
"
getDistance
"
,
function
()
{
it
(
"
inside element
"
,
function
()
{
var
map
=
helper
.
createCustomMap
();
var
alias
=
helper
.
createAlias
(
map
);
alias
.
setX
(
50
);
alias
.
setY
(
60
);
alias
.
setWidth
(
100
);
alias
.
setHeight
(
200
);
var
ie
=
new
IdentifiedElement
(
alias
);
return
map
.
getDistance
({
modelId
:
map
.
getId
(),
coordinates
:
new
Point
(
100
,
200
),
element
:
ie
}).
then
(
function
(
distance
){
assert
.
equal
(
0
,
distance
);
return
map
.
destroy
();
});
});
it
(
"
to the left
"
,
function
()
{
var
map
=
helper
.
createCustomMap
();
var
alias
=
helper
.
createAlias
(
map
);
alias
.
setX
(
50
);
alias
.
setY
(
60
);
alias
.
setWidth
(
100
);
alias
.
setHeight
(
200
);
var
ie
=
new
IdentifiedElement
(
alias
);
return
map
.
getDistance
({
modelId
:
map
.
getId
(),
coordinates
:
new
Point
(
1
,
200
),
element
:
ie
}).
then
(
function
(
distance
){
assert
.
equal
(
49
,
distance
);
return
map
.
destroy
();
});
});
it
(
"
to the right
"
,
function
()
{
var
map
=
helper
.
createCustomMap
();
var
alias
=
helper
.
createAlias
(
map
);
alias
.
setX
(
50
);
alias
.
setY
(
60
);
alias
.
setWidth
(
100
);
alias
.
setHeight
(
200
);
var
ie
=
new
IdentifiedElement
(
alias
);
return
map
.
getDistance
({
modelId
:
map
.
getId
(),
coordinates
:
new
Point
(
161
,
200
),
element
:
ie
}).
then
(
function
(
distance
){
assert
.
equal
(
11
,
distance
);
return
map
.
destroy
();
});
});
it
(
"
to the top
"
,
function
()
{
var
map
=
helper
.
createCustomMap
();
var
alias
=
helper
.
createAlias
(
map
);
alias
.
setX
(
50
);
alias
.
setY
(
60
);
alias
.
setWidth
(
100
);
alias
.
setHeight
(
200
);
var
ie
=
new
IdentifiedElement
(
alias
);
return
map
.
getDistance
({
modelId
:
map
.
getId
(),
coordinates
:
new
Point
(
100
,
11
),
element
:
ie
}).
then
(
function
(
distance
){
assert
.
equal
(
49
,
distance
);
return
map
.
destroy
();
});
});
it
(
"
to the bottom
"
,
function
()
{
var
map
=
helper
.
createCustomMap
();
var
alias
=
helper
.
createAlias
(
map
);
alias
.
setX
(
50
);
alias
.
setY
(
60
);
alias
.
setWidth
(
100
);
alias
.
setHeight
(
200
);
var
ie
=
new
IdentifiedElement
(
alias
);
return
map
.
getDistance
({
modelId
:
map
.
getId
(),
coordinates
:
new
Point
(
100
,
300
),
element
:
ie
}).
then
(
function
(
distance
){
assert
.
equal
(
40
,
distance
);
return
map
.
destroy
();
});
});
it
(
"
corner
"
,
function
()
{
var
map
=
helper
.
createCustomMap
();
var
alias
=
helper
.
createAlias
(
map
);
alias
.
setX
(
50
);
alias
.
setY
(
60
);
alias
.
setWidth
(
100
);
alias
.
setHeight
(
200
);
var
ie
=
new
IdentifiedElement
(
alias
);
return
map
.
getDistance
({
modelId
:
map
.
getId
(),
coordinates
:
new
Point
(
46
,
57
),
element
:
ie
}).
then
(
function
(
distance
){
assert
.
equal
(
5
,
distance
);
return
map
.
destroy
();
});
});
});
});
Write
Preview
Markdown
is supported
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