Solved

LATITUDE AND LONGITUDE

Posted on 2014-09-15
8
202 Views
Last Modified: 2014-09-15
Hello,

How do I add, and substract 1 mile for a given latitude? And 1 mile to a given longitude?

Thanks!
0
Comment
Question by:SimpleDude
  • 3
  • 3
  • 2
8 Comments
 
LVL 27

Expert Comment

by:d-glitch
ID: 40323401
Latitude is easy.  Longitude is more complicated.

    http://www.answers.com/Q/How_many_miles_are_in_a_degree_of_longitude_or_latitude
0
 
LVL 84

Accepted Solution

by:
ozo earned 400 total points
ID: 40323405
latitude + 0.014457
longitude + 0.014481/cos(latitude)
0
 
LVL 27

Assisted Solution

by:d-glitch
d-glitch earned 100 total points
ID: 40323417
And you need to be careful at the boundaries:  the N and S poles, the equator, the prime (0 deg) meridian and its opposite (180 deg).
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

Author Comment

by:SimpleDude
ID: 40323426
Hi guys, I just need to select X number of records within a Lat and Long range.

I was using this formula, but it drastically decreases the server performance:

  (ACOS(SIN(47.988594 * PI() / 180) * SIN(dbo.ADDRESSES.latitude * PI() / 180) + COS(47.988594 * PI() / 180) * COS(dbo.ADDRESSES.latitude * PI()
                      / 180) * COS((- 122.201789 - dbo.ADDRESSES.longitude) * PI() / 180)) * 180 / PI() * 60 * 1.1515 BETWEEN 0 AND @distance
0
 
LVL 27

Expert Comment

by:d-glitch
ID: 40323453
How big is the data base?  Is it sorted in any way?
What units are used in the database?  Degrees or radians?
You should search in the same units the data base uses.  Save a lot on conversions.

This   (SIN(47.988594 * PI() / 180)  (and several similar terms) are constants.  
You only have to calculate them once.

Is this related to the nearest k restaurants problem?
0
 

Author Comment

by:SimpleDude
ID: 40323466
Something like that. The point of origin (lat-long) changes constantly, that's why I cannot calculate it just once.
0
 
LVL 84

Expert Comment

by:ozo
ID: 40323474
If the restaurants are in a small area, it may be preferable to convert the latitudes and longitudes into a flat grid to make distance calculations easier.
If the restaurants are in a large area where a flat approximation would be inaccurate, it may be preferable to convert into a 3-d orthogonal coordinate system to make distance calculations easier.
0
 

Author Closing Comment

by:SimpleDude
ID: 40323557
Thanks guys
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
How to Win a Jar of Candy Corn: A Scientific Approach! I love mathematics. If you love mathematics also, you may enjoy this tip on how to use math to win your own jar of candy corn and to impress your friends. As I said, I love math, but I gu…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question