Re: database function to get distance between 2 latitude/longitude points

  • From: "Rich Jesse" <rjoralist@xxxxxxxxxxxxxxxxxxxxx>
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Wed, 29 Apr 2009 09:40:27 -0500 (CDT)

Hi Deen,

A quick Google search using "Haversine" and "PL/SQL" shows some examples. 
The top hit is for Postgres, but should be easily convertible.  There's even
one that shows how to expand that functionality to US zip code.  And there
are several web pages for you to check your results.

One could also purchase the Oracle Spatial option...

HTH!  GL!

Rich

> Has anybody written a database funtion to get this?
>
> I got this code from http://www.movable-type.co.uk/scripts/latlong.html
>
> R = earth's radius (mean radius = 6,371km)
> ¥Älat = lat2- lat1
> ¥Älong = long2- long1
> a = sin©÷(¥Älat/2) + cos(lat1).cos(lat2).sin©÷(¥Älong/2)
> c = 2.atan2(¡îa, ¡î(1-a))
> d = R.c
>
>
> I am not a math guy, i am just wondering has any one written any db function
> for this.
>
> thanks
> Deen
>


--
//www.freelists.org/webpage/oracle-l


Other related posts: