Thanks for the info, I'll check it out.

Urb


You almost certainly want to use the Haversine formula for this task
(calculating distances to points that are quite close on a sphere).

http://en.wikipedia.org/wiki/Great-circle_distance

The basic Great Circle formula gives *incorrect* results for points that are
very close to each other.  I.E., the zip code 05702 is NOT actually on top
of 05701, and I expect that your database of zip code centroids is fine,
however, at some point roundoff error is killing you.  That is,

arccos(1) = 0       //true!
arccos(.999999999) = 0   //true for computers, not true for mathematicians

So zip 05702 is too close to zip 05701, and its arccos is getting rounded to
zero, which makes the distance calculated be zero, which is untrue.

Use one of the other formulas on that Wikipedia page.




_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to