2

Possible Duplicate:
Query to get records based on Radius in SQLite?

I am using sqlite to save latitude,longitude and video path in my application. by passing the current latitude and longitude as parameter in the query. i need to sort the video paths based
on the proximity. I am using the following query to achieve this SELECT videopath , ( 3959 * ACOS( COS( RADIANS( 12.9833 ) ) * COS( RADIANS( lat ) ) * COS( RADIANS( lng ) - RADIANS( 77.5833 ) ) + SIN( RADIANS( 12.9833 ) ) * SIN( RADIANS( lat ) ) ) ) AS distance FROM VideoPathsTable ORDER BY distance ASC LIMIT 0 , 30. In sql this query executes fine but in sqlite i am getting the following error no such function: ACOS is there any other alternate way to do this. Please help me to solve this issue.I am using libsqlite3.0.dylib

Community
  • 1
  • 1
user1602941
  • 41
  • 1
  • 5
  • There is a method that works on iOS, see http://daveaddey.com/?p=71 no need to add new columns. I would write it as an answer, but the editors have incorrectly marked this question as a duplicate (note to editors: the question you refer to http://stackoverflow.com/questions/3126830/query-to-get-records-based-on-radius-in-sqlite is specific to Android "**I can't run custom functions with it as it's on Android**", please un-duplicate this question – we can run custom functions on iOS). – William Denniss Aug 03 '13 at 05:56
  • I think your question is answered by stephencelis here: http://stackoverflow.com/questions/30825513/creating-custom-sqlite-functions-in-swift-alone – Jack Amoratis Jun 14 '15 at 14:46

1 Answers1

0

It looks like this is not part of the standart SQLite: Query to get records based on Radius in SQLite?

Check on SO before :-)

Community
  • 1
  • 1
tiguero
  • 11,477
  • 5
  • 43
  • 61
  • Actually that question is referring to Android, on iOS there are more options available and you don't have to create additional columns. You can add a custom function like so http://daveaddey.com/?p=71 it's really easy to do, and works with your existing structure. – William Denniss Aug 03 '13 at 05:55