I send these paramaters my script : Latitude : 41.0186 Longitude : 28.964701 (it is sample). i want to find nearest location’s name. how to do this? (query’s where code’s must be changed)
Sql Query :
SELECT Name FROM Location
WHERE Latitude = 41.0186 AND longitude= 28.964701
Location table likes this: (in real, this is huge table)
Latitude longitude Name
41.0200500000 40.5234490000 a
41.0185714000 37.0975924000 b
41.0184913000 34.0373739000 c
41.0166667000 39.5833333000 d
41.0166667000 28.9333333000 e
Use this function
You may order by this function, BUT on large datasets it will be very slow, so try to prefilter the recordset
UPD:
Using @chopikadze’s test data:
Assuming that the Earth is NOT a geoid, but the round ball, if you need under 1m exact formula – I can find it, don’t have it with me