-2

we have large database for search using latitude,longitude and radius. It takes long time for search whole database. we want to search not whole database only search specific area of range. we want to insert area in table using latitude and longitude. pls suggest any idea for fast nearest search technique.

how to find common area using latitude,longitude and radius?

we need to find common area using latitude,longitude and radius for only search that area not whole database search.

1 Answers1

0

Knowing a little basic of trigonometry and MySql, what i suggest to you is to try this solution

SELECT * FROM Places WHERE acos(sin([givenlatitude]) * sin(Lat) + cos([givenlatitude]) * cos(Lat) * cos(Lon - ([givenlongitude]))) * 6371 <= [givenDistance];

Where 6371 is Earth radius.

Lucarnosky
  • 514
  • 4
  • 18
  • we already used this formula but it takes time for fetch result. we want to search not whole database only nearest area range – user3471502 Oct 23 '15 at 13:13
  • SELECT vb.id, vk.keyword, vb.business_address, ( 6371 * ACOS( COS( RADIANS( 28.684342 ) ) * COS( RADIANS( vb.latitude ) ) * COS( RADIANS( vb.longitude ) - RADIANS( 77.137941 ) ) + SIN( RADIANS( 28.684342 ) ) * SIN( RADIANS( vb.latitude ) ) ) ) AS distance FROM vendor_businesses vb, vendors_keyword vk WHERE vk.vender_id = vb.vendor_id AND vk.keyword_id=3258 HAVING distance <10 – user3471502 Oct 23 '15 at 13:16