android - how to get distance of 2 beacons and make a condtion base on that distance -
I'm trying to figure out what I'm getting at the distance of 2 beacons with ID1D2 And ID3 is for beacon 1 and 2 beacon 2 ... but my code does not work :( ... I'm not good at programming and I do not know how to use most of the functions or methods of Altbikon Do ... can someone help me how to get the beacon distance and that distance of 2 beacons Create a suspension basis on .... Is there any sample code in doing this?
Public ZeroKorangebackConision (collection & lieutenant; beacon> beacon, field area) {if ((Beacon. GetID 3 (.) Equal (identifier. PRSE ("1") and beacon.get diastans () <0.5) & amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; intoinsignues.getDistance () & gt; 5 & amp; amp; amp; & Amp; amp; amp; beacon .getId3 (.) Equal (identifier. PRSE ("2") LogToDisplay ("first floor");}}
This is the math for the distance < pre> var R = 6371; // km var Ï ?? 1 = toRad (Lat1); var Ï ?? 2 = toRad (lat2); Var Î ?? Ï ?? = ToRad ((lat2-lat1)); Var Î ?? Î »= toRad ((lon2-lon1)); Var a = Math.sin (Î ?? Ï ?? / 2) * Math.sin (Î ?? Ï? / 2) + math kos (Ï? 1) * math kos (Ï ?? 2) * math. Sin (Î ?? Î »/ 2) * monastery sin (Î ?? λ / 2); Var c = 2 * Math.atan2 (Math.sqrt (a), Math.sqrt (1-A)); Var D = R * C; // Printing distance K.M. Up to two decimal digits in $ ("# distance") Append (DTOFICKSED (2) + "KM") You will need distance to beacons, save them in one variable and then type something like this var beacon1 = foo var beacon2 = baa if (beacon 1 - beacon2 = lt; = 0.5) {doing something} other {do} something else}
Comments
Post a Comment