how to get distance using Wi-Fi

后端 未结 7 983
悲哀的现实
悲哀的现实 2020-12-29 17:03

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?

相关标签:
7条回答
  • 2020-12-29 17:25

    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.

    0 讨论(0)
  • 2020-12-29 17:26

    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).

    0 讨论(0)
  • 2020-12-29 17:26

    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));
        }
    
    0 讨论(0)
  • 2020-12-29 17:36

    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.

    0 讨论(0)
  • 2020-12-29 17:37

    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.

    0 讨论(0)
  • 2020-12-29 17:43

    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

    0 讨论(0)
提交回复
热议问题