Wednesday, August 12, 2015

GEO-Search - Faster approch between two point


Previous post, I port the calculation and formula from Federico

My search bring me another solution, which is more faster than previous ->

Below it is, [This one calculate for Kilometre]
  
struct arg_max_min_lo_lt

{
    double min_long;

    double min_lat;

    double max_long;

    double max_lat;
}; 

struct arg_max_min_lo_lt get_lo_lt_values()

{

        int eRadius = 12742;

        float radius=5;

        struct arg_max_min_lo_lt m_lo_lt_ptr;

        //each degree of lon or lat is approximately 69 miles or 111 kilometres difference

        double denominator = cos(deg2rad(curr_lat)) * 111;

        m_lo_lt_ptr.min_long = curr_long - (radius / denominator );

        m_lo_lt_ptr.max_long = curr_long + (radius / denominator );

        m_lo_lt_ptr.min_lat = curr_lat - (double)radius / 111;

        m_lo_lt_ptr.max_lat = curr_lat + (double)radius / 111;

        return m_lo_lt_ptr;

}

No comments:

Post a Comment