Android Question GPS Vs Proximity

Discussion in 'Android Questions' started by DeviousD, May 29, 2015.

Similar threads

B4A Question Help with some b4A Calculations
B4A Code Snippet [B4X] Find distance between two points (Lat/Lon)
B4A Question Deg2Rad
B4A Code Snippet Get panel touch direction
B4A Example Simple Pong Game
  1. DeviousD

    DeviousD Member Licensed User

    Hi

    I have a need to determine the location of other devices in the vicinity on the current device.

    I'm using HTTP push to send current device GPS coords to a mysql database with PHP backend.

    Using this PHP function i can get the distance away from me...

    function haversineGreatCircleDistance(
    $latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, $earthMeanRadius = 6371)
    {
    $deltaLatitude = deg2rad($latitudeTo - $latitudeFrom);
    $deltaLongitude = deg2rad($longitudeTo - $longitudeFrom);
    $a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) +
    cos(deg2rad($latitudeFrom)) * cos(deg2rad(latitudeTo)) *
    sin($deltaLongitude / 2) * sin($deltaLongitude / 2);
    $c = 2 * atan2(sqrt($a), sqrt(1-$a));
    return $earthMeanRadius * $c;
    }

    I can fetch devices that are within a certain distance from my PHP dataservice... but...

    How would i go about getting the bearing of where other devices are in relation to me and then plot them?

    I have used the GPS samples for Other projects and this works to a degree, Not sure the proximity samples will work as I'm not sure how to bring these elements together.

    Any suggestions on how to tackle this?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Let the server return a list of the near devices coordinates. You can then use Location.DistanceTo and BearingTo to find those values.
     
    Peter Simpson likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice