Last active
July 18, 2019 20:07
-
-
Save josheinstein/08c7cc65a1e579aca20349237ea93d01 to your computer and use it in GitHub Desktop.
Calculates the distance, in miles, between two LERG VH coordinates.
This file contains 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
-- ============================================= | |
-- Author: Josh Einstein | |
-- Create date: 2/19/2005 | |
-- Description: Calculates the distance between two VH coordinates. | |
-- ============================================= | |
ALTER FUNCTION [dbo].[DistanceBetween] | |
( | |
@v1 int, | |
@h1 int, | |
@v2 int, | |
@h2 int | |
) | |
RETURNS int | |
AS | |
BEGIN | |
DECLARE @result int | |
DECLARE @vDiff int | |
DECLARE @hDiff int | |
SET @vDiff = ABS(@v1-@v2) | |
SET @hDiff = ABS(@h1-@h2) | |
SET @result = CEILING( SQRT( ( POWER( @vDiff, 2 ) + POWER( @hDiff, 2 ) ) / 10 ) ) | |
RETURN @result | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment