Created
July 22, 2010 16:57
-
-
Save cbrumelle/486240 to your computer and use it in GitHub Desktop.
Calculate distance in MySQL from Points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELIMITER $$ | |
DROP FUNCTION IF EXISTS `test`.`distance` $$ | |
CREATE FUNCTION `distance`(a POINT, b POINT) RETURNS double | |
DETERMINISTIC | |
COMMENT 'distance function' | |
BEGIN | |
RETURN round(glength(linestringfromwkb(linestring(asbinary(a), asbinary(b))))); | |
END $$ | |
DELIMITER ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment