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 (Created) (JIRA)" <ji...@apache.org> on 2011/11/27 08:00:40 UTC

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

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


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


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

Posted by "Hoss Man (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-3599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13159601#comment-13159601 ] 

Hoss Man commented on LUCENE-3599:
----------------------------------

Committed revision 1208118. - trunk
Committed revision 1208120. - 3x

                
> 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
>            Assignee: David Smiley
>             Fix For: 3.6, 4.0
>
>         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


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

Posted by "Hoss Man (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-3599?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hoss Man resolved LUCENE-3599.
------------------------------

       Resolution: Fixed
    Fix Version/s: 4.0
                   3.6
         Assignee: David Smiley

Oy ... I think my eyes are bleeding trying to make sense of the x/y swaps in this patch.

David: thanks for catching this
                
> 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
>            Assignee: David Smiley
>             Fix For: 3.6, 4.0
>
>         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


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

Posted by "David Smiley (Updated) (JIRA)" <ji...@apache.org>.
     [ 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