Solved

LATITUDE AND LONGITUDE

Posted on 2014-09-15
8
199 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
 

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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! https://www.google.com/about/careers/students/guide-to-technical-development.html How to Know You are Making a Difference at EE In August, 2013, one …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now