Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Equivalent of atn function
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01459871
Message ID:
01459981
Vues:
45
Please note that the output of the distance calculation from my blog is in MILES, not kilometers. You may need to convert it to kilometers for your own use.

I spent a considerable amount of time optimizing this UDF for performance. One thing I realized is that the PI() function is slow. Since PI isn't about to change anytime soon, it is faster to simply use a constant. SQL Server has a couple of built in functions to convert from radians to degrees and vice versa.

Select Degrees(3.14159), Radians(180.0)

Unfortunately, these functions are slow too. Don't use them.

There was a suggestion early to store your latitude/longitudes in radians instead of degrees. Presumably, this would allow you to simplify the math. Converting from degrees to radians is "simple" math (multiply or divide by a constant). This operation is going to be extremely fast. The distance calculations use several trigonometry functions, which are the slow part. When people talk about lat/long, it is always in degrees (not radians). I wouldn't suggest changing how these values are stored.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform