<span style>You're right. I was right thinking about it yesterday while committing the changes. </span><div style><b>f </b>is misleading, and it should be substituded by <b>rf</b> in my formula.</div><div style><br></div>
<div style>Thanks for having reported your measurements. They helped a lot to figure out the bug ;)</div><div style>giovanni</div><br><div class="gmail_quote">2012/4/6 blavet <span dir="ltr"><<a href="mailto:didier.blavet@ird.fr">didier.blavet@ird.fr</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>


  

<div text="#000000" bgcolor="#ffffff">
<b>Good evening</b><br>
<br>
Of course thank you again i fully agree with what you found which is
mathematically correct ,<br>
 it was not easy to find, and is essential for debugging the
calculation of ellipsoîdal distances<br>
<br>
I just had a quick look at the code found at
<a href="http://trac.osgeo.org/qgis/browser/trunk/qgis/src/core/qgsdistancearea.cpp#L540" target="_blank">http://trac.osgeo.org/qgis/browser/trunk/qgis/src/core/qgsdistancearea.cpp#L540</a>
<br>
<br>
i'm not an informatician so i can just say few words <br>
<br>
inverse flattening seems correctly defined in line 148 as <br>
mInvFlattening <span>=</span> mSemiMajor <span>/</span> <span>(</span> mSemiMajor <span>-</span> mSemiMinor <span>)<br>
<br>
therefater the bug that you found could be in line 153 </span><span></span><span></span><span></span><span></span><span></span>(and may be in some other
lines of the code, i cannot say)<br>
<br>
Therafter, it is just a detail (and a convention) but <br>
just to try to help to avoid a potential confusion in the future code
maintenance. , <br>
about the letter "f" used in your message about "inverse flattening" i
think that it would may be  better to use another letter than f  for
designation of inverse flattening ... I say this   just because  in
line 550 of the code found today at 
<a href="http://trac.osgeo.org/qgis/browser/trunk/qgis/src/core/qgsdistancearea.cpp#L540" target="_blank">http://trac.osgeo.org/qgis/browser/trunk/qgis/src/core/qgsdistancearea.cpp#L540</a>
the letter f was already assigned as f = 1/mInvFlattening, indicating
that letter f in this code is already reserved for ... flattening)   <br>
<br>
So of course and again what you said is perfecly correct from a
mathematical point of view (as long as you say, by convention,  that f
= inverse flattening) , <br>
Therefore the demonstration  would may be a bit clearer just with
replacing this letter f by some other symbol or combination of symbols
for the designation of inverse flattening <br>
(as this f is already used for something else in the code).  <br>
Would it be possible for instance to use the symbolic combination <b>rf</b>,
used in proj4  (for "reciprocal flattening" which is, as far as i
know,  in english, equivalent to inverse flattening) <br>
<br>
then this would give, from what you found this morning , and with
exactly the same meaning that what you said :<br>
<br>
"<br>
<b>In Qgis the semi-minor axis of the ellipsoid is calculated with:<br>
     b = a - (rf/a)<br>
     where<br>
     b = semi-minor axis<br>
     a = semi-major axis<br>
     rf =  inverse flattening (= "reciprocal flattening" = a/(a-b)  )<br>
<br>
     while it should be:<br>
     b = a - (a/rf)</b><br>
"<br>
<br>
therefore, this rf symbol would also fit with the +rf proj4 parameter
defined as  <br>
"+rf       reciprocal of the ellipsoid flattening term (e.g. 298)"<br>
(also in proj4 +f is used for flattening<br>
+f         Flattening of the ellipsoid (often presented as an inverse,
e.g. 1/298) <br>
<br>
(by the way , I guess, however, that the adjective reciprocal for
"reciprocal numbers" can have also some other meanings for the pure
mathematicians .. <br>
... Therefore it would also be possible to use another symbol for
inverse flattening than rf  (but preferentially not f (:-))<br>
<br>
<b>Thank you again<br>
<br>
Best regards<br>
</b><br>
Le 06/04/2012 14:15, G. Allegri a écrit :
<blockquote type="cite">Not at all.
  <div>The change has already been committed to the development version.</div>
  <div><br>
  </div>
  <div>giovanni</div>
  <br>
  <div class="gmail_quote">2012/4/6 blavet <span dir="ltr"><<a href="mailto:didier.blavet@ird.fr" target="_blank">didier.blavet@ird.fr</a>></span><br>
  <blockquote class="gmail_quote" style="border-left:1px solid rgb(204,204,204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
    <div text="#000000" bgcolor="#ffffff">
Thank you very much for this very fast and efficient diagnosis<br>
    <br>
Best regards<br>
    <br>
Didier Blavet<br>
    <br>
Le 06/04/2012 12:01, G. Allegri a écrit :
    <blockquote type="cite">Probably I've found the bug.
      <div>In Qgis the semi-minor axis of the ellipsoid is calculated
with:</div>
      <div><br>
      </div>
      <div>b = a - (f/a)</div>
      <div><br>
      </div>
      <div>where </div>
      <div>b = semi-minor axis</div>
      <div>a = semi-majot axis</div>
      <div>f = inverse flattening</div>
      <div><br>
      </div>
      <div>while it should be:</div>
      <div><br>
      </div>
      <div>b = a - (a/f)</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div>In Qgis the WGS84 semi-minor axis is 6378136,xxx</div>
      <div>while it should be 6356752.xxx</div>
      <div><br>
      </div>
      <div>giovanni</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div><br>
      <br>
      <div class="gmail_quote">2012/4/6 G. Allegri <span dir="ltr"><<a href="mailto:giohappy@gmail.com" target="_blank">giohappy@gmail.com</a>></span><br>
      <blockquote class="gmail_quote" style="border-left:1px solid rgb(204,204,204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
        <div><span>AFAICS, the Qgis formula [1] to calculate
distances on ellipssoid is Vincenty's.</span>
        <div>I've reproduced it for the first set of points and I can
confirm tha QGis gives 540.9973919726176 m</div>
        <div><br>
        </div>
        <div>The online Vincenty calculator [2] gives 540.045 m</div>
        <div><br>
        </div>
        <div>I suppose it's a rounding issue. </div>
        <div>I will investigate it more...</div>
        <div><br>
        </div>
        <div>giovanni</div>
        <div><br>
        <div><br>
        </div>
        <div>[1]  <a href="http://trac.osgeo.org/qgis/browser/trunk/qgis/src/core/qgsdistancearea.cpp#L540" style="color:rgb(17,85,204)" target="_blank">http://trac.osgeo.org/qgis/browser/trunk/qgis/src/core/qgsdistancearea.cpp#L540</a> </div>

        <div>[2] <a href="http://www.movable-type.co.uk/scripts/latlong-vincenty.html" style="color:rgb(17,85,204)" target="_blank">http://www.movable-type.co.uk/scripts/latlong-vincenty.html</a> </div>
        </div>
        <br>
        </div>
        <div class="gmail_quote">2012/4/6 blavet <span dir="ltr"><<a href="mailto:didier.blavet@ird.fr" target="_blank">didier.blavet@ird.fr</a>></span><br>
        <blockquote class="gmail_quote" style="border-left:1px solid rgb(204,204,204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
          <div>
          <div>
          <div text="#000000" bgcolor="#ffffff">Dear QGis Developpers
and
Users <br>
          <br>
          <br>
          <div>
          <p style="margin-bottom:0cm"><font>_______________________________________________________________________________________</font></p>
          <p style="margin-bottom:0cm"><font color="#008000"><font><b>Didier
B</b><b>lavet</b> </font></font> </p>
          <p style="margin-bottom:0cm"><font color="#000000"><font>Institut
de
Recherche
pour
le Développement - IRD (<font color="#0000ff"><a href="http://www.ird.fr" target="_blank">http://www.ird.fr</a></font>)
          </font></font></p>
          <p style="margin-bottom:0cm"><font color="#000000"><font>UMR
Eco&Sols
- Ecologie Fonctionnelle & Biogéochimie des Sols &
Agroécosystèmes </font></font> </p>
          <p style="margin-bottom:0cm"><font color="#000000"><font>(Montpellier
SupAgro-CIRAD-INRA-IRD)
(<font color="#0000ff"><a href="http://www.montpellier.inra.fr/ecosols" target="_blank">http://www.montpellier.inra.fr/ecosols</a></font><span style="font-style:normal">)</span></font></font></p>
          <p style="margin-bottom:0cm"><font color="#000000"><font>Bâtiment
12,
2
place
Viala, F-34060 Montpellier Cedex 2 , France </font></font> </p>
          <p style="margin-bottom:0cm"><font color="#000000"><font>Tel
bureau
: <a href="tel:%2B33%20%280%294%2099%2061%2021%2033" value="+33499612133" target="_blank">+33 (0)4 99 61 21 33</a> </font></font> </p>
          <p style="margin-bottom:0cm"><font color="#000000"><font>Secrétariat
:

          <a href="tel:%2B33%20%280%294%2099%2061%2021%2001" value="+33499612101" target="_blank">+33 (0)4 99 61 21 01</a> / Fax : <a href="tel:%2B33%20%280%294%2099%2061%2021%2019" value="+33499612119" target="_blank">+33 (0)4 99 61 21 19</a> </font></font>
          </p>
          <p style="margin-bottom:0cm"><font color="#000000"><font>Courriel
:

          <font color="#0000ff"><a href="mailto:didier.blavet@ird.fr" target="_blank">didier.blavet@ird.fr</a></font>
          </font></font> </p>
          <p style="margin-bottom:0cm"><font>_______________________________________________________________________________________</font></p>
          </div>
          </div>
          <br>
          </div>
          </div>
          <div>_______________________________________________<br>
Qgis-user mailing list<br>
          <a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
          <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
          <br>
          </div>
        </blockquote>
        </div>
        <br>
      </blockquote>
      </div>
      <br>
      </div>
    </blockquote>
    <br>
    <div>-- <br>
    <p style="margin-bottom:0cm"><font>_______________________________________________________________________________________</font></p>
    <p style="margin-bottom:0cm"><font color="#008000"><font><b>Didier
B</b><b>lavet</b> </font></font>
    </p>
    <p style="margin-bottom:0cm"><font color="#000000"><font>Institut
de
Recherche pour le Développement - IRD (<font color="#0000ff"><a href="http://www.ird.fr" target="_blank">http://www.ird.fr</a></font>)
    </font></font></p>
    <p style="margin-bottom:0cm"><font color="#000000"><font>UMR
Eco&Sols - Ecologie Fonctionnelle & Biogéochimie des Sols &
Agroécosystèmes </font></font>
    </p>
    <p style="margin-bottom:0cm"><font color="#000000"><font>(Montpellier
SupAgro-CIRAD-INRA-IRD)
(<font color="#0000ff"><a href="http://www.montpellier.inra.fr/ecosols" target="_blank">http://www.montpellier.inra.fr/ecosols</a></font><span style="font-style:normal">)</span></font></font></p>
    <p style="margin-bottom:0cm"><font color="#000000"><font>Bâtiment
12,
2 place Viala, F-34060 Montpellier Cedex 2 , France </font></font>
    </p>
    <p style="margin-bottom:0cm"><font color="#000000"><font>Tel
bureau : <a href="tel:%2B33%20%280%294%2099%2061%2021%2033" value="+33499612133" target="_blank">+33 (0)4 99 61 21 33</a> </font></font>
    </p>
    <p style="margin-bottom:0cm"><font color="#000000"><font>Secrétariat
:
    <a href="tel:%2B33%20%280%294%2099%2061%2021%2001" value="+33499612101" target="_blank">+33 (0)4 99 61 21 01</a> / Fax : <a href="tel:%2B33%20%280%294%2099%2061%2021%2019" value="+33499612119" target="_blank">+33 (0)4 99 61 21 19</a> </font></font>
    </p>
    <p style="margin-bottom:0cm"><font color="#000000"><font>Courriel
:
    <font color="#0000ff"><a href="mailto:didier.blavet@ird.fr" target="_blank">didier.blavet@ird.fr</a></font>
    </font></font>
    </p>
    <p style="margin-bottom:0cm"><font>_______________________________________________________________________________________</font></p>
    </div>
    </div>
  </blockquote>
  </div>
  <br>
</blockquote>
<br>
<div>-- <br>








<p style="margin-bottom:0cm"><font>_______________________________________________________________________________________</font></p>
<p style="margin-bottom:0cm"><font color="#008000"><font><b>Didier
B</b><b>lavet</b> </font></font>
</p>
<p style="margin-bottom:0cm"><font color="#000000"><font>Institut
de
Recherche pour le Développement - IRD (<font color="#0000ff"><a href="http://www.ird.fr" target="_blank">http://www.ird.fr</a></font>)
</font></font></p>
<p style="margin-bottom:0cm"><font color="#000000"><font>UMR
Eco&Sols - Ecologie Fonctionnelle & Biogéochimie des Sols &
Agroécosystèmes </font></font>
</p>
<p style="margin-bottom:0cm"><font color="#000000"><font>(Montpellier
SupAgro-CIRAD-INRA-IRD)
(<font color="#0000ff"><a href="http://www.montpellier.inra.fr/ecosols" target="_blank">http://www.montpellier.inra.fr/ecosols</a></font><span style="font-style:normal">)</span></font></font></p>
<p style="margin-bottom:0cm"><font color="#000000"><font>Bâtiment
12,
2 place Viala, F-34060 Montpellier Cedex 2 , France </font></font>
</p>
<p style="margin-bottom:0cm"><font color="#000000"><font>Tel
bureau : <a href="tel:%2B33%20%280%294%2099%2061%2021%2033" value="+33499612133" target="_blank">+33 (0)4 99 61 21 33</a> </font></font>
</p>
<p style="margin-bottom:0cm"><font color="#000000"><font>Secrétariat
:
<a href="tel:%2B33%20%280%294%2099%2061%2021%2001" value="+33499612101" target="_blank">+33 (0)4 99 61 21 01</a> / Fax : <a href="tel:%2B33%20%280%294%2099%2061%2021%2019" value="+33499612119" target="_blank">+33 (0)4 99 61 21 19</a> </font></font>
</p>
<p style="margin-bottom:0cm"><font color="#000000"><font>Courriel
:
<font color="#0000ff"><a href="mailto:didier.blavet@ird.fr" target="_blank">didier.blavet@ird.fr</a></font> </font></font>
</p>
<p style="margin-bottom:0cm"><font>_______________________________________________________________________________________</font></p>
</div>
</div>

</blockquote></div><br>