Algorithm For Determining City Name W/o Internet Access?
I have a database of Cities my application supports. This includes following: Name. Center coordinates. Nearest cities my app support are pretty far away. Algorithm I want to im
Solution 1:
You can use the following logic to get the distance between two lat long
(This is for oracle)
DISTANCE = (NVL(Radius,0) *ACOS((sin(NVL(Lat1,0) / DegToRad) *SIN(NVL(Lat2,0) / DegToRad)) +
(COS(NVL(Lat1,0) / DegToRad) *COS(NVL(Lat2,0) / DegToRad) *Cos(Nvl(Lon2,0) / Degtorad - Nvl(Lon1,0)/ Degtorad))))
Where
DEGTORAD = 57.29577951;
Radius= 6387.7;
May be, similar logic can be implemented via a raw Query in SQLite DB.
The distance can be calculated and ranked and sorted based on least distance.
Post a Comment for "Algorithm For Determining City Name W/o Internet Access?"