Manhattan distance function is incorrect, not absolute distance between coordinates

Key: LUCENE3814
URL: https://issues.apache.org/jira/browse/LUCENE3814
Project: Lucene  Java
Issue Type: Bug
Components: modules/spatial
Affects Versions: 4.0
Reporter: Neil Hooey
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."
I don't have a patch, but the offending code is here:
// 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];
}
It just needs to use Math.abs() when subtracting the coordinates.

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, email: devunsubscribe@lucene.apache.org
For additional commands, email: devhelp@lucene.apache.org
