GPS Positioning and query of locations near latitude and longitude-C # Implementation Method

Source: Internet
Author: User
Tags asin sql 2008

The database records the longitude and latitude dimensions (for example, 116.412007, 39.947545) marked by sellers on Baidu ),

The original idea is to take the center of the center point as the center point and cycle the radius. Every time a pixel is added to the radius (tentatively 1 meter), the circle is made again, query the merchants of corresponding points in the database (it is a long cycle)

Similar articles on Baidu have a look

The general idea is to know a central point, a radius, and find the circle containing all the points in the parabolic circle. In this way, we need to know the vertex of the diagonal line of the circle, the problem is that the longitude and latitude are a point, and the radius is a distance.

Finally find the desired article

Http://digdeeply.org/archives/06152067.html

Refer to the original article lz to change to C # class

Code is not too much nonsense:

                                 Degree( x,               X =             Y =                                     {               { x =                                     {               { y =                       EARTH_RADIUS = ;                                                              radians(               d * Math.PI /                                                                degrees(               d * ( /                                                          radLat1 =              radLat2 =              a = radLat1 -              b = radians(Degree1.Y) -               s =  * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin(a / ), ) +              Math.Cos(radLat1) * Math.Cos(radLat2) * Math.Pow(Math.Sin(b / ),              s = s *             s = Math.Round(s * ) /                                                                       radLat1 =              radLng1 =              radLat2 =              radLng2 =               s = Math.Acos(Math.Cos(radLat1) * Math.Cos(radLat2) * Math.Cos(radLng1 - radLng2) + Math.Sin(radLat1) *             s = s *             s = Math.Round(s * ) /                                                                            Degree[] GetDegreeCoordinates(Degree Degree1,                dlng =  * Math.Asin(Math.Sin(distance / ( * EARTH_RADIUS)) /             dlng = degrees(dlng);               dlat = distance /             dlat = degrees(dlat);                Degree[] {  Degree(Math.Round(Degree1.X + dlat,), Math.Round(Degree1.Y - dlng,)),                                    Degree(Math.Round(Degree1.X - dlat,), Math.Round(Degree1.Y - dlng,)),                                    Degree(Math.Round(Degree1.X + dlat,), Math.Round(Degree1.Y + dlng,)),                                    Degree(Math.Round(Degree1.X - dlat,), Math.Round(Degree1.Y + dlng,))         }

 

Test method:

    Main(               a = CoordDispose.GetDistance( Degree(, ),  Degree(, ));              b = CoordDispose.GetDistanceGoogle( Degree(, ),  Degree(,              Degree[] dd = CoordDispose.GetDegreeCoordinates( Degree(, ),              Console.WriteLine(a+ +             Console.WriteLine(dd[].X +  + dd[             Console.WriteLine(dd[].X +  + dd[          }

 

Lz tried many times with an error of about 1 meter.

It's easy to get the vertices of the circle.

If the database uses SQL 2008, it can directly index the latitude and longitude fields of the space, which should provide better performance (not tried)

It doesn't matter if the lz company's database is still 2005 old. The key is to split computing by latitude and longitude. This doesn't need to be said. There are many SQL statements on the Internet that were last implemented.

SELECT id,zuobiao FROM dbo.zuobiao WHERE zuobiao<>,)>,)<,)<,)>

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.