From the course: PHP Tips, Tricks, and Techniques

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Shortest distance between two locations

Shortest distance between two locations

From the course: PHP Tips, Tricks, and Techniques

Shortest distance between two locations

- [David Powers] Hi, I'm David Powers, and welcome to this week's edition of PHP tips, tricks, and techniques designed to help you become a smarter, more productive PHP developer. This week's technique is finding the shortest distance between two locations. If you're wondering, why bother, there are several really practical applications for this technique on the web. You could use it to show users the closest delivery point to drop off or pick up packages. Or how about the closest pizza store? And I've used it to develop an app to find parking lots within a given radius. Hopefully, that's whetted your appetite. So how do we go about it? As satellite technology and space travel have confirmed, the Earth is round, not perfectly so, but close enough. And as you probably know, drawing a straight line between two locations isn't the shortest route. To get the shortest distance, you need to follow the curvature of the Earth, and that's where some pretty horrendous calculations come in…

Contents