If I want to provide a website with location appropriate content, what ways can I use to find the visitor's rough location using their IP or header information?
[GIS] How to determine the location of a visitor to the website
geolocationmobile
Related Solutions
It sounds like you don't know the signal locations very well, so you need first to estimate them and then, given those estimates, triangulate your position.
If you want some accuracy and realism, consider adopting a likelihood model for the signal strengths, finding the maximum likelihood, and making a gridded map of the location probability computed from the maximum likelihood estimates. The global maximum on the grid identifies the best estimate of the location and the contours (relative to the maximum) give confidence sets for that location.
A general likelihood model is obtained by positing a formula for the signal attenuation and allowing for error. You won't get very far with a completely general formula (with an angle- and location-dependent attenuation function), so you'll have to simplify. For instance, you might consider a "universal" attenuation function, call it f, so that if the source strength at a WiFi location x equals a then the expected strength at another location y is given by
z(y; x) = a f(|y - x|).
For example, you might consider inverse-square attenuation for which f(t) = 1/t^2 provided the distance t is greater than some small threshold. As another simplification, you might take the strength reading z(y;x) at location y for the source at x to differ from the expected value by a normally-distributed error; assume all errors are independent; and assume they all have the same standard deviation (s). The contribution to the log likelihood of a strength reading z then becomes
L(y,x) = -[(z(y;x) - a f(|y-x|)^2 / s^2 + ln(s)]/2.
The log likelihood to be maximized is the double sum of L(y,x) over all locations y and all sources x. It is a function of the unknown locations, the unknown source intensities, and the unknown standard deviation of the errors. It's straightforward to find the optimal standard deviation and optimal source intensities (take partial derivatives, set those to zero, and solve), but for realistic attenuation functions f you have a non-linear problem for finding the locations. However, in your example it involves only 13 parameters so you should be able to dump it into, say, a multivariate Newton-Raphson optimizer and quickly get a good answer. (The statistics literature is full of methods to solve these kinds of equations.)
If you additionally assume the second device has proportionally greater sensitivity than the data-collection device, it will make little difference in the model I have proposed (because the signal strengths enter multiplicatively). In fact, if you let the errors scale with intensity (so they have standard deviation a *s* rather than s) the difference between devices should be inconsequential.
In order to keep this simple I have skipped over some statistical niceties, such as the fact that this is a multivariate prediction interval problem, not a confidence interval problem. If the amount of error is not great (i.e., s is small), the difference will not be of much consequence.
After googling a bit more, I found this paper, Using Wi-Fi for Navigating the Great Indoors. I suppose the algorithm that handles multiple fingerprints, plus compass and accelerometer is what caught Apple's eye.
When a gadget using WiFiSLAM wants to know its location, it analyzes the signal strengths and unique IDs of all the Wi-Fi networks around it. That is matched against a reference data set for the area either accessed over the Internet, or stored on the device. The estimate of location can be sharpened if a gadget moves slightly, because WiFiSLAM's algorithms can gather multiple fingerprints. Compass data and accelerometer signals capturing a person's footsteps are also used to refine the accuracy of subsequent location fixes as a person moves around.
WiFiSLAM needs similar data to be gathered in advance inside a particular building before it can offer location fixes. A person running another special app must walk around a building a few times, entering every room at least once. Algorithms originally developed for robot navigation process the changing pattern of Wi-Fi fingerprints and footsteps to re-create the path the person covered. That trace is then manually associated with a map of the place so that WiFiSLAM can tell a user in that environment where they are.
Edit 2: Also, looks like WifiSlam had a blog that's been removed. However, Google still has it in their cache with some details:
Most recently, WiFiSLAM’s inertial sensor fusion was featured in Grizzly Analytics. It sparked some excellent e-mail discussion with Dr. Bruce Krulwich and we’d love to summarize it for you here!
The demo video includes no maps constraints. It is purely accelerometer, gyroscope, and compass.
We are able to get better-than-typical accuracy because we are taking non-traditional pattern-matching approaches to sensor fusion rather than the conventional “double-integration + Kalman filter” techniques used traditionally.
We held the phone in front of us, trying to mimic a typical smartphone user who is following a map and walking while looking at their phone. Nothing super-specific.
Inertial sensor fusion is now enabled by default as of last week’s releases of the entire WiFiSLAM product line: footprint.io, WiFiSLAM QuickMap, and the Indoor Location SDK. Any user of WiFiSLAM with a gyroscope-enabled smartphone will receive hybrid positioning that uses both our Wi-Fi fingerprinting technology combined with our inertial sensor fusion.
Edit 3 Grizzly analytics provides map setup details in their recent blog post.
WiFiSlam has released a mobile app that enables any smartphone user to take a picture of a map of their indoor site, walk around the site a few times, and have that site work within WiFiSLAM's location positioning system. This app enables much easier crowd-sourcing of indoor maps than Google or others have, and would enable iPhone indoor positioning to spread like wildfire as iPhone fanboys jump to upload their site maps.
Edit 4 Here's a video from the GeoMeetup (kindly posted by Ragi Burhum) where Joseph Huang of WiFiSLAM presents a talk about the underlying algorithms.
Best Answer
Firstly, you should know that the accuracy of these services is, and always will be, low.
MaxMind Geolite city is free. If it is not good enough, you can apparently upgrade to a more accurate paid-version. I can't speak for the quality of the paid version, as I have never used it.
If you like your SQL, download the CSV version. Load it into your database of choice, and query away.
The faster and space-efficient option is to download the file binary blob version of the same database, and then use a language specific API from the same website to query it.
Alternatively, I have found ipinfodb.com to be useful. Query is by simple HTTP GET. For example, to geolocate stackoverflow.com try:
This will return an XML file containing latitude and longitude, that looks like: