Top

Name

haversine_deg_km — Given latitudes and longitudes of two points in degrees, calculates the approximate distance between that points in kilometers

Synopsis

haversine_deg_km ( in lat1 double precision ,
  in long1 double precision ,
  in lat2 double precision ,
  in long2 double precision );
 

Description

The function calculates the approximate distance between two points, using haversine formula with an adjustment for case when points are ends of some diameter.

Note that the order of arguments is latitude-longitude, not longitude-latitude.

Parameters

lat1

latitude

long1

longitude

lat2

latitude

long2

longitude

Return Types

The function returns distance in kilometers as double precision.

Examples

Example 24.663. Simple example

-- select haversine_deg_km (-90,0,90,0)
haversine_deg_km
VARCHAR
_______________________________________________________________________________

20003.88915449353

-- select haversine_deg_km (0,0,0,180) - haversine_deg_km (-90,0,90,0)
temp
VARCHAR
_______________________________________________________________________________

33.61918829571368