1

diff r 17e0ba522478 src/core/pal/pointset.cpp

2

 a/src/core/pal/pointset.cpp Thu Mar 29 16:58:30 2012 +0300

3

+++ b/src/core/pal/pointset.cpp Thu Mar 29 17:06:29 2012 +0300

4

@@ 966,14 +966,14 @@

5

for ( i = 0; i < nbPoints; i++ )

6

{

7

j = i + 1; if ( j == nbPoints ) j = 0;

8

 tmp = ( x[i] * y[j]  x[j] * y[i] );

9

 cx += ( x[i] + x[j] ) * tmp;

10

 cy += ( y[i] + y[j] ) * tmp;

11

+ tmp = ( ( x[i]  x[0] ) * ( y[j]  y[0] )  ( x[j]  x[0] ) * ( y[i]  y[0] ) );

12

+ cx += ( x[i] + x[j]  2 * x[0] ) * tmp;

13

+ cy += ( y[i] + y[j]  2 * y[0] ) * tmp;

14

A += tmp;

15

}

16


17

 px = cx / ( 3 * A );

18

 py = cy / ( 3 * A );

19

+ px = x[0] + cx / ( 3 * A );

20

+ py = y[0] + cy / ( 3 * A );

21

}

22


23

} // end namespace

24

diff r 17e0ba522478 src/core/qgscentralpointpositionmanager.cpp

25

 a/src/core/qgscentralpointpositionmanager.cpp Thu Mar 29 16:58:30 2012 +0300

26

+++ b/src/core/qgscentralpointpositionmanager.cpp Thu Mar 29 17:06:29 2012 +0300

27

@@ 232,17 +232,17 @@

28


29

for ( i = numberOfPoints  1, j = 0; j < numberOfPoints; i = j, j++ )

30

{

31

 ai = x[i] * y[j]  x[j] * y[i];

32

+ ai = ( x[i]  x[0] ) * ( y[j]  y[0] )  ( x[j]  x[0] ) * ( y[i]  y[0] );

33

atmp += ai;

34

 xtmp += ( x[j] + x[i] ) * ai;

35

 ytmp += ( y[j] + y[i] ) * ai;

36

+ xtmp += ( x[j] + x[i]  2 * x[0] ) * ai;

37

+ ytmp += ( y[j] + y[i]  2 * y[0] ) * ai;

38

}

39

if ( atmp == 0 )

40

{

41

return 2;

42

}

43

 centroidX = xtmp / ( 3 * atmp );

44

 centroidY = ytmp / ( 3 * atmp );

45

+ centroidX = x[0] + xtmp / ( 3 * atmp );

46

+ centroidY = y[0] + ytmp / ( 3 * atmp );

47

return 0;

48

}

49

