Skip to content

Commit

Permalink
backend specific
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan committed Jul 11, 2010
1 parent f03b8d4 commit 9812f08
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions sql/geoname.mysql.sql
@@ -0,0 +1,21 @@
DROP FUNCTION IF EXISTS fn_distance_cosine_km;
DELIMITER |
CREATE FUNCTION fn_distance_cosine (
point1 POINT,
point2 POINT
)
RETURNS DOUBLE
BEGIN
DECLARE latitude_1, longitude_1, latitude_2, longitude_2 DOUBLE;
SET latitude_1:=X(point1);
SET longitude_1:=Y(point1);
SET latitude_2:=X(point2);
SET longitude_2:=Y(point2);
RETURN ACOS(
SIN(RADIANS(latitude_1)) * SIN(RADIANS(latitude_2))
+ COS(RADIANS(latitude_1)) * COS(RADIANS(latitude_2))
* COS(RADIANS(longitude_2 - longitude_1))
) * 6371;
END
|
DELIMITER ;

0 comments on commit 9812f08

Please sign in to comment.