Skip to content

Commit 0dc5d3f

Browse files
committed
bugfix (use corret scala)
1 parent 641d6e8 commit 0dc5d3f

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

app/scripts/services/calculatecircleposition.js

+14-15
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ angular.module('whatamiApp')
1212
// Service logic
1313
// ...
1414
function calculateBoundaries(positions, centerPosition) {
15-
var maxX = centerPosition.longitude + 5;
16-
var minX = centerPosition.longitude - 5;
17-
var minY = centerPosition.latitude + 5;
18-
var maxY = centerPosition.latitude - 5;
15+
var maxLongitude = centerPosition.longitude + 5;
16+
var minLongitude = centerPosition.longitude - 5;
17+
var minLatitude = centerPosition.latitude - 5;
18+
var maxLatitude = centerPosition.latitude + 5;
1919

2020
positions.forEach(function (position) {
21-
while (position.longitude >= maxX || position.longitude <= minX) {
22-
maxX = maxX + 5;
23-
minX = minY - 5;
21+
while (position.longitude >= maxLongitude || position.longitude <= minLongitude) {
22+
maxLongitude = maxLongitude + 5;
23+
minLongitude = minLongitude - 5;
2424
}
25-
while (position.latitude >= maxY || position.latitude <= minY) {
26-
maxY = maxY + 5;
27-
minY = minY - 5;
25+
while (position.latitude >= maxLatitude || position.latitude <= minLatitude) {
26+
maxLatitude = maxLatitude + 5;
27+
minLatitude = minLatitude - 5;
2828
}
2929
});
3030

3131
return {
32-
maxX: maxX,
33-
minX: minX,
34-
maxY: maxY,
35-
minY: minY
32+
maxX: maxLongitude,
33+
minX: minLongitude,
34+
maxY: maxLatitude,
35+
minY: minLatitude
3636
};
3737

3838
}
@@ -68,7 +68,6 @@ angular.module('whatamiApp')
6868

6969
var boundaries = calculateBoundaries(positions, centerPosition);
7070

71-
console.log(boundaries);
7271
positions.forEach(function (position) {
7372
domainValues.push({
7473
cx: calculateCx(position, boundaries),

test/spec/services/calculatecircleposition.js

+22
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,26 @@ describe('Service: calculateCirclePosition', function () {
5757
expect(calculateCirclePosition.calc(theData)).toEqual(expectedData);
5858
});
5959

60+
61+
it('bug with three cluster', function () {
62+
var theData = [
63+
{'latitude':46,'longitude':7,'counter':18},
64+
{'latitude':47,'longitude':7,'counter':2},
65+
{'latitude':52,'longitude':13,'counter':4}
66+
];
67+
var expectedData = {
68+
domainData: [
69+
{cx: 50, cy: 50, r: 7.5},
70+
{cx: 50, cy: 45, r: 0.83},
71+
{cx: 80, cy: 20, r: 1.67}],
72+
boundaries: {
73+
maxY: 56,
74+
minY: 36,
75+
maxX: 17,
76+
minX: -3
77+
} };
78+
79+
expect(calculateCirclePosition.calc(theData)).toEqual(expectedData);
80+
81+
});
6082
});

0 commit comments

Comments
 (0)