Saturday, February 20, 2010

WincFood - Winchester VA - Use Iphone To Automatically Find Restaurants Nearby

With the iPhone 3.0 firmware release, Safari now supports the geolocation API, which can be used to make a website location aware. With that said, wincfood.com's mobile site can now automatically find restaurants near you based on your location.

The mobile website will now prompt you for your current location. If you allow WincFood.com to access your current location, the mobile website will find Winchester Va restaurants that are closest to your location. Kinda cool huh? Maybe not.

Anyway, all of the code behind the "Nearby" feature of mobile.WincFood.com is home grown. We are not using any external mapping or integrating with Google maps like many website use to display geographic information.

Instead we are using MySQL spatial extensions. These extensions allow the generation, storage, and analysis of geographic features. In our case Winchester restaurants.

You may wonder, Why are we stupid enough to do this on our own when Google makes it so easy to integrate maps into a website? The reasons are simple.

1) believe it or not, Google isn't always correct. Don't believe us? go to maps.google.com and search for 8 west cork street, Winchester, VA 22601. This is the address to Cork Street Tavern. Google maps shows that the Cork Street Tavern is on the corner of Loudoun and Cork (not true), it also show that George Washington's office is between Loudoun and Indian Alley (not true), finally it shows that Sweet Caroline's is between Indian Alley and Loudoun (again not true). Google's positions are VERY VERY close. However, they aren't exactly correct. We've eaten in just about every restaurant in Winchester, I
think we know exactly where they are located. If we don't, we can easily find out.

2) MySQL Spatial is free. Why not use it?

3) we are hardcore nerds

So how does it work?
Not all devices have browsers that support the get current location feature. Iphone's safari, google's nexus one browser and Firefox all do. Blackberry's browser does not. Provided that we can get your device's current location, we then query our database. Our database contains geographical information for almost every restaurant in Winchester (work in progress).

Our query determines the distance between your location and all restaurants in Winchester and orders the results closest to farthest from your location.

Things to consider:
Our distances are not 100% accurate for many reasons. So please do not use our distances as a means of navigation.

Here is why:

1) the geolocation that many device web browsers use does not always get the most accurate location. At times, it can be 1/2 mile off or more. We can't guarantee an accurate location. If you have a good signal and an unobstructed view of the sky (not in a building) then we can probably get an accurate location of your device. It is hit or miss.

2) I'm sure your high school geometry teacher taught you that the shortest distance between two points is a straight line, right? How can I break this to you? . . . They lied. Kinda. That is true on a flat surfaces. But on a sphere, the shortest distance between two points is an arch. Last time I checked, we all live on a planet called earth, and guess what, earth is a sphere, and it isn't even a perfect sphere which makes distance calculations even more inaccurate unless handled properly. Soooooo, you guessed it, Winchester Va has a curved surface. Over small distances like 5-10 miles, the curvature of the earth has little affect on distance calculations but the inaccuracy is there none the less.

In addition, there are two methods of computation that can be used to determine distance between two points. Rhumbline (straight line) and great-circle or Ellipsoidal (arched line). WincFood.com's queries use rhumbline, so our distances are going to be slightly off, we know.

Keep in mind, when Google calculates distance between two points, it
uses known routes on roads, we do not. Our method is a straight line, point to point calculation that doesn't factor in roads.

We hope you enjoyed our geek out session. If you have any questions
or suggestions you can contact us on one of the following:

http://www.wincfood.com
http://www.twitter.com/wincfood
http://www.facebook.com/wincfood

3 comments:

JayM said...

Woot! Thanks! This makes the mobile site even more useful!

DJ said...

Very awesome write up!

wincfood.com said...

Thanks guys, we are glad you all liked this. Jay, we hope to have some of the other features that you suggested in the near future. Mobile reviews are now possible.