You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "David Smiley (Updated) (JIRA)" <ji...@apache.org> on 2011/11/27 08:02:40 UTC

[jira] [Updated] (LUCENE-3599) haversine() is broken / misdocumented

     [ https://issues.apache.org/jira/browse/LUCENE-3599?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Smiley updated LUCENE-3599:
---------------------------------

    Attachment: LUCENE-3599_Broken_haversine_formula.patch

The attached patch changes the documentation and parameter names of haversine() to reflect how callers are actually calling it -- in lat,lon order. I fixed the algorithm for this as well.  Furthermore, in Solr's HaversineFunction I changed some local variable names to reflect the true order.
                
> haversine() is broken / misdocumented
> -------------------------------------
>
>                 Key: LUCENE-3599
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3599
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: modules/spatial
>    Affects Versions: 3.5
>            Reporter: David Smiley
>         Attachments: LUCENE-3599_Broken_haversine_formula.patch
>
>
> DistanceUtils.haversine() is coded in a way that is erroneous based on the documented order of the parameters.  The parameters are defined as (x1,y1,x2,y2,radius)  -- i.e. lon,lat order.  The code implementing the algorithm, however, is as if the meaning of x and y are transposed, which means that if you supply the arguments in lat,lon (y,x) order, you will get the correct behavior.  It turns out that all callers of this method do this!
> FYI I found out about this bug since it is inherited code in LSP (lucene-spatial-playground) and I have been supplying parameters according to its documented order.  Apparently I shouldn't do that ;-)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org