Return-Path: Delivered-To: apmail-lucene-solr-user-archive@minotaur.apache.org Received: (qmail 3674 invoked from network); 21 Aug 2010 03:06:37 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 21 Aug 2010 03:06:37 -0000 Received: (qmail 51475 invoked by uid 500); 21 Aug 2010 03:06:34 -0000 Delivered-To: apmail-lucene-solr-user-archive@lucene.apache.org Received: (qmail 51246 invoked by uid 500); 21 Aug 2010 03:06:31 -0000 Mailing-List: contact solr-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-user@lucene.apache.org Delivered-To: mailing list solr-user@lucene.apache.org Received: (qmail 51238 invoked by uid 99); 21 Aug 2010 03:06:30 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Aug 2010 03:06:30 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of goksron@gmail.com designates 74.125.82.176 as permitted sender) Received: from [74.125.82.176] (HELO mail-wy0-f176.google.com) (74.125.82.176) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Aug 2010 03:06:09 +0000 Received: by wyb35 with SMTP id 35so5465794wyb.35 for ; Fri, 20 Aug 2010 20:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=OtRE7RZL/vVaV1yNTOS7RR1MPd1EbRWgHI67ExvD1+Q=; b=yHn6rXSpYn4+ESIQkm+MrG2Q+MBtWOVB5n9wT191ND68+SoR9lI8elGXD2cQnuat6a YyaNRVhi6ChQ+Y/dIltkWmIj/lt/kRNqmJsS/eoLWNrTL8dBZnPuxRiwpV4tujUOMx7T HWOj67ZFg2KPzL5+HPpkBUENZq6dFwTP9Hf20= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=nKL5T490wWpp15auuH4/LBopzFa0fe1iLePLeNAh7YqhKRluBgjau5cd//mW/hEVOg yGuCDnD7xuztmPcUVQqkq6MufXuEmcuPIZndX+Lr3GiHAQNKZcxgTN7dA8lxjj6tAxtM r6QSrx87KEkOQMZz7i4uBpADj//NENjFUVCwY= MIME-Version: 1.0 Received: by 10.227.208.7 with SMTP id ga7mr2013939wbb.126.1282359949691; Fri, 20 Aug 2010 20:05:49 -0700 (PDT) Received: by 10.216.139.211 with HTTP; Fri, 20 Aug 2010 20:05:49 -0700 (PDT) In-Reply-To: References: Date: Fri, 20 Aug 2010 20:05:49 -0700 Message-ID: Subject: Re: Fun with Spatial (Haversine formula) From: Lance Norskog To: solr-user@lucene.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org 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) wrote: > It might have something to do with the source data and its spatial refere= nce > system. For example, if the data is in WGS84 then the haversine (great > circle) distance precision gets worse the farther away two cities are fro= m > each other or for particular regions (e.g. further away from equator). > > Cheers, > Chris > > > > On 8/20/10 6:50 PM, "Yonik Seeley" 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 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 =C2=A0 =C2=A0 -> 396.320500= 00000004 >>> equator vertical =C2=A0 0.1 deg: lat/lon 0.0/0.0 =C2=A0 =C2=A0 -> 396.3= 2050000000004 >>> NYC horizontal =C2=A0 =C2=A0 0.1 deg: lat/lon -72.0/0.0 =C2=A0 -> 383.3= 3093669272654 >>> NYC vertical =C2=A0 =C2=A0 =C2=A0 0.1 deg: lat/lon -72.0/0.0 =C2=A0 -> = 396.32049999997747 >>> arctic horizontal =C2=A00.1 deg: lat/lon 89.0/0.0 =C2=A0 =C2=A0-> 202.1= 3129169290906 >>> arctic vertical =C2=A0 =C2=A00.1 deg: lat/lon 89.0/0.0 =C2=A0 =C2=A0-> = 396.32049999997747 >>> N. Pole horizontal 0.1 deg: lat/lon 89.8/0.0 =C2=A0 =C2=A0-> 103.610362= 92825034 >>> N. Pole vertical =C2=A0 0.1 deg: lat/lon 89.8/0.0 =C2=A0 =C2=A0-> 396.3= 205000000338 >>> >>> 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? >>> >>> >>> =C2=A0public static void main(String[] args) { >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0show("equator horizontal 0.1 deg", 0.= 0, 0.0, 0.0, 0.1); >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0show("equator vertical =C2=A0 0.1 deg= ", 0.0, 0.0, 0.1, 0.0); >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0show("NYC horizontal =C2=A0 =C2=A0 0.= 1 deg", -72, 0.0, -72, 0.1); >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0show("NYC vertical =C2=A0 =C2=A0 =C2= =A0 0.1 deg", -72, 0, -72.1, 0.0); >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0show("arctic horizontal =C2=A00.1 deg= ", 89.0, 0.0, 89.0, 0.1); >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0show("arctic vertical =C2=A0 =C2=A00.= 1 deg", 89.0, 0.0, 89.1, 0.0); >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0show("N. Pole horizontal 0.1 deg", 89= .8, 0.0, 89.8, 0.1); >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0show("N. Pole vertical =C2=A0 0.1 deg= ", 89.8, 0.0, 89.9, 0.0); >>> =C2=A0} >>> >>> =C2=A0private static void show(String label, double d, double e, double= f, >>> double g) { >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0System.out.println(label + ": lat/lon= " + d + "/" + e + " \t-> " + >>> haversine(d,e,f,g, 3963.205)); >>> =C2=A0} >>> >>> (This is from the Solr trunk.) >>> >>> -- >>> Lance Norskog >>> goksron@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.Mattmann@jpl.nasa.gov > WWW: =C2=A0 http://sunset.usc.edu/~mattmann/ > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > Adjunct Assistant Professor, Computer Science Department > University of Southern California, Los Angeles, CA 90089 USA > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > > --=20 Lance Norskog goksron@gmail.com