I need to perform some simple radius searches based on the Latitude and Longitude from a database table.
The table has LatitudeSouth, and LongitudeEast fields
my stored procedure accepts 3 parameters
@LatitudeSouth float,
@LongitudeEast float,
@Radius int
I got this code and it works 80% on the data. It doesn't work on some coordinates (even though they are correct). And if I increase the Radius to 100KM, it bombs out/or takes forever to load.
Is there a simpler formula that you think I can use and guarantee exact/correct result?
The table has LatitudeSouth, and LongitudeEast fields
my stored procedure accepts 3 parameters
@LatitudeSouth float,
@LongitudeEast float,
@Radius int
Code:
SELECT ...... FROM Location as ML ........
WHERE
(
(
( 6371 * acos( cos( radians(@LatitudeSouth) ) *
cos( radians( ML.LatitudeSouth ) ) * cos( radians( ML.LongitudeEast) - radians(@LongitudeEast) ) +
sin( radians(@LatitudeSouth) ) * sin( radians( ML.LatitudeSouth))))
) <= @Radius
)
I got this code and it works 80% on the data. It doesn't work on some coordinates (even though they are correct). And if I increase the Radius to 100KM, it bombs out/or takes forever to load.
Is there a simpler formula that you think I can use and guarantee exact/correct result?