lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lance Norskog <goks...@gmail.com>
Subject Fun with Spatial (Haversine formula)
Date Wed, 18 Aug 2010 05:54:37 GMT
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
goksron@gmail.com

Mime
View raw message