views:

2884

answers:

7

I want to find the distance using wi-fi and plot the marker on map in iPhone.

So any idea or code i can get for that?

A: 

It is not possible to get an accurate distance (in meters or feet) to an access point by just using the signal-strength from your network card.

Espo
how can i locate my position on map using wifi?
A classic already :P
borisCallens
@Espo: Don't spread lies. I just got a measuring tape and measured the distance, and therefore I proved it *is* possible to get the distance to an access point.
dreamlax
You can also use proximity. If the access point has a known position, being able to reach it puts you within (range of wifi) distance from AP position.
andy
Meters / foot?
MusiGenesis
A: 

Possibly you will be able to get a rough distance using 3 or more access points. Now there is a technique to get the distance to a mobile subscriber using 3 GSM mobile base stations.

Chathuranga Chandrasekara
but if i am using iPod then how can i get my position cause in iPod only Wifi is present...
do u have any code that will give distance using GSM mobile stations?
A: 

Using the recieved power you can work out the distance using a rf propagation model from an emitter to a reciever. However, it sounds like you want the location, not just the distance.

Free-space Path Loss Model:

http://en.wikipedia.org/wiki/Free-space_path_loss

monkut
Possible, but building a model that takes into account the effect of obstructions etc, is damn near impossible. These obstructions are usually moving, too.
andy
Yup, I didn't say it was practical. Nothings 100% accurate anyway.
monkut
+2  A: 

Upon first reading your question, i was under the assumption you were referring to distance to an access point. After writing a bunch about that, i realized you might mean something else. In case that is what you mean, keep reading...

Given your configuration:

  • a single fixed receiver (your phone doesn't have to be fixed, but it is effectively fixed if you're looking for instantaneous measurements)
  • a single fixed base station (the access point)
  • an omnidirectional antenna on the receiver
  • 802.11 b/g protocol

This cannot be done. Even if you were working at the PHY level, this is an impossible problem to solve. To make it slightly more feasible, you need to triangulate the position of your receiver relative to two (but preferably more) base stations. Even then this is still a hard problem. RF waves travel at the speed of light, so using relay techniques to measure round-trip signal propagation delay won't give good accuracy (the receivers have to operate extremely fast, and then there's multipath problems...). Again, this is all assuming you're basically building your own RF hardware, which obviously you're not about to do for the iPhone.

Your best bet to track down the location of a base station is to record the WiFi signal strength as you change the position of the phone. By 'change the position', you would essentially have to sweep around the area. With some good heuristics, and robustness to handle non-distance related signal degradation, you could achieve decent accuracy (probably on the order of 10 meters).

Bill
This is only partly true. You can also look at lateration, that is trying to measure the distance to access point based on signal strength. This implies that signal strength attenuates along some known formula. That can be difficult, but not impossible. Look into Microsoft Research's "Radar".
andy
+1  A: 

Use Apple's CoreLocation framework, it can give you the coordinates of your location. I can't link to it as I don't have access to the iPhone documentation.

Georg
A: 

What are you trying to achieve here?

If you are trying to plot your position on a map using the Iphone then this feature is already a part of the Iphone which has a GPS receiver and will do that "out of the box".

If you are trying to find the position of your laptop using wifi and send that location to an iphone then you have quite a difficult problem to solve that is probably not doable without a lot of work.

There are facilities to enable you to triangulate your position from GSM masts but these are in fixed positions with know lat/longs. Wifi Access points do not have a database of geographical locations so triangulating from those will be very difficult/impossible.

You can use 3rd party services such as this to track your position using GSM however these are wildly inaccurate unless you are in a large city and would require you having a GSM modem in whatever it is you are tracking.

Steve Weet
A: 

Here http://www.mathforum.com/library/drmath/view/51711.html you can find equations to calculate distance between two locations from GPS. This is a C# code I created upon this (it’s scaled to metric system)

    private double Distance(GpsPosition p1, GpsPosition p2)
    {
        // http://www.mathforum.com/library/drmath/view/51711.html

        double A = p1.Latitude / 57.29577951;
        double B = p1.Longitude / 57.29577951;
        double C = p2.Latitude / 57.29577951;
        double D = p2.Longitude / 57.29577951;

        if((A==C) && (B==D))
            return 0;

        if((Math.Sin(A)*Math.Sin(C)+Math.Cos(A)*Math.Cos(C)*Math.Cos(B-D)) > 1.0)
            return 6372.72 * Math.Acos(1);
        else
            return 6372.72 * Math.Acos(Math.Sin(A) * Math.Sin(C) + Math.Cos(A) * Math.Cos(C) * Math.Cos(B - D));
    }
michael
and this is usefull why? How should he know the GPS location of the acces point?
PoweRoy