lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Smiley (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENE-3814) Manhattan distance function is incorrect, not absolute distance between coordinates
Date Fri, 08 Nov 2013 05:26:17 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-3814?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13817007#comment-13817007
] 

David Smiley commented on LUCENE-3814:
--------------------------------------

The pertinent code is actually in Spatial4j now and it was recently fixed. When Lucene-spatial
updates the Spatial4j version (within a month I figure), I'll close this issue.

> Manhattan distance function is incorrect, not absolute distance between coordinates
> -----------------------------------------------------------------------------------
>
>                 Key: LUCENE-3814
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3814
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: modules/spatial
>    Affects Versions: 4.0-ALPHA
>            Reporter: Neil Hooey
>            Assignee: David Smiley
>              Labels: distance, geometric
>
> The Lucene vectorDistance() function's Manhattan distance function is incorrect.
> Wikipedia says: http://en.wikipedia.org/wiki/Manhattan_distance
> "Taxicab geometry, blahblahblah, is a form of geometry in which the usual distance function
or metric of Euclidean geometry is replaced by a new metric in which the distance between
two points is the sum of the *absolute differences* of their coordinates."
> The Lucene function isn't taking the absolute value before subtracting the vector coordinates.
> I don't have a patch, but the offending code is here:
> {code}
> // lucene/contrib/spatial/src/java/org/apache/lucene/spatial/DistanceUtils.java
>     } else if (power == 1.0) { 
>       for (int i = 0; i < vec1.length; i++) { 
>         result += vec1[i] - vec2[i]; 
>     }
> {code}
> It just needs to use Math.abs() when subtracting the coordinates.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

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


Mime
View raw message