Calculate distance between two points directly in SQLite

前端 未结 5 637
北海茫月
北海茫月 2020-12-17 19:15

In my web/MySQL application I have something like this to get distance between two points:

6371 * acos(cos(radians(-19.83996)) * cos(radians(lat)) * cos(radi         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-17 19:57

    Reply of Angel does not solve the problem for SQLite since it still includes ACOS function which does not exist in SQLite

    What I have concluded after a thorough research is that one should pick a rough estimation to use in SQLite with the formula below:

    Distance estimation for km:

    SQRT(SQUARE((TO_LAT-FROM_LAT)*110)+
         SQUARE((TO_LONG-FROM_LONG)*COS(TO_LAT)*111)) 
    

提交回复
热议问题