I copied a different formulation out of the Wikipedia article on Haversine. It's the same idea as in DistanceUtils, but turned inside out with cosines instead of sines. It gives exactly the same results.
This is not with source data, just using round numbers in the latitude/longitude space. I do not know how latitude great circles are defined. Chris, are latitudes equidistant on the surface of the sphere? If so, these numbers are correct: longitude distances shrink but latitudes don't. On Fri, Aug 20, 2010 at 7:12 PM, Mattmann, Chris A (388J) <chris.a.mattm...@jpl.nasa.gov> wrote: > It might have something to do with the source data and its spatial reference > system. For example, if the data is in WGS84 then the haversine (great > circle) distance precision gets worse the farther away two cities are from > each other or for particular regions (e.g. further away from equator). > > Cheers, > Chris > > > > On 8/20/10 6:50 PM, "Yonik Seeley" <yo...@lucidimagination.com> wrote: > >> Lance, have you figured out what the issue is? >> Anyone know if this is a haversine limitation, or a bug? >> >> -Yonik >> http://lucenerevolution.org Lucene/Solr Conference, Boston Oct 7-8 >> >> On Wed, Aug 18, 2010 at 1:54 AM, Lance Norskog <goks...@gmail.com> wrote: >>> The Haversine formula in o.a.s.s.f.d.DistanceUtils.java gives these >>> results for a 0.1 degree difference in miles: >>> >>> equator horizontal 0.1 deg: lat/lon 0.0/0.0 -> 396.32050000000004 >>> equator vertical 0.1 deg: lat/lon 0.0/0.0 -> 396.32050000000004 >>> NYC horizontal 0.1 deg: lat/lon -72.0/0.0 -> 383.33093669272654 >>> NYC vertical 0.1 deg: lat/lon -72.0/0.0 -> 396.32049999997747 >>> arctic horizontal 0.1 deg: lat/lon 89.0/0.0 -> 202.13129169290906 >>> arctic vertical 0.1 deg: lat/lon 89.0/0.0 -> 396.32049999997747 >>> N. Pole horizontal 0.1 deg: lat/lon 89.8/0.0 -> 103.61036292825034 >>> N. Pole vertical 0.1 deg: lat/lon 89.8/0.0 -> 396.3205000000338 >>> >>> That is, a horizontal shift of 0.1 at the equator, New York City's >>> latitude, 1 degree south of the North Pole and almost-almost-almost at >>> the North Pole, these are the distances in miles. >>> The latitude changes make perfect sense, but one would expect the >>> longitudes to shrink as well. >>> >>> Here is the code, added to DistanceUtils.java. What am I doing wrong? >>> >>> >>> public static void main(String[] args) { >>> show("equator horizontal 0.1 deg", 0.0, 0.0, 0.0, 0.1); >>> show("equator vertical 0.1 deg", 0.0, 0.0, 0.1, 0.0); >>> show("NYC horizontal 0.1 deg", -72, 0.0, -72, 0.1); >>> show("NYC vertical 0.1 deg", -72, 0, -72.1, 0.0); >>> show("arctic horizontal 0.1 deg", 89.0, 0.0, 89.0, 0.1); >>> show("arctic vertical 0.1 deg", 89.0, 0.0, 89.1, 0.0); >>> show("N. Pole horizontal 0.1 deg", 89.8, 0.0, 89.8, 0.1); >>> show("N. Pole vertical 0.1 deg", 89.8, 0.0, 89.9, 0.0); >>> } >>> >>> private static void show(String label, double d, double e, double f, >>> double g) { >>> System.out.println(label + ": lat/lon " + d + "/" + e + " \t-> " + >>> haversine(d,e,f,g, 3963.205)); >>> } >>> >>> (This is from the Solr trunk.) >>> >>> -- >>> Lance Norskog >>> goks...@gmail.com >>> >> > > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > Chris Mattmann, Ph.D. > Senior Computer Scientist > NASA Jet Propulsion Laboratory Pasadena, CA 91109 USA > Office: 171-266B, Mailstop: 171-246 > Email: chris.mattm...@jpl.nasa.gov > WWW: http://sunset.usc.edu/~mattmann/ > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > Adjunct Assistant Professor, Computer Science Department > University of Southern California, Los Angeles, CA 90089 USA > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > > -- Lance Norskog goks...@gmail.com